Skip to content
Open
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
2 changes: 2 additions & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ build-config.json
# OpenNext
.open-next
.wrangler

.bigcommerce
13 changes: 6 additions & 7 deletions packages/catalyst/src/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ export const build = new Command('build')
.addOption(
new Option(
'--project-uuid <uuid>',
'Project UUID to be included in the deployment configuration.',
).env('BIGCOMMERCE_PROJECT_UUID'),
'Project UUID to be included in the deployment configuration. Can also be set via the CATALYST_PROJECT_UUID environment variable.',
).env('CATALYST_PROJECT_UUID'),
)
.addOption(
new Option('--framework <framework>', 'The framework to use for the build.').choices([
'nextjs',
'catalyst',
]),
new Option('--framework <framework>', 'The framework to use for the build.')
.env('CATALYST_FRAMEWORK')
.choices(['nextjs', 'catalyst']),
)
.action(async (nextBuildOptions, options) => {
const coreDir = process.cwd();
Expand Down Expand Up @@ -60,7 +59,7 @@ export const build = new Command('build')

if (!projectUuid) {
throw new Error(
'Project UUID is required. Please run `catalyst project create` or `catalyst project link` or this command again with --project-uuid <uuid>.',
'Project UUID is required. This can be set via the --project-uuid flag, the CATALYST_PROJECT_UUID environment variable, or the projectUuid property in the .bigcommerce/project.json file.',
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/catalyst/src/cli/commands/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,19 @@ test('--dry-run skips upload and deployment', async () => {

test('reads from env options', () => {
const envVariables = parseEnvironmentVariables([
'BIGCOMMERCE_STORE_HASH=123',
'BIGCOMMERCE_STOREFRONT_TOKEN=456',
'CATALYST_STORE_HASH=123',
'CATALYST_ACCESS_TOKEN=456',
Comment on lines -309 to +310
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this intentional, to rename BIGCOMMERCE_STOREFRONT_TOKEN to CATALYST_ACCESS_TOKEN?

]);

expect(envVariables).toEqual([
{
type: 'secret',
key: 'BIGCOMMERCE_STORE_HASH',
key: 'CATALYST_STORE_HASH',
value: '123',
},
{
type: 'secret',
key: 'BIGCOMMERCE_STOREFRONT_TOKEN',
key: 'CATALYST_ACCESS_TOKEN',
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this intentional, to rename BIGCOMMERCE_STOREFRONT_TOKEN to CATALYST_ACCESS_TOKEN?

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 actually just realized I made that jump. I think I just had access_token in my mind and put that in the different docs, then copied in. I don't think we made a collective decision on that. I think the correct thing to do would be CATALYST_STOREFRONT_TOKEN. Does you agree with 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.

Wait ignore the above lol I get it now. This is supposed to be testing parsing secret runtime variables. Great catch!

value: '456',
},
]);
Expand Down
45 changes: 22 additions & 23 deletions packages/catalyst/src/cli/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,14 @@ export const deploy = new Command('deploy')
.addOption(
new Option(
'--store-hash <hash>',
'BigCommerce store hash. Can be found in the URL of your store Control Panel.',
)
.env('BIGCOMMERCE_STORE_HASH')
.makeOptionMandatory(),
'BigCommerce store hash. Can be found in the URL of your store Control Panel. Can also be set via the CATALYST_STORE_HASH environment variable or the storeHash property in the .bigcommerce/project.json file.',
).env('CATALYST_STORE_HASH'),
)
.addOption(
new Option(
'--access-token <token>',
'BigCommerce access token. Can be found after creating a store-level API account.',
)
.env('BIGCOMMERCE_ACCESS_TOKEN')
.makeOptionMandatory(),
'BigCommerce access token. Can be found after creating a store-level API account. Can also be set via the CATALYST_ACCESS_TOKEN environment variable or the accessToken property in the .bigcommerce/project.json file.',
).env('CATALYST_ACCESS_TOKEN'),
)
.addOption(
new Option('--api-host <host>', 'BigCommerce API host. The default is api.bigcommerce.com.')
Expand All @@ -303,8 +299,8 @@ export const deploy = new Command('deploy')
.addOption(
new Option(
'--project-uuid <uuid>',
'BigCommerce intrastructure project UUID. Can be found via the BigCommerce API (GET /v3/infrastructure/projects).',
).env('BIGCOMMERCE_PROJECT_UUID'),
'BigCommerce infrastructure project UUID. Can be found via the BigCommerce API (GET /v3/infrastructure/projects). Can also be set via the CATALYST_PROJECT_UUID environment variable or the projectUuid property in the .bigcommerce/project.json file.',
).env('CATALYST_PROJECT_UUID'),
)
.addOption(
new Option(
Expand All @@ -318,16 +314,24 @@ export const deploy = new Command('deploy')
try {
const config = getProjectConfig();

await telemetry.identify(options.storeHash);

const storeHash = options.storeHash ?? config.get('storeHash');
const accessToken = options.accessToken ?? config.get('accessToken');
const projectUuid = options.projectUuid ?? config.get('projectUuid');

if (!storeHash || !accessToken) {
throw new Error(
'Store hash and access token are required. Can be set via the --store-hash and --access-token flags, the CATALYST_STORE_HASH and CATALYST_ACCESS_TOKEN environment variables, or the storeHash and accessToken properties in the .bigcommerce/project.json file.',
);
}

if (!projectUuid) {
throw new Error(
'Project UUID is required. Please run either `catalyst project link` or `catalyst project create` or this command again with --project-uuid <uuid>.',
'Project UUID is required. This can be set via the --project-uuid flag, the CATALYST_PROJECT_UUID environment variable, or the projectUuid property in the .bigcommerce/project.json file.',
);
}

await telemetry.identify(storeHash);

await generateBundleZip();

if (options.dryRun) {
Expand All @@ -341,8 +345,8 @@ export const deploy = new Command('deploy')
}

const uploadSignature = await generateUploadSignature(
options.storeHash,
options.accessToken,
storeHash,
accessToken,
options.apiHost,
);

Expand All @@ -353,18 +357,13 @@ export const deploy = new Command('deploy')
const { deployment_uuid: deploymentUuid } = await createDeployment(
projectUuid,
uploadSignature.upload_uuid,
options.storeHash,
options.accessToken,
storeHash,
accessToken,
options.apiHost,
environmentVariables,
);

await getDeploymentStatus(
deploymentUuid,
options.storeHash,
options.accessToken,
options.apiHost,
);
await getDeploymentStatus(deploymentUuid, storeHash, accessToken, options.apiHost);
} catch (error) {
consola.error(error);
process.exit(1);
Expand Down
Loading