@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.2
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 +26 -4
- package/dist/app-authoring.d.ts +11 -2
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +135 -20
- 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/assembly.d.ts +7 -0
- package/dist/assembly.d.ts.map +1 -0
- package/dist/assembly.js +131 -0
- package/dist/assembly.js.map +1 -0
- package/dist/authoring.d.ts +6 -15
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +13 -42
- 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 +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +639 -147
- package/dist/cli.js.map +1 -1
- package/dist/config-secret.d.ts +3 -0
- package/dist/config-secret.d.ts.map +1 -0
- package/dist/config-secret.js +83 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +7 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -22
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +9 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +90 -0
- package/dist/content-provider.js.map +1 -0
- 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/get.d.ts +3 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +61 -0
- package/dist/get.js.map +1 -0
- package/dist/identity.d.ts +9 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +89 -0
- package/dist/identity.js.map +1 -0
- 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 +1 -2
- package/dist/source-bundle.js.map +1 -1
- package/dist/state.d.ts +35 -10
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +124 -14
- package/dist/state.js.map +1 -1
- package/dist/swarm.d.ts +113 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +760 -0
- package/dist/swarm.js.map +1 -0
- 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 +15 -10
- package/src/app-authoring.ts +203 -29
- package/src/app-definition.ts +1 -7
- package/src/app-templates.ts +13 -0
- package/src/assembly.ts +182 -0
- package/src/authoring.ts +32 -58
- package/src/builtins.ts +5 -11
- package/src/cli.ts +785 -167
- package/src/config-secret.ts +96 -0
- package/src/config.ts +161 -25
- package/src/content-provider.ts +123 -0
- package/src/context.ts +10 -0
- package/src/get.ts +68 -0
- package/src/identity.ts +133 -0
- package/src/ipc.ts +8 -0
- package/src/pins.ts +14 -28
- package/src/runtime.ts +1 -0
- package/src/source-bundle.ts +1 -2
- package/src/state.ts +149 -24
- package/src/swarm.ts +1186 -0
- package/src/template-definition.ts +1 -10
package/src/cli.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
publicUrl,
|
|
12
12
|
stateLocation,
|
|
13
13
|
storeConfiguration,
|
|
14
|
+
visibleConfig,
|
|
14
15
|
type GlobalOptions,
|
|
15
16
|
} from "./config.js";
|
|
16
17
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
@@ -25,17 +26,29 @@ import {
|
|
|
25
26
|
import { execute } from "./runtime.js";
|
|
26
27
|
import { validatedBundle } from "./space.js";
|
|
27
28
|
import { exactCid, pinName, State, type RunRecord } from "./state.js";
|
|
29
|
+
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
30
|
+
import { initApp } from "./app-authoring.js";
|
|
31
|
+
import { assembleBundle } from "./assembly.js";
|
|
32
|
+
import { getBundle } from "./get.js";
|
|
28
33
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
createSwarm,
|
|
35
|
+
requestMembership,
|
|
36
|
+
approveMembership,
|
|
37
|
+
joinSwarm,
|
|
38
|
+
descriptor,
|
|
39
|
+
swarmHeader,
|
|
40
|
+
addSwarm,
|
|
41
|
+
updateSwarm,
|
|
42
|
+
searchNames,
|
|
43
|
+
resolveReference,
|
|
44
|
+
publish,
|
|
45
|
+
type SwarmContext,
|
|
46
|
+
} from "./swarm.js";
|
|
35
47
|
import { schemaAlias } from "./app-definition.js";
|
|
36
48
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
37
49
|
import { logFiles } from "./logs.js";
|
|
38
50
|
import { builtinContent } from "./builtins.js";
|
|
51
|
+
import { readSecretStream } from "./config-secret.js";
|
|
39
52
|
|
|
40
53
|
export interface IO {
|
|
41
54
|
out(text: string): void;
|
|
@@ -43,6 +56,7 @@ export interface IO {
|
|
|
43
56
|
tty: boolean;
|
|
44
57
|
columns?(): number | undefined;
|
|
45
58
|
confirm(text: string): Promise<boolean>;
|
|
59
|
+
readSecret?(): Promise<string>;
|
|
46
60
|
}
|
|
47
61
|
export const processIO: IO = {
|
|
48
62
|
out(text) {
|
|
@@ -55,6 +69,14 @@ export const processIO: IO = {
|
|
|
55
69
|
columns() {
|
|
56
70
|
return process.stdout.columns;
|
|
57
71
|
},
|
|
72
|
+
async readSecret() {
|
|
73
|
+
if (process.stdin.isTTY)
|
|
74
|
+
syntax(
|
|
75
|
+
"Pipe the API key through stdin; interactive echo is not permitted.",
|
|
76
|
+
);
|
|
77
|
+
process.stdin.setEncoding("utf8");
|
|
78
|
+
return readSecretStream(process.stdin as AsyncIterable<string>);
|
|
79
|
+
},
|
|
58
80
|
async confirm(text) {
|
|
59
81
|
const reader = createInterface({
|
|
60
82
|
input: process.stdin,
|
|
@@ -70,35 +92,54 @@ export const processIO: IO = {
|
|
|
70
92
|
},
|
|
71
93
|
};
|
|
72
94
|
const commands: Record<string, string> = {
|
|
95
|
+
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
96
|
+
"swarm request": "swarm request SWARM_CID",
|
|
97
|
+
"swarm approve": "swarm approve REQUEST_CID [--expires-in SECONDS] --yes",
|
|
98
|
+
"swarm join": "swarm join RESPONSE_CID",
|
|
99
|
+
"swarm status": "swarm status [SWARM_CID]",
|
|
100
|
+
"swarm list": "swarm list",
|
|
101
|
+
"swarm add": "swarm add SWARM_CID [--alias ALIAS]",
|
|
102
|
+
"swarm use": "swarm use CID_OR_ALIAS",
|
|
103
|
+
"swarm remove": "swarm remove CID_OR_ALIAS",
|
|
104
|
+
"swarm update":
|
|
105
|
+
"swarm update [CID_OR_ALIAS] [--name TEXT] [--description TEXT]",
|
|
106
|
+
publish:
|
|
107
|
+
"publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
|
|
108
|
+
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
109
|
+
search: "search QUERY [--current] [--force | --no-force]",
|
|
73
110
|
init: "init NAME [DIR] [OPTIONS]",
|
|
74
|
-
build: "build [
|
|
75
|
-
"bundle init": "bundle init TYPE DIR",
|
|
111
|
+
build: "build [SOURCE] [OPTIONS]",
|
|
76
112
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
77
113
|
"bundle inspect": "bundle inspect SOURCE",
|
|
78
114
|
"bundle import": "bundle import FILE.car",
|
|
79
|
-
exec: "exec [--log] APP [APP_ARGS...]",
|
|
80
|
-
open: "open [--log] CONTENT",
|
|
115
|
+
exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
|
|
116
|
+
open: "open [--log] [--raw] [--force | --no-force] CONTENT",
|
|
81
117
|
"pin add": "pin add NAME CID",
|
|
82
118
|
"pin delete": "pin delete NAME",
|
|
83
|
-
"pin list": "pin list [--
|
|
119
|
+
"pin list": "pin list [--type TYPE]",
|
|
84
120
|
"pin show": "pin show NAME",
|
|
85
121
|
"pin rename": "pin rename OLD_NAME NEW_NAME",
|
|
86
122
|
"register list": "register list",
|
|
87
123
|
"register set": "register set SCHEMA APP [--replace] [-- TEMPLATE...]",
|
|
88
124
|
"register remove": "register remove SCHEMA",
|
|
89
125
|
"config get": "config get [KEY]",
|
|
90
|
-
"config set":
|
|
126
|
+
"config set":
|
|
127
|
+
"config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
91
128
|
"config reset": "config reset KEY",
|
|
129
|
+
"store usage": "store usage",
|
|
130
|
+
"store gc": "store gc",
|
|
92
131
|
"history list": "history list [OPTIONS]",
|
|
93
132
|
"history show": "history show RUN_ID",
|
|
94
133
|
"history remove":
|
|
95
134
|
"history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
96
135
|
};
|
|
97
136
|
const groups: Record<string, string> = {
|
|
137
|
+
swarm: "Create, authorize, select and manage personal swarms",
|
|
98
138
|
bundle: "Create, inspect and import content bundles",
|
|
99
139
|
pin: "Retain content and manage short names",
|
|
100
140
|
register: "Associate content types with Apps",
|
|
101
141
|
config: "Manage local configuration",
|
|
142
|
+
store: "Query local storage and collect unreferenced blocks",
|
|
102
143
|
history: "View and remove execution history",
|
|
103
144
|
};
|
|
104
145
|
const commandHelp: Record<
|
|
@@ -111,8 +152,174 @@ const commandHelp: Record<
|
|
|
111
152
|
notes?: string[];
|
|
112
153
|
}
|
|
113
154
|
> = {
|
|
155
|
+
"swarm create": {
|
|
156
|
+
summary: "Create a swarm using the account HOME identity",
|
|
157
|
+
options: [
|
|
158
|
+
"--service URL Must match the protected pointers.service origin.",
|
|
159
|
+
"--resume OPERATION Recover the same saved create/idempotency result.",
|
|
160
|
+
"--name TEXT Initial mutable swarm name.",
|
|
161
|
+
"--description TEXT Initial mutable description.",
|
|
162
|
+
"--alias ALIAS Optional local registry alias (not the shared name).",
|
|
163
|
+
],
|
|
164
|
+
examples: [
|
|
165
|
+
"ipab config set pointers.service https://service.example",
|
|
166
|
+
"ipab config set pointers.apiKey -",
|
|
167
|
+
"ipab swarm create",
|
|
168
|
+
],
|
|
169
|
+
notes: [
|
|
170
|
+
"Creation uses the protected, origin-bound API key and owner possession proof.",
|
|
171
|
+
"Uses the prepared private Kubo provider; never deploys infrastructure.",
|
|
172
|
+
"Returns one descriptor CID; owner needs no member certificate.",
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
"swarm request": {
|
|
176
|
+
summary: "Publish a signed account membership request",
|
|
177
|
+
examples: ["ipab swarm request SWARM_CID"],
|
|
178
|
+
notes: [
|
|
179
|
+
"Returns one request CID. Private IPFS access is a prerequisite, not membership.",
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
"swarm approve": {
|
|
183
|
+
summary: "Owner signs a certificate for an exact request",
|
|
184
|
+
options: [
|
|
185
|
+
"--yes Explicit approval; required outside a TTY.",
|
|
186
|
+
"--expires-in SECONDS 60..2592000; default 604800.",
|
|
187
|
+
],
|
|
188
|
+
examples: ["ipab swarm approve REQUEST_CID --yes"],
|
|
189
|
+
notes: ["Returns one response CID. Never exports the owner private key."],
|
|
190
|
+
},
|
|
191
|
+
"swarm join": {
|
|
192
|
+
summary: "Verify a response and authenticate HEAD",
|
|
193
|
+
examples: ["ipab swarm join RESPONSE_CID"],
|
|
194
|
+
options: ["--alias ALIAS Register this swarm with a local alias."],
|
|
195
|
+
notes: [
|
|
196
|
+
"Requires this account's exact pending request and bound member certificate.",
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
"swarm status": {
|
|
200
|
+
summary: "Authenticate the current swarm HEAD",
|
|
201
|
+
examples: ["ipab swarm status", "ipab swarm status work"],
|
|
202
|
+
notes: [
|
|
203
|
+
"Always authenticate and refresh HEAD; update the local header cache.",
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
"swarm list": {
|
|
207
|
+
summary: "List local swarm registrations and the effective selection",
|
|
208
|
+
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
209
|
+
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
210
|
+
},
|
|
211
|
+
"swarm add": {
|
|
212
|
+
summary: "Authenticate and register a swarm you already have access to",
|
|
213
|
+
options: [
|
|
214
|
+
"--alias ALIAS Unique local alias; does not rename the shared swarm.",
|
|
215
|
+
],
|
|
216
|
+
examples: ["ipab swarm add SWARM_CID --alias work"],
|
|
217
|
+
notes: [
|
|
218
|
+
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
219
|
+
],
|
|
220
|
+
},
|
|
221
|
+
"swarm use": {
|
|
222
|
+
summary: "Save a registered swarm as the current default",
|
|
223
|
+
examples: ["ipab swarm use work"],
|
|
224
|
+
notes: ["Local only. --swarm still overrides the saved default."],
|
|
225
|
+
},
|
|
226
|
+
"swarm remove": {
|
|
227
|
+
summary: "Forget a local registration without revoking membership",
|
|
228
|
+
examples: ["ipab swarm remove work"],
|
|
229
|
+
notes: [
|
|
230
|
+
"Preserves credentials, content and remote membership. Clears a matching saved default without selecting a replacement.",
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
"swarm update": {
|
|
234
|
+
summary: "Update shared swarm information as an owner or member",
|
|
235
|
+
arguments: ["CID_OR_ALIAS Defaults to the effective current swarm."],
|
|
236
|
+
options: [
|
|
237
|
+
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
238
|
+
"--description TEXT Replace the shared description; empty text clears it.",
|
|
239
|
+
],
|
|
240
|
+
examples: [
|
|
241
|
+
'ipab swarm update work --name "Team" --description "Shared workspace"',
|
|
242
|
+
'ipab swarm update --description ""',
|
|
243
|
+
],
|
|
244
|
+
notes: [
|
|
245
|
+
"Requires at least one field. Any authorized member can update both fields.",
|
|
246
|
+
"Last successful write wins for the specified fields; no expected-value/version input.",
|
|
247
|
+
"Automatically retries HEAD contention while preserving current Names and unspecified properties.",
|
|
248
|
+
"Shared name changes do not rename local registry aliases.",
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
search: {
|
|
252
|
+
summary: "Search formal Names across registered swarms",
|
|
253
|
+
arguments: [
|
|
254
|
+
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
255
|
+
],
|
|
256
|
+
options: [
|
|
257
|
+
"--current Search only the effective current swarm; conflicts with --swarm.",
|
|
258
|
+
"--force Refresh HEAD for every swarm in the search scope.",
|
|
259
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
260
|
+
],
|
|
261
|
+
examples: ["ipab search hello", "ipab --swarm work search hello --force"],
|
|
262
|
+
notes: [
|
|
263
|
+
"Searches all registered swarms unless --current or --swarm selects one.",
|
|
264
|
+
"Valid caches use local Names only; absent/expired caches refresh. No payload downloads.",
|
|
265
|
+
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
publish: {
|
|
269
|
+
summary: "Provide built content and explicitly publish a Name",
|
|
270
|
+
options: [
|
|
271
|
+
"--name NAME New formal Name; occupied Names fail.",
|
|
272
|
+
"--expect CID Exact old Artifact node, required for iteration.",
|
|
273
|
+
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
274
|
+
],
|
|
275
|
+
examples: [
|
|
276
|
+
"ipab publish app.car --name apps/hello",
|
|
277
|
+
"ipab publish APP_CID --name apps/hello --expect OLD_NODE_CID",
|
|
278
|
+
"ipab publish CONTENT_CID",
|
|
279
|
+
],
|
|
280
|
+
notes: [
|
|
281
|
+
"No build, edit, install or execution. CID-only stdout.",
|
|
282
|
+
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
283
|
+
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
get: {
|
|
287
|
+
summary: "Verify and unpack Bundle content without executing it",
|
|
288
|
+
options: [
|
|
289
|
+
"--raw Select the Artifact node instead of its value.",
|
|
290
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
291
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
292
|
+
"-o, --output DIRECTORY New or empty directory; defaults to resolved CID.",
|
|
293
|
+
],
|
|
294
|
+
examples: [
|
|
295
|
+
"ipab --json get ipab:///apps/hello -o hello-app",
|
|
296
|
+
"ipab get ipab://work/apps/hello -o hello-app",
|
|
297
|
+
"ipab get --raw RELEASE_CID",
|
|
298
|
+
],
|
|
299
|
+
notes: [
|
|
300
|
+
"Returns the selected content CID and original target CID (editing baseline).",
|
|
301
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
302
|
+
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
"store usage": {
|
|
306
|
+
summary: "Query cached and recursively pinned block bytes",
|
|
307
|
+
examples: ["ipab store usage", "ipab --json store usage"],
|
|
308
|
+
notes: [
|
|
309
|
+
"Local Store only; excludes metadata, temporary files and disk allocation overhead.",
|
|
310
|
+
"Pinned DAGs include all descendants, with shared blocks counted once.",
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
"store gc": {
|
|
314
|
+
summary: "Delete unprotected blocks from the entire selected local Store",
|
|
315
|
+
examples: ["ipab store gc", "ipab --json store gc"],
|
|
316
|
+
notes: [
|
|
317
|
+
"Preserves pins, all participating owners, pending operations and staged imports.",
|
|
318
|
+
"Does not unpin, clear history, delete unknown files or request Kubo daemon GC.",
|
|
319
|
+
],
|
|
320
|
+
},
|
|
114
321
|
init: {
|
|
115
|
-
summary: "Create a
|
|
322
|
+
summary: "Create files from a Template Bundle (default: Node App project)",
|
|
116
323
|
arguments: ["NAME Project name; DIR defaults to NAME (new/empty only)."],
|
|
117
324
|
options: [
|
|
118
325
|
"--template TEMPLATE node (default), web-app, directory, CAR, CID or pin.",
|
|
@@ -127,33 +334,27 @@ const commandHelp: Record<
|
|
|
127
334
|
notes: ["Does not install dependencies or execute template code."],
|
|
128
335
|
},
|
|
129
336
|
build: {
|
|
130
|
-
summary: "
|
|
131
|
-
arguments: [
|
|
337
|
+
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
338
|
+
arguments: [
|
|
339
|
+
"SOURCE Recipe file or Bundle directory (default: current directory).",
|
|
340
|
+
],
|
|
132
341
|
options: [
|
|
133
|
-
"-o, --output FILE Destination (default: dist/
|
|
342
|
+
"-o, --output FILE Destination (default: dist/bundle.car).",
|
|
134
343
|
"--replace Allow replacing existing regular artifacts.",
|
|
135
|
-
"--no-import Write CAR
|
|
136
|
-
|
|
137
|
-
|
|
344
|
+
"--no-import Write the CAR without importing the Bundle into Store.",
|
|
345
|
+
],
|
|
346
|
+
examples: [
|
|
347
|
+
"ipab build prepared-app",
|
|
348
|
+
"ipab build ipab.build.yaml --replace",
|
|
138
349
|
],
|
|
139
|
-
examples: ["ipab build", "ipab build hello --replace --without-source"],
|
|
140
350
|
notes: [
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
351
|
+
"Recipe explicitly maps source files and exact CID imports to target paths.",
|
|
352
|
+
"Type and entry come from .bundle.yaml; imported DAG identities are preserved.",
|
|
353
|
+
"Legacy App ipab.yaml is rejected; use project preparation tools separately.",
|
|
354
|
+
"Select explicit files; review private files before providing Bundles.",
|
|
145
355
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
146
356
|
],
|
|
147
357
|
},
|
|
148
|
-
"bundle init": {
|
|
149
|
-
summary: "Create content from a Bundle type",
|
|
150
|
-
arguments: [
|
|
151
|
-
"TYPE Definition file, type CAR, exact type CID or Schema pin.",
|
|
152
|
-
"DIR New or empty destination directory.",
|
|
153
|
-
],
|
|
154
|
-
examples: ["ipab bundle init types\\dist\\schema.car note"],
|
|
155
|
-
notes: ["Writes .bundle.yaml, .bundle-ignore and the default entry."],
|
|
156
|
-
},
|
|
157
358
|
"bundle build": {
|
|
158
359
|
summary: "Build a content or type CAR without compiling code",
|
|
159
360
|
arguments: ["SOURCE Bundle directory or definition file."],
|
|
@@ -188,20 +389,23 @@ const commandHelp: Record<
|
|
|
188
389
|
],
|
|
189
390
|
},
|
|
190
391
|
exec: {
|
|
191
|
-
summary: "Run an App by CID or
|
|
392
|
+
summary: "Run an App by CID, named pin or IPAB URI",
|
|
192
393
|
arguments: [
|
|
193
394
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
194
395
|
],
|
|
195
396
|
options: [
|
|
196
397
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
398
|
+
"--force Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
399
|
+
"--no-force Override swarm.forceRefresh; must precede APP.",
|
|
197
400
|
],
|
|
198
401
|
examples: [
|
|
199
402
|
"ipab exec reader",
|
|
200
|
-
"ipab exec reader --help",
|
|
201
403
|
"ipab exec --log reader",
|
|
404
|
+
"ipab exec ipab://work/apps/hello --help",
|
|
202
405
|
],
|
|
203
406
|
notes: [
|
|
204
407
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
408
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
205
409
|
"History stores argv by default; do not put secrets in arguments.",
|
|
206
410
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
207
411
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -209,25 +413,35 @@ const commandHelp: Record<
|
|
|
209
413
|
},
|
|
210
414
|
open: {
|
|
211
415
|
summary: "Open content with its registered App",
|
|
212
|
-
arguments: ["CONTENT Bundle CID or
|
|
213
|
-
options: [
|
|
214
|
-
|
|
416
|
+
arguments: ["CONTENT Bundle CID, named pin or IPAB URI."],
|
|
417
|
+
options: [
|
|
418
|
+
"--log Record stdout/stderr; requires history enabled.",
|
|
419
|
+
"--raw Open the Artifact node rather than its value.",
|
|
420
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
421
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
422
|
+
],
|
|
423
|
+
examples: [
|
|
424
|
+
"ipab open CONTENT_CID",
|
|
425
|
+
"ipab open --log my-note",
|
|
426
|
+
"ipab open ipab:///documents/readme",
|
|
427
|
+
],
|
|
215
428
|
notes: [
|
|
216
429
|
"Requires a saved registration and App support for the exact content type.",
|
|
430
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
217
431
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
218
432
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
219
433
|
"--json is not supported; App stdio is passed through.",
|
|
220
434
|
],
|
|
221
435
|
},
|
|
222
436
|
"pin add": {
|
|
223
|
-
summary: "Verify, retain and name
|
|
437
|
+
summary: "Verify, retain and name a Bundle",
|
|
224
438
|
arguments: [
|
|
225
439
|
"NAME Unused short name.",
|
|
226
|
-
"CID Exact
|
|
440
|
+
"CID Exact Bundle CID, not another pin name or a standalone type block.",
|
|
227
441
|
],
|
|
228
442
|
examples: ["ipab pin add reader APP_CID"],
|
|
229
443
|
notes: [
|
|
230
|
-
"
|
|
444
|
+
"Validates a complete Bundle and retains its full DAG in the configured Store.",
|
|
231
445
|
"Does not execute or trust Apps, install dependencies or start a daemon.",
|
|
232
446
|
"The builtin namespace is read-only.",
|
|
233
447
|
],
|
|
@@ -243,15 +457,12 @@ const commandHelp: Record<
|
|
|
243
457
|
"pin list": {
|
|
244
458
|
summary: "List user and built-in pins",
|
|
245
459
|
options: [
|
|
246
|
-
"--
|
|
247
|
-
"--type TYPE Exact schema CID, Schema pin or builtin shortcut.",
|
|
248
|
-
],
|
|
249
|
-
examples: [
|
|
250
|
-
"ipab pin list",
|
|
251
|
-
"ipab pin list --kind bundle --type builtin:node-app.v1",
|
|
460
|
+
"--type TYPE Exact type CID or the name of a Bundle pin of that type.",
|
|
252
461
|
],
|
|
462
|
+
examples: ["ipab pin list", "ipab pin list --type reader"],
|
|
253
463
|
notes: [
|
|
254
|
-
"
|
|
464
|
+
"Unfinished operations and legacy non-Bundle pins are reported separately.",
|
|
465
|
+
"Legacy retention is preserved; use pin delete to explicitly release it.",
|
|
255
466
|
"Reads local registrations and packaged built-ins, not live node status.",
|
|
256
467
|
],
|
|
257
468
|
},
|
|
@@ -300,21 +511,25 @@ const commandHelp: Record<
|
|
|
300
511
|
"config get": {
|
|
301
512
|
summary: "Show effective configuration",
|
|
302
513
|
arguments: ["KEY Optional configuration key; omit to show all values."],
|
|
303
|
-
examples: ["ipab config get", "ipab config get store.
|
|
514
|
+
examples: ["ipab config get", "ipab config get store.gateway"],
|
|
304
515
|
},
|
|
305
516
|
"config set": {
|
|
306
517
|
summary: "Save a local configuration value",
|
|
307
518
|
examples: [
|
|
308
|
-
"ipab config set
|
|
519
|
+
"ipab config set pointers.apiKey -",
|
|
520
|
+
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
309
521
|
"ipab config set history.enabled false",
|
|
310
522
|
],
|
|
311
523
|
notes: [
|
|
312
|
-
"store.
|
|
524
|
+
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
525
|
+
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
526
|
+
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
527
|
+
"Saving pointers.apiKey protects state SQLite files with account-only Unix modes or Windows ACLs.",
|
|
313
528
|
],
|
|
314
529
|
},
|
|
315
530
|
"config reset": {
|
|
316
531
|
summary: "Remove a saved configuration override",
|
|
317
|
-
examples: ["ipab config reset store.
|
|
532
|
+
examples: ["ipab config reset store.gateway"],
|
|
318
533
|
},
|
|
319
534
|
"history list": {
|
|
320
535
|
summary: "List execution history",
|
|
@@ -362,8 +577,9 @@ const commandHelp: Record<
|
|
|
362
577
|
|
|
363
578
|
export function help(path = ""): string {
|
|
364
579
|
const globalOptions = `Global options (before COMMAND):
|
|
580
|
+
--swarm CID|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
365
581
|
--state-dir PATH Set the local state directory
|
|
366
|
-
--store-
|
|
582
|
+
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
367
583
|
--json Output management/development metadata, not App stdio`;
|
|
368
584
|
const footer =
|
|
369
585
|
"Full reference: https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md";
|
|
@@ -382,9 +598,14 @@ Create:
|
|
|
382
598
|
bundle ${groups.bundle}
|
|
383
599
|
|
|
384
600
|
Manage:
|
|
601
|
+
swarm ${groups.swarm}
|
|
602
|
+
search Search formal Names across registered swarms
|
|
603
|
+
publish ${commandHelp.publish!.summary}
|
|
604
|
+
get ${commandHelp.get!.summary}
|
|
385
605
|
pin ${groups.pin}
|
|
386
606
|
register ${groups.register}
|
|
387
607
|
config ${groups.config}
|
|
608
|
+
store ${groups.store}
|
|
388
609
|
history ${groups.history}
|
|
389
610
|
|
|
390
611
|
${globalOptions}
|
|
@@ -461,6 +682,20 @@ function runDuration(record: Pick<RunRecord, "startedAt" | "endedAt">): string {
|
|
|
461
682
|
return `${Math.floor(duration / 1000)}s`;
|
|
462
683
|
}
|
|
463
684
|
|
|
685
|
+
function storageBytes(bytes: number): string {
|
|
686
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
687
|
+
let scaled = bytes;
|
|
688
|
+
let unit = 0;
|
|
689
|
+
while (scaled >= 1000 && unit < units.length - 1) {
|
|
690
|
+
scaled /= 1000;
|
|
691
|
+
unit++;
|
|
692
|
+
}
|
|
693
|
+
const exact = bytes.toLocaleString("en-US");
|
|
694
|
+
return unit === 0
|
|
695
|
+
? `${exact} bytes`
|
|
696
|
+
: `${scaled.toLocaleString("en-US", { maximumFractionDigits: 2 })} ${units[unit]} (${exact} bytes)`;
|
|
697
|
+
}
|
|
698
|
+
|
|
464
699
|
function table(headers: string[], rows: string[][], empty: string): string {
|
|
465
700
|
if (!rows.length) return empty;
|
|
466
701
|
const cells = rows.map((row) => row.map(printable));
|
|
@@ -566,12 +801,21 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
566
801
|
};
|
|
567
802
|
}
|
|
568
803
|
if (flag === "--json") flags.json = true;
|
|
569
|
-
else if (flag === "--
|
|
804
|
+
else if (flag === "--store-rpc")
|
|
805
|
+
syntax(
|
|
806
|
+
"Store RPC is no longer supported. Use --store-gateway with an HTTP gateway URL; existing Kubo pins are not migrated.",
|
|
807
|
+
);
|
|
808
|
+
else if (
|
|
809
|
+
flag === "--state-dir" ||
|
|
810
|
+
flag === "--store-gateway" ||
|
|
811
|
+
flag === "--swarm"
|
|
812
|
+
) {
|
|
570
813
|
const value = tokens.shift();
|
|
571
814
|
if (!value || value.startsWith("-")) syntax(`${flag} needs a value.`);
|
|
572
815
|
if (flag === "--state-dir") flags.stateDir = value;
|
|
816
|
+
else if (flag === "--swarm") flags.swarm = value;
|
|
573
817
|
else {
|
|
574
|
-
flags.
|
|
818
|
+
flags.storeGateway = publicUrl(value);
|
|
575
819
|
}
|
|
576
820
|
} else syntax(`Unknown global option "${flag}".`);
|
|
577
821
|
}
|
|
@@ -587,10 +831,14 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
587
831
|
if (!group) return result;
|
|
588
832
|
if (group === "exec") {
|
|
589
833
|
if (flags.json) syntax("--json is not supported for exec/open.");
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
834
|
+
while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
|
|
835
|
+
const option = tokens.shift()!.slice(2);
|
|
836
|
+
if (Object.hasOwn(result.options, option))
|
|
837
|
+
syntax(`Duplicate option --${option}.`);
|
|
838
|
+
result.options[option] = true;
|
|
593
839
|
}
|
|
840
|
+
if (result.options.force && result.options["no-force"])
|
|
841
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
594
842
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
595
843
|
result.help = true;
|
|
596
844
|
return result;
|
|
@@ -600,8 +848,18 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
600
848
|
result.positional = tokens;
|
|
601
849
|
return result;
|
|
602
850
|
}
|
|
603
|
-
if (!["open", "init", "build"].includes(group)) {
|
|
604
|
-
if (
|
|
851
|
+
if (!["open", "init", "build", "publish", "get", "search"].includes(group)) {
|
|
852
|
+
if (
|
|
853
|
+
![
|
|
854
|
+
"bundle",
|
|
855
|
+
"pin",
|
|
856
|
+
"register",
|
|
857
|
+
"config",
|
|
858
|
+
"history",
|
|
859
|
+
"store",
|
|
860
|
+
"swarm",
|
|
861
|
+
].includes(group)
|
|
862
|
+
)
|
|
605
863
|
syntax(`Unknown command "${group}".`);
|
|
606
864
|
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
607
865
|
result.help = true;
|
|
@@ -618,30 +876,58 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
618
876
|
result.help = true;
|
|
619
877
|
return result;
|
|
620
878
|
}
|
|
879
|
+
if (
|
|
880
|
+
result.path === "config set" &&
|
|
881
|
+
tokens.includes("pointers.apiKey") &&
|
|
882
|
+
!(tokens.length === 2 && tokens[1] === "-")
|
|
883
|
+
)
|
|
884
|
+
syntax(
|
|
885
|
+
"API key must be provided through '-' and piped stdin; never pass it in command arguments.",
|
|
886
|
+
);
|
|
621
887
|
const booleans =
|
|
622
888
|
result.path === "bundle build"
|
|
623
889
|
? ["replace", "schema-only", "no-import"]
|
|
624
890
|
: result.path === "build"
|
|
625
|
-
? ["replace", "no-import"
|
|
626
|
-
: result.path === "
|
|
627
|
-
? ["
|
|
628
|
-
: result.path === "
|
|
629
|
-
? ["
|
|
630
|
-
: result.path === "
|
|
631
|
-
? ["
|
|
632
|
-
:
|
|
891
|
+
? ["replace", "no-import"]
|
|
892
|
+
: result.path === "publish"
|
|
893
|
+
? ["snapshot"]
|
|
894
|
+
: result.path === "get"
|
|
895
|
+
? ["raw", "force", "no-force"]
|
|
896
|
+
: result.path === "search"
|
|
897
|
+
? ["current", "force", "no-force"]
|
|
898
|
+
: result.path === "swarm approve"
|
|
899
|
+
? ["yes"]
|
|
900
|
+
: result.path === "register set"
|
|
901
|
+
? ["replace"]
|
|
902
|
+
: result.path === "history remove"
|
|
903
|
+
? ["yes"]
|
|
904
|
+
: result.path === "open"
|
|
905
|
+
? ["log", "raw", "force", "no-force"]
|
|
906
|
+
: [];
|
|
633
907
|
const values =
|
|
634
|
-
result.path === "
|
|
635
|
-
? ["
|
|
636
|
-
: result.path === "
|
|
637
|
-
? ["
|
|
638
|
-
: result.path === "
|
|
639
|
-
? ["
|
|
640
|
-
: result.path === "
|
|
641
|
-
? ["
|
|
642
|
-
: result.path === "
|
|
643
|
-
? ["
|
|
644
|
-
:
|
|
908
|
+
result.path === "swarm create"
|
|
909
|
+
? ["service", "resume", "name", "description", "alias"]
|
|
910
|
+
: result.path === "swarm add" || result.path === "swarm join"
|
|
911
|
+
? ["alias"]
|
|
912
|
+
: result.path === "swarm update"
|
|
913
|
+
? ["name", "description"]
|
|
914
|
+
: result.path === "swarm approve"
|
|
915
|
+
? ["expires-in"]
|
|
916
|
+
: result.path === "publish"
|
|
917
|
+
? ["name", "expect"]
|
|
918
|
+
: result.path === "get"
|
|
919
|
+
? ["output"]
|
|
920
|
+
: result.path === "init"
|
|
921
|
+
? ["template"]
|
|
922
|
+
: result.path === "bundle build" || result.path === "build"
|
|
923
|
+
? ["output"]
|
|
924
|
+
: result.path === "history list"
|
|
925
|
+
? ["app", "status", "since", "until", "limit", "before"]
|
|
926
|
+
: result.path === "history remove"
|
|
927
|
+
? ["app", "status", "since", "until"]
|
|
928
|
+
: result.path === "pin list"
|
|
929
|
+
? ["type"]
|
|
930
|
+
: [];
|
|
645
931
|
while (tokens.length) {
|
|
646
932
|
const value = tokens.shift()!;
|
|
647
933
|
if (value.startsWith("--") || value === "-o") {
|
|
@@ -658,15 +944,40 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
658
944
|
if (booleans.includes(option)) result.options[option] = true;
|
|
659
945
|
else if (values.includes(option)) {
|
|
660
946
|
const input = tokens.shift();
|
|
661
|
-
if (
|
|
947
|
+
if (
|
|
948
|
+
input === undefined ||
|
|
949
|
+
input.startsWith("--") ||
|
|
950
|
+
(input === "" && result.path !== "swarm update")
|
|
951
|
+
)
|
|
952
|
+
syntax(`${value} needs a value.`);
|
|
662
953
|
result.options[option] = input;
|
|
663
954
|
} else syntax(`Unknown option "${value}".`);
|
|
664
955
|
} else result.positional.push(value);
|
|
665
956
|
}
|
|
957
|
+
if (result.options.force && result.options["no-force"])
|
|
958
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
959
|
+
if (
|
|
960
|
+
result.path === "search" &&
|
|
961
|
+
result.options.current &&
|
|
962
|
+
flags.swarm !== undefined
|
|
963
|
+
)
|
|
964
|
+
syntax("--current and --swarm are mutually exclusive.");
|
|
666
965
|
const counts: Record<string, [number, number]> = {
|
|
966
|
+
"swarm create": [0, 0],
|
|
967
|
+
"swarm request": [1, 1],
|
|
968
|
+
"swarm approve": [1, 1],
|
|
969
|
+
"swarm join": [1, 1],
|
|
970
|
+
"swarm status": [0, 1],
|
|
971
|
+
"swarm list": [0, 0],
|
|
972
|
+
"swarm add": [1, 1],
|
|
973
|
+
"swarm use": [1, 1],
|
|
974
|
+
"swarm remove": [1, 1],
|
|
975
|
+
"swarm update": [0, 1],
|
|
976
|
+
publish: [1, 1],
|
|
977
|
+
get: [1, 1],
|
|
978
|
+
search: [1, 1],
|
|
667
979
|
init: [1, 2],
|
|
668
980
|
build: [0, 1],
|
|
669
|
-
"bundle init": [2, 2],
|
|
670
981
|
"bundle build": [1, 1],
|
|
671
982
|
"bundle inspect": [1, 1],
|
|
672
983
|
"bundle import": [1, 1],
|
|
@@ -682,6 +993,8 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
682
993
|
"config get": [0, 1],
|
|
683
994
|
"config set": [2, 2],
|
|
684
995
|
"config reset": [1, 1],
|
|
996
|
+
"store usage": [0, 0],
|
|
997
|
+
"store gc": [0, 0],
|
|
685
998
|
"history list": [0, 0],
|
|
686
999
|
"history show": [1, 1],
|
|
687
1000
|
"history remove": [0, Number.MAX_SAFE_INTEGER],
|
|
@@ -712,16 +1025,21 @@ export function parse(argv: readonly string[]): Parsed {
|
|
|
712
1025
|
if (result.path === "pin add") exactCid(result.positional[1]!);
|
|
713
1026
|
if (result.path === "pin rename") pinName(result.positional[1]!);
|
|
714
1027
|
}
|
|
715
|
-
if (
|
|
716
|
-
result.options.kind !== undefined &&
|
|
717
|
-
!["bundle", "schema"].includes(String(result.options.kind))
|
|
718
|
-
)
|
|
719
|
-
syntax("--kind must be bundle or schema.");
|
|
720
1028
|
if (result.path.startsWith("config ") && result.positional[0]) {
|
|
721
|
-
if (
|
|
1029
|
+
if (
|
|
1030
|
+
!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
1031
|
+
!(result.path === "config reset" && result.positional[0] === "store.rpc")
|
|
1032
|
+
)
|
|
722
1033
|
configKey(result.positional[0]);
|
|
723
|
-
if (result.path === "config set")
|
|
724
|
-
|
|
1034
|
+
if (result.path === "config set") {
|
|
1035
|
+
if (result.positional[0] === "pointers.apiKey") {
|
|
1036
|
+
if (result.positional[1] !== "-")
|
|
1037
|
+
syntax(
|
|
1038
|
+
"Set pointers.apiKey using '-' and piped stdin; never put the key in command-line arguments.",
|
|
1039
|
+
);
|
|
1040
|
+
} else
|
|
1041
|
+
parseValue(configKey(result.positional[0]), result.positional[1], true);
|
|
1042
|
+
}
|
|
725
1043
|
}
|
|
726
1044
|
if (typeof result.options.limit === "string")
|
|
727
1045
|
parseValue("history.limit", result.options.limit, true);
|
|
@@ -760,20 +1078,317 @@ async function performCli(
|
|
|
760
1078
|
syntax("Non-interactive history remove requires --yes.");
|
|
761
1079
|
const builtins = await builtinContent();
|
|
762
1080
|
state = new State(stateLocation(parsed.flags, env).path, builtins.pins);
|
|
763
|
-
|
|
1081
|
+
if (
|
|
1082
|
+
parsed.path === "config reset" &&
|
|
1083
|
+
parsed.positional[0] === "store.rpc"
|
|
1084
|
+
) {
|
|
1085
|
+
state.resetConfig("store.rpc");
|
|
1086
|
+
io.out(
|
|
1087
|
+
parsed.flags.json
|
|
1088
|
+
? JSON.stringify({ reset: ["store.rpc"] })
|
|
1089
|
+
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.",
|
|
1090
|
+
);
|
|
1091
|
+
return 0;
|
|
1092
|
+
}
|
|
1093
|
+
const items = effectiveConfig(
|
|
1094
|
+
state.config(),
|
|
1095
|
+
parsed.flags,
|
|
1096
|
+
env,
|
|
1097
|
+
(reference) => state!.resolveSwarm(reference),
|
|
1098
|
+
);
|
|
764
1099
|
const value = (key: string) =>
|
|
765
1100
|
items.find((item) => item.key === key)!.value;
|
|
766
1101
|
const emit = (result: unknown, human: string) => {
|
|
767
1102
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
768
1103
|
};
|
|
769
1104
|
const [first, second] = parsed.positional;
|
|
1105
|
+
const selectedSwarm =
|
|
1106
|
+
value("swarm.default") === null
|
|
1107
|
+
? undefined
|
|
1108
|
+
: String(value("swarm.default"));
|
|
1109
|
+
const swarmContext = (): SwarmContext => ({
|
|
1110
|
+
store: store!,
|
|
1111
|
+
state: state!,
|
|
1112
|
+
env,
|
|
1113
|
+
stateDir: stateLocation(parsed.flags, env).path,
|
|
1114
|
+
provider: String(value("swarm.provider") ?? "http://127.0.0.1:5001"),
|
|
1115
|
+
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
1116
|
+
forceRefresh: parsed.options.force
|
|
1117
|
+
? true
|
|
1118
|
+
: parsed.options["no-force"]
|
|
1119
|
+
? false
|
|
1120
|
+
: Boolean(value("swarm.forceRefresh")),
|
|
1121
|
+
diagnostic: (text) => {
|
|
1122
|
+
io.err(text);
|
|
1123
|
+
},
|
|
1124
|
+
...(typeof value("pointers.service") === "string"
|
|
1125
|
+
? { pointerService: String(value("pointers.service")) }
|
|
1126
|
+
: {}),
|
|
1127
|
+
...(typeof value("pointers.apiKey") === "string"
|
|
1128
|
+
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1129
|
+
: {}),
|
|
1130
|
+
});
|
|
770
1131
|
const filter = parsed.path.startsWith("history ")
|
|
771
1132
|
? filters(state, parsed.options)
|
|
772
1133
|
: {};
|
|
1134
|
+
const selection = () => {
|
|
1135
|
+
const current = effectiveConfig(
|
|
1136
|
+
state!.config(),
|
|
1137
|
+
parsed.flags,
|
|
1138
|
+
env,
|
|
1139
|
+
(reference) => state!.resolveSwarm(reference),
|
|
1140
|
+
).find((item) => item.key === "swarm.default")!;
|
|
1141
|
+
return {
|
|
1142
|
+
savedCurrent: state!.config()["swarm.default"] ?? null,
|
|
1143
|
+
effectiveCurrent: current.value,
|
|
1144
|
+
source: current.source,
|
|
1145
|
+
};
|
|
1146
|
+
};
|
|
773
1147
|
switch (parsed.path) {
|
|
1148
|
+
case "swarm list": {
|
|
1149
|
+
const result = { swarms: state.swarms(), ...selection() };
|
|
1150
|
+
emit(
|
|
1151
|
+
result,
|
|
1152
|
+
[
|
|
1153
|
+
...result.swarms.map(
|
|
1154
|
+
(entry) =>
|
|
1155
|
+
`${entry.cid === result.savedCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`,
|
|
1156
|
+
),
|
|
1157
|
+
`Saved current: ${result.savedCurrent ?? "(none)"}`,
|
|
1158
|
+
`Effective current: ${result.effectiveCurrent ?? "(none)"} (${result.source})`,
|
|
1159
|
+
].join("\n"),
|
|
1160
|
+
);
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
case "swarm use": {
|
|
1164
|
+
state.useSwarm(first!);
|
|
1165
|
+
const result = selection();
|
|
1166
|
+
emit(result, `Saved current swarm: ${result.savedCurrent}`);
|
|
1167
|
+
if (result.source === "flag" || result.source === "env")
|
|
1168
|
+
io.err(
|
|
1169
|
+
`The saved default is overridden by ${result.source}: ${result.effectiveCurrent}.`,
|
|
1170
|
+
);
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
case "swarm remove": {
|
|
1174
|
+
const removed = state.removeSwarm(first!);
|
|
1175
|
+
emit(
|
|
1176
|
+
{ removed, savedCurrent: state.config()["swarm.default"] ?? null },
|
|
1177
|
+
`Removed registration ${removed}. Credentials, content and remote membership are unchanged.`,
|
|
1178
|
+
);
|
|
1179
|
+
break;
|
|
1180
|
+
}
|
|
1181
|
+
case "swarm add":
|
|
1182
|
+
case "swarm update":
|
|
1183
|
+
case "search":
|
|
1184
|
+
case "swarm create":
|
|
1185
|
+
case "swarm request":
|
|
1186
|
+
case "swarm approve":
|
|
1187
|
+
case "swarm join":
|
|
1188
|
+
case "swarm status":
|
|
1189
|
+
case "publish":
|
|
1190
|
+
case "get": {
|
|
1191
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1192
|
+
const context = swarmContext();
|
|
1193
|
+
if (parsed.path === "swarm update") {
|
|
1194
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1195
|
+
if (!cid)
|
|
1196
|
+
syntax(
|
|
1197
|
+
"swarm update requires a registered alias, Swarm CID or current swarm.",
|
|
1198
|
+
);
|
|
1199
|
+
const result = await updateSwarm(context, cid, {
|
|
1200
|
+
...(typeof parsed.options.name === "string"
|
|
1201
|
+
? { name: parsed.options.name }
|
|
1202
|
+
: {}),
|
|
1203
|
+
...(typeof parsed.options.description === "string"
|
|
1204
|
+
? { description: parsed.options.description }
|
|
1205
|
+
: {}),
|
|
1206
|
+
});
|
|
1207
|
+
emit(
|
|
1208
|
+
result,
|
|
1209
|
+
`Swarm: ${result.cid}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD: ${result.root}\nRevision: ${result.revision}`,
|
|
1210
|
+
);
|
|
1211
|
+
break;
|
|
1212
|
+
}
|
|
1213
|
+
if (parsed.path === "swarm add") {
|
|
1214
|
+
const cid = exactCid(first!);
|
|
1215
|
+
await addSwarm(
|
|
1216
|
+
context,
|
|
1217
|
+
cid,
|
|
1218
|
+
typeof parsed.options.alias === "string"
|
|
1219
|
+
? parsed.options.alias
|
|
1220
|
+
: undefined,
|
|
1221
|
+
);
|
|
1222
|
+
const entry = state.registeredSwarm(cid);
|
|
1223
|
+
emit(
|
|
1224
|
+
{ ...entry, savedCurrent: state.config()["swarm.default"] ?? null },
|
|
1225
|
+
`Registered swarm ${entry.alias ?? cid} (${cid}).`,
|
|
1226
|
+
);
|
|
1227
|
+
break;
|
|
1228
|
+
}
|
|
1229
|
+
if (parsed.path === "search") {
|
|
1230
|
+
const source = items.find(
|
|
1231
|
+
(item) => item.key === "swarm.default",
|
|
1232
|
+
)!.source;
|
|
1233
|
+
const limited = parsed.options.current || source === "flag";
|
|
1234
|
+
if (limited && !selectedSwarm)
|
|
1235
|
+
syntax(
|
|
1236
|
+
"Search of the current swarm requires --swarm or swarm.default.",
|
|
1237
|
+
);
|
|
1238
|
+
const registrations = state.swarms();
|
|
1239
|
+
const scope = limited
|
|
1240
|
+
? [
|
|
1241
|
+
{
|
|
1242
|
+
cid: selectedSwarm!,
|
|
1243
|
+
alias:
|
|
1244
|
+
registrations.find((entry) => entry.cid === selectedSwarm)
|
|
1245
|
+
?.alias ?? null,
|
|
1246
|
+
},
|
|
1247
|
+
]
|
|
1248
|
+
: registrations;
|
|
1249
|
+
const result = await searchNames(context, first!, scope);
|
|
1250
|
+
emit(
|
|
1251
|
+
result,
|
|
1252
|
+
result.matches.length
|
|
1253
|
+
? result.matches
|
|
1254
|
+
.map(
|
|
1255
|
+
(match) =>
|
|
1256
|
+
`${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`,
|
|
1257
|
+
)
|
|
1258
|
+
.join("\n")
|
|
1259
|
+
: "No matching Names.",
|
|
1260
|
+
);
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
if (parsed.path === "swarm status") {
|
|
1264
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1265
|
+
if (!cid)
|
|
1266
|
+
syntax("swarm status requires a Swarm CID or swarm.default.");
|
|
1267
|
+
const data = await descriptor(store, cid);
|
|
1268
|
+
const { head, snapshot } = await swarmHeader(context, cid, true);
|
|
1269
|
+
emit(
|
|
1270
|
+
{
|
|
1271
|
+
cid,
|
|
1272
|
+
...data,
|
|
1273
|
+
root: head.root,
|
|
1274
|
+
revision: head.revision,
|
|
1275
|
+
properties: snapshot.properties,
|
|
1276
|
+
},
|
|
1277
|
+
`Swarm: ${cid}\nName: ${printable(snapshot.properties.name)}\nDescription: ${printable(snapshot.properties.description)}\nHEAD: ${head.root}\nRevision: ${head.revision}`,
|
|
1278
|
+
);
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
if (parsed.path === "get") {
|
|
1282
|
+
const selected = await resolveReference(
|
|
1283
|
+
context,
|
|
1284
|
+
first!,
|
|
1285
|
+
selectedSwarm,
|
|
1286
|
+
(reference) => state!.resolve(reference),
|
|
1287
|
+
Boolean(parsed.options.raw),
|
|
1288
|
+
);
|
|
1289
|
+
const directory = await getBundle(
|
|
1290
|
+
store,
|
|
1291
|
+
selected.cid,
|
|
1292
|
+
typeof parsed.options.output === "string"
|
|
1293
|
+
? parsed.options.output
|
|
1294
|
+
: undefined,
|
|
1295
|
+
);
|
|
1296
|
+
emit(
|
|
1297
|
+
{ ...selected, directory },
|
|
1298
|
+
`CID: ${selected.cid}\nTarget CID: ${selected.targetCid}\nDirectory: ${directory}`,
|
|
1299
|
+
);
|
|
1300
|
+
break;
|
|
1301
|
+
}
|
|
1302
|
+
let cid: string;
|
|
1303
|
+
if (parsed.path === "swarm create") {
|
|
1304
|
+
cid = await createSwarm(context, {
|
|
1305
|
+
...(typeof parsed.options.service === "string"
|
|
1306
|
+
? { service: parsed.options.service }
|
|
1307
|
+
: {}),
|
|
1308
|
+
...(typeof parsed.options.resume === "string"
|
|
1309
|
+
? { resume: parsed.options.resume }
|
|
1310
|
+
: {}),
|
|
1311
|
+
properties: {
|
|
1312
|
+
name: String(parsed.options.name ?? ""),
|
|
1313
|
+
description: String(parsed.options.description ?? ""),
|
|
1314
|
+
},
|
|
1315
|
+
...(typeof parsed.options.alias === "string"
|
|
1316
|
+
? { alias: parsed.options.alias }
|
|
1317
|
+
: {}),
|
|
1318
|
+
});
|
|
1319
|
+
} else if (parsed.path === "swarm request")
|
|
1320
|
+
cid = await requestMembership(context, exactCid(first!));
|
|
1321
|
+
else if (parsed.path === "swarm approve") {
|
|
1322
|
+
if (
|
|
1323
|
+
!parsed.options.yes &&
|
|
1324
|
+
(!io.tty ||
|
|
1325
|
+
!(await io.confirm(
|
|
1326
|
+
`Approve membership request ${first!}? This grants swarm HEAD read/write access.`,
|
|
1327
|
+
)))
|
|
1328
|
+
)
|
|
1329
|
+
throw new HostError(
|
|
1330
|
+
"Approval requires explicit --yes or interactive confirmation.",
|
|
1331
|
+
);
|
|
1332
|
+
cid = await approveMembership(
|
|
1333
|
+
context,
|
|
1334
|
+
exactCid(first!),
|
|
1335
|
+
parsed.options["expires-in"] === undefined
|
|
1336
|
+
? undefined
|
|
1337
|
+
: Number(parsed.options["expires-in"]),
|
|
1338
|
+
);
|
|
1339
|
+
} else if (parsed.path === "swarm join")
|
|
1340
|
+
cid = await joinSwarm(
|
|
1341
|
+
context,
|
|
1342
|
+
exactCid(first!),
|
|
1343
|
+
typeof parsed.options.alias === "string"
|
|
1344
|
+
? parsed.options.alias
|
|
1345
|
+
: undefined,
|
|
1346
|
+
);
|
|
1347
|
+
else {
|
|
1348
|
+
let content: string;
|
|
1349
|
+
if (first!.toLowerCase().endsWith(".car"))
|
|
1350
|
+
content = (
|
|
1351
|
+
await importBundle(first!, () => Promise.resolve(store!))
|
|
1352
|
+
).cid;
|
|
1353
|
+
else content = exactCid(first!);
|
|
1354
|
+
cid = await publish(context, content, {
|
|
1355
|
+
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
1356
|
+
...(typeof parsed.options.name === "string"
|
|
1357
|
+
? { name: parsed.options.name }
|
|
1358
|
+
: {}),
|
|
1359
|
+
...(typeof parsed.options.expect === "string"
|
|
1360
|
+
? { expect: parsed.options.expect }
|
|
1361
|
+
: {}),
|
|
1362
|
+
snapshot: Boolean(parsed.options.snapshot),
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
if (parsed.path === "swarm create" || parsed.path === "swarm join")
|
|
1366
|
+
io.err(
|
|
1367
|
+
`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`,
|
|
1368
|
+
);
|
|
1369
|
+
emit({ cid }, cid);
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1372
|
+
case "store usage":
|
|
1373
|
+
case "store gc": {
|
|
1374
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1375
|
+
if (parsed.path === "store usage") {
|
|
1376
|
+
const result = await store.usage();
|
|
1377
|
+
emit(
|
|
1378
|
+
result,
|
|
1379
|
+
`Cached blocks: ${storageBytes(result.cachedBytes)}\nPinned blocks (deduplicated): ${storageBytes(result.pinnedBytes)}`,
|
|
1380
|
+
);
|
|
1381
|
+
} else {
|
|
1382
|
+
const result = await store.gc();
|
|
1383
|
+
emit(
|
|
1384
|
+
result,
|
|
1385
|
+
`Removed ${result.removedBlocks} blocks; reclaimed ${storageBytes(result.reclaimedBytes)}.`,
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
break;
|
|
1389
|
+
}
|
|
774
1390
|
case "init":
|
|
775
1391
|
case "build":
|
|
776
|
-
case "bundle init":
|
|
777
1392
|
case "bundle build":
|
|
778
1393
|
case "bundle inspect":
|
|
779
1394
|
case "bundle import": {
|
|
@@ -792,7 +1407,7 @@ async function performCli(
|
|
|
792
1407
|
try {
|
|
793
1408
|
let pendingStore: Promise<IpfsStore> | undefined;
|
|
794
1409
|
const getStore = () => {
|
|
795
|
-
pendingStore ??= storeConfiguration(value("store.
|
|
1410
|
+
pendingStore ??= storeConfiguration(value("store.gateway")).then(
|
|
796
1411
|
(configuration) => {
|
|
797
1412
|
store = new IpfsStore(configuration);
|
|
798
1413
|
return store;
|
|
@@ -820,7 +1435,7 @@ async function performCli(
|
|
|
820
1435
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
821
1436
|
io.err(
|
|
822
1437
|
parsed.path === "build"
|
|
823
|
-
? "
|
|
1438
|
+
? "Assembling and validating Bundle (no compilation)..."
|
|
824
1439
|
: "Validating and building bundle...",
|
|
825
1440
|
);
|
|
826
1441
|
if (parsed.path === "bundle import")
|
|
@@ -843,34 +1458,27 @@ async function performCli(
|
|
|
843
1458
|
: {}),
|
|
844
1459
|
})
|
|
845
1460
|
: parsed.path === "build"
|
|
846
|
-
? await
|
|
1461
|
+
? await assembleBundle(first, {
|
|
847
1462
|
...request,
|
|
848
1463
|
replace: Boolean(parsed.options.replace),
|
|
849
|
-
...(parsed.options["with-source"]
|
|
850
|
-
? { includeSource: true }
|
|
851
|
-
: parsed.options["without-source"]
|
|
852
|
-
? { includeSource: false }
|
|
853
|
-
: {}),
|
|
854
1464
|
...(typeof parsed.options.output === "string"
|
|
855
1465
|
? { output: parsed.options.output }
|
|
856
1466
|
: {}),
|
|
857
1467
|
outputDir: String(value("bundle.outputDir")),
|
|
858
1468
|
})
|
|
859
|
-
: parsed.path === "bundle
|
|
860
|
-
? await
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
:
|
|
872
|
-
? await importBundle(first!, getStore, request)
|
|
873
|
-
: await inspectBundle(source!, request);
|
|
1469
|
+
: parsed.path === "bundle build"
|
|
1470
|
+
? await buildBundle(source!, {
|
|
1471
|
+
...request,
|
|
1472
|
+
schemaOnly: Boolean(parsed.options["schema-only"]),
|
|
1473
|
+
replace: Boolean(parsed.options.replace),
|
|
1474
|
+
...(typeof parsed.options.output === "string"
|
|
1475
|
+
? { output: parsed.options.output }
|
|
1476
|
+
: {}),
|
|
1477
|
+
outputDir: String(value("bundle.outputDir")),
|
|
1478
|
+
})
|
|
1479
|
+
: parsed.path === "bundle import"
|
|
1480
|
+
? await importBundle(first!, getStore, request)
|
|
1481
|
+
: await inspectBundle(source!, request);
|
|
874
1482
|
const importing = "output" in result && !parsed.options["no-import"];
|
|
875
1483
|
if (importing) {
|
|
876
1484
|
io.err("Importing build result into Store (without pinning)...");
|
|
@@ -894,33 +1502,34 @@ async function performCli(
|
|
|
894
1502
|
if ("output" in result)
|
|
895
1503
|
emit(
|
|
896
1504
|
{ ...result, imported: importing },
|
|
897
|
-
`CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${
|
|
1505
|
+
`CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nCAR: ${result.output}${result.validation !== undefined ? `\nEntry validation: ${result.validation?.status ?? "not-applicable"}` : ""}\nStore: ${importing ? "imported (not pinned)" : "not imported (--no-import)"}`,
|
|
898
1506
|
);
|
|
899
1507
|
else if (result.kind === "bundle-import")
|
|
900
1508
|
emit(
|
|
901
1509
|
result,
|
|
902
|
-
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}`,
|
|
1510
|
+
`Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`,
|
|
903
1511
|
);
|
|
904
|
-
else if (result.kind === "
|
|
1512
|
+
else if (result.kind === "project-init") {
|
|
905
1513
|
emit(
|
|
906
1514
|
result,
|
|
907
|
-
`Created
|
|
908
|
-
);
|
|
909
|
-
io.err(
|
|
910
|
-
`Next: install declared dependencies in ${JSON.stringify(result.directory)}; then ipab build ${JSON.stringify(result.directory)} (requires locally linked ipab).`,
|
|
911
|
-
);
|
|
912
|
-
} else if ("directory" in result) {
|
|
913
|
-
emit(
|
|
914
|
-
result,
|
|
915
|
-
`Created: ${result.directory}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})`,
|
|
916
|
-
);
|
|
917
|
-
io.err(
|
|
918
|
-
`Next: ipab bundle build ${JSON.stringify(result.directory)}`,
|
|
1515
|
+
`Created project: ${result.directory}${result.templateCid ? `\nTemplate CID: ${result.templateCid}` : ""}`,
|
|
919
1516
|
);
|
|
1517
|
+
if (
|
|
1518
|
+
result.files.includes("package.json") &&
|
|
1519
|
+
(result.files.includes("ipab.yaml") ||
|
|
1520
|
+
result.files.includes("ipab.json"))
|
|
1521
|
+
)
|
|
1522
|
+
io.err(
|
|
1523
|
+
`Next: install declared dependencies and explicitly link the candidate @ipab/cli as a project dependency in ${JSON.stringify(result.directory)}; run pnpm build to prepare and package the App. Root ipab build does not compile.`,
|
|
1524
|
+
);
|
|
1525
|
+
else if (result.files.includes(".bundle.yaml"))
|
|
1526
|
+
io.err(
|
|
1527
|
+
`Next: ipab bundle build ${JSON.stringify(result.directory)}`,
|
|
1528
|
+
);
|
|
920
1529
|
} else
|
|
921
1530
|
emit(
|
|
922
1531
|
result,
|
|
923
|
-
`Kind: ${result.kind}\nName: ${printable(result.name)}\nSchema CID: ${result.schemaCid}\nEntry: ${result.entry.path} (${result.entry.contentType})\
|
|
1532
|
+
`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"}`,
|
|
924
1533
|
);
|
|
925
1534
|
} catch (cause) {
|
|
926
1535
|
if (cancelled)
|
|
@@ -938,58 +1547,52 @@ async function performCli(
|
|
|
938
1547
|
break;
|
|
939
1548
|
}
|
|
940
1549
|
case "pin list": {
|
|
941
|
-
if (typeof parsed.options.type === "string") {
|
|
942
|
-
const named = state.pin(parsed.options.type);
|
|
943
|
-
if (named && pinDetails(named).kind !== "schema")
|
|
944
|
-
throw new HostError(
|
|
945
|
-
"--type short names must identify a Schema pin.",
|
|
946
|
-
);
|
|
947
|
-
}
|
|
948
1550
|
const type =
|
|
949
1551
|
typeof parsed.options.type === "string"
|
|
950
|
-
? state.resolve(
|
|
1552
|
+
? state.resolve(parsed.options.type, true)
|
|
951
1553
|
: undefined;
|
|
952
1554
|
const pins = state.pins();
|
|
953
1555
|
const listed = pins
|
|
954
|
-
.filter(
|
|
1556
|
+
.filter(
|
|
1557
|
+
(pin) => pin.status === "ready" && pin.metadata?.kind === "bundle",
|
|
1558
|
+
)
|
|
955
1559
|
.map(pinDetails)
|
|
1560
|
+
.filter((pin) => type === undefined || pin.schemaCid === type);
|
|
1561
|
+
const invalid = pins
|
|
956
1562
|
.filter(
|
|
957
|
-
(pin) =>
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1563
|
+
(pin) => pin.status === "ready" && pin.metadata?.kind !== "bundle",
|
|
1564
|
+
)
|
|
1565
|
+
.map(({ name, cid, metadata }) => ({
|
|
1566
|
+
name,
|
|
1567
|
+
cid,
|
|
1568
|
+
kind: metadata?.kind,
|
|
1569
|
+
reason:
|
|
1570
|
+
"Not a Bundle pin; retention is preserved. Use pin delete to release it.",
|
|
1571
|
+
}));
|
|
961
1572
|
const pending = pins
|
|
962
1573
|
.filter((pin) => pin.status !== "ready")
|
|
963
1574
|
.map(({ name, cid, status }) => ({ name, cid, status }));
|
|
964
|
-
const legacyAliases = state.aliases();
|
|
965
1575
|
if (pending.length)
|
|
966
1576
|
io.err(
|
|
967
1577
|
`Unfinished pin operations (not usable pins): ${JSON.stringify(pending)}. Retry pin add/delete.`,
|
|
968
1578
|
);
|
|
969
|
-
if (
|
|
1579
|
+
if (invalid.length)
|
|
970
1580
|
io.err(
|
|
971
|
-
|
|
1581
|
+
`Legacy non-Bundle pins (not usable pins): ${JSON.stringify(invalid)}. Retention is unchanged; delete explicitly and wrap content in a Bundle before pinning again.`,
|
|
972
1582
|
);
|
|
973
1583
|
emit(
|
|
974
|
-
{ items: listed, pending,
|
|
1584
|
+
{ items: listed, pending, invalid },
|
|
975
1585
|
table(
|
|
976
1586
|
["NAME", "CID", "KIND", "BUNDLE TYPE", "SOURCE"],
|
|
977
1587
|
listed.map((pin) => [
|
|
978
1588
|
pin.name,
|
|
979
1589
|
pin.cid,
|
|
980
1590
|
pin.kind,
|
|
981
|
-
pin.typeName
|
|
1591
|
+
pin.typeName,
|
|
982
1592
|
pin.builtin ? "built-in (read-only)" : "user",
|
|
983
1593
|
]),
|
|
984
1594
|
"No named pins.",
|
|
985
|
-
)
|
|
986
|
-
(legacyAliases.length
|
|
987
|
-
? `\nLegacy Aliases (not pinned):\n${table(
|
|
988
|
-
["NAME", "CID"],
|
|
989
|
-
legacyAliases.map((alias) => [alias.name, alias.cid]),
|
|
990
|
-
"",
|
|
991
|
-
)}`
|
|
992
|
-
: ""),
|
|
1595
|
+
),
|
|
993
1596
|
);
|
|
994
1597
|
break;
|
|
995
1598
|
}
|
|
@@ -999,11 +1602,11 @@ async function performCli(
|
|
|
999
1602
|
state,
|
|
1000
1603
|
first!,
|
|
1001
1604
|
second!,
|
|
1002
|
-
await storeConfiguration(value("store.
|
|
1605
|
+
await storeConfiguration(value("store.gateway")),
|
|
1003
1606
|
);
|
|
1004
1607
|
emit(
|
|
1005
1608
|
result,
|
|
1006
|
-
`${result.name} → ${result.cid}\
|
|
1609
|
+
`${result.name} → ${result.cid}\nBundle type: ${printable(result.typeName)}`,
|
|
1007
1610
|
);
|
|
1008
1611
|
break;
|
|
1009
1612
|
}
|
|
@@ -1024,7 +1627,7 @@ async function performCli(
|
|
|
1024
1627
|
const result = pinDetails(pin);
|
|
1025
1628
|
emit(
|
|
1026
1629
|
result,
|
|
1027
|
-
`Name: ${printable(result.name)}\nCID: ${result.cid}\
|
|
1630
|
+
`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)"}`,
|
|
1028
1631
|
);
|
|
1029
1632
|
break;
|
|
1030
1633
|
}
|
|
@@ -1068,9 +1671,9 @@ async function performCli(
|
|
|
1068
1671
|
break;
|
|
1069
1672
|
}
|
|
1070
1673
|
case "config get": {
|
|
1071
|
-
const selected =
|
|
1072
|
-
? items.filter((item) => item.key === first)
|
|
1073
|
-
|
|
1674
|
+
const selected = (
|
|
1675
|
+
first ? items.filter((item) => item.key === first) : items
|
|
1676
|
+
).map(visibleConfig);
|
|
1074
1677
|
emit(
|
|
1075
1678
|
{ items: selected },
|
|
1076
1679
|
table(
|
|
@@ -1083,14 +1686,21 @@ async function performCli(
|
|
|
1083
1686
|
}
|
|
1084
1687
|
case "config set": {
|
|
1085
1688
|
const key = configKey(first!);
|
|
1086
|
-
const saved = parseValue(
|
|
1689
|
+
const saved = parseValue(
|
|
1690
|
+
key,
|
|
1691
|
+
key === "pointers.apiKey"
|
|
1692
|
+
? await (io.readSecret ?? processIO.readSecret!)()
|
|
1693
|
+
: second,
|
|
1694
|
+
true,
|
|
1695
|
+
);
|
|
1087
1696
|
state.setConfig(key, saved);
|
|
1088
1697
|
const source = items.find((item) => item.key === key)!.source;
|
|
1089
1698
|
if (source === "env" || source === "flag")
|
|
1090
1699
|
io.err(`Warning: saved user value is masked by ${source}.`);
|
|
1700
|
+
const display = visibleConfig({ key, value: saved, source: "user" });
|
|
1091
1701
|
emit(
|
|
1092
|
-
|
|
1093
|
-
`Saved ${key} = ${printable(String(
|
|
1702
|
+
display,
|
|
1703
|
+
`Saved ${key} = ${printable(String(display.value))} (user).`,
|
|
1094
1704
|
);
|
|
1095
1705
|
break;
|
|
1096
1706
|
}
|
|
@@ -1189,9 +1799,17 @@ async function performCli(
|
|
|
1189
1799
|
throw new HostError(
|
|
1190
1800
|
"Execution logging requires history.enabled=true.",
|
|
1191
1801
|
);
|
|
1192
|
-
const target = state.resolve(first!);
|
|
1193
1802
|
await recoverInactive(state);
|
|
1194
|
-
store = new IpfsStore(await storeConfiguration(value("store.
|
|
1803
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1804
|
+
const target = (
|
|
1805
|
+
await resolveReference(
|
|
1806
|
+
swarmContext(),
|
|
1807
|
+
first!,
|
|
1808
|
+
selectedSwarm,
|
|
1809
|
+
(reference) => state!.resolve(reference),
|
|
1810
|
+
Boolean(parsed.options.raw),
|
|
1811
|
+
)
|
|
1812
|
+
).cid;
|
|
1195
1813
|
let appCid: string;
|
|
1196
1814
|
let appArgv: string[];
|
|
1197
1815
|
if (parsed.path === "open") {
|