@secondlayer/cli 9.0.3 → 9.0.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
@@ -2492,7 +2492,7 @@ import {
2492
2492
  } from "node:fs/promises";
2493
2493
  import { homedir } from "node:os";
2494
2494
  import { dirname, join } from "node:path";
2495
- import { z } from "zod/v4";
2495
+ import { z } from "zod";
2496
2496
  async function readSession() {
2497
2497
  try {
2498
2498
  const raw = await readFile(SESSION_PATH, "utf8");
@@ -2709,7 +2709,7 @@ __export(exports_config, {
2709
2709
  });
2710
2710
  import { homedir as homedir2 } from "node:os";
2711
2711
  import { join as join2 } from "node:path";
2712
- import { z as z2 } from "zod/v4";
2712
+ import { z as z2 } from "zod";
2713
2713
  async function ensureConfigDir() {
2714
2714
  await ensureDir(CONFIG_DIR);
2715
2715
  }
@@ -16383,6 +16383,7 @@ var require_constants2 = __commonJS((exports, module) => {
16383
16383
  var path3 = __require("path");
16384
16384
  var WIN_SLASH = "\\\\/";
16385
16385
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
16386
+ var DEFAULT_MAX_EXTGLOB_RECURSION = 0;
16386
16387
  var DOT_LITERAL = "\\.";
16387
16388
  var PLUS_LITERAL = "\\+";
16388
16389
  var QMARK_LITERAL = "\\?";
@@ -16430,6 +16431,7 @@ var require_constants2 = __commonJS((exports, module) => {
16430
16431
  END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
16431
16432
  };
16432
16433
  var POSIX_REGEX_SOURCE = {
16434
+ __proto__: null,
16433
16435
  alnum: "a-zA-Z0-9",
16434
16436
  alpha: "a-zA-Z",
16435
16437
  ascii: "\\x00-\\x7F",
@@ -16446,6 +16448,7 @@ var require_constants2 = __commonJS((exports, module) => {
16446
16448
  xdigit: "A-Fa-f0-9"
16447
16449
  };
16448
16450
  module.exports = {
16451
+ DEFAULT_MAX_EXTGLOB_RECURSION,
16449
16452
  MAX_LENGTH: 1024 * 64,
16450
16453
  POSIX_REGEX_SOURCE,
16451
16454
  REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
@@ -16455,6 +16458,7 @@ var require_constants2 = __commonJS((exports, module) => {
16455
16458
  REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
16456
16459
  REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
16457
16460
  REPLACEMENTS: {
16461
+ __proto__: null,
16458
16462
  "***": "*",
16459
16463
  "**/**": "**",
16460
16464
  "**/**/**": "**"
@@ -16920,6 +16924,213 @@ var require_parse2 = __commonJS((exports, module) => {
16920
16924
  var syntaxError = (type, char) => {
16921
16925
  return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
16922
16926
  };
16927
+ var splitTopLevel = (input4) => {
16928
+ const parts = [];
16929
+ let bracket = 0;
16930
+ let paren = 0;
16931
+ let quote = 0;
16932
+ let value = "";
16933
+ let escaped = false;
16934
+ for (const ch of input4) {
16935
+ if (escaped === true) {
16936
+ value += ch;
16937
+ escaped = false;
16938
+ continue;
16939
+ }
16940
+ if (ch === "\\") {
16941
+ value += ch;
16942
+ escaped = true;
16943
+ continue;
16944
+ }
16945
+ if (ch === '"') {
16946
+ quote = quote === 1 ? 0 : 1;
16947
+ value += ch;
16948
+ continue;
16949
+ }
16950
+ if (quote === 0) {
16951
+ if (ch === "[") {
16952
+ bracket++;
16953
+ } else if (ch === "]" && bracket > 0) {
16954
+ bracket--;
16955
+ } else if (bracket === 0) {
16956
+ if (ch === "(") {
16957
+ paren++;
16958
+ } else if (ch === ")" && paren > 0) {
16959
+ paren--;
16960
+ } else if (ch === "|" && paren === 0) {
16961
+ parts.push(value);
16962
+ value = "";
16963
+ continue;
16964
+ }
16965
+ }
16966
+ }
16967
+ value += ch;
16968
+ }
16969
+ parts.push(value);
16970
+ return parts;
16971
+ };
16972
+ var isPlainBranch = (branch) => {
16973
+ let escaped = false;
16974
+ for (const ch of branch) {
16975
+ if (escaped === true) {
16976
+ escaped = false;
16977
+ continue;
16978
+ }
16979
+ if (ch === "\\") {
16980
+ escaped = true;
16981
+ continue;
16982
+ }
16983
+ if (/[?*+@!()[\]{}]/.test(ch)) {
16984
+ return false;
16985
+ }
16986
+ }
16987
+ return true;
16988
+ };
16989
+ var normalizeSimpleBranch = (branch) => {
16990
+ let value = branch.trim();
16991
+ let changed = true;
16992
+ while (changed === true) {
16993
+ changed = false;
16994
+ if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
16995
+ value = value.slice(2, -1);
16996
+ changed = true;
16997
+ }
16998
+ }
16999
+ if (!isPlainBranch(value)) {
17000
+ return;
17001
+ }
17002
+ return value.replace(/\\(.)/g, "$1");
17003
+ };
17004
+ var hasRepeatedCharPrefixOverlap = (branches) => {
17005
+ const values2 = branches.map(normalizeSimpleBranch).filter(Boolean);
17006
+ for (let i = 0;i < values2.length; i++) {
17007
+ for (let j = i + 1;j < values2.length; j++) {
17008
+ const a = values2[i];
17009
+ const b2 = values2[j];
17010
+ const char = a[0];
17011
+ if (!char || a !== char.repeat(a.length) || b2 !== char.repeat(b2.length)) {
17012
+ continue;
17013
+ }
17014
+ if (a === b2 || a.startsWith(b2) || b2.startsWith(a)) {
17015
+ return true;
17016
+ }
17017
+ }
17018
+ }
17019
+ return false;
17020
+ };
17021
+ var parseRepeatedExtglob = (pattern, requireEnd = true) => {
17022
+ if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
17023
+ return;
17024
+ }
17025
+ let bracket = 0;
17026
+ let paren = 0;
17027
+ let quote = 0;
17028
+ let escaped = false;
17029
+ for (let i = 1;i < pattern.length; i++) {
17030
+ const ch = pattern[i];
17031
+ if (escaped === true) {
17032
+ escaped = false;
17033
+ continue;
17034
+ }
17035
+ if (ch === "\\") {
17036
+ escaped = true;
17037
+ continue;
17038
+ }
17039
+ if (ch === '"') {
17040
+ quote = quote === 1 ? 0 : 1;
17041
+ continue;
17042
+ }
17043
+ if (quote === 1) {
17044
+ continue;
17045
+ }
17046
+ if (ch === "[") {
17047
+ bracket++;
17048
+ continue;
17049
+ }
17050
+ if (ch === "]" && bracket > 0) {
17051
+ bracket--;
17052
+ continue;
17053
+ }
17054
+ if (bracket > 0) {
17055
+ continue;
17056
+ }
17057
+ if (ch === "(") {
17058
+ paren++;
17059
+ continue;
17060
+ }
17061
+ if (ch === ")") {
17062
+ paren--;
17063
+ if (paren === 0) {
17064
+ if (requireEnd === true && i !== pattern.length - 1) {
17065
+ return;
17066
+ }
17067
+ return {
17068
+ type: pattern[0],
17069
+ body: pattern.slice(2, i),
17070
+ end: i
17071
+ };
17072
+ }
17073
+ }
17074
+ }
17075
+ };
17076
+ var getStarExtglobSequenceOutput = (pattern) => {
17077
+ let index = 0;
17078
+ const chars = [];
17079
+ while (index < pattern.length) {
17080
+ const match = parseRepeatedExtglob(pattern.slice(index), false);
17081
+ if (!match || match.type !== "*") {
17082
+ return;
17083
+ }
17084
+ const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
17085
+ if (branches.length !== 1) {
17086
+ return;
17087
+ }
17088
+ const branch = normalizeSimpleBranch(branches[0]);
17089
+ if (!branch || branch.length !== 1) {
17090
+ return;
17091
+ }
17092
+ chars.push(branch);
17093
+ index += match.end + 1;
17094
+ }
17095
+ if (chars.length < 1) {
17096
+ return;
17097
+ }
17098
+ const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
17099
+ return `${source}*`;
17100
+ };
17101
+ var repeatedExtglobRecursion = (pattern) => {
17102
+ let depth = 0;
17103
+ let value = pattern.trim();
17104
+ let match = parseRepeatedExtglob(value);
17105
+ while (match) {
17106
+ depth++;
17107
+ value = match.body.trim();
17108
+ match = parseRepeatedExtglob(value);
17109
+ }
17110
+ return depth;
17111
+ };
17112
+ var analyzeRepeatedExtglob = (body, options2) => {
17113
+ if (options2.maxExtglobRecursion === false) {
17114
+ return { risky: false };
17115
+ }
17116
+ const max = typeof options2.maxExtglobRecursion === "number" ? options2.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
17117
+ const branches = splitTopLevel(body).map((branch) => branch.trim());
17118
+ if (branches.length > 1) {
17119
+ if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
17120
+ return { risky: true };
17121
+ }
17122
+ }
17123
+ for (const branch of branches) {
17124
+ const safeOutput = getStarExtglobSequenceOutput(branch);
17125
+ if (safeOutput) {
17126
+ return { risky: true, safeOutput };
17127
+ }
17128
+ if (repeatedExtglobRecursion(branch) > max) {
17129
+ return { risky: true };
17130
+ }
17131
+ }
17132
+ return { risky: false };
17133
+ };
16923
17134
  var parse2 = (input4, options2) => {
16924
17135
  if (typeof input4 !== "string") {
16925
17136
  throw new TypeError("Expected a string");
@@ -17052,6 +17263,8 @@ var require_parse2 = __commonJS((exports, module) => {
17052
17263
  token.prev = prev;
17053
17264
  token.parens = state.parens;
17054
17265
  token.output = state.output;
17266
+ token.startIndex = state.index;
17267
+ token.tokensIndex = tokens.length;
17055
17268
  const output2 = (opts.capture ? "(" : "") + token.open;
17056
17269
  increment("parens");
17057
17270
  push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
@@ -17059,6 +17272,26 @@ var require_parse2 = __commonJS((exports, module) => {
17059
17272
  extglobs.push(token);
17060
17273
  };
17061
17274
  const extglobClose = (token) => {
17275
+ const literal = input4.slice(token.startIndex, state.index + 1);
17276
+ const body = input4.slice(token.startIndex + 2, state.index);
17277
+ const analysis = analyzeRepeatedExtglob(body, opts);
17278
+ if ((token.type === "plus" || token.type === "star") && analysis.risky) {
17279
+ const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : undefined;
17280
+ const open = tokens[token.tokensIndex];
17281
+ open.type = "text";
17282
+ open.value = literal;
17283
+ open.output = safeOutput || utils.escapeRegex(literal);
17284
+ for (let i = token.tokensIndex + 1;i < tokens.length; i++) {
17285
+ tokens[i].value = "";
17286
+ tokens[i].output = "";
17287
+ delete tokens[i].suffix;
17288
+ }
17289
+ state.output = token.output + open.output;
17290
+ state.backtrack = true;
17291
+ push({ type: "paren", extglob: true, value, output: "" });
17292
+ decrement("parens");
17293
+ return;
17294
+ }
17062
17295
  let output2 = token.close + (opts.capture ? ")" : "");
17063
17296
  let rest;
17064
17297
  if (token.type === "negate") {
@@ -31829,7 +32062,7 @@ var {
31829
32062
  // package.json
31830
32063
  var package_default = {
31831
32064
  name: "@secondlayer/cli",
31832
- version: "9.0.3",
32065
+ version: "9.0.5",
31833
32066
  repository: {
31834
32067
  type: "git",
31835
32068
  url: "git+https://github.com/ryanwaits/secondlayer.git",
@@ -31878,14 +32111,14 @@ var package_default = {
31878
32111
  dependencies: {
31879
32112
  "@inquirer/prompts": "^8.2.0",
31880
32113
  "@secondlayer/bundler": "^0.4.0",
31881
- "@secondlayer/scaffold": "^1.4.0",
31882
- "@secondlayer/sdk": "^6.29.1",
31883
- "@secondlayer/shared": "^7.0.0",
32114
+ "@secondlayer/scaffold": "^1.4.1",
32115
+ "@secondlayer/sdk": "^6.36.0",
32116
+ "@secondlayer/shared": "^7.0.3",
31884
32117
  "@secondlayer/stacks": "^2.14.1",
31885
- "@secondlayer/subgraphs": "^3.19.7",
32118
+ "@secondlayer/subgraphs": "^3.20.0",
31886
32119
  "@biomejs/js-api": "^0.7.0",
31887
32120
  "@biomejs/wasm-nodejs": "^1.9.0",
31888
- esbuild: "^0.19.0",
32121
+ esbuild: "^0.27.4",
31889
32122
  "smol-toml": "^1.6.1",
31890
32123
  zod: "^4.3.6"
31891
32124
  },
@@ -35611,6 +35844,32 @@ Stopped watching.`);
35611
35844
  return;
35612
35845
  }
35613
35846
  const deployStartBlock = startBlock ?? effectiveDef.startBlock;
35847
+ if (!options2.yes) {
35848
+ const existingDetail = await getSubgraphApi(effectiveDef.name).catch(() => null);
35849
+ const existingSchema = existingDetail?.definition?.schema;
35850
+ if (existingDetail && existingSchema) {
35851
+ const { diffSchema, hasBreakingChanges } = await import("@secondlayer/subgraphs");
35852
+ const verdict = hasBreakingChanges(diffSchema(existingSchema, effectiveDef.schema));
35853
+ const existingStart = existingDetail.definition?.startBlock;
35854
+ const startBlockForcesReindex = deployStartBlock !== undefined && deployStartBlock !== existingStart;
35855
+ if (verdict.breaking || startBlockForcesReindex) {
35856
+ if (verdict.breaking) {
35857
+ warn("Breaking changes detected:");
35858
+ for (const r of verdict.reasons)
35859
+ warn(` ✗ ${r}`);
35860
+ } else {
35861
+ warn(`startBlock change (${existingStart ?? "unset"} → ${deployStartBlock}) forces a reindex.`);
35862
+ }
35863
+ const confirmed = await confirm3({
35864
+ message: "⚠ This will drop all data and reindex from scratch. Continue?"
35865
+ });
35866
+ if (!confirmed) {
35867
+ info("Aborted — nothing was deployed.");
35868
+ process.exit(0);
35869
+ }
35870
+ }
35871
+ }
35872
+ }
35614
35873
  if (options2.databaseUrl) {
35615
35874
  info("BYO data plane: schema + rows will live in your database. The server verifies the connection before deploying.");
35616
35875
  }
@@ -35676,13 +35935,6 @@ Stopped watching.`);
35676
35935
  info(` + columns: ${t}.${cols.join(", ")}`);
35677
35936
  }
35678
35937
  }
35679
- const confirmed = options2.yes || await confirm3({
35680
- message: "⚠ This will drop all data and reindex from scratch. Continue?"
35681
- });
35682
- if (!confirmed) {
35683
- info("Aborted.");
35684
- process.exit(0);
35685
- }
35686
35938
  success(`Subgraph "${effectiveDef.name}" updated → v${result.version} (reindexing)`);
35687
35939
  await printDeployFooter();
35688
35940
  } else {
@@ -37902,7 +38154,7 @@ import { existsSync as existsSync5 } from "node:fs";
37902
38154
  import { mkdir as mkdir4, readFile as readFile3, writeFile as writeFile4 } from "node:fs/promises";
37903
38155
  import { homedir as homedir5 } from "node:os";
37904
38156
  import { dirname as dirname12, join as join11, parse as parsePath2, resolve as resolve9 } from "node:path";
37905
- import { z as z3 } from "zod/v4";
38157
+ import { z as z3 } from "zod";
37906
38158
  var ProjectFileSchema = z3.object({
37907
38159
  slug: z3.string().min(1)
37908
38160
  });
@@ -38154,5 +38406,5 @@ registerAccountCommand(program);
38154
38406
  registerKeysCommand(program);
38155
38407
  program.parse();
38156
38408
 
38157
- //# debugId=A1CC1485DE33C24164756E2164756E21
38409
+ //# debugId=099A28BD17DC66FD64756E2164756E21
38158
38410
  //# sourceMappingURL=cli.js.map