@telorun/cli 0.59.0 → 0.61.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/README.md +32 -14
- package/dist/bundle/partition-layers.d.ts +71 -0
- package/dist/bundle/partition-layers.d.ts.map +1 -0
- package/dist/bundle/partition-layers.js +166 -0
- package/dist/bundle/partition-layers.js.map +1 -0
- package/dist/bundle/warm-layers.d.ts +36 -0
- package/dist/bundle/warm-layers.d.ts.map +1 -0
- package/dist/bundle/warm-layers.js +85 -0
- package/dist/bundle/warm-layers.js.map +1 -0
- package/dist/commands/install.d.ts +1 -0
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +25 -6
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/publish.d.ts +3 -0
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +33 -16
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +21 -3
- package/dist/commands/run.js.map +1 -1
- package/dist/logger.d.ts +7 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +48 -22
- package/dist/logger.js.map +1 -1
- package/package.json +5 -5
- package/dist/bundle/extract.d.ts +0 -22
- package/dist/bundle/extract.d.ts.map +0 -1
- package/dist/bundle/extract.js +0 -97
- package/dist/bundle/extract.js.map +0 -1
package/dist/bundle/extract.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { defaultTransportRegistry, cachePathForCanonical } from "@telorun/kernel";
|
|
2
|
-
import { IntegrityError } from "@telorun/analyzer";
|
|
3
|
-
import { existsSync } from "fs";
|
|
4
|
-
import * as fs from "fs/promises";
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
/** Marker written into a module's cache dir after a successful extraction.
|
|
7
|
-
* Registry versions are immutable, so its presence means the bundle is
|
|
8
|
-
* already on disk and the fetch can be skipped (the marker is written last,
|
|
9
|
-
* so a partial extraction leaves no marker and re-runs). */
|
|
10
|
-
const EXTRACTED_MARKER = ".telo-bundle";
|
|
11
|
-
/** True when the module's owner Application/Library doc declares a non-empty
|
|
12
|
-
* `files:` list — i.e. it ships a payload worth fetching. Reads the graph's
|
|
13
|
-
* already-parsed manifest so a payload-less module triggers no network at all. */
|
|
14
|
-
function declaresFiles(module) {
|
|
15
|
-
const doc = module.owner.manifests.find((m) => m?.kind === "Telo.Application" || m?.kind === "Telo.Library");
|
|
16
|
-
return Array.isArray(doc?.files) && doc.files.length > 0;
|
|
17
|
-
}
|
|
18
|
-
/** A module fetched from the registry / an HTTP URL — its assets live in a
|
|
19
|
-
* bundle, not on the local disk. file:// (local dev) and memory:// are
|
|
20
|
-
* skipped: their assets are already where Http.Static resolves them. */
|
|
21
|
-
function isRemoteSource(source) {
|
|
22
|
-
if (source.startsWith("file://") || source.startsWith("memory://"))
|
|
23
|
-
return false;
|
|
24
|
-
if (source.startsWith("http://") || source.startsWith("https://"))
|
|
25
|
-
return true;
|
|
26
|
-
// Registry ref form: namespace/name@version
|
|
27
|
-
return source.includes("@") && source.includes("/");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* For every module in `graph` that ships a `files:` payload from a remote
|
|
31
|
-
* transport, fetch its full artifact through the transport its ref selects and
|
|
32
|
-
* extract the payload into the module's cache directory (next to the cached
|
|
33
|
-
* `telo.yaml`), so a relative `Http.Static` root / bundled controller `path:`
|
|
34
|
-
* resolves on disk exactly as it does in dev.
|
|
35
|
-
*
|
|
36
|
-
* The fetch keys off each module's **pinned** `requestedUrl` (the import ref
|
|
37
|
-
* with its `#sha256-...`), so the transport verifies the manifest against the
|
|
38
|
-
* inline hash and the payload against that manifest's `filesIntegrity` — the
|
|
39
|
-
* Merkle chain stays anchored to the importer's pin.
|
|
40
|
-
*
|
|
41
|
-
* Runs after `writeManifestCache`. Best-effort per module for transient fetch
|
|
42
|
-
* failures (reported and skipped — the manifest itself is still cached), but an
|
|
43
|
-
* integrity failure (`IntegrityError`) or a tar entry escaping the module
|
|
44
|
-
* directory is a hard error (tamper / path-traversal guard).
|
|
45
|
-
*
|
|
46
|
-
* Returns the number of bundles extracted.
|
|
47
|
-
*/
|
|
48
|
-
export async function extractModuleBundles(graph, entryDir, registryUrl, manifestsDir, onWarn) {
|
|
49
|
-
let count = 0;
|
|
50
|
-
const seen = new Set();
|
|
51
|
-
const transports = defaultTransportRegistry(registryUrl);
|
|
52
|
-
for (const [, module] of graph.modules) {
|
|
53
|
-
const file = module.owner;
|
|
54
|
-
if (seen.has(file.source))
|
|
55
|
-
continue;
|
|
56
|
-
seen.add(file.source);
|
|
57
|
-
if (!isRemoteSource(file.source))
|
|
58
|
-
continue;
|
|
59
|
-
if (!declaresFiles(module))
|
|
60
|
-
continue;
|
|
61
|
-
const manifestCachePath = cachePathForCanonical(file.source, entryDir, registryUrl, manifestsDir);
|
|
62
|
-
if (!manifestCachePath)
|
|
63
|
-
continue;
|
|
64
|
-
const moduleDir = path.dirname(manifestCachePath);
|
|
65
|
-
// Extract-once: a pinned registry version is immutable, so once its bundle
|
|
66
|
-
// is on disk there is nothing to re-fetch.
|
|
67
|
-
if (existsSync(path.join(moduleDir, EXTRACTED_MARKER)))
|
|
68
|
-
continue;
|
|
69
|
-
let files;
|
|
70
|
-
try {
|
|
71
|
-
({ files } = await transports.fetchArtifact(file.requestedUrl));
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
// A tamper failure must never be swallowed; a transient fetch failure is
|
|
75
|
-
// best-effort (the manifest is still cached, runtime surfaces a clear
|
|
76
|
-
// error if the payload is actually needed).
|
|
77
|
-
if (err instanceof IntegrityError)
|
|
78
|
-
throw err;
|
|
79
|
-
onWarn(`could not fetch bundle for ${file.requestedUrl}: ` +
|
|
80
|
-
(err instanceof Error ? err.message : String(err)));
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const realModuleDir = path.resolve(moduleDir) + path.sep;
|
|
84
|
-
for (const entry of files) {
|
|
85
|
-
const dest = path.resolve(moduleDir, entry.name);
|
|
86
|
-
if (!dest.startsWith(realModuleDir)) {
|
|
87
|
-
throw new Error(`bundle for ${file.requestedUrl} contains entry '${entry.name}' that resolves outside the module cache directory.`);
|
|
88
|
-
}
|
|
89
|
-
await fs.mkdir(path.dirname(dest), { recursive: true });
|
|
90
|
-
await fs.writeFile(dest, entry.content);
|
|
91
|
-
}
|
|
92
|
-
await fs.writeFile(path.join(moduleDir, EXTRACTED_MARKER), "");
|
|
93
|
-
count++;
|
|
94
|
-
}
|
|
95
|
-
return count;
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=extract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/bundle/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAuC,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;6DAG6D;AAC7D,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;mFAEmF;AACnF,SAAS,aAAa,CAAC,MAAoB;IACzC,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,kBAAkB,IAAI,CAAC,EAAE,IAAI,KAAK,cAAc,CACjC,CAAC;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED;;yEAEyE;AACzE,SAAS,cAAc,CAAC,MAAc;IACpC,IAAI,MAAM,CAAC,UAAU,CAAC,SA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