Skip to content

Commit 91d6cdb

Browse files
Tecvan-feCopilot
andauthored
chore: auto generate vscode settings for first time install (#388)
Co-authored-by: Copilot <[email protected]>
1 parent 6ee7ccb commit 91d6cdb

File tree

6 files changed

+300
-2
lines changed

6 files changed

+300
-2
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ output/*
3333
*.swp
3434

3535
# Vscode files
36-
.vscode
36+
.vscode/settings.json
3737

3838
/patches
3939
/oldimpl

.vscode/extensions.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"recommendations": [
3+
"editorconfig.editorconfig",
4+
"esbenp.prettier-vscode",
5+
"streetsidesoftware.code-spell-checker",
6+
"codezombiech.gitignore",
7+
"aaron-bond.better-comments",
8+
"mikestead.dotenv",
9+
"stylelint.vscode-stylelint"
10+
],
11+
"unwantedRecommendations": [
12+
"nucllear.vscode-extension-auto-import",
13+
"steoates.autoimport"
14+
]
15+
}

.vscode/settings.template.json

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
"eslint.nodePath": "frontend/config/eslint-config/node_modules/eslint",
3+
"prettier.prettierPath": "frontend/config/eslint-config/node_modules/prettier",
4+
"editor.tabSize": 2,
5+
"editor.insertSpaces": true,
6+
"editor.formatOnSave": true,
7+
"editor.formatOnType": false,
8+
"editor.formatOnPaste": false,
9+
"editor.defaultFormatter": "esbenp.prettier-vscode",
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll": "never",
12+
"source.fixAll.eslint": "never",
13+
"source.removeUnused": "never",
14+
"source.organizeImports": "never"
15+
// "source.sortImports": "always"
16+
},
17+
"editor.formatOnSaveMode": "modificationsIfAvailable",
18+
"search.followSymlinks": false,
19+
"search.exclude": {
20+
"**/node_modules": true,
21+
"**/.nyc_output": true,
22+
"**/.rush": true,
23+
"**/pnpm-lock.yaml": true,
24+
"**/CHANGELOG.json": true,
25+
"**/CHANGELOG.md": true,
26+
"common/changes": true,
27+
"**/output": true,
28+
"**/lib": true,
29+
"**/rush-logs": true,
30+
"**/dist": true,
31+
"**/coverage": true,
32+
"common/temp": true
33+
},
34+
"eslint.workingDirectories": [
35+
{
36+
"mode": "auto"
37+
}
38+
],
39+
"files.defaultLanguage": "plaintext",
40+
"files.associations": {
41+
".code-workspace": "jsonc",
42+
".babelrc": "json",
43+
".eslintrc": "jsonc",
44+
".eslintrc*.json": "jsonc",
45+
".stylelintrc": "javascript",
46+
"stylelintrc": "jsonc",
47+
"*.json": "jsonc",
48+
"package.json": "json",
49+
".htmlhintrc": "jsonc",
50+
"htmlhintrc": "jsonc",
51+
"Procfile*": "shellscript",
52+
"README": "markdown",
53+
"**/coverage/**/*.*": "plaintext",
54+
"OWNERS": "yaml",
55+
// Set the pnpm-lock file to plaintext to avoid parsing; otherwise, VSCode may freeze when opening the file
56+
"**/pnpm-lock.yaml": "plaintext",
57+
"**/dist/**": "plaintext",
58+
"**/dist_*/**": "plaintext",
59+
"*.map": "plaintext",
60+
"*.log": "plaintext"
61+
},
62+
"files.exclude": {
63+
"**/.git": true,
64+
"**/.svn": true,
65+
"**/.hg": true,
66+
"**/CVS": true,
67+
"**/.DS_Store": true,
68+
"**/Thumbs.db": true,
69+
"**/.rush": true,
70+
"**/.swc": true
71+
},
72+
"files.watcherExclude": {
73+
"**/.git/objects/**": true,
74+
"**/.git/subtree-cache/**": true,
75+
"**/node_modules/*/**": true
76+
},
77+
"search.useIgnoreFiles": true,
78+
//
79+
"editor.rulers": [80, 120],
80+
"files.eol": "\n",
81+
"files.trimTrailingWhitespace": true,
82+
"files.insertFinalNewline": true,
83+
"cSpell.diagnosticLevel": "Warning",
84+
"eslint.probe": [
85+
"javascript",
86+
"javascriptreact",
87+
"typescript",
88+
"typescriptreact"
89+
],
90+
"editor.semanticHighlighting.enabled": false,
91+
"eslint.format.enable": false,
92+
"eslint.enable": true,
93+
"eslint.useFlatConfig": true,
94+
"eslint.codeActionsOnSave.mode": "problems",
95+
"eslint.lintTask.enable": false,
96+
"javascript.validate.enable": false,
97+
"typescript.tsdk": "frontend/config/ts-config/node_modules/typescript/lib",
98+
"typescript.enablePromptUseWorkspaceTsdk": true,
99+
"typescript.disableAutomaticTypeAcquisition": true,
100+
"typescript.format.enable": false,
101+
"typescript.referencesCodeLens.enabled": false,
102+
"typescript.preferGoToSourceDefinition": true,
103+
"typescript.updateImportsOnFileMove.enabled": "never",
104+
// tsserver logs are not automatically deleted and accumulate over time, causing disk space issues, so disabled by default
105+
"typescript.tsserver.log": "off",
106+
"typescript.tsserver.experimental.enableProjectDiagnostics": false,
107+
"typescript.workspaceSymbols.excludeLibrarySymbols": true,
108+
"editor.minimap.enabled": true,
109+
"typescript.preferences.includePackageJsonAutoImports": "off",
110+
"typescript.suggest.autoImports": true,
111+
"typescript.tsserver.maxTsServerMemory": 10240,
112+
"typescript.tsserver.enableRegionDiagnostics": false,
113+
"typescript.tsserver.watchOptions": {
114+
"fallbackPolling": "dynamicPriorityPolling",
115+
"synchronousWatchDirectory": true,
116+
"watchDirectory": "useFsEvents",
117+
"watchFile": "useFsEventsOnParentDirectory",
118+
"excludeDirectories": ["/**/node_modules"],
119+
"excludeLibrarySymbols": true,
120+
"excludeFiles": ["/**/node_modules/**"]
121+
},
122+
"css.validate": false,
123+
"scss.validate": false,
124+
"less.validate": false,
125+
"stylelint.enable": true,
126+
"stylelint.validate": ["css", "scss", "less"],
127+
"stylelint.stylelintPath": "frontend/config/stylelint-config/node_modules/stylelint",
128+
"emmet.triggerExpansionOnTab": true,
129+
"[typescript]": {
130+
"editor.defaultFormatter": "esbenp.prettier-vscode"
131+
},
132+
"[yaml]": {
133+
"editor.defaultFormatter": "esbenp.prettier-vscode"
134+
},
135+
"[css]": {
136+
"editor.defaultFormatter": "esbenp.prettier-vscode"
137+
},
138+
"[html]": {
139+
"editor.defaultFormatter": "esbenp.prettier-vscode"
140+
},
141+
"[javascript]": {
142+
"editor.defaultFormatter": "esbenp.prettier-vscode"
143+
},
144+
"[javascriptreact]": {
145+
"editor.defaultFormatter": "esbenp.prettier-vscode"
146+
},
147+
"[json]": {
148+
"editor.defaultFormatter": "esbenp.prettier-vscode"
149+
},
150+
"[jsonc]": {
151+
"editor.defaultFormatter": "esbenp.prettier-vscode"
152+
},
153+
"[less]": {
154+
"editor.defaultFormatter": "stylelint.vscode-stylelint"
155+
},
156+
"[scss]": {
157+
"editor.defaultFormatter": "esbenp.prettier-vscode"
158+
},
159+
"[typescriptreact]": {
160+
"editor.defaultFormatter": "esbenp.prettier-vscode"
161+
},
162+
"[ignore]": {
163+
"editor.defaultFormatter": "foxundermoon.shell-format"
164+
},
165+
"[shellscript]": {
166+
"editor.defaultFormatter": "foxundermoon.shell-format"
167+
},
168+
"[dotenv]": {
169+
"editor.defaultFormatter": "foxundermoon.shell-format"
170+
},
171+
"[svg]": {
172+
"editor.defaultFormatter": "jock.svg"
173+
},
174+
"svg.preview.background": "white",
175+
"[xml]": {
176+
"editor.defaultFormatter": "mblode.pretty-formatter"
177+
},
178+
"[sql]": {
179+
"editor.defaultFormatter": "adpyke.vscode-sql-formatter"
180+
},
181+
"git.openRepositoryInParentFolders": "always",
182+
"references.preferredLocation": "view"
183+
}

