@react-consulting/rc-kit 0.14.1 → 0.14.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.
@@ -52,6 +52,42 @@ function legacyProject(): string {
52
52
  }
53
53
 
54
54
  describe("migrateToKitPackage", () => {
55
+ test("a script only named in ignore lists is removed, with its entries", () => {
56
+ const root = writeTree(tempDir(), {
57
+ "package.json": {
58
+ name: "contoso-site",
59
+ devDependencies: { "@rc/kit": "link:../_rc-kit" },
60
+ },
61
+ "biome.jsonc":
62
+ '{\n "files": {\n "includes": [\n "**",\n "!scripts/ensure-rc-kit.ts",\n "!scripts/on-workers-ci.ts"\n ]\n }\n}\n',
63
+ "tsconfig.json":
64
+ '{\n "exclude": [\n "dist",\n "scripts/upload-sourcemaps.ts"\n ]\n}\n',
65
+ "rc.config.json": '{ "project": "contoso-site", "kit": ">=0.10.0" }\n',
66
+ "scripts/ensure-rc-kit.ts": "",
67
+ "scripts/on-workers-ci.ts": "",
68
+ "scripts/upload-sourcemaps.ts":
69
+ 'import { resolveBuildCommitSha } from "./build-commit-sha"\n',
70
+ "scripts/build-commit-sha.ts": "",
71
+ })
72
+
73
+ migrateToKitPackage({ root, kitVersion: "0.13.0" })
74
+
75
+ for (const script of [
76
+ "on-workers-ci",
77
+ "upload-sourcemaps",
78
+ "build-commit-sha",
79
+ ]) {
80
+ expect(existsSync(join(root, `scripts/${script}.ts`))).toBe(false)
81
+ }
82
+
83
+ expect(readFileSync(join(root, "biome.jsonc"), "utf8")).toBe(
84
+ '{\n "files": {\n "includes": [\n "**"\n ]\n }\n}\n'
85
+ )
86
+ expect(readFileSync(join(root, "tsconfig.json"), "utf8")).toBe(
87
+ '{\n "exclude": [\n "dist"\n ]\n}\n'
88
+ )
89
+ })
90
+
55
91
  test("an app outside the workspaces is migrated without its own kit dependency", () => {
56
92
  const root = writeTree(tempDir(), {
57
93
  "package.json": {
@@ -54,6 +54,8 @@ const SCRIPT_REWRITES: [RegExp, string][] = [
54
54
  ]
55
55
  const BUILD_IMPORT_RE =
56
56
  /(["'])(?:\.\.?\/)+scripts\/(?:build-commit-sha|deployed-public-env)(?:\.ts)?\1/g
57
+ const TOOL_CONFIGS = ["biome.json", "biome.jsonc", "tsconfig.json"]
58
+ const TOOL_IGNORE_ENTRY_RE = /"!(?:\.\/)?scripts\/[^"]+"/g
57
59
  const SOURCE_EXTENSIONS = /\.(?:[cm]?[jt]sx?|astro|vue|svelte|jsonc)$/
58
60
  const DOC_EXTENSIONS = /\.mdx?$|\.example$/
59
61
  const STALE_DOC_RE =
@@ -538,7 +540,7 @@ function stillUsedScripts(
538
540
  ): Set<string> {
539
541
  const texts = referencingFiles(migration.root).map((file) => ({
540
542
  rel: migration.rel(file),
541
- text: migratedText(file),
543
+ text: migratedText(file).replace(TOOL_IGNORE_ENTRY_RE, ""),
542
544
  }))
543
545
  const kept = new Set<string>()
544
546
  let changed = true
@@ -592,6 +594,43 @@ function removeLegacyScripts(migration: Migration): void {
592
594
  migration.remove(join(migration.root, script), replaced[script] ?? "")
593
595
  }
594
596
  }
597
+
598
+ const removed = [
599
+ LEGACY_SCRIPTS.bootstrap,
600
+ ...candidates.filter((script) => !kept.has(script)),
601
+ ]
602
+
603
+ dropToolEntries(migration, removed)
604
+ }
605
+
606
+ // Lint and TypeScript configs list the old scripts in their ignore lists: an entry for a removed file is dropped.
607
+ function dropToolEntries(migration: Migration, scripts: string[]): void {
608
+ for (const name of TOOL_CONFIGS) {
609
+ const file = join(migration.root, name)
610
+
611
+ if (!existsSync(file)) {
612
+ continue
613
+ }
614
+
615
+ const text = readFileSync(file, "utf8")
616
+ const next = text
617
+ .split("\n")
618
+ .filter((line) => {
619
+ const entry = line.trim().match(/^"!?(?:\.\/)?([^"]+)",?$/)?.[1]
620
+
621
+ return !entry || !scripts.includes(entry)
622
+ })
623
+ .join("\n")
624
+ .replace(/,(\s*\n\s*[\]}])/g, "$1")
625
+
626
+ if (next !== text) {
627
+ migration.write(
628
+ file,
629
+ next,
630
+ "anciens scripts retirés des listes d'exclusion"
631
+ )
632
+ }
633
+ }
595
634
  }
596
635
 
597
636
  function reportDocs(migration: Migration): void {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-consulting/rc-kit",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
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": {