@react-consulting/rc-kit 0.13.0 → 0.13.2
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/README.md +3 -4
- package/devkit/README.md +2 -2
- package/devkit/lib/kit-migrate.test.ts +18 -0
- package/devkit/lib/kit-migrate.ts +19 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,10 +84,9 @@ Le paquet `@react-consulting/rc-kit` se publie depuis `main` par `.github/workfl
|
|
|
84
84
|
|
|
85
85
|
Mise en place, une fois :
|
|
86
86
|
|
|
87
|
-
1.
|
|
88
|
-
2.
|
|
89
|
-
3.
|
|
90
|
-
4. Variable de dépôt `KIT_RELEASE_ENABLED` = `true`.
|
|
87
|
+
1. Sur npmjs.com, paquet → Settings → Trusted publishing → GitHub Actions : ce dépôt, workflow `release.yml`. Le workflow publie par OIDC (`id-token: write`), sans jeton npm dans les secrets. npm n'accepte un trusted publisher que sur un paquet qui existe : un nouveau nom se publie une première fois à la main (`npm publish` avec un compte membre de l'organisation).
|
|
88
|
+
2. Repère de version : un tag `v<version>` existe sur le commit qui porte cette version, pour que semantic-release ne reparte pas de 1.0.0.
|
|
89
|
+
3. Variable de dépôt `KIT_RELEASE_ENABLED` = `true`.
|
|
91
90
|
|
|
92
91
|
## CI et déploiement
|
|
93
92
|
|
package/devkit/README.md
CHANGED
|
@@ -208,10 +208,10 @@ Fait passer un projet de l'ancien clone voisin (`"@rc/kit": "link:../_rc-kit"`)
|
|
|
208
208
|
- `@rc/kit` devient `@react-consulting/rc-kit@^<version du kit>` dans chaque `package.json` (catalog compris), et les apps dont les scripts lancent `rc` le déclarent aussi ;
|
|
209
209
|
- imports `@rc/kit/*` → `@react-consulting/rc-kit/*` (le registre de composants `@rc/<nom>` ne change pas), import des règles de `CLAUDE.md` / `AGENTS.md`, `$schema` et clé `kit` de `rc.config.json` (commentaires gardés) ;
|
|
210
210
|
- `scripts/ensure-rc-kit.ts` et les hooks `preinstall` / `postinstall` qui le lancent sont retirés ;
|
|
211
|
-
- `bun ../../scripts/on-workers-ci.ts` → `rc ci:only`, `bun ../../scripts/upload-sourcemaps.ts` → `rc sentry:sourcemaps`, imports de `scripts/build-commit-sha` et `scripts/deployed-public-env` → `@react-consulting/rc-kit/build`, `rc op:sync` → `rc secrets:pull` (le script `op:sync` devient `secrets:pull
|
|
211
|
+
- `bun ../../scripts/on-workers-ci.ts` → `rc ci:only`, `bun ../../scripts/upload-sourcemaps.ts` → `rc sentry:sourcemaps`, imports de `scripts/build-commit-sha` et `scripts/deployed-public-env` → `@react-consulting/rc-kit/build`, `rc op:sync` → `rc secrets:pull` (le script `op:sync` devient `secrets:pull`, y compris quand un script TypeScript le lance) ; chaque ancien script est supprimé quand plus rien ne s'en sert, sinon signalé ;
|
|
212
212
|
- `--project <projet Sentry>` passe à `--app <app>` (l'app de `rc.config.json` dont `path` est le dossier du workspace) ; si `rc.config.json` n'a pas de clé `sentry`, elle est créée avec ces projets et l'organisation lue dans l'ancien `upload-sourcemaps.ts`.
|
|
213
213
|
|
|
214
|
-
Les dossiers cachés (`.worktrees`…) et les dépôts git imbriqués ne sont pas parcourus. Les workflows GitHub qui clonent encore le kit, la documentation qui
|
|
214
|
+
Les dossiers cachés (`.worktrees`…) et les dépôts git imbriqués ne sont pas parcourus. Les workflows et actions GitHub (`.github/**/*.yml`) qui clonent encore le kit, la documentation et les fichiers `*.example` qui décrivent encore l'ancien montage et les réglages Workers Builds sont signalés, pas modifiés. `--dry-run` liste les changements sans écrire. Relancer la commande ne change plus rien.
|
|
215
215
|
|
|
216
216
|
### `rc new <dossier> --name <slug> --prefix <pfx> --account <entité> --account-id <id> [--sentry-org <org>] [--no-install]`
|
|
217
217
|
|
|
@@ -178,6 +178,10 @@ describe("migrateToKitPackage", () => {
|
|
|
178
178
|
"scripts/upload-sourcemaps.ts":
|
|
179
179
|
'const SENTRY_ORG = process.env.SENTRY_ORG ?? "contoso-org"\n',
|
|
180
180
|
".worktrees/kit/src/a.ts": 'import "@rc/kit"\n',
|
|
181
|
+
".github/actions/setup/action.yml": " path: .rc-kit\n",
|
|
182
|
+
".env.example": "# secrets lus par rc op:sync\n",
|
|
183
|
+
"scripts/dev/boot.ts":
|
|
184
|
+
'spawnSync(rc, ["op:sync"])\nconsole.warn("rc op:sync a échoué")\n',
|
|
181
185
|
"vendor/other/.git": "gitdir: elsewhere\n",
|
|
182
186
|
"vendor/other/b.ts": 'import "@rc/kit"\n',
|
|
183
187
|
"rc.config.json":
|
|
@@ -197,11 +201,25 @@ describe("migrateToKitPackage", () => {
|
|
|
197
201
|
expect(json("apps/tools/package.json").scripts.build).toContain(
|
|
198
202
|
"--project ctz-tools"
|
|
199
203
|
)
|
|
204
|
+
expect(
|
|
205
|
+
result.changes.find((change) => change.file === "package.json")?.detail
|
|
206
|
+
).not.toContain("script op:sync,")
|
|
200
207
|
expect(json("rc.config.json").sentry).toEqual({
|
|
201
208
|
org: "contoso-org",
|
|
202
209
|
projects: { api: "ctz-api" },
|
|
203
210
|
})
|
|
204
211
|
expect(result.manual.some((line) => line.includes("ctz-tools"))).toBe(true)
|
|
212
|
+
expect(
|
|
213
|
+
result.manual.some((line) =>
|
|
214
|
+
line.startsWith(".github/actions/setup/action.yml")
|
|
215
|
+
)
|
|
216
|
+
).toBe(true)
|
|
217
|
+
expect(result.manual.some((line) => line.includes(".env.example"))).toBe(
|
|
218
|
+
true
|
|
219
|
+
)
|
|
220
|
+
expect(readFileSync(join(root, "scripts/dev/boot.ts"), "utf8")).toBe(
|
|
221
|
+
'spawnSync(rc, ["secrets:pull"])\nconsole.warn("rc secrets:pull a échoué")\n'
|
|
222
|
+
)
|
|
205
223
|
expect(result.changes.map((change) => change.file)).not.toContain(
|
|
206
224
|
".worktrees/kit/src/a.ts"
|
|
207
225
|
)
|
|
@@ -54,7 +54,7 @@ const SCRIPT_REWRITES: [RegExp, string][] = [
|
|
|
54
54
|
const BUILD_IMPORT_RE =
|
|
55
55
|
/(["'])(?:\.\.?\/)+scripts\/(?:build-commit-sha|deployed-public-env)(?:\.ts)?\1/g
|
|
56
56
|
const SOURCE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|astro|vue|svelte)$/
|
|
57
|
-
const DOC_EXTENSIONS = /\.mdx
|
|
57
|
+
const DOC_EXTENSIONS = /\.mdx?$|\.example$/
|
|
58
58
|
const STALE_DOC_RE =
|
|
59
59
|
/_rc-kit|@rc\/kit(?![\w-])|ensure-rc-kit|\bop:sync\b|upload-sourcemaps|on-workers-ci/
|
|
60
60
|
const SKIPPED_DIRS = new Set([
|
|
@@ -77,6 +77,8 @@ const DEPENDENCY_FIELDS = [
|
|
|
77
77
|
|
|
78
78
|
const LEGACY_SECRETS_SCRIPT = "op:sync"
|
|
79
79
|
const SECRETS_SCRIPT = "secrets:pull"
|
|
80
|
+
const LEGACY_SECRETS_LITERAL_RE = /(["'`])op:sync\1/g
|
|
81
|
+
const LEGACY_SECRETS_COMMAND_RE = /\brc op:sync\b/g
|
|
80
82
|
const SOURCEMAPS_PROJECT_RE = /rc sentry:sourcemaps --project (\S+)/g
|
|
81
83
|
const LEGACY_SENTRY_ORG_RE = /SENTRY_ORG\s*\?\?\s*["']([^"']+)["']/
|
|
82
84
|
|
|
@@ -269,9 +271,16 @@ function rewriteScripts(
|
|
|
269
271
|
}
|
|
270
272
|
|
|
271
273
|
sentryProjectsToApps(migration, scripts, app)
|
|
272
|
-
|
|
274
|
+
const renamed = renameSecretsScript(scripts)
|
|
273
275
|
|
|
274
|
-
|
|
276
|
+
if (renamed.length === 0) {
|
|
277
|
+
return notes
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return [
|
|
281
|
+
...notes.filter((note) => note !== `script ${LEGACY_SECRETS_SCRIPT}`),
|
|
282
|
+
...renamed,
|
|
283
|
+
]
|
|
275
284
|
}
|
|
276
285
|
|
|
277
286
|
function usesRc(pkg: Manifest): boolean {
|
|
@@ -344,9 +353,11 @@ function migrateSources(migration: Migration): void {
|
|
|
344
353
|
const next = text
|
|
345
354
|
.replace(LEGACY_IMPORT_RE, KIT_PACKAGE)
|
|
346
355
|
.replace(BUILD_IMPORT_RE, `$1${KIT_PACKAGE}/build$1`)
|
|
356
|
+
.replace(LEGACY_SECRETS_LITERAL_RE, `$1${SECRETS_SCRIPT}$1`)
|
|
357
|
+
.replace(LEGACY_SECRETS_COMMAND_RE, `rc ${SECRETS_SCRIPT}`)
|
|
347
358
|
|
|
348
359
|
if (next !== text) {
|
|
349
|
-
migration.write(file, next, `imports vers ${KIT_PACKAGE}`)
|
|
360
|
+
migration.write(file, next, `imports et appels vers ${KIT_PACKAGE}`)
|
|
350
361
|
}
|
|
351
362
|
}
|
|
352
363
|
}
|
|
@@ -579,18 +590,18 @@ function reportDocs(migration: Migration): void {
|
|
|
579
590
|
}
|
|
580
591
|
|
|
581
592
|
function reportWorkflows(migration: Migration): void {
|
|
582
|
-
const dir = join(migration.root, ".github"
|
|
593
|
+
const dir = join(migration.root, ".github")
|
|
583
594
|
|
|
584
595
|
if (!existsSync(dir)) {
|
|
585
596
|
return
|
|
586
597
|
}
|
|
587
598
|
|
|
588
|
-
for (const
|
|
589
|
-
const text = readFileSync(
|
|
599
|
+
for (const file of sourceFiles(dir, /\.ya?ml$/)) {
|
|
600
|
+
const text = readFileSync(file, "utf8")
|
|
590
601
|
|
|
591
602
|
if (/_rc-kit|\.rc-kit|RC_KIT_TOKEN|repository:\s*\S+\/rc-kit/.test(text)) {
|
|
592
603
|
migration.manual.push(
|
|
593
|
-
|
|
604
|
+
`${migration.rel(file)} : retire le checkout du kit, son déplacement et « bun install --cwd ../_rc-kit » ; reprends template/.github/workflows/ci.yml du kit.`
|
|
594
605
|
)
|
|
595
606
|
}
|
|
596
607
|
}
|