@secondlayer/cli 3.5.4 → 3.5.5

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 CHANGED
@@ -32439,7 +32439,7 @@ var {
32439
32439
  // package.json
32440
32440
  var package_default = {
32441
32441
  name: "@secondlayer/cli",
32442
- version: "3.5.4",
32442
+ version: "3.5.5",
32443
32443
  description: "CLI for subgraphs and blockchain indexing on Stacks",
32444
32444
  type: "module",
32445
32445
  bin: {
@@ -34637,6 +34637,23 @@ function ensureScaffoldPackageJson(dir) {
34637
34637
  writeFileSync2(packagePath, `${JSON.stringify(pkg, null, 2)}
34638
34638
  `, "utf8");
34639
34639
  }
34640
+ async function runBunInstall(dir) {
34641
+ const proc = Bun.spawn(["bun", "install"], {
34642
+ cwd: dir,
34643
+ stdout: "inherit",
34644
+ stderr: "inherit"
34645
+ });
34646
+ const exitCode = await proc.exited;
34647
+ if (exitCode !== 0) {
34648
+ throw new Error(`bun install exited with code ${exitCode}`);
34649
+ }
34650
+ }
34651
+ async function installScaffoldDependencies(dir, options2 = {}) {
34652
+ if (options2.install === false)
34653
+ return "skipped";
34654
+ await (options2.installer ?? runBunInstall)(dir);
34655
+ return "installed";
34656
+ }
34640
34657
  function createSubgraphDeployPreview(def, options2 = {}) {
34641
34658
  const tableColumns = Object.entries(def.schema).map(([table, schema]) => `${table}: ${Object.keys(schema.columns).join(", ") || "(no columns)"}`);
34642
34659
  return {
@@ -35117,7 +35134,7 @@ ${rows.length} row(s)`));
35117
35134
  handleApiError(err, "delete subgraph");
35118
35135
  }
35119
35136
  });
35120
- subgraphs.command("scaffold <contractAddress>").description("Scaffold a defineSubgraph() file from a contract ABI").option("-o, --output <path>", "Output file path (required)").option("--api-key <key>", "Stacks node API key for direct RPC URLs").action(async (contractAddress, options2) => {
35137
+ subgraphs.command("scaffold <contractAddress>").description("Scaffold a defineSubgraph() file from a contract ABI").option("-o, --output <path>", "Output file path (required)").option("--api-key <key>", "Stacks node API key for direct RPC URLs").option("--no-install", "Skip bun install after writing package.json").action(async (contractAddress, options2) => {
35121
35138
  try {
35122
35139
  if (!options2.output) {
35123
35140
  error("--output <path> is required");
@@ -35141,6 +35158,18 @@ ${rows.length} row(s)`));
35141
35158
  await writeTextFile(outPath, content);
35142
35159
  ensureScaffoldPackageJson(dir);
35143
35160
  success(`Created ${outPath}`);
35161
+ if (options2.install === false) {
35162
+ info(`Run: cd ${dir} && bun install`);
35163
+ } else {
35164
+ info("Installing dependencies with bun install...");
35165
+ try {
35166
+ await installScaffoldDependencies(dir);
35167
+ } catch (err) {
35168
+ error(`Dependency install failed: ${err instanceof Error ? err.message : String(err)}`);
35169
+ info(`Run: cd ${dir} && bun install`);
35170
+ process.exit(1);
35171
+ }
35172
+ }
35144
35173
  info(`Next: sl subgraphs deploy ${options2.output}`);
35145
35174
  } catch (err) {
35146
35175
  error(`Failed to scaffold subgraph: ${err}`);
@@ -36197,12 +36226,12 @@ function registerInstanceCommand(program2) {
36197
36226
  });
36198
36227
  instance.command("delete").description("Permanently delete your instance + all data").option("--yes", "Skip typed-slug confirm").action(async (opts) => {
36199
36228
  guardOssMode();
36200
- const info_ = await httpPlatform("/api/tenants/me").catch(() => null);
36201
- if (!info_?.tenant) {
36229
+ const tenant = await fetchCurrentTenant();
36230
+ if (!tenant) {
36202
36231
  warn("No instance to delete.");
36203
36232
  return;
36204
36233
  }
36205
- const slug = info_.tenant.slug;
36234
+ const slug = tenant.slug;
36206
36235
  if (!opts.yes) {
36207
36236
  if (!process.stdin.isTTY) {
36208
36237
  error(`Refusing to prompt in a non-interactive terminal. Re-run with --yes to delete instance "${slug}".`);
@@ -36219,6 +36248,13 @@ function registerInstanceCommand(program2) {
36219
36248
  await httpPlatform("/api/tenants/me", { method: "DELETE" });
36220
36249
  success("Instance deleted.");
36221
36250
  } catch (err) {
36251
+ const afterDelete = await fetchCurrentTenant().catch(() => {
36252
+ return;
36253
+ });
36254
+ if (afterDelete === null) {
36255
+ success("Instance deleted.");
36256
+ return;
36257
+ }
36222
36258
  handleInstanceError(err, "delete");
36223
36259
  }
36224
36260
  });
@@ -36341,19 +36377,29 @@ async function requireActiveProject() {
36341
36377
  }
36342
36378
  return active.slug;
36343
36379
  }
36344
- async function renderInstanceInfo() {
36380
+ async function fetchCurrentTenant() {
36345
36381
  try {
36346
36382
  const res = await httpPlatform("/api/tenants/me");
36347
- if (!res.tenant) {
36383
+ return res.tenant;
36384
+ } catch (err) {
36385
+ if (err instanceof CliHttpError && err.status === 404) {
36386
+ return null;
36387
+ }
36388
+ throw err;
36389
+ }
36390
+ }
36391
+ async function renderInstanceInfo() {
36392
+ try {
36393
+ const tenant = await fetchCurrentTenant();
36394
+ if (!tenant) {
36348
36395
  info("No instance for the active project. Run `sl instance create --plan launch`.");
36349
36396
  return;
36350
36397
  }
36351
- const t = res.tenant;
36352
36398
  console.log(formatKeyValue([
36353
- ["URL", t.apiUrl],
36354
- ["Plan", t.plan],
36355
- ["Status", t.status],
36356
- ["Created", new Date(t.createdAt).toLocaleString()]
36399
+ ["URL", tenant.apiUrl],
36400
+ ["Plan", tenant.plan],
36401
+ ["Status", tenant.status],
36402
+ ["Created", new Date(tenant.createdAt).toLocaleString()]
36357
36403
  ]));
36358
36404
  } catch (err) {
36359
36405
  handleInstanceError(err, "fetch instance");
@@ -36582,5 +36628,5 @@ registerLocalCommand(program);
36582
36628
  registerAccountCommand(program);
36583
36629
  program.parse();
36584
36630
 
36585
- //# debugId=96B7A917235EEA4164756E2164756E21
36631
+ //# debugId=3944D78DF47F7DD164756E2164756E21
36586
36632
  //# sourceMappingURL=cli.js.map