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

refactor(cli): refactor option parsing, create new channel #572

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

matthewvolk
Copy link
Contributor

What/Why?

This PR fixes two issues:

  1. Before this PR, CLI flag (option) parsing missed edge cases, such as --project-name potentially conflicting with another directory name in the target project directory.
  2. Before this PR, users capable of creating a channel on their store were not offered the option to use an existing channel; it was incorrectly assumed that if a user could create a new channel, they always would. Now, they have the option to create a new channel or use an existing one.

Testing

CI

@matthewvolk matthewvolk requested a review from a team as a code owner February 16, 2024 21:09
Copy link

vercel bot commented Feb 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst-latest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2024 6:01pm
catalyst-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2024 6:01pm
7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
catalyst ⬜️ Ignored (Inspect) Feb 20, 2024 6:01pm
catalyst-1millionproducts-store ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 6:01pm
catalyst-2000ms-api ⬜️ Ignored (Inspect) Feb 20, 2024 6:01pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 6:01pm
catalyst-nodejs ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 6:01pm
catalyst-ppr ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 6:01pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2024 6:01pm

Comment on lines -19 to -23
- [ ] Channel Site Routes
- [ ] Check Active Storeront Limit
- [ ] Prompt Sample Data API for New Channels
- [ ] Yarn module resolution bug
- [ ] Write root `.vscode/settings.json`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are now accounted for in the backlog, removing from README.

Copy link
Contributor Author

@matthewvolk matthewvolk left a comment

Choose a reason for hiding this comment

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

While the diff looks large, there aren't any material changes to how the CLI works. This PR mostly just fixes a bunch of validations errors that previous versions of the CLI were letting slip through.

Comment on lines +30 to +35
let projectName;
let projectDir;
let storeHash = options.storeHash;
let accessToken = options.accessToken;
let channelId;
let customerImpersonationToken = options.customerImpersonationToken;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values may be parsed from options, but typically need additional validation, formatting, etc. which is denoted below by the if (options.property) statements below

Comment on lines +23 to +28
const { packageManager, ghRef } = options;

const URLSchema = z.string().url();
const sampleDataApiUrl = parse(options.sampleDataApiUrl, URLSchema);
const bigcommerceApiUrl = parse(`https://api.${options.bigcommerceHostname}`, URLSchema);
const bigcommerceAuthUrl = parse(`https://login.${options.bigcommerceHostname}`, URLSchema);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These values are parsed from options, and never need to be modified again (hence, the const declaration).

import { Https } from './https';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const checkStorefrontLimit = (bc: Https) => true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Placeholder stub - will be completed as part of CATALYST-313

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR for this is up: #573

@@ -34,8 +34,12 @@ export const login = async (
return { storeHash, accessToken };
}

const shouldLogin = await confirm({
const shouldLogin = await select({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched for consistency with other yes/no prompts.

Copy link
Contributor

⚡️🏠 Lighthouse report

We ran Lighthouse against the changes and produced this report. Here's the summary:

Category Score
🟢 Performance 98
🟢 Accessibility 95
🟠 Best practices 78
🟢 SEO 92

Lighthouse ran against https://catalyst-latest-cckbuvv5v-bigcommerce-platform.vercel.app/

@matthewvolk matthewvolk force-pushed the refactor/catalyst-315-319 branch from 9599b62 to 1a774d1 Compare February 20, 2024 17:59
@matthewvolk matthewvolk added this pull request to the merge queue Feb 20, 2024
Merged via the queue into main with commit dcd427e Feb 20, 2024
18 of 19 checks passed
@matthewvolk matthewvolk deleted the refactor/catalyst-315-319 branch February 20, 2024 18:03
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