@secondlayer/cli 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +72 -14
- package/dist/cli.js.map +3 -3
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -32678,7 +32678,7 @@ var {
|
|
|
32678
32678
|
// package.json
|
|
32679
32679
|
var package_default = {
|
|
32680
32680
|
name: "@secondlayer/cli",
|
|
32681
|
-
version: "1.11.
|
|
32681
|
+
version: "1.11.1",
|
|
32682
32682
|
description: "CLI for streams, subgraphs, and real-time blockchain indexing on Stacks",
|
|
32683
32683
|
type: "module",
|
|
32684
32684
|
bin: {
|
|
@@ -32719,11 +32719,11 @@ var package_default = {
|
|
|
32719
32719
|
license: "MIT",
|
|
32720
32720
|
dependencies: {
|
|
32721
32721
|
"@inquirer/prompts": "^8.2.0",
|
|
32722
|
-
"@secondlayer/sdk": "^0.10.
|
|
32723
|
-
"@secondlayer/shared": "^0.
|
|
32722
|
+
"@secondlayer/sdk": "^0.10.1",
|
|
32723
|
+
"@secondlayer/shared": "^0.11.0",
|
|
32724
32724
|
"@secondlayer/stacks": "^0.2.2",
|
|
32725
|
-
"@secondlayer/subgraphs": "^0.
|
|
32726
|
-
"@secondlayer/workflows": "^0.0.
|
|
32725
|
+
"@secondlayer/subgraphs": "^0.10.0",
|
|
32726
|
+
"@secondlayer/workflows": "^0.0.2",
|
|
32727
32727
|
"@biomejs/js-api": "^0.7.0",
|
|
32728
32728
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32729
32729
|
esbuild: "^0.19.0",
|
|
@@ -37218,10 +37218,22 @@ function registerWhoamiCommand(program2) {
|
|
|
37218
37218
|
});
|
|
37219
37219
|
}
|
|
37220
37220
|
// src/commands/workflows.ts
|
|
37221
|
+
init_config();
|
|
37221
37222
|
init_output();
|
|
37222
37223
|
import { existsSync as existsSync2 } from "node:fs";
|
|
37223
37224
|
import { resolve as resolve7 } from "node:path";
|
|
37224
37225
|
import { SecondLayer as SecondLayer2 } from "@secondlayer/sdk";
|
|
37226
|
+
function formatValidationError(err) {
|
|
37227
|
+
if (err != null && typeof err === "object" && "issues" in err && Array.isArray(err.issues)) {
|
|
37228
|
+
error("Workflow validation failed:");
|
|
37229
|
+
for (const issue of err.issues) {
|
|
37230
|
+
const path = issue.path?.length ? issue.path.join(".") : "(root)";
|
|
37231
|
+
error(` ${path}: ${issue.message}`);
|
|
37232
|
+
}
|
|
37233
|
+
} else {
|
|
37234
|
+
error(`Failed to validate workflow: ${err}`);
|
|
37235
|
+
}
|
|
37236
|
+
}
|
|
37225
37237
|
function getClient2() {
|
|
37226
37238
|
const apiKey = process.env.SECONDLAYER_API_KEY;
|
|
37227
37239
|
if (!apiKey) {
|
|
@@ -37244,16 +37256,67 @@ function registerWorkflowsCommand(program2) {
|
|
|
37244
37256
|
const def = mod.default ?? mod;
|
|
37245
37257
|
const { validateWorkflowDefinition } = await import("@secondlayer/workflows/validate");
|
|
37246
37258
|
const result = validateWorkflowDefinition(def);
|
|
37259
|
+
const config = await loadConfig();
|
|
37260
|
+
if (config.network !== "local") {
|
|
37261
|
+
info(`Bundling for remote deploy (${config.network})...`);
|
|
37262
|
+
const esbuild = await import("esbuild");
|
|
37263
|
+
const buildResult = await esbuild.build({
|
|
37264
|
+
entryPoints: [absPath],
|
|
37265
|
+
bundle: true,
|
|
37266
|
+
platform: "node",
|
|
37267
|
+
format: "esm",
|
|
37268
|
+
external: ["@secondlayer/workflows"],
|
|
37269
|
+
write: false
|
|
37270
|
+
});
|
|
37271
|
+
const handlerCode = new TextDecoder().decode(buildResult.outputFiles?.[0]?.contents);
|
|
37272
|
+
const deployResult = await getClient2().workflows.deploy({
|
|
37273
|
+
name: def.name,
|
|
37274
|
+
trigger: def.trigger,
|
|
37275
|
+
handlerCode,
|
|
37276
|
+
retries: def.retries,
|
|
37277
|
+
timeout: def.timeout
|
|
37278
|
+
});
|
|
37279
|
+
if (deployResult.action === "unchanged") {
|
|
37280
|
+
info(`Workflow "${def.name}" is up to date (no changes)`);
|
|
37281
|
+
} else {
|
|
37282
|
+
success(`Workflow "${def.name}" ${deployResult.action} (remote)`);
|
|
37283
|
+
}
|
|
37284
|
+
} else {
|
|
37285
|
+
success(`Workflow "${result.name}" is valid`);
|
|
37286
|
+
info(`Trigger: ${result.trigger.type}`);
|
|
37287
|
+
if (result.retries) {
|
|
37288
|
+
info(`Retries: maxAttempts=${result.retries.maxAttempts ?? "default"}`);
|
|
37289
|
+
}
|
|
37290
|
+
if (result.timeout) {
|
|
37291
|
+
info(`Timeout: ${result.timeout}ms`);
|
|
37292
|
+
}
|
|
37293
|
+
}
|
|
37294
|
+
} catch (err) {
|
|
37295
|
+
formatValidationError(err);
|
|
37296
|
+
process.exit(1);
|
|
37297
|
+
}
|
|
37298
|
+
});
|
|
37299
|
+
workflows.command("validate <file>").description("Validate a workflow definition without deploying").action(async (file) => {
|
|
37300
|
+
try {
|
|
37301
|
+
const absPath = resolve7(file);
|
|
37302
|
+
if (!existsSync2(absPath)) {
|
|
37303
|
+
error(`File not found: ${absPath}`);
|
|
37304
|
+
process.exit(1);
|
|
37305
|
+
}
|
|
37306
|
+
const mod = await import(absPath);
|
|
37307
|
+
const def = mod.default ?? mod;
|
|
37308
|
+
const { validateWorkflowDefinition } = await import("@secondlayer/workflows/validate");
|
|
37309
|
+
const result = validateWorkflowDefinition(def);
|
|
37247
37310
|
success(`Workflow "${result.name}" is valid`);
|
|
37248
37311
|
info(`Trigger: ${result.trigger.type}`);
|
|
37249
37312
|
if (result.retries) {
|
|
37250
|
-
info(`Retries: maxAttempts=${result.retries.maxAttempts ?? "default"}`);
|
|
37313
|
+
info(`Retries: maxAttempts=${result.retries.maxAttempts ?? "default"}, backoffMs=${result.retries.backoffMs ?? 1000}, multiplier=${result.retries.backoffMultiplier ?? 2}`);
|
|
37251
37314
|
}
|
|
37252
37315
|
if (result.timeout) {
|
|
37253
37316
|
info(`Timeout: ${result.timeout}ms`);
|
|
37254
37317
|
}
|
|
37255
37318
|
} catch (err) {
|
|
37256
|
-
|
|
37319
|
+
formatValidationError(err);
|
|
37257
37320
|
process.exit(1);
|
|
37258
37321
|
}
|
|
37259
37322
|
});
|
|
@@ -37270,12 +37333,7 @@ function registerWorkflowsCommand(program2) {
|
|
|
37270
37333
|
}
|
|
37271
37334
|
const rows = items.map((w) => {
|
|
37272
37335
|
const statusColor = w.status === "active" ? green : yellow;
|
|
37273
|
-
return [
|
|
37274
|
-
w.name,
|
|
37275
|
-
statusColor(w.status),
|
|
37276
|
-
w.triggerType,
|
|
37277
|
-
w.createdAt
|
|
37278
|
-
];
|
|
37336
|
+
return [w.name, statusColor(w.status), w.triggerType, w.createdAt];
|
|
37279
37337
|
});
|
|
37280
37338
|
console.log(formatTable(["Name", "Status", "Trigger", "Created"], rows));
|
|
37281
37339
|
console.log(dim(`
|
|
@@ -37429,5 +37487,5 @@ registerWhoamiCommand(program);
|
|
|
37429
37487
|
registerReceiverCommand(program);
|
|
37430
37488
|
program.parse();
|
|
37431
37489
|
|
|
37432
|
-
//# debugId=
|
|
37490
|
+
//# debugId=A12A8B4794F94ECD64756E2164756E21
|
|
37433
37491
|
//# sourceMappingURL=cli.js.map
|