@bitmagic/cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.d.ts +1 -0
- package/dist/commands/build.js +16 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/forge.d.ts +15 -3
- package/dist/commands/forge.js +38 -4
- package/dist/commands/forge.js.map +1 -1
- package/dist/commands/upgrade.d.ts +21 -0
- package/dist/commands/upgrade.js +161 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/verify.js +8 -9
- package/dist/commands/verify.js.map +1 -1
- package/dist/forge/apply-modifications.js +7 -13
- package/dist/forge/apply-modifications.js.map +1 -1
- package/dist/publish/bundle.d.ts +31 -0
- package/dist/publish/bundle.js +77 -0
- package/dist/publish/bundle.js.map +1 -0
- package/dist/publish/fingerprint.d.ts +27 -0
- package/dist/publish/fingerprint.js +64 -0
- package/dist/publish/fingerprint.js.map +1 -0
- package/dist/scaffold/dependency-diff.d.ts +28 -0
- package/dist/scaffold/dependency-diff.js +28 -0
- package/dist/scaffold/dependency-diff.js.map +1 -0
- package/dist/scaffold/project-files.d.ts +22 -0
- package/dist/scaffold/project-files.js +66 -5
- package/dist/scaffold/project-files.js.map +1 -1
- package/dist/scaffold/project.d.ts +17 -0
- package/dist/scaffold/project.js +24 -4
- package/dist/scaffold/project.js.map +1 -1
- package/dist/scaffold/upgrade-project.d.ts +35 -0
- package/dist/scaffold/upgrade-project.js +63 -0
- package/dist/scaffold/upgrade-project.js.map +1 -0
- package/dist/verify/result.d.ts +60 -0
- package/dist/verify/result.js +74 -0
- package/dist/verify/result.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { VerifyResult } from './classify.js';
|
|
2
|
+
export declare const VERIFY_RESULT_FILENAME = "result.json";
|
|
3
|
+
/**
|
|
4
|
+
* What `bitmagic verify` observed, written so `bitmagic publish` can gate on it.
|
|
5
|
+
*
|
|
6
|
+
* `fingerprint` is what makes the record trustworthy later: it names the exact project state
|
|
7
|
+
* that was verified, so publish can tell "verified and unchanged" from "verified, then edited".
|
|
8
|
+
*/
|
|
9
|
+
export interface VerifyRunRecord {
|
|
10
|
+
ok: boolean;
|
|
11
|
+
failures: string[];
|
|
12
|
+
warnings: string[];
|
|
13
|
+
fingerprint: string;
|
|
14
|
+
/** ISO 8601. Reported to the creator; never used to decide staleness. */
|
|
15
|
+
at: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function writeVerifyRecord(artifactDir: string, record: VerifyRunRecord): void;
|
|
18
|
+
/**
|
|
19
|
+
* The last recorded run, or `null` if there is none to trust.
|
|
20
|
+
*
|
|
21
|
+
* Unreadable and malformed both read as null on purpose. This is not swallowing an error: the
|
|
22
|
+
* caller's next move is identical in all three cases — tell the creator to run `bitmagic
|
|
23
|
+
* verify` — and a partially-parsed record would be a worse thing to gate a publish on than no
|
|
24
|
+
* record at all.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readVerifyRecord(artifactDir: string): VerifyRunRecord | null;
|
|
27
|
+
/**
|
|
28
|
+
* What a classified verify run produces: the record to write, and whether the command then
|
|
29
|
+
* fails.
|
|
30
|
+
*
|
|
31
|
+
* Split out of the command so the ORDER is testable. The record must be written even when the
|
|
32
|
+
* run failed — publish distinguishes "verify failed" from "verify never ran", and those have
|
|
33
|
+
* different messages and different remedies. Inside `run()` that ordering is only observable by
|
|
34
|
+
* spawning vite and a browser, which is why it went unguarded.
|
|
35
|
+
*/
|
|
36
|
+
export declare function decideVerifyOutcome(result: VerifyResult, fingerprint: string, at: string): {
|
|
37
|
+
record: VerifyRunRecord;
|
|
38
|
+
shouldThrow: boolean;
|
|
39
|
+
};
|
|
40
|
+
export interface VerifyReporter {
|
|
41
|
+
write: (artifactDir: string, record: VerifyRunRecord) => void;
|
|
42
|
+
info: (line: string) => void;
|
|
43
|
+
error: (line: string) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Record the run, report it, and fail the command if it did not pass.
|
|
47
|
+
*
|
|
48
|
+
* The record is written BEFORE the throw and regardless of the verdict, because publish
|
|
49
|
+
* distinguishes "verify failed" from "verify never ran" and those have different remedies.
|
|
50
|
+
* That ordering lives here, behind injectable seams, precisely so a test can prove the record
|
|
51
|
+
* survives a failing run — inside `run()` it was observable only by spawning vite and a browser,
|
|
52
|
+
* which is why it went unguarded.
|
|
53
|
+
*/
|
|
54
|
+
export declare function recordAndGateVerify(artifactDir: string, outcome: {
|
|
55
|
+
record: VerifyRunRecord;
|
|
56
|
+
shouldThrow: boolean;
|
|
57
|
+
}, paths: {
|
|
58
|
+
consolePath: string;
|
|
59
|
+
screenshotPath: string;
|
|
60
|
+
}, reporter: VerifyReporter): void;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { CliError } from '../errors.js';
|
|
4
|
+
export const VERIFY_RESULT_FILENAME = 'result.json';
|
|
5
|
+
export function writeVerifyRecord(artifactDir, record) {
|
|
6
|
+
fs.mkdirSync(artifactDir, { recursive: true });
|
|
7
|
+
fs.writeFileSync(path.join(artifactDir, VERIFY_RESULT_FILENAME), `${JSON.stringify(record, null, 2)}\n`);
|
|
8
|
+
}
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
if (typeof value !== 'object' || value === null)
|
|
11
|
+
return false;
|
|
12
|
+
const r = value;
|
|
13
|
+
return (typeof r.ok === 'boolean'
|
|
14
|
+
&& Array.isArray(r.failures)
|
|
15
|
+
&& r.failures.every((f) => typeof f === 'string')
|
|
16
|
+
&& Array.isArray(r.warnings)
|
|
17
|
+
&& r.warnings.every((w) => typeof w === 'string')
|
|
18
|
+
&& typeof r.fingerprint === 'string'
|
|
19
|
+
&& typeof r.at === 'string');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The last recorded run, or `null` if there is none to trust.
|
|
23
|
+
*
|
|
24
|
+
* Unreadable and malformed both read as null on purpose. This is not swallowing an error: the
|
|
25
|
+
* caller's next move is identical in all three cases — tell the creator to run `bitmagic
|
|
26
|
+
* verify` — and a partially-parsed record would be a worse thing to gate a publish on than no
|
|
27
|
+
* record at all.
|
|
28
|
+
*/
|
|
29
|
+
export function readVerifyRecord(artifactDir) {
|
|
30
|
+
try {
|
|
31
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(artifactDir, VERIFY_RESULT_FILENAME), 'utf-8'));
|
|
32
|
+
return isRecord(parsed) ? parsed : null;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* What a classified verify run produces: the record to write, and whether the command then
|
|
40
|
+
* fails.
|
|
41
|
+
*
|
|
42
|
+
* Split out of the command so the ORDER is testable. The record must be written even when the
|
|
43
|
+
* run failed — publish distinguishes "verify failed" from "verify never ran", and those have
|
|
44
|
+
* different messages and different remedies. Inside `run()` that ordering is only observable by
|
|
45
|
+
* spawning vite and a browser, which is why it went unguarded.
|
|
46
|
+
*/
|
|
47
|
+
export function decideVerifyOutcome(result, fingerprint, at) {
|
|
48
|
+
return {
|
|
49
|
+
record: { ok: result.ok, failures: result.failures, warnings: result.warnings, fingerprint, at },
|
|
50
|
+
shouldThrow: !result.ok,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Record the run, report it, and fail the command if it did not pass.
|
|
55
|
+
*
|
|
56
|
+
* The record is written BEFORE the throw and regardless of the verdict, because publish
|
|
57
|
+
* distinguishes "verify failed" from "verify never ran" and those have different remedies.
|
|
58
|
+
* That ordering lives here, behind injectable seams, precisely so a test can prove the record
|
|
59
|
+
* survives a failing run — inside `run()` it was observable only by spawning vite and a browser,
|
|
60
|
+
* which is why it went unguarded.
|
|
61
|
+
*/
|
|
62
|
+
export function recordAndGateVerify(artifactDir, outcome, paths, reporter) {
|
|
63
|
+
reporter.write(artifactDir, outcome.record);
|
|
64
|
+
for (const warning of outcome.record.warnings)
|
|
65
|
+
reporter.info(`warning: ${warning}`);
|
|
66
|
+
if (outcome.shouldThrow) {
|
|
67
|
+
for (const failure of outcome.record.failures)
|
|
68
|
+
reporter.error(`✗ ${failure}`);
|
|
69
|
+
reporter.error(`\nArtifacts: ${paths.consolePath}, ${paths.screenshotPath}`);
|
|
70
|
+
throw new CliError('Verification failed.');
|
|
71
|
+
}
|
|
72
|
+
reporter.info(`Verification passed. Artifacts in ${artifactDir}`);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/verify/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AAiBpD,MAAM,UAAU,iBAAiB,CAAC,WAAmB,EAAE,MAAuB;IAC5E,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,sBAAsB,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3G,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CACL,OAAO,CAAC,CAAC,EAAE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