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/nextjs deploy #746

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/cli/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ export async function deploy(options: SWACLIConfig) {
DEPLOYMENT_TOKEN: deploymentToken,
// /!\ Static site client doesn't use OUTPUT_LOCATION at all if SKIP_APP_BUILD is set,
// so you need to provide the output path as the app location
APP_LOCATION: userWorkflowConfig?.outputLocation,
// OUTPUT_LOCATION: outputLocation,
APP_LOCATION: userWorkflowConfig?.appLocation,
OUTPUT_LOCATION: userWorkflowConfig?.outputLocation,
API_LOCATION: userWorkflowConfig?.apiLocation,
DATA_API_LOCATION: userWorkflowConfig?.dataApiLocation,
// If config file is not in output location, we need to tell where to find it
Expand Down Expand Up @@ -271,13 +271,15 @@ export async function deploy(options: SWACLIConfig) {
logger.silly(`Deploying using ${cliEnv.SWA_CLI_DEPLOY_BINARY}`);
logger.silly(`Deploying using the following options:`);
logger.silly({ env: { ...cliEnv, ...deployClientEnv } });
logger.silly(`StaticSiteClient working directory: ${path.dirname(userWorkflowConfig?.appLocation!)}`);

spinner.start(`Preparing deployment. Please wait...`);

const child = spawn(binary, [], {
env: {
...swaCLIEnv(cliEnv, deployClientEnv),
},
cwd: path.dirname(userWorkflowConfig?.appLocation!),
});

let projectUrl = "";
Expand Down
29 changes: 20 additions & 9 deletions src/core/utils/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,33 @@ export function matchLoadedConfigName(name: string) {
* @returns An object with the `{@link SWACLIOptions}` config or an empty object if the config file, or the config entry were not found.
*/
export async function getConfigFileOptions(configName: string | undefined, configFilePath: string): Promise<SWACLIConfig> {
logger.silly(`Getting config file options from ${configFilePath}...`);
logger.silly(`Getting config file options from "${configFilePath}"...`);

configFilePath = path.resolve(configFilePath);
if (!swaCliConfigFileExists(configFilePath)) {
logger.silly(`Config file does not exist at ${configFilePath}`);
return {};
let configFilePathResolved = path.resolve(configFilePath);
if (!swaCliConfigFileExists(configFilePathResolved)) {
logger.silly(`Config file does not exist at "${configFilePath}"`);

// Handle the case when the user runs the command outside the project path
if (!configName || !swaCliConfigFileExists(path.resolve(configName, swaCliConfigFilename))) {
return {};
}
logger.warn(
`WARNING: Config file does not exist at "${configFilePath}", but can be detected at "${path.join(
configName,
swaCliConfigFilename
)}". Do you mean "swa --config ${path.join(configName, swaCliConfigFilename)} <command> ${configName} [options]"?`
);
configFilePathResolved = path.resolve(configName, swaCliConfigFilename);
}

const cliConfig = await tryParseSwaCliConfig(configFilePath);
const cliConfig = await tryParseSwaCliConfig(configFilePathResolved);
if (!cliConfig.configurations) {
logger.warn(`${swaCliConfigFilename} is missing the "configurations" property. No options will be loaded.`);
return {};
}

// Use configuration root path as the outputLocation
const configDir = path.dirname(configFilePath);
const configDir = path.dirname(configFilePathResolved);
process.chdir(configDir);

logger.silly(`Changed directory to ${configDir}`);
Expand All @@ -76,10 +87,10 @@ export async function getConfigFileOptions(configName: string | undefined, confi
}

const [configName, config] = Object.entries(cliConfig.configurations)[0];
printConfigMsg(configName, configFilePath);
printConfigMsg(configName, configFilePathResolved);
currentSwaCliConfigFromFile = {
name: configName,
filePath: configFilePath,
filePath: configFilePathResolved,
config,
};
return { ...config };
Expand Down
Loading