rush.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"repository": {},
1414
"eventHooks": {
1515
"preRushInstall": [],
16-
"postRushInstall": [],
16+
"postRushInstall": ["scripts/hooks/post-rush-install.sh"],
1717
"preRushBuild": [],
1818
"postRushBuild": []
1919
},

scripts/hooks/post-rush-install.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2025 coze-dev Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
19+
set -e
20+
21+
# Get script directory
22+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23+
24+
# Setup VSCode settings if needed
25+
bash "$SCRIPT_DIR/setup-vscode-settings.sh"
26+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2025 coze-dev Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
19+
# Script to ensure .vscode/settings.json exists by copying from template
20+
# This script creates default VSCode settings if none exist
21+
22+
set -e
23+
24+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
25+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
26+
VSCODE_DIR="$PROJECT_ROOT/.vscode"
27+
SETTINGS_FILE="$VSCODE_DIR/settings.json"
28+
TEMPLATE_FILE="$VSCODE_DIR/settings.template.json"
29+
30+
# Function to log messages (only when VERBOSE=true)
31+
log() {
32+
if [[ "${VERBOSE:-false}" == "true" ]]; then
33+
echo "[setup-vscode-settings] $1"
34+
fi
35+
}
36+
37+
# Create .vscode directory if it doesn't exist
38+
if [[ ! -d "$VSCODE_DIR" ]]; then
39+
log "Creating .vscode directory..."
40+
mkdir -p "$VSCODE_DIR"
41+
fi
42+
43+
# Check if settings.json exists
44+
if [[ ! -f "$SETTINGS_FILE" ]]; then
45+
log "settings.json not found"
46+
47+
# Check if template file exists
48+
if [[ -f "$TEMPLATE_FILE" ]]; then
49+
log "Copying settings.template.json to settings.json..."
50+
cp "$TEMPLATE_FILE" "$SETTINGS_FILE"
51+
log "✓ settings.json created from template"
52+
else
53+
log "Warning: settings.template.json not found, creating minimal settings.json..."
54+
55+
# Create a minimal settings.json if template doesn't exist
56+
cat > "$SETTINGS_FILE" << 'EOF'
57+
{
58+
"search.exclude": {
59+
"**/node_modules": true,
60+
"**/common/temp": true,
61+
"**/.rush": true
62+
},
63+
"files.exclude": {
64+
"**/node_modules": true,
65+
"**/common/temp": true,
66+
"**/.rush": true
67+
}
68+
}
69+
EOF
70+
log "✓ Minimal settings.json created"
71+
fi
72+
else
73+
log "settings.json already exists, skipping..."
74+
fi

0 commit comments

Comments
 (0)