@xyo-network/dapp-kit-cli 0.1.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 +29 -0
- package/dist/node/bin.d.ts +3 -0
- package/dist/node/bin.d.ts.map +1 -0
- package/dist/node/bin.mjs +417 -0
- package/dist/node/bin.mjs.map +7 -0
- package/dist/node/dappCli.d.ts +39 -0
- package/dist/node/dappCli.d.ts.map +1 -0
- package/dist/node/defaultDappCliLifecycle.d.ts +7 -0
- package/dist/node/defaultDappCliLifecycle.d.ts.map +1 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +419 -0
- package/dist/node/index.mjs.map +7 -0
- package/package.json +80 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# `@xyo-network/dapp-kit-cli`
|
|
2
|
+
|
|
3
|
+
Thin command-line adapter for `xl1.dapp.json` projects.
|
|
4
|
+
|
|
5
|
+
The `xl1-dapp` binary implements `init`, `validate`, `inspect`, `build`, `plan`,
|
|
6
|
+
`dev`, and `test`. Parsing, rendering, and exit-code mapping live here; repository
|
|
7
|
+
loading, artifact admission, planning, resource ownership, and host lifecycle
|
|
8
|
+
remain in the importable Node/local packages. The CLI has no actor supervisor,
|
|
9
|
+
provider locator, XL1 gateway, daemon manager, or site server of its own.
|
|
10
|
+
|
|
11
|
+
`init` calls the importable Node repository operation that atomically adds the
|
|
12
|
+
exact `.xl1/` rule to `.gitignore`. It is idempotent and does not create or alter
|
|
13
|
+
the project manifest.
|
|
14
|
+
|
|
15
|
+
`inspect` renders credential-free definition and deployment projections. With
|
|
16
|
+
`--deployment`, it selects one declared deployment and reports its actors,
|
|
17
|
+
hosts, port/identity/store bindings, semantic resource requests, policies,
|
|
18
|
+
verification classes, explicit absence guarantees, and inputs still awaiting
|
|
19
|
+
artifact build or environment resolution.
|
|
20
|
+
|
|
21
|
+
`plan`, `dev`, and `test` use the closed, versioned local environment catalog by
|
|
22
|
+
default. `--catalog` selects an explicit repository-relative override for
|
|
23
|
+
embedding and conformance work. `dev` and `test` default to the importable lifecycle
|
|
24
|
+
owner from `@xyo-network/dapp-kit-local`; callers may still inject the same
|
|
25
|
+
narrow service interface for embedding and deterministic tests. `dev` maps
|
|
26
|
+
SIGINT/SIGTERM into owned reverse teardown. `test` binds the same signal policy,
|
|
27
|
+
launches the same system, runs every manifest-declared verification with its
|
|
28
|
+
explicit evidence label, and always stops. `--retain-on-failure` preserves
|
|
29
|
+
isolated failed test state.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/dappCli.ts
|
|
4
|
+
import PATH2 from "node:path";
|
|
5
|
+
import {
|
|
6
|
+
canonicalizeIJson as canonicalizeIJson2,
|
|
7
|
+
DappEnvironmentCatalogZod
|
|
8
|
+
} from "@xyo-network/dapp-kit";
|
|
9
|
+
import {
|
|
10
|
+
buildLocalDappProjectArtifacts,
|
|
11
|
+
createDefaultLocalEnvironmentCatalog,
|
|
12
|
+
planLocalDappProject
|
|
13
|
+
} from "@xyo-network/dapp-kit-local";
|
|
14
|
+
import {
|
|
15
|
+
initializeDappProject,
|
|
16
|
+
loadDappProject,
|
|
17
|
+
readStrictJsonFile,
|
|
18
|
+
resolveRepositoryPath
|
|
19
|
+
} from "@xyo-network/dapp-kit-node";
|
|
20
|
+
|
|
21
|
+
// src/defaultDappCliLifecycle.ts
|
|
22
|
+
import PATH from "node:path";
|
|
23
|
+
import { canonicalizeIJson } from "@xyo-network/dapp-kit";
|
|
24
|
+
import {
|
|
25
|
+
runLocalDappVerifications,
|
|
26
|
+
startDefaultLocalDappRun
|
|
27
|
+
} from "@xyo-network/dapp-kit-local";
|
|
28
|
+
function renderEvent(io, componentId, value) {
|
|
29
|
+
io.stderr(`[${componentId}] ${canonicalizeIJson(value)}
|
|
30
|
+
`);
|
|
31
|
+
}
|
|
32
|
+
function signalOwnedRun(run) {
|
|
33
|
+
const stop = () => {
|
|
34
|
+
void run.stop().catch(() => null);
|
|
35
|
+
};
|
|
36
|
+
process.once("SIGINT", stop);
|
|
37
|
+
process.once("SIGTERM", stop);
|
|
38
|
+
return () => {
|
|
39
|
+
process.off("SIGINT", stop);
|
|
40
|
+
process.off("SIGTERM", stop);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function renderReady(io, run, endpoints) {
|
|
44
|
+
renderEvent(io, "runner", {
|
|
45
|
+
code: "cli.run-ready",
|
|
46
|
+
endpoints,
|
|
47
|
+
runId: run.runId,
|
|
48
|
+
stateRoot: run.stateRoot
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function runDev(project, options) {
|
|
52
|
+
const run = await startDefaultLocalDappRun({
|
|
53
|
+
mode: "dev",
|
|
54
|
+
onForegroundLog: (entry) => renderEvent(options.io, entry.componentId, entry),
|
|
55
|
+
planned: project
|
|
56
|
+
});
|
|
57
|
+
const unbindSignals = signalOwnedRun(run);
|
|
58
|
+
try {
|
|
59
|
+
try {
|
|
60
|
+
const ready = await run.whenReady;
|
|
61
|
+
renderReady(options.io, run, ready.endpoints);
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return await run.whenTerminal;
|
|
65
|
+
} finally {
|
|
66
|
+
unbindSignals();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function stopAfterTest(run, isVerificationFailed, retainOnFailure) {
|
|
70
|
+
if (isVerificationFailed && retainOnFailure) run.retainState();
|
|
71
|
+
const terminal = await run.stop();
|
|
72
|
+
return terminal.outcome === "failed" || isVerificationFailed ? { outcome: "failed" } : { outcome: "stopped" };
|
|
73
|
+
}
|
|
74
|
+
async function runTest(project, options) {
|
|
75
|
+
const run = await startDefaultLocalDappRun({
|
|
76
|
+
mode: "test",
|
|
77
|
+
onForegroundLog: (entry) => renderEvent(options.io, entry.componentId, entry),
|
|
78
|
+
planned: project,
|
|
79
|
+
retainOnFailure: options.retainOnFailure
|
|
80
|
+
});
|
|
81
|
+
const abort = new AbortController();
|
|
82
|
+
const unbindSignals = signalOwnedRun(run);
|
|
83
|
+
void run.whenTerminal.then(() => abort.abort());
|
|
84
|
+
try {
|
|
85
|
+
const ready = await run.whenReady;
|
|
86
|
+
renderReady(options.io, run, ready.endpoints);
|
|
87
|
+
const summary = await runLocalDappVerifications({
|
|
88
|
+
contextRoot: PATH.join(run.stateRoot, "verification"),
|
|
89
|
+
deploymentName: project.lock.deployment.name,
|
|
90
|
+
endpoints: ready.endpoints,
|
|
91
|
+
lockId: project.lock.lockId,
|
|
92
|
+
onOutput: (output) => run.logVerificationOutput(output),
|
|
93
|
+
planId: project.lock.plan.planId,
|
|
94
|
+
project: project.project,
|
|
95
|
+
signal: abort.signal
|
|
96
|
+
});
|
|
97
|
+
for (const result of summary.results) renderEvent(options.io, `verification-${result.id}`, result);
|
|
98
|
+
return await stopAfterTest(run, summary.outcome === "failed", options.retainOnFailure);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
renderEvent(options.io, "runner", {
|
|
101
|
+
code: "cli.test-failed",
|
|
102
|
+
causeCode: error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "unknown"
|
|
103
|
+
});
|
|
104
|
+
if (options.retainOnFailure) run.retainState();
|
|
105
|
+
const terminal = await run.stop();
|
|
106
|
+
return terminal.outcome === "failed" ? terminal : { outcome: "failed" };
|
|
107
|
+
} finally {
|
|
108
|
+
unbindSignals();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function createDefaultDappCliLifecycleServices(options) {
|
|
112
|
+
return {
|
|
113
|
+
dev: async (project) => await runDev(project, options),
|
|
114
|
+
test: async (project) => await runTest(project, options)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// src/dappCli.ts
|
|
119
|
+
var DappCliExitCode = {
|
|
120
|
+
success: 0,
|
|
121
|
+
dataError: 1,
|
|
122
|
+
usageError: 2,
|
|
123
|
+
runtimeError: 3
|
|
124
|
+
};
|
|
125
|
+
var DappCliIssueCode = {
|
|
126
|
+
commandUnknown: "cli.command-unknown",
|
|
127
|
+
deploymentRequired: "cli.deployment-required",
|
|
128
|
+
deploymentUnknown: "cli.deployment-unknown",
|
|
129
|
+
lifecycleUnavailable: "cli.lifecycle-unavailable",
|
|
130
|
+
optionInvalid: "cli.option-invalid"
|
|
131
|
+
};
|
|
132
|
+
var DappCliError = class extends Error {
|
|
133
|
+
code;
|
|
134
|
+
exitCode;
|
|
135
|
+
constructor(code, message, exitCode = DappCliExitCode.usageError) {
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = "DappCliError";
|
|
138
|
+
this.code = code;
|
|
139
|
+
this.exitCode = exitCode;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var Commands = /* @__PURE__ */ new Set(["build", "dev", "init", "inspect", "plan", "test", "validate"]);
|
|
143
|
+
var ValueOptions = /* @__PURE__ */ new Set(["--catalog", "--deployment", "--manifest", "--repository"]);
|
|
144
|
+
var Help = `Usage: xl1-dapp <command> [options]
|
|
145
|
+
|
|
146
|
+
Commands:
|
|
147
|
+
init Add or verify .xl1/ repository ignore policy
|
|
148
|
+
validate Validate xl1.dapp.json and repository identity
|
|
149
|
+
inspect Render the normalized project/deployment shape
|
|
150
|
+
build Build and admit declared artifacts
|
|
151
|
+
plan Create a reproducible deployment lock
|
|
152
|
+
dev Run a planned deployment in the foreground
|
|
153
|
+
test Run a planned deployment and its verification suite
|
|
154
|
+
|
|
155
|
+
Options:
|
|
156
|
+
--repository <path> Repository root (default: current directory)
|
|
157
|
+
--manifest <path> Repository-relative manifest (default: xl1.dapp.json)
|
|
158
|
+
--deployment <name> Deployment for plan/dev/test
|
|
159
|
+
--catalog <path> Repository-relative environment catalog override
|
|
160
|
+
--json Emit canonical JSON
|
|
161
|
+
--retain-on-failure Keep isolated test state after failure
|
|
162
|
+
--help Show this help
|
|
163
|
+
`;
|
|
164
|
+
function defaultIo() {
|
|
165
|
+
return {
|
|
166
|
+
stderr: (output) => process.stderr.write(output),
|
|
167
|
+
stdout: (output) => process.stdout.write(output)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function optionValue(arguments_, index, option) {
|
|
171
|
+
const value = arguments_[index + 1];
|
|
172
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
173
|
+
throw new DappCliError(DappCliIssueCode.optionInvalid, `${option} requires one value`);
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
function isCommand(value) {
|
|
178
|
+
return typeof value === "string" && Commands.has(value);
|
|
179
|
+
}
|
|
180
|
+
function parseCommand(arguments_, cwd) {
|
|
181
|
+
if (arguments_.length === 0 || arguments_[0] === "--help" || arguments_[0] === "-h") return "help";
|
|
182
|
+
const command = arguments_[0];
|
|
183
|
+
if (!isCommand(command)) {
|
|
184
|
+
throw new DappCliError(DappCliIssueCode.commandUnknown, `unknown command ${command}`);
|
|
185
|
+
}
|
|
186
|
+
let catalog;
|
|
187
|
+
let deployment;
|
|
188
|
+
let isJson = false;
|
|
189
|
+
let manifest;
|
|
190
|
+
let retainOnFailure = false;
|
|
191
|
+
let repository = cwd;
|
|
192
|
+
for (let index = 1; index < arguments_.length; index += 1) {
|
|
193
|
+
const option = arguments_[index];
|
|
194
|
+
if (option === "--json") {
|
|
195
|
+
isJson = true;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (option === "--retain-on-failure") {
|
|
199
|
+
retainOnFailure = true;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (option === void 0 || !ValueOptions.has(option)) {
|
|
203
|
+
throw new DappCliError(DappCliIssueCode.optionInvalid, `unknown option ${String(option)}`);
|
|
204
|
+
}
|
|
205
|
+
const value = optionValue(arguments_, index, option);
|
|
206
|
+
index += 1;
|
|
207
|
+
switch (option) {
|
|
208
|
+
case "--catalog":
|
|
209
|
+
catalog = value;
|
|
210
|
+
break;
|
|
211
|
+
case "--deployment":
|
|
212
|
+
deployment = value;
|
|
213
|
+
break;
|
|
214
|
+
case "--manifest":
|
|
215
|
+
manifest = value;
|
|
216
|
+
break;
|
|
217
|
+
case "--repository":
|
|
218
|
+
repository = PATH2.resolve(cwd, value);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
...catalog === void 0 ? {} : { catalog },
|
|
224
|
+
command,
|
|
225
|
+
...deployment === void 0 ? {} : { deployment },
|
|
226
|
+
isJson,
|
|
227
|
+
...manifest === void 0 ? {} : { manifest },
|
|
228
|
+
retainOnFailure,
|
|
229
|
+
repository
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function print(io, value, isJson) {
|
|
233
|
+
const serialized = canonicalizeIJson2(value);
|
|
234
|
+
io.stdout(isJson ? `${serialized}
|
|
235
|
+
` : `${JSON.stringify(value, void 0, 2)}
|
|
236
|
+
`);
|
|
237
|
+
}
|
|
238
|
+
function projectSummary(project) {
|
|
239
|
+
return {
|
|
240
|
+
command: "validate",
|
|
241
|
+
projectId: project.manifest.projectId,
|
|
242
|
+
manifestPath: project.manifestPath,
|
|
243
|
+
packageManager: project.packageManager,
|
|
244
|
+
source: project.source
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function deploymentSummary(manifest, deploymentName) {
|
|
248
|
+
const deployment = manifest.deployments[deploymentName];
|
|
249
|
+
if (deployment === void 0) {
|
|
250
|
+
throw new DappCliError(
|
|
251
|
+
DappCliIssueCode.deploymentUnknown,
|
|
252
|
+
`deployment ${deploymentName} is not declared`,
|
|
253
|
+
DappCliExitCode.dataError
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const request = deployment.request;
|
|
257
|
+
const hosts = [.../* @__PURE__ */ new Set([
|
|
258
|
+
...request.actors.map((actor) => actor.host),
|
|
259
|
+
...request.portBindings.map((binding) => binding.host)
|
|
260
|
+
])].sort();
|
|
261
|
+
return {
|
|
262
|
+
deploymentName,
|
|
263
|
+
network: request.network,
|
|
264
|
+
supervision: request.supervision,
|
|
265
|
+
actors: request.actors.map((actor) => ({
|
|
266
|
+
executionMode: actor.executionMode,
|
|
267
|
+
host: actor.host,
|
|
268
|
+
instanceId: actor.instanceId,
|
|
269
|
+
roleId: actor.roleId
|
|
270
|
+
})),
|
|
271
|
+
hosts,
|
|
272
|
+
portBindings: request.portBindings,
|
|
273
|
+
identityBindings: request.identityBindings,
|
|
274
|
+
auxiliaryStores: request.auxiliaryStores,
|
|
275
|
+
resources: Object.entries(request.resources).map(([resourceId, resource]) => ({
|
|
276
|
+
persistence: resource.persistence,
|
|
277
|
+
provision: resource.provision,
|
|
278
|
+
resourceClass: resource.class,
|
|
279
|
+
resourceId
|
|
280
|
+
})),
|
|
281
|
+
policies: request.policies,
|
|
282
|
+
verification: request.verification.map((verification) => ({
|
|
283
|
+
evidence: verification.evidence,
|
|
284
|
+
id: verification.id,
|
|
285
|
+
package: verification.package,
|
|
286
|
+
script: verification.script
|
|
287
|
+
})),
|
|
288
|
+
absenceGuarantees: {
|
|
289
|
+
actors: request.actors.length === 0,
|
|
290
|
+
datalake: request.policies.datalake.mode === "none",
|
|
291
|
+
externalSources: request.policies.externalInteraction.mode === "none",
|
|
292
|
+
projection: request.policies.projection.profile === "none",
|
|
293
|
+
sideChannel: request.policies.sideChannel.profile === "none"
|
|
294
|
+
},
|
|
295
|
+
unresolved: {
|
|
296
|
+
artifactBuilds: Object.keys(manifest.artifacts),
|
|
297
|
+
environmentResources: Object.keys(request.resources)
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function inspectSummary(manifest, selectedDeployment) {
|
|
302
|
+
const deploymentNames = selectedDeployment === void 0 ? Object.keys(manifest.deployments) : [selectedDeployment];
|
|
303
|
+
return {
|
|
304
|
+
command: "inspect",
|
|
305
|
+
projectId: manifest.projectId,
|
|
306
|
+
definition: {
|
|
307
|
+
dappId: manifest.definition.dappId,
|
|
308
|
+
definitionVersion: manifest.definition.definitionVersion,
|
|
309
|
+
protocolVersion: manifest.definition.protocolVersion,
|
|
310
|
+
actors: manifest.definition.actors.map((actor) => actor.roleId),
|
|
311
|
+
ports: manifest.definition.ports.map((port) => port.portId),
|
|
312
|
+
durability: manifest.definition.durability
|
|
313
|
+
},
|
|
314
|
+
artifacts: Object.entries(manifest.artifacts).map(([artifactId, artifact]) => ({
|
|
315
|
+
artifactId,
|
|
316
|
+
kind: artifact.kind,
|
|
317
|
+
package: artifact.package
|
|
318
|
+
})),
|
|
319
|
+
deployments: deploymentNames.map((name) => deploymentSummary(manifest, name))
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function buildSummary(built) {
|
|
323
|
+
return {
|
|
324
|
+
command: "build",
|
|
325
|
+
projectId: built.project.manifest.projectId,
|
|
326
|
+
artifacts: built.locks
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
async function loadCatalog(command) {
|
|
330
|
+
if (command.catalog === void 0) return createDefaultLocalEnvironmentCatalog();
|
|
331
|
+
const path = await resolveRepositoryPath(command.repository, command.catalog, { kind: "file" });
|
|
332
|
+
return DappEnvironmentCatalogZod.parse(await readStrictJsonFile(path));
|
|
333
|
+
}
|
|
334
|
+
async function planned(command) {
|
|
335
|
+
if (command.deployment === void 0) {
|
|
336
|
+
throw new DappCliError(DappCliIssueCode.deploymentRequired, "--deployment is required for plan, dev, and test");
|
|
337
|
+
}
|
|
338
|
+
return await planLocalDappProject({
|
|
339
|
+
catalog: await loadCatalog(command),
|
|
340
|
+
deploymentName: command.deployment,
|
|
341
|
+
...command.manifest === void 0 ? {} : { manifestPath: command.manifest },
|
|
342
|
+
repositoryRoot: command.repository
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
async function execute(command, options, io) {
|
|
346
|
+
const projectOptions = {
|
|
347
|
+
...command.manifest === void 0 ? {} : { manifestPath: command.manifest },
|
|
348
|
+
repositoryRoot: command.repository
|
|
349
|
+
};
|
|
350
|
+
if (command.command === "validate") {
|
|
351
|
+
print(io, projectSummary(await loadDappProject(projectOptions)), command.isJson);
|
|
352
|
+
return DappCliExitCode.success;
|
|
353
|
+
}
|
|
354
|
+
if (command.command === "init") {
|
|
355
|
+
print(io, { command: "init", ...await initializeDappProject(command.repository) }, command.isJson);
|
|
356
|
+
return DappCliExitCode.success;
|
|
357
|
+
}
|
|
358
|
+
if (command.command === "inspect") {
|
|
359
|
+
const project = await loadDappProject(projectOptions);
|
|
360
|
+
print(io, inspectSummary(project.manifest, command.deployment), command.isJson);
|
|
361
|
+
return DappCliExitCode.success;
|
|
362
|
+
}
|
|
363
|
+
if (command.command === "build") {
|
|
364
|
+
const built = await buildLocalDappProjectArtifacts({
|
|
365
|
+
...projectOptions,
|
|
366
|
+
onStderr: (output) => io.stderr(output),
|
|
367
|
+
onStdout: (output) => io.stdout(output)
|
|
368
|
+
});
|
|
369
|
+
print(io, buildSummary(built), command.isJson);
|
|
370
|
+
return DappCliExitCode.success;
|
|
371
|
+
}
|
|
372
|
+
const plan = await planned(command);
|
|
373
|
+
if (command.command === "plan") {
|
|
374
|
+
print(io, { command: "plan", lock: plan.lock }, command.isJson);
|
|
375
|
+
return DappCliExitCode.success;
|
|
376
|
+
}
|
|
377
|
+
const lifecycle = options.lifecycle ?? createDefaultDappCliLifecycleServices({
|
|
378
|
+
io,
|
|
379
|
+
retainOnFailure: command.retainOnFailure
|
|
380
|
+
});
|
|
381
|
+
const result = command.command === "dev" ? await lifecycle.dev?.(plan) : await lifecycle.test?.(plan);
|
|
382
|
+
if (result === void 0) {
|
|
383
|
+
throw new DappCliError(
|
|
384
|
+
DappCliIssueCode.lifecycleUnavailable,
|
|
385
|
+
`${command.command} requires an installed local lifecycle service`,
|
|
386
|
+
DappCliExitCode.runtimeError
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
print(io, { command: command.command, outcome: result.outcome }, command.isJson);
|
|
390
|
+
return result.outcome === "stopped" ? DappCliExitCode.success : DappCliExitCode.runtimeError;
|
|
391
|
+
}
|
|
392
|
+
function errorCode(error) {
|
|
393
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "cli.internal-error";
|
|
394
|
+
}
|
|
395
|
+
async function runDappCli(arguments_, options = {}) {
|
|
396
|
+
const io = options.io ?? defaultIo();
|
|
397
|
+
try {
|
|
398
|
+
const parsed = parseCommand(arguments_, options.cwd ?? process.cwd());
|
|
399
|
+
if (parsed === "help") {
|
|
400
|
+
io.stdout(Help);
|
|
401
|
+
return DappCliExitCode.success;
|
|
402
|
+
}
|
|
403
|
+
return await execute(parsed, options, io);
|
|
404
|
+
} catch (error) {
|
|
405
|
+
const exitCode = error instanceof DappCliError ? error.exitCode : DappCliExitCode.dataError;
|
|
406
|
+
io.stderr(`${canonicalizeIJson2({
|
|
407
|
+
code: errorCode(error),
|
|
408
|
+
message: error instanceof Error ? error.message : "unknown CLI failure"
|
|
409
|
+
})}
|
|
410
|
+
`);
|
|
411
|
+
return exitCode;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/bin.ts
|
|
416
|
+
process.exitCode = await runDappCli(process.argv.slice(2));
|
|
417
|
+
//# sourceMappingURL=bin.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dappCli.ts", "../../src/defaultDappCliLifecycle.ts", "../../src/bin.ts"],
|
|
4
|
+
"sourcesContent": ["import PATH from 'node:path'\n\nimport type {\n DappEnvironmentCatalog,\n DappProjectManifest,\n} from '@xyo-network/dapp-kit'\nimport {\n canonicalizeIJson,\n DappEnvironmentCatalogZod,\n} from '@xyo-network/dapp-kit'\nimport type {\n BuiltLocalDappProjectArtifacts,\n PlannedLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport {\n buildLocalDappProjectArtifacts,\n createDefaultLocalEnvironmentCatalog,\n planLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport type { LoadedDappProject } from '@xyo-network/dapp-kit-node'\nimport {\n initializeDappProject,\n loadDappProject,\n readStrictJsonFile,\n resolveRepositoryPath,\n} from '@xyo-network/dapp-kit-node'\n\nimport { createDefaultDappCliLifecycleServices } from './defaultDappCliLifecycle.ts'\n\nexport const DappCliExitCode = {\n success: 0,\n dataError: 1,\n usageError: 2,\n runtimeError: 3,\n} as const\n\nexport type DappCliExitCode = typeof DappCliExitCode[keyof typeof DappCliExitCode]\n\nexport const DappCliIssueCode = {\n commandUnknown: 'cli.command-unknown',\n deploymentRequired: 'cli.deployment-required',\n deploymentUnknown: 'cli.deployment-unknown',\n lifecycleUnavailable: 'cli.lifecycle-unavailable',\n optionInvalid: 'cli.option-invalid',\n} as const\n\nexport type DappCliIssueCode = typeof DappCliIssueCode[keyof typeof DappCliIssueCode]\n\nexport class DappCliError extends Error {\n readonly code: DappCliIssueCode\n readonly exitCode: DappCliExitCode\n\n constructor(code: DappCliIssueCode, message: string, exitCode: DappCliExitCode = DappCliExitCode.usageError) {\n super(message)\n this.name = 'DappCliError'\n this.code = code\n this.exitCode = exitCode\n }\n}\n\nexport interface DappCliIo {\n readonly stderr: (output: string) => void\n readonly stdout: (output: string) => void\n}\n\nexport interface DappCliLifecycleResult {\n readonly outcome: 'failed' | 'stopped'\n}\n\nexport interface DappCliLifecycleServices {\n dev?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>\n test?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>\n}\n\nexport interface RunDappCliOptions {\n readonly cwd?: string\n readonly io?: DappCliIo\n readonly lifecycle?: DappCliLifecycleServices\n}\n\ninterface ParsedCommand {\n readonly catalog?: string\n readonly command: 'build' | 'dev' | 'init' | 'inspect' | 'plan' | 'test' | 'validate'\n readonly deployment?: string\n readonly isJson: boolean\n readonly manifest?: string\n readonly repository: string\n readonly retainOnFailure: boolean\n}\n\ntype DappCliCommand = ParsedCommand['command']\n\nconst Commands = new Set<DappCliCommand>(['build', 'dev', 'init', 'inspect', 'plan', 'test', 'validate'])\nconst ValueOptions = new Set(['--catalog', '--deployment', '--manifest', '--repository'])\n\nconst Help = `Usage: xl1-dapp <command> [options]\n\nCommands:\n init Add or verify .xl1/ repository ignore policy\n validate Validate xl1.dapp.json and repository identity\n inspect Render the normalized project/deployment shape\n build Build and admit declared artifacts\n plan Create a reproducible deployment lock\n dev Run a planned deployment in the foreground\n test Run a planned deployment and its verification suite\n\nOptions:\n --repository <path> Repository root (default: current directory)\n --manifest <path> Repository-relative manifest (default: xl1.dapp.json)\n --deployment <name> Deployment for plan/dev/test\n --catalog <path> Repository-relative environment catalog override\n --json Emit canonical JSON\n --retain-on-failure Keep isolated test state after failure\n --help Show this help\n`\n\nfunction defaultIo(): DappCliIo {\n return {\n stderr: output => process.stderr.write(output),\n stdout: output => process.stdout.write(output),\n }\n}\n\nfunction optionValue(arguments_: readonly string[], index: number, option: string): string {\n const value = arguments_[index + 1]\n if (value === undefined || value.startsWith('--')) {\n throw new DappCliError(DappCliIssueCode.optionInvalid, `${option} requires one value`)\n }\n return value\n}\n\nfunction isCommand(value: unknown): value is DappCliCommand {\n return typeof value === 'string' && Commands.has(value as DappCliCommand)\n}\n\nfunction parseCommand(arguments_: readonly string[], cwd: string): ParsedCommand | 'help' {\n if (arguments_.length === 0 || arguments_[0] === '--help' || arguments_[0] === '-h') return 'help'\n const command = arguments_[0]\n if (!isCommand(command)) {\n throw new DappCliError(DappCliIssueCode.commandUnknown, `unknown command ${command}`)\n }\n let catalog: string | undefined\n let deployment: string | undefined\n let isJson = false\n let manifest: string | undefined\n let retainOnFailure = false\n let repository = cwd\n for (let index = 1; index < arguments_.length; index += 1) {\n const option = arguments_[index]\n if (option === '--json') {\n isJson = true\n continue\n }\n if (option === '--retain-on-failure') {\n retainOnFailure = true\n continue\n }\n if (option === undefined || !ValueOptions.has(option)) {\n throw new DappCliError(DappCliIssueCode.optionInvalid, `unknown option ${String(option)}`)\n }\n const value = optionValue(arguments_, index, option)\n index += 1\n switch (option) {\n case '--catalog':\n catalog = value\n break\n case '--deployment':\n deployment = value\n break\n case '--manifest':\n manifest = value\n break\n case '--repository':\n repository = PATH.resolve(cwd, value)\n break\n }\n }\n return {\n ...(catalog === undefined ? {} : { catalog }),\n command,\n ...(deployment === undefined ? {} : { deployment }),\n isJson,\n ...(manifest === undefined ? {} : { manifest }),\n retainOnFailure,\n repository,\n }\n}\n\nfunction print(io: DappCliIo, value: unknown, isJson: boolean): void {\n const serialized = canonicalizeIJson(value)\n io.stdout(isJson ? `${serialized}\\n` : `${JSON.stringify(value, undefined, 2)}\\n`)\n}\n\nfunction projectSummary(project: LoadedDappProject) {\n return {\n command: 'validate',\n projectId: project.manifest.projectId,\n manifestPath: project.manifestPath,\n packageManager: project.packageManager,\n source: project.source,\n }\n}\n\nfunction deploymentSummary(\n manifest: DappProjectManifest,\n deploymentName: string,\n) {\n const deployment = manifest.deployments[deploymentName]\n if (deployment === undefined) {\n throw new DappCliError(\n DappCliIssueCode.deploymentUnknown,\n `deployment ${deploymentName} is not declared`,\n DappCliExitCode.dataError,\n )\n }\n const request = deployment.request\n const hosts = [...new Set([\n ...request.actors.map(actor => actor.host),\n ...request.portBindings.map(binding => binding.host),\n ])].sort()\n return {\n deploymentName,\n network: request.network,\n supervision: request.supervision,\n actors: request.actors.map(actor => ({\n executionMode: actor.executionMode,\n host: actor.host,\n instanceId: actor.instanceId,\n roleId: actor.roleId,\n })),\n hosts,\n portBindings: request.portBindings,\n identityBindings: request.identityBindings,\n auxiliaryStores: request.auxiliaryStores,\n resources: Object.entries(request.resources).map(([resourceId, resource]) => ({\n persistence: resource.persistence,\n provision: resource.provision,\n resourceClass: resource.class,\n resourceId,\n })),\n policies: request.policies,\n verification: request.verification.map(verification => ({\n evidence: verification.evidence,\n id: verification.id,\n package: verification.package,\n script: verification.script,\n })),\n absenceGuarantees: {\n actors: request.actors.length === 0,\n datalake: request.policies.datalake.mode === 'none',\n externalSources: request.policies.externalInteraction.mode === 'none',\n projection: request.policies.projection.profile === 'none',\n sideChannel: request.policies.sideChannel.profile === 'none',\n },\n unresolved: {\n artifactBuilds: Object.keys(manifest.artifacts),\n environmentResources: Object.keys(request.resources),\n },\n }\n}\n\nfunction inspectSummary(manifest: DappProjectManifest, selectedDeployment?: string) {\n const deploymentNames = selectedDeployment === undefined\n ? Object.keys(manifest.deployments)\n : [selectedDeployment]\n return {\n command: 'inspect',\n projectId: manifest.projectId,\n definition: {\n dappId: manifest.definition.dappId,\n definitionVersion: manifest.definition.definitionVersion,\n protocolVersion: manifest.definition.protocolVersion,\n actors: manifest.definition.actors.map(actor => actor.roleId),\n ports: manifest.definition.ports.map(port => port.portId),\n durability: manifest.definition.durability,\n },\n artifacts: Object.entries(manifest.artifacts).map(([artifactId, artifact]) => ({\n artifactId, kind: artifact.kind, package: artifact.package,\n })),\n deployments: deploymentNames.map(name => deploymentSummary(manifest, name)),\n }\n}\n\nfunction buildSummary(built: BuiltLocalDappProjectArtifacts) {\n return {\n command: 'build',\n projectId: built.project.manifest.projectId,\n artifacts: built.locks,\n }\n}\n\nasync function loadCatalog(command: ParsedCommand): Promise<DappEnvironmentCatalog> {\n if (command.catalog === undefined) return createDefaultLocalEnvironmentCatalog()\n const path = await resolveRepositoryPath(command.repository, command.catalog, { kind: 'file' })\n return DappEnvironmentCatalogZod.parse(await readStrictJsonFile(path))\n}\n\nasync function planned(command: ParsedCommand): Promise<PlannedLocalDappProject> {\n if (command.deployment === undefined) {\n throw new DappCliError(DappCliIssueCode.deploymentRequired, '--deployment is required for plan, dev, and test')\n }\n return await planLocalDappProject({\n catalog: await loadCatalog(command),\n deploymentName: command.deployment,\n ...(command.manifest === undefined ? {} : { manifestPath: command.manifest }),\n repositoryRoot: command.repository,\n })\n}\n\nasync function execute(\n command: ParsedCommand,\n options: RunDappCliOptions,\n io: DappCliIo,\n): Promise<DappCliExitCode> {\n const projectOptions = {\n ...(command.manifest === undefined ? {} : { manifestPath: command.manifest }),\n repositoryRoot: command.repository,\n }\n if (command.command === 'validate') {\n print(io, projectSummary(await loadDappProject(projectOptions)), command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'init') {\n print(io, { command: 'init', ...await initializeDappProject(command.repository) }, command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'inspect') {\n const project = await loadDappProject(projectOptions)\n print(io, inspectSummary(project.manifest, command.deployment), command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'build') {\n const built = await buildLocalDappProjectArtifacts({\n ...projectOptions,\n onStderr: output => io.stderr(output),\n onStdout: output => io.stdout(output),\n })\n print(io, buildSummary(built), command.isJson)\n return DappCliExitCode.success\n }\n const plan = await planned(command)\n if (command.command === 'plan') {\n print(io, { command: 'plan', lock: plan.lock }, command.isJson)\n return DappCliExitCode.success\n }\n const lifecycle = options.lifecycle ?? createDefaultDappCliLifecycleServices({\n io,\n retainOnFailure: command.retainOnFailure,\n })\n const result = command.command === 'dev'\n ? await lifecycle.dev?.(plan)\n : await lifecycle.test?.(plan)\n if (result === undefined) {\n throw new DappCliError(\n DappCliIssueCode.lifecycleUnavailable,\n `${command.command} requires an installed local lifecycle service`,\n DappCliExitCode.runtimeError,\n )\n }\n print(io, { command: command.command, outcome: result.outcome }, command.isJson)\n return result.outcome === 'stopped' ? DappCliExitCode.success : DappCliExitCode.runtimeError\n}\n\nfunction errorCode(error: unknown): string {\n return error instanceof Error && 'code' in error && typeof error.code === 'string'\n ? error.code\n : 'cli.internal-error'\n}\n\nexport async function runDappCli(\n arguments_: readonly string[],\n options: RunDappCliOptions = {},\n): Promise<DappCliExitCode> {\n const io = options.io ?? defaultIo()\n try {\n const parsed = parseCommand(arguments_, options.cwd ?? process.cwd())\n if (parsed === 'help') {\n io.stdout(Help)\n return DappCliExitCode.success\n }\n return await execute(parsed, options, io)\n } catch (error) {\n const exitCode = error instanceof DappCliError ? error.exitCode : DappCliExitCode.dataError\n io.stderr(`${canonicalizeIJson({\n code: errorCode(error),\n message: error instanceof Error ? error.message : 'unknown CLI failure',\n })}\\n`)\n return exitCode\n }\n}\n", "import PATH from 'node:path'\n\nimport { canonicalizeIJson } from '@xyo-network/dapp-kit'\nimport type {\n DefaultLocalDappRun,\n PlannedLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport {\n runLocalDappVerifications,\n startDefaultLocalDappRun,\n} from '@xyo-network/dapp-kit-local'\n\nimport type {\n DappCliIo,\n DappCliLifecycleResult,\n DappCliLifecycleServices,\n} from './dappCli.ts'\n\nexport interface CreateDefaultDappCliLifecycleOptions {\n readonly io: DappCliIo\n readonly retainOnFailure: boolean\n}\n\nfunction renderEvent(io: DappCliIo, componentId: string, value: unknown): void {\n io.stderr(`[${componentId}] ${canonicalizeIJson(value)}\\n`)\n}\n\nfunction signalOwnedRun(run: DefaultLocalDappRun): () => void {\n const stop = (): void => {\n void run.stop().catch(() => null)\n }\n process.once('SIGINT', stop)\n process.once('SIGTERM', stop)\n return () => {\n process.off('SIGINT', stop)\n process.off('SIGTERM', stop)\n }\n}\n\nfunction renderReady(io: DappCliIo, run: DefaultLocalDappRun, endpoints: readonly unknown[]): void {\n renderEvent(io, 'runner', {\n code: 'cli.run-ready',\n endpoints,\n runId: run.runId,\n stateRoot: run.stateRoot,\n })\n}\n\nasync function runDev(\n project: PlannedLocalDappProject,\n options: CreateDefaultDappCliLifecycleOptions,\n): Promise<DappCliLifecycleResult> {\n const run = await startDefaultLocalDappRun({\n mode: 'dev',\n onForegroundLog: entry => renderEvent(options.io, entry.componentId, entry),\n planned: project,\n })\n const unbindSignals = signalOwnedRun(run)\n try {\n try {\n const ready = await run.whenReady\n renderReady(options.io, run, ready.endpoints)\n } catch {\n // The terminal result below retains the stable startup failure.\n }\n return await run.whenTerminal\n } finally {\n unbindSignals()\n }\n}\n\nasync function stopAfterTest(\n run: DefaultLocalDappRun,\n isVerificationFailed: boolean,\n retainOnFailure: boolean,\n): Promise<DappCliLifecycleResult> {\n if (isVerificationFailed && retainOnFailure) run.retainState()\n const terminal = await run.stop()\n return terminal.outcome === 'failed' || isVerificationFailed\n ? { outcome: 'failed' }\n : { outcome: 'stopped' }\n}\n\nasync function runTest(\n project: PlannedLocalDappProject,\n options: CreateDefaultDappCliLifecycleOptions,\n): Promise<DappCliLifecycleResult> {\n const run = await startDefaultLocalDappRun({\n mode: 'test',\n onForegroundLog: entry => renderEvent(options.io, entry.componentId, entry),\n planned: project,\n retainOnFailure: options.retainOnFailure,\n })\n const abort = new AbortController()\n const unbindSignals = signalOwnedRun(run)\n void run.whenTerminal.then(() => abort.abort())\n try {\n const ready = await run.whenReady\n renderReady(options.io, run, ready.endpoints)\n const summary = await runLocalDappVerifications({\n contextRoot: PATH.join(run.stateRoot, 'verification'),\n deploymentName: project.lock.deployment.name,\n endpoints: ready.endpoints,\n lockId: project.lock.lockId,\n onOutput: output => run.logVerificationOutput(output),\n planId: project.lock.plan.planId,\n project: project.project,\n signal: abort.signal,\n })\n for (const result of summary.results) renderEvent(options.io, `verification-${result.id}`, result)\n return await stopAfterTest(run, summary.outcome === 'failed', options.retainOnFailure)\n } catch (error) {\n renderEvent(options.io, 'runner', {\n code: 'cli.test-failed',\n causeCode: error instanceof Error && 'code' in error && typeof error.code === 'string'\n ? error.code\n : 'unknown',\n })\n if (options.retainOnFailure) run.retainState()\n const terminal = await run.stop()\n return terminal.outcome === 'failed' ? terminal : { outcome: 'failed' }\n } finally {\n unbindSignals()\n }\n}\n\nexport function createDefaultDappCliLifecycleServices(\n options: CreateDefaultDappCliLifecycleOptions,\n): DappCliLifecycleServices {\n return {\n dev: async project => await runDev(project, options),\n test: async project => await runTest(project, options),\n }\n}\n", "#!/usr/bin/env node\n\nimport { runDappCli } from './dappCli.ts'\n\nprocess.exitCode = await runDappCli(process.argv.slice(2))\n"],
|
|
5
|
+
"mappings": ";;;AAAA,OAAOA,WAAU;AAMjB;AAAA,EACE,qBAAAC;AAAA,EACA;AAAA,OACK;AAKP;AAAA,EACE;AAAA,E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AEA,SAAS,UAAU,OAAwB;AACzC,SAAO,iBAAiB,SAAS,UAAU,SAAS,OAAO,MAAM,SAAS,WACtE,MAAM,OACN;AACN;AAEA,eAAsB,WACpB,YACA,UAA6B,CAAC,GACJ;AAC1B,QAAM,KAAK,QAAQ,MAAM,UAAU;AACnC,MAAI;AACF,UAAM,SAAS,aAAa,YAAY,QAAQ,OAAO,QAAQ,IAAI,CAAC;AACpE,QAAI,WAAW,QAAQ;AACrB,SAAG,OAAO,IAAI;AACd,aAAO,gBAAgB;AAAA,IACzB;AACA,WAAO,MAAM,QAAQ,QAAQ,SAAS,EAAE;AAAA,EAC1C,SAAS,OAAO;AACd,UAAM,WAAW,iBAAiB,eAAe,MAAM,WAAW,gBAAgB;AAClF,OAAG,OAAO,GAAGA,mBAAkB;AAAA,MAC7B,MAAM,UAAU,KAAK;AAAA,MACrB,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IACpD,CAAC,CAAC;AAAA,CAAI;AACN,WAAO;AAAA,EACT;AACF;;;AEjYA,QAAQ,WAAW,MAAM,WAAW,QAAQ,KAAK,MAAM,CAAC,CAAC;",
|
|
6
|
+
"names": ["PATH", "canonicalizeIJson", "PATH", "canonicalizeIJson"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PlannedLocalDappProject } from '@xyo-network/dapp-kit-local';
|
|
2
|
+
export declare const DappCliExitCode: {
|
|
3
|
+
readonly success: 0;
|
|
4
|
+
readonly dataError: 1;
|
|
5
|
+
readonly usageError: 2;
|
|
6
|
+
readonly runtimeError: 3;
|
|
7
|
+
};
|
|
8
|
+
export type DappCliExitCode = typeof DappCliExitCode[keyof typeof DappCliExitCode];
|
|
9
|
+
export declare const DappCliIssueCode: {
|
|
10
|
+
readonly commandUnknown: "cli.command-unknown";
|
|
11
|
+
readonly deploymentRequired: "cli.deployment-required";
|
|
12
|
+
readonly deploymentUnknown: "cli.deployment-unknown";
|
|
13
|
+
readonly lifecycleUnavailable: "cli.lifecycle-unavailable";
|
|
14
|
+
readonly optionInvalid: "cli.option-invalid";
|
|
15
|
+
};
|
|
16
|
+
export type DappCliIssueCode = typeof DappCliIssueCode[keyof typeof DappCliIssueCode];
|
|
17
|
+
export declare class DappCliError extends Error {
|
|
18
|
+
readonly code: DappCliIssueCode;
|
|
19
|
+
readonly exitCode: DappCliExitCode;
|
|
20
|
+
constructor(code: DappCliIssueCode, message: string, exitCode?: DappCliExitCode);
|
|
21
|
+
}
|
|
22
|
+
export interface DappCliIo {
|
|
23
|
+
readonly stderr: (output: string) => void;
|
|
24
|
+
readonly stdout: (output: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface DappCliLifecycleResult {
|
|
27
|
+
readonly outcome: 'failed' | 'stopped';
|
|
28
|
+
}
|
|
29
|
+
export interface DappCliLifecycleServices {
|
|
30
|
+
dev?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>;
|
|
31
|
+
test?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>;
|
|
32
|
+
}
|
|
33
|
+
export interface RunDappCliOptions {
|
|
34
|
+
readonly cwd?: string;
|
|
35
|
+
readonly io?: DappCliIo;
|
|
36
|
+
readonly lifecycle?: DappCliLifecycleServices;
|
|
37
|
+
}
|
|
38
|
+
export declare function runDappCli(arguments_: readonly string[], options?: RunDappCliOptions): Promise<DappCliExitCode>;
|
|
39
|
+
//# sourceMappingURL=dappCli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dappCli.d.ts","sourceRoot":"","sources":["../../src/dappCli.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,6BAA6B,CAAA;AAgBpC,eAAO,MAAM,eAAe;;;;;CAKlB,CAAA;AAEV,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAA;AAElF,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAA;AAEV,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAA;AAErF,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;gBAEtB,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,eAA4C;CAM5G;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAC1C;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,SAAS,CAAA;CACvC;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACvE,IAAI,CAAC,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACzE;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,wBAAwB,CAAA;CAC9C;AAmSD,wBAAsB,UAAU,CAC9B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,CAiB1B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DappCliIo, DappCliLifecycleServices } from './dappCli.ts';
|
|
2
|
+
export interface CreateDefaultDappCliLifecycleOptions {
|
|
3
|
+
readonly io: DappCliIo;
|
|
4
|
+
readonly retainOnFailure: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function createDefaultDappCliLifecycleServices(options: CreateDefaultDappCliLifecycleOptions): DappCliLifecycleServices;
|
|
7
|
+
//# sourceMappingURL=defaultDappCliLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultDappCliLifecycle.d.ts","sourceRoot":"","sources":["../../src/defaultDappCliLifecycle.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,SAAS,EAET,wBAAwB,EACzB,MAAM,cAAc,CAAA;AAErB,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;IACtB,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAyGD,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,oCAAoC,GAC5C,wBAAwB,CAK1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,8BAA8B,CAAA"}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
// src/dappCli.ts
|
|
2
|
+
import PATH2 from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
canonicalizeIJson as canonicalizeIJson2,
|
|
5
|
+
DappEnvironmentCatalogZod
|
|
6
|
+
} from "@xyo-network/dapp-kit";
|
|
7
|
+
import {
|
|
8
|
+
buildLocalDappProjectArtifacts,
|
|
9
|
+
createDefaultLocalEnvironmentCatalog,
|
|
10
|
+
planLocalDappProject
|
|
11
|
+
} from "@xyo-network/dapp-kit-local";
|
|
12
|
+
import {
|
|
13
|
+
initializeDappProject,
|
|
14
|
+
loadDappProject,
|
|
15
|
+
readStrictJsonFile,
|
|
16
|
+
resolveRepositoryPath
|
|
17
|
+
} from "@xyo-network/dapp-kit-node";
|
|
18
|
+
|
|
19
|
+
// src/defaultDappCliLifecycle.ts
|
|
20
|
+
import PATH from "node:path";
|
|
21
|
+
import { canonicalizeIJson } from "@xyo-network/dapp-kit";
|
|
22
|
+
import {
|
|
23
|
+
runLocalDappVerifications,
|
|
24
|
+
startDefaultLocalDappRun
|
|
25
|
+
} from "@xyo-network/dapp-kit-local";
|
|
26
|
+
function renderEvent(io, componentId, value) {
|
|
27
|
+
io.stderr(`[${componentId}] ${canonicalizeIJson(value)}
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
function signalOwnedRun(run) {
|
|
31
|
+
const stop = () => {
|
|
32
|
+
void run.stop().catch(() => null);
|
|
33
|
+
};
|
|
34
|
+
process.once("SIGINT", stop);
|
|
35
|
+
process.once("SIGTERM", stop);
|
|
36
|
+
return () => {
|
|
37
|
+
process.off("SIGINT", stop);
|
|
38
|
+
process.off("SIGTERM", stop);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function renderReady(io, run, endpoints) {
|
|
42
|
+
renderEvent(io, "runner", {
|
|
43
|
+
code: "cli.run-ready",
|
|
44
|
+
endpoints,
|
|
45
|
+
runId: run.runId,
|
|
46
|
+
stateRoot: run.stateRoot
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function runDev(project, options) {
|
|
50
|
+
const run = await startDefaultLocalDappRun({
|
|
51
|
+
mode: "dev",
|
|
52
|
+
onForegroundLog: (entry) => renderEvent(options.io, entry.componentId, entry),
|
|
53
|
+
planned: project
|
|
54
|
+
});
|
|
55
|
+
const unbindSignals = signalOwnedRun(run);
|
|
56
|
+
try {
|
|
57
|
+
try {
|
|
58
|
+
const ready = await run.whenReady;
|
|
59
|
+
renderReady(options.io, run, ready.endpoints);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
return await run.whenTerminal;
|
|
63
|
+
} finally {
|
|
64
|
+
unbindSignals();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function stopAfterTest(run, isVerificationFailed, retainOnFailure) {
|
|
68
|
+
if (isVerificationFailed && retainOnFailure) run.retainState();
|
|
69
|
+
const terminal = await run.stop();
|
|
70
|
+
return terminal.outcome === "failed" || isVerificationFailed ? { outcome: "failed" } : { outcome: "stopped" };
|
|
71
|
+
}
|
|
72
|
+
async function runTest(project, options) {
|
|
73
|
+
const run = await startDefaultLocalDappRun({
|
|
74
|
+
mode: "test",
|
|
75
|
+
onForegroundLog: (entry) => renderEvent(options.io, entry.componentId, entry),
|
|
76
|
+
planned: project,
|
|
77
|
+
retainOnFailure: options.retainOnFailure
|
|
78
|
+
});
|
|
79
|
+
const abort = new AbortController();
|
|
80
|
+
const unbindSignals = signalOwnedRun(run);
|
|
81
|
+
void run.whenTerminal.then(() => abort.abort());
|
|
82
|
+
try {
|
|
83
|
+
const ready = await run.whenReady;
|
|
84
|
+
renderReady(options.io, run, ready.endpoints);
|
|
85
|
+
const summary = await runLocalDappVerifications({
|
|
86
|
+
contextRoot: PATH.join(run.stateRoot, "verification"),
|
|
87
|
+
deploymentName: project.lock.deployment.name,
|
|
88
|
+
endpoints: ready.endpoints,
|
|
89
|
+
lockId: project.lock.lockId,
|
|
90
|
+
onOutput: (output) => run.logVerificationOutput(output),
|
|
91
|
+
planId: project.lock.plan.planId,
|
|
92
|
+
project: project.project,
|
|
93
|
+
signal: abort.signal
|
|
94
|
+
});
|
|
95
|
+
for (const result of summary.results) renderEvent(options.io, `verification-${result.id}`, result);
|
|
96
|
+
return await stopAfterTest(run, summary.outcome === "failed", options.retainOnFailure);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
renderEvent(options.io, "runner", {
|
|
99
|
+
code: "cli.test-failed",
|
|
100
|
+
causeCode: error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "unknown"
|
|
101
|
+
});
|
|
102
|
+
if (options.retainOnFailure) run.retainState();
|
|
103
|
+
const terminal = await run.stop();
|
|
104
|
+
return terminal.outcome === "failed" ? terminal : { outcome: "failed" };
|
|
105
|
+
} finally {
|
|
106
|
+
unbindSignals();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function createDefaultDappCliLifecycleServices(options) {
|
|
110
|
+
return {
|
|
111
|
+
dev: async (project) => await runDev(project, options),
|
|
112
|
+
test: async (project) => await runTest(project, options)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/dappCli.ts
|
|
117
|
+
var DappCliExitCode = {
|
|
118
|
+
success: 0,
|
|
119
|
+
dataError: 1,
|
|
120
|
+
usageError: 2,
|
|
121
|
+
runtimeError: 3
|
|
122
|
+
};
|
|
123
|
+
var DappCliIssueCode = {
|
|
124
|
+
commandUnknown: "cli.command-unknown",
|
|
125
|
+
deploymentRequired: "cli.deployment-required",
|
|
126
|
+
deploymentUnknown: "cli.deployment-unknown",
|
|
127
|
+
lifecycleUnavailable: "cli.lifecycle-unavailable",
|
|
128
|
+
optionInvalid: "cli.option-invalid"
|
|
129
|
+
};
|
|
130
|
+
var DappCliError = class extends Error {
|
|
131
|
+
code;
|
|
132
|
+
exitCode;
|
|
133
|
+
constructor(code, message, exitCode = DappCliExitCode.usageError) {
|
|
134
|
+
super(message);
|
|
135
|
+
this.name = "DappCliError";
|
|
136
|
+
this.code = code;
|
|
137
|
+
this.exitCode = exitCode;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var Commands = /* @__PURE__ */ new Set(["build", "dev", "init", "inspect", "plan", "test", "validate"]);
|
|
141
|
+
var ValueOptions = /* @__PURE__ */ new Set(["--catalog", "--deployment", "--manifest", "--repository"]);
|
|
142
|
+
var Help = `Usage: xl1-dapp <command> [options]
|
|
143
|
+
|
|
144
|
+
Commands:
|
|
145
|
+
init Add or verify .xl1/ repository ignore policy
|
|
146
|
+
validate Validate xl1.dapp.json and repository identity
|
|
147
|
+
inspect Render the normalized project/deployment shape
|
|
148
|
+
build Build and admit declared artifacts
|
|
149
|
+
plan Create a reproducible deployment lock
|
|
150
|
+
dev Run a planned deployment in the foreground
|
|
151
|
+
test Run a planned deployment and its verification suite
|
|
152
|
+
|
|
153
|
+
Options:
|
|
154
|
+
--repository <path> Repository root (default: current directory)
|
|
155
|
+
--manifest <path> Repository-relative manifest (default: xl1.dapp.json)
|
|
156
|
+
--deployment <name> Deployment for plan/dev/test
|
|
157
|
+
--catalog <path> Repository-relative environment catalog override
|
|
158
|
+
--json Emit canonical JSON
|
|
159
|
+
--retain-on-failure Keep isolated test state after failure
|
|
160
|
+
--help Show this help
|
|
161
|
+
`;
|
|
162
|
+
function defaultIo() {
|
|
163
|
+
return {
|
|
164
|
+
stderr: (output) => process.stderr.write(output),
|
|
165
|
+
stdout: (output) => process.stdout.write(output)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function optionValue(arguments_, index, option) {
|
|
169
|
+
const value = arguments_[index + 1];
|
|
170
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
171
|
+
throw new DappCliError(DappCliIssueCode.optionInvalid, `${option} requires one value`);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
function isCommand(value) {
|
|
176
|
+
return typeof value === "string" && Commands.has(value);
|
|
177
|
+
}
|
|
178
|
+
function parseCommand(arguments_, cwd) {
|
|
179
|
+
if (arguments_.length === 0 || arguments_[0] === "--help" || arguments_[0] === "-h") return "help";
|
|
180
|
+
const command = arguments_[0];
|
|
181
|
+
if (!isCommand(command)) {
|
|
182
|
+
throw new DappCliError(DappCliIssueCode.commandUnknown, `unknown command ${command}`);
|
|
183
|
+
}
|
|
184
|
+
let catalog;
|
|
185
|
+
let deployment;
|
|
186
|
+
let isJson = false;
|
|
187
|
+
let manifest;
|
|
188
|
+
let retainOnFailure = false;
|
|
189
|
+
let repository = cwd;
|
|
190
|
+
for (let index = 1; index < arguments_.length; index += 1) {
|
|
191
|
+
const option = arguments_[index];
|
|
192
|
+
if (option === "--json") {
|
|
193
|
+
isJson = true;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (option === "--retain-on-failure") {
|
|
197
|
+
retainOnFailure = true;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (option === void 0 || !ValueOptions.has(option)) {
|
|
201
|
+
throw new DappCliError(DappCliIssueCode.optionInvalid, `unknown option ${String(option)}`);
|
|
202
|
+
}
|
|
203
|
+
const value = optionValue(arguments_, index, option);
|
|
204
|
+
index += 1;
|
|
205
|
+
switch (option) {
|
|
206
|
+
case "--catalog":
|
|
207
|
+
catalog = value;
|
|
208
|
+
break;
|
|
209
|
+
case "--deployment":
|
|
210
|
+
deployment = value;
|
|
211
|
+
break;
|
|
212
|
+
case "--manifest":
|
|
213
|
+
manifest = value;
|
|
214
|
+
break;
|
|
215
|
+
case "--repository":
|
|
216
|
+
repository = PATH2.resolve(cwd, value);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
...catalog === void 0 ? {} : { catalog },
|
|
222
|
+
command,
|
|
223
|
+
...deployment === void 0 ? {} : { deployment },
|
|
224
|
+
isJson,
|
|
225
|
+
...manifest === void 0 ? {} : { manifest },
|
|
226
|
+
retainOnFailure,
|
|
227
|
+
repository
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function print(io, value, isJson) {
|
|
231
|
+
const serialized = canonicalizeIJson2(value);
|
|
232
|
+
io.stdout(isJson ? `${serialized}
|
|
233
|
+
` : `${JSON.stringify(value, void 0, 2)}
|
|
234
|
+
`);
|
|
235
|
+
}
|
|
236
|
+
function projectSummary(project) {
|
|
237
|
+
return {
|
|
238
|
+
command: "validate",
|
|
239
|
+
projectId: project.manifest.projectId,
|
|
240
|
+
manifestPath: project.manifestPath,
|
|
241
|
+
packageManager: project.packageManager,
|
|
242
|
+
source: project.source
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function deploymentSummary(manifest, deploymentName) {
|
|
246
|
+
const deployment = manifest.deployments[deploymentName];
|
|
247
|
+
if (deployment === void 0) {
|
|
248
|
+
throw new DappCliError(
|
|
249
|
+
DappCliIssueCode.deploymentUnknown,
|
|
250
|
+
`deployment ${deploymentName} is not declared`,
|
|
251
|
+
DappCliExitCode.dataError
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const request = deployment.request;
|
|
255
|
+
const hosts = [.../* @__PURE__ */ new Set([
|
|
256
|
+
...request.actors.map((actor) => actor.host),
|
|
257
|
+
...request.portBindings.map((binding) => binding.host)
|
|
258
|
+
])].sort();
|
|
259
|
+
return {
|
|
260
|
+
deploymentName,
|
|
261
|
+
network: request.network,
|
|
262
|
+
supervision: request.supervision,
|
|
263
|
+
actors: request.actors.map((actor) => ({
|
|
264
|
+
executionMode: actor.executionMode,
|
|
265
|
+
host: actor.host,
|
|
266
|
+
instanceId: actor.instanceId,
|
|
267
|
+
roleId: actor.roleId
|
|
268
|
+
})),
|
|
269
|
+
hosts,
|
|
270
|
+
portBindings: request.portBindings,
|
|
271
|
+
identityBindings: request.identityBindings,
|
|
272
|
+
auxiliaryStores: request.auxiliaryStores,
|
|
273
|
+
resources: Object.entries(request.resources).map(([resourceId, resource]) => ({
|
|
274
|
+
persistence: resource.persistence,
|
|
275
|
+
provision: resource.provision,
|
|
276
|
+
resourceClass: resource.class,
|
|
277
|
+
resourceId
|
|
278
|
+
})),
|
|
279
|
+
policies: request.policies,
|
|
280
|
+
verification: request.verification.map((verification) => ({
|
|
281
|
+
evidence: verification.evidence,
|
|
282
|
+
id: verification.id,
|
|
283
|
+
package: verification.package,
|
|
284
|
+
script: verification.script
|
|
285
|
+
})),
|
|
286
|
+
absenceGuarantees: {
|
|
287
|
+
actors: request.actors.length === 0,
|
|
288
|
+
datalake: request.policies.datalake.mode === "none",
|
|
289
|
+
externalSources: request.policies.externalInteraction.mode === "none",
|
|
290
|
+
projection: request.policies.projection.profile === "none",
|
|
291
|
+
sideChannel: request.policies.sideChannel.profile === "none"
|
|
292
|
+
},
|
|
293
|
+
unresolved: {
|
|
294
|
+
artifactBuilds: Object.keys(manifest.artifacts),
|
|
295
|
+
environmentResources: Object.keys(request.resources)
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function inspectSummary(manifest, selectedDeployment) {
|
|
300
|
+
const deploymentNames = selectedDeployment === void 0 ? Object.keys(manifest.deployments) : [selectedDeployment];
|
|
301
|
+
return {
|
|
302
|
+
command: "inspect",
|
|
303
|
+
projectId: manifest.projectId,
|
|
304
|
+
definition: {
|
|
305
|
+
dappId: manifest.definition.dappId,
|
|
306
|
+
definitionVersion: manifest.definition.definitionVersion,
|
|
307
|
+
protocolVersion: manifest.definition.protocolVersion,
|
|
308
|
+
actors: manifest.definition.actors.map((actor) => actor.roleId),
|
|
309
|
+
ports: manifest.definition.ports.map((port) => port.portId),
|
|
310
|
+
durability: manifest.definition.durability
|
|
311
|
+
},
|
|
312
|
+
artifacts: Object.entries(manifest.artifacts).map(([artifactId, artifact]) => ({
|
|
313
|
+
artifactId,
|
|
314
|
+
kind: artifact.kind,
|
|
315
|
+
package: artifact.package
|
|
316
|
+
})),
|
|
317
|
+
deployments: deploymentNames.map((name) => deploymentSummary(manifest, name))
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function buildSummary(built) {
|
|
321
|
+
return {
|
|
322
|
+
command: "build",
|
|
323
|
+
projectId: built.project.manifest.projectId,
|
|
324
|
+
artifacts: built.locks
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
async function loadCatalog(command) {
|
|
328
|
+
if (command.catalog === void 0) return createDefaultLocalEnvironmentCatalog();
|
|
329
|
+
const path = await resolveRepositoryPath(command.repository, command.catalog, { kind: "file" });
|
|
330
|
+
return DappEnvironmentCatalogZod.parse(await readStrictJsonFile(path));
|
|
331
|
+
}
|
|
332
|
+
async function planned(command) {
|
|
333
|
+
if (command.deployment === void 0) {
|
|
334
|
+
throw new DappCliError(DappCliIssueCode.deploymentRequired, "--deployment is required for plan, dev, and test");
|
|
335
|
+
}
|
|
336
|
+
return await planLocalDappProject({
|
|
337
|
+
catalog: await loadCatalog(command),
|
|
338
|
+
deploymentName: command.deployment,
|
|
339
|
+
...command.manifest === void 0 ? {} : { manifestPath: command.manifest },
|
|
340
|
+
repositoryRoot: command.repository
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
async function execute(command, options, io) {
|
|
344
|
+
const projectOptions = {
|
|
345
|
+
...command.manifest === void 0 ? {} : { manifestPath: command.manifest },
|
|
346
|
+
repositoryRoot: command.repository
|
|
347
|
+
};
|
|
348
|
+
if (command.command === "validate") {
|
|
349
|
+
print(io, projectSummary(await loadDappProject(projectOptions)), command.isJson);
|
|
350
|
+
return DappCliExitCode.success;
|
|
351
|
+
}
|
|
352
|
+
if (command.command === "init") {
|
|
353
|
+
print(io, { command: "init", ...await initializeDappProject(command.repository) }, command.isJson);
|
|
354
|
+
return DappCliExitCode.success;
|
|
355
|
+
}
|
|
356
|
+
if (command.command === "inspect") {
|
|
357
|
+
const project = await loadDappProject(projectOptions);
|
|
358
|
+
print(io, inspectSummary(project.manifest, command.deployment), command.isJson);
|
|
359
|
+
return DappCliExitCode.success;
|
|
360
|
+
}
|
|
361
|
+
if (command.command === "build") {
|
|
362
|
+
const built = await buildLocalDappProjectArtifacts({
|
|
363
|
+
...projectOptions,
|
|
364
|
+
onStderr: (output) => io.stderr(output),
|
|
365
|
+
onStdout: (output) => io.stdout(output)
|
|
366
|
+
});
|
|
367
|
+
print(io, buildSummary(built), command.isJson);
|
|
368
|
+
return DappCliExitCode.success;
|
|
369
|
+
}
|
|
370
|
+
const plan = await planned(command);
|
|
371
|
+
if (command.command === "plan") {
|
|
372
|
+
print(io, { command: "plan", lock: plan.lock }, command.isJson);
|
|
373
|
+
return DappCliExitCode.success;
|
|
374
|
+
}
|
|
375
|
+
const lifecycle = options.lifecycle ?? createDefaultDappCliLifecycleServices({
|
|
376
|
+
io,
|
|
377
|
+
retainOnFailure: command.retainOnFailure
|
|
378
|
+
});
|
|
379
|
+
const result = command.command === "dev" ? await lifecycle.dev?.(plan) : await lifecycle.test?.(plan);
|
|
380
|
+
if (result === void 0) {
|
|
381
|
+
throw new DappCliError(
|
|
382
|
+
DappCliIssueCode.lifecycleUnavailable,
|
|
383
|
+
`${command.command} requires an installed local lifecycle service`,
|
|
384
|
+
DappCliExitCode.runtimeError
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
print(io, { command: command.command, outcome: result.outcome }, command.isJson);
|
|
388
|
+
return result.outcome === "stopped" ? DappCliExitCode.success : DappCliExitCode.runtimeError;
|
|
389
|
+
}
|
|
390
|
+
function errorCode(error) {
|
|
391
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "cli.internal-error";
|
|
392
|
+
}
|
|
393
|
+
async function runDappCli(arguments_, options = {}) {
|
|
394
|
+
const io = options.io ?? defaultIo();
|
|
395
|
+
try {
|
|
396
|
+
const parsed = parseCommand(arguments_, options.cwd ?? process.cwd());
|
|
397
|
+
if (parsed === "help") {
|
|
398
|
+
io.stdout(Help);
|
|
399
|
+
return DappCliExitCode.success;
|
|
400
|
+
}
|
|
401
|
+
return await execute(parsed, options, io);
|
|
402
|
+
} catch (error) {
|
|
403
|
+
const exitCode = error instanceof DappCliError ? error.exitCode : DappCliExitCode.dataError;
|
|
404
|
+
io.stderr(`${canonicalizeIJson2({
|
|
405
|
+
code: errorCode(error),
|
|
406
|
+
message: error instanceof Error ? error.message : "unknown CLI failure"
|
|
407
|
+
})}
|
|
408
|
+
`);
|
|
409
|
+
return exitCode;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
export {
|
|
413
|
+
DappCliError,
|
|
414
|
+
DappCliExitCode,
|
|
415
|
+
DappCliIssueCode,
|
|
416
|
+
createDefaultDappCliLifecycleServices,
|
|
417
|
+
runDappCli
|
|
418
|
+
};
|
|
419
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dappCli.ts", "../../src/defaultDappCliLifecycle.ts"],
|
|
4
|
+
"sourcesContent": ["import PATH from 'node:path'\n\nimport type {\n DappEnvironmentCatalog,\n DappProjectManifest,\n} from '@xyo-network/dapp-kit'\nimport {\n canonicalizeIJson,\n DappEnvironmentCatalogZod,\n} from '@xyo-network/dapp-kit'\nimport type {\n BuiltLocalDappProjectArtifacts,\n PlannedLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport {\n buildLocalDappProjectArtifacts,\n createDefaultLocalEnvironmentCatalog,\n planLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport type { LoadedDappProject } from '@xyo-network/dapp-kit-node'\nimport {\n initializeDappProject,\n loadDappProject,\n readStrictJsonFile,\n resolveRepositoryPath,\n} from '@xyo-network/dapp-kit-node'\n\nimport { createDefaultDappCliLifecycleServices } from './defaultDappCliLifecycle.ts'\n\nexport const DappCliExitCode = {\n success: 0,\n dataError: 1,\n usageError: 2,\n runtimeError: 3,\n} as const\n\nexport type DappCliExitCode = typeof DappCliExitCode[keyof typeof DappCliExitCode]\n\nexport const DappCliIssueCode = {\n commandUnknown: 'cli.command-unknown',\n deploymentRequired: 'cli.deployment-required',\n deploymentUnknown: 'cli.deployment-unknown',\n lifecycleUnavailable: 'cli.lifecycle-unavailable',\n optionInvalid: 'cli.option-invalid',\n} as const\n\nexport type DappCliIssueCode = typeof DappCliIssueCode[keyof typeof DappCliIssueCode]\n\nexport class DappCliError extends Error {\n readonly code: DappCliIssueCode\n readonly exitCode: DappCliExitCode\n\n constructor(code: DappCliIssueCode, message: string, exitCode: DappCliExitCode = DappCliExitCode.usageError) {\n super(message)\n this.name = 'DappCliError'\n this.code = code\n this.exitCode = exitCode\n }\n}\n\nexport interface DappCliIo {\n readonly stderr: (output: string) => void\n readonly stdout: (output: string) => void\n}\n\nexport interface DappCliLifecycleResult {\n readonly outcome: 'failed' | 'stopped'\n}\n\nexport interface DappCliLifecycleServices {\n dev?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>\n test?(project: PlannedLocalDappProject): Promise<DappCliLifecycleResult>\n}\n\nexport interface RunDappCliOptions {\n readonly cwd?: string\n readonly io?: DappCliIo\n readonly lifecycle?: DappCliLifecycleServices\n}\n\ninterface ParsedCommand {\n readonly catalog?: string\n readonly command: 'build' | 'dev' | 'init' | 'inspect' | 'plan' | 'test' | 'validate'\n readonly deployment?: string\n readonly isJson: boolean\n readonly manifest?: string\n readonly repository: string\n readonly retainOnFailure: boolean\n}\n\ntype DappCliCommand = ParsedCommand['command']\n\nconst Commands = new Set<DappCliCommand>(['build', 'dev', 'init', 'inspect', 'plan', 'test', 'validate'])\nconst ValueOptions = new Set(['--catalog', '--deployment', '--manifest', '--repository'])\n\nconst Help = `Usage: xl1-dapp <command> [options]\n\nCommands:\n init Add or verify .xl1/ repository ignore policy\n validate Validate xl1.dapp.json and repository identity\n inspect Render the normalized project/deployment shape\n build Build and admit declared artifacts\n plan Create a reproducible deployment lock\n dev Run a planned deployment in the foreground\n test Run a planned deployment and its verification suite\n\nOptions:\n --repository <path> Repository root (default: current directory)\n --manifest <path> Repository-relative manifest (default: xl1.dapp.json)\n --deployment <name> Deployment for plan/dev/test\n --catalog <path> Repository-relative environment catalog override\n --json Emit canonical JSON\n --retain-on-failure Keep isolated test state after failure\n --help Show this help\n`\n\nfunction defaultIo(): DappCliIo {\n return {\n stderr: output => process.stderr.write(output),\n stdout: output => process.stdout.write(output),\n }\n}\n\nfunction optionValue(arguments_: readonly string[], index: number, option: string): string {\n const value = arguments_[index + 1]\n if (value === undefined || value.startsWith('--')) {\n throw new DappCliError(DappCliIssueCode.optionInvalid, `${option} requires one value`)\n }\n return value\n}\n\nfunction isCommand(value: unknown): value is DappCliCommand {\n return typeof value === 'string' && Commands.has(value as DappCliCommand)\n}\n\nfunction parseCommand(arguments_: readonly string[], cwd: string): ParsedCommand | 'help' {\n if (arguments_.length === 0 || arguments_[0] === '--help' || arguments_[0] === '-h') return 'help'\n const command = arguments_[0]\n if (!isCommand(command)) {\n throw new DappCliError(DappCliIssueCode.commandUnknown, `unknown command ${command}`)\n }\n let catalog: string | undefined\n let deployment: string | undefined\n let isJson = false\n let manifest: string | undefined\n let retainOnFailure = false\n let repository = cwd\n for (let index = 1; index < arguments_.length; index += 1) {\n const option = arguments_[index]\n if (option === '--json') {\n isJson = true\n continue\n }\n if (option === '--retain-on-failure') {\n retainOnFailure = true\n continue\n }\n if (option === undefined || !ValueOptions.has(option)) {\n throw new DappCliError(DappCliIssueCode.optionInvalid, `unknown option ${String(option)}`)\n }\n const value = optionValue(arguments_, index, option)\n index += 1\n switch (option) {\n case '--catalog':\n catalog = value\n break\n case '--deployment':\n deployment = value\n break\n case '--manifest':\n manifest = value\n break\n case '--repository':\n repository = PATH.resolve(cwd, value)\n break\n }\n }\n return {\n ...(catalog === undefined ? {} : { catalog }),\n command,\n ...(deployment === undefined ? {} : { deployment }),\n isJson,\n ...(manifest === undefined ? {} : { manifest }),\n retainOnFailure,\n repository,\n }\n}\n\nfunction print(io: DappCliIo, value: unknown, isJson: boolean): void {\n const serialized = canonicalizeIJson(value)\n io.stdout(isJson ? `${serialized}\\n` : `${JSON.stringify(value, undefined, 2)}\\n`)\n}\n\nfunction projectSummary(project: LoadedDappProject) {\n return {\n command: 'validate',\n projectId: project.manifest.projectId,\n manifestPath: project.manifestPath,\n packageManager: project.packageManager,\n source: project.source,\n }\n}\n\nfunction deploymentSummary(\n manifest: DappProjectManifest,\n deploymentName: string,\n) {\n const deployment = manifest.deployments[deploymentName]\n if (deployment === undefined) {\n throw new DappCliError(\n DappCliIssueCode.deploymentUnknown,\n `deployment ${deploymentName} is not declared`,\n DappCliExitCode.dataError,\n )\n }\n const request = deployment.request\n const hosts = [...new Set([\n ...request.actors.map(actor => actor.host),\n ...request.portBindings.map(binding => binding.host),\n ])].sort()\n return {\n deploymentName,\n network: request.network,\n supervision: request.supervision,\n actors: request.actors.map(actor => ({\n executionMode: actor.executionMode,\n host: actor.host,\n instanceId: actor.instanceId,\n roleId: actor.roleId,\n })),\n hosts,\n portBindings: request.portBindings,\n identityBindings: request.identityBindings,\n auxiliaryStores: request.auxiliaryStores,\n resources: Object.entries(request.resources).map(([resourceId, resource]) => ({\n persistence: resource.persistence,\n provision: resource.provision,\n resourceClass: resource.class,\n resourceId,\n })),\n policies: request.policies,\n verification: request.verification.map(verification => ({\n evidence: verification.evidence,\n id: verification.id,\n package: verification.package,\n script: verification.script,\n })),\n absenceGuarantees: {\n actors: request.actors.length === 0,\n datalake: request.policies.datalake.mode === 'none',\n externalSources: request.policies.externalInteraction.mode === 'none',\n projection: request.policies.projection.profile === 'none',\n sideChannel: request.policies.sideChannel.profile === 'none',\n },\n unresolved: {\n artifactBuilds: Object.keys(manifest.artifacts),\n environmentResources: Object.keys(request.resources),\n },\n }\n}\n\nfunction inspectSummary(manifest: DappProjectManifest, selectedDeployment?: string) {\n const deploymentNames = selectedDeployment === undefined\n ? Object.keys(manifest.deployments)\n : [selectedDeployment]\n return {\n command: 'inspect',\n projectId: manifest.projectId,\n definition: {\n dappId: manifest.definition.dappId,\n definitionVersion: manifest.definition.definitionVersion,\n protocolVersion: manifest.definition.protocolVersion,\n actors: manifest.definition.actors.map(actor => actor.roleId),\n ports: manifest.definition.ports.map(port => port.portId),\n durability: manifest.definition.durability,\n },\n artifacts: Object.entries(manifest.artifacts).map(([artifactId, artifact]) => ({\n artifactId, kind: artifact.kind, package: artifact.package,\n })),\n deployments: deploymentNames.map(name => deploymentSummary(manifest, name)),\n }\n}\n\nfunction buildSummary(built: BuiltLocalDappProjectArtifacts) {\n return {\n command: 'build',\n projectId: built.project.manifest.projectId,\n artifacts: built.locks,\n }\n}\n\nasync function loadCatalog(command: ParsedCommand): Promise<DappEnvironmentCatalog> {\n if (command.catalog === undefined) return createDefaultLocalEnvironmentCatalog()\n const path = await resolveRepositoryPath(command.repository, command.catalog, { kind: 'file' })\n return DappEnvironmentCatalogZod.parse(await readStrictJsonFile(path))\n}\n\nasync function planned(command: ParsedCommand): Promise<PlannedLocalDappProject> {\n if (command.deployment === undefined) {\n throw new DappCliError(DappCliIssueCode.deploymentRequired, '--deployment is required for plan, dev, and test')\n }\n return await planLocalDappProject({\n catalog: await loadCatalog(command),\n deploymentName: command.deployment,\n ...(command.manifest === undefined ? {} : { manifestPath: command.manifest }),\n repositoryRoot: command.repository,\n })\n}\n\nasync function execute(\n command: ParsedCommand,\n options: RunDappCliOptions,\n io: DappCliIo,\n): Promise<DappCliExitCode> {\n const projectOptions = {\n ...(command.manifest === undefined ? {} : { manifestPath: command.manifest }),\n repositoryRoot: command.repository,\n }\n if (command.command === 'validate') {\n print(io, projectSummary(await loadDappProject(projectOptions)), command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'init') {\n print(io, { command: 'init', ...await initializeDappProject(command.repository) }, command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'inspect') {\n const project = await loadDappProject(projectOptions)\n print(io, inspectSummary(project.manifest, command.deployment), command.isJson)\n return DappCliExitCode.success\n }\n if (command.command === 'build') {\n const built = await buildLocalDappProjectArtifacts({\n ...projectOptions,\n onStderr: output => io.stderr(output),\n onStdout: output => io.stdout(output),\n })\n print(io, buildSummary(built), command.isJson)\n return DappCliExitCode.success\n }\n const plan = await planned(command)\n if (command.command === 'plan') {\n print(io, { command: 'plan', lock: plan.lock }, command.isJson)\n return DappCliExitCode.success\n }\n const lifecycle = options.lifecycle ?? createDefaultDappCliLifecycleServices({\n io,\n retainOnFailure: command.retainOnFailure,\n })\n const result = command.command === 'dev'\n ? await lifecycle.dev?.(plan)\n : await lifecycle.test?.(plan)\n if (result === undefined) {\n throw new DappCliError(\n DappCliIssueCode.lifecycleUnavailable,\n `${command.command} requires an installed local lifecycle service`,\n DappCliExitCode.runtimeError,\n )\n }\n print(io, { command: command.command, outcome: result.outcome }, command.isJson)\n return result.outcome === 'stopped' ? DappCliExitCode.success : DappCliExitCode.runtimeError\n}\n\nfunction errorCode(error: unknown): string {\n return error instanceof Error && 'code' in error && typeof error.code === 'string'\n ? error.code\n : 'cli.internal-error'\n}\n\nexport async function runDappCli(\n arguments_: readonly string[],\n options: RunDappCliOptions = {},\n): Promise<DappCliExitCode> {\n const io = options.io ?? defaultIo()\n try {\n const parsed = parseCommand(arguments_, options.cwd ?? process.cwd())\n if (parsed === 'help') {\n io.stdout(Help)\n return DappCliExitCode.success\n }\n return await execute(parsed, options, io)\n } catch (error) {\n const exitCode = error instanceof DappCliError ? error.exitCode : DappCliExitCode.dataError\n io.stderr(`${canonicalizeIJson({\n code: errorCode(error),\n message: error instanceof Error ? error.message : 'unknown CLI failure',\n })}\\n`)\n return exitCode\n }\n}\n", "import PATH from 'node:path'\n\nimport { canonicalizeIJson } from '@xyo-network/dapp-kit'\nimport type {\n DefaultLocalDappRun,\n PlannedLocalDappProject,\n} from '@xyo-network/dapp-kit-local'\nimport {\n runLocalDappVerifications,\n startDefaultLocalDappRun,\n} from '@xyo-network/dapp-kit-local'\n\nimport type {\n DappCliIo,\n DappCliLifecycleResult,\n DappCliLifecycleServices,\n} from './dappCli.ts'\n\nexport interface CreateDefaultDappCliLifecycleOptions {\n readonly io: DappCliIo\n readonly retainOnFailure: boolean\n}\n\nfunction renderEvent(io: DappCliIo, componentId: string, value: unknown): void {\n io.stderr(`[${componentId}] ${canonicalizeIJson(value)}\\n`)\n}\n\nfunction signalOwnedRun(run: DefaultLocalDappRun): () => void {\n const stop = (): void => {\n void run.stop().catch(() => null)\n }\n process.once('SIGINT', stop)\n process.once('SIGTERM', stop)\n return () => {\n process.off('SIGINT', stop)\n process.off('SIGTERM', stop)\n }\n}\n\nfunction renderReady(io: DappCliIo, run: DefaultLocalDappRun, endpoints: readonly unknown[]): void {\n renderEvent(io, 'runner', {\n code: 'cli.run-ready',\n endpoints,\n runId: run.runId,\n stateRoot: run.stateRoot,\n })\n}\n\nasync function runDev(\n project: PlannedLocalDappProject,\n options: CreateDefaultDappCliLifecycleOptions,\n): Promise<DappCliLifecycleResult> {\n const run = await startDefaultLocalDappRun({\n mode: 'dev',\n onForegroundLog: entry => renderEvent(options.io, entry.componentId, entry),\n planned: project,\n })\n const unbindSignals = signalOwnedRun(run)\n try {\n try {\n const ready = await run.whenReady\n renderReady(options.io, run, ready.endpoints)\n } catch {\n // The terminal result below retains the stable startup failure.\n }\n return await run.whenTerminal\n } finally {\n unbindSignals()\n }\n}\n\nasync function stopAfterTest(\n run: DefaultLocalDappRun,\n isVerificationFailed: boolean,\n retainOnFailure: boolean,\n): Promise<DappCliLifecycleResult> {\n if (isVerificationFailed && retainOnFailure) run.retainState()\n const terminal = await run.stop()\n return terminal.outcome === 'failed' || isVerificationFailed\n ? { outcome: 'failed' }\n : { outcome: 'stopped' }\n}\n\nasync function runTest(\n project: PlannedLocalDappProject,\n options: CreateDefaultDappCliLifecycleOptions,\n): Promise<DappCliLifecycleResult> {\n const run = await startDefaultLocalDappRun({\n mode: 'test',\n onForegroundLog: entry => renderEvent(options.io, entry.componentId, entry),\n planned: project,\n retainOnFailure: options.retainOnFailure,\n })\n const abort = new AbortController()\n const unbindSignals = signalOwnedRun(run)\n void run.whenTerminal.then(() => abort.abort())\n try {\n const ready = await run.whenReady\n renderReady(options.io, run, ready.endpoints)\n const summary = await runLocalDappVerifications({\n contextRoot: PATH.join(run.stateRoot, 'verification'),\n deploymentName: project.lock.deployment.name,\n endpoints: ready.endpoints,\n lockId: project.lock.lockId,\n onOutput: output => run.logVerificationOutput(output),\n planId: project.lock.plan.planId,\n project: project.project,\n signal: abort.signal,\n })\n for (const result of summary.results) renderEvent(options.io, `verification-${result.id}`, result)\n return await stopAfterTest(run, summary.outcome === 'failed', options.retainOnFailure)\n } catch (error) {\n renderEvent(options.io, 'runner', {\n code: 'cli.test-failed',\n causeCode: error instanceof Error && 'code' in error && typeof error.code === 'string'\n ? error.code\n : 'unknown',\n })\n if (options.retainOnFailure) run.retainState()\n const terminal = await run.stop()\n return terminal.outcome === 'failed' ? terminal : { outcome: 'failed' }\n } finally {\n unbindSignals()\n }\n}\n\nexport function createDefaultDappCliLifecycleServices(\n options: CreateDefaultDappCliLifecycleOptions,\n): DappCliLifecycleServices {\n return {\n dev: async project => await runDev(project, options),\n test: async project => await runTest(project, options),\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAOA,WAAU;AAMjB;AAAA,EACE,qBAAAC;AAAA,EACA;AAAA,OACK;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACzBP,OAAO,UAAU;AAEjB,SAAS,yBAAyB;AAKlC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAaP,SAAS,YAAY,IAAe,aAAqB,OAAsB;AAC7E,KAAG,OAAO,IAAI,WAAW,KAAK,kBAAkB,KAAK,CAAC;AAAA,CAAI;AAC5D;AAEA,SAAS,eAAe,KAAsC;AAC5D,QAAM,OAAO,MAAY;AACvB,SAAK,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI;AAAA,EAClC;AACA,UAAQ,KAAK,UAAU,IAAI;AAC3B,UAAQ,KAAK,WAAW,IAAI;AAC5B,SAAO,MAAM;AACX,YAAQ,IAAI,UAAU,IAAI;AAC1B,YAAQ,IAAI,WAAW,IAAI;AAAA,EAC7B;AACF;AAEA,SAAS,YAAY,IAAe,KAA0B,WAAqC;AACjG,cAAY,IAAI,UAAU;AAAA,IACxB,MAAM;AAAA,IACN;AAAA,IACA,OAAO,IAAI;AAAA,IACX,WAAW,IAAI;AAAA,EACjB,CAAC;AACH;AAEA,eAAe,OACb,SACA,SACiC;AACjC,QAAM,MAAM,MAAM,yBAAyB;AAAA,IACzC,MAAM;AAAA,IACN,iBAAiB,WAAS,YAAY,QAAQ,IAAI,MAAM,aAAa,KAAK;AAAA,IAC1E,SAAS;AAAA,EACX,CAAC;AACD,QAAM,gBAAgB,eAAe,GAAG;AACxC,MAAI;AACF,QAAI;AACF,YAAM,QAAQ,MAAM,IAAI;AACxB,kBAAY,QAAQ,IAAI,KAAK,MAAM,SAAS;AAAA,IAC9C,QAAQ;AAAA,IAER;AACA,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gBAAgB;AAAA,IAClB;AAAA,EACF;AACA,QAAM,IAAI,EAAE,SAAS,QAAQ,SAAS,SAAS,OAAO,QAAQ,GAAG,QAAQ,MAAM;AAC/E,SAAO,OAAO,YAAY,YAAY,gBAAgB,UAAU,gBAAgB;AAClF;AAEA,SAAS,UAAU,OAAwB;AACzC,SAAO,iBAAiB,SAAS,UAAU,SAAS,OAAO,MAAM,SAAS,WACtE,MAAM,OACN;AACN;AAEA,eAAsB,WACpB,YACA,UAA6B,CAAC,GACJ;AAC1B,QAAM,KAAK,QAAQ,MAAM,UAAU;AACnC,MAAI;AACF,UAAM,SAAS,aAAa,YAAY,QAAQ,OAAO,QAAQ,IAAI,CAAC;AACpE,QAAI,WAAW,QAAQ;AACrB,SAAG,OAAO,IAAI;AACd,aAAO,gBAAgB;AAAA,IACzB;AACA,WAAO,MAAM,QAAQ,QAAQ,SAAS,EAAE;AAAA,EAC1C,SAAS,OAAO;AACd,UAAM,WAAW,iBAAiB,eAAe,MAAM,WAAW,gBAAgB;AAClF,OAAG,OAAO,GAAGA,mBAAkB;AAAA,MAC7B,MAAM,UAAU,KAAK;AAAA,MACrB,SAAS,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IACpD,CAAC,CAAC;AAAA,CAAI;AACN,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["PATH", "canonicalizeIJson", "PATH", "canonicalizeIJson"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyo-network/dapp-kit-cli",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Thin command-line adapter for XL1 dapp-kit projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xyo",
|
|
7
|
+
"xl1",
|
|
8
|
+
"dapp",
|
|
9
|
+
"cli",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/XYOracleNetwork/dapp-kit/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/XYOracleNetwork/dapp-kit.git",
|
|
18
|
+
"directory": "packages/dapp-kit-cli"
|
|
19
|
+
},
|
|
20
|
+
"license": "UNLICENSED",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"bin": {
|
|
24
|
+
"xl1-dapp": "./dist/node/bin.mjs"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/node/index.d.ts",
|
|
29
|
+
"default": "./dist/node/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./bin": {
|
|
32
|
+
"types": "./dist/node/bin.d.ts",
|
|
33
|
+
"default": "./dist/node/bin.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json",
|
|
36
|
+
"./README.md": "./README.md"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@ariestools/actor-model": "~1.3.0",
|
|
44
|
+
"@ariestools/actor-system": "~1.3.0",
|
|
45
|
+
"@ariestools/cli-kit": "~1.2.3",
|
|
46
|
+
"@ariestools/sdk": "~8.1.8",
|
|
47
|
+
"@noble/hashes": "~2.3.0",
|
|
48
|
+
"@opentelemetry/api": "~1.9.1",
|
|
49
|
+
"@xyo-network/sdk": "~7.2.3",
|
|
50
|
+
"@xyo-network/sdk-protocol": "~7.2.3",
|
|
51
|
+
"@xyo-network/xl1-sdk": "~5.1.1",
|
|
52
|
+
"async-mutex": "~0.5.0",
|
|
53
|
+
"ethers": "~6.17.0",
|
|
54
|
+
"semver": "~7.8.5",
|
|
55
|
+
"zod": "~4.4.3",
|
|
56
|
+
"@xyo-network/dapp-kit": "~0.1.2",
|
|
57
|
+
"@xyo-network/dapp-kit-local": "~0.1.2",
|
|
58
|
+
"@xyo-network/dapp-kit-node": "~0.1.2"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@ariestools/toolchain": "~8.7.29",
|
|
62
|
+
"@ariestools/tsconfig": "~8.7.29",
|
|
63
|
+
"@types/node": "~26.2.0",
|
|
64
|
+
"eslint": "~10.8.1",
|
|
65
|
+
"eslint-import-resolver-typescript": "~4.4.5",
|
|
66
|
+
"typescript": "~6.0.3",
|
|
67
|
+
"vite": "~8.2.1",
|
|
68
|
+
"vitest": "~4.1.10"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=24"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:ci": "vitest run"
|
|
79
|
+
}
|
|
80
|
+
}
|