diff --git a/.gitignore b/.gitignore index 0c6e8bb..f9b52bb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ pnpm-debug.log* lerna-debug.log* node_modules +.turbo/ dist dist-ssr coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6628f4..48a4c32 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,12 @@ Use Node and pnpm versions declared in [package.json](package.json). Install dependencies with `pnpm install`, then run `pnpm dev` for the playground. +Turborepo runs workspace builds, typechecks, development and preview servers, and documentation browser tests. All Turbo task caching is disabled; every invocation executes its selected tasks. Build dependencies run before their consumers, while independent tasks can run in parallel. + +Use `pnpm build` for all libraries and applications, or `pnpm build:packages` for libraries only. Select a workspace directly with `pnpm exec turbo run build --filter=@react-fabrio/ui`; this also builds its dependencies. `pnpm typecheck` checks all workspaces, integration examples, E2E tests and the root Node configuration without requiring a build first. `pnpm dev` starts only the playground, and `pnpm docs:dev` starts only documentation. Server arguments pass through, for example `pnpm dev --host 127.0.0.1 --port 4173 --strictPort`. + +Vitest, coverage, lint, formatting, React Doctor and playground E2E tests keep their existing runners. `pnpm test` runs Vitest; `pnpm docs:test` runs documentation browser tests against an existing documentation build. CI continues to cache pnpm dependencies only. + ## Workflow Read the [glossary](GLOSSARY.md), [architecture](apps/docs/content/architecture.md), and [relevant domain references](apps/docs/content/index.md). Keep changes in the owning package and update the reference that defines the changed contract. Add meaningful behavior tests for document fidelity, permissions, output correctness or customer workflows; avoid tests that duplicate implementation details. diff --git a/apps/docs/content/releasing.md b/apps/docs/content/releasing.md index 366539b..da7b26b 100644 --- a/apps/docs/content/releasing.md +++ b/apps/docs/content/releasing.md @@ -7,10 +7,14 @@ The CI workflow publishes the five library packages from `packages/` with one sh ## Configure npm access -Add an Actions secret named `NPM_TOKEN` in the GitHub repository. Use an npm granular access token with permission to publish every package in the `@react-fabrio` scope, including creating the packages for the first release. The token must support unattended publication under the npm account's two-factor authentication policy. Renew it before it expires. +For the first publication, add an Actions secret named `NPM_TOKEN` in the GitHub repository. Use an npm granular access token with **Read and write (publish and stage)** permission for the `@react-fabrio` scope, including creating the packages, and explicitly enable **Bypass two-factor authentication**. A token that passes `npm whoami` can still fail publication with `ERR_PNPM_OTP_NON_INTERACTIVE` when this option is disabled. Renew it before it expires. See [npm access token configuration](https://docs.npmjs.com/creating-and-viewing-access-tokens/). The workflow supplies this secret as `NODE_AUTH_TOKEN` through the registry configuration created by `actions/setup-node`. GitHub tags and releases use the job's `GITHUB_TOKEN` with `contents: write`. No separate GitHub token is needed. +For subsequent publications, configure a [Trusted Publisher](https://docs.npmjs.com/trusted-publishers/) on each of the five npm packages: GitHub owner `Imunal`, repository `react-fabrio`, workflow filename `ci.yml`, and no environment name (the publish job does not use an environment). Allow direct publishing. The publish job grants `id-token: write`, allowing pnpm to authenticate through OIDC. After all packages use trusted publishing, remove `NPM_TOKEN`. Granting the workflow permission alone does not configure trust on npm. + +Semantic-release does not run `npm whoami` as a precondition because that command does not validate OIDC publication access. npm checks publication access when pnpm publishes. Local `pnpm release` cannot use the GitHub runner's OIDC identity and needs a valid npm token or interactive authentication. + ## Choose commit messages Semantic-release uses Conventional Commits to determine the next version: @@ -28,16 +32,18 @@ Use these conventions in the final commit message on `main`, including the squas The `publish` job runs automatically for pushes to `main` after `validate`, `e2e` and `docs` pass. Pull requests and manual workflow dispatches do not publish. Release jobs run one at a time. -The job installs the locked dependencies and builds the library packages. Its separate **Publish packages and create GitHub release** step runs `pnpm release`. Semantic-release checks registry and GitHub access, analyzes commits and generates release notes. When a release is needed, it sets every public library package to the new version, creates the tag and publishes through pnpm. A GitHub release follows successful npm publication. +The job installs the locked dependencies and builds the library packages. Its separate **Publish packages and create GitHub release** step runs `pnpm release`. Semantic-release checks GitHub access, analyzes commits and generates release notes. When a release is needed, it sets every public library package to the new version, creates the tag and publishes through pnpm. A GitHub release follows successful npm publication. Workspace dependencies become registry versions during packing. The optional Three peer uses `workspace:^`, so its published range follows the release version too. Version changes happen in the CI checkout and are not committed back to the repository; tags and published manifests record the released versions. -`pnpm release:dry-run` previews the release decision and notes without publishing or changing versions. It still checks remote access and requires registry authentication and a GitHub token. Use a checkout of `main` with full Git history. +`pnpm release:dry-run` previews the release decision and notes without publishing or changing versions. It still checks GitHub access and requires a GitHub token; it does not validate npm publication access. Use a checkout of `main` with full Git history. ## Recover from a partial publication If publication fails after the tag was created, inspect the job logs and npm before retrying. Semantic-release may see the existing tag and decide there is no new release. +This also applies to the failed `v1.0.0` publication: correcting authentication and rerunning semantic-release does not finish that tagged version. Follow the recovery steps below with version `1.0.0`; use a token with **Bypass two-factor authentication** when recovering locally. + To finish that release, use a clean checkout of its tag, install dependencies and run the preparation script with that tag's version, for example `node scripts/prepare-release.mjs 1.2.3`. Build the packages, then rerun the pnpm publish command from [release.config.mjs](../../../release.config.mjs) with valid registry credentials. Recursive publishing skips package versions already on npm. After all five versions are available, create the missing GitHub release using the notes from the failed run. Do not remove a tag or reuse a version to change files that have already reached npm. diff --git a/package.json b/package.json index ce0cf1c..fa0ce0a 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,10 @@ "license": "MIT", "type": "module", "scripts": { - "dev": "pnpm --filter playground dev", - "build": "pnpm -r --if-present build", - "build:packages": "pnpm --filter './packages/**' -r build", - "typecheck": "pnpm -r --if-present typecheck && tsc -p tests/tsconfig.json && tsc -p e2e/tsconfig.json && tsc -p tsconfig.node.json", + "dev": "turbo run dev --filter=playground --", + "build": "turbo run build --", + "build:packages": "turbo run build --filter='./packages/**' --", + "typecheck": "turbo run typecheck && tsc -p tests/tsconfig.json && tsc -p e2e/tsconfig.json && tsc -p tsconfig.node.json", "test": "vitest run", "test:coverage": "vitest run --coverage", "test:e2e": "pnpm build:packages && playwright test --config e2e/playwright.config.ts", @@ -17,12 +17,12 @@ "react-doctor": "react-doctor --project @react-fabrio/docs,playground,@react-fabrio/react,@react-fabrio/ui --yes --blocking error --no-telemetry", "format": "oxfmt .", "format:check": "oxfmt . --check", - "preview": "pnpm --filter playground preview", + "preview": "turbo run preview --filter=playground --", "prepare": "lefthook install", - "docs:dev": "pnpm --filter @react-fabrio/docs dev", - "docs:build": "pnpm --filter @react-fabrio/docs build", - "docs:preview": "pnpm --filter @react-fabrio/docs preview", - "docs:test": "pnpm --filter @react-fabrio/docs test", + "docs:dev": "turbo run dev --filter=@react-fabrio/docs --", + "docs:build": "turbo run build --filter=@react-fabrio/docs --", + "docs:preview": "turbo run preview --filter=@react-fabrio/docs --", + "docs:test": "turbo run test --filter=@react-fabrio/docs --", "release": "semantic-release", "release:dry-run": "semantic-release --dry-run" }, @@ -40,6 +40,7 @@ "oxlint": "^1.88.0", "react-doctor": "^0.9.18", "semantic-release": "^25.0.9", + "turbo": "2.11.10", "typescript": "~7.0.2", "vite": "^8.3.4", "vitest": "^5.0.5" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d85c65..e2fc7b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -205,6 +205,9 @@ importers: semantic-release: specifier: ^25.0.9 version: 25.0.9(supports-color@7.2.0)(typescript@7.0.2) + turbo: + specifier: 2.11.10 + version: 2.11.10 typescript: specifier: ~7.0.2 version: 7.0.2 @@ -2491,6 +2494,36 @@ packages: resolution: {integrity: sha512-uhOeFyxLcU41HzvrxsGpiWdcMbScY1EDgbZ5K7DVRMYInbLYWAC0EA/kx9wXAoSM8q82bUG2hRl8+EAjE6XAbA==} engines: {node: '>=20.19'} + '@turbo/darwin-64@2.11.10': + resolution: {integrity: sha512-By4idRap5+nLnMuRzLB4qkOPRlvNdyY1ne4VJYDyUoUB11H94k7uif9mbe3JT8JSNXs1D68uMcBj6hJ/jMQRvA==} + cpu: [x64] + os: [darwin] + + '@turbo/darwin-arm64@2.11.10': + resolution: {integrity: sha512-pyEYlVcuexOPa92p0Wlwl9YT1Is5D60lxN3ItWm3g30YLvFaUq86TF4BBWg5ZAc0uMTnrOzCvuCsOBTdzUWnRQ==} + cpu: [arm64] + os: [darwin] + + '@turbo/linux-64@2.11.10': + resolution: {integrity: sha512-1tYeR/IDZ5HEdsb0jNq2L2xam5nMQ+g80tlV2BZmv4OFw+pMcUM0mMmUcfc5wXPPNHVNPuDMjh9Y8G8HgXPLZA==} + cpu: [x64] + os: [android, linux] + + '@turbo/linux-arm64@2.11.10': + resolution: {integrity: sha512-HuekQxvVGhUd46g1Im/DKdOtglHr4/gguZAvzEpPUgtxNkztSa8lWhQEGQ+EmPQ0n7w19qjThFU+OfEEd0uvlw==} + cpu: [arm64] + os: [android, linux] + + '@turbo/windows-64@2.11.10': + resolution: {integrity: sha512-UJOP3BkbreY3/JlMgJR6ZiimxYIBn+c+B4tnBIxD0E9c3Estmk+XoVNVBNBottZLNRXe3/ScgOU4+/k8tIWysg==} + cpu: [x64] + os: [win32] + + '@turbo/windows-arm64@2.11.10': + resolution: {integrity: sha512-xOkEjF3ws/b/YNlc+bvJHMYBn+vL+QbEISZFVi0qS+ImmhA1X3/gmNmBrjjIG3dg6aeN+n6gQitzSkXQ286qJQ==} + cpu: [arm64] + os: [win32] + '@tweenjs/tween.js@23.1.3': resolution: {integrity: sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==} @@ -5443,6 +5476,10 @@ packages: resolution: {integrity: sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==} engines: {node: '>=0.6.11 <=0.7.0 || >=0.7.3'} + turbo@2.11.10: + resolution: {integrity: sha512-3GJYwig8ygEI89oaOZdduJX8/aw6O9eRPYHoIt6T3FZl9hkKjiyIspufJoVgqXihPoJu8M5CSV0DlZvzfohBCw==} + hasBin: true + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -7715,6 +7752,24 @@ snapshots: '@tanstack/virtual-file-routes@1.162.0': {} + '@turbo/darwin-64@2.11.10': + optional: true + + '@turbo/darwin-arm64@2.11.10': + optional: true + + '@turbo/linux-64@2.11.10': + optional: true + + '@turbo/linux-arm64@2.11.10': + optional: true + + '@turbo/windows-64@2.11.10': + optional: true + + '@turbo/windows-arm64@2.11.10': + optional: true + '@tweenjs/tween.js@23.1.3': {} '@tybys/wasm-util@0.10.4': @@ -10968,6 +11023,15 @@ snapshots: tunnel@0.0.6: {} + turbo@2.11.10: + optionalDependencies: + '@turbo/darwin-64': 2.11.10 + '@turbo/darwin-arm64': 2.11.10 + '@turbo/linux-64': 2.11.10 + '@turbo/linux-arm64': 2.11.10 + '@turbo/windows-64': 2.11.10 + '@turbo/windows-arm64': 2.11.10 + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..20487ac --- /dev/null +++ b/turbo.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://turborepo.dev/schema.json", + "envMode": "loose", + "tasks": { + "build": { + "dependsOn": ["^build"], + "cache": false + }, + "typecheck": { + "cache": false + }, + "dev": { + "cache": false, + "persistent": true + }, + "preview": { + "cache": false, + "persistent": true + }, + "test": { + "cache": false + } + } +}