Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sandbox client config options #643

Merged
merged 8 commits into from Nov 15, 2023
Merged

fix: sandbox client config options #643

merged 8 commits into from Nov 15, 2023

Conversation

rtpascual
Copy link
Contributor

@rtpascual rtpascual commented Nov 14, 2023

Issue #, if available:

Description of changes:

  • Rename sandbox --out-dir option to sandbox --config-out-dir
  • Pass config-out-dir to client config lifecycle handler so the option is respected
  • Noticed sandbox --format was the same and fixed that as well
  • Rename sandbox --format option to sandbox --config-format

amplify sandbox --config-out-dir src --config-format ts will generate the client config in the specified src directory and with the provided format:

Screenshot 2023-11-14 at 10 10 20 AM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 14, 2023

🦋 Changeset detected

Latest commit: 79acaf7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

edwardfoyle
edwardfoyle previously approved these changes Nov 14, 2023
Copy link
Member

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

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

LGTM, one additional change to consider

@@ -105,7 +105,7 @@ void describe('sandbox command', () => {
assert.match(output, /--dir-to-watch/);
assert.match(output, /--exclude/);
assert.match(output, /--format/);
Copy link
Member

Choose a reason for hiding this comment

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

Just chatted with the PMs and they suggested changing this to config-format for consistency. If you want to roll that into this PR you could, or do a follow up PR.

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 can add that to this PR. What is your opinion on e2e testing config-format and config-out-dir? I can follow up with another PR when I address #403 or should it be a part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to config-format in ece9635

Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with e2e tests going in a follow up PR. When you do get to that, I suggest adding this as an additional assertion on the existing sandbox test rather than a whole new test.

validateDirectory = (option: string, dir: string) => {
let stats;
try {
stats = fs.statSync(dir, {});
Copy link
Member

Choose a reason for hiding this comment

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

it seems that check might be supporting async functions.
Can you give it a try and convert this to async?

Ref: yargs/yargs#1872

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was not aware of this, good to know and done in 4cb5b72.

Copy link
Member

Choose a reason for hiding this comment

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

any file system access if possible should be made async so that event loop is not blocked.

Comment on lines +99 to +100
args['config-out-dir'],
args['config-format']
Copy link
Member

Choose a reason for hiding this comment

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

can we add a test which asserts that these values are flowing correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 70969c4

sobolk
sobolk previously approved these changes Nov 14, 2023
@@ -201,4 +196,16 @@ export class SandboxCommand
await this.sandboxFactory.getInstance()
).delete({ name: this.sandboxName });
};

validateDirectory = async (option: string, dir: string) => {
Copy link
Member

Choose a reason for hiding this comment

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

This should be private

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 79acaf7

@rtpascual rtpascual merged commit 79ac139 into main Nov 15, 2023
20 checks passed
@rtpascual rtpascual deleted the sandbox-out-dir branch November 15, 2023 19:15
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.

None yet

3 participants