@driftless-sh/cli 0.1.46 → 0.1.48

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/index.js CHANGED
@@ -213426,11 +213426,26 @@ var require_nestjs_extractor = __commonJS({
213426
213426
  }
213427
213427
  return null;
213428
213428
  }
213429
+ function calleeName(expr) {
213430
+ if (typescript_1.default.isIdentifier(expr))
213431
+ return expr.text;
213432
+ if (typescript_1.default.isPropertyAccessExpression(expr) && typescript_1.default.isIdentifier(expr.name))
213433
+ return expr.name.text;
213434
+ return null;
213435
+ }
213429
213436
  function argText(arg) {
213430
213437
  if (typescript_1.default.isStringLiteralLike(arg))
213431
213438
  return [arg.text];
213432
213439
  if (typescript_1.default.isIdentifier(arg))
213433
213440
  return [arg.text];
213441
+ if (typescript_1.default.isCallExpression(arg) || typescript_1.default.isNewExpression(arg)) {
213442
+ const n = calleeName(arg.expression);
213443
+ return n ? [n] : [];
213444
+ }
213445
+ if (typescript_1.default.isPropertyAccessExpression(arg)) {
213446
+ const n = calleeName(arg);
213447
+ return n ? [n] : [];
213448
+ }
213434
213449
  if (typescript_1.default.isObjectLiteralExpression(arg)) {
213435
213450
  const out = [];
213436
213451
  for (const prop of arg.properties) {
@@ -213462,10 +213477,11 @@ var require_nestjs_extractor = __commonJS({
213462
213477
  for (const d of decs || []) {
213463
213478
  if (getDecoratorName(d) !== "Module")
213464
213479
  continue;
213480
+ const emptyMeta = { imports: [], providers: [], controllers: [], globalGuards: [] };
213465
213481
  if (!typescript_1.default.isCallExpression(d.expression) || d.expression.arguments.length === 0)
213466
- return { imports: [], providers: [], controllers: [] };
213482
+ return emptyMeta;
213467
213483
  const obj = d.expression.arguments[0];
213468
- const meta = { imports: [], providers: [], controllers: [] };
213484
+ const meta = { imports: [], providers: [], controllers: [], globalGuards: [] };
213469
213485
  if (typescript_1.default.isObjectLiteralExpression(obj)) {
213470
213486
  for (const prop of obj.properties) {
213471
213487
  if (!typescript_1.default.isPropertyAssignment(prop) || !typescript_1.default.isIdentifier(prop.name))
@@ -213476,8 +213492,27 @@ var require_nestjs_extractor = __commonJS({
213476
213492
  if (!typescript_1.default.isArrayLiteralExpression(prop.initializer))
213477
213493
  continue;
213478
213494
  for (const el of prop.initializer.elements) {
213479
- if (typescript_1.default.isIdentifier(el))
213495
+ if (typescript_1.default.isIdentifier(el)) {
213480
213496
  meta[key].push(el.text);
213497
+ } else if (key === "providers" && typescript_1.default.isObjectLiteralExpression(el)) {
213498
+ let isAppGuard = false;
213499
+ let guardName = null;
213500
+ for (const p of el.properties) {
213501
+ if (!typescript_1.default.isPropertyAssignment(p) || !typescript_1.default.isIdentifier(p.name))
213502
+ continue;
213503
+ if (p.name.text === "provide") {
213504
+ const v = p.initializer;
213505
+ if (typescript_1.default.isIdentifier(v) && v.text === "APP_GUARD" || typescript_1.default.isPropertyAccessExpression(v) && typescript_1.default.isIdentifier(v.name) && v.name.text === "APP_GUARD") {
213506
+ isAppGuard = true;
213507
+ }
213508
+ } else if (p.name.text === "useClass" || p.name.text === "useExisting") {
213509
+ if (typescript_1.default.isIdentifier(p.initializer))
213510
+ guardName = p.initializer.text;
213511
+ }
213512
+ }
213513
+ if (isAppGuard && guardName)
213514
+ meta.globalGuards.push(guardName);
213515
+ }
213481
213516
  }
213482
213517
  }
213483
213518
  }
@@ -213873,11 +213908,12 @@ var require_nestjs_extractor = __commonJS({
213873
213908
  const controllerName = className || "UnknownController";
213874
213909
  const controllerPath = extractControllerPath(cls);
213875
213910
  const moduleName = moduleByDir.get(node_path_1.default.dirname(facts.filePath)) ?? null;
213911
+ const classGuards = (cls.decoratorArgs["UseGuards"] ?? []).filter((g) => /^[A-Z]\w*$/.test(g));
213876
213912
  for (const method of methods) {
213877
213913
  const endpointDecorators = extractEndpointPath(method, controllerPath);
213878
213914
  if (endpointDecorators.length === 0)
213879
213915
  continue;
213880
- const methodGuards = extractGuardsFromMethod(method);
213916
+ const methodGuards = [.../* @__PURE__ */ new Set([...classGuards, ...extractGuardsFromMethod(method)])];
213881
213917
  methodGuards.forEach((g) => guardNames.add(g));
213882
213918
  const { params, bodyDto, return_type } = extractEndpointParams(method);
213883
213919
  const paramInfos = params.filter((p) => p.source === "param");
@@ -213963,12 +213999,13 @@ var require_nestjs_extractor = __commonJS({
213963
213999
  }, 1));
213964
214000
  }
213965
214001
  if (decorators.includes("Module")) {
214002
+ const globalGuards = cls.moduleMeta?.globalGuards ?? [];
213966
214003
  components.push(stamp({
213967
214004
  type: "module",
213968
214005
  name: className || "UnknownModule",
213969
214006
  file_path: facts.filePath,
213970
214007
  line_number: line,
213971
- metadata: {},
214008
+ metadata: globalGuards.length > 0 ? { global_guards: globalGuards } : {},
213972
214009
  relations: extractModuleRelations(cls, symbolIndex)
213973
214010
  }, 1));
213974
214011
  }
@@ -214560,7 +214597,7 @@ async function installSkillCommand() {
214560
214597
  // src/commands/init.ts
214561
214598
  function getVersion() {
214562
214599
  try {
214563
- return "0.1.46";
214600
+ return "0.1.48";
214564
214601
  } catch {
214565
214602
  return "0.0.0";
214566
214603
  }
@@ -216615,10 +216652,14 @@ async function graphCommand(args) {
216615
216652
  const header = g2.file && g2.file !== g2.query_path ? `\u258C ${path} \u2192 ${g2.file}` : `\u258C ${path}`;
216616
216653
  console.log(`${header}
216617
216654
  `);
216655
+ if (g2.global_guards && g2.global_guards.length) {
216656
+ console.log(`global guards (APP_GUARD): ${g2.global_guards.join(", ")}
216657
+ `);
216658
+ }
216618
216659
  if (g2.entrypoints.length) {
216619
216660
  console.log("entrypoints (routes that reach this):");
216620
216661
  for (const e of g2.entrypoints) {
216621
- const guards = e.guards && e.guards.length ? ` [${e.guards.join(", ")}]` : "";
216662
+ const guards = e.guards && e.guards.length ? ` [${e.guards.join(", ")}]` : " [no auth detected \u2014 verify]";
216622
216663
  console.log(` ${e.method ?? "?"} ${e.path ?? "?"} \u2192 ${e.handler}${guards}`);
216623
216664
  }
216624
216665
  console.log("");
@@ -216652,7 +216693,10 @@ async function graphCommand(args) {
216652
216693
  console.log(` ${consumers.length} consumer component(s) across ${g.impacted_files.length} file(s)`);
216653
216694
  if (eps.length) {
216654
216695
  console.log(` ${eps.length} reachable endpoint(s):`);
216655
- for (const e of eps.slice(0, 15)) console.log(` ${e.method ?? "?"} ${e.path ?? "?"} \u2192 ${e.handler}`);
216696
+ for (const e of eps.slice(0, 15)) {
216697
+ const guards = e.guards && e.guards.length ? ` [${e.guards.join(", ")}]` : " [no auth detected \u2014 verify]";
216698
+ console.log(` ${e.method ?? "?"} ${e.path ?? "?"} \u2192 ${e.handler}${guards}`);
216699
+ }
216656
216700
  if (eps.length > 15) console.log(` \u2026 and ${eps.length - 15} more`);
216657
216701
  }
216658
216702
  console.log("");
@@ -216669,7 +216713,7 @@ async function graphCommand(args) {
216669
216713
  }
216670
216714
 
216671
216715
  // src/index.ts
216672
- var VERSION = "0.1.46";
216716
+ var VERSION = "0.1.48";
216673
216717
  var HELP_TEXT = `Driftless CLI v${VERSION} \u2014 Living repo context for humans and coding agents
216674
216718
 
216675
216719
  Install: npm install -g @driftless-sh/cli