animader-cli 0.0.0-stage → 0.1.0
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/LICENSE +121 -0
- package/adapters/build-node.mjs +261 -0
- package/adapters/devserver.mjs +481 -0
- package/adapters/devsession.mjs +619 -0
- package/adapters/export-node.mjs +601 -0
- package/adapters/export-run.mjs +126 -0
- package/adapters/generations.mjs +211 -0
- package/adapters/http.mjs +294 -0
- package/adapters/launch.mjs +83 -0
- package/adapters/node-fs.mjs +68 -0
- package/adapters/pngine.mjs +87 -0
- package/adapters/snapshot.mjs +129 -0
- package/adapters/target.mjs +104 -0
- package/adapters/watch.mjs +355 -0
- package/adapters/webaudio.mjs +102 -0
- package/bin/animader.mjs +31 -0
- package/hello/join.js +46 -0
- package/hello/run.js +259 -0
- package/lib/build.mjs +126 -0
- package/lib/buildloop.mjs +254 -0
- package/lib/contract.mjs +371 -0
- package/lib/errors.mjs +51 -0
- package/lib/export.mjs +445 -0
- package/lib/new.mjs +304 -0
- package/lib/pipeline.mjs +247 -0
- package/lib/receipt.mjs +331 -0
- package/lib/routes.mjs +170 -0
- package/lib/score.mjs +434 -0
- package/lib/show.mjs +458 -0
- package/lib/soundtrack.mjs +67 -0
- package/lib/vendor.mjs +99 -0
- package/lib/wav.mjs +197 -0
- package/package.json +47 -4
- package/player/boot.mjs +792 -0
- package/player/controller.mjs +366 -0
- package/player/devchannel.mjs +306 -0
- package/player/index.html +35 -0
- package/player/page.mjs +134 -0
- package/player/player.css +393 -0
- package/player/release.mjs +76 -0
- package/src/commands/build.mjs +201 -0
- package/src/commands/dev.mjs +214 -0
- package/src/commands/doctor.mjs +348 -0
- package/src/commands/export.mjs +158 -0
- package/src/commands/new.mjs +164 -0
- package/src/commands/project.mjs +46 -0
- package/src/config.mjs +110 -0
- package/src/router.mjs +149 -0
- package/src/toolchain.mjs +691 -0
- package/starters/circle/README.md +50 -0
- package/starters/circle/animader.json +4 -0
- package/starters/circle/gitignore +9 -0
- package/starters/circle/kernels/circle.wgsl +32 -0
- package/starters/circle/program.sjon +34 -0
- package/starters/circle/timeline.piece.sjon +26 -0
- package/starters/ember/bake/spans.bin +0 -0
- package/starters/ember/kernels/curl.wgsl +10 -0
- package/starters/ember/kernels/ember.wgsl +10 -0
- package/starters/ember/kernels/hash.wgsl +12 -0
- package/starters/ember/kernels/simplex.wgsl +27 -0
- package/starters/ember/program.sjon +328 -0
- package/starters/ember/timeline.piece.sjon +34 -0
- package/toolchain/licenses/animader.txt +121 -0
- package/toolchain/licenses/esbuild.txt +21 -0
- package/toolchain/licenses/pacer.txt +121 -0
- package/toolchain/licenses/pngine.txt +121 -0
- package/toolchain/manifest.json +212 -0
- package/toolchain/prepare.mjs +446 -0
- package/toolchain/uniform-type-name.js +184 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Creative Commons Legal Code
|
|
2
|
+
|
|
3
|
+
CC0 1.0 Universal
|
|
4
|
+
|
|
5
|
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
|
6
|
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
|
7
|
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
|
8
|
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
|
9
|
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
|
10
|
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
|
11
|
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
|
12
|
+
HEREUNDER.
|
|
13
|
+
|
|
14
|
+
Statement of Purpose
|
|
15
|
+
|
|
16
|
+
The laws of most jurisdictions throughout the world automatically confer
|
|
17
|
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
|
18
|
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
|
19
|
+
authorship and/or a database (each, a "Work").
|
|
20
|
+
|
|
21
|
+
Certain owners wish to permanently relinquish those rights to a Work for
|
|
22
|
+
the purpose of contributing to a commons of creative, cultural and
|
|
23
|
+
scientific works ("Commons") that the public can reliably and without fear
|
|
24
|
+
of later claims of infringement build upon, modify, incorporate in other
|
|
25
|
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
|
26
|
+
and for any purposes, including without limitation commercial purposes.
|
|
27
|
+
These owners may contribute to the Commons to promote the ideal of a free
|
|
28
|
+
culture and the further production of creative, cultural and scientific
|
|
29
|
+
works, or to gain reputation or greater distribution for their Work in
|
|
30
|
+
part through the use and efforts of others.
|
|
31
|
+
|
|
32
|
+
For these and/or other purposes and motivations, and without any
|
|
33
|
+
expectation of additional consideration or compensation, the person
|
|
34
|
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
|
35
|
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
|
36
|
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
|
37
|
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
|
38
|
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
|
39
|
+
|
|
40
|
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
|
41
|
+
protected by copyright and related or neighboring rights ("Copyright and
|
|
42
|
+
Related Rights"). Copyright and Related Rights include, but are not limited
|
|
43
|
+
to, the following:
|
|
44
|
+
|
|
45
|
+
i. the right to reproduce, adapt, distribute, perform, display,
|
|
46
|
+
communicate, and translate a Work;
|
|
47
|
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
|
48
|
+
iii. publicity and privacy rights pertaining to a person's image or
|
|
49
|
+
likeness depicted in a Work;
|
|
50
|
+
iv. rights protecting against unfair competition in regards to a Work,
|
|
51
|
+
subject to the limitations in paragraph 4(a), below;
|
|
52
|
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
|
53
|
+
in a Work;
|
|
54
|
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
|
55
|
+
European Parliament and of the Council of 11 March 1996 on the legal
|
|
56
|
+
protection of databases, and under any national implementation
|
|
57
|
+
thereof, including any amended or successor version of such
|
|
58
|
+
directive); and
|
|
59
|
+
vii. other similar, equivalent or corresponding rights throughout the
|
|
60
|
+
world based on applicable law or treaty, and any national
|
|
61
|
+
implementations thereof.
|
|
62
|
+
|
|
63
|
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
|
64
|
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
|
65
|
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
|
66
|
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
|
67
|
+
of action, whether now known or unknown (including existing as well as
|
|
68
|
+
future claims and causes of action), in the Work (i) in all territories
|
|
69
|
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
|
70
|
+
treaty (including future time extensions), (iii) in any current or future
|
|
71
|
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
|
72
|
+
including without limitation commercial, advertising or promotional
|
|
73
|
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
|
74
|
+
member of the public at large and to the detriment of Affirmer's heirs and
|
|
75
|
+
successors, fully intending that such Waiver shall not be subject to
|
|
76
|
+
revocation, rescission, cancellation, termination, or any other legal or
|
|
77
|
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
|
78
|
+
as contemplated by Affirmer's express Statement of Purpose.
|
|
79
|
+
|
|
80
|
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
|
81
|
+
be judged legally invalid or ineffective under applicable law, then the
|
|
82
|
+
Waiver shall be preserved to the maximum extent permitted taking into
|
|
83
|
+
account Affirmer's express Statement of Purpose. In addition, to the
|
|
84
|
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
|
85
|
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
|
86
|
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
|
87
|
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
|
88
|
+
maximum duration provided by applicable law or treaty (including future
|
|
89
|
+
time extensions), (iii) in any current or future medium and for any number
|
|
90
|
+
of copies, and (iv) for any purpose whatsoever, including without
|
|
91
|
+
limitation commercial, advertising or promotional purposes (the
|
|
92
|
+
"License"). The License shall be deemed effective as of the date CC0 was
|
|
93
|
+
applied by Affirmer to the Work. Should any part of the License for any
|
|
94
|
+
reason be judged legally invalid or ineffective under applicable law, such
|
|
95
|
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
|
96
|
+
of the License, and in such case Affirmer hereby affirms that he or she
|
|
97
|
+
will not (i) exercise any of his or her remaining Copyright and Related
|
|
98
|
+
Rights in the Work or (ii) assert any associated claims and causes of
|
|
99
|
+
action with respect to the Work, in either case contrary to Affirmer's
|
|
100
|
+
express Statement of Purpose.
|
|
101
|
+
|
|
102
|
+
4. Limitations and Disclaimers.
|
|
103
|
+
|
|
104
|
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
|
105
|
+
surrendered, licensed or otherwise affected by this document.
|
|
106
|
+
b. Affirmer offers the Work as-is and makes no representations or
|
|
107
|
+
warranties of any kind concerning the Work, express, implied,
|
|
108
|
+
statutory or otherwise, including without limitation warranties of
|
|
109
|
+
title, merchantability, fitness for a particular purpose, non
|
|
110
|
+
infringement, or the absence of latent or other defects, accuracy, or
|
|
111
|
+
the present or absence of errors, whether or not discoverable, all to
|
|
112
|
+
the greatest extent permissible under applicable law.
|
|
113
|
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
|
114
|
+
that may apply to the Work or any use thereof, including without
|
|
115
|
+
limitation any person's Copyright and Related Rights in the Work.
|
|
116
|
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
|
117
|
+
consents, permissions or other rights required for any use of the
|
|
118
|
+
Work.
|
|
119
|
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
|
120
|
+
party to this document and has no duty or obligation with respect to
|
|
121
|
+
this CC0 or use of the Work.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// The Node adapter for the shared full build (plan section 4). It owns the
|
|
2
|
+
// real producer ports the portable pipeline (`lib/pipeline.mjs`) calls —
|
|
3
|
+
// the vendored PieceHost derivation, pngine's own reflection readers, the
|
|
4
|
+
// real `pacer pack` CLI, and the vendored playback-only PacerRt the host
|
|
5
|
+
// audit loads — plus `runFullBuild`, the operation `animader build` and
|
|
6
|
+
// `animader dev`'s preflight run: one input snapshot this build owns
|
|
7
|
+
// (outside the source tree, the same filter the export uses), the pipeline
|
|
8
|
+
// stages over that consistent copy, and the three artifacts copied back
|
|
9
|
+
// into the project's own out/. The export runs the same pipeline on its
|
|
10
|
+
// own snapshot; neither trusts a stale out/.
|
|
11
|
+
|
|
12
|
+
import { promises as fsp } from 'node:fs';
|
|
13
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
15
|
+
|
|
16
|
+
import { packScore as realPackScore, reflectionOfPayload } from './export-node.mjs';
|
|
17
|
+
import { listSnapshotInputFiles, snapshotProject } from './snapshot.mjs';
|
|
18
|
+
import { createNodeIo, hashBytes } from './node-fs.mjs';
|
|
19
|
+
import { buildError } from '../lib/errors.mjs';
|
|
20
|
+
import { buildProject, assertProjectSnapshotsMatch } from '../lib/pipeline.mjs';
|
|
21
|
+
import { BAKED_PAYLOAD, BUILD_RECEIPT, GENERATED_DIR, PACKED_SCORE, inspectProject } from '../lib/contract.mjs';
|
|
22
|
+
import { resolveRoots } from '../toolchain/prepare.mjs';
|
|
23
|
+
import { contributorToolchain } from '../src/toolchain.mjs';
|
|
24
|
+
|
|
25
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
// The package root and the contributor workspace around it: the vendored
|
|
27
|
+
// runtime bundle still lives under the checkout's demo/vendor, filled by
|
|
28
|
+
// the contributor prepare (toolchain/prepare.mjs).
|
|
29
|
+
const PKG = resolve(HERE, '..');
|
|
30
|
+
const REPO = resolve(PKG, '..', '..');
|
|
31
|
+
|
|
32
|
+
/** The generated artifacts a full build owns, in out/. */
|
|
33
|
+
export const FULL_BUILD_ARTIFACTS = Object.freeze([BAKED_PAYLOAD, PACKED_SCORE, BUILD_RECEIPT]);
|
|
34
|
+
|
|
35
|
+
async function importRuntimeModule(toolchain, relative, label, remedy) {
|
|
36
|
+
const source = await toolchain.runtime.requireFile(relative);
|
|
37
|
+
try {
|
|
38
|
+
return await import(pathToFileURL(source).href);
|
|
39
|
+
} catch (cause) {
|
|
40
|
+
throw buildError(
|
|
41
|
+
'vendor_module_missing',
|
|
42
|
+
`the runtime module ${relative} (${source}) could not be loaded for the ${label}`,
|
|
43
|
+
remedy,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The real build producer ports over the toolchain's runtime and native
|
|
50
|
+
* tools: the PieceHost score derivation, pngine's own payload reflection,
|
|
51
|
+
* the real `pacer pack` CLI (with its binary identity for the receipt),
|
|
52
|
+
* and the playback-only PacerRt plus pacer-rt.wasm the host audit loads.
|
|
53
|
+
* Tests inject the same shapes.
|
|
54
|
+
*
|
|
55
|
+
* The runtime comes from a toolchain descriptor (src/toolchain.mjs): the
|
|
56
|
+
* contributor workspace's vendored bundle by default, an installed package
|
|
57
|
+
* tree when the caller resolved one. The legacy {roots, vendorRoot} pair
|
|
58
|
+
* still constructs a contributor toolchain for the compat entries/tests.
|
|
59
|
+
*
|
|
60
|
+
* @param {{toolchain?: object, roots?: object, vendorRoot?: string}} [options]
|
|
61
|
+
*/
|
|
62
|
+
export function createBuildProducers({ toolchain = null, roots, vendorRoot } = {}) {
|
|
63
|
+
const chain = toolchain ?? contributorToolchain({ roots: roots ?? resolveRoots(), vendorRoot: vendorRoot ?? join(REPO, 'demo', 'vendor') });
|
|
64
|
+
let pieceHost = null;
|
|
65
|
+
let pacerRt = null;
|
|
66
|
+
let pacerRtWasm = null;
|
|
67
|
+
return {
|
|
68
|
+
async deriveScore(timelineText) {
|
|
69
|
+
if (pieceHost === null) {
|
|
70
|
+
const module = await importRuntimeModule(
|
|
71
|
+
chain,
|
|
72
|
+
'animader/piece.js',
|
|
73
|
+
'score derivation',
|
|
74
|
+
'Prepare the vendored runtime with node demo/prepare.mjs; the build never falls back to a second reader.',
|
|
75
|
+
);
|
|
76
|
+
const wasm = await fsp.readFile(chain.runtime.path('animader/animader.wasm')).catch((cause) => {
|
|
77
|
+
throw buildError(
|
|
78
|
+
'vendor_module_missing',
|
|
79
|
+
`the prepared animader.wasm could not be read for the score derivation: ${cause?.message ?? cause}`,
|
|
80
|
+
'Prepare the vendored runtime with node demo/prepare.mjs.',
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
pieceHost = await module.PieceHost.instantiate(wasm);
|
|
84
|
+
}
|
|
85
|
+
return pieceHost.score(timelineText);
|
|
86
|
+
},
|
|
87
|
+
reflectPayload(payloadBytes) {
|
|
88
|
+
return reflectionOfPayload({ payloadBytes, toolchain: chain });
|
|
89
|
+
},
|
|
90
|
+
async packScore({ scoreText, reflection, outPath, workDir }) {
|
|
91
|
+
return realPackScore({ scoreText, reflection, outPath, workDir, pacerCli: chain.pacer.cli });
|
|
92
|
+
},
|
|
93
|
+
async pacerRtWasm() {
|
|
94
|
+
if (pacerRtWasm === null) {
|
|
95
|
+
pacerRtWasm = await fsp.readFile(chain.runtime.path('pacer/pacer-rt.wasm')).catch((cause) => {
|
|
96
|
+
throw buildError(
|
|
97
|
+
'vendor_module_missing',
|
|
98
|
+
`the prepared pacer-rt.wasm could not be read for the playability audit: ${cause?.message ?? cause}`,
|
|
99
|
+
'Prepare the vendored runtime with node demo/prepare.mjs; the audit never runs against a guessed runtime.',
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return pacerRtWasm;
|
|
104
|
+
},
|
|
105
|
+
async loadPacerRt(wasm, bytes, options) {
|
|
106
|
+
if (pacerRt === null) {
|
|
107
|
+
const module = await importRuntimeModule(
|
|
108
|
+
chain,
|
|
109
|
+
'pacer/rt.js',
|
|
110
|
+
'playability audit',
|
|
111
|
+
'Prepare the vendored runtime with node demo/prepare.mjs; the audit loads the same runtime the release ships.',
|
|
112
|
+
);
|
|
113
|
+
pacerRt = module.PacerRt;
|
|
114
|
+
}
|
|
115
|
+
return pacerRt.load(wasm, bytes, options);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* One full build over a snapshot this build owns: clear the project's stale
|
|
122
|
+
* generated artifacts, copy the authored project outside the source tree
|
|
123
|
+
* (the export's own filter), refuse drift between the caller's inspection
|
|
124
|
+
* and the copy, hash the filtered snapshot for the receipt, run the shared
|
|
125
|
+
* pipeline there, then copy the three artifacts back into the project's
|
|
126
|
+
* out/ and verify them against the receipt. A failed stage leaves no
|
|
127
|
+
* out/ artifact behind, so no stale receipt can claim a validated score.
|
|
128
|
+
*
|
|
129
|
+
* @param {Object} options
|
|
130
|
+
* @param {{folder: string, files: Object}} options.project the inspected project
|
|
131
|
+
* @param {number} options.seconds resolved host show length
|
|
132
|
+
* @param {{folder: string, outDir: string, payload: string, score: string, receipt: string,
|
|
133
|
+
* projectName: string}} options.paths the project's real out/ destinations
|
|
134
|
+
* @param {{outDir: string, stageDir: string, sizePath: string}} [options.snapshotPaths]
|
|
135
|
+
* owned export/staging trees inside the project to exclude from the snapshot
|
|
136
|
+
* @param {Object} options.native the pngine adapter
|
|
137
|
+
* @param {Object} options.runtime `{ verify }` over the prepared bundle
|
|
138
|
+
* @param {Object} options.producers the build ports (see createBuildProducers)
|
|
139
|
+
* @param {Object} [options.io]
|
|
140
|
+
* @param {string} [options.workRoot] parent for the snapshot; default is the
|
|
141
|
+
* OS temporary directory, always outside the source tree
|
|
142
|
+
*/
|
|
143
|
+
export async function runFullBuild({
|
|
144
|
+
project,
|
|
145
|
+
seconds,
|
|
146
|
+
paths,
|
|
147
|
+
snapshotPaths,
|
|
148
|
+
native,
|
|
149
|
+
runtime,
|
|
150
|
+
producers,
|
|
151
|
+
io = createNodeIo(),
|
|
152
|
+
workRoot,
|
|
153
|
+
}) {
|
|
154
|
+
// A failed build must leave no valid-looking claim in out/: the stale
|
|
155
|
+
// artifacts go first, exactly like the legacy preflight cleared its own.
|
|
156
|
+
await fsp.mkdir(paths.outDir, { recursive: true });
|
|
157
|
+
for (const name of FULL_BUILD_ARTIFACTS) {
|
|
158
|
+
await fsp.rm(join(paths.outDir, name), { force: true });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const { built, work, workProject } = await runSnapshotBuild({
|
|
162
|
+
project,
|
|
163
|
+
seconds,
|
|
164
|
+
projectName: paths.projectName,
|
|
165
|
+
snapshotPaths,
|
|
166
|
+
native,
|
|
167
|
+
runtime,
|
|
168
|
+
producers,
|
|
169
|
+
io,
|
|
170
|
+
workRoot,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
const destinations = [
|
|
175
|
+
[join(workProject, GENERATED_DIR, BAKED_PAYLOAD), paths.payload, built.receipt.outputs.payload.sha256],
|
|
176
|
+
[join(workProject, GENERATED_DIR, PACKED_SCORE), paths.score, built.receipt.outputs.score.sha256],
|
|
177
|
+
];
|
|
178
|
+
for (const [source, destination, expected] of destinations) {
|
|
179
|
+
const bytes = await fsp.readFile(source);
|
|
180
|
+
if (hashBytes(bytes) !== expected) {
|
|
181
|
+
throw buildError('build_output_drift', 'a built artifact does not match its own receipt after the copy', 'Re-run the build; the pipeline never publishes bytes it did not verify.');
|
|
182
|
+
}
|
|
183
|
+
await fsp.writeFile(destination, bytes);
|
|
184
|
+
}
|
|
185
|
+
await fsp.writeFile(paths.receipt, `${JSON.stringify(built.receipt, null, 2)}\n`);
|
|
186
|
+
return built;
|
|
187
|
+
} finally {
|
|
188
|
+
await fsp.rm(work, { recursive: true, force: true });
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The shared build-over-a-snapshot core (plan section 4 and 5): take one
|
|
194
|
+
* input snapshot outside the source tree, refuse drift between the
|
|
195
|
+
* caller's inspection and the copy, hash the filtered snapshot for the
|
|
196
|
+
* receipt, and run the pipeline stages there. The caller decides what the
|
|
197
|
+
* finished tree becomes: `runFullBuild` copies the artifacts back into the
|
|
198
|
+
* project's own out/ and removes the work tree; the dev session keeps the
|
|
199
|
+
* tree itself as one immutable generation. On any failure the work tree is
|
|
200
|
+
* removed and nothing else is touched.
|
|
201
|
+
*
|
|
202
|
+
* @param {Object} options
|
|
203
|
+
* @param {{folder: string, files: Object}} options.project the inspected source project
|
|
204
|
+
* @param {number} options.seconds resolved host show length
|
|
205
|
+
* @param {string} options.projectName the name the receipt records
|
|
206
|
+
* @param {{outDir: string, stageDir: string, sizePath: string}} [options.snapshotPaths]
|
|
207
|
+
* @param {Object} options.native the pngine adapter
|
|
208
|
+
* @param {Object} options.runtime `{ verify }` over the prepared bundle
|
|
209
|
+
* @param {Object} options.producers the build ports
|
|
210
|
+
* @param {Object} [options.io]
|
|
211
|
+
* @param {string} [options.workRoot] parent for the snapshot (the dev
|
|
212
|
+
* session passes its own staging root)
|
|
213
|
+
* @returns {Promise<{built: Object, work: string, workProject: string}>}
|
|
214
|
+
* `workProject` is the finished tree: the authored files plus out/ with
|
|
215
|
+
* payload, score and receipt; `work` is the root to remove for it
|
|
216
|
+
*/
|
|
217
|
+
export async function runSnapshotBuild({
|
|
218
|
+
project,
|
|
219
|
+
seconds,
|
|
220
|
+
projectName,
|
|
221
|
+
snapshotPaths,
|
|
222
|
+
native,
|
|
223
|
+
runtime,
|
|
224
|
+
producers,
|
|
225
|
+
io = createNodeIo(),
|
|
226
|
+
workRoot,
|
|
227
|
+
}) {
|
|
228
|
+
const { work, workProject } = await snapshotProject({ project, paths: snapshotPaths ?? {}, workRoot });
|
|
229
|
+
try {
|
|
230
|
+
const copied = await inspectProject({ folder: workProject, io });
|
|
231
|
+
await assertProjectSnapshotsMatch({ original: project, copied, what: 'build' });
|
|
232
|
+
|
|
233
|
+
const inputFiles = await listSnapshotInputFiles({ workProject, paths: snapshotPaths ?? {} });
|
|
234
|
+
const built = await buildProject({
|
|
235
|
+
project: copied,
|
|
236
|
+
seconds,
|
|
237
|
+
paths: {
|
|
238
|
+
folder: workProject,
|
|
239
|
+
outDir: join(workProject, GENERATED_DIR),
|
|
240
|
+
payload: join(workProject, GENERATED_DIR, BAKED_PAYLOAD),
|
|
241
|
+
score: join(workProject, GENERATED_DIR, PACKED_SCORE),
|
|
242
|
+
receipt: join(workProject, GENERATED_DIR, BUILD_RECEIPT),
|
|
243
|
+
workDir: work,
|
|
244
|
+
projectName,
|
|
245
|
+
payloadRelative: `${GENERATED_DIR}/${BAKED_PAYLOAD}`,
|
|
246
|
+
scoreRelative: `${GENERATED_DIR}/${PACKED_SCORE}`,
|
|
247
|
+
receiptRelative: `${GENERATED_DIR}/${BUILD_RECEIPT}`,
|
|
248
|
+
},
|
|
249
|
+
io,
|
|
250
|
+
native,
|
|
251
|
+
runtime,
|
|
252
|
+
hashBytes,
|
|
253
|
+
inputFiles,
|
|
254
|
+
producers,
|
|
255
|
+
});
|
|
256
|
+
return { built, work, workProject };
|
|
257
|
+
} catch (cause) {
|
|
258
|
+
await fsp.rm(work, { recursive: true, force: true });
|
|
259
|
+
throw cause;
|
|
260
|
+
}
|
|
261
|
+
}
|