@packtory/cli 0.0.7 → 0.0.9
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/command-line-interface/config-loader.js +7 -5
- package/command-line-interface/config-loader.js.map +1 -1
- package/command-line-interface/one-time-password-prompt.js +29 -0
- package/command-line-interface/one-time-password-prompt.js.map +1 -0
- package/command-line-interface/preview-io-shared.js +75 -0
- package/command-line-interface/preview-io-shared.js.map +1 -0
- package/command-line-interface/preview-io.js +15 -0
- package/command-line-interface/preview-io.js.map +1 -0
- package/command-line-interface/runner.js +211 -76
- package/command-line-interface/runner.js.map +1 -1
- package/command-line-interface/spinner-boot.entry-point.js +25 -0
- package/command-line-interface/spinner-boot.entry-point.js.map +1 -0
- package/command-line-interface/spinner-boot.js +9 -0
- package/command-line-interface/spinner-boot.js.map +1 -0
- package/command-line-interface/spinner-shared-state.js +167 -0
- package/command-line-interface/spinner-shared-state.js.map +1 -0
- package/command-line-interface/spinner-worker-backend.js +62 -0
- package/command-line-interface/spinner-worker-backend.js.map +1 -0
- package/command-line-interface/terminal-spinner-renderer.js +21 -15
- package/command-line-interface/terminal-spinner-renderer.js.map +1 -1
- package/common/typed-diff.js +5 -0
- package/common/typed-diff.js.map +1 -0
- package/package.json +7 -7
- package/packages/command-line-interface/command-line-interface.entry-point.d.ts +2 -1
- package/packages/command-line-interface/command-line-interface.entry-point.d.ts.map +1 -1
- package/packages/command-line-interface/command-line-interface.entry-point.js +61 -7
- package/packages/command-line-interface/command-line-interface.entry-point.js.map +1 -1
- package/readme.md +33 -1
- package/report/changed-artifacts.js +10 -0
- package/report/changed-artifacts.js.map +1 -0
- package/report/html-escaping.js +9 -0
- package/report/html-escaping.js.map +1 -0
- package/report/html-renderer.js +337 -0
- package/report/html-renderer.js.map +1 -0
- package/report/preview-document-diff.js +17 -0
- package/report/preview-document-diff.js.map +1 -0
- package/report/preview-document-helpers.js +173 -0
- package/report/preview-document-helpers.js.map +1 -0
- package/report/preview-document-tree.js +13 -0
- package/report/preview-document-tree.js.map +1 -0
- package/report/preview-document.js +97 -0
- package/report/preview-document.js.map +1 -0
- package/report/terminal-preview-renderer-shared.js +41 -0
- package/report/terminal-preview-renderer-shared.js.map +1 -0
- package/report/terminal-preview-renderer.js +94 -0
- package/report/terminal-preview-renderer.js.map +1 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
import { has } from 'effect/ReadonlyRecord';
|
|
2
|
+
import { isPlainObject } from 'remeda';
|
|
4
3
|
function isFunction(value) {
|
|
5
4
|
return typeof value === 'function';
|
|
6
5
|
}
|
|
6
|
+
function hasOwn(value, key) {
|
|
7
|
+
return Object.hasOwn(value, key);
|
|
8
|
+
}
|
|
7
9
|
export function createConfigLoader(dependencies) {
|
|
8
10
|
const { currentWorkingDirectory, importModule } = dependencies;
|
|
9
11
|
async function importConfigModule() {
|
|
10
12
|
const configFilePath = path.join(currentWorkingDirectory, 'packtory.config.js');
|
|
11
13
|
const module = await importModule(configFilePath);
|
|
12
|
-
if (!
|
|
14
|
+
if (!isPlainObject(module)) {
|
|
13
15
|
throw new Error('Invalid config file');
|
|
14
16
|
}
|
|
15
17
|
return module;
|
|
@@ -17,10 +19,10 @@ export function createConfigLoader(dependencies) {
|
|
|
17
19
|
return {
|
|
18
20
|
async load() {
|
|
19
21
|
const module = await importConfigModule();
|
|
20
|
-
if (
|
|
22
|
+
if (hasOwn(module, 'config')) {
|
|
21
23
|
return module.config;
|
|
22
24
|
}
|
|
23
|
-
if (
|
|
25
|
+
if (hasOwn(module, 'buildConfig')) {
|
|
24
26
|
const { buildConfig } = module;
|
|
25
27
|
if (isFunction(buildConfig)) {
|
|
26
28
|
return buildConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../../../source/command-line-interface/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../../../source/command-line-interface/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAavC,SAAS,UAAU,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC;AAED,SAAS,MAAM,CACX,KAA6C,EAC7C,GAAM;IAEN,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,YAAsC;IACrE,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC;IAE/D,KAAK,UAAU,kBAAkB;QAC7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,oBAAoB,CAAC,CAAC;QAChF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,CAAC;QAElD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO;QACH,KAAK,CAAC,IAAI;YACN,MAAM,MAAM,GAAG,MAAM,kBAAkB,EAAE,CAAC;YAE1C,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;gBAC3B,OAAO,MAAM,CAAC,MAAM,CAAC;YACzB,CAAC;YAED,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;gBAChC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;gBAC/B,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;oBAC1B,OAAO,WAAW,EAAE,CAAC;gBACzB,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;YACnF,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;QAC1F,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const oneTimePasswordPromptTimeoutMs = 90_000;
|
|
2
|
+
export function createOneTimePasswordPrompt(dependencies) {
|
|
3
|
+
const { clock, isInteractiveTerminal, stopSpinner, createInterface } = dependencies;
|
|
4
|
+
return async () => {
|
|
5
|
+
if (!isInteractiveTerminal()) {
|
|
6
|
+
throw new Error('The registry requested a one-time password, but prompting requires an interactive terminal');
|
|
7
|
+
}
|
|
8
|
+
stopSpinner();
|
|
9
|
+
const interfaceInstance = createInterface();
|
|
10
|
+
try {
|
|
11
|
+
const answer = await Promise.race([
|
|
12
|
+
interfaceInstance.question('Registry one-time password: '),
|
|
13
|
+
new Promise((resolve) => {
|
|
14
|
+
clock.setTimeout(() => {
|
|
15
|
+
resolve(undefined);
|
|
16
|
+
}, oneTimePasswordPromptTimeoutMs);
|
|
17
|
+
})
|
|
18
|
+
]);
|
|
19
|
+
if (typeof answer !== 'string' || answer.trim().length === 0) {
|
|
20
|
+
throw new Error('One-time password input timed out or was empty');
|
|
21
|
+
}
|
|
22
|
+
return answer.trim();
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
interfaceInstance.close();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=one-time-password-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-time-password-prompt.js","sourceRoot":"","sources":["../../../../source/command-line-interface/one-time-password-prompt.ts"],"names":[],"mappings":"AAgBA,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,MAAM,UAAU,2BAA2B,CACvC,YAAyD;IAEzD,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;IAEpF,OAAO,KAAK,IAAI,EAAE;QACd,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACX,4FAA4F,CAC/F,CAAC;QACN,CAAC;QAED,WAAW,EAAE,CAAC;QACd,MAAM,iBAAiB,GAAG,eAAe,EAAE,CAAC;QAE5C,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAC9B,iBAAiB,CAAC,QAAQ,CAAC,8BAA8B,CAAC;gBAC1D,IAAI,OAAO,CAAY,CAAC,OAAO,EAAE,EAAE;oBAC/B,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE;wBAClB,OAAO,CAAC,SAAS,CAAC,CAAC;oBACvB,CAAC,EAAE,8BAA8B,CAAC,CAAC;gBACvC,CAAC,CAAC;aACL,CAAC,CAAC;YAEH,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3D,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;YACtE,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACP,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-disable no-undef -- the NodeJS namespace type is used for portable platform detection */
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export function defaultSpawnProcess(command, args, options) {
|
|
5
|
+
return spawn(command, Array.from(args), {
|
|
6
|
+
...options,
|
|
7
|
+
stdio: options.stdio === 'ignore' ? 'ignore' : Array.from(options.stdio)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export function createPreviewIo(dependencies) {
|
|
11
|
+
const shell = dependencies.shell ?? 'sh';
|
|
12
|
+
async function spawnForCompletion(command, args, content) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const child = dependencies.spawnProcess(command, args, {
|
|
15
|
+
stdio: ['pipe', 'inherit', 'inherit']
|
|
16
|
+
});
|
|
17
|
+
if (child.stdin === null) {
|
|
18
|
+
resolve(false);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
child.on('error', () => {
|
|
22
|
+
resolve(false);
|
|
23
|
+
});
|
|
24
|
+
child.on('close', (code) => {
|
|
25
|
+
resolve(code === 0);
|
|
26
|
+
});
|
|
27
|
+
child.stdin.on('error', () => {
|
|
28
|
+
resolve(false);
|
|
29
|
+
});
|
|
30
|
+
child.stdin.end(content);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async function spawnDetached(options) {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
const child = dependencies.spawnProcess(options.command, options.args, {
|
|
36
|
+
detached: true,
|
|
37
|
+
stdio: 'ignore'
|
|
38
|
+
});
|
|
39
|
+
child.on('error', () => {
|
|
40
|
+
resolve(false);
|
|
41
|
+
});
|
|
42
|
+
child.unref();
|
|
43
|
+
queueMicrotask(() => {
|
|
44
|
+
resolve(true);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
createTemporaryPreviewHtmlPath() {
|
|
50
|
+
return path.join(dependencies.tmpdir(), `packtory-preview-${dependencies.randomUuid()}.html`);
|
|
51
|
+
},
|
|
52
|
+
async pagePreviewOutput(content) {
|
|
53
|
+
if (!dependencies.stdoutIsTTY) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (dependencies.pager !== undefined && dependencies.pager !== '') {
|
|
57
|
+
const didPage = await spawnForCompletion(shell, ['-lc', dependencies.pager], content);
|
|
58
|
+
if (didPage) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return spawnForCompletion(shell, ['-lc', 'less -R'], content);
|
|
63
|
+
},
|
|
64
|
+
async openPreviewFile(filePath) {
|
|
65
|
+
if (dependencies.platform === 'darwin') {
|
|
66
|
+
return spawnDetached({ command: 'open', args: [filePath] });
|
|
67
|
+
}
|
|
68
|
+
if (dependencies.platform === 'win32') {
|
|
69
|
+
return spawnDetached({ command: 'cmd', args: ['/c', 'start', '', filePath] });
|
|
70
|
+
}
|
|
71
|
+
return spawnDetached({ command: 'xdg-open', args: [filePath] });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=preview-io-shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-io-shared.js","sourceRoot":"","sources":["../../../../source/command-line-interface/preview-io-shared.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAuC7B,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,IAAuB,EAAE,OAAqB;IAC/F,OAAO,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACpC,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;KAC3E,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,YAAmC;IAC/D,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC;IAEzC,KAAK,UAAU,kBAAkB,CAAC,OAAe,EAAE,IAAuB,EAAE,OAAe;QACvF,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE;g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+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import { createPreviewIo, defaultSpawnProcess } from "./preview-io-shared.js";
|
|
4
|
+
export const previewIo = createPreviewIo({
|
|
5
|
+
spawnProcess: defaultSpawnProcess,
|
|
6
|
+
randomUuid: randomUUID,
|
|
7
|
+
tmpdir: os.tmpdir,
|
|
8
|
+
platform: process.platform,
|
|
9
|
+
// eslint-disable-next-line node/no-process-env -- preview pager/open behavior is intentionally driven by the caller environment
|
|
10
|
+
shell: process.env.SHELL,
|
|
11
|
+
// eslint-disable-next-line node/no-process-env -- preview pager/open behavior is intentionally driven by the caller environment
|
|
12
|
+
pager: process.env.PAGER,
|
|
13
|
+
stdoutIsTTY: process.stdout.isTTY
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=preview-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-io.js","sourceRoot":"","sources":["../../../../source/command-line-interface/preview-io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;IACrC,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,EAAE,CAAC,MAAM;IACjB,QAAQ,EAAE,OAAO,CAAC,QAAQ;IAC1B,gIAAgI;IAChI,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK;IACxB,gIAAgI;IAChI,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK;IACxB,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;CACpC,CAAC,CAAC"}
|
|
@@ -1,102 +1,237 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/* eslint-disable import/max-dependencies -- the CLI runner orchestrates command parsing, reporting, preview rendering, and progress wiring */
|
|
2
|
+
import { command, subcommands, flag, binary, runSafely } from 'cmd-ts';
|
|
3
|
+
import { bold, red, green, yellow, dim } from 'yoctocolors';
|
|
4
|
+
import { buildPreviewDocument } from "../report/preview-document.js";
|
|
5
|
+
import { renderHtmlReport } from "../report/html-renderer.js";
|
|
6
|
+
import { renderFailureOnlyTerminalPreview, renderTerminalPreview } from "../report/terminal-preview-renderer.js";
|
|
7
|
+
function hasCommandParseError(result) {
|
|
8
|
+
return 'error' in result;
|
|
9
|
+
}
|
|
10
|
+
function getErrorSymbol() {
|
|
11
|
+
return bold(red('✖'));
|
|
12
|
+
}
|
|
13
|
+
function getSuccessSymbol() {
|
|
14
|
+
return bold(green('✔'));
|
|
15
|
+
}
|
|
16
|
+
function getWarningSymbol() {
|
|
17
|
+
return yellow('⚠');
|
|
18
|
+
}
|
|
19
|
+
function printDryRunNote(log, flags) {
|
|
20
|
+
if (flags.noDryRun) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
log(`${getWarningSymbol()} ${dim(` Note: dry-run mode was enabled, so there was nothing really published; add the ${bold('--no-dry-run')} flag to disable dry-run mode`)}`);
|
|
24
|
+
}
|
|
25
|
+
function printInvalidConfigErrors(log, issues) {
|
|
26
|
+
const title = `${getErrorSymbol()} The provided config is invalid, there are ${issues.length} issue(s)`;
|
|
27
|
+
const message = `${title}\n\n- ${issues.join('\n- ')}`;
|
|
28
|
+
log(message);
|
|
29
|
+
}
|
|
30
|
+
function printCheckErrors(log, issues) {
|
|
31
|
+
const title = `${getErrorSymbol()} Checks failed, there are ${issues.length} issue(s)`;
|
|
32
|
+
const message = `${title}\n\n- ${issues.join('\n- ')}`;
|
|
33
|
+
log(message);
|
|
34
|
+
}
|
|
35
|
+
function printPartialErrorSummary(log, error) {
|
|
36
|
+
const total = error.succeeded.length + error.failures.length;
|
|
37
|
+
const failureCount = red(String(error.failures.length));
|
|
38
|
+
const successCount = green(String(error.succeeded.length));
|
|
39
|
+
log(`${getErrorSymbol()} ${failureCount} from ${bold(String(total))} package(s) failed; ${successCount} succeeded`);
|
|
40
|
+
}
|
|
41
|
+
function printPublishFailure(log, error) {
|
|
42
|
+
if (error.type === 'config') {
|
|
43
|
+
printInvalidConfigErrors(log, error.issues);
|
|
44
|
+
}
|
|
45
|
+
else if (error.type === 'checks') {
|
|
46
|
+
printCheckErrors(log, error.issues);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
printPartialErrorSummary(log, error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function printSuccessSummary(log, results) {
|
|
53
|
+
log(`${getSuccessSymbol()} Success: all ${results.length} package(s) have been published`);
|
|
54
|
+
}
|
|
55
|
+
function registerProgressListeners(progressBroadcaster, spinnerRenderer) {
|
|
56
|
+
progressBroadcaster.on('scheduled', (payload) => {
|
|
57
|
+
spinnerRenderer.add(payload.packageName, payload.packageName, 'Scheduled …');
|
|
58
|
+
});
|
|
59
|
+
progressBroadcaster.on('error', (payload) => {
|
|
60
|
+
spinnerRenderer.stop(payload.packageName, 'failure', payload.error.message);
|
|
61
|
+
});
|
|
62
|
+
progressBroadcaster.on('done', (payload) => {
|
|
63
|
+
let message = `New version ${payload.version} published`;
|
|
64
|
+
if (payload.status === 'already-published') {
|
|
65
|
+
message = `Nothing has changed, published version ${payload.version} is already up-to-date`;
|
|
66
|
+
}
|
|
67
|
+
if (payload.status === 'initial-version') {
|
|
68
|
+
message = `First version ${payload.version} has been published`;
|
|
12
69
|
}
|
|
13
|
-
|
|
70
|
+
spinnerRenderer.stop(payload.packageName, 'success', message);
|
|
71
|
+
});
|
|
72
|
+
progressBroadcaster.on('building', (payload) => {
|
|
73
|
+
spinnerRenderer.updateMessage(payload.packageName, `Building package with version ${payload.version}`);
|
|
74
|
+
});
|
|
75
|
+
progressBroadcaster.on('rebuilding', (payload) => {
|
|
76
|
+
spinnerRenderer.updateMessage(payload.packageName, `Rebuilding package with version ${payload.version}`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const jsonIndentSpaces = 2;
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/max-params -- report persistence needs shared flags plus build outcome/report data
|
|
81
|
+
async function writeReports(writeReportFile, report, result, flags, dryRun) {
|
|
82
|
+
if (report === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (flags.reportJson) {
|
|
86
|
+
await writeReportFile('packtory-report.json', `${JSON.stringify(report, undefined, jsonIndentSpaces)}\n`);
|
|
87
|
+
}
|
|
88
|
+
if (flags.reportHtml) {
|
|
89
|
+
const document = await buildPreviewDocument({ report, result, dryRun });
|
|
90
|
+
await writeReportFile('packtory-report.html', renderHtmlReport(document));
|
|
14
91
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
92
|
+
}
|
|
93
|
+
async function reportOutcome(log, writeReportFile, outcome, flags) {
|
|
94
|
+
let exitCode = 0;
|
|
95
|
+
if (outcome.result.isErr) {
|
|
96
|
+
exitCode = 1;
|
|
97
|
+
printPublishFailure(log, outcome.result.error);
|
|
19
98
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const message = `${title}\n\n- ${issues.join('\n- ')}`;
|
|
23
|
-
log(message);
|
|
99
|
+
else {
|
|
100
|
+
printSuccessSummary(log, outcome.result.value);
|
|
24
101
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
102
|
+
await writeReports(writeReportFile, outcome.getReport(), outcome.result, flags, !flags.noDryRun);
|
|
103
|
+
return exitCode;
|
|
104
|
+
}
|
|
105
|
+
async function runPublishHandler(deps) {
|
|
106
|
+
const { log, packtory, spinnerRenderer, configLoader, writeReportFile, flags } = deps;
|
|
107
|
+
const config = await configLoader.load();
|
|
108
|
+
const collectReport = flags.reportJson || flags.reportHtml;
|
|
109
|
+
try {
|
|
110
|
+
const outcome = await packtory.buildAndPublishAll(config, {
|
|
111
|
+
dryRun: !flags.noDryRun,
|
|
112
|
+
collectReport
|
|
113
|
+
});
|
|
114
|
+
spinnerRenderer.stopAll();
|
|
115
|
+
return await reportOutcome(log, writeReportFile, outcome, flags);
|
|
28
116
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
117
|
+
finally {
|
|
118
|
+
spinnerRenderer.stopAll();
|
|
119
|
+
printDryRunNote(log, { noDryRun: flags.noDryRun });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function createEmptyReport() {
|
|
123
|
+
return {
|
|
124
|
+
schemaVersion: 1,
|
|
125
|
+
generatedAt: new Date().toISOString(),
|
|
126
|
+
packages: {},
|
|
127
|
+
aggregate: { crossBundleLinks: [] }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function isPreviewableResult(result) {
|
|
131
|
+
return result.isOk || (result.error.type === 'partial' && result.error.succeeded.length > 0);
|
|
132
|
+
}
|
|
133
|
+
// eslint-disable-next-line max-statements -- preview handling intentionally coordinates build, render, paging, and opening in one place
|
|
134
|
+
async function runPreviewHandler(deps) {
|
|
135
|
+
const { log, pageOutput, openFile, createTemporaryFilePath, packtory, spinnerRenderer, configLoader, writeReportFile, flags } = deps;
|
|
136
|
+
try {
|
|
137
|
+
const config = await configLoader.load();
|
|
138
|
+
const outcome = await packtory.buildAndPublishAll(config, {
|
|
139
|
+
dryRun: true,
|
|
140
|
+
collectReport: true
|
|
141
|
+
});
|
|
142
|
+
spinnerRenderer.stopAll();
|
|
143
|
+
const report = outcome.getReport() ?? createEmptyReport();
|
|
144
|
+
const document = await buildPreviewDocument({
|
|
145
|
+
report,
|
|
146
|
+
result: outcome.result,
|
|
147
|
+
dryRun: true
|
|
148
|
+
});
|
|
149
|
+
if (flags.open) {
|
|
150
|
+
const filePath = createTemporaryFilePath();
|
|
151
|
+
await writeReportFile(filePath, renderHtmlReport(document));
|
|
152
|
+
const opened = await openFile(filePath);
|
|
153
|
+
if (!opened) {
|
|
154
|
+
log(filePath);
|
|
155
|
+
}
|
|
32
156
|
}
|
|
33
|
-
else if (
|
|
34
|
-
|
|
157
|
+
else if (isPreviewableResult(outcome.result)) {
|
|
158
|
+
await pageOutput(renderTerminalPreview(document));
|
|
35
159
|
}
|
|
36
160
|
else {
|
|
37
|
-
|
|
161
|
+
log(renderFailureOnlyTerminalPreview(document).trimEnd());
|
|
38
162
|
}
|
|
163
|
+
return outcome.result.isErr ? 1 : 0;
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
spinnerRenderer.stopAll();
|
|
39
167
|
}
|
|
40
|
-
|
|
41
|
-
|
|
168
|
+
}
|
|
169
|
+
function getParseExitCode(log, result) {
|
|
170
|
+
if (!hasCommandParseError(result)) {
|
|
171
|
+
return undefined;
|
|
42
172
|
}
|
|
173
|
+
log(result.error.config.message);
|
|
174
|
+
return result.error.config.exitCode;
|
|
175
|
+
}
|
|
176
|
+
export function createCommandLineInterfaceRunner(dependencies) {
|
|
177
|
+
const { log, packtory, progressBroadcaster, spinnerRenderer, configLoader, writeReportFile, pageOutput, openFile, createTemporaryFilePath } = dependencies;
|
|
178
|
+
let exitCode = 0;
|
|
179
|
+
const publishCommandName = 'publish';
|
|
180
|
+
const previewCommandName = 'preview';
|
|
43
181
|
const baseCommand = subcommands({
|
|
44
182
|
name: 'packtory',
|
|
45
183
|
cmds: {
|
|
46
|
-
|
|
47
|
-
name:
|
|
184
|
+
[publishCommandName]: command({
|
|
185
|
+
name: publishCommandName,
|
|
48
186
|
description: 'Builds and publishes all packages (dry-run enabled by default).',
|
|
49
187
|
args: {
|
|
50
|
-
noDryRun: flag({ long: 'no-dry-run' })
|
|
188
|
+
noDryRun: flag({ long: 'no-dry-run' }),
|
|
189
|
+
reportJson: flag({ long: 'report-json' }),
|
|
190
|
+
reportHtml: flag({ long: 'report-html' })
|
|
51
191
|
},
|
|
52
|
-
async handler({ noDryRun }) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
spinnerRenderer
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
192
|
+
async handler({ noDryRun, reportJson, reportHtml }) {
|
|
193
|
+
const handlerExitCode = await runPublishHandler({
|
|
194
|
+
log,
|
|
195
|
+
packtory,
|
|
196
|
+
spinnerRenderer,
|
|
197
|
+
configLoader,
|
|
198
|
+
writeReportFile,
|
|
199
|
+
flags: { noDryRun, reportJson, reportHtml }
|
|
200
|
+
});
|
|
201
|
+
exitCode = handlerExitCode;
|
|
202
|
+
}
|
|
203
|
+
}),
|
|
204
|
+
[previewCommandName]: command({
|
|
205
|
+
name: previewCommandName,
|
|
206
|
+
description: 'Builds all packages in fresh dry-run mode and opens a human preview.',
|
|
207
|
+
args: {
|
|
208
|
+
open: flag({ long: 'open' })
|
|
209
|
+
},
|
|
210
|
+
async handler({ open }) {
|
|
211
|
+
const handlerExitCode = await runPreviewHandler({
|
|
212
|
+
log,
|
|
213
|
+
pageOutput,
|
|
214
|
+
openFile,
|
|
215
|
+
createTemporaryFilePath,
|
|
216
|
+
packtory,
|
|
217
|
+
spinnerRenderer,
|
|
218
|
+
configLoader,
|
|
219
|
+
writeReportFile,
|
|
220
|
+
flags: { open }
|
|
221
|
+
});
|
|
222
|
+
exitCode = handlerExitCode;
|
|
69
223
|
}
|
|
70
224
|
})
|
|
71
225
|
}
|
|
72
226
|
});
|
|
73
227
|
return {
|
|
74
228
|
async run(programArguments) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
progressBroadcaster.on('done', (payload) => {
|
|
82
|
-
let message = `New version ${payload.version} published`;
|
|
83
|
-
if (payload.status === 'already-published') {
|
|
84
|
-
message = `Nothing has changed, published version ${payload.version} is already up-to-date`;
|
|
85
|
-
}
|
|
86
|
-
if (payload.status === 'initial-version') {
|
|
87
|
-
message = `First version ${payload.version} has been published`;
|
|
88
|
-
}
|
|
89
|
-
spinnerRenderer.stop(payload.packageName, 'success', message);
|
|
90
|
-
});
|
|
91
|
-
progressBroadcaster.on('building', (payload) => {
|
|
92
|
-
spinnerRenderer.updateMessage(payload.packageName, `Building package with version ${payload.version}`);
|
|
93
|
-
});
|
|
94
|
-
progressBroadcaster.on('rebuilding', (payload) => {
|
|
95
|
-
spinnerRenderer.updateMessage(payload.packageName, `Rebuilding package with version ${payload.version}`);
|
|
96
|
-
});
|
|
97
|
-
const program = binary(baseCommand);
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- ok in this case
|
|
99
|
-
await run(program, programArguments);
|
|
229
|
+
exitCode = 0;
|
|
230
|
+
registerProgressListeners(progressBroadcaster, spinnerRenderer);
|
|
231
|
+
const parseExitCode = getParseExitCode(log, await runSafely(binary(baseCommand), Array.from(programArguments)));
|
|
232
|
+
if (parseExitCode !== undefined) {
|
|
233
|
+
return parseExitCode;
|
|
234
|
+
}
|
|
100
235
|
return exitCode;
|
|
101
236
|
}
|
|
102
237
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../source/command-line-interface/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../source/command-line-interface/runner.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM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AE,UAAU,EAAE;qBAC9C,CAAC,CAAC;oBACH,QAAQ,GAAG,eAAe,CAAC;gBAC/B,CAAC;aACJ,CAAC;YACF,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;gBAC1B,IAAI,EAAE,kBAAkB;gBACxB,WAAW,EAAE,sEAAsE;gBACnF,IAAI,EAAE;oBACF,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iBAC/B;gBACD,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE;oBAClB,MAAM,eAAe,GAAG,MAAM,iBAAiB,CAAC;wBAC5C,GAAG;wBACH,UAAU;wBACV,QAAQ;wBACR,uBAAuB;wBACvB,QAAQ;wBACR,eAAe;wBACf,YAAY;wBACZ,eAAe;wBACf,KAAK,EAAE,EAAE,IAAI,EAAE;qBAClB,CAAC,CAAC;oBACH,QAAQ,GAAG,eAAe,CAAC;gBAC/B,CAAC;aACJ,CAAC;SACL;KACJ,CAAC,CAAC;IAEH,OAAO;QACH,KAAK,CAAC,GAAG,CAAC,gBAAgB;YACtB,QAAQ,GAAG,CAAC,CAAC;YACb,yBAAyB,CAAC,mBAAmB,EAAE,eAAe,CAAC,CAAC;YAEhE,MAAM,aAAa,GAAG,gBAAgB,CAClC,GAAG,EACH,MAAM,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CACrE,CAAC;YAEF,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAC9B,OAAO,aAAa,CAAC;YACzB,CAAC;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { Worker as WorkerThread } from 'node:worker_threads';
|
|
4
|
+
import { bootSpinnerRuntime } from "./spinner-boot.js";
|
|
5
|
+
const bootModulePath = fileURLToPath(import.meta.url);
|
|
6
|
+
const bootModuleExtension = path.extname(bootModulePath);
|
|
7
|
+
const workerModulePath = path.join(path.dirname(bootModulePath), `spinner-worker.entry-point${bootModuleExtension}`);
|
|
8
|
+
const workerExecArgv = bootModuleExtension === '.ts' ? ['--experimental-strip-types', '--enable-source-maps'] : ['--enable-source-maps'];
|
|
9
|
+
function spawnWorker(request) {
|
|
10
|
+
const worker = new WorkerThread(workerModulePath, {
|
|
11
|
+
workerData: {
|
|
12
|
+
buffer: request.buffer,
|
|
13
|
+
slotCount: request.slotCount,
|
|
14
|
+
stdoutFileDescriptor: request.stdoutFileDescriptor
|
|
15
|
+
},
|
|
16
|
+
execArgv: workerExecArgv
|
|
17
|
+
});
|
|
18
|
+
worker.unref();
|
|
19
|
+
}
|
|
20
|
+
export const bootedSpinnerRuntime = bootSpinnerRuntime({
|
|
21
|
+
spawnWorker,
|
|
22
|
+
initialLabel: 'packtory',
|
|
23
|
+
initialMessage: 'Starting …'
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=spinner-boot.entry-point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner-boot.entry-point.js","sourceRoot":"","sources":["../../../../source/command-line-interface/spinner-boot.entry-point.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtD,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,6BAA6B,mBAAmB,EAAE,CAAC,CAAC;AACrH,MAAM,cAAc,GAChB,mBAAmB,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,4BAA4B,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;AAEtH,SAAS,WAAW,CAAC,OAA2B;IAC5C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,gBAAgB,EAAE;QAC9C,UAAU,EAAE;YACR,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;SACrD;QACD,QAAQ,EAAE,cAAc;KAC3B,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAmB,kBAAkB,CAAC;IACnE,WAAW;IACX,YAAY,EAAE,UAAU;IACxB,cAAc,EAAE,YAAY;CAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createSpinnerRuntime } from "./spinner-worker-backend.js";
|
|
2
|
+
const bootSlotIndex = 0;
|
|
3
|
+
export function bootSpinnerRuntime(options) {
|
|
4
|
+
const runtime = createSpinnerRuntime(options);
|
|
5
|
+
runtime.accessors.writeSlot(bootSlotIndex, 'running', options.initialLabel, options.initialMessage);
|
|
6
|
+
runtime.accessors.bumpSlotGeneration(bootSlotIndex);
|
|
7
|
+
return runtime;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=spinner-boot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner-boot.js","sourceRoot":"","sources":["../../../../source/command-line-interface/spinner-boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAmD,MAAM,6BAA6B,CAAC;AAEpH,MAAM,aAAa,GAAG,CAAC,CAAC;AAOxB,MAAM,UAAU,kBAAkB,CAAC,OAA2B;IAC1D,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACpG,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|