@marktiderman/genesis-cli 1.17.0 → 1.17.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.
@@ -90,16 +90,16 @@
90
90
  "version": "0.1.3"
91
91
  },
92
92
  "@marktiderman/genesis-core": {
93
- "version": "2.4.0"
93
+ "version": "2.4.1"
94
94
  },
95
95
  "@marktiderman/genesis-design-system": {
96
- "version": "1.6.0"
96
+ "version": "1.6.1"
97
97
  },
98
98
  "@marktiderman/genesis-extension": {
99
99
  "version": "0.2.2"
100
100
  },
101
101
  "@marktiderman/genesis-features": {
102
- "version": "0.8.0"
102
+ "version": "0.8.1"
103
103
  },
104
104
  "@marktiderman/genesis-forms": {
105
105
  "version": "0.11.0"
@@ -123,16 +123,16 @@
123
123
  "version": "0.7.0"
124
124
  },
125
125
  "@marktiderman/genesis": {
126
- "version": "0.10.6"
126
+ "version": "0.10.8"
127
127
  },
128
128
  "@marktiderman/genesis-cli": {
129
- "version": "1.17.0"
129
+ "version": "1.17.2"
130
130
  },
131
131
  "@marktiderman/genesis-media": {
132
- "version": "0.1.1"
132
+ "version": "0.2.0"
133
133
  },
