@stealthscale/tool-cli 0.1.0 → 0.1.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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as stealth } from "../cli-DC07sdDR.mjs";
2
+ import { n as stealth } from "../cli-DLoqOFRh.mjs";
3
3
  import { runMain } from "citty";
4
4
  //#region src/bin/stealth.ts
5
5
  /**
@@ -31,7 +31,7 @@ const stealth = defineCommand({
31
31
  *
32
32
  * @returns {Promise<CommandDef>} The release command.
33
33
  */
34
- release: () => import("./command-DHNo5e1V.mjs").then((module) => module.releaseCommand) }
34
+ release: () => import("./command-D_fTql-P.mjs").then((module) => module.releaseCommand) }
35
35
  });
36
36
  //#endregion
37
37
  export { stealth as n, commandMeta as t };
@@ -278,20 +278,24 @@ function shell() {
278
278
  };
279
279
  }
280
280
  //#endregion
281
- //#region src/release/ranges.ts
281
+ //#region src/release/published.ts
282
282
  /**
283
- * @fileoverview Writes the range a published manifest carries where the workspace wrote the
284
- * `workspace:` protocol.
283
+ * @fileoverview Turns the manifest a contributor works against into the one that ships.
285
284
  *
286
- * Bun rewrites the protocol itself, but it takes the version from the lockfile, and nothing
287
- * updates the version a lockfile records for a workspace package: `changeset version` writes
288
- * the manifests alone, and `bun install`, `--force` and `--lockfile-only` all answer "no
289
- * changes". So bun ships the version from before the bump. A theme released at 0.1.0 asked
290
- * for `core-theme@^0.0.0`, and a caret on a `0.0.x` version excludes every later one, so no
291
- * consumer could install it.
285
+ * The workspace manifest names the source: `exports` carries the repository's own condition
286
+ * so a package resolves to `src` for whoever asks for it, and `bin` names the file a
287
+ * contributor edits. That is the point of the condition and it stays. None of it can ship,
288
+ * because no tarball carries `src`, and Node cannot execute TypeScript.
292
289
  *
293
- * The release knows every version it is publishing, because it read the manifests to decide
294
- * what to publish. It writes the ranges from those rather than trusting the lockfile.
290
+ * The built form of both is already written, under `publishConfig`, where tsdown puts it. It
291
+ * is a pnpm convention and pnpm applies it at pack time; npm and bun do not, and those are
292
+ * what pack and publish here, so the first release shipped the working manifest. A `bin`
293
+ * naming `src/bin/stealth.ts` cannot run under `npx`, and every `exports` named a directory
294
+ * the tarball does not hold.
295
+ *
296
+ * So the release applies it. This is the one place the two forms meet, and it is the same
297
+ * place the `workspace:` protocol is resolved, for the same reason: the release knows what it
298
+ * is publishing and the manifest on disk describes something else.
295
299
  */
296
300
  /**
297
301
  * Names the blocks a manifest declares dependencies in.
@@ -303,6 +307,18 @@ const DEPENDENCY_BLOCKS = [
303
307
  "peerDependencies"
304
308
  ];
305
309
  /**
310
+ * Names what `publishConfig` holds for npm rather than for the manifest.
311
+ *
312
+ * Npm reads these off the tarball when it publishes, so they stay where they are. Everything
313
+ * else in the block is a field npm expects to find at the top level.
314
+ */
315
+ const PUBLISH_DIRECTIVES = /* @__PURE__ */ new Set([
316
+ "access",
317
+ "provenance",
318
+ "registry",
319
+ "tag"
320
+ ]);
321
+ /**
306
322
  * Reads the workspace protocol and the range written after it.
307
323
  */
308
324
  const WORKSPACE = /^workspace:(?<written>.*)$/u;
@@ -323,6 +339,24 @@ function rangeFor(written, version) {
323
339
  return written;
324
340
  }
325
341
  /**
342
+ * Lays every field `publishConfig` overrides over the manifest.
343
+ *
344
+ * The block itself stays, because npm reads `access` out of the tarball to decide whether the
345
+ * package is public, and a field it keeps for npm is not a field the manifest wants.
346
+ *
347
+ * @param {Declared} declared - The manifest, as it is written on disk.
348
+ * @returns {Declared} The manifest, with the published form of every field it overrides.
349
+ */
350
+ function overridden(declared) {
351
+ const config = declared["publishConfig"];
352
+ if (typeof config !== "object" || config === null) return { ...declared };
353
+ const fields = Object.entries(config).filter(([field]) => !PUBLISH_DIRECTIVES.has(field));
354
+ return {
355
+ ...declared,
356
+ ...Object.fromEntries(fields)
357
+ };
358
+ }
359
+ /**
326
360
  * Rewrites every workspace protocol in one manifest against the versions being published.
327
361
  *
328
362
  * A dependency the workspace does not hold is left as it was written, because inventing a
@@ -348,6 +382,18 @@ function resolvedRanges(declared, versions) {
348
382
  }
349
383
  return rewritten;
350
384
  }
385
+ /**
386
+ * Builds the manifest a tarball carries from the one the workspace works against.
387
+ *
388
+ * @param {Declared} declared - The manifest, as it is written on disk.
389
+ * @param {ReadonlyMap<string, string>} versions - Each workspace package mapped to the
390
+ * version it is being published at.
391
+ * @returns {Declared} The manifest to pack: the published form of every overridden field,
392
+ * and a real range wherever the workspace protocol was.
393
+ */
394
+ function publishedManifest(declared, versions) {
395
+ return resolvedRanges(overridden(declared), versions);
396
+ }
351
397
  //#endregion
352
398
  //#region src/release/packages.ts
353
399
  /**
@@ -397,26 +443,26 @@ function declaredIn(text) {
397
443
  return Object.fromEntries(Object.entries({ ...parsed }));
398
444
  }
399
445
  /**
400
- * Runs one step with the package's manifest holding real ranges instead of the workspace
401
- * protocol, and writes back what was there however the step ended.
446
+ * Runs one step with the package's manifest in the form that ships, and writes back what was
447
+ * there however the step ended.
402
448
  *
403
- * The manifest is written rather than the tarball patched, because bun packs what is on
404
- * disk: with no protocol left there is nothing for it to rewrite out of a stale lockfile.
449
+ * The manifest is written rather than the tarball patched, because bun packs what is on disk.
405
450
  * The original text goes back byte for byte, so a manifest a person formatted stays as they
406
- * wrote it. A caller naming no versions has nothing to write, and the file is left alone.
451
+ * wrote it, and the workspace keeps resolving a package to its source the moment the pack is
452
+ * over. A caller naming no versions has nothing to write, and the file is left alone.
407
453
  *
408
454
  * @template Result - The value the step answers with.
409
455
  * @param {Manifest} manifest - The package being packed.
410
456
  * @param {ReadonlyMap<string, string>} versions - Each workspace package mapped to the
411
457
  * version it is being published at.
412
- * @param {() => Promise<Result>} step - The work to run while the ranges are written.
458
+ * @param {() => Promise<Result>} step - The work to run while the published form is written.
413
459
  * @returns {Promise<Result>} The step's own answer, unchanged.
414
460
  */
415
461
  async function written(manifest, versions, step) {
416
462
  if (versions.size === 0) return step();
417
463
  const path = join(manifest.directory, "package.json");
418
464
  const before = readFileSync(path, "utf8");
419
- const after = resolvedRanges(declaredIn(before), versions);
465
+ const after = publishedManifest(declaredIn(before), versions);
420
466
  writeFileSync(path, `${JSON.stringify(after, void 0, 2)}\n`);
421
467
  try {
422
468
  return await step();
@@ -0,0 +1,2 @@
1
+ import { t as releaseCommand } from "./command-BIAObGRz.mjs";
2
+ export { releaseCommand };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as stealth, t as commandMeta } from "./cli-DC07sdDR.mjs";
2
- import { _ as tagEvent, a as configuredRegistry, c as missingFiles, d as shell, f as failed, g as render, h as passed, i as releaseSet, l as pack, m as lastLines, n as releaseCommandWith, o as registryHasVersion, p as failures, r as release, s as withTrailingSlash, t as releaseCommand, u as publishTarball, v as writeTagEvents } from "./command-wCHt33VW.mjs";
1
+ import { n as stealth, t as commandMeta } from "./cli-DLoqOFRh.mjs";
2
+ import { _ as tagEvent, a as configuredRegistry, c as missingFiles, d as shell, f as failed, g as render, h as passed, i as releaseSet, l as pack, m as lastLines, n as releaseCommandWith, o as registryHasVersion, p as failures, r as release, s as withTrailingSlash, t as releaseCommand, u as publishTarball, v as writeTagEvents } from "./command-BIAObGRz.mjs";
3
3
  export { commandMeta, configuredRegistry, failed, failures, lastLines, missingFiles, pack, passed, publishTarball, registryHasVersion, release, releaseCommand, releaseCommandWith, releaseSet, render, shell, stealth, tagEvent, withTrailingSlash, writeTagEvents };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stealthscale/tool-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Ships the stealth command, and publishes a workspace's public packages in dependency order.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  "directory": "tools/cli"
10
10
  },
11
11
  "bin": {
12
- "stealth": "./src/bin/stealth.ts"
12
+ "stealth": "./dist/bin/stealth.mjs"
13
13
  },
14
14
  "files": [
15
15
  "dist"
@@ -20,14 +20,8 @@
20
20
  "#*": "./src/*"
21
21
  },
22
22
  "exports": {
23
- ".": {
24
- "tooling-source": "./src/index.ts",
25
- "default": "./dist/index.mjs"
26
- },
27
- "./bin/stealth": {
28
- "tooling-source": "./src/bin/stealth.ts",
29
- "default": "./dist/bin/stealth.mjs"
30
- },
23
+ ".": "./dist/index.mjs",
24
+ "./bin/stealth": "./dist/bin/stealth.mjs",
31
25
  "./package.json": "./package.json"
32
26
  },
33
27
  "publishConfig": {
@@ -45,12 +39,12 @@
45
39
  "build": "vp pack src/index.ts src/bin/stealth.ts"
46
40
  },
47
41
  "dependencies": {
48
- "@stealthscale/core-schema": "^0.1.0",
49
- "@stealthscale/tool-workspace": "^0.1.0",
42
+ "@stealthscale/core-schema": "^0.1.1",
43
+ "@stealthscale/tool-workspace": "^0.1.1",
50
44
  "citty": "~0.2.2"
51
45
  },
52
46
  "devDependencies": {
53
- "@stealthscale/tool-config": "^0.1.0",
54
- "@stealthscale/tool-testing": "^0.1.0"
47
+ "@stealthscale/tool-config": "^0.1.1",
48
+ "@stealthscale/tool-testing": "^0.1.1"
55
49
  }
56
50
  }
@@ -1,2 +0,0 @@
1
- import { t as releaseCommand } from "./command-wCHt33VW.mjs";
2
- export { releaseCommand };
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @fileoverview The `stealth` bin. It hands the command to citty and does nothing else, so
4
- * everything worth a specification lives beside it rather than in an entry a build rewrites.
5
- */
6
-
7
- import { runMain } from 'citty'
8
-
9
- import { stealth } from '#cli.ts'
10
-
11
- await runMain(stealth)