@packtory/cli 0.0.21 → 0.0.23
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/runner/failure-printing.js +19 -18
- package/command-line-interface/runner/failure-printing.js.map +1 -1
- package/command-line-interface/runner/pack-handler.js +41 -48
- package/command-line-interface/runner/pack-handler.js.map +1 -1
- package/command-line-interface/runner/preview-handler.js +5 -8
- package/command-line-interface/runner/preview-handler.js.map +1 -1
- package/command-line-interface/runner/release-diff-handler.js +2 -10
- package/command-line-interface/runner/release-diff-handler.js.map +1 -1
- package/command-line-interface/spinner/line-spinner-renderer.js +2 -1
- package/command-line-interface/spinner/line-spinner-renderer.js.map +1 -1
- package/command-line-interface/spinner/spinner-shared-state.js +117 -91
- package/command-line-interface/spinner/spinner-shared-state.js.map +1 -1
- package/command-line-interface/spinner/terminal-spinner-renderer.js +5 -1
- package/command-line-interface/spinner/terminal-spinner-renderer.js.map +1 -1
- package/common/path-tree.js +9 -4
- package/common/path-tree.js.map +1 -1
- package/package.json +3 -2
- package/report/html-renderer/artifact-tree-renderer.js +2 -1
- package/report/html-renderer/artifact-tree-renderer.js.map +1 -1
- package/report/html-renderer/diff-renderer.js +2 -4
- package/report/html-renderer/diff-renderer.js.map +1 -1
- package/report/html-renderer/html-renderer.js +1 -1
- package/report/html-renderer/html-renderer.js.map +1 -1
- package/report/html-renderer/html-styles.js +3 -1
- package/report/html-renderer/html-styles.js.map +1 -1
- package/report/preview/artifact-tree-builder.js +4 -4
- package/report/preview/artifact-tree-builder.js.map +1 -1
- package/report/preview/bundle-artifact-index.js +2 -1
- package/report/preview/bundle-artifact-index.js.map +1 -1
- package/report/preview/{preview-document-helpers.js → preview-document-state.js} +5 -7
- package/report/preview/preview-document-state.js.map +1 -0
- package/report/preview/preview-document.js +39 -16
- package/report/preview/preview-document.js.map +1 -1
- package/report/preview/preview-result-inspectors.js +25 -21
- package/report/preview/preview-result-inspectors.js.map +1 -1
- package/report/preview/preview-summary.js +19 -47
- package/report/preview/preview-summary.js.map +1 -1
- package/report/release-diff/release-diff-document.js +7 -3
- package/report/release-diff/release-diff-document.js.map +1 -1
- package/report/release-diff/release-diff-summary.js +3 -2
- package/report/release-diff/release-diff-summary.js.map +1 -1
- package/report/terminal-renderer/terminal-artifact-renderer.js +3 -1
- package/report/terminal-renderer/terminal-artifact-renderer.js.map +1 -1
- package/report/terminal-renderer/terminal-package-renderer.js +11 -14
- package/report/terminal-renderer/terminal-package-renderer.js.map +1 -1
- package/report/terminal-renderer/terminal-preview-renderer-shared.js +13 -10
- package/report/terminal-renderer/terminal-preview-renderer-shared.js.map +1 -1
- package/report/terminal-renderer/terminal-release-diff-package-renderer.js +72 -71
- package/report/terminal-renderer/terminal-release-diff-package-renderer.js.map +1 -1
- package/report/terminal-renderer/terminal-release-diff-renderer.js +22 -29
- package/report/terminal-renderer/terminal-release-diff-renderer.js.map +1 -1
- package/sbom.cdx.json +27 -10
- package/report/preview/changed-artifacts.js +0 -10
- package/report/preview/changed-artifacts.js.map +0 -1
- package/report/preview/preview-document-helpers.js.map +0 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import { match } from 'ts-pattern';
|
|
1
2
|
import { bold, dim, green, red } from 'yoctocolors';
|
|
3
|
+
import { checksErrorType, configErrorType, partialFailureType } from "packtory/packtory/packtory-results.js";
|
|
4
|
+
import { partialFailureMessages } from "packtory/packtory/partial-result.js";
|
|
2
5
|
import { getErrorSymbol, getSuccessSymbol, getWarningSymbol } from "./runner-symbols.js";
|
|
6
|
+
const issueTitleByType = {
|
|
7
|
+
[configErrorType]: 'The provided config is invalid',
|
|
8
|
+
[checksErrorType]: 'Checks failed'
|
|
9
|
+
};
|
|
3
10
|
export function printDryRunNote(log, flags) {
|
|
4
11
|
if (flags.noDryRun) {
|
|
5
12
|
return;
|
|
6
13
|
}
|
|
7
14
|
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`)}`);
|
|
8
15
|
}
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
log(`${
|
|
12
|
-
}
|
|
13
|
-
function printCheckErrors(log, issues) {
|
|
14
|
-
const title = `${getErrorSymbol()} Checks failed, there are ${issues.length} issue(s)`;
|
|
15
|
-
log(`${title}\n\n- ${issues.join('\n- ')}`);
|
|
16
|
+
function printIssueSummary(log, title, issues) {
|
|
17
|
+
const header = `${getErrorSymbol()} ${title}, there are ${issues.length} issue(s)`;
|
|
18
|
+
log(`${header}\n\n- ${issues.join('\n- ')}`);
|
|
16
19
|
}
|
|
17
20
|
function printPartialErrorSummary(log, error) {
|
|
18
21
|
const total = error.succeeded.length + error.failures.length;
|
|
@@ -20,21 +23,19 @@ function printPartialErrorSummary(log, error) {
|
|
|
20
23
|
const successCount = green(String(error.succeeded.length));
|
|
21
24
|
const summary = `${getErrorSymbol()} ${failureCount} from ${bold(String(total))} package(s) failed; ` +
|
|
22
25
|
`${successCount} succeeded`;
|
|
23
|
-
const details = error.
|
|
24
|
-
return `- ${
|
|
26
|
+
const details = partialFailureMessages(error).map((message) => {
|
|
27
|
+
return `- ${message}`;
|
|
25
28
|
});
|
|
26
29
|
log([summary, ...details].join('\n'));
|
|
27
30
|
}
|
|
28
31
|
export function printPublishFailure(log, error) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
printPartialErrorSummary(log, error);
|
|
37
|
-
}
|
|
32
|
+
match(error)
|
|
33
|
+
.with({ type: partialFailureType }, (partialError) => {
|
|
34
|
+
printPartialErrorSummary(log, partialError);
|
|
35
|
+
})
|
|
36
|
+
.otherwise((issueError) => {
|
|
37
|
+
printIssueSummary(log, issueTitleByType[issueError.type], issueError.issues);
|
|
38
|
+
});
|
|
38
39
|
}
|
|
39
40
|
export function printSuccessSummary(log, results) {
|
|
40
41
|
log(`${getSuccessSymbol()} Success: all ${results.length} package(s) have been published`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure-printing.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/failure-printing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"failure-printing.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/failure-printing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACH,eAAe,EACf,eAAe,EACf,kBAAkB,EAErB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIzF,MAAM,gBAAgB,GAAG;IACrB,CAAC,eAAe,CAAC,EAAE,gCAAgC;IACnD,CAAC,eAAe,CAAC,EAAE,eAAe;CAC5B,CAAC;AAEX,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAqC;IAC9E,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO;IACX,CAAC;IACD,GAAG,CACC,GAAG,gBAAgB,EAAE,IAAI,GAAG,CACxB,mFAAmF,IAAI,CACnF,cAAc,CACjB,+BAA+B,CACnC,EAAE,CACN,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW,EAAE,KAAa,EAAE,MAAyB;IAC5E,MAAM,MAAM,GAAG,GAAG,cAAc,EAAE,IAAI,KAAK,eAAe,MAAM,CAAC,MAAM,WAAW,CAAC;IACnF,GAAG,CAAC,GAAG,MAAM,SAAS,MAAM,CAAC,IAAI,CAAC,MAAM,C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AAyC;IACtF,GAAG,CAAC,GAAG,gBAAgB,EAAE,iBAAiB,OAAO,CAAC,MAAM,iCAAiC,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -1,35 +1,37 @@
|
|
|
1
|
+
import { partialFailureMessages } from "packtory/packtory/partial-result.js";
|
|
2
|
+
import { checksErrorType, configErrorType, packPackageFailureType, partialFailureType } from "packtory/packtory/packtory-results.js";
|
|
1
3
|
import { getErrorSymbol, getSuccessSymbol } from "./runner-symbols.js";
|
|
4
|
+
const issuePrefixByType = {
|
|
5
|
+
[configErrorType]: 'The provided config is invalid',
|
|
6
|
+
[checksErrorType]: 'Checks failed'
|
|
7
|
+
};
|
|
2
8
|
function formatIssueList(prefix, issues) {
|
|
3
9
|
const issueCount = `${issues.length} issue(s)`;
|
|
4
10
|
return `${getErrorSymbol()} ${prefix}, there are ${issueCount}\n\n- ${issues.join('\n- ')}`;
|
|
5
11
|
}
|
|
12
|
+
function formatBulletedLines(header, details) {
|
|
13
|
+
return [header, ...details].join('\n');
|
|
14
|
+
}
|
|
6
15
|
function formatPartialResolveFailure(error) {
|
|
7
|
-
|
|
8
|
-
return `- ${
|
|
9
|
-
});
|
|
10
|
-
return [`${getErrorSymbol()} ${messages.length} package(s) failed to resolve`, ...messages].join('\n');
|
|
16
|
+
return formatBulletedLines(`${getErrorSymbol()} ${error.error.failures.length} package(s) failed to resolve`, partialFailureMessages(error.error).map((message) => {
|
|
17
|
+
return `- ${message}`;
|
|
18
|
+
}));
|
|
11
19
|
}
|
|
12
20
|
function formatPeerFailure(error) {
|
|
13
|
-
|
|
21
|
+
return formatBulletedLines(`${getErrorSymbol()} Pack of "${error.packageName}" is missing ${error.items.length} peer dependency(ies)`, error.items.map((item) => {
|
|
14
22
|
return `- "${item.packageName}" needs peer "${item.peer}"`;
|
|
15
|
-
});
|
|
16
|
-
const count = error.items.length;
|
|
17
|
-
const header = `${getErrorSymbol()} Pack of "${error.packageName}" is missing ${count} peer dependency(ies)`;
|
|
18
|
-
return [header, ...lines].join('\n');
|
|
19
|
-
}
|
|
20
|
-
function formatBundleDepFailure(packageName) {
|
|
21
|
-
const note = 'declares bundleDependencies which pack does not yet support without --vendor-dependencies';
|
|
22
|
-
return `${getErrorSymbol()} Package "${packageName}" ${note}`;
|
|
23
|
-
}
|
|
24
|
-
function formatPackageNotFound(packageName) {
|
|
25
|
-
return `${getErrorSymbol()} Package "${packageName}" is not declared in the packtory configuration`;
|
|
23
|
+
}));
|
|
26
24
|
}
|
|
25
|
+
const packageFailureSuffixByType = {
|
|
26
|
+
[packPackageFailureType.bundleDependenciesUnsupported]: 'declares bundleDependencies which pack does not yet support without --vendor-dependencies',
|
|
27
|
+
[packPackageFailureType.packageNotFound]: 'is not declared in the packtory configuration'
|
|
28
|
+
};
|
|
27
29
|
function formatVendorSymlinkOutsidePackageFailure(error) {
|
|
28
30
|
const reason = 'rejected a vendored dependency with a symlink that escapes its package directory';
|
|
29
31
|
const header = `${getErrorSymbol()} Pack of "${error.packageName}" ${reason}`;
|
|
30
32
|
const target = `which resolves to "${error.resolvedTargetPath}"`;
|
|
31
33
|
const details = `- "${error.vendoredPackageName}" contains "${error.entryRelativePath}" ${target}`;
|
|
32
|
-
return
|
|
34
|
+
return `${header}\n${details}`;
|
|
33
35
|
}
|
|
34
36
|
function formatVendorInvalidDependencyNameFailure(error) {
|
|
35
37
|
const reason = 'rejected a vendored package.json with an invalid dependency name';
|
|
@@ -37,47 +39,38 @@ function formatVendorInvalidDependencyNameFailure(error) {
|
|
|
37
39
|
const sourceLabel = error.sourcePackageName === undefined ? 'the configured external set' : `"${error.sourcePackageName}"`;
|
|
38
40
|
const tail = 'which is not a valid npm package name';
|
|
39
41
|
const details = `- ${sourceLabel} declares dependency "${error.invalidDependencyName}" ${tail}`;
|
|
40
|
-
return
|
|
42
|
+
return `${header}\n${details}`;
|
|
41
43
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return
|
|
44
|
+
function formatPackageNameFailure(error) {
|
|
45
|
+
return `${getErrorSymbol()} Package "${error.packageName}" ${packageFailureSuffixByType[error.type]}`;
|
|
46
|
+
}
|
|
47
|
+
function isIssueFailure(error) {
|
|
48
|
+
return error.type === configErrorType || error.type === checksErrorType;
|
|
47
49
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
function isPackageNameFailure(error) {
|
|
51
|
+
return (error.type === packPackageFailureType.bundleDependenciesUnsupported ||
|
|
52
|
+
error.type === packPackageFailureType.packageNotFound);
|
|
53
|
+
}
|
|
54
|
+
function formatNonIssuePackFailure(error) {
|
|
55
|
+
if (error.type === partialFailureType) {
|
|
56
|
+
return formatPartialResolveFailure(error);
|
|
51
57
|
}
|
|
52
|
-
if (error
|
|
53
|
-
return
|
|
58
|
+
if (isPackageNameFailure(error)) {
|
|
59
|
+
return formatPackageNameFailure(error);
|
|
54
60
|
}
|
|
55
|
-
if (error.type ===
|
|
56
|
-
return
|
|
61
|
+
if (error.type === packPackageFailureType.peerDependenciesUnsatisfied) {
|
|
62
|
+
return formatPeerFailure(error);
|
|
57
63
|
}
|
|
58
|
-
if (error.type ===
|
|
64
|
+
if (error.type === packPackageFailureType.vendorInvalidDependencyName) {
|
|
59
65
|
return formatVendorInvalidDependencyNameFailure(error);
|
|
60
66
|
}
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
function isConfigOrCheckError(error) {
|
|
64
|
-
return error.type === 'config' || error.type === 'checks';
|
|
65
|
-
}
|
|
66
|
-
function isPackPackageError(error) {
|
|
67
|
-
return (error.type === 'package-not-found' ||
|
|
68
|
-
error.type === 'bundle-dependencies-unsupported' ||
|
|
69
|
-
error.type === 'peer-dependencies-unsatisfied' ||
|
|
70
|
-
error.type === 'vendor-symlink-target-outside-package' ||
|
|
71
|
-
error.type === 'vendor-invalid-dependency-name');
|
|
67
|
+
return formatVendorSymlinkOutsidePackageFailure(error);
|
|
72
68
|
}
|
|
73
69
|
function formatPackFailure(error) {
|
|
74
|
-
if (
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
if (isPackPackageError(error)) {
|
|
78
|
-
return formatPackPackageFailure(error);
|
|
70
|
+
if (isIssueFailure(error)) {
|
|
71
|
+
return formatIssueList(issuePrefixByType[error.type], error.issues);
|
|
79
72
|
}
|
|
80
|
-
return
|
|
73
|
+
return formatNonIssuePackFailure(error);
|
|
81
74
|
}
|
|
82
75
|
function reportOutcome(log, outcome, flags) {
|
|
83
76
|
if (outcome.result.isErr) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/pack-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pack-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/pack-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACH,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAErB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvE,MAAM,iBAAiB,GAAG;IACtB,CAAC,eAAe,CAAC,EAAE,gCAAgC;IACnD,CAAC,eAAe,CAAC,EAAE,eAAe;CAC5B,CAAC;AAkBX,SAAS,eAAe,CAAC,MAAc,EAAE,MAAyB;IAC9D,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,MAAM,WAAW,CAAC;IAC/C,OAAO,GAAG,cAAc,EAAE,IAAI,MAAM,eAAe,UAAU,SAAS,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;AAChG,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc,EAAE,OAA0B;IACnE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,SA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,KAAK,CAAC,OAAO;YACtB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;SAC/C,CAAC,CAAC;QACH,eAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;YAAS,CAAC;QACP,eAAe,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC"}
|
|
@@ -2,9 +2,6 @@ import { buildPreviewDocument } from "../../report/preview/preview-document.js";
|
|
|
2
2
|
import { renderHtmlReport } from "../../report/html-renderer/html-renderer.js";
|
|
3
3
|
import { renderFailureOnlyTerminalPreview, renderTerminalPreview } from "../../report/terminal-renderer/terminal-preview-renderer.js";
|
|
4
4
|
import { createEmptyReport } from "./report-persistence.js";
|
|
5
|
-
function isPreviewableResult(result) {
|
|
6
|
-
return result.isOk || (result.error.type === 'partial' && result.error.succeeded.length > 0);
|
|
7
|
-
}
|
|
8
5
|
async function renderOpenedReport(deps, document) {
|
|
9
6
|
const filePath = deps.createTemporaryFilePath();
|
|
10
7
|
await deps.fileManager.writeFile(filePath, renderHtmlReport(document));
|
|
@@ -13,16 +10,16 @@ async function renderOpenedReport(deps, document) {
|
|
|
13
10
|
deps.log(filePath);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
async function renderInlinePreview(deps, document
|
|
17
|
-
if (
|
|
13
|
+
async function renderInlinePreview(deps, document) {
|
|
14
|
+
if (document.previewable) {
|
|
18
15
|
await deps.pageOutput(renderTerminalPreview(document));
|
|
19
16
|
}
|
|
20
17
|
else {
|
|
21
18
|
deps.log(renderFailureOnlyTerminalPreview(document).trimEnd());
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
async function renderDocument(deps, document
|
|
25
|
-
await (deps.flags.open ? renderOpenedReport(deps, document) : renderInlinePreview(deps, document
|
|
21
|
+
async function renderDocument(deps, document) {
|
|
22
|
+
await (deps.flags.open ? renderOpenedReport(deps, document) : renderInlinePreview(deps, document));
|
|
26
23
|
}
|
|
27
24
|
export async function runPreviewHandler(deps) {
|
|
28
25
|
const { packtory, spinnerRenderer, configLoader, fileManager } = deps;
|
|
@@ -37,7 +34,7 @@ export async function runPreviewHandler(deps) {
|
|
|
37
34
|
dryRun: true,
|
|
38
35
|
fileManager
|
|
39
36
|
});
|
|
40
|
-
await renderDocument(deps, document
|
|
37
|
+
await renderDocument(deps, document);
|
|
41
38
|
return outcome.result.isErr ? 1 : 0;
|
|
42
39
|
}
|
|
43
40
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/preview-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,0CAA0C,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACH,gCAAgC,EAChC,qBAAqB,EACxB,MAAM,6DAA6D,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"preview-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/preview-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,0CAA0C,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EACH,gCAAgC,EAChC,qBAAqB,EACxB,MAAM,6DAA6D,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAgB5D,KAAK,UAAU,kBAAkB,CAC7B,IAA8F,EAC9F,QAAyB;IAEzB,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAChD,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvE,MAAM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C,MAAM;YACN,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,IAAI;YACZ,WAAW;SACd,CAAC,CAAC;QACH,MAAM,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACP,eAAe,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
+
import { succeededResultsFrom } from "packtory/packtory/partial-result.js";
|
|
1
2
|
import { buildReleaseDiffDocument } from "../../report/release-diff/release-diff-document.js";
|
|
2
3
|
import { renderFailureOnlyTerminalReleaseDiff, renderTerminalReleaseDiff } from "../../report/terminal-renderer/terminal-release-diff-renderer.js";
|
|
3
|
-
function succeededPackagesFrom(result) {
|
|
4
|
-
if (result.isOk) {
|
|
5
|
-
return result.value;
|
|
6
|
-
}
|
|
7
|
-
if (result.error.type === 'partial') {
|
|
8
|
-
return result.error.succeeded;
|
|
9
|
-
}
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
4
|
async function renderDocument(deps, document) {
|
|
13
5
|
if (document.previewable) {
|
|
14
6
|
await deps.pageOutput(renderTerminalReleaseDiff(document));
|
|
@@ -25,7 +17,7 @@ export async function runReleaseDiffHandler(deps) {
|
|
|
25
17
|
const document = buildReleaseDiffDocument({
|
|
26
18
|
report: outcome.getReport(),
|
|
27
19
|
result: outcome.result,
|
|
28
|
-
packages:
|
|
20
|
+
packages: succeededResultsFrom(outcome.result)
|
|
29
21
|
});
|
|
30
22
|
await renderDocument(deps, document);
|
|
31
23
|
return outcome.result.isErr ? 1 : 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-diff-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/release-diff-handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"release-diff-handler.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/runner/release-diff-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAA4B,MAAM,oDAAoD,CAAC;AACxH,OAAO,EACH,oCAAoC,EACpC,yBAAyB,EAC5B,MAAM,kEAAkE,CAAC;AAc1E,KAAK,UAAU,cAAc,CACzB,IAAwD,EACxD,QAA6B;IAE7B,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3D,OAAO;IACX,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,oCAAoC,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAA4B;IACpE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACzD,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAClE,eAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,wBAAwB,CAAC;YACtC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE;YAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC;SACjD,CAAC,CAAC;QACH,MAAM,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACP,eAAe,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { bold, green, red } from 'yoctocolors';
|
|
2
|
+
import { spinnerResultStatus } from "./terminal-spinner-renderer.js";
|
|
2
3
|
function getErrorSymbol() {
|
|
3
4
|
return bold(red('✖'));
|
|
4
5
|
}
|
|
@@ -9,7 +10,7 @@ function renderProgressLine(label, message) {
|
|
|
9
10
|
return `${label}: ${message}`;
|
|
10
11
|
}
|
|
11
12
|
function renderStopLine(status, label, message) {
|
|
12
|
-
const symbol = status ===
|
|
13
|
+
const symbol = status === spinnerResultStatus.success ? getSuccessSymbol() : getErrorSymbol();
|
|
13
14
|
return `${symbol} ${renderProgressLine(label, message)}`;
|
|
14
15
|
}
|
|
15
16
|
export function createLineSpinnerRenderer(dependencies) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-spinner-renderer.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/spinner/line-spinner-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"line-spinner-renderer.js","sourceRoot":"","sources":["../../../../../source/command-line-interface/spinner/line-spinner-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAgC,MAAM,gCAAgC,CAAC;AAQnG,SAAS,cAAc;IACnB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,gBAAgB;IACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa,EAAE,OAAe;IACtD,OAAO,GAA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pB,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,OAAO;YACH,UAAU,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -46,9 +46,6 @@ export function createSpinnerSharedLayout(slotCount) {
|
|
|
46
46
|
headerByteLength
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
function getCurrentTimeInMilliseconds() {
|
|
50
|
-
return Date.now();
|
|
51
|
-
}
|
|
52
49
|
function stateToByte(state) {
|
|
53
50
|
return stateToByteMap[state];
|
|
54
51
|
}
|
|
@@ -66,36 +63,112 @@ const messageSlice = {
|
|
|
66
63
|
contentCapacity: messageByteLength,
|
|
67
64
|
lengthOffset: slotMessageLengthOffset
|
|
68
65
|
};
|
|
66
|
+
function isPendingRenderedMutationWaitIteration(iteration) {
|
|
67
|
+
return 'nextCurrent' in iteration;
|
|
68
|
+
}
|
|
69
|
+
function renderedMutationWaitIterationResult(iteration) {
|
|
70
|
+
return 'result' in iteration && iteration.result === true;
|
|
71
|
+
}
|
|
72
|
+
function getRenderedMutationWaitAttemptBudget(timeoutMs) {
|
|
73
|
+
return Math.min(maximumRenderedMutationWaitAttempts, Math.max(Math.ceil(timeoutMs), 1));
|
|
74
|
+
}
|
|
69
75
|
function waitForRenderedMutationStep(args) {
|
|
70
|
-
const
|
|
76
|
+
const waitStatus = args.atomics.wait(args.headerInt32, headerRenderedMutationIndex, args.expectedMutation, args.timeoutMs);
|
|
71
77
|
const current = args.atomics.load(args.headerInt32, headerRenderedMutationIndex);
|
|
72
78
|
return {
|
|
73
79
|
current,
|
|
74
|
-
remainingMs: args.
|
|
75
|
-
timedOutWithoutProgress:
|
|
80
|
+
remainingMs: args.deadline - args.now(),
|
|
81
|
+
timedOutWithoutProgress: waitStatus === 'timed-out' && current === args.expectedMutation
|
|
76
82
|
};
|
|
77
83
|
}
|
|
78
|
-
function
|
|
84
|
+
function getRenderedMutationWaitResult(current, remainingMs, mutation) {
|
|
85
|
+
if (current >= mutation) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (remainingMs <= 0) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
function getRenderedMutationWaitStepResult(current, remainingMs, step, mutation) {
|
|
94
|
+
const waitResult = getRenderedMutationWaitResult(step.current, step.remainingMs, mutation);
|
|
95
|
+
if (waitResult !== undefined) {
|
|
96
|
+
return waitResult;
|
|
97
|
+
}
|
|
98
|
+
if (step.timedOutWithoutProgress) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (step.current === current && step.remainingMs > remainingMs) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
function advanceRenderedMutationWait(args) {
|
|
107
|
+
const currentResult = getRenderedMutationWaitResult(args.current, args.remainingMs, args.mutation);
|
|
108
|
+
if (currentResult !== undefined) {
|
|
109
|
+
return { result: currentResult };
|
|
110
|
+
}
|
|
111
|
+
const step = waitForRenderedMutationStep({
|
|
112
|
+
atomics: args.atomics,
|
|
113
|
+
headerInt32: args.headerInt32,
|
|
114
|
+
now: args.now,
|
|
115
|
+
deadline: args.deadline,
|
|
116
|
+
expectedMutation: args.current,
|
|
117
|
+
timeoutMs: Math.min(args.remainingMs, args.timeoutMs)
|
|
118
|
+
});
|
|
119
|
+
const stepResult = getRenderedMutationWaitStepResult(args.current, args.remainingMs, step, args.mutation);
|
|
120
|
+
if (stepResult !== undefined) {
|
|
121
|
+
return { result: stepResult };
|
|
122
|
+
}
|
|
79
123
|
return {
|
|
80
|
-
|
|
81
|
-
|
|
124
|
+
nextCurrent: args.atomics.load(args.headerInt32, headerRenderedMutationIndex),
|
|
125
|
+
nextRemainingMs: args.deadline - args.now()
|
|
82
126
|
};
|
|
83
127
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
128
|
+
function waitForRenderedMutationWithinBudget(args) {
|
|
129
|
+
const deadline = args.now() + args.timeoutMs;
|
|
130
|
+
let current = args.atomics.load(args.headerInt32, headerRenderedMutationIndex);
|
|
131
|
+
let remainingMs = deadline - args.now();
|
|
132
|
+
for (let remainingBudget = getRenderedMutationWaitAttemptBudget(args.timeoutMs); remainingBudget > 0; remainingBudget -= 1) {
|
|
133
|
+
const iteration = advanceRenderedMutationWait({
|
|
134
|
+
atomics: args.atomics,
|
|
135
|
+
headerInt32: args.headerInt32,
|
|
136
|
+
now: args.now,
|
|
137
|
+
deadline,
|
|
138
|
+
mutation: args.mutation,
|
|
139
|
+
current,
|
|
140
|
+
remainingMs,
|
|
141
|
+
timeoutMs: args.timeoutMs
|
|
142
|
+
});
|
|
143
|
+
if (!isPendingRenderedMutationWaitIteration(iteration)) {
|
|
144
|
+
return renderedMutationWaitIterationResult(iteration);
|
|
145
|
+
}
|
|
146
|
+
current = iteration.nextCurrent;
|
|
147
|
+
remainingMs = iteration.nextRemainingMs;
|
|
148
|
+
}
|
|
149
|
+
return getRenderedMutationWaitResult(current, remainingMs, args.mutation) ?? false;
|
|
150
|
+
}
|
|
151
|
+
function writeStringIntoSlot(views, slotIndex, slice, value) {
|
|
152
|
+
const target = views
|
|
153
|
+
.slotBytes(slotIndex)
|
|
154
|
+
.subarray(slice.contentOffset, slice.contentOffset + slice.contentCapacity);
|
|
155
|
+
target.fill(0);
|
|
156
|
+
const { written } = textEncoder.encodeInto(value, target);
|
|
157
|
+
views.slotData(slotIndex).setUint16(slice.lengthOffset, written, true);
|
|
86
158
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
step.timedOutWithoutProgress);
|
|
159
|
+
function readStringFromSlot(views, slotIndex, slice) {
|
|
160
|
+
const length = views.slotData(slotIndex).getUint16(slice.lengthOffset, true);
|
|
161
|
+
return textDecoder.decode(views.slotBytes(slotIndex).subarray(slice.contentOffset, slice.contentOffset + length));
|
|
91
162
|
}
|
|
92
|
-
function
|
|
163
|
+
export function createSpinnerSharedAccessors(buffer, layout, dependencies = {}) {
|
|
164
|
+
const atomics = dependencies.atomics ?? Atomics;
|
|
165
|
+
const now = dependencies.now ?? Date.now;
|
|
93
166
|
const headerInt32 = new Int32Array(buffer);
|
|
94
167
|
const headerUint32 = new Uint32Array(buffer);
|
|
95
168
|
const slotOffset = (slotIndex) => {
|
|
96
169
|
return layout.headerByteLength + slotIndex * layout.slotByteLength;
|
|
97
170
|
};
|
|
98
|
-
|
|
171
|
+
const views = {
|
|
99
172
|
headerInt32,
|
|
100
173
|
headerUint32,
|
|
101
174
|
slotInt32: (slotIndex) => {
|
|
@@ -108,42 +181,27 @@ function createViews(buffer, layout) {
|
|
|
108
181
|
return new DataView(buffer, slotOffset(slotIndex), layout.slotByteLength);
|
|
109
182
|
}
|
|
110
183
|
};
|
|
111
|
-
|
|
112
|
-
function writeStringIntoSlot(views, slotIndex, slice, value) {
|
|
113
|
-
const target = views
|
|
114
|
-
.slotBytes(slotIndex)
|
|
115
|
-
.subarray(slice.contentOffset, slice.contentOffset + slice.contentCapacity);
|
|
116
|
-
target.fill(0);
|
|
117
|
-
const { written } = textEncoder.encodeInto(value, target);
|
|
118
|
-
views.slotData(slotIndex).setUint16(slice.lengthOffset, written, true);
|
|
119
|
-
}
|
|
120
|
-
function readStringFromSlot(views, slotIndex, slice) {
|
|
121
|
-
const length = views.slotData(slotIndex).getUint16(slice.lengthOffset, true);
|
|
122
|
-
return textDecoder.decode(views.slotBytes(slotIndex).subarray(slice.contentOffset, slice.contentOffset + length));
|
|
123
|
-
}
|
|
124
|
-
function readSlotContent(views, slotIndex) {
|
|
125
|
-
return {
|
|
126
|
-
state: byteToState(views.slotData(slotIndex).getUint8(slotStateOffset)),
|
|
127
|
-
label: readStringFromSlot(views, slotIndex, labelSlice),
|
|
128
|
-
message: readStringFromSlot(views, slotIndex, messageSlice)
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
export function createSpinnerSharedAccessors(buffer, layout, dependencies = {}) {
|
|
132
|
-
const atomics = dependencies.atomics ?? Atomics;
|
|
133
|
-
const now = dependencies.now ?? getCurrentTimeInMilliseconds;
|
|
134
|
-
const views = createViews(buffer, layout);
|
|
135
|
-
function writeStateByte(slotIndex, stateByte) {
|
|
136
|
-
views.slotData(slotIndex).setUint8(slotStateOffset, stateByte);
|
|
137
|
-
}
|
|
138
|
-
function readSlotGeneration(slotIndex) {
|
|
139
|
-
return atomics.load(views.slotInt32(slotIndex), slotGenerationIndex);
|
|
140
|
-
}
|
|
141
|
-
function readSlotAttempt(slotIndex) {
|
|
184
|
+
function readSlotSnapshot(slotIndex) {
|
|
142
185
|
return {
|
|
143
|
-
|
|
144
|
-
|
|
186
|
+
state: byteToState(views.slotData(slotIndex).getUint8(slotStateOffset)),
|
|
187
|
+
label: readStringFromSlot(views, slotIndex, labelSlice),
|
|
188
|
+
message: readStringFromSlot(views, slotIndex, messageSlice)
|
|
145
189
|
};
|
|
146
190
|
}
|
|
191
|
+
function readStableSlotAfterGeneration(slotIndex, generationBefore, remainingAttempts) {
|
|
192
|
+
const slot = readSlotSnapshot(slotIndex);
|
|
193
|
+
const generationAfter = atomics.load(views.slotInt32(slotIndex), slotGenerationIndex);
|
|
194
|
+
if (generationAfter === generationBefore) {
|
|
195
|
+
return slot;
|
|
196
|
+
}
|
|
197
|
+
if (remainingAttempts > 1) {
|
|
198
|
+
return readStableSlotAfterGeneration(slotIndex, generationAfter, remainingAttempts - 1);
|
|
199
|
+
}
|
|
200
|
+
throw new Error('Failed to read a stable spinner slot snapshot');
|
|
201
|
+
}
|
|
202
|
+
function readStableSlot(slotIndex) {
|
|
203
|
+
return readStableSlotAfterGeneration(slotIndex, atomics.load(views.slotInt32(slotIndex), slotGenerationIndex), maximumReadSlotAttempts);
|
|
204
|
+
}
|
|
147
205
|
return {
|
|
148
206
|
layout,
|
|
149
207
|
buffer,
|
|
@@ -170,26 +228,13 @@ export function createSpinnerSharedAccessors(buffer, layout, dependencies = {})
|
|
|
170
228
|
atomics.notify(views.headerInt32, headerRenderedMutationIndex);
|
|
171
229
|
},
|
|
172
230
|
waitForRenderedMutation(mutation, timeoutMs) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const waitTimeoutMs = Math.min(state.remainingMs, timeoutMs);
|
|
181
|
-
const step = waitForRenderedMutationStep({
|
|
182
|
-
atomics,
|
|
183
|
-
headerInt32: views.headerInt32,
|
|
184
|
-
expectedMutation: state.current,
|
|
185
|
-
timeoutMs: waitTimeoutMs,
|
|
186
|
-
readRemainingMs
|
|
187
|
-
});
|
|
188
|
-
if (shouldAbortWaitingForRenderedMutation(state, step, mutation)) {
|
|
189
|
-
return step.current >= mutation;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return state.current >= mutation;
|
|
231
|
+
return waitForRenderedMutationWithinBudget({
|
|
232
|
+
atomics,
|
|
233
|
+
headerInt32: views.headerInt32,
|
|
234
|
+
mutation,
|
|
235
|
+
now,
|
|
236
|
+
timeoutMs
|
|
237
|
+
});
|
|
193
238
|
},
|
|
194
239
|
requestShutdown() {
|
|
195
240
|
atomics.store(views.headerInt32, headerControlIndex, controlShutdownValue);
|
|
@@ -201,30 +246,11 @@ export function createSpinnerSharedAccessors(buffer, layout, dependencies = {})
|
|
|
201
246
|
atomics.add(views.slotInt32(slotIndex), slotGenerationIndex, 1);
|
|
202
247
|
},
|
|
203
248
|
writeSlot(slotIndex, state, label, message) {
|
|
204
|
-
|
|
249
|
+
views.slotData(slotIndex).setUint8(slotStateOffset, stateToByte(state));
|
|
205
250
|
writeStringIntoSlot(views, slotIndex, labelSlice, label);
|
|
206
251
|
writeStringIntoSlot(views, slotIndex, messageSlice, message);
|
|
207
252
|
},
|
|
208
|
-
readSlot
|
|
209
|
-
// Seqlock retry: writers atomically bump the slot generation after
|
|
210
|
-
// updating the (non-atomic) label/message bytes; if the generation
|
|
211
|
-
// moves between the two reads we observed a torn write and retry.
|
|
212
|
-
let generationBefore = readSlotGeneration(slotIndex);
|
|
213
|
-
const attempts = Array.from({ length: maximumReadSlotAttempts + 1 }, (_value, index) => {
|
|
214
|
-
return maximumReadSlotAttempts - index;
|
|
215
|
-
});
|
|
216
|
-
for (const remainingAttempts of attempts) {
|
|
217
|
-
if (remainingAttempts === 0) {
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
const attemptResult = readSlotAttempt(slotIndex);
|
|
221
|
-
if (attemptResult.generationAfter === generationBefore) {
|
|
222
|
-
return attemptResult.slot;
|
|
223
|
-
}
|
|
224
|
-
generationBefore = attemptResult.generationAfter;
|
|
225
|
-
}
|
|
226
|
-
throw new Error('Failed to read a stable spinner slot snapshot');
|
|
227
|
-
}
|
|
253
|
+
readSlot: readStableSlot
|
|
228
254
|
};
|
|
229
255
|
}
|
|
230
256
|
//# sourceMappingURL=spinner-shared-state.js.map
|