Skip to content
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
108 changes: 108 additions & 0 deletions .github/scripts/prevent-invalid-changesets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
const fs = require("fs");

module.exports = async ({ core, exec }) => {
try {
await exec.exec("git", [
"fetch",
"https://github.com/bigcommerce/catalyst.git",
"integrations/makeswift",
]);

const { stdout } = await exec.getExecOutput("git", [
"diff",
"--name-only",
`origin/integrations/makeswift...HEAD`,
]);

const allFilenames = stdout.split("\n").filter((line) => line.trim());
const changesetFilenames = allFilenames.filter(
(file) => file.startsWith(".changeset/") && file.endsWith(".md")
);

if (changesetFilenames.length === 0) {
core.info("No changeset files found to validate");
return;
}

core.info(`Found ${changesetFilenames.length} changeset files to validate`);

for (const filename of changesetFilenames) {
core.info(`Checking ${filename}...`);

// .changeset/*.md filenames should only contain alphanumeric characters, hyphens, and underscores
if (!/^\.changeset\/[a-zA-Z0-9_-]+\.md$/.test(filename)) {
core.setFailed(`Invalid filename pattern: ${filename}`);
return;
}

// extra defense against path traversal attacks
if (
filename.includes("..") ||
(filename.includes("/") && !filename.startsWith(".changeset/"))
) {
core.setFailed(`Suspicious file path: ${filename}`);
return;
}

if (!fs.existsSync(filename)) {
core.setFailed(`File not found: ${filename}`);
return;
}

// check file size (limit to 100KB)
const stats = fs.statSync(filename);
if (stats.size > 102400) {
core.error(`File too large`, { file: filename });
core.setFailed(`File ${filename} is too large`);
return;
}

if (stats.isSymbolicLink()) {
core.error(`Symlinks are not allowed`, { file: filename });
core.setFailed(`File ${filename} is a symlink`);
return;
}

const content = fs.readFileSync(filename, "utf8");

// starts with "---", captures everything until the next "---"
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);

if (!frontmatterMatch) {
core.error(`Failed to extract frontmatter or file has no frontmatter`, {
file: filename,
});
core.setFailed(`File ${filename} has invalid or missing frontmatter`);
return;
}

const frontmatter = frontmatterMatch[1];

// extract all packages starting with "@bigcommerce/
const packageMatches = frontmatter.match(/"@bigcommerce\/[^"]+"/g);

if (packageMatches) {
const invalidPackages = packageMatches.filter(
(pkg) => pkg !== '"@bigcommerce/catalyst-makeswift"'
);

if (invalidPackages.length > 0) {
core.error(
`Invalid package found in changeset file. Only @bigcommerce/catalyst-makeswift is allowed.`,
{ file: filename }
);
core.setFailed(
`File ${filename} contains invalid packages: ${invalidPackages.join(
", "
)}`
);
return;
}
}
}

core.info("All changeset files validated successfully");
} catch (error) {
core.setFailed(`Validation failed: ${error.message}`);
}
};
27 changes: 27 additions & 0 deletions .github/workflows/prevent-invalid-changesets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Prevent invalid packages for Changesets

on:
pull_request:
branches:
- integrations/makeswift

permissions:
contents: read
pull-requests: read

jobs:
validate-changesets:
runs-on: ubuntu-latest
name: Validate Changeset Packages
steps:
- name: Checkout PR code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Validate changesets only target @bigcommerce/catalyst-makeswift
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/prevent-invalid-changesets.js')
await script({ core, exec })
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist
.turbo
.vscode/**/*
!.vscode/settings.example.json
!.vscode/launch.example.json
.idea
.vercel
.catalyst
Expand Down
38 changes: 38 additions & 0 deletions .vscode/launch.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Catalyst: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "pnpm run dev",
"cwd": "${workspaceFolder}"
},
{
"name": "Catalyst: debug client-side",
"type": "chrome", // Use "chrome" "firefox" or "msedge" as needed
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/core"
},
{
"name": "Catalyst: debug full stack",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/core",
"program": "${workspaceFolder}/core/node_modules/next/dist/bin/next",
"args": ["dev"],
"runtimeArgs": ["--inspect"],
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "development"
},
"serverReadyAction": {
"action": "openExternally",
"killOnServerStop": true,
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s"
}
}
]
}
78 changes: 66 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,106 @@ In addition to `canary`, we also maintain the `integrations/makeswift` branch, w

