@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.1
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 +7 -1
- package/dist/app-authoring.d.ts +1 -2
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +8 -9
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +0 -6
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +1 -7
- package/dist/app-definition.js.map +1 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +8 -0
- package/dist/app-templates.js.map +1 -1
- package/dist/authoring.d.ts +5 -14
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +10 -39
- package/dist/authoring.js.map +1 -1
- 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 +5 -10
- package/dist/builtins.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +124 -86
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -17
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +1 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +10 -0
- package/dist/context.js.map +1 -1
- package/dist/ipc.d.ts +2 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +10 -1
- package/dist/ipc.js.map +1 -1
- package/dist/pins.d.ts +9 -9
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +10 -28
- package/dist/pins.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/source-bundle.d.ts +0 -1
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +0 -1
- package/dist/source-bundle.js.map +1 -1
- package/dist/state.d.ts +20 -10
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +27 -16
- package/dist/state.js.map +1 -1
- package/dist/template-definition.d.ts +0 -17
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +1 -10
- package/dist/template-definition.js.map +1 -1
- package/package.json +10 -10
- package/src/app-authoring.ts +15 -13
- package/src/app-definition.ts +1 -7
- package/src/app-templates.ts +13 -0
- package/src/authoring.ts +22 -55
- package/src/builtins.ts +5 -11
- package/src/cli.ts +152 -107
- package/src/config.ts +21 -20
- package/src/context.ts +10 -0
- package/src/ipc.ts +8 -0
- package/src/pins.ts +14 -28
- package/src/runtime.ts +1 -0
- package/src/source-bundle.ts +0 -1
- package/src/state.ts +40 -26
- package/src/template-definition.ts +1 -10
package/dist/builtins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { builtinTemplateSchema,
|
|
1
|
+
import { builtinAppSchema } from "./app-definition.js";
|
|
2
|
+
import { builtinTemplateSchema, templateSchema, templateSchemaCid, } from "./template-definition.js";
|
|
3
3
|
import { builtinTemplateNames } from "./app-templates.js";
|
|
4
4
|
import { builtinTemplateSource } from "./template-source.js";
|
|
5
5
|
async function loadBuiltins() {
|
|
@@ -15,17 +15,12 @@ async function loadBuiltins() {
|
|
|
15
15
|
builtin: true,
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
-
for (const
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
for (const schema of [
|
|
19
|
+
await builtinAppSchema(),
|
|
20
|
+
await builtinTemplateSchema(),
|
|
21
21
|
]) {
|
|
22
22
|
const cid = schema.cid.toString();
|
|
23
23
|
blocks.set(cid, schema.bytes);
|
|
24
|
-
add(name, cid, {
|
|
25
|
-
kind: "schema",
|
|
26
|
-
typeName: schema.manifest.name,
|
|
27
|
-
schemaCid: cid,
|
|
28
|
-
});
|
|
29
24
|
}
|
|
30
25
|
for (const [name, selector] of builtinTemplateNames) {
|
|
31
26
|
const template = await builtinTemplateSource(selector);
|
package/dist/builtins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../src/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,KAAK,UAAU,YAAY;IAIzB,MAAM,IAAI,GAAe,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC7C,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,GAAW,EAAE,QAAqB,EAAE,EAAE;QAC/D,IAAI,CAAC,IAAI,CAAC;YACR,IAAI;YACJ,GAAG;YACH,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,OAAO;YACf,QAAQ;YACR,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACL,CAAC,CAAC;IACF,KAAK,MAAM,MAAM,IAAI;QACnB,MAAM,gBAAgB,EAAE;QACxB,MAAM,qBAAqB,EAAE;KAC9B,EAAE,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAClC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,oBAAoB,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnE,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,cAAc,CAAC,IAAI;YAC7B,SAAS,EAAE,iBAAiB,CAAC,QAAQ,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED,IAAI,MAAmD,CAAC;AACxD,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAoBrB,MAAM,WAAW,EAAE;IACjB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACzC;AACD,eAAO,MAAM,SAAS,EAAE,EAwBvB,CAAC;AA0SF,wBAAgB,IAAI,CAAC,IAAI,SAAK,GAAG,MAAM,CA+DtC;AAyGD,UAAU,MAAM;IACd,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAkBD,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAmMrD;AAqjBD,wBAAsB,MAAM,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,EAAc,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHi
|
|
|
9
9
|
import { execute } from "./runtime.js";
|
|
10
10
|
import { validatedBundle } from "./space.js";
|
|
11
11
|
import { exactCid, pinName, State } from "./state.js";
|
|
12
|
-
import { buildBundle,
|
|
12
|
+
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
13
13
|
import { buildApp, initApp } from "./app-authoring.js";
|
|
14
14
|
import { schemaAlias } from "./app-definition.js";
|
|
15
15
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
@@ -42,7 +42,6 @@ export const processIO = {
|
|
|
42
42
|
const commands = {
|
|
43
43
|
init: "init NAME [DIR] [OPTIONS]",
|
|
44
44
|
build: "build [DIR] [OPTIONS]",
|
|
45
|
-
"bundle init": "bundle init TYPE DIR",
|
|
46
45
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
47
46
|
"bundle inspect": "bundle inspect SOURCE",
|
|
48
47
|
"bundle import": "bundle import FILE.car",
|
|
@@ -50,7 +49,7 @@ const commands = {
|
|
|
50
49
|
open: "open [--log] CONTENT",
|
|
51
50
|
"pin add": "pin add NAME CID",
|
|
52
51
|
"pin delete": "pin delete NAME",
|
|
53
|
-
"pin list": "pin list [--
|
|
52
|
+
"pin list": "pin list [--type TYPE]",
|
|
54
53
|
"pin show": "pin show NAME",
|
|
55
54
|
"pin rename": "pin rename OLD_NAME NEW_NAME",
|
|
56
55
|
"register list": "register list",
|
|
@@ -59,6 +58,8 @@ const commands = {
|
|
|
59
58
|
"config get": "config get [KEY]",
|
|
60
59
|
"config set": "config set KEY VALUE",
|
|
61
60
|
"config reset": "config reset KEY",
|
|
61
|
+
"store usage": "store usage",
|
|
62
|
+
"store gc": "store gc",
|
|
62
63
|
"history list": "history list [OPTIONS]",
|
|
63
64
|
"history show": "history show RUN_ID",
|
|
64
65
|
"history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
@@ -68,11 +69,28 @@ const groups = {
|
|
|
68
69
|
pin: "Retain content and manage short names",
|
|
69
70
|
register: "Associate content types with Apps",
|
|
70
71
|
config: "Manage local configuration",
|
|
72
|
+
store: "Query local storage and collect unreferenced blocks",
|
|
71
73
|
history: "View and remove execution history",
|
|
72
74
|
};
|
|
73
75
|
const commandHelp = {
|
|
76
|
+
"store usage": {
|
|
77
|
+
summary: "Query cached and recursively pinned block bytes",
|
|
78
|
+
examples: ["ipab store usage", "ipab --json store usage"],
|
|
79
|
+
notes: [
|
|
80
|
+
"Local Store only; excludes metadata, temporary files and disk allocation overhead.",
|
|
81
|
+
"Pinned DAGs include all descendants, with shared blocks counted once.",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
"store gc": {
|
|
85
|
+
summary: "Delete unprotected blocks from the entire selected local Store",
|
|
86
|
+
examples: ["ipab store gc", "ipab --json store gc"],
|
|
87
|
+
notes: [
|
|
88
|
+
"Preserves pins, all participating owners, pending operations and staged imports.",
|
|
89
|
+
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
90
|
+
],
|
|
91
|
+
},
|
|
74
92
|
init: {
|
|
75
|
-
summary: "Create a
|
|
93
|
+
summary: "Create files from a Template Bundle (default: Node App project)",
|
|
76
94
|
arguments: ["NAME Project name; DIR defaults to NAME (new/empty only)."],
|
|
77
95
|
options: [
|
|
78
96
|
"--template TEMPLATE node (default), web-app, directory, CAR, CID or pin.",
|
|
@@ -105,15 +123,6 @@ const commandHelp = {
|
|
|
105
123
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
106
124
|
],
|
|
107
125
|
},
|
|
108
|
-
"bundle init": {
|
|
109
|
-
summary: "Create content from a Bundle type",
|
|
110
|
-
arguments: [
|
|
111
|
-
"TYPE Definition file, type CAR, exact type CID or Schema pin.",
|
|
112
|
-
"DIR New or empty destination directory.",
|
|
113
|
-
],
|
|
114
|
-
examples: ["ipab bundle init types\\dist\\schema.car note"],
|
|
115
|
-
notes: ["Writes .bundle.yaml, .bundle-ignore and the default entry."],
|
|
116
|
-
},
|
|
117
126
|
"bundle build": {
|
|
118
127
|
summary: "Build a content or type CAR without compiling code",
|
|
119
128
|
arguments: ["SOURCE Bundle directory or definition file."],
|
|
@@ -180,14 +189,14 @@ const commandHelp = {
|
|
|
180
189
|
],
|
|
181
190
|
},
|
|
182
191
|
"pin add": {
|
|
183
|
-
summary: "Verify, retain and name
|
|
192
|
+
summary: "Verify, retain and name a Bundle",
|
|
184
193
|
arguments: [
|
|
185
194
|
"NAME Unused short name.",
|
|
186
|
-
"CID Exact
|
|
195
|
+
"CID Exact Bundle CID, not another pin name or a standalone type block.",
|
|
187
196
|
],
|
|
188
197
|
examples: ["ipab pin add reader APP_CID"],
|
|
189
198
|
notes: [
|
|
190
|
-
"
|
|
199
|
+
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
191
200
|
"Does not execute or trust Apps, install dependencies or start a daemon.",
|
|
192
201
|
"The builtin namespace is read-only.",
|
|
193
202
|
],
|
|
@@ -203,15 +212,12 @@ const commandHelp = {
|
|
|
203
212
|
"pin list": {
|
|
204
213
|
summary: "List user and built-in pins",
|
|
205
214
|
options: [
|
|
206
|
-
"--
|
|
207
|
-
"--type TYPE Exact schema CID, Schema pin or builtin shortcut.",
|
|
208
|
-
],
|
|
209
|
-
examples: [
|
|
210
|
-
"ipab pin list",
|
|
211
|
-
"ipab pin list --kind bundle --type builtin:node-app.v1",
|
|
215
|
+
"--type TYPE Exact type CID or the name of a Bundle pin of that type.",
|
|
212
216
|
],
|
|
217
|
+
examples: ["ipab pin list", "ipab pin list --type reader"],
|
|
213
218
|
notes: [
|
|
214
|
-
"
|
|
219
|
+
"Unfinished operations and legacy non-Bundle pins are reported separately.",
|
|
220
|
+
"Legacy retention is preserved; use pin delete to explicitly release it.",
|
|
215
221
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
216
222
|
],
|
|
217
223
|
},
|
|
@@ -260,21 +266,21 @@ const commandHelp = {
|
|
|
260
266
|
"config get": {
|
|
261
267
|
summary: "Show effective configuration",
|
|
262
268
|
arguments: ["KEY Optional configuration key; omit to show all values."],
|
|
263
|
-
examples: ["ipab config get", "ipab config get store.
|
|
269
|
+
examples: ["ipab config get", "ipab config get store.gateway"],
|
|
264
270
|
},
|
|
265
271
|
"config set": {
|
|
266
272
|
summary: "Save a local configuration value",
|
|
267
273
|
examples: [
|
|
268
|
-
"ipab config set store.
|
|
274
|
+
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
269
275
|
"ipab config set history.enabled false",
|
|
270
276
|
],
|
|
271
277
|
notes: [
|
|
272
|
-
"store.
|
|
278
|
+
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
273
279
|
],
|
|
274
280
|
},
|
|
275
281
|
"config reset": {
|
|
276
282
|
summary: "Remove a saved configuration override",
|
|
277
|
-
examples: ["ipab config reset store.
|
|
283
|
+
examples: ["ipab config reset store.gateway"],
|
|
278
284
|
},
|
|
279
285
|
"history list": {
|
|
280
286
|
summary: "List execution history",
|
|
@@ -322,7 +328,7 @@ const commandHelp = {
|
|
|
322
328
|
export function help(path = "") {
|
|
323
329
|
const globalOptions = `Global options (before COMMAND):
|
|
324
330
|
--state-dir PATH Set the local state directory
|
|
325
|
-
--store-
|
|
331
|
+
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
326
332
|
--json Output management/development metadata, not App stdio`;
|
|
327
333
|
const footer = "Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
|
|
328
334
|
if (!path)
|
|
@@ -343,6 +349,7 @@ Manage:
|
|
|
343
349
|
pin ${groups.pin}
|
|
344
350
|
register ${groups.register}
|
|
345
351
|
config ${groups.config}
|
|
352
|
+
store ${groups.store}
|
|
346
353
|
history ${groups.history}
|
|
347
354
|
|
|
348
355
|
${globalOptions}
|
|
@@ -412,6 +419,19 @@ function runDuration(record) {
|
|
|
412
419
|
throw new HostError("Execution record has an invalid duration.");
|
|
413
420
|
return `${Math.floor(duration / 1000)}s`;
|
|
414
421
|
}
|
|
422
|
+
function storageBytes(bytes) {
|
|
423
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
424
|
+
let scaled = bytes;
|
|
425
|
+
let unit = 0;
|
|
426
|
+
while (scaled >= 1000 && unit < units.length - 1) {
|
|
427
|
+
scaled /= 1000;
|
|
428
|
+
unit++;
|
|
429
|
+
}
|
|
430
|
+
const exact = bytes.toLocaleString("en-US");
|
|
431
|
+
return unit === 0
|
|
432
|
+
? `${exact} bytes`
|
|
433
|
+
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
434
|
+
}
|
|
415
435
|
function table(headers, rows, empty) {
|
|
416
436
|
if (!rows.length)
|
|
417
437
|
return empty;
|
|
@@ -490,14 +510,16 @@ export function parse(argv) {
|
|
|
490
510
|
}
|
|
491
511
|
if (flag === "--json")
|
|
492
512
|
flags.json = true;
|
|
493
|
-
else if (flag === "--
|
|
513
|
+
else if (flag === "--store-rpc")
|
|
514
|
+
syntax("Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.");
|
|
515
|
+
else if (flag === "--state-dir" || flag === "--store-gateway") {
|
|
494
516
|
const value = tokens.shift();
|
|
495
517
|
if (!value || value.startsWith("-"))
|
|
496
518
|
syntax(`${flag} needs a value.`);
|
|
497
519
|
if (flag === "--state-dir")
|
|
498
520
|
flags.stateDir = value;
|
|
499
521
|
else {
|
|
500
|
-
flags.
|
|
522
|
+
flags.storeGateway = publicUrl(value);
|
|
501
523
|
}
|
|
502
524
|
}
|
|
503
525
|
else
|
|
@@ -531,7 +553,7 @@ export function parse(argv) {
|
|
|
531
553
|
return result;
|
|
532
554
|
}
|
|
533
555
|
if (!["open", "init", "build"].includes(group)) {
|
|
534
|
-
if (!["bundle", "pin", "register", "config", "history"].includes(group))
|
|
556
|
+
if (!["bundle", "pin", "register", "config", "history", "store"].includes(group))
|
|
535
557
|
syntax(`Unknown command "${group}".`);
|
|
536
558
|
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
537
559
|
result.help = true;
|
|
@@ -572,7 +594,7 @@ export function parse(argv) {
|
|
|
572
594
|
: result.path === "history remove"
|
|
573
595
|
? ["app", "status", "since", "until"]
|
|
574
596
|
: result.path === "pin list"
|
|
575
|
-
? ["
|
|
597
|
+
? ["type"]
|
|
576
598
|
: [];
|
|
577
599
|
while (tokens.length) {
|
|
578
600
|
const value = tokens.shift();
|
|
@@ -604,7 +626,6 @@ export function parse(argv) {
|
|
|
604
626
|
const counts = {
|
|
605
627
|
init: [1, 2],
|
|
606
628
|
build: [0, 1],
|
|
607
|
-
"bundle init": [2, 2],
|
|
608
629
|
"bundle build": [1, 1],
|
|
609
630
|
"bundle inspect": [1, 1],
|
|
610
631
|
"bundle import": [1, 1],
|
|
@@ -620,6 +641,8 @@ export function parse(argv) {
|
|
|
620
641
|
"config get": [0, 1],
|
|
621
642
|
"config set": [2, 2],
|
|
622
643
|
"config reset": [1, 1],
|
|
644
|
+
"store usage": [0, 0],
|
|
645
|
+
"store gc": [0, 0],
|
|
623
646
|
"history list": [0, 0],
|
|
624
647
|
"history show": [1, 1],
|
|
625
648
|
"history remove": [0, Number.MAX_SAFE_INTEGER],
|
|
@@ -646,11 +669,9 @@ export function parse(argv) {
|
|
|
646
669
|
if (result.path === "pin rename")
|
|
647
670
|
pinName(result.positional[1]);
|
|
648
671
|
}
|
|
649
|
-
if (result.options.kind !== undefined &&
|
|
650
|
-
!["bundle", "schema"].includes(String(result.options.kind)))
|
|
651
|
-
syntax("--kind must be bundle or schema.");
|
|
652
672
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
653
|
-
if (!(result.path === "config get" && result.positional[0] === "state-dir")
|
|
673
|
+
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
674
|
+
!(result.path === "config reset" && result.positional[0] === "store.rpc"))
|
|
654
675
|
configKey(result.positional[0]);
|
|
655
676
|
if (result.path === "config set")
|
|
656
677
|
parseValue(configKey(result.positional[0]), result.positional[1], true);
|
|
@@ -682,6 +703,14 @@ async function performCli(argv, io, env) {
|
|
|
682
703
|
syntax("Non-interactive history remove requires --yes.");
|
|
683
704
|
const builtins = await builtinContent();
|
|
684
705
|
state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
|
|
706
|
+
if (parsed.path === "config reset" &&
|
|
707
|
+
parsed.positional[0] === "store.rpc") {
|
|
708
|
+
state.resetConfig("store.rpc");
|
|
709
|
+
io.out(parsed.flags.json
|
|
710
|
+
? JSON.stringify({ reset: ["store.rpc"] })
|
|
711
|
+
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.");
|
|
712
|
+
return 0;
|
|
713
|
+
}
|
|
685
714
|
const items = effectiveConfig(state.config(), parsed.flags, env);
|
|
686
715
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
687
716
|
const emit = (result, human) => {
|
|
@@ -692,9 +721,21 @@ async function performCli(argv, io, env) {
|
|
|
692
721
|
? filters(state, parsed.options)
|
|
693
722
|
: {};
|
|
694
723
|
switch (parsed.path) {
|
|
724
|
+
case "store usage":
|
|
725
|
+
case "store gc": {
|
|
726
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
727
|
+
if (parsed.path === "store usage") {
|
|
728
|
+
const result = await store.usage();
|
|
729
|
+
emit(result, `Cached blocks: ${storageBytes(result.cachedBytes)}\nPinned blocks (deduplicated): ${storageBytes(result.pinnedBytes)}`);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
const result = await store.gc();
|
|
733
|
+
emit(result, `Removed ${result.removedBlocks} blocks; reclaimed ${storageBytes(result.reclaimedBytes)}.`);
|
|
734
|
+
}
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
695
737
|
case "init":
|
|
696
738
|
case "build":
|
|
697
|
-
case "bundle init":
|
|
698
739
|
case "bundle build":
|
|
699
740
|
case "bundle inspect":
|
|
700
741
|
case "bundle import": {
|
|
@@ -713,7 +754,7 @@ async function performCli(argv, io, env) {
|
|
|
713
754
|
try {
|
|
714
755
|
let pendingStore;
|
|
715
756
|
const getStore = () => {
|
|
716
|
-
pendingStore ??= storeConfiguration(value("store.
|
|
757
|
+
pendingStore ??= storeConfiguration(value("store.gateway")).then((configuration) => {
|
|
717
758
|
store = new IpfsStore(configuration);
|
|
718
759
|
return store;
|
|
719
760
|
});
|
|
@@ -772,21 +813,19 @@ async function performCli(argv, io, env) {
|
|
|
772
813
|
: {}),
|
|
773
814
|
outputDir: String(value("bundle.outputDir")),
|
|
774
815
|
})
|
|
775
|
-
: parsed.path === "bundle
|
|
776
|
-
? await
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
:
|
|
788
|
-
? await importBundle(first, getStore, request)
|
|
789
|
-
: await inspectBundle(source, request);
|
|
816
|
+
: parsed.path === "bundle build"
|
|
817
|
+
? await buildBundle(source, {
|
|
818
|
+
...request,
|
|
819
|
+
schemaOnly: Boolean(parsed.options["schema-only"]),
|
|
820
|
+
replace: Boolean(parsed.options.replace),
|
|
821
|
+
...(typeof parsed.options.output === "string"
|
|
822
|
+
? { output: parsed.options.output }
|
|
823
|
+
: {}),
|
|
824
|
+
outputDir: String(value("bundle.outputDir")),
|
|
825
|
+
})
|
|
826
|
+
: parsed.path === "bundle import"
|
|
827
|
+
? await importBundle(first, getStore, request)
|
|
828
|
+
: await inspectBundle(source, request);
|
|
790
829
|
const importing = "output" in result && !parsed.options["no-import"];
|
|
791
830
|
if (importing) {
|
|
792
831
|
io.err("Importing build result into Store (without pinning)...");
|
|
@@ -804,19 +843,20 @@ async function performCli(argv, io, env) {
|
|
|
804
843
|
state = undefined;
|
|
805
844
|
controller.signal.throwIfAborted();
|
|
806
845
|
if ("output" in result)
|
|
807
|
-
emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${"source" in result ? `\nSource CID: ${result.source.cid}\nSource CAR: ${result.source.output} (not imported or pinned)` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
|
|
846
|
+
emit({ ...result, imported: importing }, `CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}${"source" in result ? `\nSource CID: ${result.source.cid}\nSource CAR: ${result.source.output} (not imported or pinned)` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`);
|
|
808
847
|
else if (result.kind === "bundle-import")
|
|
809
|
-
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}`);
|
|
810
|
-
else if (result.kind === "
|
|
811
|
-
emit(result, `Created
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
848
|
+
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`);
|
|
849
|
+
else if (result.kind === "project-init") {
|
|
850
|
+
emit(result, `Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`);
|
|
851
|
+
if (result.files.includes("package.json") &&
|
|
852
|
+
(result.files.includes("ipab.yaml") ||
|
|
853
|
+
result.files.includes("ipab.json")))
|
|
854
|
+
io.err(`Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`);
|
|
855
|
+
else if (result.files.includes(".bundle.yaml"))
|
|
856
|
+
io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
|
|
817
857
|
}
|
|
818
858
|
else
|
|
819
|
-
emit(result, `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\
|
|
859
|
+
emit(result, `Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\nDefinition validation: passed\nStorage verification: ${result.validation.storage}\nEntry validation: ${result.validation.entry?.status ?? "not-applicable"}`);
|
|
820
860
|
}
|
|
821
861
|
catch (cause) {
|
|
822
862
|
if (cancelled)
|
|
@@ -830,44 +870,42 @@ async function performCli(argv, io, env) {
|
|
|
830
870
|
break;
|
|
831
871
|
}
|
|
832
872
|
case "pin list": {
|
|
833
|
-
if (typeof parsed.options.type === "string") {
|
|
834
|
-
const named = state.pin(parsed.options.type);
|
|
835
|
-
if (named && pinDetails(named).kind !== "schema")
|
|
836
|
-
throw new HostError("--type short names must identify a Schema pin.");
|
|
837
|
-
}
|
|
838
873
|
const type = typeof parsed.options.type === "string"
|
|
839
|
-
? state.resolve(
|
|
874
|
+
? state.resolve(parsed.options.type, true)
|
|
840
875
|
: undefined;
|
|
841
876
|
const pins = state.pins();
|
|
842
877
|
const listed = pins
|
|
843
|
-
.filter((pin) => pin.status === "ready")
|
|
878
|
+
.filter((pin) => pin.status === "ready" && pin.metadata?.kind === "bundle")
|
|
844
879
|
.map(pinDetails)
|
|
845
|
-
.filter((pin) =>
|
|
846
|
-
|
|
880
|
+
.filter((pin) => type === undefined || pin.schemaCid === type);
|
|
881
|
+
const invalid = pins
|
|
882
|
+
.filter((pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle")
|
|
883
|
+
.map(({ name, cid, metadata }) => ({
|
|
884
|
+
name,
|
|
885
|
+
cid,
|
|
886
|
+
kind: metadata?.kind,
|
|
887
|
+
reason: "Not a Bundle pin; retention is preserved. Use pin delete to release it.",
|
|
888
|
+
}));
|
|
847
889
|
const pending = pins
|
|
848
890
|
.filter((pin) => pin.status !== "ready")
|
|
849
891
|
.map(({ name, cid, status }) => ({ name, cid, status }));
|
|
850
|
-
const legacyAliases = state.aliases();
|
|
851
892
|
if (pending.length)
|
|
852
893
|
io.err(`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`);
|
|
853
|
-
if (
|
|
854
|
-
io.err(
|
|
855
|
-
emit({ items: listed, pending,
|
|
894
|
+
if (invalid.length)
|
|
895
|
+
io.err(`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`);
|
|
896
|
+
emit({ items: listed, pending, invalid }, table(["NAME", "CID", "KIND", "BUNDLE TYPE", "SOURCE"], listed.map((pin) => [
|
|
856
897
|
pin.name,
|
|
857
898
|
pin.cid,
|
|
858
899
|
pin.kind,
|
|
859
|
-
pin.typeName
|
|
900
|
+
pin.typeName,
|
|
860
901
|
pin.builtin ? "built-in (read-only)" : "user",
|
|
861
|
-
]), "No named pins.")
|
|
862
|
-
(legacyAliases.length
|
|
863
|
-
? `\nLegacy Aliases (not pinned):\n${table(["NAME", "CID"], legacyAliases.map((alias) => [alias.name, alias.cid]), "")}`
|
|
864
|
-
: ""));
|
|
902
|
+
]), "No named pins."));
|
|
865
903
|
break;
|
|
866
904
|
}
|
|
867
905
|
case "pin add": {
|
|
868
906
|
io.err("Fetching, verifying and retaining content in Store...");
|
|
869
|
-
const result = await addPin(state, first, second, await storeConfiguration(value("store.
|
|
870
|
-
emit(result, `${result.name} → ${result.cid}\
|
|
907
|
+
const result = await addPin(state, first, second, await storeConfiguration(value("store.gateway")));
|
|
908
|
+
emit(result, `${result.name} → ${result.cid}\nBundle type: ${printable(result.typeName)}`);
|
|
871
909
|
break;
|
|
872
910
|
}
|
|
873
911
|
case "pin delete": {
|
|
@@ -880,7 +918,7 @@ async function performCli(argv, io, env) {
|
|
|
880
918
|
if (!pin)
|
|
881
919
|
throw new HostError(`Pin "${first}" does not exist. Run ipab pin list.`);
|
|
882
920
|
const result = pinDetails(pin);
|
|
883
|
-
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\
|
|
921
|
+
emit(result, `Name: ${printable(result.name)}\nCID: ${result.cid}\nBundle type: ${printable(result.typeName)}\nSchema CID: ${result.schemaCid}\nSource: ${result.builtin ? "built-in (read-only; content bundled with IPAB)" : "local registration (not live node verification)"}`);
|
|
884
922
|
break;
|
|
885
923
|
}
|
|
886
924
|
case "pin rename": {
|
|
@@ -997,7 +1035,7 @@ async function performCli(argv, io, env) {
|
|
|
997
1035
|
throw new HostError("Execution logging requires history.enabled=true.");
|
|
998
1036
|
const target = state.resolve(first);
|
|
999
1037
|
await recoverInactive(state);
|
|
1000
|
-
store = new IpfsStore(await storeConfiguration(value("store.
|
|
1038
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1001
1039
|
let appCid;
|
|
1002
1040
|
let appArgv;
|
|
1003
1041
|
if (parsed.path === "open") {
|