Skip to content

Commit eddec80

Browse files
authored
chore(settings): remove core/package.json dependency (#5340)
Settings are instead auto-generated from each extension package.json. This allows us to keep compile-time checks.
1 parent efad3c2 commit eddec80

File tree

7 files changed

+344
-10
lines changed

7 files changed

+344
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ __pycache__
2020

2121
# Auto generated definitions
2222
packages/*/src/**/*.gen.ts
23+
!packages/core/src/shared/settings-*.gen.ts
2324
src.gen/*
2425

2526
# Test reports

packages/amazonq/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"browser": "./dist/src/extensionWeb",
4747
"scripts": {
4848
"vscode:prepublish": "npm run clean && npm run buildScripts && webpack --mode production",
49-
"buildScripts": "npm run generateNonCodeFiles && npm run copyFiles && npm run syncPackageJson && tsc -p ./ --noEmit",
49+
"buildScripts": "npm run generateNonCodeFiles && npm run copyFiles && npm run generateSettings && npm run syncPackageJson && tsc -p ./ --noEmit",
5050
"generateNonCodeFiles": "ts-node ../../scripts/generateNonCodeFiles.ts",
5151
"copyFiles": "ts-node ./scripts/build/copyFiles.ts",
5252
"syncPackageJson": "ts-node ./scripts/build/syncPackageJson.ts",
@@ -63,7 +63,8 @@
6363
"webWatch": "npm run clean && npm run buildScripts && webpack --mode development --watch",
6464
"serve": "webpack serve --config-name mainServe --mode development",
6565
"newChange": "ts-node ../../scripts/newChange.ts",
66-
"createRelease": "ts-node ../../scripts/createRelease.ts"
66+
"createRelease": "ts-node ../../scripts/createRelease.ts",
67+
"generateSettings": "ts-node ../../scripts/generateSettings.ts"
6768
},
6869
"dependencies": {
6970
"aws-core-vscode": "file:../core/"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* This file was autogenerated by generateSettings.ts. Do NOT modify by hand.
8+
* To update this file, update the settings in the extension package.json
9+
* and run `npm run generateSettings` for that extension.
10+
*/
11+
12+
export const amazonqSettings = {
13+
"amazonQ.telemetry": {},
14+
"amazonQ.suppressPrompts": {
15+
"createCredentialsProfile": {},
16+
"codeWhispererNewWelcomeMessage": {},
17+
"codeWhispererConnectionExpired": {},
18+
"amazonQWelcomePage": {}
19+
},
20+
"amazonQ.showInlineCodeSuggestionsWithCodeReferences": {},
21+
"amazonQ.importRecommendationForInlineCodeSuggestions": {},
22+
"amazonQ.shareContentWithAWS": {},
23+
"amazonQ.workspaceIndex": {},
24+
"amazonQ.workspaceIndexWorkerThreads": {},
25+
"amazonQ.workspaceIndexUseGPU": {},
26+
"amazonQ.workspaceIndexMaxSize": {}
27+
}
28+
29+
export default amazonqSettings
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* This file was autogenerated by generateSettings.ts. Do NOT modify by hand.
8+
* To update this file, update the settings in the extension package.json
9+
* and run `npm run generateSettings` for that extension.
10+
*/
11+
12+
export const toolkitSettings = {
13+
"aws.profile": {},
14+
"aws.ecs.openTerminalCommand": {},
15+
"aws.iot.maxItemsPerPage": {},
16+
"aws.s3.maxItemsPerPage": {},
17+
"aws.samcli.location": {},
18+
"aws.samcli.lambdaTimeout": {},
19+
"aws.samcli.legacyDeploy": {},
20+
"aws.telemetry": {},
21+
"aws.stepfunctions.asl.format.enable": {},
22+
"aws.stepfunctions.asl.maxItemsComputed": {},
23+
"aws.ssmDocument.ssm.maxItemsComputed": {},
24+
"aws.cwl.limit": {},
25+
"aws.samcli.manuallySelectedBuckets": {},
26+
"aws.samcli.enableCodeLenses": {},
27+
"aws.suppressPrompts": {
28+
"apprunnerNotifyPricing": {},
29+
"apprunnerNotifyPause": {},
30+
"ecsRunCommand": {},
31+
"ecsRunCommandEnable": {},
32+
"ecsRunCommandDisable": {},
33+
"regionAddAutomatically": {},
34+
"yamlExtPrompt": {},
35+
"fileViewerEdit": {},
36+
"createCredentialsProfile": {},
37+
"samcliConfirmDevStack": {},
38+
"remoteConnected": {},
39+
"codeCatalystConnectionExpired": {}
40+
},
41+
"aws.experiments": {
42+
"jsonResourceModification": {}
43+
},
44+
"aws.resources.enabledResources": {},
45+
"aws.lambda.recentlyUploaded": {},
46+
"aws.accessAnalyzer.policyChecks.checkNoNewAccessFilePath": {},
47+
"aws.accessAnalyzer.policyChecks.checkAccessNotGrantedFilePath": {},
48+
"aws.accessAnalyzer.policyChecks.cloudFormationParameterFilePath": {}
49+
}
50+
51+
export default toolkitSettings

packages/core/src/shared/settings.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as vscode from 'vscode'
77
import * as codecatalyst from './clients/codecatalystClient'
88
import * as codewhisperer from '../codewhisperer/client/codewhisperer'
9-
import packageJson from '../../package.json'
109
import { getLogger } from './logger'
1110
import {
1211
cast,
@@ -22,6 +21,8 @@ import { once, onceChanged } from './utilities/functionUtils'
2221
import { ToolkitError } from './errors'
2322
import { telemetry } from './telemetry/telemetry'
2423
import globals from './extensionGlobals'
24+
import toolkitSettings from './settings-toolkit.gen'
25+
import amazonQSettings from './settings-amazonq.gen'
2526

2627
type Workspace = Pick<typeof vscode.workspace, 'getConfiguration' | 'onDidChangeConfiguration'>
2728

@@ -484,7 +485,7 @@ export interface ResetableMemento extends vscode.Memento {
484485
// from implementations. Using types requires basically no logic but lacks
485486
// precision. We still need to manually specify what type something should be,
486487
// at least for anything beyond primitive types.
487-
const settingsProps = packageJson.contributes.configuration.properties
488+
const settingsProps = { ...toolkitSettings, ...amazonQSettings }
488489

489490
type SettingsProps = typeof settingsProps
490491

@@ -617,7 +618,7 @@ export function fromExtensionManifest<T extends TypeDescriptor & Partial<Section
617618
* TODO: Settings should be defined in individual extensions, and passed to the
618619
* core lib as necessary.
619620
*/
620-
export const toolkitPrompts = settingsProps['aws.suppressPrompts'].properties
621+
export const toolkitPrompts = settingsProps['aws.suppressPrompts']
621622
type toolkitPromptName = keyof typeof toolkitPrompts
622623
export class ToolkitPromptSettings extends Settings.define(
623624
'aws.suppressPrompts',
@@ -647,7 +648,7 @@ export class ToolkitPromptSettings extends Settings.define(
647648
}
648649
}
649650

650-
export const amazonQPrompts = settingsProps['amazonQ.suppressPrompts'].properties
651+
export const amazonQPrompts = settingsProps['amazonQ.suppressPrompts']
651652
type amazonQPromptName = keyof typeof amazonQPrompts
652653
export class AmazonQPromptSettings extends Settings.define(
653654
'amazonQ.suppressPrompts',
@@ -677,7 +678,7 @@ export class AmazonQPromptSettings extends Settings.define(
677678
}
678679
}
679680

680-
const experiments = settingsProps['aws.experiments'].properties
681+
const experiments = settingsProps['aws.experiments']
681682
type ExperimentName = keyof typeof experiments
682683

683684
/**

packages/toolkit/package.json

Lines changed: 198 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
"main": "./dist/src/extensionNode",
5353
"browser": "./dist/src/extensionWeb",
5454
"engines": "This field will be autopopulated from the core module during debugging and packaging.",
55-
"contributes": "This field will be autopopulated from the core module during debugging and packaging.",
5655
"scripts": {
5756
"vscode:prepublish": "npm run clean && npm run buildScripts && webpack --mode production",
58-
"buildScripts": "npm run generateNonCodeFiles && npm run copyFiles && tsc -p ./ --noEmit",
57+
"buildScripts": "npm run generateNonCodeFiles && npm run copyFiles && npm run generateSettings && tsc -p ./ --noEmit",
5958
"generateNonCodeFiles": "ts-node ../../scripts/generateNonCodeFiles.ts",
6059
"copyFiles": "ts-node ./scripts/build/copyFiles.ts",
6160
"clean": "ts-node ../../scripts/clean.ts dist/ LICENSE NOTICE quickStart*",
@@ -70,7 +69,203 @@
7069
"newChange": "ts-node ../../scripts/newChange.ts",
7170
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
7271
"copyPackageJson": "ts-node ./scripts/build/handlePackageJson",
73-
"restorePackageJson": "ts-node ./scripts/build/handlePackageJson --restore"
72+
"restorePackageJson": "ts-node ./scripts/build/handlePackageJson --restore",
73+
"generateSettings": "ts-node ../../scripts/generateSettings.ts"
74+
},
75+
"contributes": {
76+
"configuration": {
77+
"type": "object",
78+
"title": "%AWS.productName%",
79+
"cloud9": {
80+
"cn": {
81+
"title": "%AWS.productName.cn%"
82+
}
83+
},
84+
"properties": {
85+
"aws.profile": {
86+
"type": "string",
87+
"deprecationMessage": "The current profile is now stored internally by the Toolkit.",
88+
"description": "%AWS.configuration.profileDescription%"
89+
},
90+
"aws.ecs.openTerminalCommand": {
91+
"type": "string",
92+
"default": "/bin/sh",
93+
"markdownDescription": "%AWS.configuration.description.ecs.openTerminalCommand%"
94+
},
95+
"aws.iot.maxItemsPerPage": {
96+
"type": "number",
97+
"default": 100,
98+
"minimum": 1,
99+
"maximum": 250,
100+
"markdownDescription": "%AWS.configuration.description.iot.maxItemsPerPage%"
101+
},
102+
"aws.s3.maxItemsPerPage": {
103+
"type": "number",
104+
"default": 300,
105+
"minimum": 3,
106+
"maximum": 1000,
107+
"markdownDescription": "%AWS.configuration.description.s3.maxItemsPerPage%"
108+
},
109+
"aws.samcli.location": {
110+
"type": "string",
111+
"scope": "machine",
112+
"default": "",
113+
"markdownDescription": "%AWS.configuration.description.samcli.location%"
114+
},
115+
"aws.samcli.lambdaTimeout": {
116+
"type": "number",
117+
"default": 90000,
118+
"markdownDescription": "%AWS.configuration.description.samcli.lambdaTimeout%"
119+
},
120+
"aws.samcli.legacyDeploy": {
121+
"type": "boolean",
122+
"default": false,
123+
"markdownDescription": "%AWS.configuration.description.samcli.legacyDeploy%"
124+
},
125+
"aws.telemetry": {
126+
"type": "boolean",
127+
"default": true,
128+
"markdownDescription": "%AWS.configuration.description.telemetry%",
129+
"cloud9": {
130+
"cn": {
131+
"markdownDescription": "%AWS.configuration.description.telemetry.cn%"
132+
}
133+
}
134+
},
135+
"aws.stepfunctions.asl.format.enable": {
136+
"type": "boolean",
137+
"scope": "window",
138+
"default": true,
139+
"description": "%AWS.stepFunctions.asl.format.enable.desc%"
140+
},
141+
"aws.stepfunctions.asl.maxItemsComputed": {
142+
"type": "number",
143+
"default": 5000,
144+
"description": "%AWS.stepFunctions.asl.maxItemsComputed.desc%"
145+
},
146+
"aws.ssmDocument.ssm.maxItemsComputed": {
147+
"type": "number",
148+
"default": 5000,
149+
"description": "%AWS.ssmDocument.ssm.maxItemsComputed.desc%"
150+
},
151+
"aws.cwl.limit": {
152+
"type": "number",
153+
"default": 10000,
154+
"description": "%AWS.cwl.limit.desc%",
155+
"maximum": 10000
156+
},
157+
"aws.samcli.manuallySelectedBuckets": {
158+
"type": "object",
159+
"description": "%AWS.samcli.deploy.bucket.recentlyUsed%",
160+
"default": []
161+
},
162+
"aws.samcli.enableCodeLenses": {
163+
"type": "boolean",
164+
"description": "%AWS.configuration.enableCodeLenses%",
165+
"default": false
166+
},
167+
"aws.suppressPrompts": {
168+
"type": "object",
169+
"description": "%AWS.configuration.description.suppressPrompts%",
170+
"default": {},
171+
"properties": {
172+
"apprunnerNotifyPricing": {
173+
"type": "boolean",
174+
"default": false
175+
},
176+
"apprunnerNotifyPause": {
177+
"type": "boolean",
178+
"default": false
179+
},
180+
"ecsRunCommand": {
181+
"type": "boolean",
182+
"default": false
183+
},
184+
"ecsRunCommandEnable": {
185+
"type": "boolean",
186+
"default": false
187+
},
188+
"ecsRunCommandDisable": {
189+
"type": "boolean",
190+
"default": false
191+
},
192+
"regionAddAutomatically": {
193+
"type": "boolean",
194+
"default": false
195+
},
196+
"yamlExtPrompt": {
197+
"type": "boolean",
198+
"default": false
199+
},
200+
"fileViewerEdit": {
201+
"type": "boolean",
202+
"default": false
203+
},
204+
"createCredentialsProfile": {
205+
"type": "boolean",
206+
"default": false
207+
},
208+
"samcliConfirmDevStack": {
209+
"type": "boolean",
210+
"default": false
211+
},
212+
"remoteConnected": {
213+
"type": "boolean",
214+
"default": false
215+
},
216+
"codeCatalystConnectionExpired": {
217+
"type": "boolean",
218+
"default": false
219+
}
220+
},
221+
"additionalProperties": false
222+
},
223+
"aws.experiments": {
224+
"type": "object",
225+
"markdownDescription": "%AWS.configuration.description.experiments%",
226+
"default": {
227+
"jsonResourceModification": false
228+
},
229+
"properties": {
230+
"jsonResourceModification": {
231+
"type": "boolean",
232+
"default": false
233+
}
234+
},
235+
"additionalProperties": false
236+
},
237+
"aws.resources.enabledResources": {
238+
"type": "array",
239+
"description": "%AWS.configuration.description.resources.enabledResources%",
240+
"items": {
241+
"type": "string"
242+
}
243+
},
244+
"aws.lambda.recentlyUploaded": {
245+
"type": "object",
246+
"description": "%AWS.configuration.description.lambda.recentlyUploaded%",
247+
"default": []
248+
},
249+
"aws.accessAnalyzer.policyChecks.checkNoNewAccessFilePath": {
250+
"type": "string",
251+
"default": "",
252+
"description": "File path or S3 path to a text document for CheckNoNewAccess custom check.",
253+
"scope": "window"
254+
},
255+
"aws.accessAnalyzer.policyChecks.checkAccessNotGrantedFilePath": {
256+
"type": "string",
257+
"default": "",
258+
"description": "File path or S3 path to a text document for CheckAccessNotGranted custom check.",
259+
"scope": "window"
260+
},
261+
"aws.accessAnalyzer.policyChecks.cloudFormationParameterFilePath": {
262+
"type": "string",
263+
"default": "",
264+
"description": "A JSON formatted file that specifies template parameter values, a stack policy, and tags. Only parameters are used from this file.",
265+
"scope": "machine-overridable"
266+
}
267+
}
268+
}
74269
},
75270
"devDependencies": {},
76271
"dependencies": {

0 commit comments

Comments
 (0)