@packtory/cli 0.0.8 → 0.0.10
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.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/spinner-worker-loop.js +94 -0
- package/command-line-interface/spinner-worker-loop.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 +14 -9
- package/packages/command-line-interface/command-line-interface.entry-point.d.ts +1 -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/packages/command-line-interface/spinner-boot.entry-point.js +25 -0
- package/packages/command-line-interface/spinner-boot.entry-point.js.map +1 -0
- package/packages/command-line-interface/spinner-worker.entry-point.js +16 -0
- package/packages/command-line-interface/spinner-worker.entry-point.js.map +1 -0
- 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
- package/sbom.cdx.json +118 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { writeSync } from 'node:fs';
|
|
2
|
+
import { setInterval as scheduleInterval, clearInterval as cancelInterval } from 'node:timers';
|
|
3
|
+
import { workerData } from 'node:worker_threads';
|
|
4
|
+
import { isSpinnerWorkerInput, startSpinnerWorker } from "../../command-line-interface/spinner-worker-loop.js";
|
|
5
|
+
if (!isSpinnerWorkerInput(workerData)) {
|
|
6
|
+
throw new TypeError('Spinner worker started with invalid workerData');
|
|
7
|
+
}
|
|
8
|
+
startSpinnerWorker(workerData, {
|
|
9
|
+
write: (fileDescriptor, chunk) => {
|
|
10
|
+
// eslint-disable-next-line node/no-sync -- the worker holds the only writer to fd 1 and synchronous writes are the simplest way to render
|
|
11
|
+
writeSync(fileDescriptor, chunk);
|
|
12
|
+
},
|
|
13
|
+
setInterval: scheduleInterval,
|
|
14
|
+
clearInterval: cancelInterval
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=spinner-worker.entry-point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner-worker.entry-point.js","sourceRoot":"","sources":["../../../../../source/packages/command-line-interface/spinner-worker.entry-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAE/G,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;IACpC,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;AAC1E,CAAC;AAED,kBAAkB,CAAC,UAAU,EAAE;IAC3B,KAAK,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,EAAE;QAC7B,0IAA0I;QAC1I,SAAS,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,WAAW,EAAE,gBAAgB;IAC7B,aAAa,EAAE,cAAc;CAChC,CAAC,CAAC"}
|
package/readme.md
CHANGED
|
@@ -18,12 +18,44 @@ packtory <command> [options]
|
|
|
18
18
|
|
|
19
19
|
**Commands:**
|
|
20
20
|
|
|
21
|
+
- **preview:** Runs a fresh dry-run build with report collection enabled and shows a human-oriented preview of the emitted package contents, file statuses, and changed-file diffs.
|
|
21
22
|
- **publish:** Bundles and publishes npm packages based on the configuration in `packtory.config.js`.
|
|
22
23
|
|
|
23
24
|
**Options:**
|
|
24
25
|
|
|
25
26
|
- **--no-dry-run:** Disables dry-run mode (enabled by default), allowing actual publishing.
|
|
27
|
+
- **preview --open:** Generates the same fresh preview report as `packtory preview`, writes a temporary HTML file, and opens it with the platform opener.
|
|
28
|
+
- **publish --report-json:** Writes `packtory-report.json`, the machine-readable `BuildReport`.
|
|
29
|
+
- **publish --report-html:** Writes `packtory-report.html`, the rich HTML report used by `packtory preview --open`.
|
|
30
|
+
|
|
31
|
+
**Preview behavior:**
|
|
32
|
+
|
|
33
|
+
- `packtory preview` always performs a fresh dry-run build. It does not reuse prior report files.
|
|
34
|
+
- Previewable runs are shown through `$PAGER` when possible, otherwise `less -R`, otherwise standard output.
|
|
35
|
+
- Failure-only runs skip the pager and print diagnostics directly to standard output.
|
|
36
|
+
- The terminal preview always carries a visible dry-run label.
|
|
37
|
+
- `packtory preview` exits with code `0` on a clean run and `1` on config errors, check failures, or partial failures.
|
|
38
|
+
- `packtory preview --open` still exits successfully if report generation worked but opening the file failed; in that case it prints the temporary file path.
|
|
39
|
+
|
|
40
|
+
**Report outputs:**
|
|
41
|
+
|
|
42
|
+
- `--report-json` keeps the durable structured `BuildReport` contract.
|
|
43
|
+
- `--report-html` and `preview --open` render the same human-facing HTML document.
|
|
44
|
+
- The HTML report can still be written for failing runs when report data is available.
|
|
26
45
|
|
|
27
46
|
**Configuration:**
|
|
28
47
|
|
|
29
|
-
Create a `packtory.config.js` file in your project to define the configuration. Refer to the [full documentation](
|
|
48
|
+
Create a `packtory.config.js` file in your project to define the configuration. Refer to the [full documentation](../../../readme.md) for detailed configuration options.
|
|
49
|
+
Your root `package.json` must declare `"type": "module"`.
|
|
50
|
+
|
|
51
|
+
**One-time-password support:**
|
|
52
|
+
|
|
53
|
+
- If the registry challenges a publish with a one-time password, the CLI prompts for it when running in an interactive TTY.
|
|
54
|
+
- The prompt times out after 90 seconds.
|
|
55
|
+
- Non-interactive runs cannot answer a one-time-password challenge. For CI, prefer an auth method that does not require live one-time-password entry, such as npm trusted publishing / OIDC or a suitable registry token setup.
|
|
56
|
+
|
|
57
|
+
**Publish settings:**
|
|
58
|
+
|
|
59
|
+
Every package needs a `publishSettings` value, either set in `commonPackageSettings` as a default or on each package entry directly. If neither is set, the CLI exits with `publishSettings must be set in commonPackageSettings or in every package`. See the [main configuration docs](../../../readme.md) for the full shape and the access ↔ provenance constraint.
|
|
60
|
+
|
|
61
|
+
For the full list of publish-time errors and remediation, see [Supply Chain → CLI error reference](../../../documentation/supply-chain.md#cli-error-reference).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function collectChangedArtifacts(tree) {
|
|
2
|
+
return tree.flatMap((node) => {
|
|
3
|
+
if (node.type !== 'file') {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
const { artifact } = node;
|
|
7
|
+
return artifact.diff === undefined ? [] : [{ ...artifact, diff: artifact.diff }];
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=changed-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changed-artifacts.js","sourceRoot":"","sources":["../../../../source/report/changed-artifacts.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,uBAAuB,CAAC,IAAoC;IACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACd,CAAC;QACD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-escaping.js","sourceRoot":"","sources":["../../../../source/report/html-escaping.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,KAAK;SACP,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/* eslint-disable @stylistic/max-len, complexity -- the HTML report renderer is intentionally template-heavy */
|
|
2
|
+
/* cspell:words Palatino Menlo */
|
|
3
|
+
import { artifactBadgeLabel, artifactStatusLabel } from "./preview-document.js";
|
|
4
|
+
import { collectChangedArtifacts } from "./changed-artifacts.js";
|
|
5
|
+
import { escapeHtml } from "./html-escaping.js";
|
|
6
|
+
const jsonIndentSpaces = 2;
|
|
7
|
+
function renderJsonBlock(value) {
|
|
8
|
+
return `<pre>${escapeHtml(JSON.stringify(value, undefined, jsonIndentSpaces))}</pre>`;
|
|
9
|
+
}
|
|
10
|
+
function renderSection(title, value) {
|
|
11
|
+
return `<details class="diagnostic secondary"><summary>${escapeHtml(title)}</summary>${renderJsonBlock(value)}</details>`;
|
|
12
|
+
}
|
|
13
|
+
function formatBytes(bytes) {
|
|
14
|
+
return `${bytes} B`;
|
|
15
|
+
}
|
|
16
|
+
function renderBadge(text, className) {
|
|
17
|
+
return `<span class="badge ${className}">${escapeHtml(text)}</span>`;
|
|
18
|
+
}
|
|
19
|
+
function renderSummaryCard(label, value) {
|
|
20
|
+
return `<div class="summary-card"><span class="summary-label">${escapeHtml(label)}</span><strong>${escapeHtml(String(value))}</strong></div>`;
|
|
21
|
+
}
|
|
22
|
+
function renderIssues(issueItems) {
|
|
23
|
+
return `<section class="issues"><h2>Issues</h2><ul>${issueItems}</ul></section>`;
|
|
24
|
+
}
|
|
25
|
+
function renderArtifactNode(node) {
|
|
26
|
+
if (node.type === 'directory') {
|
|
27
|
+
return `<li class="tree-row directory" style="--depth:${node.depth}"><span class="tree-name">${escapeHtml(node.name)}/</span></li>`;
|
|
28
|
+
}
|
|
29
|
+
const { artifact } = node;
|
|
30
|
+
const badges = [
|
|
31
|
+
renderBadge(artifactStatusLabel(artifact.status), `status-${artifact.status}`),
|
|
32
|
+
...artifact.badges.map((badge) => {
|
|
33
|
+
return renderBadge(artifactBadgeLabel(badge), 'secondary');
|
|
34
|
+
})
|
|
35
|
+
].join('');
|
|
36
|
+
return `<li class="tree-row file" style="--depth:${node.depth}">
|
|
37
|
+
<span class="tree-name">${escapeHtml(node.name)}</span>
|
|
38
|
+
<span class="tree-meta">${escapeHtml(artifact.kind)} · ${escapeHtml(formatBytes(artifact.sizeBytes))}</span>
|
|
39
|
+
<span class="tree-badges">${badges}</span>
|
|
40
|
+
</li>`;
|
|
41
|
+
}
|
|
42
|
+
function renderDiffLine(line) {
|
|
43
|
+
return `<div class="diff-line ${line.type}">${escapeHtml(line.text)}</div>`;
|
|
44
|
+
}
|
|
45
|
+
function renderDiffHunk(header, lines) {
|
|
46
|
+
let renderedLines = '';
|
|
47
|
+
for (const line of lines) {
|
|
48
|
+
renderedLines += renderDiffLine(line);
|
|
49
|
+
}
|
|
50
|
+
return `<div class="diff-hunk"><div class="diff-header">${escapeHtml(header)}</div>${renderedLines}</div>`;
|
|
51
|
+
}
|
|
52
|
+
function renderArtifactDiff(artifact) {
|
|
53
|
+
let hunks = '';
|
|
54
|
+
for (const hunk of artifact.diff) {
|
|
55
|
+
hunks += renderDiffHunk(hunk.header, hunk.lines);
|
|
56
|
+
}
|
|
57
|
+
return `<details class="diff" open><summary>${escapeHtml(artifact.path)}</summary>${hunks}</details>`;
|
|
58
|
+
}
|
|
59
|
+
function renderDiffs(pkg) {
|
|
60
|
+
const changedFiles = collectChangedArtifacts(pkg.tree);
|
|
61
|
+
if (changedFiles.length === 0) {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
let sections = '';
|
|
65
|
+
for (const artifact of changedFiles) {
|
|
66
|
+
sections += renderArtifactDiff(artifact);
|
|
67
|
+
}
|
|
68
|
+
return `<section class="package-block"><h3>Changed files</h3>${sections}</section>`;
|
|
69
|
+
}
|
|
70
|
+
function renderEliminatedFiles(pkg) {
|
|
71
|
+
if (pkg.eliminatedSourceFiles.length === 0) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
let items = '';
|
|
75
|
+
for (const file of pkg.eliminatedSourceFiles) {
|
|
76
|
+
items += `<li><code>${escapeHtml(file.path)}</code> <span class="tree-meta">${escapeHtml(formatBytes(file.sourceBytes))}</span></li>`;
|
|
77
|
+
}
|
|
78
|
+
return `<section class="package-block">
|
|
79
|
+
<h3>Eliminated source files</h3>
|
|
80
|
+
<ul class="eliminated-list">${items}</ul>
|
|
81
|
+
</section>`;
|
|
82
|
+
}
|
|
83
|
+
function renderDiagnostics(pkg) {
|
|
84
|
+
const sections = [
|
|
85
|
+
pkg.diagnostics.inputs === undefined ? '' : renderSection('Inputs', pkg.diagnostics.inputs),
|
|
86
|
+
Object.keys(pkg.diagnostics.decisions).length === 0
|
|
87
|
+
? ''
|
|
88
|
+
: renderSection('Decisions', pkg.diagnostics.decisions),
|
|
89
|
+
pkg.diagnostics.outputs === undefined ? '' : renderSection('Outputs', pkg.diagnostics.outputs),
|
|
90
|
+
Object.keys(pkg.diagnostics.timings).length === 0 ? '' : renderSection('Timings (ms)', pkg.diagnostics.timings),
|
|
91
|
+
pkg.diagnostics.failure === undefined ? '' : renderSection('Failure', pkg.diagnostics.failure)
|
|
92
|
+
].join('');
|
|
93
|
+
if (sections === '') {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
return `<section class="package-block diagnostics"><h3>Diagnostics</h3>${sections}</section>`;
|
|
97
|
+
}
|
|
98
|
+
function renderFailure(pkg) {
|
|
99
|
+
if (pkg.failure === undefined) {
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
return `<p class="failure">Failed in stage <strong>${escapeHtml(pkg.failure.stage)}</strong>: ${escapeHtml(pkg.failure.message)}</p>`;
|
|
103
|
+
}
|
|
104
|
+
function renderPackage(pkg) {
|
|
105
|
+
const badges = [
|
|
106
|
+
renderBadge(pkg.hasChanges ? 'changed' : 'unchanged', pkg.hasChanges ? 'status-changed' : 'status-unchanged'),
|
|
107
|
+
...(pkg.versionTransition === undefined ? [] : [renderBadge(pkg.versionTransition, 'secondary')])
|
|
108
|
+
].join('');
|
|
109
|
+
return `<details class="package"${pkg.openByDefault ? ' open' : ''}>
|
|
110
|
+
<summary><span class="package-title">${escapeHtml(pkg.name)}</span><span class="package-summary">${badges}</span></summary>
|
|
111
|
+
${renderFailure(pkg)}
|
|
112
|
+
<section class="package-block">
|
|
113
|
+
<h3>Artifacts</h3>
|
|
114
|
+
<ul class="tree">${pkg.tree.map(renderArtifactNode).join('')}</ul>
|
|
115
|
+
</section>
|
|
116
|
+
${renderEliminatedFiles(pkg)}
|
|
117
|
+
${renderDiffs(pkg)}
|
|
118
|
+
${renderDiagnostics(pkg)}
|
|
119
|
+
</details>`;
|
|
120
|
+
}
|
|
121
|
+
const styles = `
|
|
122
|
+
:root {
|
|
123
|
+
color-scheme: light;
|
|
124
|
+
--bg: #f4f0e8;
|
|
125
|
+
--panel: #fffdf8;
|
|
126
|
+
--line: #d8cfc2;
|
|
127
|
+
--text: #2c2924;
|
|
128
|
+
--muted: #6b645a;
|
|
129
|
+
--changed: #b6540d;
|
|
130
|
+
--generated: #0b6e4f;
|
|
131
|
+
--unchanged: #4f6d7a;
|
|
132
|
+
--danger: #b42318;
|
|
133
|
+
--danger-bg: #fff1ef;
|
|
134
|
+
--diff-add: #e7f6ec;
|
|
135
|
+
--diff-remove: #fdecec;
|
|
136
|
+
--diff-header: #efe7da;
|
|
137
|
+
--shadow: 0 18px 50px rgba(63, 48, 29, 0.08);
|
|
138
|
+
}
|
|
139
|
+
* { box-sizing: border-box; }
|
|
140
|
+
body {
|
|
141
|
+
margin: 0;
|
|
142
|
+
background:
|
|
143
|
+
radial-gradient(circle at top left, rgba(193, 143, 71, 0.15), transparent 28rem),
|
|
144
|
+
linear-gradient(180deg, #f6f2e8 0%, var(--bg) 100%);
|
|
145
|
+
color: var(--text);
|
|
146
|
+
font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
|
|
147
|
+
}
|
|
148
|
+
main { max-width: 72rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
|
|
149
|
+
h1 { margin: 0 0 0.25rem; font-size: 2rem; }
|
|
150
|
+
h2, h3 { margin: 0 0 0.75rem; }
|
|
151
|
+
.meta { color: var(--muted); margin: 0; }
|
|
152
|
+
.header {
|
|
153
|
+
background: rgba(255, 253, 248, 0.82);
|
|
154
|
+
backdrop-filter: blur(14px);
|
|
155
|
+
border: 1px solid rgba(216, 207, 194, 0.85);
|
|
156
|
+
border-radius: 1.25rem;
|
|
157
|
+
padding: 1.5rem;
|
|
158
|
+
box-shadow: var(--shadow);
|
|
159
|
+
}
|
|
160
|
+
.mode-label {
|
|
161
|
+
display: inline-block;
|
|
162
|
+
font-size: 0.78rem;
|
|
163
|
+
letter-spacing: 0.08em;
|
|
164
|
+
text-transform: uppercase;
|
|
165
|
+
color: var(--muted);
|
|
166
|
+
margin-bottom: 0.65rem;
|
|
167
|
+
}
|
|
168
|
+
.summary {
|
|
169
|
+
display: grid;
|
|
170
|
+
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
|
|
171
|
+
gap: 0.75rem;
|
|
172
|
+
margin: 1.5rem 0;
|
|
173
|
+
}
|
|
174
|
+
.summary-card {
|
|
175
|
+
background: var(--panel);
|
|
176
|
+
border: 1px solid var(--line);
|
|
177
|
+
border-radius: 0.9rem;
|
|
178
|
+
padding: 0.95rem 1rem;
|
|
179
|
+
box-shadow: var(--shadow);
|
|
180
|
+
}
|
|
181
|
+
.summary-label {
|
|
182
|
+
display: block;
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
font-size: 0.82rem;
|
|
185
|
+
margin-bottom: 0.35rem;
|
|
186
|
+
}
|
|
187
|
+
.issues {
|
|
188
|
+
background: var(--danger-bg);
|
|
189
|
+
border: 1px solid rgba(180, 35, 24, 0.22);
|
|
190
|
+
border-radius: 0.9rem;
|
|
191
|
+
padding: 1rem 1.1rem;
|
|
192
|
+
margin: 1rem 0 0;
|
|
193
|
+
}
|
|
194
|
+
.packages { display: grid; gap: 1rem; }
|
|
195
|
+
details.package {
|
|
196
|
+
background: var(--panel);
|
|
197
|
+
border: 1px solid var(--line);
|
|
198
|
+
border-radius: 1rem;
|
|
199
|
+
box-shadow: var(--shadow);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
}
|
|
202
|
+
details.package > summary {
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
list-style: none;
|
|
205
|
+
display: flex;
|
|
206
|
+
align-items: center;
|
|
207
|
+
justify-content: space-between;
|
|
208
|
+
gap: 1rem;
|
|
209
|
+
padding: 1rem 1.25rem;
|
|
210
|
+
font-weight: 700;
|
|
211
|
+
background: rgba(255, 250, 241, 0.85);
|
|
212
|
+
}
|
|
213
|
+
details.package > summary::-webkit-details-marker { display: none; }
|
|
214
|
+
.package-title { font-size: 1.05rem; }
|
|
215
|
+
.package-summary { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
|
|
216
|
+
.package-block { padding: 0 1.25rem 1.25rem; }
|
|
217
|
+
.tree { list-style: none; padding: 0; margin: 0; }
|
|
218
|
+
.tree-row {
|
|
219
|
+
display: grid;
|
|
220
|
+
grid-template-columns: minmax(0, 1fr) auto auto;
|
|
221
|
+
gap: 0.65rem;
|
|
222
|
+
padding: 0.32rem 0;
|
|
223
|
+
padding-left: calc(var(--depth) * 1rem);
|
|
224
|
+
border-bottom: 1px solid rgba(216, 207, 194, 0.35);
|
|
225
|
+
align-items: baseline;
|
|
226
|
+
}
|
|
227
|
+
.tree-row:last-child { border-bottom: 0; }
|
|
228
|
+
.tree-row.directory { grid-template-columns: minmax(0, 1fr); color: var(--muted); font-weight: 700; }
|
|
229
|
+
.tree-name { word-break: break-all; }
|
|
230
|
+
.tree-meta { color: var(--muted); font-size: 0.84rem; }
|
|
231
|
+
.tree-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
|
|
232
|
+
.badge {
|
|
233
|
+
display: inline-flex;
|
|
234
|
+
align-items: center;
|
|
235
|
+
border-radius: 999px;
|
|
236
|
+
padding: 0.15rem 0.5rem;
|
|
237
|
+
font-size: 0.76rem;
|
|
238
|
+
font-family: ui-sans-serif, system-ui, sans-serif;
|
|
239
|
+
border: 1px solid currentColor;
|
|
240
|
+
}
|
|
241
|
+
.badge.secondary { color: var(--muted); }
|
|
242
|
+
.badge.status-changed { color: var(--changed); }
|
|
243
|
+
.badge.status-generated { color: var(--generated); }
|
|
244
|
+
.badge.status-unchanged { color: var(--unchanged); }
|
|
245
|
+
.failure {
|
|
246
|
+
margin: 0 1.25rem 1rem;
|
|
247
|
+
padding: 0.9rem 1rem;
|
|
248
|
+
background: var(--danger-bg);
|
|
249
|
+
border-radius: 0.8rem;
|
|
250
|
+
color: var(--danger);
|
|
251
|
+
}
|
|
252
|
+
.eliminated-list { margin: 0; padding-left: 1.25rem; }
|
|
253
|
+
details.diff, details.diagnostic {
|
|
254
|
+
border: 1px solid rgba(216, 207, 194, 0.7);
|
|
255
|
+
border-radius: 0.8rem;
|
|
256
|
+
margin-top: 0.75rem;
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
background: #fffdfa;
|
|
259
|
+
}
|
|
260
|
+
details.diff > summary, details.diagnostic > summary {
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
list-style: none;
|
|
263
|
+
padding: 0.75rem 0.9rem;
|
|
264
|
+
font-weight: 600;
|
|
265
|
+
}
|
|
266
|
+
details.diff > summary::-webkit-details-marker, details.diagnostic > summary::-webkit-details-marker { display: none; }
|
|
267
|
+
.diff-hunk { border-top: 1px solid rgba(216, 207, 194, 0.5); }
|
|
268
|
+
.diff-header {
|
|
269
|
+
padding: 0.45rem 0.75rem;
|
|
270
|
+
background: var(--diff-header);
|
|
271
|
+
color: var(--muted);
|
|
272
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
273
|
+
font-size: 0.8rem;
|
|
274
|
+
}
|
|
275
|
+
.diff-line {
|
|
276
|
+
white-space: pre-wrap;
|
|
277
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
278
|
+
font-size: 0.83rem;
|
|
279
|
+
padding: 0.08rem 0.75rem;
|
|
280
|
+
}
|
|
281
|
+
.diff-line.add { background: var(--diff-add); }
|
|
282
|
+
.diff-line.remove { background: var(--diff-remove); }
|
|
283
|
+
pre {
|
|
284
|
+
margin: 0;
|
|
285
|
+
padding: 0.95rem 1rem 1rem;
|
|
286
|
+
overflow-x: auto;
|
|
287
|
+
background: #faf6ef;
|
|
288
|
+
font-size: 0.82rem;
|
|
289
|
+
}
|
|
290
|
+
@media (max-width: 720px) {
|
|
291
|
+
.tree-row { grid-template-columns: minmax(0, 1fr); }
|
|
292
|
+
.tree-badges, .package-summary { justify-content: flex-start; }
|
|
293
|
+
}
|
|
294
|
+
`;
|
|
295
|
+
export function renderHtmlReport(document) {
|
|
296
|
+
const rawJson = JSON.stringify(document.report, undefined, jsonIndentSpaces);
|
|
297
|
+
let issueItems = '';
|
|
298
|
+
for (const issue of document.issues) {
|
|
299
|
+
issueItems += `<li>${escapeHtml(issue)}</li>`;
|
|
300
|
+
}
|
|
301
|
+
const issueSection = document.issues.length === 0 ? '' : renderIssues(issueItems);
|
|
302
|
+
let packageSections = '';
|
|
303
|
+
for (const pkg of document.packages) {
|
|
304
|
+
packageSections += renderPackage(pkg);
|
|
305
|
+
}
|
|
306
|
+
return `<!doctype html>
|
|
307
|
+
<html lang="en">
|
|
308
|
+
<head>
|
|
309
|
+
<meta charset="utf-8">
|
|
310
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
311
|
+
<title>Packtory build report</title>
|
|
312
|
+
<style>${styles}</style>
|
|
313
|
+
</head>
|
|
314
|
+
<body>
|
|
315
|
+
<main>
|
|
316
|
+
<section class="header">
|
|
317
|
+
<div class="mode-label">${escapeHtml(document.modeLabel)}</div>
|
|
318
|
+
<h1>${escapeHtml(document.title)}</h1>
|
|
319
|
+
<p class="meta">Schema version: ${escapeHtml(String(document.report.schemaVersion))} · Generated at: ${escapeHtml(document.report.generatedAt)}</p>
|
|
320
|
+
</section>
|
|
321
|
+
<section class="summary">
|
|
322
|
+
${renderSummaryCard('Packages', document.summary.totalPackages)}
|
|
323
|
+
${renderSummaryCard('Changed', document.summary.changedPackages)}
|
|
324
|
+
${renderSummaryCard('Unchanged', document.summary.unchangedPackages)}
|
|
325
|
+
${renderSummaryCard('Failed', document.summary.failedPackages)}
|
|
326
|
+
${renderSummaryCard('Artifacts', document.summary.emittedArtifacts)}
|
|
327
|
+
${renderSummaryCard('Changed files', document.summary.changedArtifacts)}
|
|
328
|
+
${renderSummaryCard('Eliminated', document.summary.eliminatedSourceFiles)}
|
|
329
|
+
</section>
|
|
330
|
+
${issueSection}
|
|
331
|
+
<section class="packages">${packageSections}</section>
|
|
332
|
+
<script type="application/json" id="packtory-report-data">${escapeHtml(rawJson)}</script>
|
|
333
|
+
</main>
|
|
334
|
+
</body>
|
|
335
|
+
</html>`;
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=html-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-renderer.js","sourceRoot":"","sources":["../../../../source/report/html-renderer.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,iCAAiC;AACjC,OAAO,EACH,kBAAkB,EAClB,mBAAmB,EAGtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAA+B,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,SAAS,eAAe,CAAC,KAAc;IACnC,OAAO,QAAQ,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC;AAC1F,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,KAAc;IAChD,OAAO,kDAAkD,UAAU,CAAC,KAAK,CAAC,aAAa,eAAe,CAAC,KAAK,CAAC,YAAY,CAAC;AAC9H,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAC9B,OAAO,GAAG,KAAK,IAAI,CAAC;AACxB,CAAC;AAED,SAAS,WAAW,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OAAO,CAAC,iBAAiB,CAAC;cAClE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC;cAC5D,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC;cACjE,iBAAiB,CAAC,eAAe,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC;cACrE,iBAAiB,CAAC,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC;;UAE3E,YAAY;oCACc,eAAe;oEACiB,UAAU,CAAC,OAAO,CAAC;;;QAG/E,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isCodeFile } from "packtory/common/code-files.js";
|
|
2
|
+
export function isDiffableArtifact(entry) {
|
|
3
|
+
return (entry.sourcePath !== undefined &&
|
|
4
|
+
entry.status === 'changed' &&
|
|
5
|
+
entry.kind === 'source' &&
|
|
6
|
+
isCodeFile(entry.path));
|
|
7
|
+
}
|
|
8
|
+
export function toDiffLineType(line) {
|
|
9
|
+
if (line.startsWith('+')) {
|
|
10
|
+
return 'add';
|
|
11
|
+
}
|
|
12
|
+
if (line.startsWith('-')) {
|
|
13
|
+
return 'remove';
|
|
14
|
+
}
|
|
15
|
+
return 'context';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=preview-document-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-document-diff.js","sourceRoot":"","sources":["../../../../source/report/preview-document-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,MAAM,UAAU,kBAAkB,CAAC,KAAoB;IACnD,OAAO,CACH,KAAK,CAAC,UAAU,KAAK,SAAS;QAC9B,KAAK,CAAC,MAAM,KAAK,SAAS;QAC1B,KAAK,CAAC,IAAI,KAAK,QAAQ;QACvB,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CACzB,CAAC;AACN,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACvC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createStructuredPatch } from "../common/typed-diff.js";
|
|
3
|
+
import { isDiffableArtifact, toDiffLineType } from "./preview-document-diff.js";
|
|
4
|
+
import { compareTreeNodes, treeNodeSortKey } from "./preview-document-tree.js";
|
|
5
|
+
const diffContextLines = 3;
|
|
6
|
+
const diffHunkLimit = 2;
|
|
7
|
+
export function isPreviewableResult(result) {
|
|
8
|
+
return result.isOk || (result.error.type === 'partial' && result.error.succeeded.length > 0);
|
|
9
|
+
}
|
|
10
|
+
export function getSucceededResults(result) {
|
|
11
|
+
if (result.isOk) {
|
|
12
|
+
return result.value;
|
|
13
|
+
}
|
|
14
|
+
if (result.error.type === 'partial') {
|
|
15
|
+
return result.error.succeeded;
|
|
16
|
+
}
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
export function getIssues(result) {
|
|
20
|
+
if (result.isOk) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
if (result.error.type === 'partial') {
|
|
24
|
+
return result.error.failures.map((failure) => {
|
|
25
|
+
return failure.message;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return result.error.issues;
|
|
29
|
+
}
|
|
30
|
+
export function getResultType(result) {
|
|
31
|
+
if (result.isOk) {
|
|
32
|
+
return 'success';
|
|
33
|
+
}
|
|
34
|
+
return result.error.type;
|
|
35
|
+
}
|
|
36
|
+
export function buildBundleArtifactIndex(results) {
|
|
37
|
+
return new Map(results.map((result) => {
|
|
38
|
+
const entries = new Map([
|
|
39
|
+
['package.json', { content: result.bundle.manifestFile.content }]
|
|
40
|
+
]);
|
|
41
|
+
for (const entry of result.bundle.contents) {
|
|
42
|
+
entries.set(entry.fileDescription.targetFilePath, {
|
|
43
|
+
content: entry.fileDescription.content,
|
|
44
|
+
sourcePath: entry.fileDescription.sourceFilePath
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return [result.bundle.name, entries];
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
// eslint-disable-next-line max-statements -- diff construction intentionally validates, loads, and shapes hunks in one place
|
|
51
|
+
export async function buildDiffForArtifact(packageName, artifact, bundleArtifactIndex, readWorkspaceFile) {
|
|
52
|
+
if (!isDiffableArtifact(artifact)) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
const packageArtifacts = bundleArtifactIndex.get(packageName);
|
|
56
|
+
const finalArtifact = packageArtifacts?.get(artifact.path);
|
|
57
|
+
if (finalArtifact?.sourcePath !== artifact.sourcePath) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const originalContent = await readWorkspaceFile(artifact.sourcePath);
|
|
61
|
+
if (originalContent === finalArtifact.content) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const patchFile = createStructuredPatch(artifact.path, artifact.path, originalContent, finalArtifact.content, undefined, undefined, {
|
|
65
|
+
context: diffContextLines
|
|
66
|
+
});
|
|
67
|
+
return patchFile.hunks.slice(0, diffHunkLimit).map((hunk) => {
|
|
68
|
+
return {
|
|
69
|
+
header: `@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`,
|
|
70
|
+
lines: hunk.lines
|
|
71
|
+
.filter((line) => {
|
|
72
|
+
return !line.startsWith('\\');
|
|
73
|
+
})
|
|
74
|
+
.map((line) => {
|
|
75
|
+
return {
|
|
76
|
+
type: toDiffLineType(line),
|
|
77
|
+
text: line
|
|
78
|
+
};
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function createDirectory(pathname, name, depth) {
|
|
84
|
+
return {
|
|
85
|
+
name,
|
|
86
|
+
path: pathname,
|
|
87
|
+
depth,
|
|
88
|
+
directories: new Map(),
|
|
89
|
+
files: []
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function insertArtifact(root, artifact) {
|
|
93
|
+
const parts = artifact.path.split('/');
|
|
94
|
+
let current = root;
|
|
95
|
+
for (const part of parts.slice(0, -1)) {
|
|
96
|
+
const nextPath = path.posix.join(current.path, part);
|
|
97
|
+
const next = current.directories.get(part) ?? createDirectory(nextPath, part, current.depth + 1);
|
|
98
|
+
current.directories.set(part, next);
|
|
99
|
+
current = next;
|
|
100
|
+
}
|
|
101
|
+
current.files.push(artifact);
|
|
102
|
+
}
|
|
103
|
+
function flattenTree(directory) {
|
|
104
|
+
const nodes = [];
|
|
105
|
+
const directoryEntries = Array.from(directory.directories.values());
|
|
106
|
+
const directoryChildren = directoryEntries.map((entry) => {
|
|
107
|
+
const node = {
|
|
108
|
+
path: entry.path,
|
|
109
|
+
name: entry.name,
|
|
110
|
+
depth: entry.depth,
|
|
111
|
+
type: 'directory'
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
node,
|
|
115
|
+
directory: entry,
|
|
116
|
+
sortKey: treeNodeSortKey(node)
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const fileChildren = directory.files.map((artifact) => {
|
|
120
|
+
const node = {
|
|
121
|
+
path: artifact.path,
|
|
122
|
+
name: path.posix.basename(artifact.path),
|
|
123
|
+
depth: directory.depth,
|
|
124
|
+
type: 'file',
|
|
125
|
+
artifact
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
node,
|
|
129
|
+
sortKey: treeNodeSortKey(node)
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
const children = [...directoryChildren, ...fileChildren].toSorted((left, right) => {
|
|
133
|
+
return compareTreeNodes(left.node, right.node);
|
|
134
|
+
});
|
|
135
|
+
for (const child of children) {
|
|
136
|
+
nodes.push(child.node);
|
|
137
|
+
if (child.directory !== undefined) {
|
|
138
|
+
nodes.push(...flattenTree(child.directory));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return nodes;
|
|
142
|
+
}
|
|
143
|
+
export function buildArtifactTree(artifacts) {
|
|
144
|
+
const root = {
|
|
145
|
+
path: '',
|
|
146
|
+
depth: 0,
|
|
147
|
+
directories: new Map(),
|
|
148
|
+
files: []
|
|
149
|
+
};
|
|
150
|
+
for (const artifact of artifacts) {
|
|
151
|
+
insertArtifact(root, artifact);
|
|
152
|
+
}
|
|
153
|
+
return flattenTree(root);
|
|
154
|
+
}
|
|
155
|
+
export function buildVersionTransition(packageReport) {
|
|
156
|
+
const { version } = packageReport.decisions;
|
|
157
|
+
if (version === undefined) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
if (version.previousVersion === undefined) {
|
|
161
|
+
return version.chosenVersion;
|
|
162
|
+
}
|
|
163
|
+
return `${version.previousVersion} -> ${version.chosenVersion}`;
|
|
164
|
+
}
|
|
165
|
+
export function hasMeaningfulChanges(artifacts, eliminatedSourceFiles) {
|
|
166
|
+
if (eliminatedSourceFiles.length > 0) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return artifacts.some((artifact) => {
|
|
170
|
+
return artifact.status === 'changed';
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=preview-document-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-document-helpers.js","sourceRoot":"","sources":["../../../../source/report/preview-document-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,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