@pellux/goodvibes-toolchain 1.11.0 → 1.11.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.
- package/dist/bin/publish-package.js +30 -2
- package/dist/bin/toolchain.d.ts +3 -0
- package/dist/bin/toolchain.d.ts.map +1 -0
- package/dist/bin/toolchain.js +47 -0
- package/dist/lib/publish-package.d.ts +10 -0
- package/dist/lib/publish-package.d.ts.map +1 -1
- package/dist/lib/publish-package.js +26 -0
- package/package.json +2 -1
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
4
|
import { loadToolchainConfig } from '../lib/load-config.js';
|
|
5
5
|
import { consoleLogger } from '../lib/effects.js';
|
|
6
6
|
import { runPublishPackage, pollPropagation } from '../lib/publish-package.js';
|
|
7
|
+
/** Read the value that follows a `--flag <value>` argument, or undefined when absent. */
|
|
8
|
+
function flagValue(flag) {
|
|
9
|
+
const index = process.argv.indexOf(flag);
|
|
10
|
+
if (index < 0)
|
|
11
|
+
return undefined;
|
|
12
|
+
return process.argv[index + 1];
|
|
13
|
+
}
|
|
7
14
|
const root = process.cwd();
|
|
8
15
|
const config = loadToolchainConfig(root);
|
|
9
16
|
if (!config.publish) {
|
|
@@ -13,7 +20,28 @@ if (!config.publish) {
|
|
|
13
20
|
const version = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')).version;
|
|
14
21
|
const dryRun = process.argv.includes('--dry-run');
|
|
15
22
|
const registry = process.env.GOODVIBES_PUBLISH_REGISTRY ?? config.publish.defaultRegistry;
|
|
16
|
-
|
|
23
|
+
// --tarball <path>: publish a prebuilt .tgz instead of packing cwd. Validate the
|
|
24
|
+
// flag value up front — a missing/empty path is a caller error (exit 2), kept
|
|
25
|
+
// distinct from a publish failure (exit 1) so a broken pack→publish handoff is
|
|
26
|
+
// unambiguous in CI logs.
|
|
27
|
+
const tarballPath = flagValue('--tarball');
|
|
28
|
+
if (process.argv.includes('--tarball') && (tarballPath === undefined || tarballPath.length === 0)) {
|
|
29
|
+
consoleLogger.error('publish-package: --tarball requires a file path');
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
if (tarballPath !== undefined && !existsSync(resolve(root, tarballPath))) {
|
|
33
|
+
consoleLogger.error(`publish-package: --tarball path does not exist: ${tarballPath}`);
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
const result = runPublishPackage({
|
|
37
|
+
cwd: root,
|
|
38
|
+
name: config.publish.packageName,
|
|
39
|
+
version,
|
|
40
|
+
registry,
|
|
41
|
+
dryRun,
|
|
42
|
+
...(tarballPath !== undefined ? { tarballPath } : {}),
|
|
43
|
+
logger: consoleLogger,
|
|
44
|
+
});
|
|
17
45
|
consoleLogger.info(`publish-package: ${result.detail}`);
|
|
18
46
|
if (!result.ok)
|
|
19
47
|
process.exit(1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolchain.d.ts","sourceRoot":"","sources":["../../src/bin/toolchain.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Dispatcher bin, named after the package itself (`goodvibes-toolchain`).
|
|
4
|
+
*
|
|
5
|
+
* `bunx @pellux/goodvibes-toolchain <tool> [flags]` resolves the bin whose
|
|
6
|
+
* name matches the package's final path segment. Without this dispatcher the
|
|
7
|
+
* package exposed only the eleven `goodvibes-*` tool bins, and bunx silently
|
|
8
|
+
* fell back to the FIRST bin in the map (sdk-pin-gate) with the intended tool
|
|
9
|
+
* name as a stray argument — crashing in workspaces without a toolchain
|
|
10
|
+
* config, and worse, "passing" while running the wrong tool in workspaces
|
|
11
|
+
* with one. Every tool stays directly invocable by its own bin name; this
|
|
12
|
+
* entry only adds the package-name route.
|
|
13
|
+
*
|
|
14
|
+
* The tool argument accepts both the bare tool name (`per-job-green`) and the
|
|
15
|
+
* bin-prefixed form (`goodvibes-per-job-green`) so existing invocation
|
|
16
|
+
* strings work unchanged.
|
|
17
|
+
*/
|
|
18
|
+
const TOOLS = {
|
|
19
|
+
'sdk-pin-gate': './sdk-pin-gate.js',
|
|
20
|
+
'build-binaries': './build-binaries.js',
|
|
21
|
+
'release-cut': './release-cut.js',
|
|
22
|
+
'coverage-gate': './coverage-gate.js',
|
|
23
|
+
'verification-ledger': './verification-ledger.js',
|
|
24
|
+
'post-build-smoke': './post-build-smoke.js',
|
|
25
|
+
'package-install-check': './package-install-check.js',
|
|
26
|
+
'publish-package': './publish-package.js',
|
|
27
|
+
'per-job-green': './per-job-green.js',
|
|
28
|
+
'changelog-gate': './changelog-gate.js',
|
|
29
|
+
'sha256sums': './sha256sums.js',
|
|
30
|
+
};
|
|
31
|
+
const [tool, ...rest] = process.argv.slice(2);
|
|
32
|
+
const key = tool?.replace(/^goodvibes-/, '') ?? '';
|
|
33
|
+
const target = TOOLS[key];
|
|
34
|
+
if (!target) {
|
|
35
|
+
const usage = [
|
|
36
|
+
`goodvibes-toolchain: ${tool ? `unknown tool '${tool}'` : 'a tool name is required'}.`,
|
|
37
|
+
'Usage: goodvibes-toolchain <tool> [flags]',
|
|
38
|
+
`Tools: ${Object.keys(TOOLS).join(', ')}`,
|
|
39
|
+
].join('\n');
|
|
40
|
+
console.error(usage);
|
|
41
|
+
process.exit(2);
|
|
42
|
+
}
|
|
43
|
+
// Tool bins read flags positionally from process.argv; splice the dispatcher
|
|
44
|
+
// hop out so their view is identical to a direct bin invocation.
|
|
45
|
+
process.argv = [process.argv[0], process.argv[1], ...rest];
|
|
46
|
+
await import(target);
|
|
47
|
+
export {};
|
|
@@ -15,7 +15,17 @@ export interface PublishOptions {
|
|
|
15
15
|
readonly version: string;
|
|
16
16
|
readonly registry?: string;
|
|
17
17
|
readonly dryRun?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* When set, publish this prebuilt tarball (`npm publish <tarballPath>`)
|
|
20
|
+
* instead of packing and publishing `cwd`. Used by repos whose npm bytes are
|
|
21
|
+
* produced by a separate pack job (e.g. the agent bundles a runtime before
|
|
22
|
+
* `bun pm pack`), so the publish must ship the staged .tgz rather than a bare
|
|
23
|
+
* checkout. The path must exist and be a readable `.tgz`.
|
|
24
|
+
*/
|
|
25
|
+
readonly tarballPath?: string;
|
|
18
26
|
readonly exec?: Exec;
|
|
27
|
+
/** File-existence seam (defaults to node `existsSync`) so tarball validation is testable. */
|
|
28
|
+
readonly fileExists?: (path: string) => boolean;
|
|
19
29
|
readonly logger?: Logger;
|
|
20
30
|
}
|
|
21
31
|
export interface PublishResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish-package.d.ts","sourceRoot":"","sources":["../../src/lib/publish-package.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"publish-package.d.ts","sourceRoot":"","sources":["../../src/lib/publish-package.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIxD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK9G;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,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ry
|
|
7
7
|
* actually serves the new version before downstream jobs depend on it.
|
|
8
8
|
*/
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
9
10
|
import { realExec, consoleLogger, realSleep } from './effects.js';
|
|
10
11
|
import { DEFAULT_REGISTRY } from '../config.js';
|
|
11
12
|
/** Query the published version of name@version; null when absent (or on error). */
|
|
@@ -21,6 +22,31 @@ export function runPublishPackage(options) {
|
|
|
21
22
|
const exec = options.exec ?? realExec;
|
|
22
23
|
const logger = options.logger ?? consoleLogger;
|
|
23
24
|
const registry = options.registry ?? DEFAULT_REGISTRY;
|
|
25
|
+
const fileExists = options.fileExists ?? existsSync;
|
|
26
|
+
const tarball = options.tarballPath;
|
|
27
|
+
if (tarball !== undefined) {
|
|
28
|
+
// Tarball mode: publish a prebuilt .tgz. Validate the flag value — the file
|
|
29
|
+
// must exist and be a `.tgz` — before doing anything with it. `npm pack
|
|
30
|
+
// --dry-run` is meaningless here (there is nothing to pack), so a dry run
|
|
31
|
+
// just confirms the staged tarball is present and readable.
|
|
32
|
+
if (!tarball.endsWith('.tgz') || !fileExists(tarball)) {
|
|
33
|
+
return { ok: false, skipped: false, detail: `tarball not found or not a .tgz: ${tarball}` };
|
|
34
|
+
}
|
|
35
|
+
if (options.dryRun) {
|
|
36
|
+
return { ok: true, skipped: false, detail: `dry-run: tarball present (${tarball})` };
|
|
37
|
+
}
|
|
38
|
+
const alreadyTarball = getPublishedVersion(exec, options.name, options.version, registry);
|
|
39
|
+
if (alreadyTarball === options.version) {
|
|
40
|
+
logger.info(`[publish-package] ${options.name}@${options.version} already published — skipping`);
|
|
41
|
+
return { ok: true, skipped: true, detail: 'already published' };
|
|
42
|
+
}
|
|
43
|
+
const res = exec('npm', ['publish', tarball, '--access', 'public', '--registry', registry], { cwd: options.cwd });
|
|
44
|
+
if (res.status !== 0) {
|
|
45
|
+
return { ok: false, skipped: false, detail: `npm publish failed: ${res.stderr.trim().slice(0, 400)}` };
|
|
46
|
+
}
|
|
47
|
+
logger.info(`[publish-package] published ${options.name}@${options.version} from ${tarball}`);
|
|
48
|
+
return { ok: true, skipped: false, detail: 'published' };
|
|
49
|
+
}
|
|
24
50
|
if (options.dryRun) {
|
|
25
51
|
const res = exec('npm', ['pack', '--json'], { cwd: options.cwd });
|
|
26
52
|
return { ok: res.status === 0, skipped: false, detail: res.status === 0 ? 'dry-run pack ok' : `dry-run pack failed: ${res.stderr.trim()}` };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-toolchain",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"engines": {
|
|
5
5
|
"bun": "1.3.10",
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
|
+
"goodvibes-toolchain": "./dist/bin/toolchain.js",
|
|
24
25
|
"goodvibes-sdk-pin-gate": "./dist/bin/sdk-pin-gate.js",
|
|
25
26
|
"goodvibes-build-binaries": "./dist/bin/build-binaries.js",
|
|
26
27
|
"goodvibes-release-cut": "./dist/bin/release-cut.js",
|