@react-consulting/rc-kit 0.14.0 → 0.14.1

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,35 @@ function legacyProject(): string {
52
52
  }
53
53
 
54
54
  describe("migrateToKitPackage", () => {
55
+ test("an app outside the workspaces is migrated without its own kit dependency", () => {
56
+ const root = writeTree(tempDir(), {
57
+ "package.json": {
58
+ name: "contoso-books",
59
+ devDependencies: { "@rc/kit": "link:../_rc-kit" },
60
+ },
61
+ "workers/jobs/package.json": {
62
+ name: "contoso-jobs",
63
+ scripts: {
64
+ "build:cloudflare":
65
+ "wrangler deploy --dry-run --define __RC_BUILD_SHA__:$(bun ../../scripts/build-commit-sha.ts) && bun ../../scripts/upload-sourcemaps.ts --app jobs --directory dist",
66
+ },
67
+ },
68
+ "rc.config.json":
69
+ '{ "project": "contoso-books", "kit": ">=0.10.0", "apps": { "web": { "path": "." }, "jobs": { "path": "workers/jobs" } } }\n',
70
+ })
71
+
72
+ migrateToKitPackage({ root, kitVersion: "0.13.0" })
73
+
74
+ const jobs = JSON.parse(
75
+ readFileSync(join(root, "workers/jobs/package.json"), "utf8")
76
+ )
77
+
78
+ expect(jobs.scripts["build:cloudflare"]).toBe(
79
+ "wrangler deploy --dry-run --define __RC_BUILD_SHA__:$(rc build:sha) && rc sentry:sourcemaps --app jobs --directory dist"
80
+ )
81
+ expect(jobs.devDependencies).toBeUndefined()
82
+ })
83
+
55
84
  test("a Wrangler build reads its commit from rc build:sha", () => {
56
85
  const root = writeTree(tempDir(), {
57
86
  "package.json": {
@@ -308,10 +308,28 @@ function appsByPath(root: string): Map<string, string> {
308
308
  )
309
309
  }
310
310
 
311
+ type ManifestDir = { dir: string; rel: string; installed: boolean }
312
+
313
+ // An app of rc.config.json outside the workspaces (a second Worker of a single-package project) runs from the root's install.
314
+ function manifestDirs(root: string): ManifestDir[] {
315
+ const workspaces = listWorkspaces(root).map((workspace) => ({
316
+ dir: workspace.dir,
317
+ rel: workspace.rel,
318
+ installed: true,
319
+ }))
320
+ const known = new Set(workspaces.map((workspace) => workspace.rel))
321
+ const outsideApps = [...appsByPath(root).keys()]
322
+ .filter((rel) => !known.has(rel) && rel !== "")
323
+ .map((rel) => ({ dir: join(root, rel), rel, installed: false }))
324
+ .filter((app) => existsSync(join(app.dir, "package.json")))
325
+
326
+ return [...workspaces, ...outsideApps]
327
+ }
328
+
311
329
  function migrateManifests(migration: Migration, spec: string): void {
312
330
  const apps = appsByPath(migration.root)
313
331
 
314
- for (const workspace of listWorkspaces(migration.root)) {
332
+ for (const workspace of manifestDirs(migration.root)) {
315
333
  const file = join(workspace.dir, "package.json")
316
334
  const before = readFileSync(file, "utf8")
317
335
  const pkg = JSON.parse(before) as Manifest
@@ -330,7 +348,7 @@ function migrateManifests(migration: Migration, spec: string): void {
330
348
  const dependencyNotes = rewriteDependencies(
331
349
  pkg,
332
350
  spec,
333
- workspace.rel !== "." && usesRc(pkg)
351
+ workspace.installed && workspace.rel !== "." && usesRc(pkg)
334
352
  )
335
353
  const notes = [...dependencyNotes, ...catalogNotes, ...scriptNotes]
336
354
 
@@ -508,7 +526,7 @@ function migratedText(file: string): string {
508
526
  function referencingFiles(root: string): string[] {
509
527
  return [
510
528
  ...sourceFiles(root),
511
- ...listWorkspaces(root).map((workspace) =>
529
+ ...manifestDirs(root).map((workspace) =>
512
530
  join(workspace.dir, "package.json")
513
531
  ),
514
532
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-consulting/rc-kit",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
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": {