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

feat: command to help generate integration patches #1192

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

matthewvolk
Copy link
Contributor

What/Why?

Adds a command to the create-catalyst CLI that can be executed by running [npm|pnpm|yarn] create @bigcommerce/catalyst@latest integration once published. Also updates the packages/create-catalyst/README.md with some documentation that partners interested in developing integrations can follow.

When you execute this new command following the steps below, the command will create a folder with two new files:

  • integration.patch
  • manifest.json

The expectation is that the folder containing these two files will be committed to a branch, and that branch will then be used to open a PR into bigcommerce/catalyst:main. Once merged, the pnpm create @bigcommerce/catalyst@latest create CLI will then be able to accept an argument for which integration you want to scaffold your Catalyst project with, check that the argument you passed exists in the integrations folder on bigcommerce/catalyst:main, read the manifest.json to, install dependencies, devDependencies, add environment variables, and then read the integration.patch file to apply the patch.

Testing

Clone https://github.com/bigcommerce/catalyst and run the following commands to test this command with the Makeswift integration:

  1. git fetch --all
  2. git switch integrations/create-patch
  3. pnpm install
  4. pnpm -F @bigcommerce/create-catalyst build
  5. git branch integrations/makeswift origin/integrations/makeswift
  6. node packages/create-catalyst/dist/index.js integration --integration-name "Makeswift" --source-branch "integrations/makeswift"

@matthewvolk matthewvolk requested a review from a team as a code owner July 30, 2024 21:21
Copy link

vercel bot commented Jul 30, 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 Aug 7, 2024 4:42pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst ⬜️ Ignored (Inspect) Aug 7, 2024 4:42pm
catalyst-1millionproducts-store ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 4:42pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 4:42pm
catalyst-test-store ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 4:42pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 4:42pm
catalyst-unstable ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 4:42pm

Copy link

changeset-bot bot commented Jul 30, 2024

🦋 Changeset detected

Latest commit: 4f6c67f

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

This PR includes changesets to release 1 package
Name Type
@bigcommerce/create-catalyst Minor

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

packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
packages/create-catalyst/src/commands/integration.ts Outdated Show resolved Hide resolved
Comment on lines 89 to 103
const envVars: string[] = [];
const lines = envVarDiff.split('\n');
const envPattern = /^\+([A-Z_]+)=/;

lines.forEach((line) => {
const match = line.match(envPattern);

if (match) {
envVars.push(match[1]);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here. You could git show the file and drop it into dotenv.parse I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This parses out just the new additions - what happens if an integration developer for some reason deletes some other env vars from their example that diverge from main?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately importing dotenv.parse throws:

Error: Dynamic require of "fs" is not supported

This can be fixed by adding external: ['dotenv'], to the tsup config, but not sure if that's something we want to do, or if we just keep the regex approach

Copy link
Contributor

github-actions bot commented Aug 7, 2024

⚡️🏠 Lighthouse report

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

🖥️ Desktop

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

Category Score
🟠 Performance 81
🟢 Accessibility 100
🟢 Best practices 96
🟠 SEO 82

📱 Mobile

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

Category Score
🟢 Performance 97
🟢 Accessibility 100
🟢 Best practices 96
🟠 SEO 85

spaces: 2,
});

console.log('Integration created successfully.');
Copy link
Contributor

Choose a reason for hiding this comment

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

🍹 Be cool to log the integration name (in a branded/readable form, maybe just the name from the manifest?) eventually

@matthewvolk matthewvolk added this pull request to the merge queue Aug 7, 2024
Merged via the queue into main with commit d7d5a96 Aug 7, 2024
13 checks passed
@matthewvolk matthewvolk deleted the integrations/create-patch branch August 7, 2024 19:08
@github-actions github-actions bot mentioned this pull request Aug 7, 2024
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.

3 participants