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

Jikun/start or deploy from outside #740

Merged
merged 5 commits into from
Aug 22, 2023
Merged

Conversation

cjk7989
Copy link
Contributor

@cjk7989 cjk7989 commented Aug 18, 2023

Supported "swa start app1" or "swa deploy app1" outside the app1 folder.
For example, under the current working dir containing two projects "app1" and "app2", the above commands will work if there is a "swa-cli.config.json" in "app1" folder, while in the past users must run "swa start" under the app folder.

if (!configName || !swaCliConfigFileExists(path.resolve(configName, configFilePath))) {
return {};
}
logger.warn(`WARNING: Config file does not exist at "${configFilePath}", but can be detected at "${path.join(configName, configFilePath)}".`);

Choose a reason for hiding this comment

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

It's a little strange that both path.join and path.resolve were used in the same part of code. I believe using only one of them is enough depending on the case.

Nit: make it as a variable in the beginning.

if (!confirmConfigPath) {
return {};
}
resolvedConfigFilePath = path.resolve(configName, configFilePath);

Choose a reason for hiding this comment

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

Same question: Why in some places path.resolve was used and in some other places path.join was used?

currentSwaCliConfigFromFile = {
name: configName,
filePath: configFilePath,
filePath: resolvedConfigFilePath,
Copy link

@IvanJobs IvanJobs Aug 21, 2023

Choose a reason for hiding this comment

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

Suggestion:
You can handle the config path fallback logic in the beginning of this function, so that you won't need to change configFilePath to resolved* all the way down here.

@IvanJobs
Copy link

Just checked the code in details. It seems we got a config path option in SWA CLI's global configs. If Cx runs SWA outside of a project folder, we expect Cx to specify the config path as an extra option. This may be the appropriate way to handle this from a PM's perspective.

@cjk7989 cjk7989 merged commit 6b27c1e into main Aug 22, 2023
36 checks passed
@cjk7989 cjk7989 deleted the jikun/start-or-deploy-from-outside branch August 22, 2023 11:50
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.

2 participants