diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..a6955ec --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,56 @@ +# Changesets + +This folder holds the pending release notes for the next version. + +Whenever you change something worth mentioning in a release, run `npx changeset` +and answer the two prompts (which packages, and whether it's a patch/minor/major). +That writes a small markdown file here, which you commit along with your changes. + +At release time `npm run publish` consumes every pending file: it computes the +resulting versions, updates the `package.json`s and the `CHANGELOG.md`s, and +deletes the files. + +## Each package versions on its own + +There is no group here: the ten packages are **independent**, so a changeset +touching `datocms-structured-text-to-markdown` bumps that package and nothing +else. This is what `lerna.json` asked for in "Switch lerna to independent +versioning", and it is what the repository now actually does — the ten packages +sitting at `6.0.0` are the residue of the fixed mode that came before it. + +So the package list inside a changeset carries real weight, unlike in a lockstep +repo. Pick every package whose _own_ behaviour changed. You do **not** need to +list packages that merely depend on one you changed: changesets bumps a +dependent by itself, whenever the new version falls outside the range that +dependent declares. + +`datocms-structured-text-utils` is the root of the graph — everything else +depends on it, directly or through `datocms-structured-text-generic-html-renderer` +— so a `major` there is a major for the whole repository in practice, even +though the version numbers will no longer move in lockstep to say so. + +## Which bump level? + +- `patch` — bug fixes only. It's the clearest signal in semver ("nothing new, + just a fix"), so we don't spend it on anything else. +- `minor` — new API surface. A new exported function, a new node type, a new + option on an existing one. +- `major` — something was removed or renamed. + +## Prereleases + +`npm run publish-next` publishes under the `next` dist-tag, leaving `latest` +untouched. It works in two modes: + +- **as-is** — the pending changesets produce a normal version (say `6.1.0`) + which is published under `next` instead of `latest`; +- **real prerelease versions** — run `npx changeset pre enter next` first and + the same command produces `6.1.0-next.0`, `6.1.0-next.1`, … That mode is + recorded in `.changeset/pre.json`, which you commit. Run + `npx changeset pre exit` when the line is done. + +Either way the GitHub release is marked as a prerelease, so it never becomes +the repository's "Latest release". + +`npm run publish` refuses to run while `.changeset/pre.json` exists, so a +forgotten pre mode can't quietly turn a real release into a prerelease. diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..487f6ae --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@4.0.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "access": "public", + "baseBranch": "main", + "fixed": [], + "linked": [], + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6b317cb..2c159dd 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -1,4 +1,6 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node +# Installs from the lockfile, builds every workspace through Turborepo and runs +# the test suite. +# # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: Node.js CI @@ -15,8 +17,10 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 22.x] + # 18 and 20 are both past end-of-life, and @changesets/cli needs + # ^22.11 || ^24 || >=26 — see .nvmrc. # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + node-version: [22.x, 24.x] steps: - uses: actions/checkout@v4 @@ -24,7 +28,10 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} + # One install for the whole workspace; the internal packages are + # symlinked into the root node_modules, so there is no bootstrap step. - run: npm ci - - run: ./node_modules/.bin/lerna bootstrap - - run: npm run build --if-present + # Turborepo derives the build order from the manifests: `utils` before + # `generic-html-renderer` before the renderers that depend on it. + - run: npm run build - run: npm test diff --git a/.gitignore b/.gitignore index 984d6a8..755b4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ yarn.lock **/.rpt2_cache .vscode/settings.json + +# Turborepo +.turbo diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/.prettierignore b/.prettierignore index 2ef4e34..d9549b7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ **/dist -**/package-lock.json \ No newline at end of file +**/package-lock.json +.turbo diff --git a/CLAUDE.md b/CLAUDE.md index da16e2d..b2f6174 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,24 +4,30 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Overview -This is a Lerna-managed monorepo for DatoCMS Structured Text (DAST) utilities. It provides TypeScript libraries for handling, converting, and rendering DatoCMS Structured Text documents across multiple formats. +This is an npm-workspaces monorepo for DatoCMS Structured Text (DAST) utilities, built with Turborepo and released with Changesets. It provides TypeScript libraries for handling, converting, and rendering DatoCMS Structured Text documents across multiple formats. + +Node 22 or later is required (see `.nvmrc`) — `@changesets/cli` declares `^22.11 || ^24 || >=26` and dies on Node 20 with an error that does not mention versions. The published packages have no such requirement. ## Commands ### Building ```bash -npm run build # Bootstrap all packages and build them -lerna bootstrap # Install dependencies for all packages -lerna run build # Build all packages +npm install # One install for the whole workspace; no bootstrap step +npm run build # turbo run build — every package, in dependency order +npx turbo run build --filter= # ...and its dependencies only ``` -Individual packages can be built by navigating to `packages/` and running: +Turborepo derives the order from the manifests (`dependsOn: ["^build"]`), so nobody maintains a list: `utils` builds before `generic-html-renderer` before the renderers that depend on it. `npm run