@ipab/cli 0.1.0-rc.1 → 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 +21 -5
- package/dist/app-authoring.d.ts +10 -0
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +127 -11
- package/dist/app-authoring.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 +1 -1
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +3 -3
- 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/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +520 -66
- 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 +5 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +105 -7
- 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/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/source-bundle.js +1 -1
- package/dist/source-bundle.js.map +1 -1
- package/dist/state.d.ts +15 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +100 -1
- 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/package.json +10 -5
- package/src/app-authoring.ts +188 -16
- package/src/assembly.ts +182 -0
- package/src/authoring.ts +10 -3
- package/src/cli.ts +641 -68
- package/src/config-secret.ts +96 -0
- package/src/config.ts +142 -7
- package/src/content-provider.ts +123 -0
- package/src/get.ts +68 -0
- package/src/identity.ts +133 -0
- package/src/source-bundle.ts +1 -1
- package/src/state.ts +112 -1
- package/src/swarm.ts +1186 -0
package/dist/cli.js
CHANGED
|
@@ -3,18 +3,22 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { IpfsStore } from "@ipab/ipfs-store";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
import stringWidth from "string-width";
|
|
6
|
-
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, } from "./config.js";
|
|
6
|
+
import { configKey, effectiveConfig, parseValue, publicUrl, stateLocation, storeConfiguration, visibleConfig, } from "./config.js";
|
|
7
7
|
import { HostError, message, object, syntax } from "./errors.js";
|
|
8
8
|
import { filters, listHistory, selectedIds, Ownership, recoverInactive, removeHistory, } from "./history.js";
|
|
9
9
|
import { execute } from "./runtime.js";
|
|
10
10
|
import { validatedBundle } from "./space.js";
|
|
11
11
|
import { exactCid, pinName, State } from "./state.js";
|
|
12
12
|
import { buildBundle, inspectBundle, importBundle } from "./authoring.js";
|
|
13
|
-
import {
|
|
13
|
+
import { initApp } from "./app-authoring.js";
|
|
14
|
+
import { assembleBundle } from "./assembly.js";
|
|
15
|
+
import { getBundle } from "./get.js";
|
|
16
|
+
import { createSwarm, requestMembership, approveMembership, joinSwarm, descriptor, swarmHeader, addSwarm, updateSwarm, searchNames, resolveReference, publish, } from "./swarm.js";
|
|
14
17
|
import { schemaAlias } from "./app-definition.js";
|
|
15
18
|
import { addPin, deletePin, pinDetails, renamePin } from "./pins.js";
|
|
16
19
|
import { logFiles } from "./logs.js";
|
|
17
20
|
import { builtinContent } from "./builtins.js";
|
|
21
|
+
import { readSecretStream } from "./config-secret.js";
|
|
18
22
|
export const processIO = {
|
|
19
23
|
out(text) {
|
|
20
24
|
process.stdout.write(`${text}\n`);
|
|
@@ -26,6 +30,12 @@ export const processIO = {
|
|
|
26
30
|
columns() {
|
|
27
31
|
return process.stdout.columns;
|
|
28
32
|
},
|
|
33
|
+
async readSecret() {
|
|
34
|
+
if (process.stdin.isTTY)
|
|
35
|
+
syntax("Pipe the API key through stdin; interactive echo is not permitted.");
|
|
36
|
+
process.stdin.setEncoding("utf8");
|
|
37
|
+
return readSecretStream(process.stdin);
|
|
38
|
+
},
|
|
29
39
|
async confirm(text) {
|
|
30
40
|
const reader = createInterface({
|
|
31
41
|
input: process.stdin,
|
|
@@ -40,13 +50,26 @@ export const processIO = {
|
|
|
40
50
|
},
|
|
41
51
|
};
|
|
42
52
|
const commands = {
|
|
53
|
+
"swarm create": "swarm create [--service URL] [--resume OPERATION]",
|
|
54
|
+
"swarm request": "swarm request SWARM_CID",
|
|
55
|
+
"swarm approve": "swarm approve REQUEST_CID [--expires-in SECONDS] --yes",
|
|
56
|
+
"swarm join": "swarm join RESPONSE_CID",
|
|
57
|
+
"swarm status": "swarm status [SWARM_CID]",
|
|
58
|
+
"swarm list": "swarm list",
|
|
59
|
+
"swarm add": "swarm add SWARM_CID [--alias ALIAS]",
|
|
60
|
+
"swarm use": "swarm use CID_OR_ALIAS",
|
|
61
|
+
"swarm remove": "swarm remove CID_OR_ALIAS",
|
|
62
|
+
"swarm update": "swarm update [CID_OR_ALIAS] [--name TEXT] [--description TEXT]",
|
|
63
|
+
publish: "publish CID_OR_CAR [--name NAME [--expect OLD_NODE_CID | --snapshot]]",
|
|
64
|
+
get: "get REF [--raw] [--force | --no-force] [-o DIRECTORY]",
|
|
65
|
+
search: "search QUERY [--current] [--force | --no-force]",
|
|
43
66
|
init: "init NAME [DIR] [OPTIONS]",
|
|
44
|
-
build: "build [
|
|
67
|
+
build: "build [SOURCE] [OPTIONS]",
|
|
45
68
|
"bundle build": "bundle build SOURCE [OPTIONS]",
|
|
46
69
|
"bundle inspect": "bundle inspect SOURCE",
|
|
47
70
|
"bundle import": "bundle import FILE.car",
|
|
48
|
-
exec: "exec [--log] APP [APP_ARGS...]",
|
|
49
|
-
open: "open [--log] CONTENT",
|
|
71
|
+
exec: "exec [--log] [--force | --no-force] APP [APP_ARGS...]",
|
|
72
|
+
open: "open [--log] [--raw] [--force | --no-force] CONTENT",
|
|
50
73
|
"pin add": "pin add NAME CID",
|
|
51
74
|
"pin delete": "pin delete NAME",
|
|
52
75
|
"pin list": "pin list [--type TYPE]",
|
|
@@ -56,7 +79,7 @@ const commands = {
|
|
|
56
79
|
"register set": "register set SCHEMA APP [--replace] [-- TEMPLATE...]",
|
|
57
80
|
"register remove": "register remove SCHEMA",
|
|
58
81
|
"config get": "config get [KEY]",
|
|
59
|
-
"config set": "config set KEY VALUE",
|
|
82
|
+
"config set": "config set KEY VALUE\n ipab config set pointers.apiKey - < protected-key-file",
|
|
60
83
|
"config reset": "config reset KEY",
|
|
61
84
|
"store usage": "store usage",
|
|
62
85
|
"store gc": "store gc",
|
|
@@ -65,6 +88,7 @@ const commands = {
|
|
|
65
88
|
"history remove": "history remove RUN_ID... [--yes]\n ipab history remove FILTERS [--yes]",
|
|
66
89
|
};
|
|
67
90
|
const groups = {
|
|
91
|
+
swarm: "Create, authorize, select and manage personal swarms",
|
|
68
92
|
bundle: "Create, inspect and import content bundles",
|
|
69
93
|
pin: "Retain content and manage short names",
|
|
70
94
|
register: "Associate content types with Apps",
|
|
@@ -73,6 +97,156 @@ const groups = {
|
|
|
73
97
|
history: "View and remove execution history",
|
|
74
98
|
};
|
|
75
99
|
const commandHelp = {
|
|
100
|
+
"swarm create": {
|
|
101
|
+
summary: "Create a swarm using the account HOME identity",
|
|
102
|
+
options: [
|
|
103
|
+
"--service URL Must match the protected pointers.service origin.",
|
|
104
|
+
"--resume OPERATION Recover the same saved create/idempotency result.",
|
|
105
|
+
"--name TEXT Initial mutable swarm name.",
|
|
106
|
+
"--description TEXT Initial mutable description.",
|
|
107
|
+
"--alias ALIAS Optional local registry alias (not the shared name).",
|
|
108
|
+
],
|
|
109
|
+
examples: [
|
|
110
|
+
"ipab config set pointers.service https://service.example",
|
|
111
|
+
"ipab config set pointers.apiKey -",
|
|
112
|
+
"ipab swarm create",
|
|
113
|
+
],
|
|
114
|
+
notes: [
|
|
115
|
+
"Creation uses the protected, origin-bound API key and owner possession proof.",
|
|
116
|
+
"Uses the prepared private Kubo provider; never deploys infrastructure.",
|
|
117
|
+
"Returns one descriptor CID; owner needs no member certificate.",
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
"swarm request": {
|
|
121
|
+
summary: "Publish a signed account membership request",
|
|
122
|
+
examples: ["ipab swarm request SWARM_CID"],
|
|
123
|
+
notes: [
|
|
124
|
+
"Returns one request CID. Private IPFS access is a prerequisite, not membership.",
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
"swarm approve": {
|
|
128
|
+
summary: "Owner signs a certificate for an exact request",
|
|
129
|
+
options: [
|
|
130
|
+
"--yes Explicit approval; required outside a TTY.",
|
|
131
|
+
"--expires-in SECONDS 60..2592000; default 604800.",
|
|
132
|
+
],
|
|
133
|
+
examples: ["ipab swarm approve REQUEST_CID --yes"],
|
|
134
|
+
notes: ["Returns one response CID. Never exports the owner private key."],
|
|
135
|
+
},
|
|
136
|
+
"swarm join": {
|
|
137
|
+
summary: "Verify a response and authenticate HEAD",
|
|
138
|
+
examples: ["ipab swarm join RESPONSE_CID"],
|
|
139
|
+
options: ["--alias ALIAS Register this swarm with a local alias."],
|
|
140
|
+
notes: [
|
|
141
|
+
"Requires this account's exact pending request and bound member certificate.",
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
"swarm status": {
|
|
145
|
+
summary: "Authenticate the current swarm HEAD",
|
|
146
|
+
examples: ["ipab swarm status", "ipab swarm status work"],
|
|
147
|
+
notes: [
|
|
148
|
+
"Always authenticate and refresh HEAD; update the local header cache.",
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
"swarm list": {
|
|
152
|
+
summary: "List local swarm registrations and the effective selection",
|
|
153
|
+
examples: ["ipab swarm list", "ipab --json swarm list"],
|
|
154
|
+
notes: ["Local only; does not verify remote membership or refresh HEAD."],
|
|
155
|
+
},
|
|
156
|
+
"swarm add": {
|
|
157
|
+
summary: "Authenticate and register a swarm you already have access to",
|
|
158
|
+
options: [
|
|
159
|
+
"--alias ALIAS Unique local alias; does not rename the shared swarm.",
|
|
160
|
+
],
|
|
161
|
+
examples: ["ipab swarm add SWARM_CID --alias work"],
|
|
162
|
+
notes: [
|
|
163
|
+
"Not a membership grant. The first registration becomes the saved default only if none exists.",
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
"swarm use": {
|
|
167
|
+
summary: "Save a registered swarm as the current default",
|
|
168
|
+
examples: ["ipab swarm use work"],
|
|
169
|
+
notes: ["Local only. --swarm still overrides the saved default."],
|
|
170
|
+
},
|
|
171
|
+
"swarm remove": {
|
|
172
|
+
summary: "Forget a local registration without revoking membership",
|
|
173
|
+
examples: ["ipab swarm remove work"],
|
|
174
|
+
notes: [
|
|
175
|
+
"Preserves credentials, content and remote membership. Clears a matching saved default without selecting a replacement.",
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
"swarm update": {
|
|
179
|
+
summary: "Update shared swarm information as an owner or member",
|
|
180
|
+
arguments: ["CID_OR_ALIAS Defaults to the effective current swarm."],
|
|
181
|
+
options: [
|
|
182
|
+
"--name TEXT Replace the shared display name; empty text clears it.",
|
|
183
|
+
"--description TEXT Replace the shared description; empty text clears it.",
|
|
184
|
+
],
|
|
185
|
+
examples: [
|
|
186
|
+
'ipab swarm update work --name "Team" --description "Shared workspace"',
|
|
187
|
+
'ipab swarm update --description ""',
|
|
188
|
+
],
|
|
189
|
+
notes: [
|
|
190
|
+
"Requires at least one field. Any authorized member can update both fields.",
|
|
191
|
+
"Last successful write wins for the specified fields; no expected-value/version input.",
|
|
192
|
+
"Automatically retries HEAD contention while preserving current Names and unspecified properties.",
|
|
193
|
+
"Shared name changes do not rename local registry aliases.",
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
search: {
|
|
197
|
+
summary: "Search formal Names across registered swarms",
|
|
198
|
+
arguments: [
|
|
199
|
+
"QUERY Case-insensitive literal name substring, 1..256 characters.",
|
|
200
|
+
],
|
|
201
|
+
options: [
|
|
202
|
+
"--current Search only the effective current swarm; conflicts with --swarm.",
|
|
203
|
+
"--force Refresh HEAD for every swarm in the search scope.",
|
|
204
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
205
|
+
],
|
|
206
|
+
examples: ["ipab search hello", "ipab --swarm work search hello --force"],
|
|
207
|
+
notes: [
|
|
208
|
+
"Searches all registered swarms unless --current or --swarm selects one.",
|
|
209
|
+
"Valid caches use local Names only; absent/expired caches refresh. No payload downloads.",
|
|
210
|
+
"No matches is success, not a reason to refresh valid caches. Any failed swarm fails the whole search.",
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
publish: {
|
|
214
|
+
summary: "Provide built content and explicitly publish a Name",
|
|
215
|
+
options: [
|
|
216
|
+
"--name NAME New formal Name; occupied Names fail.",
|
|
217
|
+
"--expect CID Exact old Artifact node, required for iteration.",
|
|
218
|
+
"--snapshot Name ordinary content without an Artifact; initial only.",
|
|
219
|
+
],
|
|
220
|
+
examples: [
|
|
221
|
+
"ipab publish app.car --name apps/hello",
|
|
222
|
+
"ipab publish APP_CID --name apps/hello --expect OLD_NODE_CID",
|
|
223
|
+
"ipab publish CONTENT_CID",
|
|
224
|
+
],
|
|
225
|
+
notes: [
|
|
226
|
+
"No build, edit, install or execution. CID-only stdout.",
|
|
227
|
+
"Different-name CAS contention is rebased; same-name edits conflict (exit 3).",
|
|
228
|
+
"Kubo pin confirmation precedes HEAD; it does not prove a remote device is online.",
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
get: {
|
|
232
|
+
summary: "Verify and unpack Bundle content without executing it",
|
|
233
|
+
options: [
|
|
234
|
+
"--raw Select the Artifact node instead of its value.",
|
|
235
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
236
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
237
|
+
"-o, --output DIRECTORY New or empty directory; defaults to resolved CID.",
|
|
238
|
+
],
|
|
239
|
+
examples: [
|
|
240
|
+
"ipab --json get ipab:///apps/hello -o hello-app",
|
|
241
|
+
"ipab get ipab://work/apps/hello -o hello-app",
|
|
242
|
+
"ipab get --raw RELEASE_CID",
|
|
243
|
+
],
|
|
244
|
+
notes: [
|
|
245
|
+
"Returns the selected content CID and original target CID (editing baseline).",
|
|
246
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
247
|
+
"Does not install, build, edit, or automatically retrieve associated source.",
|
|
248
|
+
],
|
|
249
|
+
},
|
|
76
250
|
"store usage": {
|
|
77
251
|
summary: "Query cached and recursively pinned block bytes",
|
|
78
252
|
examples: ["ipab store usage", "ipab --json store usage"],
|
|
@@ -105,21 +279,24 @@ const commandHelp = {
|
|
|
105
279
|
notes: ["Does not install dependencies or execute template code."],
|
|
106
280
|
},
|
|
107
281
|
build: {
|
|
108
|
-
summary: "
|
|
109
|
-
arguments: [
|
|
282
|
+
summary: "Assemble any Bundle using ipab.build.yaml (no compilation)",
|
|
283
|
+
arguments: [
|
|
284
|
+
"SOURCE Recipe file or Bundle directory (default: current directory).",
|
|
285
|
+
],
|
|
110
286
|
options: [
|
|
111
|
-
"-o, --output FILE Destination (default: dist/
|
|
287
|
+
"-o, --output FILE Destination (default: dist/bundle.car).",
|
|
112
288
|
"--replace Allow replacing existing regular artifacts.",
|
|
113
|
-
"--no-import Write CAR
|
|
114
|
-
|
|
115
|
-
|
|
289
|
+
"--no-import Write the CAR without importing the Bundle into Store.",
|
|
290
|
+
],
|
|
291
|
+
examples: [
|
|
292
|
+
"ipab build prepared-app",
|
|
293
|
+
"ipab build ipab.build.yaml --replace",
|
|
116
294
|
],
|
|
117
|
-
examples: ["ipab build", "ipab build hello --replace --without-source"],
|
|
118
295
|
notes: [
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
296
|
+
"Recipe explicitly maps source files and exact CID imports to target paths.",
|
|
297
|
+
"Type and entry come from .bundle.yaml; imported DAG identities are preserved.",
|
|
298
|
+
"Legacy App ipab.yaml is rejected; use project preparation tools separately.",
|
|
299
|
+
"Select explicit files; review private files before providing Bundles.",
|
|
123
300
|
"Store failures preserve the CAR; retry with ipab bundle import FILE.car.",
|
|
124
301
|
],
|
|
125
302
|
},
|
|
@@ -157,20 +334,23 @@ const commandHelp = {
|
|
|
157
334
|
],
|
|
158
335
|
},
|
|
159
336
|
exec: {
|
|
160
|
-
summary: "Run an App by CID or
|
|
337
|
+
summary: "Run an App by CID, named pin or IPAB URI",
|
|
161
338
|
arguments: [
|
|
162
339
|
"APP_ARGS Everything after APP is passed verbatim, including --help.",
|
|
163
340
|
],
|
|
164
341
|
options: [
|
|
165
342
|
"--log Record stdout/stderr; must precede APP. Requires history enabled.",
|
|
343
|
+
"--force Refresh the shared Name's swarm HEAD; must precede APP.",
|
|
344
|
+
"--no-force Override swarm.forceRefresh; must precede APP.",
|
|
166
345
|
],
|
|
167
346
|
examples: [
|
|
168
347
|
"ipab exec reader",
|
|
169
|
-
"ipab exec reader --help",
|
|
170
348
|
"ipab exec --log reader",
|
|
349
|
+
"ipab exec ipab://work/apps/hello --help",
|
|
171
350
|
],
|
|
172
351
|
notes: [
|
|
173
352
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
353
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
174
354
|
"History stores argv by default; do not put secrets in arguments.",
|
|
175
355
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
176
356
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -178,11 +358,21 @@ const commandHelp = {
|
|
|
178
358
|
},
|
|
179
359
|
open: {
|
|
180
360
|
summary: "Open content with its registered App",
|
|
181
|
-
arguments: ["CONTENT Bundle CID or
|
|
182
|
-
options: [
|
|
183
|
-
|
|
361
|
+
arguments: ["CONTENT Bundle CID, named pin or IPAB URI."],
|
|
362
|
+
options: [
|
|
363
|
+
"--log Record stdout/stderr; requires history enabled.",
|
|
364
|
+
"--raw Open the Artifact node rather than its value.",
|
|
365
|
+
"--force Refresh the shared Name's swarm HEAD.",
|
|
366
|
+
"--no-force Override swarm.forceRefresh and use valid cached headers.",
|
|
367
|
+
],
|
|
368
|
+
examples: [
|
|
369
|
+
"ipab open CONTENT_CID",
|
|
370
|
+
"ipab open --log my-note",
|
|
371
|
+
"ipab open ipab:///documents/readme",
|
|
372
|
+
],
|
|
184
373
|
notes: [
|
|
185
374
|
"Requires a saved registration and App support for the exact content type.",
|
|
375
|
+
"ipab://SWARM_CID_OR_ALIAS/PATH selects its own swarm; ipab:///PATH uses --swarm or swarm.default.",
|
|
186
376
|
"Apps are NOT sandboxed; run only Apps you trust.",
|
|
187
377
|
"Logs may contain secrets; stdin is never logged. Logging makes output non-TTY.",
|
|
188
378
|
"--json is not supported; App stdio is passed through.",
|
|
@@ -271,11 +461,15 @@ const commandHelp = {
|
|
|
271
461
|
"config set": {
|
|
272
462
|
summary: "Save a local configuration value",
|
|
273
463
|
examples: [
|
|
464
|
+
"ipab config set pointers.apiKey -",
|
|
274
465
|
"ipab config set store.gateway http://127.0.0.1:8080",
|
|
275
466
|
"ipab config set history.enabled false",
|
|
276
467
|
],
|
|
277
468
|
notes: [
|
|
278
469
|
"store.gateway is a read-only HTTP gateway; blocks, pins and GC remain local.",
|
|
470
|
+
"pointers.service is a canonical HTTPS origin (HTTP loopback allowed).",
|
|
471
|
+
"pointers.apiKey is accepted only through stdin using VALUE '-'; queries and confirmations redact it.",
|
|
472
|
+
"Saving pointers.apiKey protects state SQLite files with account-only Unix modes or Windows ACLs.",
|
|
279
473
|
],
|
|
280
474
|
},
|
|
281
475
|
"config reset": {
|
|
@@ -327,6 +521,7 @@ const commandHelp = {
|
|
|
327
521
|
};
|
|
328
522
|
export function help(path = "") {
|
|
329
523
|
const globalOptions = `Global options (before COMMAND):
|
|
524
|
+
--swarm CID|ALIAS Select shared swarm (otherwise swarm.default; URI swarm takes precedence)
|
|
330
525
|
--state-dir PATH Set the local state directory
|
|
331
526
|
--store-gateway URL Use a read-only upstream HTTP gateway
|
|
332
527
|
--json Output management/development metadata, not App stdio`;
|
|
@@ -346,6 +541,10 @@ Create:
|
|
|
346
541
|
bundle ${groups.bundle}
|
|
347
542
|
|
|
348
543
|
Manage:
|
|
544
|
+
swarm ${groups.swarm}
|
|
545
|
+
search Search formal Names across registered swarms
|
|
546
|
+
publish ${commandHelp.publish.summary}
|
|
547
|
+
get ${commandHelp.get.summary}
|
|
349
548
|
pin ${groups.pin}
|
|
350
549
|
register ${groups.register}
|
|
351
550
|
config ${groups.config}
|
|
@@ -512,12 +711,16 @@ export function parse(argv) {
|
|
|
512
711
|
flags.json = true;
|
|
513
712
|
else if (flag === "--store-rpc")
|
|
514
713
|
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" ||
|
|
714
|
+
else if (flag === "--state-dir" ||
|
|
715
|
+
flag === "--store-gateway" ||
|
|
716
|
+
flag === "--swarm") {
|
|
516
717
|
const value = tokens.shift();
|
|
517
718
|
if (!value || value.startsWith("-"))
|
|
518
719
|
syntax(`${flag} needs a value.`);
|
|
519
720
|
if (flag === "--state-dir")
|
|
520
721
|
flags.stateDir = value;
|
|
722
|
+
else if (flag === "--swarm")
|
|
723
|
+
flags.swarm = value;
|
|
521
724
|
else {
|
|
522
725
|
flags.storeGateway = publicUrl(value);
|
|
523
726
|
}
|
|
@@ -539,10 +742,14 @@ export function parse(argv) {
|
|
|
539
742
|
if (group === "exec") {
|
|
540
743
|
if (flags.json)
|
|
541
744
|
syntax("--json is not supported for exec/open.");
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
745
|
+
while (["--log", "--force", "--no-force"].includes(tokens[0] ?? "")) {
|
|
746
|
+
const option = tokens.shift().slice(2);
|
|
747
|
+
if (Object.hasOwn(result.options, option))
|
|
748
|
+
syntax(`Duplicate option --${option}.`);
|
|
749
|
+
result.options[option] = true;
|
|
545
750
|
}
|
|
751
|
+
if (result.options.force && result.options["no-force"])
|
|
752
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
546
753
|
if (tokens[0] === "-h" || tokens[0] === "--help") {
|
|
547
754
|
result.help = true;
|
|
548
755
|
return result;
|
|
@@ -552,8 +759,16 @@ export function parse(argv) {
|
|
|
552
759
|
result.positional = tokens;
|
|
553
760
|
return result;
|
|
554
761
|
}
|
|
555
|
-
if (!["open", "init", "build"].includes(group)) {
|
|
556
|
-
if (![
|
|
762
|
+
if (!["open", "init", "build", "publish", "get", "search"].includes(group)) {
|
|
763
|
+
if (![
|
|
764
|
+
"bundle",
|
|
765
|
+
"pin",
|
|
766
|
+
"register",
|
|
767
|
+
"config",
|
|
768
|
+
"history",
|
|
769
|
+
"store",
|
|
770
|
+
"swarm",
|
|
771
|
+
].includes(group))
|
|
557
772
|
syntax(`Unknown command "${group}".`);
|
|
558
773
|
if (!tokens.length || tokens[0] === "-h" || tokens[0] === "--help") {
|
|
559
774
|
result.help = true;
|
|
@@ -574,28 +789,52 @@ export function parse(argv) {
|
|
|
574
789
|
result.help = true;
|
|
575
790
|
return result;
|
|
576
791
|
}
|
|
792
|
+
if (result.path === "config set" &&
|
|
793
|
+
tokens.includes("pointers.apiKey") &&
|
|
794
|
+
!(tokens.length === 2 && tokens[1] === "-"))
|
|
795
|
+
syntax("API key must be provided through '-' and piped stdin; never pass it in command arguments.");
|
|
577
796
|
const booleans = result.path === "bundle build"
|
|
578
797
|
? ["replace", "schema-only", "no-import"]
|
|
579
798
|
: result.path === "build"
|
|
580
|
-
? ["replace", "no-import"
|
|
581
|
-
: result.path === "
|
|
582
|
-
? ["
|
|
583
|
-
: result.path === "
|
|
584
|
-
? ["
|
|
585
|
-
: result.path === "
|
|
586
|
-
? ["
|
|
587
|
-
:
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
799
|
+
? ["replace", "no-import"]
|
|
800
|
+
: result.path === "publish"
|
|
801
|
+
? ["snapshot"]
|
|
802
|
+
: result.path === "get"
|
|
803
|
+
? ["raw", "force", "no-force"]
|
|
804
|
+
: result.path === "search"
|
|
805
|
+
? ["current", "force", "no-force"]
|
|
806
|
+
: result.path === "swarm approve"
|
|
807
|
+
? ["yes"]
|
|
808
|
+
: result.path === "register set"
|
|
809
|
+
? ["replace"]
|
|
810
|
+
: result.path === "history remove"
|
|
811
|
+
? ["yes"]
|
|
812
|
+
: result.path === "open"
|
|
813
|
+
? ["log", "raw", "force", "no-force"]
|
|
814
|
+
: [];
|
|
815
|
+
const values = result.path === "swarm create"
|
|
816
|
+
? ["service", "resume", "name", "description", "alias"]
|
|
817
|
+
: result.path === "swarm add" || result.path === "swarm join"
|
|
818
|
+
? ["alias"]
|
|
819
|
+
: result.path === "swarm update"
|
|
820
|
+
? ["name", "description"]
|
|
821
|
+
: result.path === "swarm approve"
|
|
822
|
+
? ["expires-in"]
|
|
823
|
+
: result.path === "publish"
|
|
824
|
+
? ["name", "expect"]
|
|
825
|
+
: result.path === "get"
|
|
826
|
+
? ["output"]
|
|
827
|
+
: result.path === "init"
|
|
828
|
+
? ["template"]
|
|
829
|
+
: result.path === "bundle build" || result.path === "build"
|
|
830
|
+
? ["output"]
|
|
831
|
+
: result.path === "history list"
|
|
832
|
+
? ["app", "status", "since", "until", "limit", "before"]
|
|
833
|
+
: result.path === "history remove"
|
|
834
|
+
? ["app", "status", "since", "until"]
|
|
835
|
+
: result.path === "pin list"
|
|
836
|
+
? ["type"]
|
|
837
|
+
: [];
|
|
599
838
|
while (tokens.length) {
|
|
600
839
|
const value = tokens.shift();
|
|
601
840
|
if (value.startsWith("--") || value === "-o") {
|
|
@@ -613,7 +852,9 @@ export function parse(argv) {
|
|
|
613
852
|
result.options[option] = true;
|
|
614
853
|
else if (values.includes(option)) {
|
|
615
854
|
const input = tokens.shift();
|
|
616
|
-
if (
|
|
855
|
+
if (input === undefined ||
|
|
856
|
+
input.startsWith("--") ||
|
|
857
|
+
(input === "" && result.path !== "swarm update"))
|
|
617
858
|
syntax(`${value} needs a value.`);
|
|
618
859
|
result.options[option] = input;
|
|
619
860
|
}
|
|
@@ -623,7 +864,26 @@ export function parse(argv) {
|
|
|
623
864
|
else
|
|
624
865
|
result.positional.push(value);
|
|
625
866
|
}
|
|
867
|
+
if (result.options.force && result.options["no-force"])
|
|
868
|
+
syntax("--force and --no-force are mutually exclusive.");
|
|
869
|
+
if (result.path === "search" &&
|
|
870
|
+
result.options.current &&
|
|
871
|
+
flags.swarm !== undefined)
|
|
872
|
+
syntax("--current and --swarm are mutually exclusive.");
|
|
626
873
|
const counts = {
|
|
874
|
+
"swarm create": [0, 0],
|
|
875
|
+
"swarm request": [1, 1],
|
|
876
|
+
"swarm approve": [1, 1],
|
|
877
|
+
"swarm join": [1, 1],
|
|
878
|
+
"swarm status": [0, 1],
|
|
879
|
+
"swarm list": [0, 0],
|
|
880
|
+
"swarm add": [1, 1],
|
|
881
|
+
"swarm use": [1, 1],
|
|
882
|
+
"swarm remove": [1, 1],
|
|
883
|
+
"swarm update": [0, 1],
|
|
884
|
+
publish: [1, 1],
|
|
885
|
+
get: [1, 1],
|
|
886
|
+
search: [1, 1],
|
|
627
887
|
init: [1, 2],
|
|
628
888
|
build: [0, 1],
|
|
629
889
|
"bundle build": [1, 1],
|
|
@@ -673,8 +933,14 @@ export function parse(argv) {
|
|
|
673
933
|
if (!(result.path === "config get" && result.positional[0] === "state-dir") &&
|
|
674
934
|
!(result.path === "config reset" && result.positional[0] === "store.rpc"))
|
|
675
935
|
configKey(result.positional[0]);
|
|
676
|
-
if (result.path === "config set")
|
|
677
|
-
|
|
936
|
+
if (result.path === "config set") {
|
|
937
|
+
if (result.positional[0] === "pointers.apiKey") {
|
|
938
|
+
if (result.positional[1] !== "-")
|
|
939
|
+
syntax("Set pointers.apiKey using '-' and piped stdin; never put the key in command-line arguments.");
|
|
940
|
+
}
|
|
941
|
+
else
|
|
942
|
+
parseValue(configKey(result.positional[0]), result.positional[1], true);
|
|
943
|
+
}
|
|
678
944
|
}
|
|
679
945
|
if (typeof result.options.limit === "string")
|
|
680
946
|
parseValue("history.limit", result.options.limit, true);
|
|
@@ -711,16 +977,208 @@ async function performCli(argv, io, env) {
|
|
|
711
977
|
: "Removed legacy store.rpc configuration. Existing Kubo pins and content are unchanged.");
|
|
712
978
|
return 0;
|
|
713
979
|
}
|
|
714
|
-
const items = effectiveConfig(state.config(), parsed.flags, env);
|
|
980
|
+
const items = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference));
|
|
715
981
|
const value = (key) => items.find((item) => item.key === key).value;
|
|
716
982
|
const emit = (result, human) => {
|
|
717
983
|
io.out(parsed.flags.json ? JSON.stringify(result) : human);
|
|
718
984
|
};
|
|
719
985
|
const [first, second] = parsed.positional;
|
|
986
|
+
const selectedSwarm = value("swarm.default") === null
|
|
987
|
+
? undefined
|
|
988
|
+
: String(value("swarm.default"));
|
|
989
|
+
const swarmContext = () => ({
|
|
990
|
+
store: store,
|
|
991
|
+
state: state,
|
|
992
|
+
env,
|
|
993
|
+
stateDir: stateLocation(parsed.flags, env).path,
|
|
994
|
+
provider: String(value("swarm.provider") ?? "http://127.0.0.1:5001"),
|
|
995
|
+
cacheTtl: Number(value("swarm.cacheTtl")),
|
|
996
|
+
forceRefresh: parsed.options.force
|
|
997
|
+
? true
|
|
998
|
+
: parsed.options["no-force"]
|
|
999
|
+
? false
|
|
1000
|
+
: Boolean(value("swarm.forceRefresh")),
|
|
1001
|
+
diagnostic: (text) => {
|
|
1002
|
+
io.err(text);
|
|
1003
|
+
},
|
|
1004
|
+
...(typeof value("pointers.service") === "string"
|
|
1005
|
+
? { pointerService: String(value("pointers.service")) }
|
|
1006
|
+
: {}),
|
|
1007
|
+
...(typeof value("pointers.apiKey") === "string"
|
|
1008
|
+
? { pointerApiKey: String(value("pointers.apiKey")) }
|
|
1009
|
+
: {}),
|
|
1010
|
+
});
|
|
720
1011
|
const filter = parsed.path.startsWith("history ")
|
|
721
1012
|
? filters(state, parsed.options)
|
|
722
1013
|
: {};
|
|
1014
|
+
const selection = () => {
|
|
1015
|
+
const current = effectiveConfig(state.config(), parsed.flags, env, (reference) => state.resolveSwarm(reference)).find((item) => item.key === "swarm.default");
|
|
1016
|
+
return {
|
|
1017
|
+
savedCurrent: state.config()["swarm.default"] ?? null,
|
|
1018
|
+
effectiveCurrent: current.value,
|
|
1019
|
+
source: current.source,
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
723
1022
|
switch (parsed.path) {
|
|
1023
|
+
case "swarm list": {
|
|
1024
|
+
const result = { swarms: state.swarms(), ...selection() };
|
|
1025
|
+
emit(result, [
|
|
1026
|
+
...result.swarms.map((entry) => `${entry.cid === result.savedCurrent ? "*" : " "} ${printable(entry.alias ?? entry.cid)} ${entry.cid}`),
|
|
1027
|
+
`Saved current: ${result.savedCurrent ?? "(none)"}`,
|
|
1028
|
+
`Effective current: ${result.effectiveCurrent ?? "(none)"} (${result.source})`,
|
|
1029
|
+
].join("\n"));
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
case "swarm use": {
|
|
1033
|
+
state.useSwarm(first);
|
|
1034
|
+
const result = selection();
|
|
1035
|
+
emit(result, `Saved current swarm: ${result.savedCurrent}`);
|
|
1036
|
+
if (result.source === "flag" || result.source === "env")
|
|
1037
|
+
io.err(`The saved default is overridden by ${result.source}: ${result.effectiveCurrent}.`);
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
case "swarm remove": {
|
|
1041
|
+
const removed = state.removeSwarm(first);
|
|
1042
|
+
emit({ removed, savedCurrent: state.config()["swarm.default"] ?? null }, `Removed registration ${removed}. Credentials, content and remote membership are unchanged.`);
|
|
1043
|
+
break;
|
|
1044
|
+
}
|
|
1045
|
+
case "swarm add":
|
|
1046
|
+
case "swarm update":
|
|
1047
|
+
case "search":
|
|
1048
|
+
case "swarm create":
|
|
1049
|
+
case "swarm request":
|
|
1050
|
+
case "swarm approve":
|
|
1051
|
+
case "swarm join":
|
|
1052
|
+
case "swarm status":
|
|
1053
|
+
case "publish":
|
|
1054
|
+
case "get": {
|
|
1055
|
+
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1056
|
+
const context = swarmContext();
|
|
1057
|
+
if (parsed.path === "swarm update") {
|
|
1058
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1059
|
+
if (!cid)
|
|
1060
|
+
syntax("swarm update requires a registered alias, Swarm CID or current swarm.");
|
|
1061
|
+
const result = await updateSwarm(context, cid, {
|
|
1062
|
+
...(typeof parsed.options.name === "string"
|
|
1063
|
+
? { name: parsed.options.name }
|
|
1064
|
+
: {}),
|
|
1065
|
+
...(typeof parsed.options.description === "string"
|
|
1066
|
+
? { description: parsed.options.description }
|
|
1067
|
+
: {}),
|
|
1068
|
+
});
|
|
1069
|
+
emit(result, `Swarm: ${result.cid}\nName: ${printable(result.properties.name)}\nDescription: ${printable(result.properties.description)}\nHEAD: ${result.root}\nRevision: ${result.revision}`);
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
if (parsed.path === "swarm add") {
|
|
1073
|
+
const cid = exactCid(first);
|
|
1074
|
+
await addSwarm(context, cid, typeof parsed.options.alias === "string"
|
|
1075
|
+
? parsed.options.alias
|
|
1076
|
+
: undefined);
|
|
1077
|
+
const entry = state.registeredSwarm(cid);
|
|
1078
|
+
emit({ ...entry, savedCurrent: state.config()["swarm.default"] ?? null }, `Registered swarm ${entry.alias ?? cid} (${cid}).`);
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
if (parsed.path === "search") {
|
|
1082
|
+
const source = items.find((item) => item.key === "swarm.default").source;
|
|
1083
|
+
const limited = parsed.options.current || source === "flag";
|
|
1084
|
+
if (limited && !selectedSwarm)
|
|
1085
|
+
syntax("Search of the current swarm requires --swarm or swarm.default.");
|
|
1086
|
+
const registrations = state.swarms();
|
|
1087
|
+
const scope = limited
|
|
1088
|
+
? [
|
|
1089
|
+
{
|
|
1090
|
+
cid: selectedSwarm,
|
|
1091
|
+
alias: registrations.find((entry) => entry.cid === selectedSwarm)
|
|
1092
|
+
?.alias ?? null,
|
|
1093
|
+
},
|
|
1094
|
+
]
|
|
1095
|
+
: registrations;
|
|
1096
|
+
const result = await searchNames(context, first, scope);
|
|
1097
|
+
emit(result, result.matches.length
|
|
1098
|
+
? result.matches
|
|
1099
|
+
.map((match) => `${printable(match.alias ?? match.swarm)} ${printable(match.name)} ${match.targetCid}\n ipab get ${printable(match.reference)}`)
|
|
1100
|
+
.join("\n")
|
|
1101
|
+
: "No matching Names.");
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
if (parsed.path === "swarm status") {
|
|
1105
|
+
const cid = first ? state.resolveSwarm(first) : selectedSwarm;
|
|
1106
|
+
if (!cid)
|
|
1107
|
+
syntax("swarm status requires a Swarm CID or swarm.default.");
|
|
1108
|
+
const data = await descriptor(store, cid);
|
|
1109
|
+
const { head, snapshot } = await swarmHeader(context, cid, true);
|
|
1110
|
+
emit({
|
|
1111
|
+
cid,
|
|
1112
|
+
...data,
|
|
1113
|
+
root: head.root,
|
|
1114
|
+
revision: head.revision,
|
|
1115
|
+
properties: snapshot.properties,
|
|
1116
|
+
}, `Swarm: ${cid}\nName: ${printable(snapshot.properties.name)}\nDescription: ${printable(snapshot.properties.description)}\nHEAD: ${head.root}\nRevision: ${head.revision}`);
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
if (parsed.path === "get") {
|
|
1120
|
+
const selected = await resolveReference(context, first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw));
|
|
1121
|
+
const directory = await getBundle(store, selected.cid, typeof parsed.options.output === "string"
|
|
1122
|
+
? parsed.options.output
|
|
1123
|
+
: undefined);
|
|
1124
|
+
emit({ ...selected, directory }, `CID: ${selected.cid}\nTarget CID: ${selected.targetCid}\nDirectory: ${directory}`);
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
let cid;
|
|
1128
|
+
if (parsed.path === "swarm create") {
|
|
1129
|
+
cid = await createSwarm(context, {
|
|
1130
|
+
...(typeof parsed.options.service === "string"
|
|
1131
|
+
? { service: parsed.options.service }
|
|
1132
|
+
: {}),
|
|
1133
|
+
...(typeof parsed.options.resume === "string"
|
|
1134
|
+
? { resume: parsed.options.resume }
|
|
1135
|
+
: {}),
|
|
1136
|
+
properties: {
|
|
1137
|
+
name: String(parsed.options.name ?? ""),
|
|
1138
|
+
description: String(parsed.options.description ?? ""),
|
|
1139
|
+
},
|
|
1140
|
+
...(typeof parsed.options.alias === "string"
|
|
1141
|
+
? { alias: parsed.options.alias }
|
|
1142
|
+
: {}),
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
else if (parsed.path === "swarm request")
|
|
1146
|
+
cid = await requestMembership(context, exactCid(first));
|
|
1147
|
+
else if (parsed.path === "swarm approve") {
|
|
1148
|
+
if (!parsed.options.yes &&
|
|
1149
|
+
(!io.tty ||
|
|
1150
|
+
!(await io.confirm(`Approve membership request ${first}? This grants swarm HEAD read/write access.`))))
|
|
1151
|
+
throw new HostError("Approval requires explicit --yes or interactive confirmation.");
|
|
1152
|
+
cid = await approveMembership(context, exactCid(first), parsed.options["expires-in"] === undefined
|
|
1153
|
+
? undefined
|
|
1154
|
+
: Number(parsed.options["expires-in"]));
|
|
1155
|
+
}
|
|
1156
|
+
else if (parsed.path === "swarm join")
|
|
1157
|
+
cid = await joinSwarm(context, exactCid(first), typeof parsed.options.alias === "string"
|
|
1158
|
+
? parsed.options.alias
|
|
1159
|
+
: undefined);
|
|
1160
|
+
else {
|
|
1161
|
+
let content;
|
|
1162
|
+
if (first.toLowerCase().endsWith(".car"))
|
|
1163
|
+
content = (await importBundle(first, () => Promise.resolve(store))).cid;
|
|
1164
|
+
else
|
|
1165
|
+
content = exactCid(first);
|
|
1166
|
+
cid = await publish(context, content, {
|
|
1167
|
+
...(selectedSwarm ? { swarm: selectedSwarm } : {}),
|
|
1168
|
+
...(typeof parsed.options.name === "string"
|
|
1169
|
+
? { name: parsed.options.name }
|
|
1170
|
+
: {}),
|
|
1171
|
+
...(typeof parsed.options.expect === "string"
|
|
1172
|
+
? { expect: parsed.options.expect }
|
|
1173
|
+
: {}),
|
|
1174
|
+
snapshot: Boolean(parsed.options.snapshot),
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
if (parsed.path === "swarm create" || parsed.path === "swarm join")
|
|
1178
|
+
io.err(`Registered swarm ${state.registeredSwarm(cid).alias ?? cid}. Saved current: ${state.config()["swarm.default"] ?? "(none)"}.`);
|
|
1179
|
+
emit({ cid }, cid);
|
|
1180
|
+
break;
|
|
1181
|
+
}
|
|
724
1182
|
case "store usage":
|
|
725
1183
|
case "store gc": {
|
|
726
1184
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
@@ -779,7 +1237,7 @@ async function performCli(argv, io, env) {
|
|
|
779
1237
|
: first;
|
|
780
1238
|
if (parsed.path === "bundle build" || parsed.path === "build")
|
|
781
1239
|
io.err(parsed.path === "build"
|
|
782
|
-
? "
|
|
1240
|
+
? "Assembling and validating Bundle (no compilation)..."
|
|
783
1241
|
: "Validating and building bundle...");
|
|
784
1242
|
if (parsed.path === "bundle import")
|
|
785
1243
|
io.err("Validating and importing CAR into Store...");
|
|
@@ -800,14 +1258,9 @@ async function performCli(argv, io, env) {
|
|
|
800
1258
|
: {}),
|
|
801
1259
|
})
|
|
802
1260
|
: parsed.path === "build"
|
|
803
|
-
? await
|
|
1261
|
+
? await assembleBundle(first, {
|
|
804
1262
|
...request,
|
|
805
1263
|
replace: Boolean(parsed.options.replace),
|
|
806
|
-
...(parsed.options["with-source"]
|
|
807
|
-
? { includeSource: true }
|
|
808
|
-
: parsed.options["without-source"]
|
|
809
|
-
? { includeSource: false }
|
|
810
|
-
: {}),
|
|
811
1264
|
...(typeof parsed.options.output === "string"
|
|
812
1265
|
? { output: parsed.options.output }
|
|
813
1266
|
: {}),
|
|
@@ -843,7 +1296,7 @@ async function performCli(argv, io, env) {
|
|
|
843
1296
|
state = undefined;
|
|
844
1297
|
controller.signal.throwIfAborted();
|
|
845
1298
|
if ("output" in result)
|
|
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"}` : ""}
|
|
1299
|
+
emit({ ...result, imported: importing }, `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)"}`);
|
|
847
1300
|
else if (result.kind === "bundle-import")
|
|
848
1301
|
emit(result, `Imported CID: ${result.cid}\nSchema CID: ${result.schemaCid}\nBlocks: ${result.blocks}\nCAR: ${result.source}\nEntry validation: ${result.validation?.status ?? "not-applicable"}`);
|
|
849
1302
|
else if (result.kind === "project-init") {
|
|
@@ -851,7 +1304,7 @@ async function performCli(argv, io, env) {
|
|
|
851
1304
|
if (result.files.includes("package.json") &&
|
|
852
1305
|
(result.files.includes("ipab.yaml") ||
|
|
853
1306
|
result.files.includes("ipab.json")))
|
|
854
|
-
io.err(`Next: install declared dependencies in ${JSON.stringify(result.directory)};
|
|
1307
|
+
io.err(`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.`);
|
|
855
1308
|
else if (result.files.includes(".bundle.yaml"))
|
|
856
1309
|
io.err(`Next: ipab bundle build ${JSON.stringify(result.directory)}`);
|
|
857
1310
|
}
|
|
@@ -946,20 +1399,21 @@ async function performCli(argv, io, env) {
|
|
|
946
1399
|
break;
|
|
947
1400
|
}
|
|
948
1401
|
case "config get": {
|
|
949
|
-
const selected = first
|
|
950
|
-
? items.filter((item) => item.key === first)
|
|
951
|
-
: items;
|
|
1402
|
+
const selected = (first ? items.filter((item) => item.key === first) : items).map(visibleConfig);
|
|
952
1403
|
emit({ items: selected }, table(["KEY", "VALUE", "SOURCE"], selected.map((item) => [item.key, String(item.value), item.source]), "No configuration values."));
|
|
953
1404
|
break;
|
|
954
1405
|
}
|
|
955
1406
|
case "config set": {
|
|
956
1407
|
const key = configKey(first);
|
|
957
|
-
const saved = parseValue(key,
|
|
1408
|
+
const saved = parseValue(key, key === "pointers.apiKey"
|
|
1409
|
+
? await (io.readSecret ?? processIO.readSecret)()
|
|
1410
|
+
: second, true);
|
|
958
1411
|
state.setConfig(key, saved);
|
|
959
1412
|
const source = items.find((item) => item.key === key).source;
|
|
960
1413
|
if (source === "env" || source === "flag")
|
|
961
1414
|
io.err(`Warning: saved user value is masked by ${source}.`);
|
|
962
|
-
|
|
1415
|
+
const display = visibleConfig({ key, value: saved, source: "user" });
|
|
1416
|
+
emit(display, `Saved ${key} = ${printable(String(display.value))} (user).`);
|
|
963
1417
|
break;
|
|
964
1418
|
}
|
|
965
1419
|
case "config reset":
|
|
@@ -1033,9 +1487,9 @@ async function performCli(argv, io, env) {
|
|
|
1033
1487
|
case "open": {
|
|
1034
1488
|
if (parsed.options.log && !value("history.enabled"))
|
|
1035
1489
|
throw new HostError("Execution logging requires history.enabled=true.");
|
|
1036
|
-
const target = state.resolve(first);
|
|
1037
1490
|
await recoverInactive(state);
|
|
1038
1491
|
store = new IpfsStore(await storeConfiguration(value("store.gateway")));
|
|
1492
|
+
const target = (await resolveReference(swarmContext(), first, selectedSwarm, (reference) => state.resolve(reference), Boolean(parsed.options.raw))).cid;
|
|
1039
1493
|
let appCid;
|
|
1040
1494
|
let appArgv;
|
|
1041
1495
|
if (parsed.path === "open") {
|