134
134
  "@marktiderman/genesis-native": {
135
- "version": "0.6.0",
135
+ "version": "0.7.0",
136
136
  "blocks": {
137
137
  "push": {
138
138
  "feature": {
@@ -396,7 +396,7 @@
396
396
  }
397
397
  },
398
398
  "@marktiderman/genesis-sites": {
399
- "version": "0.5.0",
399
+ "version": "0.5.1",
400
400
  "blocks": {
401
401
  "sites": {
402
402
  "feature": {
@@ -887,10 +887,10 @@
887
887
  "version": "2.1.3"
888
888
  },
889
889
  "@marktiderman/genesis-ui": {
890
- "version": "2.25.1"
890
+ "version": "2.26.0"
891
891
  },
892
892
  "@marktiderman/genesis-ui-native": {
893
- "version": "3.2.2"
893
+ "version": "3.3.0"
894
894
  }
895
895
  }
896
896
  }
package/dist/index.js CHANGED
@@ -455,14 +455,14 @@ function inherit(own, source) {
455
455
  }
456
456
  function resolveViews(relations) {
457
457
  const done = /* @__PURE__ */ new Set();
458
- const resolve16 = (relation, depth) => {
458
+ const resolve15 = (relation, depth) => {
459
459
  if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
460
460
  done.add(relation.oid);
461
461
  const sources = new Set([...relation.origins.values()].map((o) => o.relation));
462
462
  if (sources.size !== 1) return;
463
463
  const source = relations.get([...sources][0]);
464
464
  if (!source) return;
465
- resolve16(source, depth + 1);
465
+ resolve15(source, depth + 1);
466
466
  const viewAttnumOf = /* @__PURE__ */ new Map();
467
467
  for (const [attnum, origin] of relation.origins) {
468
468
  const own = relation.columns.get(attnum);
@@ -485,7 +485,7 @@ function resolveViews(relations) {
485
485
  };
486
486
  if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
487
487
  };
488
- for (const relation of relations.values()) resolve16(relation, 0);
488
+ for (const relation of relations.values()) resolve15(relation, 0);
489
489
  }
490
490
  async function introspectPostgres(sql, schemas, options = {}) {
491
491
  const relations = /* @__PURE__ */ new Map();
@@ -2879,6 +2879,7 @@ var BUILTIN_RULES = [
2879
2879
  "native-custom-header",
2880
2880
  "native-screen-layout",
2881
2881
  "store-readiness",
2882
+ "eas-placeholder",
2882
2883
  // supabase pack
2883
2884
  "migration-grants",
2884
2885
  "migration-rls",
@@ -3255,6 +3256,32 @@ function checkNativePack(ctx) {
3255
3256
  checkCustomHeaders(ctx, pkg);
3256
3257
  checkScreenLayouts(ctx, pkg);
3257
3258
  checkStoreReadiness(ctx);
3259
+ checkEasPlaceholders(ctx);
3260
+ }
3261
+ var EAS_PLACEHOLDER = /\bREPLACE_WITH_[A-Z0-9_]+/g;
3262
+ function checkEasPlaceholders(ctx) {
3263
+ const files = [];
3264
+ if (existsSync(path19.join(ctx.root, "eas.json"))) files.push("eas.json");
3265
+ const workflows = path19.join(ctx.root, ".eas", "workflows");
3266
+ if (existsSync(workflows)) {
3267
+ for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
3268
+ }
3269
+ for (const file of files) {
3270
+ const lines = readFileSync(path19.join(ctx.root, file), "utf8").split("\n");
3271
+ lines.forEach((text, i) => {
3272
+ if (!file.endsWith(".json") && /^\s*#/.test(text)) return;
3273
+ for (const m of text.matchAll(EAS_PLACEHOLDER)) {
3274
+ ctx.report({
3275
+ rule: "eas-placeholder",
3276
+ level: "warn",
3277
+ file,
3278
+ line: i + 1,
3279
+ subject: m[0],
3280
+ message: m[0] === "REPLACE_WITH_APP_FOLDER" ? "still names REPLACE_WITH_APP_FOLDER, so only config changes start a preview; replace it with the app's code folder (src, or apps/<name> in a monorepo)" : `still has the template placeholder ${m[0]}; replace it before the job that reads it runs (see docs/NATIVE-RELEASE.md in the Genesis repository)`
3281
+ });
3282
+ }
3283
+ });
3284
+ }
3258
3285
  }
3259
3286
  var RN = String.raw`["']react-native["']`;
3260
3287
  function checkRawPrimitives(ctx, pkg) {
@@ -4181,7 +4208,7 @@ function toRegExp2(source, flags = "") {
4181
4208
  if (source.startsWith("(?i)")) return new RegExp(source.slice(4), flags + "i");
4182
4209
  return new RegExp(source, flags);
4183
4210
  }
4184
- function validateDeclaration(raw, packageName3, packageDir2, ignored) {
4211
+ function validateDeclaration(raw, packageName3, packageDir, ignored) {
4185
4212
  const fail = (msg) => {
4186
4213
  throw new PackageDeclarationError(`${packageName3}: genesis.doctor ${msg}`);
4187
4214
  };
@@ -4201,9 +4228,9 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
4201
4228
  }
4202
4229
  });
4203
4230
  if (typeof raw === "string") {
4204
- if (!packageDir2) fail(`points at ${raw}, but the package folder is unknown`);
4205
- const file = path19.resolve(packageDir2, raw);
4206
- if (!inside(packageDir2, file)) fail(`points outside the package (${raw})`);
4231
+ if (!packageDir) fail(`points at ${raw}, but the package folder is unknown`);
4232
+ const file = path19.resolve(packageDir, raw);
4233
+ if (!inside(packageDir, file)) fail(`points outside the package (${raw})`);
4207
4234
  if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
4208
4235
  let parsed;
4209
4236
  try {
@@ -4211,7 +4238,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
4211
4238
  } catch (err) {
4212
4239
  return fail(`file ${raw} is not valid JSON: ${err.message}`);
4213
4240
  }
4214
- return validateDeclaration(parsed, packageName3, packageDir2, ignored);
4241
+ return validateDeclaration(parsed, packageName3, packageDir, ignored);
4215
4242
  }
4216
4243
  if (raw === false) fail(`is false; say why with { "enforce": false, "reason": "\u2026" }`);
4217
4244
  if (!isObject3(raw)) fail(`must be an object (or a path to a JSON file in the package)`);
@@ -4249,10 +4276,10 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
4249
4276
  });
4250
4277
  let plugin;
4251
4278
  if (typeof c.plugin === "string") {
4252
- if (!packageDir2) plugin = c.plugin;
4279
+ if (!packageDir) plugin = c.plugin;
4253
4280
  else {
4254
- plugin = path19.resolve(packageDir2, c.plugin);
4255
- if (!inside(packageDir2, plugin)) fail(`plugin points outside the package (${c.plugin})`);
4281
+ plugin = path19.resolve(packageDir, c.plugin);
4282
+ if (!inside(packageDir, plugin)) fail(`plugin points outside the package (${c.plugin})`);
4256
4283
  }
4257
4284
  }
4258
4285
  return {
@@ -5098,6 +5125,23 @@ function checkTestingKit(ctx, migrations) {
5098
5125
  function granteesOf(s) {
5099
5126
  return s.replace(/\s+granted by .*$/, "").replace(/\s+with grant option$/, "").split(/\s*,\s*/).map((r) => r.replace(/^group\s+/, "").trim()).filter(Boolean);
5100
5127
  }
5128
+ function dynamicGrants(body) {
5129
+ const out = [];
5130
+ const code = body.replace(/\/\*[\s\S]*?\*\/|--[^\n]*/g, "").replace(/(?<![\w."'$])raise\s+(?:(?:debug|log|info|notice|warning|exception|sqlstate|using)\b|')[^;]*;/g, ";");
5131
+ const strings2 = /(?<![\w$])e'((?:[^'\\]|\\[\s\S]|'')*)(?:'|$)|'((?:[^']|'')*)(?:'|$)|\$(\w*)\$([\s\S]*?)(?:\$\3\$|$)/g;
5132
+ for (const m of code.matchAll(strings2)) {
5133
+ for (const stmt of (m[1] ?? m[2] ?? m[4] ?? "").split(";")) {
5134
+ if (!/^\s*(?:grant|alter default privileges\b.*?\bgrant)\b/.test(stmt)) continue;
5135
+ const to = /\bto(?:\s+|$)([\s\S]*)$/.exec(stmt);
5136
+ if (!to) continue;
5137
+ const roles = to[1].replace(/\s+(?:with grant option|granted by)\b[\s\S]*$/, "").trim();
5138
+ const open = /\b(anon|public)\b/.exec(roles);
5139
+ if (open) out.push(open[1]);
5140
+ else if (!roles || roles.includes("%")) out.push(null);
5141
+ }
5142
+ }
5143
+ return out;
5144
+ }
5101
5145
  function checkGrants(ctx, migrations, exposed) {
5102
5146
  const fix = "grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives";
5103
5147
  const open = (roles) => roles.filter((r) => r === "anon" || r === "public");
@@ -5108,7 +5152,19 @@ function checkGrants(ctx, migrations, exposed) {
5108
5152
  return null;
5109
5153
  };
5110
5154
  for (const { file, statements } of migrations) {
5111
- for (const { sql, line } of statements) {
5155
+ for (const { sql, line, bodies } of statements) {
5156
+ const dynamic = bodies.flatMap(dynamicGrants);
5157
+ if (dynamic.length) {
5158
+ const named = [...new Set(dynamic.filter((r) => r !== null))];
5159
+ ctx.report({
5160
+ rule: "migration-grants",
5161
+ level: "warn",
5162
+ file,
5163
+ line,
5164
+ subject: "dynamic grant",
5165
+ message: named.length ? `builds a grant to ${named.join(" and ")} in dynamic SQL (execute), so the doctor can't check what it grants; name each object and role in a static grant, or make sure every target is in an exposed schema` : "builds a grant to a computed role in dynamic SQL (execute), so the doctor can't check it isn't anon or public; name the role in the grant"
5166
+ });
5167
+ }
5112
5168
  const all = /^grant\b.*\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);
5113
5169
  if (all) {
5114
5170
  const hit = blanket(granteesOf(all[1]));
@@ -6046,23 +6102,43 @@ function checkRemovedScopeNames(ctx) {
6046
6102
  }
6047
6103
  var SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
6048
6104
  var DECLARATION = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\n(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/g;
6105
+ var REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
6106
+ function specifierParts(spec) {
6107
+ return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
6108
+ }
6109
+ function tagOf(comment) {
6110
+ const doc = comment.replace(/^[ \t]*\*?[ \t]*/gm, "");
6111
+ const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
6112
+ const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
6113
+ const note = deprecated?.[1].replace(/\s+/g, " ").trim();
6114
+ if (deprecated) return { stability: "deprecated", ...note ? { note } : {} };
6115
+ return stability ? { stability } : void 0;
6116
+ }
6049
6117
  function stabilityTagsIn(dts) {
6050
6118
  const tags = /* @__PURE__ */ new Map();
6051
6119
  for (const m of dts.matchAll(DECLARATION)) {
6052
- const doc = m[1].replace(/^[ \t]*\*?[ \t]*/gm, "");
6053
- const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
6054
- const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
6055
- const note = deprecated?.[1].replace(/\s+/g, " ").trim();
6056
- if (deprecated) tags.set(m[2], { stability: "deprecated", ...note ? { note } : {} });
6057
- else if (stability) tags.set(m[2], { stability });
6120
+ const tag = tagOf(m[1]);
6121
+ if (tag) tags.set(m[2], tag);
6058
6122
  }
6123
+ for (const [name, tag] of taggedReexports(dts)) tags.set(name, tag);
6059
6124
  return tags;
6060
6125
  }
6061
- function genesisNamedImports(code) {
6126
+ function* taggedReexports(dts) {
6127
+ for (const m of dts.matchAll(REEXPORT)) {
6128
+ const tag = tagOf(m[1]);
6129
+ if (!tag) continue;
6130
+ for (const spec of m[2].split(",")) {
6131
+ const name = specifierParts(spec).pop();
6132
+ if (name) yield [name, tag];
6133
+ }
6134
+ }
6135
+ }
6136
+ function genesisNamedImports(source) {
6062
6137
  const out = [];
6138
+ const code = stripForImports(source) ?? source;
6063
6139
  const re = /import\s+(?:type\s+)?(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*["']((@marktiderman\/genesis[\w-]*)(?:\/[^"']*)?)["']/g;
6064
6140
  for (const m of code.matchAll(re)) {
6065
- const names = m[1].split(",").map((n) => n.trim().replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim()).filter(Boolean);
6141
+ const names = m[1].split(",").map((n) => specifierParts(n)[0]).filter(Boolean);
6066
6142
  out.push({ pkg: m[3], specifier: m[2], names, line: code.slice(0, m.index).split("\n").length });
6067
6143
  }
6068
6144
  return out;
@@ -6075,13 +6151,6 @@ function declarationFiles(dir, out = []) {
6075
6151
  }
6076
6152
  return out;
6077
6153
  }
6078
- function packageDir(root, pkg) {
6079
- for (let dir = path19.resolve(root); ; dir = path19.dirname(dir)) {
6080
- const candidate = path19.join(dir, "node_modules", ...pkg.split("/"));
6081
- if (existsSync(path19.join(candidate, "package.json"))) return candidate;
6082
- if (path19.dirname(dir) === dir) return null;
6083
- }
6084
- }
6085
6154
  function readPackageTags(dir) {
6086
6155
  const pkg = JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8"));
6087
6156
  const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
@@ -6090,11 +6159,12 @@ function readPackageTags(dir) {
6090
6159
  for (const file of declarationFiles(dist)) {
6091
6160
  const text = readFileSync(file, "utf8");
6092
6161
  tags.byFile.set(file, stabilityTagsIn(text));
6162
+ const names = /* @__PURE__ */ new Set();
6093
6163
  for (const m of text.matchAll(/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/gm)) {
6094
- const files = tags.declaredIn.get(m[1]) ?? [];
6095
- if (!files.includes(file)) files.push(file);
6096
- tags.declaredIn.set(m[1], files);
6164
+ names.add(m[1]);
6097
6165
  }
6166
+ for (const [name] of taggedReexports(text)) names.add(name);
6167
+ for (const name of names) tags.declaredIn.set(name, [...tags.declaredIn.get(name) ?? [], file]);
6098
6168
  }
6099
6169
  return tags;
6100
6170
  }
@@ -6114,7 +6184,7 @@ function checkStabilityImports(ctx) {
6114
6184
  const cache2 = /* @__PURE__ */ new Map();
6115
6185
  const tagsOf = (pkg) => {
6116
6186
  if (!cache2.has(pkg)) {
6117
- const dir = packageDir(ctx.root, pkg);
6187
+ const dir = findPackageDir(ctx.root, pkg);
6118
6188
  cache2.set(pkg, dir ? readPackageTags(dir) : null);
6119
6189
  }
6120
6190
  return cache2.get(pkg);