@ipab/cli 0.1.0-rc.6 → 0.1.0-rc.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/README.md +96 -34
- package/dist/app-authoring.d.ts +5 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +6 -45
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +6 -45
- package/dist/app-templates.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +1 -39
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +668 -221
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -4
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +20 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +31 -2
- package/dist/context.js.map +1 -1
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/ipc.d.ts +2 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +61 -3
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.js +1 -1
- package/dist/kubo-install.js.map +1 -1
- package/dist/kubo-peers.d.ts.map +1 -1
- package/dist/kubo-peers.js +2 -1
- package/dist/kubo-peers.js.map +1 -1
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +105 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +10 -0
- package/dist/kubo.d.ts.map +1 -1
- package/dist/kubo.js +96 -15
- package/dist/kubo.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +6 -3
- package/dist/runtime.js.map +1 -1
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +5 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +12 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +84 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +736 -0
- package/dist/skills.js.map +1 -0
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +155 -18
- package/dist/space.js.map +1 -1
- package/dist/state-storage.js +1 -1
- package/dist/state-storage.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +32 -13
- package/dist/state.js.map +1 -1
- package/dist/swarm-files.d.ts +2 -2
- package/dist/swarm-files.d.ts.map +1 -1
- package/dist/swarm-files.js +4 -4
- package/dist/swarm-files.js.map +1 -1
- package/dist/swarm-meta.d.ts +14 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +65 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +262 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +172 -6
- package/dist/swarm.d.ts.map +1 -1
- package/dist/swarm.js +1106 -132
- package/dist/swarm.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +2 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +7 -1
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/package.json +7 -6
- package/src/app-authoring.ts +30 -55
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +8 -72
- package/src/builtins.ts +2 -48
- package/src/cli.ts +830 -247
- package/src/config.ts +12 -4
- package/src/context.ts +60 -2
- package/src/errors.ts +1 -25
- package/src/host-error.ts +26 -0
- package/src/ipc.ts +82 -2
- package/src/kubo-install.ts +1 -1
- package/src/kubo-peers.ts +2 -3
- package/src/kubo-topology.ts +135 -0
- package/src/kubo.ts +134 -25
- package/src/runtime.ts +6 -2
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +15 -0
- package/src/skills.ts +1005 -0
- package/src/space-path.ts +30 -0
- package/src/space.ts +216 -33
- package/src/state-storage.ts +1 -1
- package/src/state.ts +38 -13
- package/src/swarm-files.ts +4 -2
- package/src/swarm-meta.ts +90 -0
- package/src/swarm-observations.ts +374 -0
- package/src/swarm.ts +1637 -193
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +9 -2
- package/src/templates.ts +77 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReadonlyFileTree, type TreeEntry } from "@ipab/bundle-builder";
|
|
2
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
3
|
+
import type { TemplateDefinition } from "./template-definition.js";
|
|
4
|
+
export declare function projectOutputTree(tree: ReadonlyFileTree): Promise<{
|
|
5
|
+
entries: {
|
|
6
|
+
path: string;
|
|
7
|
+
kind: TreeEntry["kind"];
|
|
8
|
+
}[];
|
|
9
|
+
truncated: string | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function templateOutputTree(store: IpfsStore, cid: string): Promise<{
|
|
12
|
+
entries: {
|
|
13
|
+
path: string;
|
|
14
|
+
kind: TreeEntry["kind"];
|
|
15
|
+
}[];
|
|
16
|
+
truncated: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function templateParameterRows(definition: TemplateDefinition): string[][];
|
|
19
|
+
export declare function templateRenderExample(selector: string, swarm: string, definition: TemplateDefinition, shell: "powershell" | "posix"): string;
|
|
20
|
+
//# sourceMappingURL=template-presentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-presentation.d.ts","sourceRoot":"","sources":["../src/template-presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAclC,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB;;cACrC,MAAM;cAAQ,SAAS,CAAC,MAAM,CAAC;;;GA0BvD;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM;;cA5B7C,MAAM;cAAQ,SAAS,CAAC,MAAM,CAAC;;;GAqDvD;AAMD,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,kBAAkB,cAuBnE;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,YAAY,GAAG,OAAO,UAqC9B"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { listTree, } from "@ipab/bundle-builder";
|
|
2
|
+
import { bundleLimits, ContentBundleError } from "@ipab/bundle";
|
|
3
|
+
import { addTemplateOutputPath, templateOutputPath } from "./template-paths.js";
|
|
4
|
+
import { templateSource } from "./template-source.js";
|
|
5
|
+
class PreviewLimit extends Error {
|
|
6
|
+
}
|
|
7
|
+
function previewLimit(cause) {
|
|
8
|
+
for (let depth = 0; depth < 16 && cause instanceof Error; depth++) {
|
|
9
|
+
if (cause instanceof PreviewLimit)
|
|
10
|
+
return cause;
|
|
11
|
+
cause = cause.cause;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
export async function projectOutputTree(tree) {
|
|
16
|
+
const entries = [];
|
|
17
|
+
const paths = new Map();
|
|
18
|
+
let pathBytes = 0;
|
|
19
|
+
const collect = async (directory, depth) => {
|
|
20
|
+
if (depth >= 8)
|
|
21
|
+
throw new PreviewLimit("depth limit (8)");
|
|
22
|
+
for (const entry of await listTree(tree, directory)) {
|
|
23
|
+
if (entries.length >= 64)
|
|
24
|
+
throw new PreviewLimit("entry limit (64)");
|
|
25
|
+
const source = `${directory}/${entry.name}`;
|
|
26
|
+
const { target } = templateOutputPath(source, entry.kind);
|
|
27
|
+
pathBytes += Buffer.byteLength(target);
|
|
28
|
+
if (pathBytes > 16 * 1024)
|
|
29
|
+
throw new PreviewLimit("path byte limit (16 KiB)");
|
|
30
|
+
addTemplateOutputPath(paths, target, entry.kind);
|
|
31
|
+
entries.push({ path: target, kind: entry.kind });
|
|
32
|
+
if (entry.kind === "directory")
|
|
33
|
+
await collect(source, depth + 1);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
let truncated;
|
|
37
|
+
try {
|
|
38
|
+
await collect("project", 0);
|
|
39
|
+
}
|
|
40
|
+
catch (cause) {
|
|
41
|
+
const limit = previewLimit(cause);
|
|
42
|
+
if (!limit)
|
|
43
|
+
throw cause;
|
|
44
|
+
truncated = limit.message;
|
|
45
|
+
}
|
|
46
|
+
return { entries, truncated };
|
|
47
|
+
}
|
|
48
|
+
export async function templateOutputTree(store, cid) {
|
|
49
|
+
let reads = 0, bytes = 0;
|
|
50
|
+
try {
|
|
51
|
+
const source = await templateSource(cid, {
|
|
52
|
+
async resolveCid(key, options) {
|
|
53
|
+
if (++reads > 512)
|
|
54
|
+
throw new PreviewLimit("content read limit (512)");
|
|
55
|
+
const block = await store.block.get(key.toString(), options);
|
|
56
|
+
if (block.byteLength > bundleLimits.blockBytes)
|
|
57
|
+
throw new ContentBundleError("LIMIT_EXCEEDED", "Template source exceeds the Bundle block byte limit.");
|
|
58
|
+
bytes += block.byteLength;
|
|
59
|
+
if (bytes > 2 * 1024 * 1024)
|
|
60
|
+
throw new PreviewLimit("content byte limit (2 MiB)");
|
|
61
|
+
return block;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return await projectOutputTree(source.tree);
|
|
65
|
+
}
|
|
66
|
+
catch (cause) {
|
|
67
|
+
const limit = previewLimit(cause);
|
|
68
|
+
if (!limit)
|
|
69
|
+
throw cause;
|
|
70
|
+
return { entries: [], truncated: limit.message };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function hasDefault(parameter) {
|
|
74
|
+
return Object.hasOwn(parameter, "default");
|
|
75
|
+
}
|
|
76
|
+
export function templateParameterRows(definition) {
|
|
77
|
+
const names = Object.keys(definition.parameters).sort();
|
|
78
|
+
const ordered = [
|
|
79
|
+
"name",
|
|
80
|
+
"description",
|
|
81
|
+
...names.filter((name) => name !== "name" && name !== "description"),
|
|
82
|
+
];
|
|
83
|
+
return ordered
|
|
84
|
+
.filter((name) => Object.hasOwn(definition.parameters, name))
|
|
85
|
+
.map((name) => {
|
|
86
|
+
const parameter = definition.parameters[name];
|
|
87
|
+
return [
|
|
88
|
+
name,
|
|
89
|
+
parameter.type,
|
|
90
|
+
parameter.required && !hasDefault(parameter) ? "yes" : "no",
|
|
91
|
+
hasDefault(parameter) ? JSON.stringify(parameter.default) : "-",
|
|
92
|
+
name === "name"
|
|
93
|
+
? "NAME positional"
|
|
94
|
+
: name === "description"
|
|
95
|
+
? "--description TEXT"
|
|
96
|
+
: `--param ${name}=VALUE`,
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export function templateRenderExample(selector, swarm, definition, shell) {
|
|
101
|
+
const quote = (value) => {
|
|
102
|
+
// Shell controls cannot safely be embedded in a copyable, single-line example.
|
|
103
|
+
const safe = [...value].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127);
|
|
104
|
+
if (safe)
|
|
105
|
+
throw new Error("Cannot produce a render example containing control characters.");
|
|
106
|
+
return shell === "powershell"
|
|
107
|
+
? `'${value.replaceAll("'", "''")}'`
|
|
108
|
+
: `'${value.replaceAll("'", "'\\''")}'`;
|
|
109
|
+
};
|
|
110
|
+
const args = [
|
|
111
|
+
"ipab",
|
|
112
|
+
"--swarm",
|
|
113
|
+
quote(swarm),
|
|
114
|
+
"templates",
|
|
115
|
+
"render",
|
|
116
|
+
quote(selector),
|
|
117
|
+
quote("my-project"),
|
|
118
|
+
];
|
|
119
|
+
for (const name of Object.keys(definition.parameters).sort()) {
|
|
120
|
+
const parameter = definition.parameters[name];
|
|
121
|
+
if (name === "name" || !parameter.required || hasDefault(parameter))
|
|
122
|
+
continue;
|
|
123
|
+
const example = {
|
|
124
|
+
string: "VALUE",
|
|
125
|
+
number: "0",
|
|
126
|
+
boolean: "true",
|
|
127
|
+
json: "null",
|
|
128
|
+
}[parameter.type];
|
|
129
|
+
args.push("--param", quote(`${name}=${example}`));
|
|
130
|
+
}
|
|
131
|
+
return args.join(" ");
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=template-presentation.js.map
|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AAC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;IAC5C,CAAC,CAAC;IACF,MAAM,IAAI,GAAG;QACX,MAAM;QACN,SAAS;QACT,KAAK,CAAC,KAAK,CAAC;QACZ,WAAW;QACX,QAAQ;QACR,KAAK,CAAC,QAAQ,CAAC;QACf,KAAK,CAAC,YAAY,CAAC;KACpB,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC7D,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAE,CAAC;QAC/C,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,IAAI,UAAU,CAAC,SAAS,CAAC;YACjE,SAAS;QACX,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,MAAM;YACf,IAAI,EAAE,MAAM;SACb,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReadonlyFileTree } from "@ipab/bundle-builder";
|
|
2
2
|
import { type AuthoringOptions } from "./authoring.js";
|
|
3
|
-
export declare
|
|
3
|
+
export declare const seedTemplateNames: readonly ["node", "web-app", "check", "bundle-viewer"];
|
|
4
|
+
export declare function seedTemplateSource(selector: (typeof seedTemplateNames)[number], options?: AuthoringOptions): Promise<{
|
|
4
5
|
blocks: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
5
6
|
tree: ReadonlyFileTree;
|
|
6
7
|
cid: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-source.d.ts","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,wBAAsB,
|
|
1
|
+
{"version":3,"file":"template-source.d.ts","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAI9E,eAAO,MAAM,iBAAiB,wDAKpB,CAAC;AAEX,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,EAC5C,OAAO,GAAE,gBAAqB;;;;;GAa/B;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB;;;;GAoG1B"}
|
package/dist/template-source.js
CHANGED
|
@@ -8,7 +8,13 @@ import { openContent } from "@ipab/ipfs-store";
|
|
|
8
8
|
import { readCar, selectedTree } from "./authoring.js";
|
|
9
9
|
import { HostError } from "./errors.js";
|
|
10
10
|
import { builtinTemplateSchema } from "./template-definition.js";
|
|
11
|
-
export
|
|
11
|
+
export const seedTemplateNames = [
|
|
12
|
+
"node",
|
|
13
|
+
"web-app",
|
|
14
|
+
"check",
|
|
15
|
+
"bundle-viewer",
|
|
16
|
+
];
|
|
17
|
+
export async function seedTemplateSource(selector, options = {}) {
|
|
12
18
|
const car = await readCar(fileURLToPath(new URL(`../dist/builtins/template.${selector}.car`, import.meta.url)), options);
|
|
13
19
|
const source = await templateSource(car.root.toString(), {
|
|
14
20
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-source.js","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,SAAS,GAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAyB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"template-source.js","sourceRoot":"","sources":["../src/template-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,SAAS,GAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAyB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0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,CAAC,QAAQ,EAAE,EACpB,QAAQ,CACT,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC;wBACX,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,IAAI,EACF,KAAK,CAAC,IAAI,KAAK,WAAW;4BACxB,CAAC,CAAE,WAAqB;4BACxB,CAAC,CAAE,MAAgB;qBACxB,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,OAAO,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,mBAAmB,CAClC,MAAM,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAC3E,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IpfsStore } from "@ipab/ipfs-store";
|
|
2
|
+
export declare function inspectTemplate(store: IpfsStore, cid: string): Promise<{
|
|
3
|
+
templateCid: string;
|
|
4
|
+
typeCid: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
definition: import("./template-definition.js").TemplateDefinition;
|
|
8
|
+
parameters: Record<string, import("./template-definition.js").TemplateParameter>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function templatePublicationSource(input: string, store: IpfsStore): Promise<string>;
|
|
11
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASlD,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM;;;;;;;GAsBlE;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,mBAqCjB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { lstat } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { CID } from "multiformats/cid";
|
|
4
|
+
import { bundleLimits, openBundle } from "@ipab/bundle";
|
|
5
|
+
import { HostError } from "./errors.js";
|
|
6
|
+
import { publicationSource } from "./publish-source.js";
|
|
7
|
+
import { bytes } from "./space.js";
|
|
8
|
+
import { templateDefinition, templateSchemaCid, } from "./template-definition.js";
|
|
9
|
+
export async function inspectTemplate(store, cid) {
|
|
10
|
+
const bundle = await openBundle(CID.parse(cid), {
|
|
11
|
+
resolveCid: (key) => store.block.get(key.toString()),
|
|
12
|
+
});
|
|
13
|
+
if (bundle.schemaKey !== templateSchemaCid.toString())
|
|
14
|
+
throw new HostError("Template Bundle must use the exact project-template type CID.");
|
|
15
|
+
const definition = templateDefinition(await bytes(await bundle.readFile(bundle.manifest.entry), bundleLimits.parsingBytes));
|
|
16
|
+
return {
|
|
17
|
+
templateCid: bundle.cid.toString(),
|
|
18
|
+
typeCid: bundle.schemaKey,
|
|
19
|
+
title: bundle.manifest.title,
|
|
20
|
+
description: bundle.manifest.description,
|
|
21
|
+
definition,
|
|
22
|
+
parameters: definition.parameters,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export async function templatePublicationSource(input, store) {
|
|
26
|
+
let cid;
|
|
27
|
+
try {
|
|
28
|
+
cid = CID.parse(input);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Only explicit local Template Bundles are accepted besides exact CIDs.
|
|
32
|
+
}
|
|
33
|
+
if (!cid) {
|
|
34
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(input) &&
|
|
35
|
+
!/^[A-Za-z]:[\\/]/.test(input))
|
|
36
|
+
throw new HostError("Template SOURCE does not accept URIs; use an exact CID, self-contained CAR or explicit Template Bundle directory.");
|
|
37
|
+
const path = resolve(input);
|
|
38
|
+
const stat = await lstat(path);
|
|
39
|
+
if (stat.isSymbolicLink() ||
|
|
40
|
+
(!stat.isDirectory() &&
|
|
41
|
+
!(stat.isFile() && path.toLowerCase().endsWith(".car"))))
|
|
42
|
+
throw new HostError("Template SOURCE must be an exact CID, self-contained CAR or explicit Template Bundle directory.");
|
|
43
|
+
if (stat.isDirectory()) {
|
|
44
|
+
const manifest = await lstat(resolve(path, ".bundle.yaml"));
|
|
45
|
+
if (!manifest.isFile() || manifest.isSymbolicLink())
|
|
46
|
+
throw new HostError("Template directory requires an explicit regular .bundle.yaml.");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const content = await publicationSource(input, store);
|
|
50
|
+
await inspectTemplate(store, content);
|
|
51
|
+
return content;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,KAAgB,EAAE,GAAW;IACjE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QAC9C,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,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I,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAE1D,MAAM,IAAI,SAAS,CACjB,iGAAiG,CAClG,CAAC;QACJ,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,QAAQ,CAAC,cAAc,EAAE;gBACjD,MAAM,IAAI,SAAS,CACjB,+DAA+D,CAChE,CAAC;QACN,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACtD,MAAM,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ipab/cli",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Node subprocess IPAB host.",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=22.
|
|
22
|
+
"node": ">=22.20.0"
|
|
23
23
|
},
|
|
24
24
|
"bin": {
|
|
25
25
|
"ipab": "dist/main.js"
|
|
@@ -42,18 +42,19 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ipld/dag-cbor": "10.0.2",
|
|
44
44
|
"liquidjs": "10.30.1",
|
|
45
|
-
"@ipab/web-app": "0.1.0-rc.
|
|
45
|
+
"@ipab/web-app": "0.1.0-rc.4",
|
|
46
46
|
"esbuild": "0.28.2",
|
|
47
|
-
"@ipab/bundle-builder": "0.1.0-rc.
|
|
47
|
+
"@ipab/bundle-builder": "0.1.0-rc.8",
|
|
48
48
|
"@ipld/car": "5.4.6",
|
|
49
49
|
"@ipld/dag-pb": "4.2.0",
|
|
50
|
-
"@ipab/bundle": "0.1.0-rc.
|
|
51
|
-
"@ipab/ipfs-store": "0.1.0-rc.
|
|
50
|
+
"@ipab/bundle": "0.1.0-rc.8",
|
|
51
|
+
"@ipab/ipfs-store": "0.1.0-rc.4",
|
|
52
52
|
"ipfs-unixfs": "13.1.2",
|
|
53
53
|
"ipfs-unixfs-importer": "17.1.1",
|
|
54
54
|
"multiformats": "14.0.5",
|
|
55
55
|
"string-width": "8.2.1",
|
|
56
56
|
"ignore": "7.0.16",
|
|
57
|
+
"skills": "1.9.1",
|
|
57
58
|
"yaml": "2.9.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
package/src/app-authoring.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { lstat, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import { isBuiltin } from "node:module";
|
|
4
3
|
import {
|
|
5
4
|
basename,
|
|
6
5
|
dirname,
|
|
@@ -11,9 +10,8 @@ import {
|
|
|
11
10
|
sep,
|
|
12
11
|
} from "node:path";
|
|
13
12
|
import { StringDecoder } from "node:string_decoder";
|
|
14
|
-
import { compileFunction } from "node:vm";
|
|
15
13
|
import { stringify } from "yaml";
|
|
16
|
-
import { parseData } from "@ipab/bundle";
|
|
14
|
+
import { parseData, type BundleType } from "@ipab/bundle";
|
|
17
15
|
import { filesystemTree } from "@ipab/bundle-builder/node";
|
|
18
16
|
import { encodeBundleCar, memoryTree, readBytes } from "@ipab/bundle-builder";
|
|
19
17
|
import {
|
|
@@ -37,7 +35,12 @@ import {
|
|
|
37
35
|
builtinAppSchema,
|
|
38
36
|
} from "./app-definition.js";
|
|
39
37
|
import { appTemplate } from "./app-templates.js";
|
|
40
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
buildChain,
|
|
40
|
+
compileAppProgram,
|
|
41
|
+
projectBuild,
|
|
42
|
+
runPrebuild,
|
|
43
|
+
} from "./app-prebuild.js";
|
|
41
44
|
import { captureSource, sourceFingerprint } from "./source-bundle.js";
|
|
42
45
|
export { appSchema } from "./app-definition.js";
|
|
43
46
|
|
|
@@ -199,6 +202,8 @@ export async function buildApp(
|
|
|
199
202
|
outputDir?: string;
|
|
200
203
|
replace?: boolean;
|
|
201
204
|
includeSource?: boolean;
|
|
205
|
+
/** Exact types from an author's Open App definition; exclusive with config paths. */
|
|
206
|
+
supportedTypes?: readonly BundleType[];
|
|
202
207
|
preparedDirectory?: string;
|
|
203
208
|
} = {},
|
|
204
209
|
): Promise<
|
|
@@ -340,7 +345,19 @@ export async function buildApp(
|
|
|
340
345
|
throw new HostError(
|
|
341
346
|
"App metadata cannot override the generated source declaration.",
|
|
342
347
|
);
|
|
343
|
-
|
|
348
|
+
if (options.supportedTypes && schemas.size)
|
|
349
|
+
throw new HostError(
|
|
350
|
+
"Use either supportedTypes or supportedSchemas paths, not both.",
|
|
351
|
+
);
|
|
352
|
+
const declared = options.supportedTypes?.map(
|
|
353
|
+
(type, index) =>
|
|
354
|
+
[`schemas/${index}.json`, new TextEncoder().encode(json(type))] as const,
|
|
355
|
+
);
|
|
356
|
+
const supportedSchemas = await buildSupportedSchemas(
|
|
357
|
+
declared ? memoryTree(new Map(declared)) : tree,
|
|
358
|
+
declared ? new Set(declared.map(([path]) => path)) : schemas,
|
|
359
|
+
options,
|
|
360
|
+
);
|
|
344
361
|
const description = appDescription({
|
|
345
362
|
...defaults,
|
|
346
363
|
...overrides,
|
|
@@ -425,7 +442,6 @@ export async function buildApp(
|
|
|
425
442
|
options.signal?.throwIfAborted();
|
|
426
443
|
const stage = await mkdtemp(join(root, ".ipab-app-"));
|
|
427
444
|
try {
|
|
428
|
-
const { build } = await import("esbuild");
|
|
429
445
|
const bundleStage = join(stage, "bundle");
|
|
430
446
|
const input = prebuild ? join(stage, "input") : root;
|
|
431
447
|
if (prebuild) {
|
|
@@ -436,56 +452,13 @@ export async function buildApp(
|
|
|
436
452
|
const prebuiltSource = prebuild
|
|
437
453
|
? await readBytes(inputTree, entry, 8 * 1024 * 1024, options)
|
|
438
454
|
: undefined;
|
|
439
|
-
if (prebuiltSource) {
|
|
440
|
-
try {
|
|
441
|
-
const source = new TextDecoder("utf-8", { fatal: true }).decode(
|
|
442
|
-
prebuiltSource,
|
|
443
|
-
);
|
|
444
|
-
compileFunction(source.replace(/^#![^\r\n]*/, ""), [
|
|
445
|
-
"exports",
|
|
446
|
-
"require",
|
|
447
|
-
"module",
|
|
448
|
-
"__filename",
|
|
449
|
-
"__dirname",
|
|
450
|
-
]);
|
|
451
|
-
} catch (cause) {
|
|
452
|
-
const error = new HostError(
|
|
453
|
-
"Prebuilt App entry must be valid Node CommonJS; it is packaged without transformation.",
|
|
454
|
-
);
|
|
455
|
-
error.cause = cause;
|
|
456
|
-
throw error;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
455
|
await mkdir(join(bundleStage, "resources"), { recursive: true });
|
|
460
|
-
const program = await
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
format: "cjs",
|
|
467
|
-
target: "node22.15",
|
|
468
|
-
packages: prebuild ? "external" : "bundle",
|
|
469
|
-
metafile: true,
|
|
470
|
-
write: false,
|
|
471
|
-
logLevel: "silent",
|
|
472
|
-
logOverride: {
|
|
473
|
-
"unsupported-dynamic-import": "error",
|
|
474
|
-
"unsupported-require-call": "error",
|
|
475
|
-
"indirect-require": "error",
|
|
476
|
-
},
|
|
477
|
-
});
|
|
478
|
-
if (
|
|
479
|
-
program.outputFiles.length !== 1 ||
|
|
480
|
-
program.outputFiles[0]!.contents.length > 8 * 1024 * 1024 ||
|
|
481
|
-
(prebuild && Object.keys(program.metafile.inputs).length !== 1) ||
|
|
482
|
-
Object.values(program.metafile.outputs).some((file) =>
|
|
483
|
-
file.imports.some((item) => item.external && !isBuiltin(item.path)),
|
|
484
|
-
)
|
|
485
|
-
)
|
|
486
|
-
throw new HostError(
|
|
487
|
-
"App must bundle into one self-contained .cjs of at most 8 MiB; only Node builtins may remain external.",
|
|
488
|
-
);
|
|
456
|
+
const program = await compileAppProgram(
|
|
457
|
+
input,
|
|
458
|
+
entry,
|
|
459
|
+
join(bundleStage, "resources", "app.cjs"),
|
|
460
|
+
prebuiltSource,
|
|
461
|
+
);
|
|
489
462
|
if (sourceFiles && !prebuild)
|
|
490
463
|
for (const path of Object.keys(program.metafile.inputs))
|
|
491
464
|
if (
|
|
@@ -727,6 +700,8 @@ export async function prepareApp(
|
|
|
727
700
|
options: AuthoringOptions & {
|
|
728
701
|
replace?: boolean;
|
|
729
702
|
includeSource?: boolean;
|
|
703
|
+
/** Exact types from an author's Open App definition; exclusive with config paths. */
|
|
704
|
+
supportedTypes?: readonly BundleType[];
|
|
730
705
|
} = {},
|
|
731
706
|
) {
|
|
732
707
|
const root = resolve(directory);
|
package/src/app-prebuild.ts
CHANGED
|
@@ -3,10 +3,71 @@ import { lstat, readFile, realpath } from "node:fs/promises";
|
|
|
3
3
|
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
4
4
|
import { promisify } from "node:util";
|
|
5
5
|
import { StringDecoder } from "node:string_decoder";
|
|
6
|
+
import { isBuiltin } from "node:module";
|
|
7
|
+
import { compileFunction } from "node:vm";
|
|
6
8
|
import { HostError, object } from "./errors.js";
|
|
7
9
|
import { nodeError, type AuthoringOptions } from "./authoring.js";
|
|
8
10
|
import { relativePath } from "./space.js";
|
|
9
11
|
|
|
12
|
+
export async function compileAppProgram(
|
|
13
|
+
input: string,
|
|
14
|
+
entry: string,
|
|
15
|
+
outfile: string,
|
|
16
|
+
prebuiltSource?: Uint8Array,
|
|
17
|
+
) {
|
|
18
|
+
if (prebuiltSource) {
|
|
19
|
+
try {
|
|
20
|
+
const source = new TextDecoder("utf-8", { fatal: true }).decode(
|
|
21
|
+
prebuiltSource,
|
|
22
|
+
);
|
|
23
|
+
compileFunction(source.replace(/^#![^\r\n]*/, ""), [
|
|
24
|
+
"exports",
|
|
25
|
+
"require",
|
|
26
|
+
"module",
|
|
27
|
+
"__filename",
|
|
28
|
+
"__dirname",
|
|
29
|
+
]);
|
|
30
|
+
} catch (cause) {
|
|
31
|
+
const error = new HostError(
|
|
32
|
+
"Prebuilt App entry must be valid Node CommonJS; it is packaged without transformation.",
|
|
33
|
+
);
|
|
34
|
+
error.cause = cause;
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const { build } = await import("esbuild");
|
|
39
|
+
const program = await build({
|
|
40
|
+
absWorkingDir: input,
|
|
41
|
+
entryPoints: [entry],
|
|
42
|
+
outfile,
|
|
43
|
+
bundle: true,
|
|
44
|
+
platform: "node",
|
|
45
|
+
format: "cjs",
|
|
46
|
+
target: "node22.15",
|
|
47
|
+
packages: prebuiltSource ? "external" : "bundle",
|
|
48
|
+
metafile: true,
|
|
49
|
+
write: false,
|
|
50
|
+
logLevel: "silent",
|
|
51
|
+
logOverride: {
|
|
52
|
+
"unsupported-dynamic-import": "error",
|
|
53
|
+
"unsupported-require-call": "error",
|
|
54
|
+
"indirect-require": "error",
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
if (
|
|
58
|
+
program.outputFiles.length !== 1 ||
|
|
59
|
+
program.outputFiles[0]!.contents.length > 8 * 1024 * 1024 ||
|
|
60
|
+
(prebuiltSource && Object.keys(program.metafile.inputs).length !== 1) ||
|
|
61
|
+
Object.values(program.metafile.outputs).some((file) =>
|
|
62
|
+
file.imports.some((item) => item.external && !isBuiltin(item.path)),
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
throw new HostError(
|
|
66
|
+
"App must bundle into one self-contained .cjs of at most 8 MiB; only Node builtins may remain external.",
|
|
67
|
+
);
|
|
68
|
+
return program;
|
|
69
|
+
}
|
|
70
|
+
|
|
10
71
|
export interface ProjectBuild {
|
|
11
72
|
strategy: "ipab-prebuild";
|
|
12
73
|
typecheck: { config: string; entry: string }[];
|