@ipab/cli 0.1.0-rc.0 → 0.1.0-rc.10
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 +230 -7
- package/dist/app-authoring.d.ts +16 -2
- package/dist/app-authoring.d.ts.map +1 -1
- package/dist/app-authoring.js +151 -66
- package/dist/app-authoring.js.map +1 -1
- package/dist/app-definition.d.ts +52 -63
- package/dist/app-definition.d.ts.map +1 -1
- package/dist/app-definition.js +33 -44
- package/dist/app-definition.js.map +1 -1
- package/dist/app-prebuild.d.ts +18 -0
- package/dist/app-prebuild.d.ts.map +1 -1
- package/dist/app-prebuild.js +46 -0
- package/dist/app-prebuild.js.map +1 -1
- package/dist/app-templates.d.ts +0 -1
- package/dist/app-templates.d.ts.map +1 -1
- package/dist/app-templates.js +15 -45
- 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 +130 -0
- package/dist/assembly.js.map +1 -0
- package/dist/authoring.d.ts +8 -21
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +35 -54
- package/dist/authoring.js.map +1 -1
- package/dist/builtins/skill.ipab.car +0 -0
- package/dist/builtins/template.bundle-viewer.car +0 -0
- package/dist/builtins/template.check.car +0 -0
- package/dist/builtins/template.node.car +0 -0
- package/dist/builtins/template.web-app.car +0 -0
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +5 -32
- package/dist/builtins.js.map +1 -1
- package/dist/bundled-skills.d.ts +14 -0
- package/dist/bundled-skills.d.ts.map +1 -0
- package/dist/bundled-skills.js +34 -0
- package/dist/bundled-skills.js.map +1 -0
- package/dist/cli.d.ts +8 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2009 -308
- 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 +12 -0
- package/dist/config-secret.js.map +1 -0
- package/dist/config.d.ts +9 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +164 -23
- package/dist/config.js.map +1 -1
- package/dist/content-provider.d.ts +32 -0
- package/dist/content-provider.d.ts.map +1 -0
- package/dist/content-provider.js +222 -0
- package/dist/content-provider.js.map +1 -0
- package/dist/context-types.d.ts +12 -0
- package/dist/context-types.d.ts.map +1 -0
- package/dist/context-types.js +2 -0
- package/dist/context-types.js.map +1 -0
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +56 -2
- package/dist/context.js.map +1 -1
- package/dist/daemon-ui.d.ts +93 -0
- package/dist/daemon-ui.d.ts.map +1 -0
- package/dist/daemon-ui.js +713 -0
- package/dist/daemon-ui.js.map +1 -0
- package/dist/daemon.d.ts +21 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +317 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor.d.ts +32 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +684 -0
- package/dist/doctor.js.map +1 -0
- package/dist/errors.d.ts +1 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -20
- package/dist/errors.js.map +1 -1
- package/dist/get.d.ts +3 -0
- package/dist/get.d.ts.map +1 -0
- package/dist/get.js +80 -0
- package/dist/get.js.map +1 -0
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +6 -14
- package/dist/history.js.map +1 -1
- package/dist/host-error.d.ts +9 -0
- package/dist/host-error.d.ts.map +1 -0
- package/dist/host-error.js +21 -0
- package/dist/host-error.js.map +1 -0
- package/dist/identity.d.ts +16 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +119 -0
- package/dist/identity.js.map +1 -0
- package/dist/ipc.d.ts +5 -1
- package/dist/ipc.d.ts.map +1 -1
- package/dist/ipc.js +125 -4
- package/dist/ipc.js.map +1 -1
- package/dist/kubo-install.d.ts +26 -0
- package/dist/kubo-install.d.ts.map +1 -0
- package/dist/kubo-install.js +724 -0
- package/dist/kubo-install.js.map +1 -0
- package/dist/kubo-peering.d.ts +11 -0
- package/dist/kubo-peering.d.ts.map +1 -0
- package/dist/kubo-peering.js +93 -0
- package/dist/kubo-peering.js.map +1 -0
- package/dist/kubo-peers.d.ts +12 -0
- package/dist/kubo-peers.d.ts.map +1 -0
- package/dist/kubo-peers.js +119 -0
- package/dist/kubo-peers.js.map +1 -0
- package/dist/kubo-release.d.ts +22 -0
- package/dist/kubo-release.d.ts.map +1 -0
- package/dist/kubo-release.js +176 -0
- package/dist/kubo-release.js.map +1 -0
- package/dist/kubo-topology.d.ts +19 -0
- package/dist/kubo-topology.d.ts.map +1 -0
- package/dist/kubo-topology.js +113 -0
- package/dist/kubo-topology.js.map +1 -0
- package/dist/kubo.d.ts +85 -0
- package/dist/kubo.d.ts.map +1 -0
- package/dist/kubo.js +755 -0
- package/dist/kubo.js.map +1 -0
- package/dist/pins.d.ts +18 -20
- package/dist/pins.d.ts.map +1 -1
- package/dist/pins.js +146 -126
- package/dist/pins.js.map +1 -1
- package/dist/pivot-rpc.d.ts +62 -0
- package/dist/pivot-rpc.d.ts.map +1 -0
- package/dist/pivot-rpc.js +407 -0
- package/dist/pivot-rpc.js.map +1 -0
- package/dist/pivot-service.d.ts +16 -0
- package/dist/pivot-service.d.ts.map +1 -0
- package/dist/pivot-service.js +50 -0
- package/dist/pivot-service.js.map +1 -0
- package/dist/publish-source.d.ts +3 -0
- package/dist/publish-source.d.ts.map +1 -0
- package/dist/publish-source.js +85 -0
- package/dist/publish-source.js.map +1 -0
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +9 -4
- package/dist/runtime.js.map +1 -1
- package/dist/search-index.d.ts +64 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +409 -0
- package/dist/search-index.js.map +1 -0
- package/dist/search-service.d.ts +23 -0
- package/dist/search-service.d.ts.map +1 -0
- package/dist/search-service.js +116 -0
- package/dist/search-service.js.map +1 -0
- package/dist/skill-definition.d.ts +6 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +38 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/skill-source.d.ts +9 -0
- package/dist/skill-source.d.ts.map +1 -0
- package/dist/skill-source.js +24 -0
- package/dist/skill-source.js.map +1 -0
- package/dist/skills.d.ts +104 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +894 -0
- package/dist/skills.js.map +1 -0
- package/dist/source-bundle.d.ts +3 -9
- package/dist/source-bundle.d.ts.map +1 -1
- package/dist/source-bundle.js +17 -13
- package/dist/source-bundle.js.map +1 -1
- package/dist/space-path.d.ts +3 -0
- package/dist/space-path.d.ts.map +1 -0
- package/dist/space-path.js +17 -0
- package/dist/space-path.js.map +1 -0
- package/dist/space.d.ts +16 -4
- package/dist/space.d.ts.map +1 -1
- package/dist/space.js +170 -24
- package/dist/space.js.map +1 -1
- package/dist/state-storage-windows.d.ts +2 -0
- package/dist/state-storage-windows.d.ts.map +1 -0
- package/dist/state-storage-windows.js +114 -0
- package/dist/state-storage-windows.js.map +1 -0
- package/dist/state-storage.d.ts +5 -0
- package/dist/state-storage.d.ts.map +1 -0
- package/dist/state-storage.js +333 -0
- package/dist/state-storage.js.map +1 -0
- package/dist/state.d.ts +128 -16
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +506 -94
- package/dist/state.js.map +1 -1
- package/dist/swarm-envelope.d.ts +57 -0
- package/dist/swarm-envelope.d.ts.map +1 -0
- package/dist/swarm-envelope.js +299 -0
- package/dist/swarm-envelope.js.map +1 -0
- package/dist/swarm-files.d.ts +6 -0
- package/dist/swarm-files.d.ts.map +1 -0
- package/dist/swarm-files.js +116 -0
- package/dist/swarm-files.js.map +1 -0
- package/dist/swarm-meta.d.ts +15 -0
- package/dist/swarm-meta.d.ts.map +1 -0
- package/dist/swarm-meta.js +68 -0
- package/dist/swarm-meta.js.map +1 -0
- package/dist/swarm-observations.d.ts +40 -0
- package/dist/swarm-observations.d.ts.map +1 -0
- package/dist/swarm-observations.js +271 -0
- package/dist/swarm-observations.js.map +1 -0
- package/dist/swarm.d.ts +469 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/swarm.js +4708 -0
- package/dist/swarm.js.map +1 -0
- package/dist/template-definition.d.ts +45 -67
- package/dist/template-definition.d.ts.map +1 -1
- package/dist/template-definition.js +35 -49
- package/dist/template-definition.js.map +1 -1
- package/dist/template-paths.d.ts +7 -0
- package/dist/template-paths.d.ts.map +1 -0
- package/dist/template-paths.js +23 -0
- package/dist/template-paths.js.map +1 -0
- package/dist/template-presentation.d.ts +20 -0
- package/dist/template-presentation.d.ts.map +1 -0
- package/dist/template-presentation.js +133 -0
- package/dist/template-presentation.js.map +1 -0
- package/dist/template-source.d.ts +4 -1
- package/dist/template-source.d.ts.map +1 -1
- package/dist/template-source.js +11 -4
- package/dist/template-source.js.map +1 -1
- package/dist/templates.d.ts +11 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +53 -0
- package/dist/templates.js.map +1 -0
- package/dist/unixfs-tree.d.ts +67 -0
- package/dist/unixfs-tree.d.ts.map +1 -0
- package/dist/unixfs-tree.js +329 -0
- package/dist/unixfs-tree.js.map +1 -0
- package/package.json +18 -11
- package/src/app-authoring.ts +254 -88
- package/src/app-definition.ts +33 -45
- package/src/app-prebuild.ts +61 -0
- package/src/app-templates.ts +28 -71
- package/src/assembly.ts +185 -0
- package/src/authoring.ts +63 -72
- package/src/builtins.ts +7 -38
- package/src/bundled-skills.ts +60 -0
- package/src/cli.ts +2500 -376
- package/src/config-secret.ts +14 -0
- package/src/config.ts +215 -26
- package/src/content-provider.ts +299 -0
- package/src/context-types.ts +11 -0
- package/src/context.ts +100 -2
- package/src/daemon-ui.ts +812 -0
- package/src/daemon.ts +386 -0
- package/src/doctor.ts +1082 -0
- package/src/errors.ts +1 -25
- package/src/get.ts +90 -0
- package/src/history.ts +5 -15
- package/src/host-error.ts +26 -0
- package/src/identity.ts +175 -0
- package/src/ipc.ts +161 -4
- package/src/kubo-install.ts +936 -0
- package/src/kubo-peering.ts +126 -0
- package/src/kubo-peers.ts +144 -0
- package/src/kubo-release.ts +230 -0
- package/src/kubo-topology.ts +148 -0
- package/src/kubo.ts +1088 -0
- package/src/pins.ts +190 -142
- package/src/pivot-rpc.ts +601 -0
- package/src/pivot-service.ts +87 -0
- package/src/publish-source.ts +103 -0
- package/src/runtime.ts +16 -3
- package/src/search-index.ts +560 -0
- package/src/search-service.ts +152 -0
- package/src/skill-definition.ts +53 -0
- package/src/skill-source.ts +29 -0
- package/src/skills.ts +1236 -0
- package/src/source-bundle.ts +26 -14
- package/src/space-path.ts +30 -0
- package/src/space.ts +230 -42
- package/src/state-storage-windows.ts +134 -0
- package/src/state-storage.ts +378 -0
- package/src/state.ts +782 -116
- package/src/swarm-envelope.ts +461 -0
- package/src/swarm-files.ts +126 -0
- package/src/swarm-meta.ts +98 -0
- package/src/swarm-observations.ts +393 -0
- package/src/swarm.ts +7051 -0
- package/src/template-definition.ts +35 -49
- package/src/template-paths.ts +43 -0
- package/src/template-presentation.ts +151 -0
- package/src/template-source.ts +19 -5
- package/src/templates.ts +77 -0
- package/src/unixfs-tree.ts +401 -0
package/README.md
CHANGED
|
@@ -1,20 +1,243 @@
|
|
|
1
1
|
# @ipab/cli
|
|
2
2
|
|
|
3
|
-
Node subprocess host for InterPlanetary
|
|
4
|
-
only execute Apps you trust.
|
|
3
|
+
Node subprocess App host for IPAB (InterPlanetary Artifact Bundle). **Not a
|
|
4
|
+
sandbox**: only execute Apps you trust.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
`0.1.0-rc.10` is a release candidate, not yet published. It includes v7 UnixFS
|
|
7
|
+
Swarm roots, Config v3/Approval v2 role permissions, unified Pivot receipts and
|
|
8
|
+
search, periodic daemon synchronization and a loopback-only status WebUI.
|
|
9
|
+
Existing Swarms are not implicitly migrated. Node >=22.20.0 is unchanged.
|
|
10
|
+
|
|
11
|
+
`0.1.0-rc.8` is published on the `rc` channel. It adds private Pivot networking
|
|
12
|
+
and a foreground coordinator, State v6/root-State references, local Swarm alias
|
|
13
|
+
management and aligned human-readable lists. Upgrade every Swarm client before
|
|
14
|
+
activating the new networking: rc.7 rejects the new Profile `pivot` field,
|
|
15
|
+
including `pivot:false`. See the [release scope](../../README.md#安装) and
|
|
16
|
+
[networking limits](../../docs/swarm-networking.md).
|
|
17
|
+
|
|
18
|
+
## Explicit Bundle results (current source)
|
|
19
|
+
|
|
20
|
+
Apps may opt into the context's Bundle lifecycle without changing stdout:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
await ipab.beginOpenSession(inputCid, { supportedTypes: exactTypeCids });
|
|
24
|
+
const checkpoint = await ipab.deriveBundle(inputCid, {
|
|
25
|
+
"note.md": new TextEncoder().encode(updatedMarkdown),
|
|
26
|
+
});
|
|
27
|
+
await ipab.submitBundleResult(checkpoint);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
All four lifecycle methods (`beginOpenSession`, `deriveBundle`,
|
|
31
|
+
`submitBundleResult`, `cancelOpenSession`) accept an optional `{ signal }`. The
|
|
32
|
+
host validates the actual input Bundle and its exact type against the App's
|
|
33
|
+
`supportedSchemas`. An optional `supportedTypes` array must have no duplicates
|
|
34
|
+
and match the App declaration's entire set, not just the input type.
|
|
35
|
+
`deriveBundle` accepts safe relative file paths and byte-array replacements,
|
|
36
|
+
keeps every untouched file's exact UnixFS CID, validates the resulting Bundle,
|
|
37
|
+
and rejects type changes. Replacements can add files but do not delete files;
|
|
38
|
+
they are limited to 4096 paths and 64 MiB total per call, with normal Bundle
|
|
39
|
+
validation limits also applying. Bytes travel over the existing advanced IPC
|
|
40
|
+
serialization, not stdout or a JSON result directory.
|
|
41
|
+
|
|
42
|
+
Checkpoints are protected against GC by the execution owner until execution
|
|
43
|
+
ends. Each derivation stages under its own recoverable temporary import owner,
|
|
44
|
+
then retains/confirms the checkpoint for the execution before releasing that
|
|
45
|
+
temporary owner. A failed save or transient result validation/retention failure
|
|
46
|
+
can be retried; it never creates a successful result by itself. Submission
|
|
47
|
+
selects the exact existing Bundle CID, not an enclosing output directory. Only a
|
|
48
|
+
zero-exit, uncancelled execution commits it as the history `outputCid`. History
|
|
49
|
+
retention takes ownership before execution ownership is released; ordinary
|
|
50
|
+
explicit pins remain independent holders. With history or its retention
|
|
51
|
+
disabled, checkpoints/results have no implicit permanent pin after execution.
|
|
52
|
+
|
|
53
|
+
An opted-in session that exits without submission, or calls
|
|
54
|
+
`cancelOpenSession()`, is cancelled with no output CID. An exception, nonzero
|
|
55
|
+
exit or process cancellation also prevents submission from becoming a successful
|
|
56
|
+
result. Ordinary output Space writes cannot be mixed with explicit Bundle
|
|
57
|
+
results. Apps that never opt in or submit keep their existing output Space and
|
|
58
|
+
stdio behavior. Stdout text is never interpreted as a result CID.
|
|
59
|
+
|
|
60
|
+
Current source replaces `setup` with `ipab doctor`: read-only inspection of
|
|
61
|
+
state/configuration, managed Kubo, HOME identity, local Swarm registration and
|
|
62
|
+
compatible updates, plus the bundled IPAB Skill for detected global Agents.
|
|
63
|
+
`ipab doctor --fix --yes` also authorizes bundled Skill installation/updates,
|
|
64
|
+
without requiring a Swarm; custom edits and Swarm-managed installations are
|
|
65
|
+
protected. It otherwise authorizes only safe missing components and compatible
|
|
66
|
+
stable Kubo upgrades within `^0.43.2`. Healthy current components require
|
|
67
|
+
neither prompting nor download; archives are automatically verified and cached
|
|
68
|
+
in the protected state directory. No daemon is contacted, started or stopped,
|
|
69
|
+
and damaged credentials/installations are never replaced. For existing
|
|
70
|
+
unverified Kubo, authorized repair downloads/caches the same-version official
|
|
71
|
+
archive and compares bytes without executing or reinstalling the program.
|
|
72
|
+
Matching bytes are reused; a mismatch is an error and never overwritten.
|
|
73
|
+
Independent CID/local Store use still does not require Kubo.
|
|
74
|
+
|
|
75
|
+
`0.1.0-rc.9` is published, with on-demand background Swarm management and
|
|
76
|
+
CLI-bundled IPAB Skill bootstrap through doctor. Install this RC:
|
|
7
77
|
|
|
8
78
|
```sh
|
|
9
|
-
npm install --global @ipab/cli@0.1.0-rc.
|
|
79
|
+
npm install --global @ipab/cli@0.1.0-rc.9
|
|
10
80
|
ipab --version
|
|
11
81
|
ipab --help
|
|
12
82
|
```
|
|
13
83
|
|
|
14
|
-
Node.js 22.
|
|
15
|
-
|
|
16
|
-
|
|
84
|
+
Node.js 22.20.0 or newer is required for all commands. Shipped template CARs are
|
|
85
|
+
creation seeds; the Skill CAR also supports doctor bootstrap: new Swarms include
|
|
86
|
+
typed root State configuration, all four templates and ordinary
|
|
87
|
+
`ipab/skills/ipab` in their first HEAD. Runtime `builtin:skill.ipab` is removed;
|
|
88
|
+
cached exact CIDs remain usable offline. Upgrades never overwrite existing
|
|
89
|
+
Swarms.
|
|
90
|
+
|
|
91
|
+
Actual Swarm network activation starts a background IPAB daemon on demand, one
|
|
92
|
+
per state directory, and waits for authenticated loopback readiness. Concurrent
|
|
93
|
+
commands reuse it; launch failures are explicit. Logs are in
|
|
94
|
+
`swarm-daemon/daemon.log`. No OS service or login task is registered; after a
|
|
95
|
+
reboot, the device stays offline until its next network operation. Help/version,
|
|
96
|
+
doctor, local operations and status/members inspections do not start the
|
|
97
|
+
manager. `ipab daemon` remains a foreground alternative when no manager already
|
|
98
|
+
owns the state directory.
|
|
99
|
+
|
|
100
|
+
`ipab daemon` always manages all registered Swarms (does not accept `--swarm`)
|
|
101
|
+
with three core responsibilities: maintaining membership and network topology,
|
|
102
|
+
forcibly refreshing HEAD/State/Names/name-following pins, and automatically
|
|
103
|
+
syncing Skills (to `universal`), Templates and Registry App Bundles into the
|
|
104
|
+
local Store. Sync runs on startup for each activated Swarm, then every 60
|
|
105
|
+
seconds after the preceding sync finishes (`swarm.syncInterval` /
|
|
106
|
+
`IPAB_SWARM_SYNC_INTERVAL`, 1–86400 seconds; restart daemon to apply). Syncs
|
|
107
|
+
never overlap within a Swarm. Local edits, unmanaged content and cross-source
|
|
108
|
+
collisions remain protected; failures are logged and retried next interval.
|
|
109
|
+
Removed Skill sources are not automatically uninstalled.
|
|
110
|
+
|
|
111
|
+
`ipab skills list` discovers the selected Swarm's exact typed Skills via root
|
|
112
|
+
skillPath (legacy v2/v3/v4 use Meta.skillPath) and reports shared Names, payload
|
|
113
|
+
CIDs and installation status. `ipab skills sync [NAMES...]` uses the pinned
|
|
114
|
+
official `npx skills@1.9.1` installer; NAMES accept install identities
|
|
115
|
+
(`ipab code-review`) or full shared Names (`ipab/skills/ipab`), resolved against
|
|
116
|
+
the same verified snapshot. The installer runs globally with `--copy`; repeat
|
|
117
|
+
`--agent AGENT`, or default to `universal` (`~/.agents/skills`). Doctor
|
|
118
|
+
bootstrap separately targets detected global Agents and never enables overrides.
|
|
119
|
+
Skills operations require Node >=22.20.0. There is one selected Swarm per
|
|
120
|
+
invocation and no `--all`. `--dry-run` previews source, installer version,
|
|
121
|
+
agents, paths and file changes without npx. Noninteractive installation needs
|
|
122
|
+
`--yes`, which skips IPAB consent only. Explicit `--override-existing` permits
|
|
123
|
+
replacement of unmanaged content and local edits at selected targets;
|
|
124
|
+
cross-source ownership, unselected paths, concurrent changes and
|
|
125
|
+
symlink/junction protections remain enforced. Removed sources are not
|
|
126
|
+
automatically uninstalled. Account-wide attribution and pending recovery
|
|
127
|
+
preserve partial successes, which are reported with nonzero status. Skill
|
|
128
|
+
scripts/hooks do not run; the trusted installer is not a sandbox. Its telemetry,
|
|
129
|
+
remote audits and npm lifecycle scripts are disabled. Shipping or installing a
|
|
130
|
+
Skill does not configure automatic Agent loading. Old v5 State roots without
|
|
131
|
+
skillPath retain their exact type/configuration on ordinary writes and require a
|
|
132
|
+
new seeded Swarm with explicitly republished reviewed Names before Skills
|
|
133
|
+
operations. A user Name ipab never overrides root configuration. Only legacy
|
|
134
|
+
v2/v3/v4 standalone Meta can migrate by explicit new typed Meta publication with
|
|
135
|
+
`--expect`; both known standalone Meta types remain readable.
|
|
17
136
|
|
|
18
137
|
See the [user guide](https://github.com/silvermoon-work/ipab#readme) and
|
|
19
138
|
[command reference](https://github.com/silvermoon-work/ipab/blob/main/docs/reference.md)
|
|
20
139
|
for Store configuration, execution, pins, templates and App development.
|
|
140
|
+
|
|
141
|
+
The current CLI removes the Kubo RPC backend and legacy alias state. Use the
|
|
142
|
+
Local Store and `store.gateway`; reset old `store.rpc` configuration and rebuild
|
|
143
|
+
local named pins. Remote Kubo pins and retention are not automatically migrated
|
|
144
|
+
or released. This is an intentional prerelease compatibility change.
|
|
145
|
+
|
|
146
|
+
The rc.2 release adds shared swarm Names, authenticated five-minute HEAD
|
|
147
|
+
caching, local swarm registration/selection and named search. See the
|
|
148
|
+
[MVP implementation](../../docs/mvp-implementation.md) for force controls and
|
|
149
|
+
the migration from legacy creation/membership records.
|
|
150
|
+
|
|
151
|
+
The current source implements
|
|
152
|
+
[Scope / Variable onboarding](../../docs/onboarding.md): signed Request files,
|
|
153
|
+
trusted Owner fingerprints, encrypted nonexpiring exact-ID certificates, lazy
|
|
154
|
+
membership activation and checksum-verified managed Kubo within `^0.43.2`. Each
|
|
155
|
+
Swarm uses a separate protected repo, key and ports; daemons start on demand and
|
|
156
|
+
survive CLI exit. No Invite/Response/Join or old Swarm CID protocol fallback
|
|
157
|
+
exists.
|
|
158
|
+
|
|
159
|
+
Local naming and membership requests are separate:
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
ipab swarm set work CONFIG_URL
|
|
163
|
+
ipab swarm request work --output request.json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`set ALIAS CONFIG_URL` is offline and requires no identity or membership.
|
|
167
|
+
Retargeting an existing alias requires confirmation or `--yes`; the previous URL
|
|
168
|
+
remains registered without that alias, preserving credentials, caches and the
|
|
169
|
+
saved default URL. Each URL keeps at most one alias. Repeating the same mapping
|
|
170
|
+
is idempotent; the first registration sets the default only if none exists.
|
|
171
|
+
`request URL_OR_ALIAS` never changes registrations or aliases and can use a full
|
|
172
|
+
URL without prior `set`. The old `swarm add` and `request --alias` interfaces
|
|
173
|
+
return migration guidance.
|
|
174
|
+
|
|
175
|
+
Shared references use `ipab://ALIAS_OR_ENCODED_CONFIG_URL/PATH`; `ipab:///PATH`
|
|
176
|
+
selects `--swarm` or the saved `swarm.default`, in that order. URI swarm
|
|
177
|
+
authorities take precedence and local aliases are case-sensitive. Search text
|
|
178
|
+
uses local alias URIs when available, falling back to full configuration URLs.
|
|
179
|
+
JSON `reference` fields always use full configuration-URL-based URIs for sharing
|
|
180
|
+
across devices. Legacy `name:PATH` references are no longer supported.
|
|
181
|
+
`IPAB_SWARM` is ignored entirely: it neither selects a Swarm nor causes an
|
|
182
|
+
error. Use `--swarm` or `swarm use` to select a Swarm.
|
|
183
|
+
|
|
184
|
+
`search QUERY` searches only the current Swarm by default (`--swarm`, then the
|
|
185
|
+
saved default); missing selection is an error. Use `search QUERY --all` to
|
|
186
|
+
search every registered Swarm. `--all` conflicts with `--swarm` and `--current`;
|
|
187
|
+
`--current` remains an explicit spelling of the default scope. Valid caches
|
|
188
|
+
require no network requests. Expired or forced searches read public
|
|
189
|
+
configuration and HEAD without member Profile reads or Kubo activation; private
|
|
190
|
+
networking is activated only to obtain missing State or Name pin content. Search
|
|
191
|
+
matches shared Names, not built-in templates or Bundle metadata.
|
|
192
|
+
|
|
193
|
+
Owner uses `swarm update` for organization information and `swarm exclude` /
|
|
194
|
+
`swarm resume` for irreversible, resumable member removal. Members change only
|
|
195
|
+
their account-wide personal name/description using `ipab profile`, independently
|
|
196
|
+
of Swarm selection. Updates save protected public-key-bound HOME data first,
|
|
197
|
+
then synchronize all registered memberships, preserving each Swarm's addresses.
|
|
198
|
+
Partial failures exit nonzero with per-Swarm results; retry the update or
|
|
199
|
+
activate the failed membership normally. Future memberships adopt the same
|
|
200
|
+
profile. Legacy fields are reused only when unanimous; conflicts require
|
|
201
|
+
explicit choices. `swarm profile --address` is network-only. `swarm members`
|
|
202
|
+
publicly lists all members, including Owner, with full public keys; no identity
|
|
203
|
+
or node is needed. Existing Swarm operations use global `--swarm URL_OR_ALIAS`
|
|
204
|
+
or the saved default, never target positionals. `swarm create --name` still sets
|
|
205
|
+
the organization name. HEAD uses content-CID CAS, not a history revision.
|
|
206
|
+
|
|
207
|
+
Current-source protocol updates keep Variable JSON bodies raw and use
|
|
208
|
+
content-CID ETags for CAS. Each member reuses a single account Ed25519 key for
|
|
209
|
+
signing, managed Kubo node identity (deterministic `PeerID`), and X25519
|
|
210
|
+
Approval key agreement. Config v3 supports 256 members through flattened public
|
|
211
|
+
member entries (`publicKey`, `role`, `profileId`, `approvalId`) and Owner-only
|
|
212
|
+
2-field `{v:2,ciphertext}` dual-ECDH Approval v2 Variables (`2N + 1` live
|
|
213
|
+
Variables, with Owner `approvalId: null`); Request v2 is a 7-field offline-
|
|
214
|
+
signed JSON document (including `role: "ordinary" | "pivot"`); Pivot
|
|
215
|
+
certificates grant `[headId, profileId]` while Ordinary certificates grant only
|
|
216
|
+
`[profileId]` (requiring a Pivot/Owner `ScopeWriteReceipt` for HEAD writes).
|
|
217
|
+
Member-writable Profiles remain separate and readable without fetching any
|
|
218
|
+
Approval Variable. Existing Config v2/v1 and inline/linked State remain
|
|
219
|
+
readable. See [the protocol](../../docs/onboarding.md).
|
|
220
|
+
|
|
221
|
+
The current source adds a Swarm-only App registry (not included in rc.5), saving
|
|
222
|
+
exact type CID -> App CID + argv associations. `register list/set/remove`
|
|
223
|
+
without explicit `--swarm` uses the saved default Swarm; no selection is an
|
|
224
|
+
error with `--swarm` / `ipab swarm use` guidance. Use
|
|
225
|
+
`ipab register set TYPE_CID ipab:///apps/reader --swarm work --swarm team` to
|
|
226
|
+
register in multiple Swarms; an IPAB URI resolves independently for each target
|
|
227
|
+
and only the exact App CID is saved. Shared writes require HEAD write access and
|
|
228
|
+
commit sequentially, not atomically across Swarms. Failures identify completed
|
|
229
|
+
targets. Open uses only the content URI's Swarm, then explicit `--swarm`, then
|
|
230
|
+
the saved default; no selection is an error. Local associations and other Swarms
|
|
231
|
+
are never consulted; retrieval, compatibility and execution failures never
|
|
232
|
+
trigger fallback. `exec` remains the way to select an App directly. Existing
|
|
233
|
+
User registrations are preserved in-place as the inactive
|
|
234
|
+
`legacy_user_registrations` state-database table, never uploaded or deleted.
|
|
235
|
+
Register/Open warn with the archive location; review it and explicitly publish
|
|
236
|
+
only intended associations with `register set ... --swarm ...`.
|
|
237
|
+
|
|
238
|
+
`swarm status` reads public configuration, Scope, HEAD and verified State
|
|
239
|
+
content. Available content needs no HOME identity or managed node; missing
|
|
240
|
+
content may activate the registered Swarm's private source, with an explicit
|
|
241
|
+
diagnostic. Use `swarm status --local` for membership/Owner-interruption checks,
|
|
242
|
+
node connection, account-specific HEAD-cache updates and local PeerID/addresses.
|
|
243
|
+
Default JSON omits `peerId` and `addresses`; `--local` retains those fields.
|
package/dist/app-authoring.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { type BundleType } from "@ipab/bundle";
|
|
1
2
|
import { type AuthoringOptions, type BuildResult } from "./authoring.js";
|
|
3
|
+
export { appSchema } from "./app-definition.js";
|
|
2
4
|
export declare function initApp(name: string, directory?: string, options?: AuthoringOptions & {
|
|
3
5
|
template?: string;
|
|
4
6
|
parameters?: readonly string[];
|
|
5
7
|
}): Promise<{
|
|
6
|
-
kind: "
|
|
8
|
+
kind: "project-init";
|
|
7
9
|
directory: string;
|
|
8
10
|
name: string;
|
|
9
11
|
template: string;
|
|
10
12
|
templateCid: string | null;
|
|
11
|
-
schemaCid: string;
|
|
12
13
|
files: string[];
|
|
13
14
|
}>;
|
|
14
15
|
export declare function buildApp(directory?: string, options?: AuthoringOptions & {
|
|
@@ -16,8 +17,21 @@ export declare function buildApp(directory?: string, options?: AuthoringOptions
|
|
|
16
17
|
outputDir?: string;
|
|
17
18
|
replace?: boolean;
|
|
18
19
|
includeSource?: boolean;
|
|
20
|
+
/** Exact types from an author's Open App definition; exclusive with config paths. */
|
|
21
|
+
supportedTypes?: readonly BundleType[];
|
|
22
|
+
preparedDirectory?: string;
|
|
19
23
|
}): Promise<Omit<BuildResult, "kind"> & {
|
|
20
24
|
kind: "app-bundle";
|
|
21
25
|
source?: Omit<BuildResult, "kind">;
|
|
22
26
|
}>;
|
|
27
|
+
/** Explicit project tool. The root CLI build never calls this helper. */
|
|
28
|
+
export declare function prepareApp(directory?: string, options?: AuthoringOptions & {
|
|
29
|
+
replace?: boolean;
|
|
30
|
+
includeSource?: boolean;
|
|
31
|
+
/** Exact types from an author's Open App definition; exclusive with config paths. */
|
|
32
|
+
supportedTypes?: readonly BundleType[];
|
|
33
|
+
}): Promise<{
|
|
34
|
+
source?: Omit<BuildResult, "kind">;
|
|
35
|
+
directory: string;
|
|
36
|
+
}>;
|
|
23
37
|
//# sourceMappingURL=app-authoring.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-authoring.d.ts","sourceRoot":"","sources":["../src/app-authoring.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app-authoring.d.ts","sourceRoot":"","sources":["../src/app-authoring.ts"],"names":[],"mappings":"AAaA,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAoBxB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAMhD,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,SAAO,EAChB,OAAO,GAAE,gBAAgB,GAAG;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;;;;;;;GAgBP;AA6HD,wBAAsB,QAAQ,CAC5B,SAAS,SAAM,EACf,OAAO,GAAE,gBAAgB,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,cAAc,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACvB,GACL,OAAO,CACR,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;CACpC,CACF,CAieA;AAED,yEAAyE;AACzE,wBAAsB,UAAU,CAC9B,SAAS,SAAM,EACf,OAAO,GAAE,gBAAgB,GAAG;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,cAAc,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CACnC;;;GA2EP"}
|
package/dist/app-authoring.js
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { lstat, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
-
import {
|
|
4
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep, } from "node:path";
|
|
5
4
|
import { StringDecoder } from "node:string_decoder";
|
|
6
|
-
import { compileFunction } from "node:vm";
|
|
7
5
|
import { stringify } from "yaml";
|
|
8
6
|
import { parseData } from "@ipab/bundle";
|
|
9
7
|
import { filesystemTree } from "@ipab/bundle-builder/node";
|
|
10
8
|
import { encodeBundleCar, memoryTree, readBytes } from "@ipab/bundle-builder";
|
|
11
|
-
import { writeCar, outputAvailable, scaffoldFiles, nodeError, } from "./authoring.js";
|
|
9
|
+
import { writeCar, outputAvailable, readCar, scaffoldFiles, nodeError, } from "./authoring.js";
|
|
12
10
|
import { HostError, object } from "./errors.js";
|
|
13
11
|
import { relativePath } from "./space.js";
|
|
14
12
|
import { buildSupportedSchemas, supportedSchemasPath, } from "./supported-schemas.js";
|
|
15
13
|
import { appDescription, appSchema, builtinAppSchema, } from "./app-definition.js";
|
|
16
14
|
import { appTemplate } from "./app-templates.js";
|
|
17
|
-
import { buildChain, projectBuild, runPrebuild } from "./app-prebuild.js";
|
|
15
|
+
import { buildChain, compileAppProgram, projectBuild, runPrebuild, } from "./app-prebuild.js";
|
|
18
16
|
import { captureSource, sourceFingerprint } from "./source-bundle.js";
|
|
17
|
+
export { appSchema } from "./app-definition.js";
|
|
19
18
|
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
19
|
+
const sourceTarget = "source";
|
|
20
|
+
const sourceCarInput = "source.car";
|
|
20
21
|
export async function initApp(name, directory = name, options = {}) {
|
|
21
|
-
if (!/^[a-z0-9][a-z0-9._-]*$/.test(name) ||
|
|
22
|
-
name.length > 214 ||
|
|
23
|
-
["node_modules", "favicon.ico"].includes(name))
|
|
24
|
-
throw new HostError("App NAME must be an unscoped lowercase npm package name.");
|
|
25
22
|
const { files, cid: templateCid } = await appTemplate(options.template ?? "node", name, options);
|
|
26
|
-
const schemaCid = (await builtinAppSchema()).cid.toString();
|
|
27
23
|
const root = await scaffoldFiles(directory, files, options);
|
|
28
24
|
return {
|
|
29
|
-
kind: "
|
|
25
|
+
kind: "project-init",
|
|
30
26
|
directory: root,
|
|
31
27
|
name,
|
|
32
28
|
template: options.template ?? "node",
|
|
33
29
|
templateCid,
|
|
34
|
-
schemaCid,
|
|
35
30
|
files: [...files.keys()],
|
|
36
31
|
};
|
|
37
32
|
}
|
|
@@ -223,11 +218,14 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
223
218
|
throw new HostError("App metadata cannot override the generated supportedSchemas declaration.");
|
|
224
219
|
if (Object.hasOwn(overrides, "source"))
|
|
225
220
|
throw new HostError("App metadata cannot override the generated source declaration.");
|
|
226
|
-
|
|
221
|
+
if (options.supportedTypes && schemas.size)
|
|
222
|
+
throw new HostError("Use either supportedTypes or supportedSchemas paths, not both.");
|
|
223
|
+
const declared = options.supportedTypes?.map((type, index) => [`schemas/${index}.json`, new TextEncoder().encode(json(type))]);
|
|
224
|
+
const supportedSchemas = await buildSupportedSchemas(declared ? memoryTree(new Map(declared)) : tree, declared ? new Set(declared.map(([path]) => path)) : schemas, options);
|
|
227
225
|
const description = appDescription({
|
|
228
226
|
...defaults,
|
|
229
227
|
...overrides,
|
|
230
|
-
entry:
|
|
228
|
+
entry: "resources/app.cjs",
|
|
231
229
|
...(supportedSchemas ? { supportedSchemas: supportedSchemasPath } : {}),
|
|
232
230
|
});
|
|
233
231
|
if (description.icon !== undefined) {
|
|
@@ -297,7 +295,6 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
297
295
|
options.signal?.throwIfAborted();
|
|
298
296
|
const stage = await mkdtemp(join(root, ".ipab-app-"));
|
|
299
297
|
try {
|
|
300
|
-
const { build } = await import("esbuild");
|
|
301
298
|
const bundleStage = join(stage, "bundle");
|
|
302
299
|
const input = prebuild ? join(stage, "input") : root;
|
|
303
300
|
if (prebuild) {
|
|
@@ -308,47 +305,8 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
308
305
|
const prebuiltSource = prebuild
|
|
309
306
|
? await readBytes(inputTree, entry, 8 * 1024 * 1024, options)
|
|
310
307
|
: undefined;
|
|
311
|
-
if (prebuiltSource) {
|
|
312
|
-
try {
|
|
313
|
-
const source = new TextDecoder("utf-8", { fatal: true }).decode(prebuiltSource);
|
|
314
|
-
compileFunction(source.replace(/^#![^\r\n]*/, ""), [
|
|
315
|
-
"exports",
|
|
316
|
-
"require",
|
|
317
|
-
"module",
|
|
318
|
-
"__filename",
|
|
319
|
-
"__dirname",
|
|
320
|
-
]);
|
|
321
|
-
}
|
|
322
|
-
catch (cause) {
|
|
323
|
-
const error = new HostError("Prebuilt App entry must be valid Node CommonJS; it is packaged without transformation.");
|
|
324
|
-
error.cause = cause;
|
|
325
|
-
throw error;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
308
|
await mkdir(join(bundleStage, "resources"), { recursive: true });
|
|
329
|
-
const program = await
|
|
330
|
-
absWorkingDir: input,
|
|
331
|
-
entryPoints: [entry],
|
|
332
|
-
outfile: join(bundleStage, "resources", "app.cjs"),
|
|
333
|
-
bundle: true,
|
|
334
|
-
platform: "node",
|
|
335
|
-
format: "cjs",
|
|
336
|
-
target: "node22.15",
|
|
337
|
-
packages: prebuild ? "external" : "bundle",
|
|
338
|
-
metafile: true,
|
|
339
|
-
write: false,
|
|
340
|
-
logLevel: "silent",
|
|
341
|
-
logOverride: {
|
|
342
|
-
"unsupported-dynamic-import": "error",
|
|
343
|
-
"unsupported-require-call": "error",
|
|
344
|
-
"indirect-require": "error",
|
|
345
|
-
},
|
|
346
|
-
});
|
|
347
|
-
if (program.outputFiles.length !== 1 ||
|
|
348
|
-
program.outputFiles[0].contents.length > 8 * 1024 * 1024 ||
|
|
349
|
-
(prebuild && Object.keys(program.metafile.inputs).length !== 1) ||
|
|
350
|
-
Object.values(program.metafile.outputs).some((file) => file.imports.some((item) => item.external && !isBuiltin(item.path))))
|
|
351
|
-
throw new HostError("App must bundle into one self-contained .cjs of at most 8 MiB; only Node builtins may remain external.");
|
|
309
|
+
const program = await compileAppProgram(input, entry, join(bundleStage, "resources", "app.cjs"), prebuiltSource);
|
|
352
310
|
if (sourceFiles && !prebuild)
|
|
353
311
|
for (const path of Object.keys(program.metafile.inputs))
|
|
354
312
|
if (!path.split(/[\\/]/).includes("node_modules") &&
|
|
@@ -360,7 +318,16 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
360
318
|
flag: "wx",
|
|
361
319
|
signal: options.signal,
|
|
362
320
|
});
|
|
363
|
-
await writeFile(join(bundleStage, ".bundle.yaml"), stringify(
|
|
321
|
+
await writeFile(join(bundleStage, ".bundle.yaml"), stringify({
|
|
322
|
+
title: description.name,
|
|
323
|
+
description: description.description,
|
|
324
|
+
entry: "app.json",
|
|
325
|
+
type: ".bundle-type.yaml",
|
|
326
|
+
}), {
|
|
327
|
+
flag: "wx",
|
|
328
|
+
signal: options.signal,
|
|
329
|
+
});
|
|
330
|
+
await writeFile(join(bundleStage, ".bundle-type.yaml"), stringify(appSchema), {
|
|
364
331
|
flag: "wx",
|
|
365
332
|
signal: options.signal,
|
|
366
333
|
});
|
|
@@ -371,7 +338,12 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
371
338
|
if (++resourceCount > 4096)
|
|
372
339
|
throw new HostError("App resource file count exceeds 4096.");
|
|
373
340
|
relativePath(path);
|
|
374
|
-
if (path
|
|
341
|
+
if (path
|
|
342
|
+
.split("/")
|
|
343
|
+
.some((part, index, parts) => part.startsWith(".") &&
|
|
344
|
+
!([".bundle.yaml", ".bundle-type.yaml"].includes(part) &&
|
|
345
|
+
index === parts.length - 1 &&
|
|
346
|
+
index > 0)))
|
|
375
347
|
throw new HostError("Hidden prebuilt resources are not supported.");
|
|
376
348
|
const bytes = await readBytes(inputTree, path, 16 * 1024 * 1024, options);
|
|
377
349
|
const target = join(bundleStage, "resources", ...path.split("/"));
|
|
@@ -415,16 +387,70 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
415
387
|
? { source: { cid: encodedSource.cid.toString() } }
|
|
416
388
|
: {}),
|
|
417
389
|
}), { flag: "wx", signal: options.signal });
|
|
418
|
-
const
|
|
390
|
+
const source = encodedSource
|
|
391
|
+
? {
|
|
392
|
+
cid: encodedSource.cid.toString(),
|
|
393
|
+
schemaCid: encodedSource.schema.cid.toString(),
|
|
394
|
+
output: sourceOutput,
|
|
395
|
+
bytes: await writeCar(encodedSource, sourceOutput, Boolean(options.replace), options),
|
|
396
|
+
}
|
|
397
|
+
: undefined;
|
|
398
|
+
const sourceCar = source
|
|
399
|
+
? await readCar(source.output, options)
|
|
400
|
+
: undefined;
|
|
401
|
+
const encoded = await encodeBundleCar(await filesystemTree(bundleStage), {
|
|
402
|
+
...options,
|
|
403
|
+
imports: encodedSource && sourceCar
|
|
404
|
+
? [
|
|
405
|
+
{
|
|
406
|
+
path: sourceTarget,
|
|
407
|
+
cid: encodedSource.cid,
|
|
408
|
+
resolveCid: sourceCar.resolveCid,
|
|
409
|
+
},
|
|
410
|
+
]
|
|
411
|
+
: [],
|
|
412
|
+
});
|
|
419
413
|
try {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
414
|
+
if (options.preparedDirectory) {
|
|
415
|
+
const preparedFiles = new Map();
|
|
416
|
+
const preparedTree = await filesystemTree(bundleStage);
|
|
417
|
+
const collect = async (path) => {
|
|
418
|
+
for (const item of await preparedTree.list(path, options)) {
|
|
419
|
+
const child = path ? `${path}/${item.name}` : item.name;
|
|
420
|
+
if (item.kind === "directory")
|
|
421
|
+
await collect(child);
|
|
422
|
+
else
|
|
423
|
+
preparedFiles.set(child, await readBytes(preparedTree, child, 16 * 1024 * 1024, options));
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
await collect("");
|
|
427
|
+
preparedFiles.set("ipab.build.yaml", new TextEncoder().encode(stringify({
|
|
428
|
+
version: 1,
|
|
429
|
+
files: [...preparedFiles.keys()]
|
|
430
|
+
.filter((path) => path !== ".bundle.yaml")
|
|
431
|
+
.map((path) => ({ source: path, target: path })),
|
|
432
|
+
imports: source
|
|
433
|
+
? [
|
|
434
|
+
{
|
|
435
|
+
cid: source.cid,
|
|
436
|
+
target: sourceTarget,
|
|
437
|
+
car: sourceCarInput,
|
|
438
|
+
},
|
|
439
|
+
]
|
|
440
|
+
: [],
|
|
441
|
+
})));
|
|
442
|
+
if (source)
|
|
443
|
+
preparedFiles.set(sourceCarInput, await readBytes(await filesystemTree(dirname(source.output)), basename(source.output), source.bytes, options));
|
|
444
|
+
await scaffoldFiles(options.preparedDirectory, preparedFiles, options);
|
|
445
|
+
return {
|
|
446
|
+
kind: "app-bundle",
|
|
447
|
+
cid: encoded.cid.toString(),
|
|
448
|
+
schemaCid: encoded.schema.cid.toString(),
|
|
449
|
+
output,
|
|
450
|
+
bytes: 0,
|
|
451
|
+
...(source ? { source } : {}),
|
|
452
|
+
};
|
|
453
|
+
}
|
|
428
454
|
return {
|
|
429
455
|
kind: "app-bundle",
|
|
430
456
|
cid: encoded.cid.toString(),
|
|
@@ -446,4 +472,63 @@ export async function buildApp(directory = ".", options = {}) {
|
|
|
446
472
|
await rm(stage, { recursive: true, force: true });
|
|
447
473
|
}
|
|
448
474
|
}
|
|
475
|
+
/** Explicit project tool. The root CLI build never calls this helper. */
|
|
476
|
+
export async function prepareApp(directory = ".", options = {}) {
|
|
477
|
+
const root = resolve(directory);
|
|
478
|
+
const prepared = join(root, "dist", "prepared-app");
|
|
479
|
+
try {
|
|
480
|
+
const stat = await lstat(prepared);
|
|
481
|
+
if (stat.isSymbolicLink() || !stat.isDirectory() || !options.replace)
|
|
482
|
+
throw new HostError("Prepared output exists; explicit replacement requires a regular generated directory.");
|
|
483
|
+
const tree = await filesystemTree(prepared);
|
|
484
|
+
const recipe = object(parseData(await readBytes(tree, "ipab.build.yaml", 64 * 1024), "application/yaml"), "prepared recipe");
|
|
485
|
+
if (recipe.version !== 1 ||
|
|
486
|
+
!Array.isArray(recipe.files) ||
|
|
487
|
+
!Array.isArray(recipe.imports) ||
|
|
488
|
+
recipe.imports.length > 1)
|
|
489
|
+
throw new HostError("Existing prepared output is not owned by the App preparation tool.");
|
|
490
|
+
const allowed = new Set([
|
|
491
|
+
".bundle.yaml",
|
|
492
|
+
"ipab.build.yaml",
|
|
493
|
+
...recipe.files.map((item) => {
|
|
494
|
+
const mapping = object(item, "prepared mapping");
|
|
495
|
+
if (typeof mapping.source !== "string" ||
|
|
496
|
+
mapping.source !== mapping.target)
|
|
497
|
+
throw new HostError("Existing prepared mapping is not generated.");
|
|
498
|
+
return relativePath(mapping.source);
|
|
499
|
+
}),
|
|
500
|
+
]);
|
|
501
|
+
if (recipe.imports.length) {
|
|
502
|
+
const sourceImport = object(recipe.imports[0], "prepared source import");
|
|
503
|
+
if (sourceImport.target !== sourceTarget ||
|
|
504
|
+
sourceImport.car !== sourceCarInput ||
|
|
505
|
+
typeof sourceImport.cid !== "string")
|
|
506
|
+
throw new HostError("Existing prepared source import is not generated.");
|
|
507
|
+
allowed.add(sourceCarInput);
|
|
508
|
+
}
|
|
509
|
+
const verify = async (path) => {
|
|
510
|
+
for (const item of await tree.list(path)) {
|
|
511
|
+
const child = path ? `${path}/${item.name}` : item.name;
|
|
512
|
+
if (item.kind === "directory")
|
|
513
|
+
await verify(child);
|
|
514
|
+
else if (!allowed.has(child))
|
|
515
|
+
throw new HostError("Prepared output contains custom files; choose a new output rather than deleting them.");
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
await verify("");
|
|
519
|
+
await rm(prepared, { recursive: true });
|
|
520
|
+
}
|
|
521
|
+
catch (cause) {
|
|
522
|
+
if (!nodeError(cause, "ENOENT"))
|
|
523
|
+
throw cause;
|
|
524
|
+
}
|
|
525
|
+
const result = await buildApp(root, {
|
|
526
|
+
...options,
|
|
527
|
+
preparedDirectory: prepared,
|
|
528
|
+
});
|
|
529
|
+
return {
|
|
530
|
+
directory: prepared,
|
|
531
|
+
...(result.source ? { source: result.source } : {}),
|
|
532
|
+
};
|
|
533
|
+
}
|
|
449
534
|
//# sourceMappingURL=app-authoring.js.map
|