@staff0rd/assist 0.268.0 → 0.269.0

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +39 -23
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -229,7 +229,7 @@ The first backlog command in a repository that still has a local `.assist/backlo
229
229
  - `assist complexity <pattern>` - Analyze a file (all metrics if single match, maintainability if multiple)
230
230
  - `assist complexity cyclomatic [pattern]` - Calculate cyclomatic complexity per function
231
231
  - `assist complexity halstead [pattern]` - Calculate Halstead metrics per function
232
- - `assist complexity maintainability [pattern]` - Calculate maintainability index per file
232
+ - `assist complexity maintainability [pattern]` - Calculate maintainability index per file (`--ignore <glob>`, repeatable, excludes extra files on top of `complexity.ignore`)
233
233
  - `assist complexity sloc [pattern]` - Count source lines of code per file
234
234
  - `assist transcript configure` - Configure transcript directories
235
235
  - `assist transcript format` - Convert VTT files to formatted markdown transcripts
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.268.0",
9
+ version: "0.269.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -7596,11 +7596,10 @@ import ts5 from "typescript";
7596
7596
  import fs12 from "fs";
7597
7597
  import path18 from "path";
7598
7598
  import { minimatch as minimatch4 } from "minimatch";
7599
- function applyIgnoreGlobs(files) {
7599
+ function applyIgnoreGlobs(files, extraIgnore = []) {
7600
7600
  const { complexity } = loadConfig();
7601
- return files.filter(
7602
- (f) => !complexity.ignore.some((glob) => minimatch4(f, glob))
7603
- );
7601
+ const ignore2 = [...complexity.ignore, ...extraIgnore];
7602
+ return files.filter((f) => !ignore2.some((glob) => minimatch4(f, glob)));
7604
7603
  }
7605
7604
  function walk(dir, results) {
7606
7605
  if (!fs12.existsSync(dir)) {
@@ -7619,21 +7618,27 @@ function walk(dir, results) {
7619
7618
  }
7620
7619
  }
7621
7620
  }
7622
- function findSourceFiles2(pattern2, baseDir = ".") {
7621
+ function findSourceFiles2(pattern2, baseDir = ".", extraIgnore = []) {
7623
7622
  const results = [];
7624
7623
  if (pattern2.includes("*")) {
7625
7624
  walk(baseDir, results);
7626
- return applyIgnoreGlobs(results.filter((f) => minimatch4(f, pattern2)));
7625
+ return applyIgnoreGlobs(
7626
+ results.filter((f) => minimatch4(f, pattern2)),
7627
+ extraIgnore
7628
+ );
7627
7629
  }
7628
7630
  if (fs12.existsSync(pattern2) && fs12.statSync(pattern2).isFile()) {
7629
7631
  return [pattern2];
7630
7632
  }
7631
7633
  if (fs12.existsSync(pattern2) && fs12.statSync(pattern2).isDirectory()) {
7632
7634
  walk(pattern2, results);
7633
- return applyIgnoreGlobs(results);
7635
+ return applyIgnoreGlobs(results, extraIgnore);
7634
7636
  }
7635
7637
  walk(baseDir, results);
7636
- return applyIgnoreGlobs(results.filter((f) => minimatch4(f, pattern2)));
7638
+ return applyIgnoreGlobs(
7639
+ results.filter((f) => minimatch4(f, pattern2)),
7640
+ extraIgnore
7641
+ );
7637
7642
  }
7638
7643
 
7639
7644
  // src/commands/complexity/shared/getNodeName.ts
@@ -7832,8 +7837,8 @@ function createSourceFromFile(filePath) {
7832
7837
  filePath.endsWith(".tsx") ? ts5.ScriptKind.TSX : ts5.ScriptKind.TS
7833
7838
  );
7834
7839
  }
7835
- function withSourceFiles(pattern2, callback) {
7836
- const files = findSourceFiles2(pattern2);
7840
+ function withSourceFiles(pattern2, callback, extraIgnore = []) {
7841
+ const files = findSourceFiles2(pattern2, ".", extraIgnore);
7837
7842
  if (files.length === 0) {
7838
7843
  console.log(chalk79.yellow("No files found matching pattern"));
7839
7844
  return void 0;
@@ -7919,6 +7924,15 @@ Analyzed ${results.length} functions across ${files.length} files`
7919
7924
  // src/commands/complexity/maintainability/index.ts
7920
7925
  import fs14 from "fs";
7921
7926
 
7927
+ // src/commands/complexity/maintainability/calculateMaintainabilityIndex.ts
7928
+ function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
7929
+ if (halsteadVolume === 0 || sloc2 === 0) {
7930
+ return 100;
7931
+ }
7932
+ const mi = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(sloc2);
7933
+ return Math.max(0, Math.min(100, mi));
7934
+ }
7935
+
7922
7936
  // src/commands/complexity/maintainability/displayMaintainabilityResults.ts
7923
7937
  import chalk82 from "chalk";
7924
7938
  function displayMaintainabilityResults(results, threshold) {
@@ -7956,13 +7970,6 @@ function printMaintainabilityFormula() {
7956
7970
  }
7957
7971
 
7958
7972
  // src/commands/complexity/maintainability/index.ts
7959
- function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
7960
- if (halsteadVolume === 0 || sloc2 === 0) {
7961
- return 100;
7962
- }
7963
- const mi = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(sloc2);
7964
- return Math.max(0, Math.min(100, mi));
7965
- }
7966
7973
  function collectFileMetrics(files) {
7967
7974
  const fileMetrics = /* @__PURE__ */ new Map();
7968
7975
  for (const file of files) {
@@ -7997,11 +8004,15 @@ function aggregateResults(fileMetrics) {
7997
8004
  }
7998
8005
  async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
7999
8006
  printMaintainabilityFormula();
8000
- withSourceFiles(pattern2, (files) => {
8001
- const fileMetrics = collectFileMetrics(files);
8002
- const results = aggregateResults(fileMetrics);
8003
- displayMaintainabilityResults(results, options2.threshold);
8004
- });
8007
+ withSourceFiles(
8008
+ pattern2,
8009
+ (files) => {
8010
+ const fileMetrics = collectFileMetrics(files);
8011
+ const results = aggregateResults(fileMetrics);
8012
+ displayMaintainabilityResults(results, options2.threshold);
8013
+ },
8014
+ options2.ignore ?? []
8015
+ );
8005
8016
  }
8006
8017
 
8007
8018
  // src/commands/complexity/sloc.ts
@@ -8077,6 +8088,11 @@ function registerComplexity(program2) {
8077
8088
  "--threshold <number>",
8078
8089
  "Min maintainability threshold",
8079
8090
  Number.parseInt
8091
+ ).option(
8092
+ "--ignore <glob>",
8093
+ "Glob of files to exclude (repeatable, additive to config)",
8094
+ (value, previous) => previous.concat([value]),
8095
+ []
8080
8096
  ).action(maintainability);
8081
8097
  complexityCommand.command("sloc [pattern]").description("Count source lines of code per file").option("--threshold <number>", "Max lines threshold", Number.parseInt).action(sloc);
8082
8098
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.268.0",
3
+ "version": "0.269.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {