@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.
- package/dist/bin/stealth.mjs +1 -1
- package/dist/{cli-DC07sdDR.mjs → cli-DLoqOFRh.mjs} +1 -1
- package/dist/{command-wCHt33VW.mjs → command-BIAObGRz.mjs} +64 -18
- package/dist/command-D_fTql-P.mjs +2 -0
- package/dist/index.mjs +2 -2
- package/package.json +8 -14
- package/dist/command-DHNo5e1V.mjs +0 -2
- package/src/bin/stealth.ts +0 -11
package/dist/bin/stealth.mjs
CHANGED
|
@@ -31,7 +31,7 @@ const stealth = defineCommand({
|
|
|
31
31
|
*
|
|
32
32
|
* @returns {Promise<CommandDef>} The release command.
|
|
33
33
|
*/
|
|
34
|
-
release: () => import("./command-
|
|
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/
|
|
281
|
+
//#region src/release/published.ts
|
|
282
282
|
/**
|
|
283
|
-
* @fileoverview
|
|
284
|
-
* `workspace:` protocol.
|
|
283
|
+
* @fileoverview Turns the manifest a contributor works against into the one that ships.
|
|
285
284
|
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* the
|
|
289
|
-
*
|
|
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
|
|
294
|
-
*
|
|
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
|
|
401
|
-
*
|
|
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
|
|
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
|
|
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 =
|
|
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();
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as stealth, t as commandMeta } from "./cli-
|
|
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-
|
|
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.
|
|
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": "./
|
|
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
|
-
|
|
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.
|
|
49
|
-
"@stealthscale/tool-workspace": "^0.1.
|
|
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.
|
|
54
|
-
"@stealthscale/tool-testing": "^0.1.
|
|
47
|
+
"@stealthscale/tool-config": "^0.1.1",
|
|
48
|
+
"@stealthscale/tool-testing": "^0.1.1"
|
|
55
49
|
}
|
|
56
50
|
}
|
package/src/bin/stealth.ts
DELETED
|
@@ -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)
|