Skip to content

Commit 5c6352b

Browse files
authored
Merge branch 'master' into pomParse
2 parents 978c0bd + 4b3804f commit 5c6352b

File tree

236 files changed

+8136
-4897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+8136
-4897
lines changed

.github/workflows/node.js.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
env:
2222
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
2323
NODE_OPTIONS: '--max-old-space-size=8192'
24+
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
25+
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
2426
steps:
2527
- uses: actions/checkout@v4
2628
- name: Use Node.js ${{ matrix.node-version }}
@@ -32,16 +34,38 @@ jobs:
3234
uses: coactions/setup-xvfb@v1
3335
with:
3436
run: npm test
35-
- name: Code coverage
37+
- name: Code coverage (Core)
3638
env:
3739
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
3840
NODE_OPTIONS: ''
3941
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
4042
uses: codecov/codecov-action@v4
4143
with:
42-
flags: macos-unittests
44+
flags: macos-core-unittests
4345
verbose: true
44-
file: ./coverage/lcov.info
46+
file: ./coverage/core/lcov.info
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
- name: Code coverage (Toolkit)
49+
env:
50+
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
51+
NODE_OPTIONS: ''
52+
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
53+
uses: codecov/codecov-action@v4
54+
with:
55+
flags: macos-toolkit-unittests
56+
verbose: true
57+
file: ./coverage/toolkit/lcov.info
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
- name: Code coverage (Amazon Q)
60+
env:
61+
# Unset NODE_OPTIONS because of https://github.com/codecov/uploader/issues/475
62+
NODE_OPTIONS: ''
63+
if: ${{ github.repository == 'aws/aws-toolkit-vscode' && ( github.ref == 'master' || github.event_name == 'pull_request' ) }}
64+
uses: codecov/codecov-action@v4
65+
with:
66+
flags: macos-amazonq-unittests
67+
verbose: true
68+
file: ./coverage/amazonq/lcov.info
4569
token: ${{ secrets.CODECOV_TOKEN }}
4670
- name: Code coverage (CodeWhisperer)
4771
env:
@@ -52,7 +76,7 @@ jobs:
5276
with:
5377
flags: codewhisperer
5478
verbose: true
55-
file: ./coverage/lcov.info
79+
file: ./coverage/core/lcov.info
5680
token: ${{ secrets.CODECOV_TOKEN }}
5781

5882
web:
@@ -66,6 +90,8 @@ jobs:
6690
env:
6791
VSCODE_TEST_VERSION: ${{ matrix.vscode-version }}
6892
NODE_OPTIONS: '--max-old-space-size=8192'
93+
AWS_TOOLKIT_TEST_CACHE_DIR: '/tmp/.vscode-test/'
94+
AWS_TOOLKIT_TEST_USER_DIR: '/tmp/.vscode-test/user-data/'
6995
steps:
7096
- uses: actions/checkout@v4
7197
- name: Use Node.js ${{ matrix.node-version }}

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ __pycache__
2020

