Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Changed the TypeScript packages that talk to the API to carry the Spree version (#14980)

Damian Legawiecffe7116f4581
diff --git a/.changeset/README.md b/.changeset/README.md
index 1d34cfcc07..d302629d5e 100644
--- a/.changeset/README.md
+++ b/.changeset/README.md
@@ -3,37 +3,63 @@
One workspace-wide Changesets instance — add changesets here (`pnpm changeset`
from the repo root), never in per-package `.changeset/` directories.
-The dashboard packages (`@spree/dashboard`, `@spree/dashboard-core`,
-`@spree/dashboard-ui`) are a `fixed` group: they version and release together
-under one version number, so a scaffolded app always installs a trio that was
-released as a set. `@spree/admin-sdk` versions independently — it's a
-standalone API client, not part of the dashboard release train.
+## Packages released with Spree
-## Release trains
+The packages that talk to the Spree API — `@spree/sdk`, `@spree/admin-sdk`,
+`@spree/seller-sdk`, `@spree/core`, `@spree/dashboard`,
+`@spree/dashboard-core`, `@spree/dashboard-ui` and `@spree/seller-dashboard` —
+are one `fixed` group and carry the version of the Spree gems, in npm's
+spelling: gems `6.0.0.rc7` ship as `6.0.0-rc.7`, gems `6.0.2` as `6.0.2`. A
+bug report naming `@spree/[email protected]` therefore names the backend too.
-`@spree/sdk` is a stable 1.x package whose releases track Spree releases;
-everything else (dashboard trio, admin-sdk, cli, create-spree-app) is the
-Developer Preview train releasing continuously. The two run on different
-schedules, so:
+`@spree/cli` and `create-spree-app` manage projects rather than talk to the
+API, so they keep their own versions and release on their own tags.
-- **Preview release** (the frequent one): `pnpm version:preview` — versions
- everything pending except `@spree/sdk`, whose changesets stay queued.
-- **SDK release** (with a Spree release): plain `pnpm exec changeset version`.
- The preview queues drain continuously, so on SDK release day they're
- usually empty; if something preview-side is pending and shouldn't ship,
- hold it back with additional `--ignore` flags.
+## Releasing
-Held-back changesets are preserved, not deleted — `--ignore` defers, it
-doesn't discard.
+Every release is published by `.github/workflows/release.yml` from a tag
+pushed on a commit already on `main`. The workflow checks the tag against the
+versions in the repository first, and skips any version already published, so
+a failed release can be re-run.
+
+| Tag | Publishes |
+| --- | --- |
+| `v6.0.0.rc7` | the Spree gems and the packages in the group |
+| `@spree/[email protected]` | `@spree/cli` |
+| `[email protected]` | `create-spree-app` |
+
+**A Spree release:**
+
+1. Bump `Spree::VERSION` in `spree/core/lib/spree/core/version.rb`.
+2. Run `pnpm version:packages`. It runs `changeset version`, then moves every
+ package in the group to the Spree version. A package with no changes still
+ gets the new version and a changelog entry saying so. Pending changesets
+ for the tools are versioned too.
+3. Merge, then push the Spree tag, plus a tag for each tool whose version
+ changed: `git push origin v6.0.0.rc7 @spree/[email protected]`.
+
+**A tool release between Spree releases:** run `pnpm version:tools`, which
+versions only the tools and leaves the group's changesets for the next Spree
+release. Merge, then push the tool's tag.
+
+GitHub starts no workflow for tags pushed more than three at a time, so push
+at most three tags at once.
+
+Never run plain `changeset version` for a release: it would give the group a
+version computed from the changesets. For packages in the group, the bump type
+a changeset names only decides which heading its changelog entry goes under.
+
+`--ignore` defers changesets, it doesn't discard them.
## Peer ranges between workspace packages
Never use `workspace:^` for a peerDependency on another workspace package
(e.g. dashboard-core → dashboard-ui). Changesets majors a peer-dependent
-whenever its peer's new version escapes the declared range, and on 0.x a
-caret range escapes on every minor — inside the fixed group that cascades a
-routine minor release into 1.0.0. Use wide literal ranges instead
-(`>=0.10.0 <2`), paired with `onlyUpdatePeerDependentsWhenOutOfRange` in
-`config.json`.
+whenever its peer's new version escapes the declared range, and that cascades
+through the fixed group. Use a literal range instead, paired with
+`onlyUpdatePeerDependentsWhenOutOfRange` in `config.json`.
+`pnpm version:packages` sets those ranges on every release to that release and
+anything after it in the same major (`>=6.0.1-rc.1 <7.0.0-0`); starting the range
+at the full version is what lets a patch release candidate satisfy it.
Docs: https://github.com/changesets/changesets
diff --git a/.changeset/cli-docker-not-running.md b/.changeset/cli-docker-not-running.md
deleted file mode 100644
index 595c76d17f..0000000000
--- a/.changeset/cli-docker-not-running.md
+++ /dev/null
@@ -1,7 +0,0 @@
----
-"@spree/cli": patch
----
-
-`spree upgrade`, `spree db:reset` and `spree db:console` now say plainly when Docker is not running, and show Docker's own error for other failures instead of the command that failed.
-
-`spree upgrade` now asks before running the upgrade tasks (data backfills), so they can be skipped like the other steps.
diff --git a/.changeset/config.json b/.changeset/config.json
index 5df1367655..13f454abf1 100644
--- a/.changeset/config.json
+++ b/.changeset/config.json
@@ -2,7 +2,18 @@
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "spree/spree" }],
"commit": false,
- "fixed": [["@spree/dashboard", "@spree/dashboard-core", "@spree/dashboard-ui"]],
+ "fixed": [
+ [
+ "@spree/sdk",
+ "@spree/admin-sdk",
+ "@spree/seller-sdk",
+ "@spree/core",
+ "@spree/dashboard",
+ "@spree/dashboard-core",
+ "@spree/dashboard-ui",
+ "@spree/seller-dashboard"
+ ]
+ ],
"linked": [],
"access": "public",
"baseBranch": "main",
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 223b497d85..b4380764f0 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -426,9 +426,9 @@ Published packages use [Changesets](https://github.com/changesets/changesets) fo
pnpm changeset # from the repo root; select the affected package(s)
```
-This creates a changeset file describing your changes. Commit it with your PR. The dashboard packages (`@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui`) are a fixed group and always release together under one version — a changeset naming any of them bumps all three. See `.changeset/README.md` for the release trains.
+This creates a changeset file describing your changes. Commit it with your PR. The packages that talk to the Spree API (`@spree/sdk`, `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core`, `@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui`, `@spree/seller-dashboard`) are a fixed group: they always release together, under the version of the Spree gems. See `.changeset/README.md`.
-Releasing is a two-step flow: a maintainer consumes the pending changesets (`pnpm version:preview` for the Developer Preview train, `pnpm changeset version` to include `@spree/sdk` — writes the CHANGELOGs and bumps `package.json`) and merges that bump to `main`; the release jobs in `.github/workflows/packages.yml` then detect the unpublished versions and publish with npm provenance via Trusted Publishing. Dist-tags follow the version, matching the rule in the release jobs: `0.x` versions (the Developer Preview line) publish under `next`, prerelease versions under `beta`, and stable versions as `latest`.
+Releasing is a two-step flow: a maintainer bumps `Spree::VERSION` and runs `pnpm version:packages`, which consumes the pending changesets (writes the CHANGELOGs and bumps `package.json`), and merges that bump to `main`. Pushing a tag then publishes from `.github/workflows/release.yml`: `v<Spree version>` releases the gems and the packages that share the Spree version, and `@spree/cli@<version>` or `create-spree-app@<version>` releases that tool. `pnpm version:tools` versions the tools alone, for a release between Spree releases. Dist-tags follow the version: prerelease versions publish under `beta`, stable versions as `latest`.
Private packages (`@spree/dashboard-starter`, `@spree/dashboard-plugin-example`, `@spree/sdk-core`) are never published and don't need changesets.
diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml
index 749fc6f3f1..ad10b73a34 100644
--- a/.github/workflows/packages.yml
+++ b/.github/workflows/packages.yml
@@ -156,7 +156,7 @@ jobs:
- run: pnpm turbo build --cache-dir=.turbo
# `pnpm pack` rewrites workspace: ranges to real versions, exactly as
- # `pnpm publish` does in the release jobs below.
+ # `pnpm publish` does in release.yml.
- name: Pack packages
run: |
for pkg in core admin-sdk seller-sdk dashboard-ui dashboard-core dashboard seller-dashboard cli; do
@@ -391,489 +391,3 @@ jobs:
exit 1
fi
echo "All E2E shards passed."
-
- release-sdk:
- name: "SDK - Release"
- needs: check
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- defaults:
- run:
- working-directory: packages/sdk
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
- working-directory: .
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
- working-directory: .
-
- - name: Check if version is published
- id: check
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if npm view @spree/sdk@$PACKAGE_VERSION version 2>/dev/null; then
- echo "published=true" >> $GITHUB_OUTPUT
- else
- echo "published=false" >> $GITHUB_OUTPUT
- fi
-
- # @spree/sdk is the one package with a stable `latest` that real
- # storefronts already depend on (`^1.2.1` = the 5.x Store API). A 6.0
- # prerelease published without a tag would land on `latest` and be
- # resolved by every one of them on their next install, so the tag is
- # load-bearing here rather than a nicety.
- - name: Determine npm tag
- id: tag
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if echo "$PACKAGE_VERSION" | grep -qE '^0\.'; then
- echo "tag=next" >> $GITHUB_OUTPUT
- elif echo "$PACKAGE_VERSION" | grep -qE '[-]'; then
- echo "tag=beta" >> $GITHUB_OUTPUT
- else
- echo "tag=latest" >> $GITHUB_OUTPUT
- fi
-
- - name: Build and Publish
- if: steps.check.outputs.published == 'false'
- run: pnpm turbo build --filter=@spree/sdk && npm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }}
-
- release-core:
- name: "Core - Release"
- needs: [check, scaffolded-app]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- defaults:
- run:
- working-directory: packages/core
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
- working-directory: .
-
- # See release-sdk: Trusted Publishing needs a newer npm than Node 22 ships.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
- working-directory: .
-
- - name: Check if version is published
- id: check
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if npm view @spree/core@$PACKAGE_VERSION version 2>/dev/null; then
- echo "published=true" >> $GITHUB_OUTPUT
- else
- echo "published=false" >> $GITHUB_OUTPUT
- fi
-
- # Unlike @spree/sdk, there is no older stable line to protect, so 0.x
- # releases go to `latest`: that is what the npm page shows and what a
- # plain `npm install @spree/core` resolves.
- - name: Determine npm tag
- id: tag
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if echo "$PACKAGE_VERSION" | grep -qE '[-]'; then
- echo "tag=beta" >> $GITHUB_OUTPUT
- else
- echo "tag=latest" >> $GITHUB_OUTPUT
- fi
-
- - name: Build and Publish
- if: steps.check.outputs.published == 'false'
- run: pnpm turbo build --filter=@spree/core && npm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }}
-
- release-admin-sdk:
- name: "Admin SDK - Release"
- needs: [check, scaffolded-app]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- defaults:
- run:
- working-directory: packages/admin-sdk
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
- working-directory: .
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
- working-directory: .
-
- - name: Check if version is published
- id: check
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if npm view @spree/admin-sdk@$PACKAGE_VERSION version 2>/dev/null; then
- echo "published=true" >> $GITHUB_OUTPUT
- else
- echo "published=false" >> $GITHUB_OUTPUT
- fi
-
- - name: Determine npm tag
- id: tag
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- # Pre-1.0 / Developer Preview releases ship under the `next` tag so
- # `npm install @spree/admin-sdk` doesn't pick them up as `latest`.
- if echo "$PACKAGE_VERSION" | grep -qE '^0\.'; then
- echo "tag=next" >> $GITHUB_OUTPUT
- elif echo "$PACKAGE_VERSION" | grep -qE '[-]'; then
- echo "tag=beta" >> $GITHUB_OUTPUT
- else
- echo "tag=latest" >> $GITHUB_OUTPUT
- fi
-
- - name: Build and Publish
- if: steps.check.outputs.published == 'false'
- run: pnpm turbo build --filter=@spree/admin-sdk && npm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }}
-
- release-cli:
- name: "CLI - Release"
- # Gated on release-dashboard and release-seller: the CLI tarball embeds the
- # dashboard-starter AND seller-dashboard-starter templates with floating
- # ranges floored at the @spree/dashboard{,-ui,-core} and @spree/seller-*
- # versions being released — publishing it before those versions exist on
- # npm would ship a scaffold whose install fails until they land.
- needs: [check, scaffolded-app, release-dashboard, release-seller]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- defaults:
- run:
- working-directory: packages/cli
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
- working-directory: .
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
- working-directory: .
-
- - name: Check if version is published
- id: check
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if npm view @spree/cli@$PACKAGE_VERSION version 2>/dev/null; then
- echo "published=true" >> $GITHUB_OUTPUT
- else
- echo "published=false" >> $GITHUB_OUTPUT
- fi
-
- - name: Determine npm tag
- id: tag
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if echo "$PACKAGE_VERSION" | grep -qE '[-]'; then
- echo "tag=beta" >> $GITHUB_OUTPUT
- else
- echo "tag=latest" >> $GITHUB_OUTPUT
- fi
-
- # Build the CLI with its workspace deps first. The CLI bundles
- # @spree/admin-sdk (tsup `noExternal: [/.*/]`), so esbuild must resolve
- # that package's `dist/` at build time. A bare `pnpm build` only builds
- # the CLI; `turbo build --filter` follows the `^build` graph and builds
- # @spree/admin-sdk first (matching the SDK release jobs above).
- - name: Build
- if: steps.check.outputs.published == 'false'
- run: pnpm turbo build --filter=@spree/cli
- working-directory: .
-
- # Use `pnpm publish`, not `npm publish`: the CLI keeps @spree/admin-sdk as a
- # `workspace:` devDependency, which `npm publish` would ship to the registry
- # verbatim (EUNSUPPORTEDPROTOCOL on install). `pnpm publish` rewrites the
- # `workspace:` protocol to the resolved semver range while packing.
- - name: Publish
- if: steps.check.outputs.published == 'false'
- run: pnpm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }} --no-git-checks
-
- # The dashboard packages are source-only for everything the host's Vite
- # compiles, but their Node-side Vite-plugin entries are compiled to JS by a
- # per-package prepublishOnly hook (Node refuses to type-strip .ts under
- # node_modules). They depend on each other via workspace:^, which
- # `pnpm publish` rewrites to the concrete ^x.y.z while packing — so they
- # publish in dependency order from a single job. Pre-1.0 Developer Preview versions ship under the `next` tag,
- # matching @spree/admin-sdk.
- release-dashboard:
- name: "Dashboard packages - Release"
- # Gated on release-admin-sdk: the dashboard packages' workspace:^ ranges
- # are rewritten to concrete ^x.y.z of @spree/admin-sdk while packing — a
- # same-push admin-sdk version bump must land on npm first, or installs of
- # the just-published dashboard packages fail until it does. (release-cli
- # waits on this job, completing the admin-sdk → dashboard → cli chain.)
- # The same holds for @spree/core, which dashboard-core, dashboard-ui and
- # dashboard depend on.
- needs: [check, scaffolded-app, release-admin-sdk, release-core]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
-
- # As in the seller job: prepublishOnly compiles the Vite-plugin entries
- # with tsup, so the workspace dependency graph must be built first.
- - name: Build
- run: pnpm turbo build --filter=@spree/dashboard
-
- - name: Publish unpublished versions (dependency order)
- run: |
- set -euo pipefail
- for pkg in dashboard-ui dashboard-core dashboard; do
- cd "packages/$pkg"
- NAME=$(node -p "require('./package.json').name")
- VERSION=$(node -p "require('./package.json').version")
- if npm view "$NAME@$VERSION" version 2>/dev/null; then
- echo "$NAME@$VERSION already published — skipping."
- else
- if echo "$VERSION" | grep -qE '^0\.'; then TAG=next
- elif echo "$VERSION" | grep -qE '[-]'; then TAG=beta
- else TAG=latest
- fi
- echo "Publishing $NAME@$VERSION with tag $TAG..."
- pnpm publish --provenance --access public --tag "$TAG" --no-git-checks
- fi
- cd ../..
- done
-
- # The seller packages mirror the admin pair above: @spree/seller-sdk is the
- # Seller API client, @spree/seller-dashboard the panel built on it. They
- # publish on the same pre-1.0 `next` scheme, in dependency order, and must
- # land before release-cli — the CLI tarball embeds the seller-dashboard
- # starter with ranges floored at these versions.
- release-seller:
- name: "Seller packages - Release"
- # Gated on release-core for the same reason as release-dashboard.
- needs: [check, scaffolded-app, release-core]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
-
- # Each package's prepublishOnly runs tsup while packing, and tsup bundles
- # its workspace dependencies from their dist/ — @spree/seller-sdk pulls
- # in the private @spree/sdk-core, which nothing has built yet in a fresh
- # checkout. Build the graph first; `--filter` follows ^build, exactly as
- # the SDK and CLI release jobs do.
- - name: Build
- run: pnpm turbo build --filter=@spree/seller-sdk --filter=@spree/seller-dashboard
-
- - name: Publish unpublished versions (dependency order)
- run: |
- set -euo pipefail
- for pkg in seller-sdk seller-dashboard; do
- cd "packages/$pkg"
- NAME=$(node -p "require('./package.json').name")
- VERSION=$(node -p "require('./package.json').version")
- if npm view "$NAME@$VERSION" version 2>/dev/null; then
- echo "$NAME@$VERSION already published — skipping."
- else
- if echo "$VERSION" | grep -qE '^0\.'; then TAG=next
- elif echo "$VERSION" | grep -qE '[-]'; then TAG=beta
- else TAG=latest
- fi
- echo "Publishing $NAME@$VERSION with tag $TAG..."
- pnpm publish --provenance --access public --tag "$TAG" --no-git-checks
- fi
- cd ../..
- done
-
- # The dashboard-starter template is NOT distributed via a template repo:
- # `@spree/cli` and `create-spree-app` embed it at build time
- # (scripts/sync-starter.mjs renders packages/dashboard-starter
- # with floating ranges floored at the released versions into their
- # templates/ dir), so scaffolds install the newest dashboard release even
- # from an older CLI, and never anything older than the template was built
- # against.
-
- release-create-spree-app:
- name: "create-spree-app - Release"
- # Gated on release-cli: the dashboard scaffold phase delegates to the
- # project-local `spree add dashboard`, so a create-spree-app that offers
- # the dashboard must not publish before the CLI implementing that command
- # (with the embedded starter) is on npm. Completes the release chain:
- # admin-sdk → dashboard → cli → create-spree-app.
- needs: [check, scaffolded-app, release-cli]
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: ubuntu-latest
- permissions:
- contents: write
- pull-requests: write
- id-token: write
- defaults:
- run:
- working-directory: packages/create-spree-app
- steps:
- - uses: actions/checkout@v7
-
- - uses: pnpm/action-setup@v6
-
- - uses: actions/[email protected]
- with:
- node-version: 22
- cache: pnpm
- registry-url: https://registry.npmjs.org
-
- - run: pnpm install --frozen-lockfile
- working-directory: .
-
- # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
- # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
- # npm's own files in place and the in-flight install can't find
- # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
- # to a separate prefix and prepend to PATH instead.
- - name: Upgrade npm for Trusted Publishing support
- run: |
- npm install -g npm@latest --prefix="$HOME/.npm-global"
- echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
- working-directory: .
-
- - name: Check if version is published
- id: check
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if npm view create-spree-app@$PACKAGE_VERSION version 2>/dev/null; then
- echo "published=true" >> $GITHUB_OUTPUT
- else
- echo "published=false" >> $GITHUB_OUTPUT
- fi
-
- # Stable today, but a prerelease must never become the default for
- # `npx create-spree-app` — the entry point every new project runs.
- - name: Determine npm tag
- id: tag
- run: |
- PACKAGE_VERSION=$(node -p "require('./package.json').version")
- if echo "$PACKAGE_VERSION" | grep -qE '[-]'; then
- echo "tag=beta" >> $GITHUB_OUTPUT
- else
- echo "tag=latest" >> $GITHUB_OUTPUT
- fi
-
- - name: Build and Publish
- if: steps.check.outputs.published == 'false'
- run: pnpm build && npm publish --provenance --access public --tag ${{ steps.tag.outputs.tag }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d4c37c795c..da25a201fe 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,12 +1,48 @@
name: Release
+# Every release starts from a tag pushed on a commit already on main:
+#
+# v6.0.0.rc7 the Spree gems, and the npm packages that share the
+# Spree version (SDKs, @spree/core, dashboards)
+# @spree/[email protected] @spree/cli
+# [email protected] create-spree-app
+#
+# Each job skips versions already on its registry, so a release that failed
+# part-way can be re-run.
on:
push:
- tags: ['v*']
+ tags: ['v*', '@spree/cli@*', 'create-spree-app@*']
+
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
+
+permissions:
+ contents: read
jobs:
+ verify:
+ name: Verify the tag
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ with:
+ fetch-depth: 0
+
+ - uses: actions/[email protected]
+ with:
+ node-version: 22
+
+ - name: The tagged commit is on main
+ run: git merge-base --is-ancestor "$GITHUB_SHA" origin/main
+
+ - name: The tag matches the versions in the repository
+ run: node scripts/publish-packages.mjs verify "$GITHUB_REF_NAME"
+
release-gems:
name: Release gems to RubyGems
+ needs: verify
+ if: startsWith(github.ref_name, 'v')
runs-on: ubuntu-latest
environment: release
permissions:
@@ -28,3 +64,39 @@ jobs:
- name: Build and push gems to RubyGems
working-directory: spree
run: bundle exec rake gem:release
+
+ release-npm:
+ name: Release npm packages
+ needs: verify
+ runs-on: ubuntu-latest
+ # Must match the environment in each package's npm Trusted Publishing setting.
+ environment: release
+ permissions:
+ contents: read
+ id-token: write
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - uses: pnpm/action-setup@v6
+
+ - uses: actions/[email protected]
+ with:
+ node-version: 22
+ cache: pnpm
+ registry-url: https://registry.npmjs.org
+
+ - run: pnpm install --frozen-lockfile
+
+ # Trusted Publishing requires npm >= 11.5.1, but the bundled npm
+ # on Node 22 is 10.9.7. A plain `npm install -g npm@latest` swaps
+ # npm's own files in place and the in-flight install can't find
+ # its own dependencies (MODULE_NOT_FOUND: promise-retry). Install
+ # to a separate prefix and prepend to PATH instead.
+ - name: Upgrade npm for Trusted Publishing support
+ run: |
+ npm install -g npm@latest --prefix="$HOME/.npm-global"
+ echo "$HOME/.npm-global/bin" >> "$GITHUB_PATH"
+
+ - name: Build and publish
+ run: node scripts/publish-packages.mjs publish "$GITHUB_REF_NAME"
diff --git a/CLAUDE.md b/CLAUDE.md
index 635431adac..71960446ae 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -750,7 +750,7 @@ A **Lefthook pre-commit hook** (`lefthook.yml`) regenerates types and Zod schema
### Changesets & Versioning
-Published packages use **Changesets** for versioning — one workspace-wide instance. Place changeset files in the root `.changeset/` directory (`pnpm changeset`), never in per-package directories. The dashboard packages (`@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui`) are a `fixed` group and always release together under one version; `@spree/admin-sdk` versions independently. Two release trains: `pnpm version:preview` cuts the Developer Preview packages while holding back `@spree/sdk` (stable, tracks Spree releases); `pnpm changeset version` includes it. `--ignore` defers changesets, it never discards them.
+Published packages use **Changesets** for versioning — one workspace-wide instance. Place changeset files in the root `.changeset/` directory (`pnpm changeset`), never in per-package directories. The packages that talk to the API (`@spree/sdk`, `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core`, the dashboard trio and `@spree/seller-dashboard`) are one `fixed` group carrying the Spree gem version in npm spelling (`6.0.0.rc7` → `6.0.0-rc.7`); `@spree/cli` and `create-spree-app` version independently. Release with `pnpm version:packages` after bumping `Spree::VERSION` — never plain `changeset version`, whose computed version for the group is overwritten — then push the tags: `v<Spree version>` publishes the gems and the group, `@spree/cli@<version>` / `create-spree-app@<version>` publish a tool (`.github/workflows/release.yml`; `packages.yml` only runs checks). `pnpm version:tools` versions the tools alone between Spree releases. A changeset's bump type only sorts its changelog entry for those packages. `--ignore` defers changesets, it never discards them.
---
diff --git a/docs/developer/cli/quickstart.mdx b/docs/developer/cli/quickstart.mdx
index a478bac893..75dccc1a3d 100644
--- a/docs/developer/cli/quickstart.mdx
+++ b/docs/developer/cli/quickstart.mdx
@@ -96,7 +96,7 @@ spree build --yes # Skip confirmation prompts (for CI)
Upgrade your project to the latest Spree release in one go. It works for both kinds of project:
1. **Update the server** — on a project that runs the prebuilt image, it pulls the latest Spree image. On an [ejected](#spree-eject) project, it updates the Spree gems with `bundle update`.
-2. **Update the `@spree/*` packages** — `@spree/cli` in the project root, and the dashboard packages and Admin SDK in `apps/dashboard` and `apps/seller-dashboard`. Each package moves to the newest release its declared range in `package.json` allows, the same way `bundle update` respects your `Gemfile`. To move to a new major version, change the range in `package.json` first.
+2. **Update the `@spree/*` packages** — `@spree/cli` in the project root, and the dashboard packages and SDKs in `apps/dashboard` and `apps/seller-dashboard`. The dashboard packages and SDKs move to the Spree version your server now runs. `@spree/cli` moves to the newest release its range in `package.json` allows.
3. **Migrate the database** — on a prebuilt-image project, it recreates the containers and the migrations run as they start. On an ejected project, it applies pending migrations.
4. **Run data backfills** — the version-specific steps from the upgrade manifest that convert existing records. An ejected project's app is then restarted so it loads the new gems.
diff --git a/docs/developer/contributing/developing-spree.mdx b/docs/developer/contributing/developing-spree.mdx
index 822d2c2ebb..7ab9ace753 100644
--- a/docs/developer/contributing/developing-spree.mdx
+++ b/docs/developer/contributing/developing-spree.mdx
@@ -335,7 +335,9 @@ pnpm changeset
This creates a changeset file describing your changes. Commit it with your PR.
-Releasing is a two-step flow: a maintainer consumes the pending changesets (`changeset version` — writes the CHANGELOG and bumps `package.json`) and merges that bump to `main`; the release jobs in `.github/workflows/packages.yml` then detect the unpublished version and publish with npm provenance via Trusted Publishing. `@spree/admin-sdk` publishes under the `next` dist-tag while on the 0.x Developer Preview line; the others ship as `latest` (prereleases go to `beta`).
+The packages that talk to the Spree API (`@spree/sdk`, `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core` and the dashboard packages) carry the version of the Spree gems. `@spree/cli` and `create-spree-app` keep their own versions.
+
+Releasing is a two-step flow: a maintainer bumps the Spree version, runs `pnpm version:packages` (writes the CHANGELOGs and bumps `package.json`) and merges that bump to `main`. Pushing a tag then publishes the release: `v<Spree version>` releases the gems and the packages that share the Spree version, and `@spree/cli@<version>` or `create-spree-app@<version>` releases that tool. Prereleases publish under the `beta` dist-tag, stable versions as `latest`.
Private packages (`@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui`, `@spree/sdk-core`) don't need changesets.
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdx
index 06a38183c9..d011671b84 100644
--- a/docs/developer/upgrades/5.6-to-6.0.mdx
+++ b/docs/developer/upgrades/5.6-to-6.0.mdx
@@ -47,6 +47,27 @@ Before running `bundle update`, update your `Gemfile`: the Rails admin (`spree_a
gem 'spree_dashboard'
```
+### The TypeScript packages share the Spree version
+
+From 6.0, the packages that talk to the Spree API are released with Spree and carry its version: `@spree/[email protected]` is the Store API client for Spree 6.0.0. The same applies to `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core`, `@spree/dashboard`, `@spree/dashboard-core`, `@spree/dashboard-ui` and `@spree/seller-dashboard`. `@spree/cli` and `create-spree-app` keep their own versions.
+
+A storefront on Spree 5.x depends on `@spree/sdk` `1.x`. Change that range by hand, since it never resolves to 6.x on its own:
+
+```json storefront/package.json
+"@spree/sdk": "^6.0.0-rc.7"
+```
+
+A range that names a release candidate also accepts the final `6.0.0` and every later 6.x release, so it doesn't need changing again when 6.0 is released. `^6.0.0` doesn't accept release candidates.
+
+Projects created during the 6.0 preview depend on `1.0.0-rc` or `2.0.0-rc` versions. Update the CLI first, then upgrade, and `spree upgrade` rewrites those ranges:
+
+```bash
+pnpm update @spree/cli
+spree upgrade
+```
+
+Dashboard plugins should widen their peer dependency ranges on `@spree/admin-sdk`, `@spree/dashboard-core` and `@spree/dashboard-ui` to `^6.0.0-rc.7` for the same reason.
+
Re-running is safe — `bundle exec rake spree:upgrade` figures out what still needs to happen and does nothing on data that's already migrated. It also runs every data backfill from earlier upgrades (5.4 → 5.5 and 5.5 → 5.6), so any you missed along the way are caught up. That does not remove the requirement above: upgrade your application to 5.6 first.
## What the upgrade does
diff --git a/docs/developer/upgrades/quickstart.mdx b/docs/developer/upgrades/quickstart.mdx
index aa7c58779a..a1c89b2b69 100644
--- a/docs/developer/upgrades/quickstart.mdx
+++ b/docs/developer/upgrades/quickstart.mdx
@@ -38,6 +38,19 @@ An upgrade updates the server and the `@spree/*` packages of your dashboard apps
```
On npm or Yarn, run `npm update` or `yarn upgrade` instead, naming each `@spree/*` package from that `package.json` (they do not accept the `"@spree/*"` pattern).
+
+ `update` never moves a package pinned to an exact version, such as `"@spree/dashboard": "6.0.0-rc.6"`. Install the new version by name instead, then fold duplicate copies of shared dependencies together, in each directory you changed:
+
+ | Package manager | Install the new version | Fold duplicates |
+ | --- | --- | --- |
+ | pnpm | `pnpm add --save-exact @spree/[email protected]` | `pnpm dedupe` |
+ | npm | `npm install --save-exact @spree/[email protected]` | `npm dedupe` |
+ | Yarn 2 or later | `yarn add --exact @spree/[email protected]` | `yarn dedupe` |
+ | Yarn 1 | `yarn add --exact @spree/[email protected]` | Not available |
+
+ Moving from a release candidate pin such as `6.0.0-rc.7` to the final release, change the pin to a range such as `^6.0.0` in `package.json` instead, then run `update` as above. Installing over an exact pin by name keeps it exact.
+
+ Add `--save-dev` (pnpm and npm) or `--dev` (Yarn) for a package listed under `devDependencies`. Without the dedupe step, a dependency that the new version pins, such as `@codemirror/view`, can end up installed twice and fail type checks.
</Tab>
</Tabs>
diff --git a/docs/plans/6.0-beta-release.md b/docs/plans/6.0-beta-release.md
index ad25fa98f0..ef4efd470e 100644
--- a/docs/plans/6.0-beta-release.md
+++ b/docs/plans/6.0-beta-release.md
@@ -4,7 +4,7 @@
**Target:** Spree 6.0
**Depends on:** `5.6-project-layout-and-dashboard.md` (dashboard packaging, embedded starter)
**Author:** Damian
-**Last updated:** 2026-09-12
+**Last updated:** 2026-10-26
**Tracking:** Linear — · GitHub —
## Summary
@@ -29,6 +29,8 @@ explicit range, and `latest` keeps meaning 5.x until 6.0 is final.**
existing `5.6.0.rc1` convention.
2. **`@spree/sdk` goes to `2.0.0-beta.1`, published under the `beta` tag.**
+ *(Superseded from the release candidate after `rc6` by Decision 3: the SDK
+ moves to the Spree version. The reasoning about tags still holds.)*
This is the load-bearing decision. The major bump states the Store API
break, and the prerelease + non-`latest` tag means `^1.2.1` in both
storefront branches cannot resolve to it — semver ranges exclude
@@ -38,34 +40,61 @@ explicit range, and `latest` keeps meaning 5.x until 6.0 is final.**
would push the beta straight to `latest` and break every 5.x storefront.
This is the single highest-risk item in the release.
-3. **Every Developer-Preview package goes to `1.0.0-beta.1`: Spree 6 = 1.0.0
- for all of them.** `@spree/admin-sdk` (0.8.1), the dashboard trio (0.13.1)
- and the two seller packages (0.1.0) leave 0.x together and are promoted to
- stable `1.0.0` at 6.0 GA. One version line across the npm surface, matching
- the gems' own 6.0 line, instead of five unrelated 0.x counters nobody can
- map to a Spree release.
-
- The form is `1.0.0-beta.1`, **not** `1.0.0.pre` — npm requires a hyphen and
- rejects `1.0.0.pre` outright (that spelling is RubyGems'). They publish
- under the existing `next` tag, which the release jobs already select for any
- version containing `-`.
-
- This changes what the embedded starter templates pin. `publishedRange()` in
- `scripts/sync-starter.mjs` emits `>=x.y.z <2.0.0` only for `0.x`; at
- `1.0.0-beta.1` it emits `^1.0.0-beta.1`, which accepts the beta now and
- floats to stable `1.0.0` when it lands — the intended behaviour, no change
- needed. Verified with semver.
-
- `@spree/sdk` is the exception and stays on its own line (Decision 2): it has
- a published 1.x that means the 5.x Store API, so it goes to `2.0.0-beta.1`.
-
- Use `beta.1`, never `beta1`: semver compares dot-separated prerelease
+3. **The packages that talk to the Spree API carry the Spree version.**
+ *(Revised 2026-10-26; the beta and the first six release candidates
+ shipped them as `1.0.0-rc.x`, and `@spree/sdk` as `2.0.0-rc.x`.)*
+ `@spree/sdk`, `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core`, the
+ dashboard trio and `@spree/seller-dashboard` are one Changesets `fixed`
+ group, versioned from `Spree::VERSION`: gems `6.0.0.rc7` ship as
+ `6.0.0-rc.7`, and `6.0.0` is `6.0.0` everywhere. Their types come from the
+ serializers and their request shapes from the OpenAPI files, so a version
+ number that maps to nothing on the backend only made people consult a
+ compatibility table nobody maintained, and the numbering had already
+ drifted (the seller panel at `rc.7`, everything else at `rc.6`).
+ `@spree/cli` and `create-spree-app` keep their own versions: they manage
+ Docker and scaffolding, not the API, and need patch releases of their own.
+
+ - **Released by `pnpm version:packages`** (`scripts/version-packages.mjs`),
+ which runs `changeset version` and then moves the group to the Spree
+ version. Changesets still writes the changelogs, but for the group a
+ changeset's bump type only decides the changelog heading. A Spree release
+ with no TypeScript changes still publishes the group with an entry saying
+ so, as the nine gems already do.
+ - **The cost accepted:** a breaking change in the TypeScript code alone
+ waits for the next Spree major, the same promise the Store API makes.
+ - **Switched at the release candidate after `rc6`, not at GA.** Every
+ existing range misses the jump wherever it happens, so the question is
+ only whether the migration path first runs on release day. GA stays a
+ plain promotion of the last candidate.
+ - **Existing projects** are moved by `spree upgrade`, which rewrites any
+ range for a package in the group that is still on an older line
+ (`^1.0.0-rc.7`, `>=0.13.1 <2.0.0`) to the Spree version before updating.
+ The CLI only knows the group from its build, so a project updates
+ `@spree/cli` first, then upgrades. Until the group shares one version,
+ the CLI rewrites nothing. The storefront stays the merchant's: the CLI
+ names the exact `@spree/sdk` range to move to.
+ - **Never publish a stable `1.0.0` or `2.0.0`** of a package in the group:
+ either would satisfy the old ranges and look like a supported line.
+ Deprecate the old lines on npm after the first aligned release
+ (`npm deprecate "@spree/[email protected]" "Moved to 6.x with Spree. Run: spree upgrade"`,
+ likewise `@spree/[email protected]`).
+ - Peer ranges inside the group are literal, from the release to the end of
+ its major (`>=6.0.1-rc.1 <7.0.0-0`), set by the script on every release.
+ The floor is the full version: a patch release candidate does not satisfy
+ `>=6.0.0-0`.
+ - **Released from tags, in one workflow** *(2026-10-26)*. `release.yml`
+ publishes the gems and the group on the Spree tag (`v6.0.0.rc7`), and
+ each tool on its own tag (`@spree/[email protected]`, `[email protected]`),
+ after checking the tag against the versions in the repository.
+ `packages.yml` only runs checks. The templates the CLI embeds (the
+ dashboard and seller starters, the plugin peers) accept the whole major
+ (`^6.0.0-0`), so a CLI tag pushed before the Spree tag never points at
+ packages not yet on npm.
+
+ Use `rc.7`, never `rc7`, on npm: semver compares dot-separated prerelease
identifiers numerically but bare strings alphabetically, so `1.0.0-beta9`
- sorts ABOVE `1.0.0-beta10` and a release would ship backwards. This is the
- one place the npm and RubyGems spellings must differ — `6.0.0.beta1` is
- correct for the gems, where the trailing digits parse as their own numeric
- segment. `@spree/cli` already shipped `2.0.0-beta` → `-beta.7`, so the
- dotted form is this repo's existing precedent, not a new convention.
+ sorts ABOVE `1.0.0-beta10` and a release would ship backwards. The gems
+ keep `6.0.0.rc7`; the script converts.
**Accepted break:** the dashboard trio currently publishes to `next` at
`0.13.1`. At `1.0.0-beta.1` the release jobs route it to `beta` instead
@@ -283,7 +312,7 @@ must land before any version bump, because both change what a publish *does*.
## References
-- `.github/workflows/packages.yml` — npm release chain
-- `.github/workflows/release.yml` — gem release on `v*` tags
+- `.github/workflows/release.yml` — every release, from its tag
+- `scripts/publish-packages.mjs` — npm publishing, in dependency order
- `scripts/sync-starter.mjs` — embedded template version flooring
- `docs/plans/5.6-project-layout-and-dashboard.md` — dashboard packaging
diff --git a/docs/plans/decisions.md b/docs/plans/decisions.md
index cecdb8dd96..e3b3aed5cf 100644
--- a/docs/plans/decisions.md
+++ b/docs/plans/decisions.md
@@ -1,3 +1,23 @@
+## 2026-10-26: Every release is published from a tag, in one workflow
+
+**Context:** The npm packages published from `packages.yml` whenever a merge to `main` touched certain paths, while the gems published from `release.yml` on a tag pushed by hand. The two halves of one Spree release went out at different times, a later merge cancelled a release part-way, and gems published without any check of the commit.
+
+**Decision:** `release.yml` publishes everything, started by a tag on a commit already on `main`. `v6.0.0.rc7` releases the gems and the npm packages that share the Spree version; `@spree/[email protected]` and `[email protected]` release those tools on their own. A first job checks the tag against `Spree::VERSION` and the package versions before anything publishes, and every step skips versions already on its registry. One script (`scripts/publish-packages.mjs`) publishes npm packages in dependency order. `packages.yml` only runs checks. `pnpm version:tools` versions the tools between Spree releases while the group's changesets wait. The templates the CLI embeds accept their whole major (`^6.0.0-0`) instead of the workspace version, so a CLI tag never points at packages not yet on npm.
+
+**Consequences:** Nothing reaches npm from a merge alone; a release is the tag. npm Trusted Publishing names the workflow file, so every published package must trust `release.yml` before its first tag release. GitHub starts no workflow for more than three tags pushed at once. `@spree/docs` keeps publishing from `docs-package.yml`.
+
+**Plan amended:** `6.0-beta-release.md` (Key Decision 3, References).
+
+## 2026-10-26: The TypeScript packages that talk to the API carry the Spree version
+
+**Context:** One Spree release shipped under three numbering schemes: gems `6.0.0.rc6`, `@spree/sdk` `2.0.0-rc.5`, the Admin and Seller SDKs and the dashboard packages `1.0.0-rc.6`, the seller panel `1.0.0-rc.7`, `@spree/core` `0.3.0`. The SDKs are generated from the serializers and the dashboards read only the Admin API, so each of those numbers stood for a backend version that nobody could read off it.
+
+**Decision:** `@spree/sdk`, `@spree/admin-sdk`, `@spree/seller-sdk`, `@spree/core`, the dashboard trio and `@spree/seller-dashboard` form one Changesets `fixed` group versioned from `Spree::VERSION` in npm spelling (`6.0.0.rc7` → `6.0.0-rc.7`), released by `pnpm version:packages`. `@spree/cli` and `create-spree-app` keep their own versions, since they manage projects rather than talk to the API. The switch lands at the release candidate after `rc6` rather than at GA, so the migration path runs before release day. `spree upgrade` rewrites a project's ranges that are still on an older line, and names the exact `@spree/sdk` range for the storefront.
+
+**Consequences:** A Spree release publishes every package in the group even when one has no changes, as the gems already do. A breaking change in the TypeScript code alone waits for the next Spree major. Projects from the preview update `@spree/cli` before upgrading, because the CLI they have does not know the new numbering. Stable `1.0.0` and `2.0.0` are never published for the group, and the old lines get an npm deprecation pointing at `spree upgrade`.
+
+**Plan amended:** `6.0-beta-release.md` (Key Decisions 2 and 3).
+
## 2026-10-24: A marketplace decides whether, what and under review its sellers may upload
**Context:** With sellers able to attach downloadable files to their products (the entry below), any approved seller can put a file on the marketplace's domain that buyers download trusting the marketplace's brand. Nothing in Spree scans a file's contents, and before this there was no way to keep seller uploads off, to narrow what they may be, or to re-check an approved listing whose file changed. Digital asset writes were also plain model saves in two places, so a host had no point at which to refuse an upload.
diff --git a/package.json b/package.json
index 256a4f1216..0273e7268e 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,8 @@
"test:slots": "scripts/test/with-slot --status",
"docs:dev": "cd docs && mint dev --port 3333",
"changeset": "changeset",
- "version:preview": "changeset version --ignore @spree/sdk"
+ "version:packages": "node scripts/version-packages.mjs",
+ "version:tools": "node scripts/version-packages.mjs --tools"
},
"devDependencies": {
"@biomejs/biome": "^2.4.14",
diff --git a/packages/admin-sdk/CHANGELOG.md b/packages/admin-sdk/CHANGELOG.md
index 2d188afa66..7b5478a1fb 100644
--- a/packages/admin-sdk/CHANGELOG.md
+++ b/packages/admin-sdk/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/admin-sdk
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.6
### Minor Changes
diff --git a/packages/admin-sdk/package.json b/packages/admin-sdk/package.json
index de15d16948..4c07d999eb 100644
--- a/packages/admin-sdk/package.json
+++ b/packages/admin-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/admin-sdk",
- "version": "1.0.0-rc.6",
+ "version": "6.0.0-rc.7",
"description": "Official TypeScript SDK for Spree Commerce Admin API",
"type": "module",
"main": "./dist/index.cjs",
diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md
index 003f73d584..209af15adb 100644
--- a/packages/cli/CHANGELOG.md
+++ b/packages/cli/CHANGELOG.md
@@ -1,5 +1,17 @@
# @spree/cli
+## 3.5.0
+
+### Minor Changes
+
+- [#14980](https://github.com/spree/spree/pull/14980) [`6c126ab`](https://github.com/spree/spree/commit/6c126ab0851011b3a10658ba2527a26ef7d4d2e1) Thanks [@damianlegawiec](https://github.com/damianlegawiec)! - `spree upgrade` now moves the dashboard packages and the Admin and Seller SDKs to the Spree version. From Spree 6.0 these packages share the version of the Spree gems, and a range on an older line such as `^1.0.0-rc.7` would never reach it on its own. The packages move to the Spree version the server runs after its update, so a CLI built for an earlier release still moves them all the way. A package pinned to an exact version moves to that version and stays pinned; before, `update` left it on the old release while the server moved on. A release candidate pin moving to a final version becomes a `^` range instead, since pnpm writes release candidates back as exact versions on its own. The upgrade then dedupes each app, so a dependency the new release pins, such as `@codemirror/view`, isn't left installed twice and failing type checks. Yarn 2 and later is now also recognised from the `packageManager` field. For a storefront on an older `@spree/sdk` line, the upgrade names the exact range to move to.
+
+### Patch Changes
+
+- [#14978](https://github.com/spree/spree/pull/14978) [`2df9371`](https://github.com/spree/spree/commit/2df9371e81f24b7f7ea8af915fdb2a6ea69c3dbc) Thanks [@damianlegawiec](https://github.com/damianlegawiec)! - `spree upgrade`, `spree db:reset` and `spree db:console` now say plainly when Docker is not running, and show Docker's own error for other failures instead of the command that failed.
+
+ `spree upgrade` now asks before running the upgrade tasks (data backfills), so they can be skipped like the other steps.
+
## 3.4.1
### Patch Changes
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 6b2ed5d28a..242456b430 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/cli",
- "version": "3.4.1",
+ "version": "3.5.0",
"description": "CLI for managing Spree Commerce projects",
"type": "module",
"bin": {
diff --git a/packages/cli/scripts/plugin-peer-ranges.mjs b/packages/cli/scripts/plugin-peer-ranges.mjs
index cdffb166d2..ecfb42e5dc 100644
--- a/packages/cli/scripts/plugin-peer-ranges.mjs
+++ b/packages/cli/scripts/plugin-peer-ranges.mjs
@@ -1,6 +1,7 @@
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
+import { majorFloorRange } from '../../../scripts/version-packages.mjs'
const packagesDir = join(dirname(fileURLToPath(import.meta.url)), '../..')
@@ -13,9 +14,10 @@ const PEERS = {
}
/**
- * Caret ranges on the versions currently in the workspace, so `spree plugin
- * new` scaffolds peers that match the dashboard released alongside this CLI.
- * Injected at build time (tsup) and test time (vitest).
+ * Ranges over the major of the versions in the workspace, so `spree plugin
+ * new` scaffolds peers that accept the dashboard released alongside this CLI
+ * without naming a version that may not be on npm yet (the CLI releases on its
+ * own tag). Injected at build time (tsup) and test time (vitest).
*
* @returns {Record<string, string>}
*/
@@ -23,7 +25,7 @@ export function pluginPeerRanges() {
return Object.fromEntries(
Object.entries(PEERS).map(([variable, dir]) => {
const { version } = JSON.parse(readFileSync(join(packagesDir, dir, 'package.json'), 'utf8'))
- return [variable, `^${version}`]
+ return [variable, majorFloorRange(version)]
}),
)
}
diff --git a/packages/cli/scripts/release-line.mjs b/packages/cli/scripts/release-line.mjs
new file mode 100644
index 0000000000..620d512d58
--- /dev/null
+++ b/packages/cli/scripts/release-line.mjs
@@ -0,0 +1,39 @@
+import { readdirSync, readFileSync } from 'node:fs'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '../../..')
+
+function readJson(file) {
+ return JSON.parse(readFileSync(file, 'utf8'))
+}
+
+/**
+ * The packages that share the Spree version (the Changesets fixed group with
+ * `@spree/sdk`) and that version, so `spree upgrade` can move a project off an
+ * older numbering. Until every package in the group carries the same version
+ * there is no shared line to move to, and the list is empty. Injected at build
+ * time (tsup) and test time (vitest).
+ *
+ * @returns {{ packages: string[], version: string }}
+ */
+export function releaseLine() {
+ const { fixed } = readJson(join(repoRoot, '.changeset/config.json'))
+ const group = fixed.find((names) => names.includes('@spree/sdk')) ?? []
+ const packagesDir = join(repoRoot, 'packages')
+ const versions = new Map(
+ readdirSync(packagesDir)
+ .map((dir) => {
+ try {
+ return readJson(join(packagesDir, dir, 'package.json'))
+ } catch {
+ return undefined
+ }
+ })
+ .filter((manifest) => manifest && group.includes(manifest.name))
+ .map((manifest) => [manifest.name, manifest.version]),
+ )
+ const version = versions.get('@spree/sdk')
+ const aligned = group.every((name) => versions.get(name) === version)
+ return { packages: aligned ? group : [], version }
+}
diff --git a/packages/cli/src/commands/upgrade.ts b/packages/cli/src/commands/upgrade.ts
index c73782b4c8..d2fecd1e9c 100644
--- a/packages/cli/src/commands/upgrade.ts
+++ b/packages/cli/src/commands/upgrade.ts
@@ -14,6 +14,7 @@ import {
primeBundleVolume,
restartAppServices,
} from '../docker.js'
+import { RELEASE_LINE, type ReleaseLine, releaseLineFor } from '../lib/release-line.js'
import { APP_DIRS, detectPackageManager, generateRouteTree } from './add.js'
interface UpgradeFlags {
@@ -77,9 +78,11 @@ async function upgrade(flags: UpgradeFlags): Promise<void> {
return
}
+ let line: ReleaseLine
if (isEjectedProject(ctx.projectDir)) {
const gemsUpdated = await runBundleUpdate(ctx.projectDir, flags)
- await updateSpreePackages(ctx.projectDir, flags)
+ line = await serverReleaseLine(ctx.projectDir, { fromNewImage: false })
+ await updateSpreePackages(ctx.projectDir, flags, line)
await runMigrate(ctx.projectDir, flags)
await runRakeUpgrade(ctx.projectDir, flags)
// Puma loaded the old gems at boot; the rake steps ran in fresh processes.
@@ -87,12 +90,45 @@ async function upgrade(flags: UpgradeFlags): Promise<void> {
await restartAppServices(ctx.projectDir, 'Restarting the app to load the updated gems')
} else {
const imagePulled = await pullImage(ctx.projectDir, flags)
- await updateSpreePackages(ctx.projectDir, flags)
+ line = await serverReleaseLine(ctx.projectDir, { fromNewImage: imagePulled })
+ await updateSpreePackages(ctx.projectDir, flags, line)
if (imagePulled) await recreateContainers(ctx.projectDir)
await runRakeUpgrade(ctx.projectDir, flags)
}
- printPostUpgradeReminder(ctx.projectDir)
+ printPostUpgradeReminder(ctx.projectDir, line)
+}
+
+/**
+ * The Spree version the server runs after its update, as the release line the
+ * packages move to. The CLI that runs an upgrade was installed before it, so
+ * the version built into it can be a release behind the server. A freshly
+ * pulled image is read from a one-off container, since the running one still
+ * has the old image until it is recreated.
+ */
+async function serverReleaseLine(
+ projectDir: string,
+ { fromNewImage }: { fromNewImage: boolean },
+): Promise<ReleaseLine> {
+ try {
+ const stdout = fromNewImage
+ ? (
+ await execa(
+ 'docker',
+ ['compose', 'run', '--rm', '--no-deps', '-T', 'web', 'bundle', 'list'],
+ { cwd: projectDir },
+ )
+ ).stdout
+ : await dockerComposeCapture(['bundle', 'list'], projectDir)
+ const installed = stdout.match(/\bspree_core \(([^)\s]+)/)?.[1]
+ if (installed) return releaseLineFor(installed, RELEASE_LINE)
+ } catch {
+ // Fall through to the version this CLI was built with.
+ }
+ p.log.warn(
+ `Could not read the server's Spree version; moving the @spree/* packages to ${RELEASE_LINE.version}.`,
+ )
+ return RELEASE_LINE
}
async function confirmStep(message: string, flags: UpgradeFlags): Promise<boolean> {
@@ -241,24 +277,108 @@ async function runRakeUpgrade(projectDir: string, flags: UpgradeFlags): Promise<
// (workspace:, file:, link:, git URLs) point at code the operator manages.
const REGISTRY_SPEC = /^[\^~<>=\d*]|^latest$|^next$/
+// A single version (`6.0.0-rc.7`) rather than a range. `update` keeps a
+// declared range, and a single version is a range nothing else satisfies.
+const EXACT_VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/
+
+export interface SpreePackage {
+ name: string
+ spec: string
+ dev: boolean
+}
+
+interface PackageJson {
+ dependencies?: Record<string, string>
+ devDependencies?: Record<string, string>
+ packageManager?: string
+}
+
/**
* The @spree/* packages a package.json depends on through the registry —
* what `spree upgrade` bumps there. Returns [] for a missing or unreadable file.
*/
-export function detectSpreePackages(dir: string): string[] {
+export function detectSpreePackages(dir: string): SpreePackage[] {
try {
- const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')) as {
- dependencies?: Record<string, string>
- devDependencies?: Record<string, string>
- }
- return Object.entries({ ...pkg.dependencies, ...pkg.devDependencies })
- .filter(([name, spec]) => name.startsWith('@spree/') && REGISTRY_SPEC.test(spec))
- .map(([name]) => name)
+ const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')) as PackageJson
+ return [
+ ...Object.entries(pkg.dependencies ?? {}).map(([name, spec]) => ({ name, spec, dev: false })),
+ ...Object.entries(pkg.devDependencies ?? {}).map(([name, spec]) => ({
+ name,
+ spec,
+ dev: true,
+ })),
+ ].filter(({ name, spec }) => name.startsWith('@spree/') && REGISTRY_SPEC.test(spec))
} catch {
return []
}
}
+export function isExactVersion(spec: string): boolean {
+ return EXACT_VERSION.test(spec)
+}
+
+function escapeRegExp(text: string): string {
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+}
+
+function isReleasedPin(spec: string, line: ReleaseLine): boolean {
+ return spec.includes('-') && !line.version.includes('-') && isOlderVersion(spec, line.version)
+}
+
+function isOlderLine(spec: string, line: ReleaseLine): boolean {
+ const declared = spec.match(/(\d+)\./)
+ return declared !== null && Number(declared[1]) < Number(line.version.split('.')[0])
+}
+
+/**
+ * Rewrites the specs in a package.json that the update that follows could not
+ * move to the Spree version the server runs, for packages released with Spree:
+ *
+ * - a range on an older version line: from 6.0 these packages share the Spree
+ * version, and `^1.0.0-rc.7` never resolves to 6.x on its own
+ * - a release candidate pin, once the server is on a final version: pnpm 11's
+ * `update` writes a prerelease back as an exact version, so the pin is
+ * pnpm's rather than the operator's, and `6.0.0-rc.7` becomes `^6.0.0`
+ *
+ * Both become a `^` range on the server's version, which a locked prerelease
+ * never satisfies, so the update installs it. Other exact versions are left
+ * for the upgrade to install by name, so they stay exact. The file is edited
+ * as text so its formatting is kept.
+ *
+ * @param dir directory holding the package.json
+ * @param line the packages released with Spree and the version to move to
+ * @returns the rewritten packages with their old and new ranges, [] when none
+ */
+export function moveToReleaseLine(
+ dir: string,
+ line: ReleaseLine = RELEASE_LINE,
+): Array<{ name: string; from: string; to: string }> {
+ const manifestPath = path.join(dir, 'package.json')
+ let source: string
+ let pkg: PackageJson
+ try {
+ source = fs.readFileSync(manifestPath, 'utf-8')
+ pkg = JSON.parse(source)
+ } catch {
+ return []
+ }
+
+ const to = `^${line.version}`
+ const moved = Object.entries({ ...pkg.dependencies, ...pkg.devDependencies })
+ .filter(([name, spec]) => line.packages.includes(name) && REGISTRY_SPEC.test(spec))
+ .filter(([, spec]) =>
+ isExactVersion(spec) ? isReleasedPin(spec, line) : isOlderLine(spec, line),
+ )
+ .map(([name, from]) => ({ name, from, to }))
+
+ for (const { name, from } of moved) {
+ const declaration = new RegExp(`("${escapeRegExp(name)}"\\s*:\\s*)"${escapeRegExp(from)}"`, 'g')
+ source = source.replace(declaration, `$1"${to}"`)
+ }
+ if (moved.length > 0) fs.writeFileSync(manifestPath, source)
+ return moved
+}
+
/**
* The package-manager arguments that move the given packages to the newest
* release their declared range allows, without rewriting that range — the
@@ -272,16 +392,104 @@ export function packageUpdateArgs(
dir: string,
): string[] {
if (pm !== 'yarn') return ['update', ...packages]
- const berry = [dir, projectDir].some((candidate) =>
- fs.existsSync(path.join(candidate, '.yarnrc.yml')),
- )
- return berry ? ['up', '-R', ...packages] : ['upgrade', ...packages]
+ return isYarnBerry(projectDir, dir) ? ['up', '-R', ...packages] : ['upgrade', ...packages]
+}
+
+/**
+ * The package-manager arguments that install the given `name@version` specs
+ * and record them as exact versions again, in the group they are declared in.
+ */
+export function packageAddArgs(pm: string, specs: string[], dev: boolean): string[] {
+ if (pm === 'yarn') return ['add', '--exact', ...(dev ? ['--dev'] : []), ...specs]
+ const command = pm === 'npm' ? 'install' : 'add'
+ return [command, '--save-exact', ...(dev ? ['--save-dev'] : []), ...specs]
+}
+
+/**
+ * The package-manager arguments that fold duplicate copies of a package into
+ * one, or null where the package manager has no such command (Yarn Classic).
+ * An updated package can pin a dependency, such as `@codemirror/view`, newer
+ * than the copy the lockfile already holds for packages that take it by range;
+ * the two copies then clash in type checks until they are folded together.
+ */
+export function packageDedupeArgs(pm: string, projectDir: string, dir: string): string[] | null {
+ if (pm === 'yarn' && !isYarnBerry(projectDir, dir)) return null
+ return ['dedupe']
+}
+
+function isYarnBerry(projectDir: string, dir: string): boolean {
+ return [dir, projectDir].some((candidate) => {
+ if (fs.existsSync(path.join(candidate, '.yarnrc.yml'))) return true
+ try {
+ const pkg = JSON.parse(
+ fs.readFileSync(path.join(candidate, 'package.json'), 'utf-8'),
+ ) as PackageJson
+ const major = pkg.packageManager?.match(/^yarn@(\d+)\./)?.[1]
+ return major !== undefined && Number(major) >= 2
+ } catch {
+ return false
+ }
+ })
+}
+
+function compareIdentifiers(left: string, right: string): number {
+ const leftNumeric = /^\d+$/.test(left)
+ const rightNumeric = /^\d+$/.test(right)
+ if (leftNumeric && rightNumeric) return Number(left) - Number(right)
+ if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1
+ return left < right ? -1 : left > right ? 1 : 0
+}
+
+/**
+ * Whether one exact version sorts before another under semver precedence: the
+ * release numbers first, then a prerelease (`6.0.0-rc.7`) before its release,
+ * then prerelease identifiers one by one.
+ */
+export function isOlderVersion(version: string, than: string): boolean {
+ const [leftRelease, leftPrerelease] = splitVersion(version)
+ const [rightRelease, rightPrerelease] = splitVersion(than)
+ for (let index = 0; index < 3; index++) {
+ const difference = leftRelease[index] - rightRelease[index]
+ if (difference !== 0) return difference < 0
+ }
+ if (leftPrerelease.length === 0 || rightPrerelease.length === 0) {
+ return leftPrerelease.length > rightPrerelease.length
+ }
+ for (let index = 0; index < Math.min(leftPrerelease.length, rightPrerelease.length); index++) {
+ const difference = compareIdentifiers(leftPrerelease[index], rightPrerelease[index])
+ if (difference !== 0) return difference < 0
+ }
+ return leftPrerelease.length < rightPrerelease.length
+}
+
+function splitVersion(version: string): [number[], string[]] {
+ const [release, ...prerelease] = version.split('-')
+ const identifiers = prerelease.join('-')
+ return [release.split('.').map(Number), identifiers ? identifiers.split('.') : []]
+}
+
+// `update` leaves an exact version where it is, so a pinned app would stay on
+// the old release while the server moves on. A pin on a package released with
+// Spree that is older than the server's Spree version moves to it. A newer pin
+// stays, since the server may not have moved (a skipped pull); any other pin is
+// the operator's to move. A release candidate pin reaching a final version
+// was already turned into a range (see moveToReleaseLine).
+function pinnedOffRelease(packages: SpreePackage[], dev: boolean, line: ReleaseLine): string[] {
+ return packages
+ .filter((pkg) => pkg.dev === dev && isExactVersion(pkg.spec))
+ .filter((pkg) => line.packages.includes(pkg.name))
+ .filter((pkg) => isOlderVersion(pkg.spec, line.version))
+ .map((pkg) => `${pkg.name}@${line.version}`)
}
// The project root carries @spree/cli; each admin app carries the dashboard
// packages and the Admin SDK. The storefront is the merchant's own fork, so
// its SDK bump stays theirs (see sdkAdvisory).
-async function updateSpreePackages(projectDir: string, flags: UpgradeFlags): Promise<void> {
+async function updateSpreePackages(
+ projectDir: string,
+ flags: UpgradeFlags,
+ line: ReleaseLine,
+): Promise<void> {
const targets = ['.', ...APP_DIRS.map((dir) => path.join('apps', dir))]
.map((relative) => ({ relative, dir: path.join(projectDir, relative) }))
.map((target) => ({ ...target, packages: detectSpreePackages(target.dir) }))
@@ -294,19 +502,46 @@ async function updateSpreePackages(projectDir: string, flags: UpgradeFlags): Pro
}
for (const target of targets) {
+ for (const { name, from, to } of moveToReleaseLine(target.dir, line)) {
+ p.log.info(`${name}: ${from} → ${to} ${pc.dim(`in ${target.relative}`)}`)
+ }
const pm = detectPackageManager(projectDir, target.dir)
- const args = packageUpdateArgs(pm, target.packages, projectDir, target.dir)
- p.log.step(`${pc.bold(`${pm} ${args.join(' ')}`)} ${pc.dim(`in ${target.relative}`)}`)
- await execa(pm, args, { cwd: target.dir, stdio: 'inherit' })
+ // Read again, since the rewrite above can turn a pin into a range.
+ const packages = detectSpreePackages(target.dir)
+
+ const ranged = packages.filter((pkg) => !isExactVersion(pkg.spec)).map((pkg) => pkg.name)
+ if (ranged.length > 0) {
+ await runPackageManager(pm, packageUpdateArgs(pm, ranged, projectDir, target.dir), target)
+ }
+ const pinnedDependencies = pinnedOffRelease(packages, false, line)
+ if (pinnedDependencies.length > 0) {
+ await runPackageManager(pm, packageAddArgs(pm, pinnedDependencies, false), target)
+ }
+ const pinnedDevDependencies = pinnedOffRelease(packages, true, line)
+ if (pinnedDevDependencies.length > 0) {
+ await runPackageManager(pm, packageAddArgs(pm, pinnedDevDependencies, true), target)
+ }
+ const dedupeArgs = packageDedupeArgs(pm, projectDir, target.dir)
+ if (dedupeArgs) await runPackageManager(pm, dedupeArgs, target)
+
// An updated dashboard can ship new routes; regenerate now so the next
// dev start doesn't rewrite the file and reload the open page.
if (target.relative !== '.') await generateRouteTree(target.dir)
}
}
+async function runPackageManager(
+ pm: string,
+ args: string[],
+ target: { relative: string; dir: string },
+): Promise<void> {
+ p.log.step(`${pc.bold(`${pm} ${args.join(' ')}`)} ${pc.dim(`in ${target.relative}`)}`)
+ await execa(pm, args, { cwd: target.dir, stdio: 'inherit' })
+}
+
// We can detect the conventional create-spree-app storefront and tell the
// operator exactly what to bump.
-export function sdkAdvisory(projectDir: string): string {
+export function sdkAdvisory(projectDir: string, line: ReleaseLine = RELEASE_LINE): string {
const generic = 'Update @spree/sdk in any storefront or integration consuming the API'
const pkgPath = path.join(projectDir, 'apps', 'storefront', 'package.json')
if (!fs.existsSync(pkgPath)) return generic
@@ -317,20 +552,23 @@ export function sdkAdvisory(projectDir: string): string {
}
const declared = pkg.dependencies?.['@spree/sdk'] ?? pkg.devDependencies?.['@spree/sdk']
if (!declared) return generic
+ if (line.packages.includes('@spree/sdk') && isOlderLine(declared, line)) {
+ return `Update @spree/sdk in apps/storefront from ${declared} to ^${line.version}: from Spree 6.0 the SDK shares the Spree version`
+ }
return `Update @spree/sdk in apps/storefront (currently ${declared}) to the release matching the new Spree version`
} catch {
return generic
}
}
-function printPostUpgradeReminder(projectDir: string): void {
+function printPostUpgradeReminder(projectDir: string, line: ReleaseLine = RELEASE_LINE): void {
p.note(
[
`The manifest only ran ${pc.bold('rake-automatable')} steps.`,
'',
"Don't forget the manual parts from the upgrade doc:",
` ${pc.dim('- Compare your scheduled jobs (config/recurring.yml) with the upgrade guide')}`,
- ` ${pc.dim(`- ${sdkAdvisory(projectDir)}`)}`,
+ ` ${pc.dim(`- ${sdkAdvisory(projectDir, line)}`)}`,
` ${pc.dim('- Review the behavior changes listed in the upgrade guide')}`,
` ${pc.dim('- Audit custom decorators against renamed APIs')}`,
'',
diff --git a/packages/cli/src/lib/release-line.ts b/packages/cli/src/lib/release-line.ts
new file mode 100644
index 0000000000..d3ef4b2bdc
--- /dev/null
+++ b/packages/cli/src/lib/release-line.ts
@@ -0,0 +1,42 @@
+export interface ReleaseLine {
+ packages: string[]
+ version: string
+}
+
+declare const __SPREE_RELEASE_LINE__: ReleaseLine
+
+/**
+ * The `@spree/*` packages released with the Spree version, and that version,
+ * as of this CLI's build (see scripts/release-line.mjs).
+ */
+export const RELEASE_LINE: ReleaseLine = __SPREE_RELEASE_LINE__
+
+/**
+ * The npm spelling of a Spree gem version, as `scripts/version-packages.mjs`
+ * publishes it: `6.0.0.rc7` → `6.0.0-rc.7`. Undefined for anything else.
+ */
+export function npmVersionOf(gemVersion: string): string | undefined {
+ const match = gemVersion.match(/^(\d+\.\d+\.\d+)(?:\.([a-z]+)(\d*))?$/)
+ if (!match) return undefined
+ const [, release, label, number] = match
+ if (!label) return release
+ return number ? `${release}-${label}.${number}` : `${release}-${label}`
+}
+
+/**
+ * The release line for the Spree version a project's server runs, so the
+ * packages follow the server even when this CLI was built for an earlier
+ * release. A server older than the line this CLI knows (Spree 5.x, before the
+ * packages shared its version) moves nothing; a version that cannot be read
+ * keeps the built-in line.
+ *
+ * @param gemVersion the installed `spree_core` version, e.g. `6.0.0.rc8`
+ * @param line the line this CLI was built with
+ */
+export function releaseLineFor(gemVersion: string, line: ReleaseLine = RELEASE_LINE): ReleaseLine {
+ const version = npmVersionOf(gemVersion)
+ if (!version) return line
+ const major = (value: string) => Number(value.split('.')[0])
+ if (major(version) < major(line.version)) return { packages: [], version }
+ return { packages: line.packages, version }
+}
diff --git a/packages/cli/tests/plugin-template.test.ts b/packages/cli/tests/plugin-template.test.ts
index 6ebe75833c..f3f0066ae3 100644
--- a/packages/cli/tests/plugin-template.test.ts
+++ b/packages/cli/tests/plugin-template.test.ts
@@ -92,8 +92,11 @@ describe('bundled plugin template', () => {
expect(pkg.name).toBe('@acme/brands-dashboard')
})
- // Hand-written ranges drifted to versions no published package matched.
+ // Hand-written ranges drifted to versions no published package matched. The
+ // range covers the whole major, since the CLI can release before the
+ // workspace version reaches npm.
it('peer-depends on the admin SDK and dashboard packages released with this CLI', () => {
+ const majorOf = (dir: string) => `^${workspaceVersion(dir).split('.')[0]}.0.0-0`
const dst = path.join(tempDir(), 'out')
render({ src: TEMPLATE_SRC, dst, vars: SAMPLE_VARS })
@@ -101,9 +104,9 @@ describe('bundled plugin template', () => {
fs.readFileSync(path.join(dst, 'packages/dashboard/package.json'), 'utf8'),
)
expect(pkg.peerDependencies).toMatchObject({
- '@spree/admin-sdk': `^${workspaceVersion('admin-sdk')}`,
- '@spree/dashboard-core': `^${workspaceVersion('dashboard-core')}`,
- '@spree/dashboard-ui': `^${workspaceVersion('dashboard-ui')}`,
+ '@spree/admin-sdk': majorOf('admin-sdk'),
+ '@spree/dashboard-core': majorOf('dashboard-core'),
+ '@spree/dashboard-ui': majorOf('dashboard-ui'),
})
})
diff --git a/packages/cli/tests/upgrade.test.ts b/packages/cli/tests/upgrade.test.ts
index dc19b51405..88f72ced46 100644
--- a/packages/cli/tests/upgrade.test.ts
+++ b/packages/cli/tests/upgrade.test.ts
@@ -6,6 +6,22 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('execa', () => ({ execa: vi.fn() }))
+const LINE = vi.hoisted(() => ({
+ packages: [
+ '@spree/sdk',
+ '@spree/admin-sdk',
+ '@spree/dashboard',
+ '@spree/dashboard-core',
+ '@spree/dashboard-ui',
+ ],
+ version: '6.0.0-rc.7',
+}))
+
+vi.mock('../src/lib/release-line', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../src/lib/release-line')>()),
+ RELEASE_LINE: LINE,
+}))
+
let projectDir: string
vi.mock('../src/context', async (importOriginal) => ({
@@ -28,14 +44,47 @@ vi.mock('@clack/prompts', () => ({
}))
import * as p from '@clack/prompts'
+import * as prompts from '@clack/prompts'
import { execa } from 'execa'
import {
detectSpreeGems,
detectSpreePackages,
+ isExactVersion,
+ isOlderVersion,
+ moveToReleaseLine,
+ packageAddArgs,
+ packageDedupeArgs,
packageUpdateArgs,
registerUpgradeCommand,
sdkAdvisory,
} from '../src/commands/upgrade'
+import { npmVersionOf, releaseLineFor } from '../src/lib/release-line'
+
+describe('npmVersionOf', () => {
+ it('spells gem versions the way the packages are published', () => {
+ expect(npmVersionOf('6.0.0.rc7')).toBe('6.0.0-rc.7')
+ expect(npmVersionOf('6.0.0.rc10')).toBe('6.0.0-rc.10')
+ expect(npmVersionOf('6.0.0.beta1')).toBe('6.0.0-beta.1')
+ expect(npmVersionOf('6.0.0.alpha')).toBe('6.0.0-alpha')
+ expect(npmVersionOf('6.1.2')).toBe('6.1.2')
+ expect(npmVersionOf('6.0')).toBeUndefined()
+ })
+})
+
+describe('releaseLineFor', () => {
+ it('follows the server version, older or newer than the built-in line', () => {
+ expect(releaseLineFor('6.0.0.rc8', LINE)).toEqual({ ...LINE, version: '6.0.0-rc.8' })
+ expect(releaseLineFor('6.0.0.rc6', LINE)).toEqual({ ...LINE, version: '6.0.0-rc.6' })
+ })
+
+ it('moves nothing for a server from before the packages shared its version', () => {
+ expect(releaseLineFor('5.6.2', LINE)).toEqual({ packages: [], version: '5.6.2' })
+ })
+
+ it('keeps the built-in line for a version it cannot read', () => {
+ expect(releaseLineFor('main', LINE)).toBe(LINE)
+ })
+})
describe('sdkAdvisory', () => {
const tempDirs: string[] = []
@@ -61,18 +110,27 @@ describe('sdkAdvisory', () => {
it('names the declared @spree/sdk version when the storefront uses it', () => {
const dir = makeTempDir()
- writeStorefrontPackageJson(dir, { dependencies: { '@spree/sdk': '^1.0.3' } })
+ writeStorefrontPackageJson(dir, { dependencies: { '@spree/sdk': '^6.0.0-rc.5' } })
- expect(sdkAdvisory(dir)).toBe(
- 'Update @spree/sdk in apps/storefront (currently ^1.0.3) to the release matching the new Spree version',
+ expect(sdkAdvisory(dir, LINE)).toBe(
+ 'Update @spree/sdk in apps/storefront (currently ^6.0.0-rc.5) to the release matching the new Spree version',
+ )
+ })
+
+ it('names the exact range when the storefront is on an SDK line older than Spree 6', () => {
+ const dir = makeTempDir()
+ writeStorefrontPackageJson(dir, { dependencies: { '@spree/sdk': '^2.0.0-rc.5' } })
+
+ expect(sdkAdvisory(dir, LINE)).toBe(
+ 'Update @spree/sdk in apps/storefront from ^2.0.0-rc.5 to ^6.0.0-rc.7: from Spree 6.0 the SDK shares the Spree version',
)
})
it('finds @spree/sdk in devDependencies too', () => {
const dir = makeTempDir()
- writeStorefrontPackageJson(dir, { devDependencies: { '@spree/sdk': '1.1.0' } })
+ writeStorefrontPackageJson(dir, { devDependencies: { '@spree/sdk': '6.1.0' } })
- expect(sdkAdvisory(dir)).toContain('currently 1.1.0')
+ expect(sdkAdvisory(dir, LINE)).toContain('currently 6.1.0')
})
it('falls back to generic advice without a storefront', () => {
@@ -179,7 +237,18 @@ describe('detectSpreePackages', () => {
dependencies: { '@spree/dashboard': '^1.0.0-beta.8', react: '^19.2.6' },
devDependencies: { '@spree/cli': '~3.1.0', '@spree/docs': 'latest' },
})
- expect(detectSpreePackages(dir)).toEqual(['@spree/dashboard', '@spree/cli', '@spree/docs'])
+ expect(detectSpreePackages(dir)).toEqual([
+ { name: '@spree/dashboard', spec: '^1.0.0-beta.8', dev: false },
+ { name: '@spree/cli', spec: '~3.1.0', dev: true },
+ { name: '@spree/docs', spec: 'latest', dev: true },
+ ])
+ })
+
+ it('lists exact versions too', () => {
+ const dir = withPackageJson({ dependencies: { '@spree/dashboard': '6.0.0-rc.6' } })
+ expect(detectSpreePackages(dir)).toEqual([
+ { name: '@spree/dashboard', spec: '6.0.0-rc.6', dev: false },
+ ])
})
it('leaves local and git specs alone', () => {
@@ -199,6 +268,205 @@ describe('detectSpreePackages', () => {
})
})
+describe('moveToReleaseLine', () => {
+ let dir: string
+ beforeEach(() => {
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'spree-cli-release-line-test-'))
+ })
+ afterEach(() => fs.rmSync(dir, { recursive: true, force: true }))
+
+ function writePackageJson(source: string): void {
+ fs.writeFileSync(path.join(dir, 'package.json'), source)
+ }
+
+ function readPackageJson(): string {
+ return fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')
+ }
+
+ it('moves packages released with Spree off older lines, keeping the formatting', () => {
+ writePackageJson(
+ [
+ '{',
+ ' "dependencies": {',
+ ' "@spree/dashboard": "^1.0.0-rc.7",',
+ ' "@spree/dashboard-core": ">=0.13.1 <2.0.0",',
+ ' "react": "^19.2.6"',
+ ' },',
+ ' "devDependencies": { "@spree/admin-sdk": "~1.0.0", "@spree/cli": "^3.4.1" }',
+ '}',
+ '',
+ ].join('\n'),
+ )
+
+ expect(moveToReleaseLine(dir, LINE)).toEqual([
+ { name: '@spree/dashboard', from: '^1.0.0-rc.7', to: '^6.0.0-rc.7' },
+ { name: '@spree/dashboard-core', from: '>=0.13.1 <2.0.0', to: '^6.0.0-rc.7' },
+ { name: '@spree/admin-sdk', from: '~1.0.0', to: '^6.0.0-rc.7' },
+ ])
+ expect(readPackageJson()).toBe(
+ [
+ '{',
+ ' "dependencies": {',
+ ' "@spree/dashboard": "^6.0.0-rc.7",',
+ ' "@spree/dashboard-core": "^6.0.0-rc.7",',
+ ' "react": "^19.2.6"',
+ ' },',
+ ' "devDependencies": { "@spree/admin-sdk": "^6.0.0-rc.7", "@spree/cli": "^3.4.1" }',
+ '}',
+ '',
+ ].join('\n'),
+ )
+ })
+
+ it('leaves current, exact, tagged and local specs alone', () => {
+ const source = JSON.stringify({
+ dependencies: {
+ '@spree/dashboard': '^6.0.0-rc.5',
+ '@spree/dashboard-ui': '1.0.0-rc.5',
+ '@spree/dashboard-core': 'next',
+ '@spree/admin-sdk': 'workspace:^',
+ },
+ })
+ writePackageJson(source)
+
+ expect(moveToReleaseLine(dir, LINE)).toEqual([])
+ expect(readPackageJson()).toBe(source)
+ })
+
+ it('gives release candidate pins a range once the line is a final version', () => {
+ writePackageJson(
+ JSON.stringify({
+ dependencies: {
+ '@spree/dashboard': '6.0.0-rc.7',
+ '@spree/dashboard-ui': '6.0.0',
+ '@spree/admin-sdk': '6.0.1-rc.1',
+ },
+ }),
+ )
+
+ expect(moveToReleaseLine(dir, { ...LINE, version: '6.0.0' })).toEqual([
+ { name: '@spree/dashboard', from: '6.0.0-rc.7', to: '^6.0.0' },
+ ])
+ })
+
+ it('keeps release candidate pins exact while the line is still a release candidate', () => {
+ const source = JSON.stringify({ dependencies: { '@spree/dashboard': '6.0.0-rc.6' } })
+ writePackageJson(source)
+
+ expect(moveToReleaseLine(dir, LINE)).toEqual([])
+ expect(readPackageJson()).toBe(source)
+ })
+
+ it('returns [] without a readable package.json', () => {
+ expect(moveToReleaseLine(dir, LINE)).toEqual([])
+ writePackageJson('{ not json')
+ expect(moveToReleaseLine(dir, LINE)).toEqual([])
+ })
+})
+
+describe('isExactVersion', () => {
+ it('tells single versions from ranges and tags', () => {
+ expect(isExactVersion('1.0.0')).toBe(true)
+ expect(isExactVersion('6.0.0-rc.7')).toBe(true)
+ expect(isExactVersion('^6.0.0-rc.7')).toBe(false)
+ expect(isExactVersion('~3.1.0')).toBe(false)
+ expect(isExactVersion('>=0.5.0 <2.0.0')).toBe(false)
+ expect(isExactVersion('1.x')).toBe(false)
+ expect(isExactVersion('latest')).toBe(false)
+ })
+})
+
+describe('isOlderVersion', () => {
+ it('orders exact versions by semver precedence', () => {
+ expect(isOlderVersion('6.0.0-rc.6', '6.0.0-rc.7')).toBe(true)
+ expect(isOlderVersion('6.0.0-rc.9', '6.0.0-rc.10')).toBe(true)
+ expect(isOlderVersion('1.0.0-rc.5', '6.0.0-rc.7')).toBe(true)
+ expect(isOlderVersion('6.0.0-rc.7', '6.0.0')).toBe(true)
+ expect(isOlderVersion('6.0.0-beta.1', '6.0.0-rc.1')).toBe(true)
+ expect(isOlderVersion('6.0.0-rc', '6.0.0-rc.1')).toBe(true)
+ expect(isOlderVersion('6.0.0-rc.1', '6.0.0-rc.rc')).toBe(true)
+
+ expect(isOlderVersion('6.0.0-rc.7', '6.0.0-rc.7')).toBe(false)
+ expect(isOlderVersion('6.0.0', '6.0.0-rc.7')).toBe(false)
+ expect(isOlderVersion('6.0.1', '6.0.0')).toBe(false)
+ expect(isOlderVersion('6.0.0-rc.10', '6.0.0-rc.9')).toBe(false)
+ expect(isOlderVersion('7.0.0-rc.1', '6.9.9')).toBe(false)
+ })
+})
+
+describe('packageAddArgs', () => {
+ it('saves exact versions in the group they are declared in', () => {
+ expect(packageAddArgs('pnpm', ['@spree/[email protected]'], false)).toEqual([
+ 'add',
+ '--save-exact',
+ '@spree/[email protected]',
+ ])
+ expect(packageAddArgs('pnpm', ['@spree/[email protected]'], true)).toEqual([
+ 'add',
+ '--save-exact',
+ '--save-dev',
+ '@spree/[email protected]',
+ ])
+ expect(packageAddArgs('npm', ['@spree/[email protected]'], false)).toEqual([
+ 'install',
+ '--save-exact',
+ '@spree/[email protected]',
+ ])
+ expect(packageAddArgs('npm', ['@spree/[email protected]'], true)).toEqual([
+ 'install',
+ '--save-exact',
+ '--save-dev',
+ '@spree/[email protected]',
+ ])
+ expect(packageAddArgs('yarn', ['@spree/[email protected]'], false)).toEqual([
+ 'add',
+ '--exact',
+ '@spree/[email protected]',
+ ])
+ expect(packageAddArgs('yarn', ['@spree/[email protected]'], true)).toEqual([
+ 'add',
+ '--exact',
+ '--dev',
+ '@spree/[email protected]',
+ ])
+ })
+})
+
+describe('packageDedupeArgs', () => {
+ let projectDir: string
+ beforeEach(() => {
+ projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'spree-cli-dedupe-test-'))
+ })
+ afterEach(() => fs.rmSync(projectDir, { recursive: true, force: true }))
+
+ it('dedupes on pnpm, npm and Yarn Berry, and skips Yarn Classic', () => {
+ expect(packageDedupeArgs('pnpm', projectDir, projectDir)).toEqual(['dedupe'])
+ expect(packageDedupeArgs('npm', projectDir, projectDir)).toEqual(['dedupe'])
+ expect(packageDedupeArgs('yarn', projectDir, projectDir)).toBeNull()
+ fs.writeFileSync(path.join(projectDir, '.yarnrc.yml'), 'nodeLinker: node-modules\n')
+ expect(packageDedupeArgs('yarn', projectDir, projectDir)).toEqual(['dedupe'])
+ })
+
+ it('recognises Yarn Berry from the packageManager field', () => {
+ fs.writeFileSync(
+ path.join(projectDir, 'package.json'),
+ JSON.stringify({ packageManager: '[email protected]' }),
+ )
+ expect(packageDedupeArgs('yarn', projectDir, projectDir)).toEqual(['dedupe'])
+ expect(packageUpdateArgs('yarn', ['@spree/dashboard'], projectDir, projectDir)).toEqual([
+ 'up',
+ '-R',
+ '@spree/dashboard',
+ ])
+
+ fs.writeFileSync(
+ path.join(projectDir, 'package.json'),
+ JSON.stringify({ packageManager: '[email protected]' }),
+ )
+ expect(packageDedupeArgs('yarn', projectDir, projectDir)).toBeNull()
+ })
+})
+
describe('packageUpdateArgs', () => {
it('uses update for pnpm and npm', () => {
expect(packageUpdateArgs('pnpm', ['@spree/cli'], '/proj', '/proj')).toEqual([
@@ -235,13 +503,26 @@ describe('packageUpdateArgs', () => {
describe('spree upgrade', () => {
const mockExeca = vi.mocked(execa)
let commands: string[]
+ let versionProbes: string[]
// Every docker and package-manager call goes through execa; record them in
// order, leaving out the read-only probes (`compose ps`, `bundle list`, …).
- function routeExeca({ failOn }: { failOn?: string } = {}): void {
+ // `spreeVersion` is what the server's bundle reports for spree_core.
+ function routeExeca({
+ failOn,
+ spreeVersion = '6.0.0.rc7',
+ }: {
+ failOn?: string
+ spreeVersion?: string | null
+ } = {}): void {
mockExeca.mockImplementation((async (cmd: string, args: string[]) => {
if (args.includes('ps')) return { stdout: 'running' }
- if (args.includes('list')) return { stdout: 'spree\nspree_core\n' }
+ if (args.includes('--name-only')) return { stdout: 'spree\nspree_core\n' }
+ if (args.includes('list')) {
+ versionProbes.push(`${cmd} ${args.join(' ')}`)
+ if (spreeVersion === null) throw new Error('bundler failed')
+ return { stdout: ` * spree (${spreeVersion})\n * spree_core (${spreeVersion})\n` }
+ }
if (args.includes('config')) return { stdout: 'web\n' }
const command = `${cmd} ${args.join(' ')}`
commands.push(command)
@@ -250,7 +531,13 @@ describe('spree upgrade', () => {
}) as never)
}
- function writeProject({ ejected }: { ejected: boolean }): void {
+ function writeProject({
+ ejected,
+ dashboardDependencies = { '@spree/dashboard': '^1.0.0' },
+ }: {
+ ejected: boolean
+ dashboardDependencies?: Record<string, string>
+ }): void {
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), 'spree-cli-upgrade-run-test-'))
fs.writeFileSync(
path.join(projectDir, 'docker-compose.yml'),
@@ -266,7 +553,7 @@ describe('spree upgrade', () => {
fs.mkdirSync(dashboardDir, { recursive: true })
fs.writeFileSync(
path.join(dashboardDir, 'package.json'),
- JSON.stringify({ dependencies: { '@spree/dashboard': '^1.0.0' } }),
+ JSON.stringify({ dependencies: dashboardDependencies }),
)
}
@@ -278,6 +565,8 @@ describe('spree upgrade', () => {
beforeEach(() => {
commands = []
+ versionProbes = []
+ vi.mocked(prompts.log.warn).mockClear()
routeExeca()
})
@@ -294,7 +583,9 @@ describe('spree upgrade', () => {
expect(commands).toEqual([
'docker compose exec web bundle update spree spree_core',
'pnpm update @spree/cli',
+ 'pnpm dedupe',
'pnpm update @spree/dashboard',
+ 'pnpm dedupe',
'docker compose exec web bin/rails spree:install:migrations db:migrate',
'docker compose exec web bin/rake spree:upgrade',
'docker compose restart web',
@@ -309,13 +600,166 @@ describe('spree upgrade', () => {
expect(commands).toEqual([
'docker compose pull',
'pnpm update @spree/cli',
+ 'pnpm dedupe',
'pnpm update @spree/dashboard',
+ 'pnpm dedupe',
'docker compose up -d --no-deps web',
'docker compose up -d --wait',
'docker compose exec web bin/rake spree:upgrade',
])
})
+ it("moves the old line's ranges to the Spree version before updating", async () => {
+ writeProject({ ejected: true })
+
+ await runUpgrade()
+
+ const dashboard = JSON.parse(
+ fs.readFileSync(path.join(projectDir, 'apps', 'dashboard', 'package.json'), 'utf-8'),
+ )
+ expect(dashboard.dependencies['@spree/dashboard']).toBe('^6.0.0-rc.7')
+ })
+
+ it('installs pinned packages at the Spree version and keeps them pinned', async () => {
+ writeProject({
+ ejected: true,
+ dashboardDependencies: {
+ '@spree/dashboard': '6.0.0-rc.6',
+ '@spree/dashboard-ui': '6.0.0-rc.6',
+ '@spree/dashboard-core': '6.0.0-rc.7',
+ '@spree/admin-sdk': '^6.0.0-rc.6',
+ },
+ })
+
+ await runUpgrade()
+
+ expect(commands).toEqual([
+ 'docker compose exec web bundle update spree spree_core',
+ 'pnpm update @spree/cli',
+ 'pnpm dedupe',
+ 'pnpm update @spree/admin-sdk',
+ 'pnpm add --save-exact @spree/[email protected] @spree/[email protected]',
+ 'pnpm dedupe',
+ 'docker compose exec web bin/rails spree:install:migrations db:migrate',
+ 'docker compose exec web bin/rake spree:upgrade',
+ 'docker compose restart web',
+ ])
+ })
+
+ it('leaves pins newer than the Spree version it was built with', async () => {
+ writeProject({
+ ejected: true,
+ dashboardDependencies: { '@spree/dashboard': '6.0.0', '@spree/dashboard-ui': '6.0.1' },
+ })
+
+ await runUpgrade()
+
+ expect(commands.filter((command) => command.startsWith('pnpm'))).toEqual([
+ 'pnpm update @spree/cli',
+ 'pnpm dedupe',
+ 'pnpm dedupe',
+ ])
+ })
+
+ it('moves the packages to the Spree version the server runs, not the one built in', async () => {
+ writeProject({
+ ejected: true,
+ dashboardDependencies: {
+ '@spree/dashboard': '6.0.0-rc.7',
+ '@spree/dashboard-core': '^1.0.0',
+ },
+ })
+ routeExeca({ spreeVersion: '6.0.0.rc8' })
+
+ await runUpgrade()
+
+ expect(commands.filter((command) => command.startsWith('pnpm'))).toEqual([
+ 'pnpm update @spree/cli',
+ 'pnpm dedupe',
+ 'pnpm update @spree/dashboard-core',
+ 'pnpm add --save-exact @spree/[email protected]',
+ 'pnpm dedupe',
+ ])
+ const dashboard = JSON.parse(
+ fs.readFileSync(path.join(projectDir, 'apps', 'dashboard', 'package.json'), 'utf-8'),
+ )
+ expect(dashboard.dependencies['@spree/dashboard-core']).toBe('^6.0.0-rc.8')
+ })
+
+ it('gives release candidate pins a range back when the final release lands', async () => {
+ writeProject({
+ ejected: true,
+ dashboardDependencies: {
+ '@spree/dashboard': '6.0.0-rc.7',
+ '@spree/dashboard-ui': '6.0.0-rc.7',
+ '@spree/dashboard-core': '6.0.0-rc.7',
+ },
+ })
+ const dashboardPackageJson = path.join(projectDir, 'apps', 'dashboard', 'package.json')
+ const manifest = JSON.parse(fs.readFileSync(dashboardPackageJson, 'utf-8'))
+ manifest.devDependencies = { '@spree/admin-sdk': '6.0.0-rc.7' }
+ fs.writeFileSync(dashboardPackageJson, JSON.stringify(manifest))
+ routeExeca({ spreeVersion: '6.0.0' })
+
+ await runUpgrade()
+
+ expect(commands.filter((command) => command.startsWith('pnpm'))).toEqual([
+ 'pnpm update @spree/cli',
+ 'pnpm dedupe',
+ 'pnpm update @spree/dashboard @spree/dashboard-ui @spree/dashboard-core @spree/admin-sdk',
+ 'pnpm dedupe',
+ ])
+ const dashboard = JSON.parse(fs.readFileSync(dashboardPackageJson, 'utf-8'))
+ expect(dashboard.dependencies).toEqual({
+ '@spree/dashboard': '^6.0.0',
+ '@spree/dashboard-ui': '^6.0.0',
+ '@spree/dashboard-core': '^6.0.0',
+ })
+ expect(dashboard.devDependencies).toEqual({ '@spree/admin-sdk': '^6.0.0' })
+ })
+
+ it('keeps a pin on a final version exact', async () => {
+ writeProject({ ejected: true, dashboardDependencies: { '@spree/dashboard': '6.0.0' } })
+ routeExeca({ spreeVersion: '6.0.1' })
+
+ await runUpgrade()
+
+ expect(commands).toContain('pnpm add --save-exact @spree/[email protected]')
+ })
+
+ it('reads a pulled image from a one-off container, since the running one is still the old image', async () => {
+ writeProject({ ejected: false })
+
+ await runUpgrade()
+
+ expect(versionProbes).toEqual(['docker compose run --rm --no-deps -T web bundle list'])
+ })
+
+ it('falls back to the built-in Spree version, with a warning, when the server cannot say', async () => {
+ writeProject({ ejected: true, dashboardDependencies: { '@spree/dashboard': '6.0.0-rc.6' } })
+ routeExeca({ spreeVersion: null })
+
+ await runUpgrade()
+
+ expect(commands).toContain('pnpm add --save-exact @spree/[email protected]')
+ expect(vi.mocked(prompts.log.warn)).toHaveBeenCalledWith(
+ expect.stringContaining("Could not read the server's Spree version"),
+ )
+ })
+
+ it('moves nothing on a server from before the packages shared its version', async () => {
+ writeProject({ ejected: true, dashboardDependencies: { '@spree/dashboard': '1.0.0-rc.6' } })
+ routeExeca({ spreeVersion: '5.6.2' })
+
+ await runUpgrade()
+
+ expect(commands.filter((command) => command.startsWith('pnpm'))).toEqual([
+ 'pnpm update @spree/cli',
+ 'pnpm dedupe',
+ 'pnpm dedupe',
+ ])
+ })
+
it('has already bumped the packages when a backfill fails', async () => {
writeProject({ ejected: true })
routeExeca({ failOn: 'spree:upgrade' })
diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts
index 41f10625a6..24839cc5ea 100644
--- a/packages/cli/tsup.config.ts
+++ b/packages/cli/tsup.config.ts
@@ -1,6 +1,7 @@
import { cpSync } from 'node:fs'
import { defineConfig } from 'tsup'
import { pluginPeerRanges } from './scripts/plugin-peer-ranges.mjs'
+import { releaseLine } from './scripts/release-line.mjs'
export default defineConfig({
entry: ['src/index.ts'],
@@ -9,7 +10,10 @@ export default defineConfig({
platform: 'node',
noExternal: [/.*/],
splitting: false,
- define: { __SPREE_PLUGIN_PEER_RANGES__: JSON.stringify(pluginPeerRanges()) },
+ define: {
+ __SPREE_PLUGIN_PEER_RANGES__: JSON.stringify(pluginPeerRanges()),
+ __SPREE_RELEASE_LINE__: JSON.stringify(releaseLine()),
+ },
clean: true,
minify: true,
banner: {
diff --git a/packages/cli/turbo.json b/packages/cli/turbo.json
index 9c9d310fca..fc505b9229 100644
--- a/packages/cli/turbo.json
+++ b/packages/cli/turbo.json
@@ -9,6 +9,7 @@
"$TURBO_ROOT$/scripts/sync-starter.mjs",
"$TURBO_ROOT$/biome.json",
"$TURBO_ROOT$/packages/*/package.json",
+ "$TURBO_ROOT$/.changeset/config.json",
"$TURBO_ROOT$/packages/dashboard-starter/**",
"$TURBO_ROOT$/packages/seller-dashboard-starter/**",
"!$TURBO_ROOT$/packages/*-starter/{node_modules,dist,.turbo,.tanstack}/**",
diff --git a/packages/cli/vitest.config.ts b/packages/cli/vitest.config.ts
index cbe51da45f..28b99b5599 100644
--- a/packages/cli/vitest.config.ts
+++ b/packages/cli/vitest.config.ts
@@ -1,8 +1,12 @@
import { defineConfig } from 'vitest/config'
import { pluginPeerRanges } from './scripts/plugin-peer-ranges.mjs'
+import { releaseLine } from './scripts/release-line.mjs'
export default defineConfig({
- define: { __SPREE_PLUGIN_PEER_RANGES__: JSON.stringify(pluginPeerRanges()) },
+ define: {
+ __SPREE_PLUGIN_PEER_RANGES__: JSON.stringify(pluginPeerRanges()),
+ __SPREE_RELEASE_LINE__: JSON.stringify(releaseLine()),
+ },
test: {
environment: 'node',
include: ['tests/**/*.test.ts'],
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index e923432423..c32287ab8a 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/core
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 0.3.0
### Minor Changes
diff --git a/packages/core/package.json b/packages/core/package.json
index 2e308d9924..cc4f21a0dd 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/core",
- "version": "0.3.0",
+ "version": "6.0.0-rc.7",
"description": "Universal Spree Commerce code: country, currency, locale and unit code lists, exact money arithmetic and the filter vocabulary",
"type": "module",
"sideEffects": false,
diff --git a/packages/dashboard-core/CHANGELOG.md b/packages/dashboard-core/CHANGELOG.md
index 25902d6630..803bec6962 100644
--- a/packages/dashboard-core/CHANGELOG.md
+++ b/packages/dashboard-core/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/dashboard-core
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.6
### Minor Changes
diff --git a/packages/dashboard-core/package.json b/packages/dashboard-core/package.json
index 67f0cc8736..9034466943 100644
--- a/packages/dashboard-core/package.json
+++ b/packages/dashboard-core/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard-core",
"license": "MIT",
- "version": "1.0.0-rc.6",
+ "version": "6.0.0-rc.7",
"description": "Spree Dashboard framework — registries (table, nav, slot, settings-nav), providers (auth, permission, store), admin SDK client, generic infra hooks, and the defineDashboardPlugin extension API. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
@@ -58,8 +58,8 @@
"prepublishOnly": "tsup"
},
"peerDependencies": {
- "@spree/admin-sdk": ">=1.0.0-rc.4 <2.0.0-0",
- "@spree/dashboard-ui": ">=0.10.0 <1.0.0-0 || >=1.0.0-0 <2.0.0-0",
+ "@spree/admin-sdk": ">=6.0.0-rc.7 <7.0.0-0",
+ "@spree/dashboard-ui": ">=6.0.0-rc.7 <7.0.0-0",
"@tanstack/react-query": "^5.100.9",
"@tanstack/react-router": "^1.169.2",
"i18next": "^26.2.0",
diff --git a/packages/dashboard-ui/CHANGELOG.md b/packages/dashboard-ui/CHANGELOG.md
index 368096bb71..7e629d831b 100644
--- a/packages/dashboard-ui/CHANGELOG.md
+++ b/packages/dashboard-ui/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/dashboard-ui
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.6
### Patch Changes
diff --git a/packages/dashboard-ui/package.json b/packages/dashboard-ui/package.json
index 8bd2e98011..8cd6de96ca 100644
--- a/packages/dashboard-ui/package.json
+++ b/packages/dashboard-ui/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard-ui",
"license": "MIT",
- "version": "1.0.0-rc.6",
+ "version": "6.0.0-rc.7",
"description": "Spree Dashboard design system — shadcn primitives, headless composed components, and design tokens. Source-only package; consumers compile via their own Vite/Tailwind setup. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
diff --git a/packages/dashboard/CHANGELOG.md b/packages/dashboard/CHANGELOG.md
index 8327376504..e6abea40d9 100644
--- a/packages/dashboard/CHANGELOG.md
+++ b/packages/dashboard/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/dashboard
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.6
### Minor Changes
diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json
index ed40cd502c..8669b609cc 100644
--- a/packages/dashboard/package.json
+++ b/packages/dashboard/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard",
"license": "MIT",
- "version": "1.0.0-rc.6",
+ "version": "6.0.0-rc.7",
"description": "Spree Dashboard app shell — the next-gen React admin for Spree Commerce. Routes, resource hooks, schemas, locales, and the <Dashboard /> component. Source-only package; hosts compile it via @spree/dashboard/vite. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md
index 18505a35c1..23fb3e15da 100644
--- a/packages/sdk/CHANGELOG.md
+++ b/packages/sdk/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/sdk
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 2.0.0-rc.5
### Minor Changes
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
index 378557427b..55cd2f9418 100644
--- a/packages/sdk/package.json
+++ b/packages/sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/sdk",
- "version": "2.0.0-rc.5",
+ "version": "6.0.0-rc.7",
"description": "Official TypeScript SDK for Spree Commerce Store API",
"type": "module",
"main": "./dist/index.cjs",
diff --git a/packages/seller-dashboard/CHANGELOG.md b/packages/seller-dashboard/CHANGELOG.md
index 70a322bd00..4d248ebc90 100644
--- a/packages/seller-dashboard/CHANGELOG.md
+++ b/packages/seller-dashboard/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/seller-dashboard
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.7
### Minor Changes
diff --git a/packages/seller-dashboard/package.json b/packages/seller-dashboard/package.json
index f18e5e6556..2729674e02 100644
--- a/packages/seller-dashboard/package.json
+++ b/packages/seller-dashboard/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/seller-dashboard",
- "version": "1.0.0-rc.7",
+ "version": "6.0.0-rc.7",
"license": "MIT",
"type": "module",
"description": "Spree marketplace seller panel — the seller-facing counterpart to the admin dashboard.",
diff --git a/packages/seller-sdk/CHANGELOG.md b/packages/seller-sdk/CHANGELOG.md
index d4d2e33b48..03cf4a65fd 100644
--- a/packages/seller-sdk/CHANGELOG.md
+++ b/packages/seller-sdk/CHANGELOG.md
@@ -1,5 +1,9 @@
# @spree/seller-sdk
+## 6.0.0-rc.7
+
+Released with Spree 6.0.0.rc7, with no changes of its own. From this release the version matches the version of the Spree gems.
+
## 1.0.0-rc.6
### Minor Changes
diff --git a/packages/seller-sdk/package.json b/packages/seller-sdk/package.json
index 781f7adfea..ff74667824 100644
--- a/packages/seller-sdk/package.json
+++ b/packages/seller-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/seller-sdk",
- "version": "1.0.0-rc.6",
+ "version": "6.0.0-rc.7",
"description": "TypeScript client for the Spree Seller API — the marketplace seller panel.",
"type": "module",
"main": "./dist/index.cjs",
diff --git a/scripts/publish-packages.mjs b/scripts/publish-packages.mjs
new file mode 100644
index 0000000000..63c218e01c
--- /dev/null
+++ b/scripts/publish-packages.mjs
@@ -0,0 +1,166 @@
+// Publishes the npm packages a release tag names, skipping any version already
+// on npm, so a release that failed part-way can simply run again. The npm
+// dist-tag follows the version: `0.x` → `next`, a prerelease → `beta`, else
+// `latest`. Run by release.yml:
+//
+// v6.0.0.rc7 the packages that share the Spree version
+// @spree/[email protected] @spree/cli
+// [email protected] create-spree-app
+//
+// node scripts/publish-packages.mjs verify <tag> the tag matches the versions
+// in the repository
+// node scripts/publish-packages.mjs publish <tag> build and publish what it names
+import { execFileSync } from 'node:child_process'
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { alignedPackages, gemVersion, npmVersion } from './version-packages.mjs'
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
+
+/**
+ * @param {string} version
+ * @returns {string}
+ */
+export function distTag(version) {
+ if (version.startsWith('0.')) return 'next'
+ return version.includes('-') ? 'beta' : 'latest'
+}
+
+function manifest(dir) {
+ return JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))
+}
+
+function workspacePackages() {
+ const packagesDir = path.join(repoRoot, 'packages')
+ return new Map(
+ fs
+ .readdirSync(packagesDir)
+ .map((dir) => path.join(packagesDir, dir))
+ .filter((dir) => fs.existsSync(path.join(dir, 'package.json')))
+ .map((dir) => [manifest(dir).name, dir]),
+ )
+}
+
+/**
+ * Orders packages so each publishes after the ones it depends on: `pnpm
+ * publish` rewrites `workspace:` ranges to the versions being released, and an
+ * install of a package whose dependency is not on npm yet fails.
+ *
+ * @param {Array<{ name: string, dir: string }>} packages
+ */
+export function dependencyOrder(packages) {
+ const names = new Set(packages.map(({ name }) => name))
+ const dependsOn = new Map(
+ packages.map(({ name, dir }) => {
+ const { dependencies = {}, peerDependencies = {} } = manifest(dir)
+ return [
+ name,
+ Object.keys({ ...dependencies, ...peerDependencies }).filter((dep) => names.has(dep)),
+ ]
+ }),
+ )
+ const ordered = []
+ const visit = (name, trail = []) => {
+ if (ordered.some((pkg) => pkg.name === name)) return
+ if (trail.includes(name)) throw new Error(`Dependency cycle: ${[...trail, name].join(' → ')}`)
+ for (const dep of dependsOn.get(name)) visit(dep, [...trail, name])
+ ordered.push(packages.find((pkg) => pkg.name === name))
+ }
+ for (const { name } of packages) visit(name)
+ return ordered
+}
+
+function isPublished(name, version) {
+ try {
+ return (
+ execFileSync('npm', ['view', `${name}@${version}`, 'version'], {
+ encoding: 'utf8',
+ stdio: ['ignore', 'pipe', 'ignore'],
+ }).trim() !== ''
+ )
+ } catch {
+ return false
+ }
+}
+
+function publish(packages) {
+ const filters = packages.flatMap(({ name }) => ['--filter', name])
+ execFileSync('pnpm', ['turbo', 'build', ...filters], { cwd: repoRoot, stdio: 'inherit' })
+
+ for (const { name, dir } of dependencyOrder(packages)) {
+ const { version } = manifest(dir)
+ if (isPublished(name, version)) {
+ console.log(`${name}@${version} is already on npm, skipping.`)
+ continue
+ }
+ const tag = distTag(version)
+ console.log(`Publishing ${name}@${version} under ${tag}.`)
+ // `pnpm publish`, not `npm publish`: it rewrites `workspace:` ranges, which
+ // npm would ship verbatim, and runs each package's prepublishOnly build.
+ execFileSync(
+ 'pnpm',
+ ['publish', '--provenance', '--access', 'public', '--tag', tag, '--no-git-checks'],
+ { cwd: dir, stdio: 'inherit' },
+ )
+ }
+}
+
+// Released on their own tags, independently of Spree.
+const TOOLS = ['@spree/cli', 'create-spree-app']
+
+/**
+ * The packages a release tag names, after checking that the versions in the
+ * repository are the ones the tag announces. Throws when they are not.
+ *
+ * @param {string} gitTag
+ * @returns {Array<{ name: string, dir: string }>}
+ */
+export function packagesForTag(gitTag) {
+ if (gitTag?.startsWith('v')) {
+ const spreeVersion = gemVersion()
+ const expected = npmVersion(spreeVersion)
+ const problems = []
+ if (gitTag !== `v${spreeVersion}`) {
+ problems.push(
+ `the tag does not match Spree::VERSION ${spreeVersion} (expected v${spreeVersion})`,
+ )
+ }
+ const packages = alignedPackages()
+ for (const { name, dir } of packages) {
+ const { version } = manifest(dir)
+ if (version !== expected) problems.push(`${name} is at ${version}, expected ${expected}`)
+ }
+ if (problems.length > 0) {
+ throw new Error(
+ `Not releasing ${gitTag}:\n- ${problems.join('\n- ')}\nRun \`pnpm version:packages\` after bumping Spree::VERSION.`,
+ )
+ }
+ return packages
+ }
+
+ const at = gitTag?.lastIndexOf('@') ?? -1
+ const name = at > 0 ? gitTag.slice(0, at) : ''
+ if (!TOOLS.includes(name)) {
+ throw new Error(
+ `Not releasing ${gitTag}: expected v<Spree version> or <package>@<version> for ${TOOLS.join(' or ')}`,
+ )
+ }
+ const dir = workspacePackages().get(name)
+ const { version } = manifest(dir)
+ if (gitTag.slice(at + 1) !== version) {
+ throw new Error(`Not releasing ${gitTag}: ${name} is at ${version} in the repository`)
+ }
+ return [{ name, dir }]
+}
+
+function main([command, gitTag]) {
+ if (command === 'verify') {
+ const packages = packagesForTag(gitTag)
+ return console.log(`${gitTag} releases ${packages.map(({ name }) => name).join(', ')}.`)
+ }
+ if (command === 'publish') return publish(packagesForTag(gitTag))
+ throw new Error('Usage: publish-packages.mjs verify|publish <tag>')
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) main(process.argv.slice(2))
diff --git a/scripts/sync-starter.mjs b/scripts/sync-starter.mjs
index 57104a4c67..9c627e4a41 100644
--- a/scripts/sync-starter.mjs
+++ b/scripts/sync-starter.mjs
@@ -29,6 +29,7 @@
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
+import { alignedPackages, majorFloorRange } from './version-packages.mjs'
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
@@ -82,14 +83,13 @@ function publishedRange(name) {
if (manifest.private) {
throw new Error(`${name} is private — it can't be a dependency of the synced template`)
}
- // On 0.x, `^` never crosses a minor, so scaffolds stay frozen on whatever
- // minor the CLI happened to be published against — a dashboard release
- // without a CLI release in the same train would never reach users. Float
- // instead, floored at the version this template was built against, through
- // all of 0.x AND into 1.x so preview-era apps migrate to stable on their
- // own. After 1.0, `^` floats within the major on its own.
+ // Packages released with Spree float over their whole major, floored at its
+ // first release rather than at the version in this workspace: the CLI that
+ // embeds this template releases on its own tag, possibly before that version
+ // reaches npm, and a range on an unpublished version fails every install.
const { version } = manifest
- return version.startsWith('0.') ? `>=${version} <2.0.0` : `^${version}`
+ if (alignedPackages().some((pkg) => pkg.name === name)) return majorFloorRange(version)
+ return `^${version}`
}
const pkgPath = path.join(targetDir, 'package.json')
diff --git a/scripts/version-packages.mjs b/scripts/version-packages.mjs
new file mode 100644
index 0000000000..1fcdca63ce
--- /dev/null
+++ b/scripts/version-packages.mjs
@@ -0,0 +1,181 @@
+// Versions the npm packages from the pending changesets, then moves every
+// package in the Changesets `fixed` group onto the version of the Spree gems
+// (`spree/core/lib/spree/core/version.rb`, in npm's spelling). Changesets still
+// writes the changelogs, but the bump type a changeset names no longer decides
+// the version of those packages: `@spree/[email protected]` is the SDK for Spree 6.0.2.
+// Packages outside the group (`@spree/cli`, `create-spree-app`) keep the
+// version Changesets gives them.
+//
+// Bump `Spree::VERSION` first, then run `pnpm version:packages`.
+//
+// `pnpm version:tools` (`--tools`) versions only the packages outside the
+// group, for a CLI or create-spree-app release between Spree releases; the
+// group's pending changesets wait for the next Spree release.
+import { execFileSync } from 'node:child_process'
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
+
+/**
+ * The npm spelling of a RubyGems version: `6.0.0.rc7` → `6.0.0-rc.7`. npm needs
+ * the hyphen, and the dot keeps `rc.10` sorting above `rc.9`.
+ *
+ * @param {string} gemVersion
+ * @returns {string}
+ */
+export function npmVersion(gemVersion) {
+ const match = gemVersion.match(/^(\d+\.\d+\.\d+)(?:\.([a-z]+)(\d*))?$/)
+ if (!match) throw new Error(`Cannot convert Spree version ${gemVersion} to an npm version`)
+ const [, release, label, number] = match
+ if (!label) return release
+ return number ? `${release}-${label}.${number}` : `${release}-${label}`
+}
+
+/**
+ * The range a package in the group accepts for another one it names with a
+ * literal range: this release and anything after it in the same major. The
+ * floor is the full version because semver only lets a prerelease such as
+ * `6.0.1-rc.1` satisfy a range with a comparator on that same `6.0.1`.
+ *
+ * @param {string} version
+ * @returns {string}
+ */
+export function peerRange(version) {
+ const major = Number(version.split('.')[0])
+ return `>=${version} <${major + 1}.0.0-0`
+}
+
+/**
+ * A range over a package's whole major, release candidates included:
+ * `^6.0.0-0` accepts `6.0.0-rc.7`, `6.0.0` and every later 6.x, and installs
+ * the newest. Used where a range must never point at a version that may not be
+ * on npm yet.
+ *
+ * @param {string} version
+ * @returns {string}
+ */
+export function majorFloorRange(version) {
+ return `^${version.split('.')[0]}.0.0-0`
+}
+
+function readJson(file) {
+ return JSON.parse(fs.readFileSync(file, 'utf8'))
+}
+
+export function gemVersion() {
+ const source = fs.readFileSync(
+ path.join(repoRoot, 'spree/core/lib/spree/core/version.rb'),
+ 'utf8',
+ )
+ const match = source.match(/VERSION = '([^']+)'/)
+ if (!match) throw new Error('Spree::VERSION not found in spree/core/lib/spree/core/version.rb')
+ return match[1]
+}
+
+function hasPendingChangesets() {
+ return fs
+ .readdirSync(path.join(repoRoot, '.changeset'))
+ .some((file) => file.endsWith('.md') && file !== 'README.md')
+}
+
+export function alignedPackages() {
+ const { fixed } = readJson(path.join(repoRoot, '.changeset/config.json'))
+ const group = fixed.find((names) => names.includes('@spree/sdk'))
+ if (!group) throw new Error('No Changesets fixed group contains @spree/sdk')
+
+ const packagesDir = path.join(repoRoot, 'packages')
+ const byName = new Map(
+ fs
+ .readdirSync(packagesDir)
+ .map((dir) => path.join(packagesDir, dir))
+ .filter((dir) => fs.existsSync(path.join(dir, 'package.json')))
+ .map((dir) => [readJson(path.join(dir, 'package.json')).name, dir]),
+ )
+ return group.map((name) => {
+ const dir = byName.get(name)
+ if (!dir) throw new Error(`${name} is in the fixed group but not in packages/`)
+ return { name, dir }
+ })
+}
+
+// Edits the text rather than re-serializing, so the file keeps its formatting.
+function setVersion(manifestPath, from, to) {
+ const source = fs.readFileSync(manifestPath, 'utf8')
+ fs.writeFileSync(manifestPath, source.replace(`"version": "${from}"`, `"version": "${to}"`))
+}
+
+function setPeerRanges(manifestPath, names, range) {
+ const manifest = readJson(manifestPath)
+ let source = fs.readFileSync(manifestPath, 'utf8')
+ for (const group of ['dependencies', 'peerDependencies']) {
+ for (const [name, spec] of Object.entries(manifest[group] ?? {})) {
+ if (!names.includes(name) || spec.startsWith('workspace:') || spec === range) continue
+ source = source.replace(`"${name}": "${spec}"`, `"${name}": "${range}"`)
+ }
+ }
+ fs.writeFileSync(manifestPath, source)
+}
+
+function updateChangelog(changelogPath, { computed, target, changed, spreeVersion }) {
+ if (!fs.existsSync(changelogPath)) return
+ const source = fs.readFileSync(changelogPath, 'utf8')
+ const updated = changed
+ ? source.replace(`## ${computed}\n`, `## ${target}\n`)
+ : source.replace(
+ /^(# .+\n)/,
+ `$1\n## ${target}\n\nReleased with Spree ${spreeVersion}, with no changes of its own.\n`,
+ )
+ fs.writeFileSync(changelogPath, updated)
+}
+
+function versionTools() {
+ const ignores = alignedPackages().flatMap(({ name }) => ['--ignore', name])
+ execFileSync('pnpm', ['exec', 'changeset', 'version', ...ignores], {
+ cwd: repoRoot,
+ stdio: 'inherit',
+ })
+}
+
+function main() {
+ if (process.argv.includes('--tools')) return versionTools()
+
+ const spreeVersion = gemVersion()
+ const target = npmVersion(spreeVersion)
+ const packages = alignedPackages()
+ const names = packages.map(({ name }) => name)
+ const before = new Map(
+ packages.map(({ name, dir }) => [name, readJson(path.join(dir, 'package.json')).version]),
+ )
+
+ // `changeset version` fails when nothing is pending, but a Spree release
+ // without TypeScript changes still moves the group to the new version.
+ if (hasPendingChangesets()) {
+ execFileSync('pnpm', ['exec', 'changeset', 'version'], { cwd: repoRoot, stdio: 'inherit' })
+ }
+
+ const plans = packages.map(({ name, dir }) => {
+ const manifestPath = path.join(dir, 'package.json')
+ const computed = readJson(manifestPath).version
+ return { name, dir, manifestPath, computed, changed: computed !== before.get(name) }
+ })
+ const stale = plans.filter(({ name, changed }) => changed && before.get(name) === target)
+ if (stale.length > 0) {
+ throw new Error(
+ `${stale.map(({ name }) => name).join(', ')} already at ${target} but with pending changes. ` +
+ 'Bump Spree::VERSION, then discard the changes `changeset version` made and run this again.',
+ )
+ }
+
+ for (const { name, dir, manifestPath, computed, changed } of plans) {
+ if (before.get(name) !== target) {
+ updateChangelog(path.join(dir, 'CHANGELOG.md'), { computed, target, changed, spreeVersion })
+ setVersion(manifestPath, computed, target)
+ console.log(`${name}: ${before.get(name)} → ${target}`)
+ }
+ setPeerRanges(manifestPath, names, peerRange(target))
+ }
+}
+
+if (process.argv[1] === fileURLToPath(import.meta.url)) main()
diff --git a/spree/core/lib/spree/core/version.rb b/spree/core/lib/spree/core/version.rb
index dc60484652..06708cc653 100644
--- a/spree/core/lib/spree/core/version.rb
+++ b/spree/core/lib/spree/core/version.rb
@@ -1,5 +1,5 @@
module Spree
- VERSION = '6.0.0.rc6'.freeze
+ VERSION = '6.0.0.rc7'.freeze
def self.version
VERSION