To contribute to the `integrations/makeswift` branch, you can create a new branch off of `integrations/makeswift` and submit a PR against that branch.

### Pulling updates from `canary` into `integrations/makeswift`
### Keeping `integrations/makeswift` in sync with `canary`

We aim to keep `integrations/makeswift` in sync with `canary`. To do this, we frequently pull the latest code from `canary` into `integrations/makeswift`.
Except for the additional code required to integrate with Makeswift, the `integrations/makeswift` branch is a mirror of the `canary` branch. This means that the `integrations/makeswift` branch should be kept in sync with the `canary` branch as much as possible.

To pull the latest code from `canary` into `integrations/makeswift`, you can follow these steps:
#### Prerequisites

1. Fetch the latest code from `canary`:
In order to complete the following steps, you will need to have met the following prerequisites:

- You have a remote named `origin` pointing to the [`bigcommerce/catalyst` repository on GitHub](https://github.com/bigcommerce/catalyst). If you do not, you can add it with `git remote add origin ssh://git@github.com/bigcommerce/catalyst.git`, or if you are not using SSH, you can use `git remote add origin https://github.com/bigcommerce/catalyst.git`.
- You have rights to push to the `integrations/makeswift` branch on GitHub.

#### Steps

To pull the latest code from `canary` into `integrations/makeswift`, follow the steps below:

1. Ensure your local `canary` branch is synchronized with the remote `canary` branch:

```bash
git fetch origin
git checkout canary
git pull
git reset --hard origin/canary
```

2. Fetch the latest code from `integrations/makeswift`:

```bash
git checkout integrations/makeswift
git pull
git checkout -B integrations/makeswift origin/integrations/makeswift
```

> [!TIP]
> The `-B` flag means "create branch or reset existing branch":
>
> - If the local branch doesn't exist, it creates it from `origin/integrations/makeswift`
> - If the local branch exists, it resets it to match `origin/integrations/makeswift`

3. Checkout a new branch from `integrations/makeswift`:

```bash
git checkout -b {new-branch-name}
```

4. Merge `canary` into the new branch:
4. Merge `canary` into `{new-branch-name}`, and resolve merge conflicts, if necessary:

```bash
git merge canary
```

5. After resolving any merge conflicts, open a new PR in GitHub to merge your new branch into `integrations/makeswift`. This PR should be code reviewed and approved before the next steps.
> [!WARNING]
> There are a number of "gotchas" that you need to be aware of when merging `canary` into `integrations/makeswift`:
>
> - The `name` field in `core/package.json` should remain `@bigcommerce/catalyst-makeswift`
> - The `version` field in `core/package.json` should remain whatever the latest published `@bigcommerce/catalyst-makeswift` version was
> - The `.changeset/` directory should not include any files that reference the `"@bigcommerce/catalyst-core"` package. If these files are merged into `integrations/makeswift`, they will cause the `Changesets Release` GitHub Action in `.github/workflows/changesets-release.yml` to fail with the error: `Error: Found changeset for package @bigcommerce/catalyst-core which is not in the workspace`
>
> _Note: A [GitHub Action is in place](.github/workflows/prevent-invalid-changesets.yml) to help prevent invalid changesets from being merged into `integrations/makeswift`. Do not merge your PR if this GitHub Action fails._

5. After resolving any merge conflicts, open a new PR in GitHub to merge your `{new-branch-name}` into `integrations/makeswift`. This PR should be code reviewed and approved before the next steps.

6. Rebase the changes onto the local `integrations/makeswift` branch in order to make the branches 1-1 and keep a linear commit history.
6. Once your PR is approved, the next step is to incorporate the merge commit from `{new-branch-name}` into `integrations/makeswift`. Do not use the merge button in the GitHub UI to merge your PR. Instead, you'll want to run the following command locally:

```bash
git checkout integrations/makeswift
git rebase {new-branch-name}
```

7. Push the changes up to GitHub, which will automatically close the open PR from step 6.
> [!IMPORTANT]
> It is very important that you do not use the merge button in the GitHub UI to merge your PR. The problem with the "Squash and merge" or "Rebase and merge" button in GitHub is that it **rewrites history and throws away your local merge commit**. Instead, locally rebasing your `integrations/makeswift` branch onto your `{new-branch-name}` branch preserves the merge commit from step 4, which will properly set the new merge base for future merges from `canary` into `integrations/makeswift`.

7. Push the changes up to GitHub, which will automatically close the open PR from step 5.

```bash
git push
git push origin integrations/makeswift
```

## Cutting new releases

This repository uses [Changesets](https://github.com/changesets/changesets) to manage version bumps, changelogs, and publishing to the NPM registry. Whenever you create a pull request, you should think about whether the changes you are making warrant a version bump or a changelog entry.

If you are not sure, you can ask in the PR. Here are some examples:

- If your pull request introduces changes to the root `README.md`: _Likely does not warrant a version bump or changelog entry, therefore your PR does not need to include a Changeset._
- If your pull request introduces changes to `core/`, e.g., `core/app/`, or any of the packages in `packages/`: _Likely warrants a version bump and changelog entry, therefore your PR should include a Changeset._

You can run the following command to create a new version bump and changelog entry:

```bash
pnpm changeset
```

An interactive prompt will take you through the process of [adding your changeset](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

Once you've completed the interactive prompt, you'll see a new file in the `.changeset/` directory. This file contains the version bump and changelog entry for your changes. You should commit this file to the branch associated with your PR.

Once your PR is merged, our [GitHub Action](.github/workflows/changesets-release.yml) will handle the process of versioning and updating the changelog, (and in the case of `packages/`, publishing your changes to NPM). No further action is needed from you.

> [!WARNING]
> It is very important that `.changeset/*.md` files targeting packages in `packages/` are not merged into the `integrations/makeswift` branch. While it is technically feasible to release packages from `integrations/makeswift`, we never want to do this. If we did this, we would need to sync the branches in the opposite direction, which was never intended to happen.
>
> _Note: A [GitHub Action is in place](.github/workflows/prevent-invalid-changesets.yml) to help prevent invalid changesets from being merged into `integrations/makeswift`. Do not merge your PR if this GitHub Action fails._

## Other Ways to Contribute

- Consider reporting bugs, contributing to test coverage, or helping spread the word about Catalyst.
Expand Down
27 changes: 27 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 1.0.0

### Major Changes

- [`7f1e73d`](https://github.com/bigcommerce/catalyst/commit/7f1e73d) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0 (see [`core/CHANGELOG.md`](https://github.com/bigcommerce/catalyst/blob/canary/core/CHANGELOG.md#100) for more details)

### Patch Changes

- [`11ecddf`](https://github.com/bigcommerce/catalyst/commit/11ecddf) Thanks [@jorgemoya](https://github.com/jorgemoya)! - Re-enable Customer Group Slot component
- [`281be00`](https://github.com/bigcommerce/catalyst/commit/281be00) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: configure NextAuth cookies to work inside of the Makeswift Builder's canvas
- [`dea8eab`](https://github.com/bigcommerce/catalyst/commit/dea8eab) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: flicker on rerendering `<ProductList />`
- [`2cdd078`](https://github.com/bigcommerce/catalyst/commit/2cdd078) Thanks [@arvinpoddar](https://github.com/arvinpoddar)! - fix: bump makeswift runtime version to `v0.24.0`, fixing issue with editing on SSGd pages
- [`5c198be`](https://github.com/bigcommerce/catalyst/commit/5c198be) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: disable cookie- and language-based locale detection in the builder
- [`a298d28`](https://github.com/bigcommerce/catalyst/commit/a298d28) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - Upgrade `@makeswift/runtime` to the [0.23.3 release](https://github.com/makeswift/makeswift/releases).
- [`34ac728`](https://github.com/bigcommerce/catalyst/commit/34ac728) Thanks [@arvinpoddar](https://github.com/arvinpoddar)! - refactor: upgrade Makeswift runtime and use provided utility to construct draft request
- [`5ea6d6d`](https://github.com/bigcommerce/catalyst/commit/5ea6d6d) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - Usability/terminology fix, Accordions -> Accordion
- [`8e8b31c`](https://github.com/bigcommerce/catalyst/commit/8e8b31c) Thanks [@pvaladez](https://github.com/pvaladez)! - Add core/lib/makeswift/components folder to tailwind config content property so that tailwind classes can be used in components there.
- [`89e912e`](https://github.com/bigcommerce/catalyst/commit/89e912e) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - Upgrade to the latest version of Makeswift runtime (0.24.6)
- [`e5ad65c`](https://github.com/bigcommerce/catalyst/commit/e5ad65c) Thanks [@fikrikarim](https://github.com/fikrikarim)! - Fix: missing **Add-to-cart** feedback on `integrations/makeswift` branch: Toast success notification now appears when **Add to cart** is clicked. Cart button badge in the header now updates to show `1` when the first item is added.
- [`11ecddf`](https://github.com/bigcommerce/catalyst/commit/11ecddf) Thanks [@jorgemoya](https://github.com/jorgemoya)! - Unify Makeswift component registrations
- [`e6a98a4`](https://github.com/bigcommerce/catalyst/commit/e6a98a4) Thanks [@arvinpoddar](https://github.com/arvinpoddar)! - fix: upgrade Makeswift runtime. Includes prop editing performance improvements, a bug fix for link editing, and a fix to avoid CSS class collision by using a different Emotion key.
- [`e968366`](https://github.com/bigcommerce/catalyst/commit/e968366) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: `useCompareDrawer` does not throw on missing context
- [`037663b`](https://github.com/bigcommerce/catalyst/commit/037663b) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: configure `NEXT_LOCALE` cookie to work inside of the Makeswift Builder's canvas
- [`881a532`](https://github.com/bigcommerce/catalyst/commit/881a532) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix(theming): changing price label colors has no effect
- [`12d60da`](https://github.com/bigcommerce/catalyst/commit/12d60da) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: deletion of `NEXT_LOCALE` cookie triggers page rerender
- [`ed3202d`](https://github.com/bigcommerce/catalyst/commit/ed3202d) Thanks [@alekseygurtovoy](https://github.com/alekseygurtovoy)! - fix: support switching of the page's locale in the Makeswift Builder

## 0.24.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Major Changes

- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0
- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0 (see [`core/CHANGELOG.md`](../../core/CHANGELOG.md#100) for more details)

### Minor Changes

Expand Down
2 changes: 1 addition & 1 deletion packages/create-catalyst/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Major Changes

- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0
- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0 (see [`core/CHANGELOG.md`](../../core/CHANGELOG.md#100) for more details)

## 0.22.0

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-catalyst/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Major Changes

- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0
- [#2435](https://github.com/bigcommerce/catalyst/pull/2435) [`cd4bd60`](https://github.com/bigcommerce/catalyst/commit/cd4bd604739b0cea4b622b08ebbde4cea953fcae) Thanks [@matthewvolk](https://github.com/matthewvolk)! - Release 1.0.0 (see [`core/CHANGELOG.md`](../../core/CHANGELOG.md#100) for more details)

### Patch Changes

Expand Down