chore: auto generate vscode settings for first time install (#388)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
main
tecvan 3 months ago committed by GitHub
parent 6ee7ccb019
commit 91d6cdb430
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .gitignore
  2. 15
      .vscode/extensions.json
  3. 183
      .vscode/settings.template.json
  4. 2
      rush.json
  5. 26
      scripts/hooks/post-rush-install.sh
  6. 74
      scripts/hooks/setup-vscode-settings.sh

2
.gitignore vendored

@ -33,7 +33,7 @@ output/*
*.swp *.swp
# Vscode files # Vscode files
.vscode .vscode/settings.json
/patches /patches
/oldimpl /oldimpl

@ -0,0 +1,15 @@
{
"recommendations": [
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"codezombiech.gitignore",
"aaron-bond.better-comments",
"mikestead.dotenv",
"stylelint.vscode-stylelint"
],
"unwantedRecommendations": [
"nucllear.vscode-extension-auto-import",
"steoates.autoimport"
]
}

@ -0,0 +1,183 @@
{
"eslint.nodePath": "frontend/config/eslint-config/node_modules/eslint",
"prettier.prettierPath": "frontend/config/eslint-config/node_modules/prettier",
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": "never",
"source.fixAll.eslint": "never",
"source.removeUnused": "never",
"source.organizeImports": "never"
// "source.sortImports": "always"
},
"editor.formatOnSaveMode": "modificationsIfAvailable",
"search.followSymlinks": false,
"search.exclude": {
"**/node_modules": true,
"**/.nyc_output": true,
"**/.rush": true,
"**/pnpm-lock.yaml": true,
"**/CHANGELOG.json": true,
"**/CHANGELOG.md": true,
"common/changes": true,
"**/output": true,
"**/lib": true,
"**/rush-logs": true,
"**/dist": true,
"**/coverage": true,
"common/temp": true
},
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"files.defaultLanguage": "plaintext",
"files.associations": {
".code-workspace": "jsonc",
".babelrc": "json",
".eslintrc": "jsonc",
".eslintrc*.json": "jsonc",
".stylelintrc": "javascript",
"stylelintrc": "jsonc",
"*.json": "jsonc",
"package.json": "json",
".htmlhintrc": "jsonc",
"htmlhintrc": "jsonc",
"Procfile*": "shellscript",
"README": "markdown",
"**/coverage/**/*.*": "plaintext",
"OWNERS": "yaml",
// Set the pnpm-lock file to plaintext to avoid parsing; otherwise, VSCode may freeze when opening the file
"**/pnpm-lock.yaml": "plaintext",
"**/dist/**": "plaintext",
"**/dist_*/**": "plaintext",
"*.map": "plaintext",
"*.log": "plaintext"
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.rush": true,
"**/.swc": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
},
"search.useIgnoreFiles": true,
//
"editor.rulers": [80, 120],
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"cSpell.diagnosticLevel": "Warning",
"eslint.probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"editor.semanticHighlighting.enabled": false,
"eslint.format.enable": false,
"eslint.enable": true,
"eslint.useFlatConfig": true,
"eslint.codeActionsOnSave.mode": "problems",
"eslint.lintTask.enable": false,
"javascript.validate.enable": false,
"typescript.tsdk": "frontend/config/ts-config/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.disableAutomaticTypeAcquisition": true,
"typescript.format.enable": false,
"typescript.referencesCodeLens.enabled": false,
"typescript.preferGoToSourceDefinition": true,
"typescript.updateImportsOnFileMove.enabled": "never",
// tsserver logs are not automatically deleted and accumulate over time, causing disk space issues, so disabled by default
"typescript.tsserver.log": "off",
"typescript.tsserver.experimental.enableProjectDiagnostics": false,
"typescript.workspaceSymbols.excludeLibrarySymbols": true,
"editor.minimap.enabled": true,
"typescript.preferences.includePackageJsonAutoImports": "off",
"typescript.suggest.autoImports": true,
"typescript.tsserver.maxTsServerMemory": 10240,
"typescript.tsserver.enableRegionDiagnostics": false,
"typescript.tsserver.watchOptions": {
"fallbackPolling": "dynamicPriorityPolling",
"synchronousWatchDirectory": true,
"watchDirectory": "useFsEvents",
"watchFile": "useFsEventsOnParentDirectory",
"excludeDirectories": ["/**/node_modules"],
"excludeLibrarySymbols": true,
"excludeFiles": ["/**/node_modules/**"]
},
"css.validate": false,
"scss.validate": false,
"less.validate": false,
"stylelint.enable": true,
"stylelint.validate": ["css", "scss", "less"],
"stylelint.stylelintPath": "frontend/config/stylelint-config/node_modules/stylelint",
"emmet.triggerExpansionOnTab": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "stylelint.vscode-stylelint"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dotenv]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[svg]": {
"editor.defaultFormatter": "jock.svg"
},
"svg.preview.background": "white",
"[xml]": {
"editor.defaultFormatter": "mblode.pretty-formatter"
},
"[sql]": {
"editor.defaultFormatter": "adpyke.vscode-sql-formatter"
},
"git.openRepositoryInParentFolders": "always",
"references.preferredLocation": "view"
}

@ -13,7 +13,7 @@
"repository": {}, "repository": {},
"eventHooks": { "eventHooks": {
"preRushInstall": [], "preRushInstall": [],
"postRushInstall": [], "postRushInstall": ["scripts/hooks/post-rush-install.sh"],
"preRushBuild": [], "preRushBuild": [],
"postRushBuild": [] "postRushBuild": []
}, },

@ -0,0 +1,26 @@
#!/bin/bash
#
# Copyright 2025 coze-dev Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Setup VSCode settings if needed
bash "$SCRIPT_DIR/setup-vscode-settings.sh"

@ -0,0 +1,74 @@
#!/bin/bash
#
# Copyright 2025 coze-dev Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to ensure .vscode/settings.json exists by copying from template
# This script creates default VSCode settings if none exist
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
VSCODE_DIR="$PROJECT_ROOT/.vscode"
SETTINGS_FILE="$VSCODE_DIR/settings.json"
TEMPLATE_FILE="$VSCODE_DIR/settings.template.json"
# Function to log messages (only when VERBOSE=true)
log() {
if [[ "${VERBOSE:-false}" == "true" ]]; then
echo "[setup-vscode-settings] $1"
fi
}
# Create .vscode directory if it doesn't exist
if [[ ! -d "$VSCODE_DIR" ]]; then
log "Creating .vscode directory..."
mkdir -p "$VSCODE_DIR"
fi
# Check if settings.json exists
if [[ ! -f "$SETTINGS_FILE" ]]; then
log "settings.json not found"
# Check if template file exists
if [[ -f "$TEMPLATE_FILE" ]]; then
log "Copying settings.template.json to settings.json..."
cp "$TEMPLATE_FILE" "$SETTINGS_FILE"
log "✓ settings.json created from template"
else
log "Warning: settings.template.json not found, creating minimal settings.json..."
# Create a minimal settings.json if template doesn't exist
cat > "$SETTINGS_FILE" << 'EOF'
{
"search.exclude": {
"**/node_modules": true,
"**/common/temp": true,
"**/.rush": true
},
"files.exclude": {
"**/node_modules": true,
"**/common/temp": true,
"**/.rush": true
}
}
EOF
log "✓ Minimal settings.json created"
fi
else
log "settings.json already exists, skipping..."
fi
Loading…
Cancel
Save