@react-consulting/rc-kit 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/devkit/cli.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import { resolve } from "node:path"
3
3
 
4
- import { ciOnly, sentrySourcemaps } from "./commands/build"
4
+ import { buildSha, ciOnly, sentrySourcemaps } from "./commands/build"
5
5
  import { audit, checkDeployConfig, checkNaming } from "./commands/checks"
6
6
  import type { Command } from "./commands/context"
7
7
  import { dbBranch, dbEnv, dbGuard, dbMigrate, dbSeed } from "./commands/db"
@@ -25,6 +25,7 @@ const COMMANDS: Record<string, Command> = {
25
25
  "db:guard": dbGuard,
26
26
  "db:branch": dbBranch,
27
27
  deploy,
28
+ "build:sha": buildSha,
28
29
  "ci:only": ciOnly,
29
30
  "sentry:sourcemaps": sentrySourcemaps,
30
31
  dev,
@@ -20,6 +20,19 @@ function sentryCli(root: string): string | null {
20
20
  return Bun.which("sentry-cli", { PATH: bins.join(delimiter) })
21
21
  }
22
22
 
23
+ export const buildSha: Command = {
24
+ usage: "rc build:sha",
25
+ summary:
26
+ "écrit le commit du build en JSON, pour --define d'un build Wrangler",
27
+ details:
28
+ "Écrit WORKERS_CI_COMMIT_SHA, sinon le commit git du dossier courant, en littéral JSON (null hors dépôt). Usage : wrangler deploy --dry-run --define __RC_BUILD_SHA__:$(rc build:sha). Un build Vite lit plutôt resolveBuildCommitSha() de @react-consulting/rc-kit/build.",
29
+ cwdRoot: true,
30
+ run() {
31
+ process.stdout.write(JSON.stringify(resolveBuildCommitSha()))
32
+ return 0
33
+ },
34
+ }
35
+
23
36
  export const ciOnly: Command = {
24
37
  usage: "rc ci:only <script> [arguments…]",
25
38
  summary: "lance un script du package.json seulement dans Workers Builds",
@@ -52,6 +52,30 @@ function legacyProject(): string {
52
52
  }
53
53
 
54
54
  describe("migrateToKitPackage", () => {
55
+ test("a Wrangler build reads its commit from rc build:sha", () => {
56
+ const root = writeTree(tempDir(), {
57
+ "package.json": {
58
+ name: "contoso-api",
59
+ scripts: {
60
+ "build:cloudflare":
61
+ "wrangler deploy --dry-run --define __RC_BUILD_SHA__:$(bun scripts/lib/build-commit-sha.ts)",
62
+ },
63
+ devDependencies: { "@rc/kit": "link:../_rc-kit" },
64
+ },
65
+ "rc.config.json": '{ "project": "contoso-api", "kit": ">=0.10.0" }\n',
66
+ })
67
+
68
+ migrateToKitPackage({ root, kitVersion: "0.13.0" })
69
+
70
+ const manifest = JSON.parse(
71
+ readFileSync(join(root, "package.json"), "utf8")
72
+ )
73
+
74
+ expect(manifest.scripts["build:cloudflare"]).toBe(
75
+ "wrangler deploy --dry-run --define __RC_BUILD_SHA__:$(rc build:sha)"
76
+ )
77
+ })
78
+
55
79
  test("moves a project from the sibling clone to the npm package", () => {
56
80
  const root = legacyProject()
57
81
  const result = migrateToKitPackage({ root, kitVersion: "0.13.0" })
@@ -49,6 +49,7 @@ const LEGACY_SCRIPTS = {
49
49
  const SCRIPT_REWRITES: [RegExp, string][] = [
50
50
  [/bun (?:\.\.\/)*scripts\/on-workers-ci\.ts/g, "rc ci:only"],
51
51
  [/bun (?:\.\.\/)*scripts\/upload-sourcemaps\.ts/g, "rc sentry:sourcemaps"],
52
+ [/bun (?:\.\.\/)*scripts\/(?:lib\/)?build-commit-sha\.ts/g, "rc build:sha"],
52
53
  [/\brc op:sync\b/g, "rc secrets:pull"],
53
54
  ]
54
55
  const BUILD_IMPORT_RE =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-consulting/rc-kit",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "Règles, composants, CLI rc et modèle de départ pour des projets Cloudflare Workers en Bun",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,6 +8,6 @@
8
8
  - `anonymize` : rien d'identifiant ne part (compte, e-mail, IP, URL brute, query string, fil d'Ariane). Tags et contexte passent par liste blanche ; un projet l'étend par `allowlists`, jamais avec un identifiant.
9
9
  - Le projet garde une couche mince : `packages/shared/src/observability/server-errors.ts` (`withErrorTracking(service, handler)`, `reportServerError(error, context)`) et un `initErrorReporting({ dsn, front })` côté navigateur.
10
10
  - Variables publiques, dans les `vars` de `env.production` (vides au niveau local) : `SENTRY_DSN` (Worker), `SENTRY_TUNNEL_DSNS` (DSN de son front), `PUBLIC_SENTRY_DSN` (Astro) ou `VITE_SENTRY_DSN` (TanStack Start), injectées dans le bundle navigateur au build par `readDeployedPublicEnv` de `@react-consulting/rc-kit/build`, qui lit les `vars` de l'environnement Wrangler construit.
11
- - Release = commit du build : `resolveBuildCommitSha()` de `@react-consulting/rc-kit/build` (`WORKERS_CI_COMMIT_SHA`, sinon git) injecté en `__RC_BUILD_SHA__` (`define` Vite ou `--define` Wrangler).
11
+ - Release = commit du build : `resolveBuildCommitSha()` de `@react-consulting/rc-kit/build` (`WORKERS_CI_COMMIT_SHA`, sinon git) injecté en `__RC_BUILD_SHA__` (`define` Vite) ou `--define __RC_BUILD_SHA__:$(rc build:sha)` pour un build Wrangler ; aucun script local de commit.
12
12
  - Source maps : build en `sourcemap: "hidden"`, puis `rc sentry:sourcemaps --app <app> --directory <sortie> [--delete-maps]` à la fin de `build:cloudflare` (`--delete-maps` sur les assets publics). La commande lit `sentry` de `rc.config.json` ; dans Workers Builds elle échoue sans `SENTRY_AUTH_TOKEN` (voir `secrets.md`), en local elle saute l'envoi.
13
13
  - Alertes, membres et règles de regroupement se règlent dans Sentry, pas dans le dépôt.