Skip to content

Conversation

@Vandita2020
Copy link
Contributor

@Vandita2020 Vandita2020 commented Feb 18, 2025

Problem

This pull request introduces the functionality to allow users to download the selected pattern from the Serverless Land QuickPick flow into a directory of their choice.

Solution

The key changes made are as follows:

  1. The metadata.json file was updated to accommodate the addition of an asset_name field for each IaC and Runtime pair.
  2. Consequently, the way the metadata is extracted in the metadataManager.ts file had to be modified to account for these changes in the metadata.json file.
  3. To enable users to navigate back to the previous QuickPick options, a switch functionality was implemented in the wizard.ts file. This helps maintain the state of the current QuickPick and directs the user to the previous QuickPick.

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.

@Vandita2020 Vandita2020 force-pushed the download_code branch 5 times, most recently from a20965f to 1e35324 Compare February 20, 2025 20:52
@Vandita2020 Vandita2020 changed the title Download code feat(lambda): download serverless patterns in IDE Feb 20, 2025
@Vandita2020 Vandita2020 marked this pull request as ready for review February 20, 2025 21:43
@Vandita2020 Vandita2020 requested a review from a team as a code owner February 20, 2025 21:43
Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions in Wizard part, also please add test

}).run()
}

async function downloadPatternCode(config: CreateServerlessLandWizardForm): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you are providing a Official Serverless Land experience here, could you help to update the Download SL logic I have in walkthrough to use your logic here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is going to be used in other places as well, I suggest bringing these function outside of main.py and into another file in this folder for readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, I am using the same getPattern() function that is defined in the shared/utilities/downloadPattern. The only difference is that I am appending the .zip extension to the asset_name to ensure the pattern code is downloaded correctly. In the metadata file, I am saving the asset_name without the extension, while for the Getting Started project, the asset_name was saved with the extension. If we plan to use the metadata for the Getting Started patterns in the future, we can update the approach there as well.

if (patterns.length === 0) {
throw new ToolkitError('No patterns found in metadata')
}
let step = 'pattern'
Copy link
Member

@roger-zhangg roger-zhangg Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for line 40, IMO we should avoid public override async run(): when possible. Just put all the async prework out of the wizard. the override async run() has cause difficulties in testing as my experience.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has been simplified, and the logic that was previously executed within the public override async run() method has been moved to the public constructor. No longer need to override the run() function.

@Vandita2020 Vandita2020 changed the title feat(lambda): download serverless patterns in IDE feat(lambda): download serverless land patterns in IDE Feb 20, 2025
@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

}).run()
}

async function downloadPatternCode(config: CreateServerlessLandWizardForm): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is going to be used in other places as well, I suggest bringing these function outside of main.py and into another file in this folder for readability.

export class CreateServerlessLandWizard extends Wizard<CreateServerlessLandWizardForm> {
private metadataManager: MetadataManager
async function loadMetadata(): Promise<MetadataManager> {
const metadataManager = MetadataManager.getInstance()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense for this to live inside of the metadataManager? Or do you envision the metadata manager loading multiple different types of metadata

Copy link
Contributor Author

@Vandita2020 Vandita2020 Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project will utilize a single metadata file. I have made the changes to utilize loadMetadata() inside the metadataManager.ts file.

super({
exitPrompterProvider: createExitPrompter,
})
loadMetadata().catch((err: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the form have the metadata before the load the form loads rather than loading it afterwords?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand what you're talking about here. Can you please explain it more? Thanks!

},
{
iconPath: new vscode.ThemeIcon('open-preview'),
tooltip: 'Open in Serverless Land',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tooltip: 'Open in Serverless Land',
tooltip: 'Show Serverless Land webview',

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We technically show the web view of Serverless Land page in VS Code web view.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does "webview" mean anything to customers?

private static instance: MetadataManager
private metadata: ProjectMetadata | undefined
private static readonly metadataPath = path.join(
path.resolve(__dirname, '../../../../../'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're probably going to wait to integrate with our copyFiles scripts. This path probably exists in the extension debug mode but I don't think it exists in the actual build. Instead, you will need to copy this file to the resources file and pull from that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have made the changes in the path with the copyFiles scripts in the next PR and it is working correctly too.

Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we should review again once we have the whole feature ready

@jpinkney-aws jpinkney-aws merged commit 2335204 into aws:feature/serverlessland Feb 26, 2025
16 of 17 checks passed
Vandita2020 added a commit to Vandita2020/aws-toolkit-vscode that referenced this pull request Feb 26, 2025
This pull request introduces the functionality to allow users to
download the selected pattern from the Serverless Land QuickPick flow
into a directory of their choice.

The key changes made are as follows:
1. The `metadata.json` file was updated to accommodate the addition of
an `asset_name` field for each IaC and Runtime pair.
2. Consequently, the way the metadata is extracted in the
`metadataManager.ts` file had to be modified to account for these
changes in the `metadata.json` file.
3. To enable users to navigate back to the previous QuickPick options, a
switch functionality was implemented in the `wizard.ts` file. This helps
maintain the state of the current QuickPick and directs the user to the
previous QuickPick.
---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Co-authored-by: Vandita Patidar <[email protected]>

Building Quick Pick structure

Arranging file structure

Review revision

Download code

Updating wizard file

Download code
Vandita2020 added a commit to Vandita2020/aws-toolkit-vscode that referenced this pull request Mar 5, 2025
## Problem
This pull request introduces the functionality to allow users to
download the selected pattern from the Serverless Land QuickPick flow
into a directory of their choice.

## Solution
The key changes made are as follows:
1. The `metadata.json` file was updated to accommodate the addition of
an `asset_name` field for each IaC and Runtime pair.
2. Consequently, the way the metadata is extracted in the
`metadataManager.ts` file had to be modified to account for these
changes in the `metadata.json` file.
3. To enable users to navigate back to the previous QuickPick options, a
switch functionality was implemented in the `wizard.ts` file. This helps
maintain the state of the current QuickPick and directs the user to the
previous QuickPick.
---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Co-authored-by: Vandita Patidar <[email protected]>
nkomonen-amazon pushed a commit to nkomonen-amazon/aws-toolkit-vscode that referenced this pull request Mar 5, 2025
## Problem
This pull request introduces the functionality to allow users to
download the selected pattern from the Serverless Land QuickPick flow
into a directory of their choice.

## Solution
The key changes made are as follows:
1. The `metadata.json` file was updated to accommodate the addition of
an `asset_name` field for each IaC and Runtime pair.
2. Consequently, the way the metadata is extracted in the
`metadataManager.ts` file had to be modified to account for these
changes in the `metadata.json` file.
3. To enable users to navigate back to the previous QuickPick options, a
switch functionality was implemented in the `wizard.ts` file. This helps
maintain the state of the current QuickPick and directs the user to the
previous QuickPick.
---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

---------

Co-authored-by: Vandita Patidar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants