bun-nested-workspace 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -102,6 +102,7 @@ Exclude `node_modules` and other large directories from the build context with `
102
102
  An explicit list replaces the default trusted list of Bun, so when only one side defines the field, the packages of the other side lose the default list; list the ones whose lifecycle scripts they need.
103
103
  The sync warns when it adds the field to the host.
104
104
  - `patchedDependencies` paths are rewritten through the nested directory, such as `nested/patches/exceljs@4.4.0.patch`.
105
+ Bun warns on every install that it ignores `patchedDependencies` of the nested root package; keep them there, because the host applies the synced copies.
105
106
 
106
107
  A nested entry replaces a host entry with the same name, while the other host entries stay.
107
108
  The sync lists the host entries it replaced.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { a as syncNestedWorkspace, i as loadNestedWorkspace, n as checkNestedWorkspace, r as isInSync, t as BunInstallError, y as getErrorMessage } from "./workspace-DfVz3A2J.mjs";
2
+ import { a as syncNestedWorkspace, i as loadNestedWorkspace, n as checkNestedWorkspace, r as isInSync, t as BunInstallError, y as getErrorMessage } from "./workspace-BzA7ccrb.mjs";
3
3
  // src/cli.ts
4
4
  const usage = `Usage:
5
5
  bun-nested-workspace [bun install options] Sync package.json and bun.lock, then run bun install
package/dist/index.d.mts CHANGED
@@ -173,9 +173,12 @@ export declare function parseLockfile(text: string, source?: string): Lockfile;
173
173
  /**
174
174
  * Returns the nested lockfile with workspace and local paths relative to the host root.
175
175
  *
176
- * The nested root workspace moves to the nested directory, where it is a workspace of the host.
176
+ * The nested root workspace moves to the nested directory, where it is a workspace of the host,
177
+ * and takes `rootName`, the name of the nested root `package.json`, when it is given.
178
+ * Bun requires the name of a workspace package entry but keeps a root entry without the name
179
+ * when the name was added to `package.json` after the lockfile.
177
180
  */
178
- export declare function relocateLockfile(lock: Lockfile, dir: string): Lockfile;
181
+ export declare function relocateLockfile(lock: Lockfile, dir: string, rootName?: string): Lockfile;
179
182
  /**
180
183
  * Returns the lockfile with root fields that affect resolution taken from the root `package.json`.
181
184
  *
@@ -257,7 +260,7 @@ interface NestedWorkspace {
257
260
  manifestText: string;
258
261
  nestedManifest: PackageManifest;
259
262
  lock: Lockfile;
260
- /** Nested lockfile relocated with `relocateLockfile`. */
263
+ /** Nested lockfile relocated with `relocateLockfile`, with the root name of `nestedManifest`. */
261
264
  nestedLock: Lockfile;
262
265
  }
263
266
  /** Loads the root `package.json` and `bun.lock` files of the host and of the nested checkout. */
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as BunInstallError, d as applyManifestToLockfile, n as checkNestedWorkspace, g as diffManifests, o as findDirectDependencyMismatches, s as findOwnDependencyChanges, c as findTransitiveMismatches, l as findUncoveredWorkspaces, u as findWorkspaceMismatches, r as isInSync, i as loadNestedWorkspace, f as mergeLockfiles, p as parseLockfile, m as relocateLockfile, h as supportedLockfileVersions, _ as syncManifest, a as syncNestedWorkspace, v as syncedFields } from "./workspace-DfVz3A2J.mjs";
1
+ export { t as BunInstallError, d as applyManifestToLockfile, n as checkNestedWorkspace, g as diffManifests, o as findDirectDependencyMismatches, s as findOwnDependencyChanges, c as findTransitiveMismatches, l as findUncoveredWorkspaces, u as findWorkspaceMismatches, r as isInSync, i as loadNestedWorkspace, f as mergeLockfiles, p as parseLockfile, m as relocateLockfile, h as supportedLockfileVersions, _ as syncManifest, a as syncNestedWorkspace, v as syncedFields } from "./workspace-BzA7ccrb.mjs";
@@ -506,12 +506,18 @@ async function readLockfile(file) {
506
506
  /**
507
507
  * Returns the nested lockfile with workspace and local paths relative to the host root.
508
508
  *
509
- * The nested root workspace moves to the nested directory, where it is a workspace of the host.
509
+ * The nested root workspace moves to the nested directory, where it is a workspace of the host,
510
+ * and takes `rootName`, the name of the nested root `package.json`, when it is given.
511
+ * Bun requires the name of a workspace package entry but keeps a root entry without the name
512
+ * when the name was added to `package.json` after the lockfile.
510
513
  */
511
- function relocateLockfile(lock, dir) {
514
+ function relocateLockfile(lock, dir, rootName) {
512
515
  return {
513
516
  ...lock,
514
- workspaces: Object.fromEntries(Object.entries(lock.workspaces).map(([workspacePath, workspace]) => [path.posix.join(dir, workspacePath), workspace])),
517
+ workspaces: Object.fromEntries(Object.entries(lock.workspaces).map(([workspacePath, workspace]) => [path.posix.join(dir, workspacePath), workspacePath === "" && rootName !== void 0 ? {
518
+ ...workspace,
519
+ name: rootName
520
+ } : workspace])),
515
521
  packages: Object.fromEntries(Object.entries(lock.packages).map(([key, [resolution, ...rest]]) => [key, [relocateResolution(resolution, dir), ...rest]]))
516
522
  };
517
523
  }
@@ -815,14 +821,15 @@ async function loadNestedWorkspace(root) {
815
821
  const manifest = JSON.parse(manifestText);
816
822
  const config = readConfig(manifest);
817
823
  const nestedRoot = path.join(root, config.dir);
824
+ const nestedManifest = await Bun.file(path.join(nestedRoot, "package.json")).json();
818
825
  return {
819
826
  root,
820
827
  config,
821
828
  manifest,
822
829
  manifestText,
823
- nestedManifest: await Bun.file(path.join(nestedRoot, "package.json")).json(),
830
+ nestedManifest,
824
831
  lock: await readLockfile(path.join(root, "bun.lock")),
825
- nestedLock: relocateLockfile(await readLockfile(path.join(nestedRoot, "bun.lock")), config.dir)
832
+ nestedLock: relocateLockfile(await readLockfile(path.join(nestedRoot, "bun.lock")), config.dir, typeof nestedManifest.name === "string" ? nestedManifest.name : void 0)
826
833
  };
827
834
  }
828
835
  /** Returns whether a check found no differences. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-nested-workspace",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Embed a checkout of another Bun workspace repository into a Bun workspace and keep the root package.json and bun.lock in sync with it",
5
5
  "keywords": [
6
6
  "bun",