2121
# Auto generated definitions
2222
packages/*/src/**/*.gen.ts
23+
!packages/core/src/**/awsSamDebugConfiguration.gen.ts
24+
!packages/core/src/shared/settings-*.gen.ts
2325
src.gen/*
2426

25-
# Telemetry definition for testing adding telemetry
26-
packages/core/src/shared/telemetry/vscodeTelemetry.json
27-
2827
# Test reports
2928
.test-reports
3029

CONTRIBUTING.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ You can also use these NPM tasks (see `npm run` for the full list):
132132
133133
1. Declare a global unhandledRejection handler.
134134
```ts
135-
process.on('unhandledRejection', e => {
135+
process.on('unhandledRejection', (e) => {
136136
getLogger('channel').error(
137137
localize(
138138
'AWS.channel.aws.toolkit.activation.error',
@@ -218,12 +218,7 @@ To run tests against a specific folder in VSCode, do any one of:
218218
219219
### Coverage report
220220
221-
You can find the coverage report at `./coverage/index.html` after running the tests. Tests ran from the workspace launch config won't generate a coverage report automatically because it can break file watching. A few manual steps are needed instead:
222-
223-
- Run the command `Tasks: Run Build Task` if not already active
224-
- Instrument built code with `npm run instrument`
225-
- Exercise the code (`Extension Tests`, `Integration Tests`, etc.)
226-
- Generate a report with `npm run report`
221+
You can find the coverage report at `./coverage/amazonq/lcov-report/index.html` and `./coverage/core/lcov-report/index.html` after running the tests. Tests ran from the workspace launch config won't generate a coverage report automatically because it can break file watching.
227222
228223
### CodeCatalyst Blueprints
229224
@@ -554,7 +549,7 @@ For extensions to contribute their own codicons, VSCode requires a font file as
554549
As a simple example, let's say I wanted to add a new icon for CloudWatch log streams. I would do the following:
555550

556551
1. Place the icon in `resources/icons/aws/cloudwatch`. I'l name the icon `log-stream.svg`.
557-
1. Use `npm run generatePackage` to update `package.json`. Commit this change with the new icon.
552+
1. Use `npm run generateIcons` to update `package.json`. Commit this change with the new icon.
558553
1. You can now use the icon in the Toolkit:
559554

560555
```ts

buildspec/linuxE2ETests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ phases:
4141
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4242
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
4343
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
44-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
44+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
4545
finally:
4646
- rm -rf ~/.aws/sso/cache || true
4747
reports:

buildspec/linuxIntegrationTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ phases:
7575
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
7676
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g')
7777
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
78-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
78+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
7979
post_build:
8080
commands:
8181
# Destroy .netrc to avoid leaking $GITHUB_READONLY_TOKEN.

buildspec/linuxTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ phases:
4848
- VCS_COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}"
4949
- CI_BUILD_URL=$(echo $CODEBUILD_BUILD_URL | sed 's/#/%23/g') # Encode `#` in the URL because otherwise the url is clipped in the Codecov.io site
5050
- CI_BUILD_ID="${CODEBUILD_BUILD_ID}"
51-
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/lcov.info
51+
- test -n "${CODECOV_TOKEN}" && ./codecov --token=${CODECOV_TOKEN} --branch=${CODEBUILD_RESOLVED_SOURCE_VERSION} --repository=${CODEBUILD_SOURCE_REPO_URL} --file=./coverage/core/lcov.info --file=./coverage/amazonq/lcov.info --file=./coverage/toolkit/lcov.info
5252

5353
reports:
5454
unit-test:

codecov.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,30 @@ coverage:
1818
codewhisperer:
1919
target: 70%
2020
paths:
21-
- src/codewhisperer/*
21+
- packages/core/src/codewhisperer/*
2222
flags:
2323
- 'codewhisperer'
2424
amazonqFeatureDev:
2525
target: 70%
2626
paths:
27-
- src/amazonqFeatureDev/*
27+
- packages/core/src/amazonqFeatureDev/*
2828
flags:
2929
- 'amazonqFeatureDev'
30+
amazonqGumby:
31+
paths:
32+
- packages/core/src/amazonqGumby/*
33+
codewhispererChat:
34+
paths:
35+
- packages/core/src/codewhispererChat/*
36+
applicationcomposer:
37+
paths:
38+
- packages/core/src/applicationcomposer/*
39+
stepFunctions:
40+
paths:
41+
- packages/core/src/stepFunctions/*
42+
threatComposer:
43+
paths:
44+
- packages/core/src/threatComposer/*
3045
patch: no
3146
changes: no
3247

docs/TESTPLAN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Checking the state works well if user interactions are not required by the code
104104
To handle this, test code can register event handler that listen for when a certain type of UI element is shown. For example, if we wanted to always accept the first item of a quick pick we can do this:
105105

106106
```ts
107-
getTestWindow().onDidShowQuickPick(async picker => {
107+
getTestWindow().onDidShowQuickPick(async (picker) => {
108108
// Some pickers load items asychronously
109109
// Wait until the picker is not busy before accepting an item
110110
await picker.untilReady()
@@ -121,3 +121,9 @@ const secondPicker = await pickers.next()
121121
```
122122

123123
Exceptions thrown within one of these handlers will cause the current test to fail. This allows you to make assertions within the callback without worrying about causing the test to hang.
124+
125+
## Common issues
126+
127+
### Stubbing VSCode outside of core
128+
129+
- Stubbing VSCode imports (like executeCommand) does not work outside of core. For now you will need to put any tests that require spying/stubbing VSCode imports in core until we move more source files into the amazon q package

docs/arch_develop.md

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Current quirks of the current monorepo status that should be resolved/evaluated
3737
- This package contains shortcuts to some of the `npm` scripts found in the subproject(s).
3838
- `createRelease` and `newChange` run at the subproject level only, e.g. from root level, try npm run createRelease -w packages/toolkit
3939
- To run a script not present in the root `package.json`, use `npm run -w packages/toolkit <script>`
40-
- `coverage/`, `.test-reports/`, `node_modules/` are hoisted to the project root. As more subprojects are added,
41-
we will need to evaluate how to merge and publish coverage reports.
40+
- `coverage/`, `.test-reports/`, `node_modules/` are hoisted to the project root.
4241
- `dist/` however remains at the subproject level, along with a local `node_modules/`. See [`npm workspaces`](https://docs.npmjs.com/cli/v8/using-npm/workspaces)
4342
for more info on how `node_modules/` hoisting works.
4443
- Because of `node_modules/` hoisting, references to this folder in code access the root project modules folder. This may be
@@ -72,39 +71,37 @@ Some components of the core library depend on the `package.json`s of the extensi
7271
- Does not restore, it is a superset of what exists in `packages/core` for `configuration.properties`.
7372
- To develop for the Amazon Q extension: add all changes to `packages/amazonq/package.json`, EXCEPT for settings that are references by code in the core library, or settings that already exist in the core `package.json`
7473

75-
## Shared vs Common names
74+
If you are modifying or registering new debuggers in VS Code via the `debuggers` contribution point, you may need to regenerate the [definitions file](../packages/core/src/shared/sam/debugger/awsSamDebugConfiguration.gen.ts). After updating ['toolkit/package.json'](../packages/toolkit/package.json), run `npm run generateConfigurationAttributes -w packages/toolkit`
7675

77-
In this repo, the keywords **"shared"** and **"common"** have specific meanings in the context of file/folder names.
76+
## `web`, `node`, `common`, `shared` naming conventions
7877

79-
### "common"
78+
This project can run in different environments, eg Web mode (in the browser with no compute backend), or in Node.js on your desktop (the most common way).
79+
A problem arises when we use code that is exclusive to one environment, an example being Node.js' Filesystem module which will fail in Web mode.
8080

81-
Code within a folder/file that has the "common" keyword implies that it can run in any environment. Examples of environments are: Web mode, or Node.js (local desktop)
81+
To ensure developers use compatible code for their environment we have subfolders in each topic which contains environment specific code in a single place.
8282

83-
We need this distinction since not all code can run in any environment. A common example is filesystem code, where the actual implementation used could work in Node.js but not in Web mode.
83+
Using this file tree as reference, here are the rules:
8484

85-
### "shared"
86-
87-
Code within a folder/file that has the "shared" keyword implies that it is intended to be reused wherever it can be. This is generalized code that "Feature A" or "Feature B" could use if it works for their use case.
88-
89-
An example is the `waitUntil()` function which continuously invokes an arbitrary callback function until it succeeds.
90-
91-
> NOTE: Something that is "shared" does not mean it is "common", as it could be reused in different places but only work in Node.js for example.
85+
```
86+
src/
87+
├── myTopic/
88+
│ ├── {file}.ts
89+
│ ├── node/
90+
│ │ └── {file}.ts
91+
│ └── web/
92+
│ └── {file}.ts
93+
└── shared/
94+
```
9295

93-
### How to apply this
96+
- `myTopic/` is the general name of the folder, eg `request` for http requests.
97+
- `myTopic/{file}.ts` is for code that works in any environment, we refer to this as `"common"` code.
98+
- `node/{file}.ts` is for code that works exclusively in Node.js.
99+
- `web/{file}.ts` is for code that works exclusively in Web mode.
100+
- `shared/` is for code that is intended to be reused, i.e general purpose utils.
101+
- Note environment specific code should be place in to a `web/` or `node/` subfolder.
102+
- If the code is not in a subfolder then it is considered `shared common` code.
94103

95-
- Aim to make code compatible with "common" from the beginning.
96-
- In a "topic" folder, if you have common code, create a subfolder named "common" and add your common code to there.
97-
```
98-
src/
99-
|
100-
myTopic/
101-
|
102-
common/
103-
nonCommon.ts
104-
```
105-
- See if yours, or existing code can be moved in to a "shared" folder. Maybe it can be easily modified to become "shared".
106-
- If there is no "shared" or "common" naming used for the file/folder, then assume it only works in Node.js.
107-
- In the rare case your code only works in Web mode, create a `web` subfolder for that code.
104+
> IMPORTANT: The current codebase does not fully follow this convention yet, the transition is being done incrementally. Due to this, code that is `"common"` may not actually be common yet. If you run in to this, please move that code to the appropriate subfolder.
108105
109106
## Commands
110107

@@ -293,22 +290,22 @@ Commands and events are defined on the backend via sub-classes of `VueWebview`.
293290
```ts
294291
client
295292
.foo()
296-
.then(response => console.log(response))
297-
.catch(err => console.log(err))
293+
.then((response) => console.log(response))
294+
.catch((err) => console.log(err))
298295
```
299296

300297
The backend protocol is allowed to throw errors. These result in rejected Promises on the frontend.
301298

302299
- Registering for events:
303300

304301
```ts
305-
client.onBar(num => console.log(num))
302+
client.onBar((num) => console.log(num))
306303
```
307304

308305
- Methods called `init` will only return data on the initial webview load:
309306

310307
```ts
311-
client.init(data => (this.data = data ?? this.data))
308+
client.init((data) => (this.data = data ?? this.data))
312309
```
313310

314311
## Webviews (non Vue)
@@ -494,8 +491,8 @@ class ExampleWizard extends Wizard<ExampleState> {
494491
{ label: '1', data: 1 },
495492
{ label: '2', data: 2 },
496493
]
497-
this.form.bar.bindPrompter(state => createQuickPick(items, { title: `Select a number (${state.foo})` }), {
498-
showWhen: state => state.foo?.length > 5,
494+
this.form.bar.bindPrompter((state) => createQuickPick(items, { title: `Select a number (${state.foo})` }), {
495+
showWhen: (state) => state.foo?.length > 5,
499496
})
500497
}
501498
}

docs/icons.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Icons
22

3-
All icons that are used in the Toolkit can be found in `resources/icons`.
3+
All icons that are used in the extensions can be found in `resources/icons`.
44

5-
A [build script](../../scripts/build/generateIcons.ts) generates Toolkit artifacts:
5+
A [build script](../scripts/generateIcons.ts) generates extension artifacts in [core/](../packages/core/):
66

77
- `resources/icons/cloud9/generated`
88
- `resources/fonts/aws-toolkit-icons.woff`
99
- `resources/css/icons.css`
10-
- `contributes.icons` in [package.json](../../package.json)
10+
- `contributes.icons` in [amazonq package.json](../packages/amazonq/package.json) and [toolkit package.json](../packages/toolkit/package.json)
1111

12-
This script should be ran using `npm run generatePackage` after making updates. Any changes made to `package.json` should be committed with the relevant icons.
12+
This script should be ran using `npm run generateIcons` after making updates. Any changes made to `package.json` should be committed with the relevant icons. Type checking in `core/` relies on the entries in `core/package.json`. However, the individual extensions require entries in their `package.json`s as well. Currently, resources (including icons) are shared between `core/` and the individual extensions. If `contributes.icons` in each of the extensions does not match the entry in `core/`, then CI will fail.
13+
14+
To sync the icons to the individual extensions, run `npm run copyFiles && npm run generateIcons` for each extension.
1315

1416
## Fonts
1517

0 commit comments

Comments
 (0)