ts-repo-utils 5.3.0 → 6.0.1

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 (40) hide show
  1. package/README.md +176 -0
  2. package/dist/cmd/assert-repo-is-clean.d.mts +3 -0
  3. package/dist/cmd/assert-repo-is-clean.d.mts.map +1 -0
  4. package/dist/cmd/assert-repo-is-clean.mjs +32 -0
  5. package/dist/cmd/assert-repo-is-clean.mjs.map +1 -0
  6. package/dist/cmd/check-should-run-type-checks.d.mts +3 -0
  7. package/dist/cmd/check-should-run-type-checks.d.mts.map +1 -0
  8. package/dist/cmd/check-should-run-type-checks.mjs +42 -0
  9. package/dist/cmd/check-should-run-type-checks.mjs.map +1 -0
  10. package/dist/cmd/format-diff-from.d.mts +3 -0
  11. package/dist/cmd/format-diff-from.d.mts.map +1 -0
  12. package/dist/cmd/format-diff-from.mjs +45 -0
  13. package/dist/cmd/format-diff-from.mjs.map +1 -0
  14. package/dist/cmd/format-untracked.d.mts +3 -0
  15. package/dist/cmd/format-untracked.d.mts.map +1 -0
  16. package/dist/cmd/format-untracked.mjs +34 -0
  17. package/dist/cmd/format-untracked.mjs.map +1 -0
  18. package/dist/cmd/gen-index-ts.d.mts +3 -0
  19. package/dist/cmd/gen-index-ts.d.mts.map +1 -0
  20. package/dist/cmd/gen-index-ts.mjs +119 -0
  21. package/dist/cmd/gen-index-ts.mjs.map +1 -0
  22. package/dist/functions/format.mjs +1 -1
  23. package/dist/functions/gen-index.d.mts +5 -11
  24. package/dist/functions/gen-index.d.mts.map +1 -1
  25. package/dist/functions/gen-index.mjs +21 -15
  26. package/dist/functions/gen-index.mjs.map +1 -1
  27. package/dist/functions/should-run.d.mts +53 -13
  28. package/dist/functions/should-run.d.mts.map +1 -1
  29. package/dist/functions/should-run.mjs +82 -23
  30. package/dist/functions/should-run.mjs.map +1 -1
  31. package/dist/index.d.mts.map +1 -1
  32. package/package.json +23 -12
  33. package/src/cmd/assert-repo-is-clean.mts +28 -0
  34. package/src/cmd/check-should-run-type-checks.mts +43 -0
  35. package/src/cmd/format-diff-from.mts +49 -0
  36. package/src/cmd/format-untracked.mts +31 -0
  37. package/src/cmd/gen-index-ts.mts +147 -0
  38. package/src/functions/gen-index.mts +36 -30
  39. package/src/functions/should-run.mts +92 -27
  40. package/src/index.mts +0 -2
@@ -3,6 +3,13 @@ import { Result, ISet, pipe, Arr, isString } from 'ts-data-forge';
3
3
  import '../node-global.mjs';
4
4
  import { assertPathExists } from './assert-path-exists.mjs';
5
5
 
6
+ const defaultConfig = {
7
+ exclude: ['**/*.{test,spec}.?(c|m)[jt]s?(x)', '**/*.d.?(c|m)ts'],
8
+ targetExtensions: ['.ts', '.tsx'],
9
+ indexFileExtension: '.ts',
10
+ exportStatementExtension: '.js', // For ESM imports, .mts resolves to .mjs
11
+ silent: false,
12
+ };
6
13
  /**
7
14
  * Generates index.ts files recursively in `config.targetDirectory`.
8
15
  *
@@ -51,21 +58,20 @@ const genIndex = async (config) => {
51
58
  }
52
59
  };
53
60
  const fillConfig = (config) => {
54
- const sourceExtensions = config.sourceExtensions ?? ['.ts'];
55
- const exportExtension = config.exportExtension ?? '.js'; // For ESM imports, .mts resolves to .mjs
61
+ const targetExtensions = config.targetExtensions ?? defaultConfig.targetExtensions;
62
+ const exportExtension = config.exportStatementExtension ?? defaultConfig.exportStatementExtension;
56
63
  return {
57
64
  formatCommand: config.formatCommand,
58
65
  targetDirectory: ISet.create(isString(config.targetDirectory)
59
66
  ? [config.targetDirectory]
60
67
  : config.targetDirectory),
61
- // eslint-disable-next-line @typescript-eslint/no-deprecated
62
- exclude: pipe(config.exclude ?? config.excludePatterns).map((exclude) => typeof exclude === 'function'
68
+ exclude: pipe(config.exclude).map((exclude) => typeof exclude === 'function'
63
69
  ? exclude
64
70
  : pipe(ISet.create(Arr.generate(function* () {
65
71
  if (exclude !== undefined && Array.isArray(exclude)) {
66
72
  yield* exclude;
67
73
  }
68
- yield '**/*.{test,spec}.?(c|m)[jt]s?(x)';
74
+ yield* defaultConfig.exclude;
69
75
  }))).map((set) => ({ relativePath, fileName, }) => {
70
76
  for (const pattern of set.values()) {
71
77
  if (micromatch.isMatch(relativePath, pattern) ||
@@ -75,10 +81,10 @@ const fillConfig = (config) => {
75
81
  }
76
82
  return false;
77
83
  }).value).value,
78
- sourceExtensions: ISet.create(sourceExtensions),
79
- indexExtension: config.indexExtension ?? '.ts',
80
- exportExtension,
81
- silent: config.silent ?? false,
84
+ targetExtensions: ISet.create(targetExtensions),
85
+ indexFileExtension: config.indexFileExtension ?? defaultConfig.indexFileExtension,
86
+ exportStatementExtension: exportExtension,
87
+ silent: config.silent ?? defaultConfig.silent,
82
88
  };
83
89
  };
84
90
  /**
@@ -124,7 +130,7 @@ const generateIndexFileForDir = async (dirPath, config, baseDir) => {
124
130
  }
125
131
  }
126
132
  const indexContent = generateIndexContent(mut_subDirectories, mut_filesToExport, config);
127
- const indexPath = path.join(dirPath, `index${config.indexExtension}`);
133
+ const indexPath = path.join(dirPath, `index${config.indexFileExtension}`);
128
134
  await fs.writeFile(indexPath, indexContent);
129
135
  echo(`Generated: ${path.relative(process.cwd(), indexPath)}`);
130
136
  }
@@ -150,7 +156,7 @@ const shouldExportFile = ({ absolutePath, filePath, config, }) => {
150
156
  const fileName = path.basename(filePath);
151
157
  const ext = path.extname(fileName);
152
158
  // Must have the correct source extension
153
- if (!config.sourceExtensions.has(ext)) {
159
+ if (!config.targetExtensions.has(ext)) {
154
160
  return false;
155
161
  }
156
162
  // Don't export the index file itself
@@ -178,14 +184,14 @@ const shouldExportFile = ({ absolutePath, filePath, config, }) => {
178
184
  */
179
185
  const generateIndexContent = (subDirectories, filesToExport, config) => {
180
186
  const exportStatements = [
181
- ...subDirectories.map((subDir) => config.exportExtension === 'none'
187
+ ...subDirectories.map((subDir) => config.exportStatementExtension === 'none'
182
188
  ? `export * from "./${subDir}";`
183
- : `export * from "./${subDir}/index${config.exportExtension}";`),
189
+ : `export * from "./${subDir}/index${config.exportStatementExtension}";`),
184
190
  ...filesToExport.map((file) => {
185
191
  const fileNameWithoutExt = path.basename(file, path.extname(file));
186
- return config.exportExtension === 'none'
192
+ return config.exportStatementExtension === 'none'
187
193
  ? `export * from "./${fileNameWithoutExt}";`
188
- : `export * from "./${fileNameWithoutExt}${config.exportExtension}";`;
194
+ : `export * from "./${fileNameWithoutExt}${config.exportStatementExtension}";`;
189
195
  }),
190
196
  ];
191
197
  return exportStatements.length === 0
@@ -1 +1 @@
1
- {"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAgEA;;;;;AAKG;MACU,QAAQ,GAAG,OAAO,MAAsB,KAAmB;IACtE,IAAI,CAAC,qCAAqC,CAAC;;AAG3C,IAAA,MAAM,YAAY,GAA2B,UAAU,CAAC,MAAM,CAAC;;AAG/D,IAAA,MAAM,UAAU,GACd,OAAO,MAAM,CAAC,eAAe,KAAK;AAChC,UAAE,CAAC,MAAM,CAAC,eAAe;AACzB,UAAE,MAAM,CAAC,eAAe;AAE5B,IAAA,IAAI;;AAEF,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;;YAErC,MAAM,gBAAgB,CAAC,WAAW,EAAE,qBAAqB,GAAG,CAAA,CAAE,CAAC;QACjE;;QAGA,IAAI,CAAC,2BAA2B,CAAC;AACjC,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;;AAErC,YAAA,MAAM,uBAAuB,CAAC,WAAW,EAAE,YAAY,CAAC;QAC1D;QACA,IAAI,CAAC,2BAA2B,CAAC;;AAGjC,QAAA,IAAI,YAAY,CAAC,aAAa,KAAK,SAAS,EAAE;YAC5C,IAAI,CAAC,+BAA+B,CAAC;YACrC,MAAM,SAAS,GAAG,MAAM,CAA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,60 @@
1
1
  import '../node-global.mjs';
2
2
  /**
3
- * Checks if TypeScript type checks should run based on the diff from
4
- * origin/main. Skips type checks if all changed files are documentation files,
5
- * spell check config, or other non-TypeScript files that don't affect type
6
- * checking.
3
+ * Checks if TypeScript type checks should run based on the diff from a base
4
+ * branch. Skips type checks if all changed files match the ignored patterns.
7
5
  *
8
- * Ignored file patterns:
6
+ * This function is typically used in CI/CD pipelines to determine whether
7
+ * expensive type checking operations should be performed. If all changed files
8
+ * are documentation, configuration, or other non-TypeScript files, type checks
9
+ * can be safely skipped to improve build performance.
9
10
  *
10
- * - '.cspell.json'
11
- * - '**.md'
12
- * - '**.txt'
13
- * - 'docs/**'
11
+ * @example
12
+ * ```typescript
13
+ * // Use default settings (compare against origin/main, ignore docs/md/txt files)
14
+ * await checkShouldRunTypeChecks();
14
15
  *
15
- * @returns A promise that resolves when the check is complete. Sets
16
- * GITHUB_OUTPUT environment variable with should_run=true/false if running in
17
- * GitHub Actions.
16
+ * // Custom ignore patterns
17
+ * await checkShouldRunTypeChecks({
18
+ * pathsIgnore: ['.eslintrc.json', 'docs/', '**.md', 'scripts/'],
19
+ * });
20
+ *
21
+ * // Custom base branch
22
+ * await checkShouldRunTypeChecks({
23
+ * baseBranch: 'origin/develop',
24
+ * });
25
+ * ```;
26
+ *
27
+ * @example
28
+ * GitHub Actions usage
29
+ * ```yaml
30
+ * - name: Check if type checks should run
31
+ * id: check_diff
32
+ * run: npx check-should-run-type-checks
33
+ *
34
+ * - name: Run type checks
35
+ * if: steps.check_diff.outputs.should_run == 'true'
36
+ * run: npm run type-check
37
+ * ```
38
+ *
39
+ * @param options - Configuration options
40
+ * @param options.pathsIgnore - Array of patterns to ignore when determining if
41
+ * type checks should run. Supports three pattern types:
42
+ *
43
+ * - **Exact file matches**: e.g., `.cspell.json` matches only that file
44
+ * - **Directory prefixes**: e.g., `docs/` matches any file in docs directory
45
+ * - **File extensions**: e.g., `**.md` matches any markdown file Defaults to:
46
+ * `['LICENSE', '.editorconfig', '.gitignore', '.cspell.json',
47
+ * '.markdownlint-cli2.mjs', '.npmignore', '.prettierignore',
48
+ * '.prettierrc', 'docs/', '**.md', '**.txt']`
49
+ *
50
+ * @param options.baseBranch - Base branch to compare against for determining
51
+ * changed files. Defaults to `'origin/main'`
52
+ * @returns A promise that resolves when the check is complete. The function
53
+ * will set the GITHUB_OUTPUT environment variable with `should_run=true` or
54
+ * `should_run=false` if running in GitHub Actions environment.
18
55
  */
19
- export declare const checkShouldRunTypeChecks: () => Promise<void>;
56
+ export declare const checkShouldRunTypeChecks: (options?: Readonly<{
57
+ pathsIgnore?: readonly string[];
58
+ baseBranch?: string;
59
+ }>) => Promise<void>;
20
60
  //# sourceMappingURL=should-run.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-run.d.mts","sourceRoot":"","sources":["../../src/functions/should-run.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,QAAa,OAAO,CAAC,IAAI,CA4B7D,CAAC"}
1
+ {"version":3,"file":"should-run.d.mts","sourceRoot":"","sources":["../../src/functions/should-run.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAG5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,eAAO,MAAM,wBAAwB,GACnC,UAAU,QAAQ,CAAC;IACjB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,KACD,OAAO,CAAC,IAAI,CAmDd,CAAC"}
@@ -1,39 +1,98 @@
1
- import { Result, pipe } from 'ts-data-forge';
1
+ import { Result } from 'ts-data-forge';
2
2
  import '../node-global.mjs';
3
3
  import { getDiffFrom } from './diff.mjs';
4
4
 
5
5
  /**
6
- * Checks if TypeScript type checks should run based on the diff from
7
- * origin/main. Skips type checks if all changed files are documentation files,
8
- * spell check config, or other non-TypeScript files that don't affect type
9
- * checking.
6
+ * Checks if TypeScript type checks should run based on the diff from a base
7
+ * branch. Skips type checks if all changed files match the ignored patterns.
10
8
  *
11
- * Ignored file patterns:
9
+ * This function is typically used in CI/CD pipelines to determine whether
10
+ * expensive type checking operations should be performed. If all changed files
11
+ * are documentation, configuration, or other non-TypeScript files, type checks
12
+ * can be safely skipped to improve build performance.
12
13
  *
13
- * - '.cspell.json'
14
- * - '**.md'
15
- * - '**.txt'
16
- * - 'docs/**'
14
+ * @example
15
+ * ```typescript
16
+ * // Use default settings (compare against origin/main, ignore docs/md/txt files)
17
+ * await checkShouldRunTypeChecks();
17
18
  *
18
- * @returns A promise that resolves when the check is complete. Sets
19
- * GITHUB_OUTPUT environment variable with should_run=true/false if running in
20
- * GitHub Actions.
19
+ * // Custom ignore patterns
20
+ * await checkShouldRunTypeChecks({
21
+ * pathsIgnore: ['.eslintrc.json', 'docs/', '**.md', 'scripts/'],
22
+ * });
23
+ *
24
+ * // Custom base branch
25
+ * await checkShouldRunTypeChecks({
26
+ * baseBranch: 'origin/develop',
27
+ * });
28
+ * ```;
29
+ *
30
+ * @example
31
+ * GitHub Actions usage
32
+ * ```yaml
33
+ * - name: Check if type checks should run
34
+ * id: check_diff
35
+ * run: npx check-should-run-type-checks
36
+ *
37
+ * - name: Run type checks
38
+ * if: steps.check_diff.outputs.should_run == 'true'
39
+ * run: npm run type-check
40
+ * ```
41
+ *
42
+ * @param options - Configuration options
43
+ * @param options.pathsIgnore - Array of patterns to ignore when determining if
44
+ * type checks should run. Supports three pattern types:
45
+ *
46
+ * - **Exact file matches**: e.g., `.cspell.json` matches only that file
47
+ * - **Directory prefixes**: e.g., `docs/` matches any file in docs directory
48
+ * - **File extensions**: e.g., `**.md` matches any markdown file Defaults to:
49
+ * `['LICENSE', '.editorconfig', '.gitignore', '.cspell.json',
50
+ * '.markdownlint-cli2.mjs', '.npmignore', '.prettierignore',
51
+ * '.prettierrc', 'docs/', '**.md', '**.txt']`
52
+ *
53
+ * @param options.baseBranch - Base branch to compare against for determining
54
+ * changed files. Defaults to `'origin/main'`
55
+ * @returns A promise that resolves when the check is complete. The function
56
+ * will set the GITHUB_OUTPUT environment variable with `should_run=true` or
57
+ * `should_run=false` if running in GitHub Actions environment.
21
58
  */
22
- const checkShouldRunTypeChecks = async () => {
23
- // paths-ignore:
24
- // - '.cspell.json'
25
- // - '**.md'
26
- // - '**.txt'
27
- // - 'docs/**'
59
+ const checkShouldRunTypeChecks = async (options) => {
60
+ const pathsIgnore = options?.pathsIgnore ?? [
61
+ 'LICENSE',
62
+ '.editorconfig',
63
+ '.gitignore',
64
+ '.cspell.json',
65
+ '.markdownlint-cli2.mjs',
66
+ '.npmignore',
67
+ '.prettierignore',
68
+ '.prettierrc',
69
+ 'docs/',
70
+ '**.md',
71
+ '**.txt',
72
+ ];
73
+ const baseBranch = options?.baseBranch ?? 'origin/main';
28
74
  const GITHUB_OUTPUT = process.env['GITHUB_OUTPUT'];
29
- const files = await getDiffFrom('origin/main');
75
+ const files = await getDiffFrom(baseBranch);
30
76
  if (Result.isErr(files)) {
31
77
  console.error('Error getting diff:', files.value);
32
78
  process.exit(1);
33
79
  }
34
- const shouldRunTsChecks = !files.value.every((file) => file === '.cspell.json' ||
35
- file.startsWith('docs/') ||
36
- pipe(path.basename(file)).map((filename) => filename.endsWith('.md') || filename.endsWith('.txt')).value);
80
+ const shouldRunTsChecks = !files.value.every((file) => pathsIgnore.some((pattern) => {
81
+ // Exact file match
82
+ if (pattern === file) {
83
+ return true;
84
+ }
85
+ // Directory prefix match (pattern ends with '/')
86
+ if (pattern.endsWith('/') && file.startsWith(pattern)) {
87
+ return true;
88
+ }
89
+ // File extension pattern match (pattern starts with '**.')
90
+ if (pattern.startsWith('**.')) {
91
+ const extension = pattern.slice(2); // Remove '**'
92
+ return path.basename(file).endsWith(extension);
93
+ }
94
+ return false;
95
+ }));
37
96
  if (GITHUB_OUTPUT !== undefined) {
38
97
  await fs.appendFile(GITHUB_OUTPUT, `should_run=${shouldRunTsChecks}\n`);
39
98
  }
@@ -1 +1 @@
1
- {"version":3,"file":"should-run.mjs","sources":["../../src/functions/should-run.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;AAgBG;AACI,MAAM,wBAAwB,GAAG,YAA0B;;;;;;IAOhE,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;AAElD,IAAA,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC;AAE9C,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,KAAK,CAAC;AACjD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjB;AAEA,IAAA,MAAM,iBAAiB,GAAY,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CACnD,CAAC,IAAI,KACH,IAAI,KAAK,cAAc;AACvB,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AACxB,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAC3B,CAAC,QAAQ,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CACpE,CAAC,KAAK,CACV;AAED,IAAA,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAA,WAAA,EAAc,iBAAiB,CAAA,EAAA,CAAI,CAAC;IACzE;AACF;;;;"}
1
+ {"version":3,"file":"should-run.mjs","sources":["../../src/functions/should-run.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDG;MACU,wBAAwB,GAAG,OACtC,O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U,CAAC,aAAa,EAAE,CAAA,WAAA,EAAc,iBAAiB,CAAA,EAAA,CAAI,CAAC;IACzE;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAEA,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-repo-utils",
3
- "version": "5.3.0",
3
+ "version": "6.0.1",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -16,13 +16,20 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "import": {
19
- "types": "./dist/type.d.mts",
19
+ "types": "./dist/types.d.mts",
20
20
  "default": "./dist/index.mjs"
21
21
  }
22
22
  }
23
23
  },
24
24
  "module": "./dist/index.mjs",
25
- "types": "./dist/type.d.mts",
25
+ "types": "./dist/types.d.mts",
26
+ "bin": {
27
+ "assert-repo-is-clean": "./src/cmd/assert-repo-is-clean.mts",
28
+ "check-should-run-type-checks": "./src/cmd/check-should-run-type-checks.mts",
29
+ "format-diff-from": "./src/cmd/format-diff-from.mts",
30
+ "format-untracked": "./src/cmd/format-untracked.mts",
31
+ "gen-index-ts": "./src/cmd/gen-index-ts.mts"
32
+ },
26
33
  "files": [
27
34
  "src",
28
35
  "dist",
@@ -35,12 +42,14 @@
35
42
  "check:ext": "tsx ./scripts/cmd/check-ext.mjs",
36
43
  "cspell": "cspell \"**\" --gitignore --gitignore-root ./ --no-progress",
37
44
  "doc": "tsx ./scripts/cmd/gen-docs.mjs",
38
- "fmt": "tsx ./scripts/cmd/fmt-diff.mjs",
45
+ "fmt": "npm exec -- format-diff-from origin/main",
39
46
  "fmt:full": "prettier --write .",
40
- "gi": "tsx ./scripts/cmd/gi.mjs",
47
+ "gi": "npm exec -- gen-index-ts ./src/functions --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --fmt 'npm run fmt'",
41
48
  "lint": "eslint .",
42
49
  "lint:fix": "eslint . --fix",
43
50
  "md": "markdownlint-cli2",
51
+ "prepare-release": "run-s sync-cli-versions fmt build doc",
52
+ "sync-cli-versions": "tsx scripts/cmd/sync-cli-versions.mts",
44
53
  "test": "npm run z:vitest -- run",
45
54
  "test:cov": "npm run z:vitest -- run --coverage",
46
55
  "test:cov:ui": "vite preview --outDir ./coverage",
@@ -54,10 +63,12 @@
54
63
  },
55
64
  "dependencies": {
56
65
  "@types/micromatch": "^4.0.9",
66
+ "cmd-ts": "^0.13.0",
57
67
  "fast-glob": "^3.3.3",
58
68
  "micromatch": "^4.0.8",
59
69
  "prettier": "^3.6.2",
60
- "ts-data-forge": "^3.0.5"
70
+ "ts-data-forge": "^3.0.5",
71
+ "tsx": "^4.20.3"
61
72
  },
62
73
  "devDependencies": {
63
74
  "@eslint/js": "^9.31.0",
@@ -71,13 +82,13 @@
71
82
  "@semantic-release/github": "^11.0.3",
72
83
  "@semantic-release/npm": "^12.0.2",
73
84
  "@semantic-release/release-notes-generator": "^14.0.3",
74
- "@types/node": "^24.1.0",
85
+ "@types/node": "^24.2.1",
75
86
  "@vitest/coverage-v8": "^3.2.4",
76
87
  "@vitest/ui": "^3.2.4",
77
88
  "conventional-changelog-conventionalcommits": "^9.1.0",
78
89
  "cspell": "^9.2.0",
79
90
  "dedent": "^1.6.0",
80
- "eslint": "^9.32.0",
91
+ "eslint": "^9.33.0",
81
92
  "eslint-import-resolver-typescript": "4.4.4",
82
93
  "eslint-plugin-array-func": "5.0.2",
83
94
  "eslint-plugin-functional": "9.0.2",
@@ -88,6 +99,7 @@
88
99
  "eslint-plugin-unicorn": "60.0.0",
89
100
  "eslint-plugin-vitest": "0.5.4",
90
101
  "markdownlint-cli2": "^0.18.1",
102
+ "npm-run-all2": "^8.0.4",
91
103
  "prettier-plugin-jsdoc": "^1.3.3",
92
104
  "prettier-plugin-organize-imports": "^4.2.0",
93
105
  "prettier-plugin-packagejson": "^2.5.19",
@@ -95,11 +107,10 @@
95
107
  "semantic-release": "^24.2.7",
96
108
  "ts-type-forge": "^2.1.1",
97
109
  "tslib": "^2.8.1",
98
- "tsx": "^4.20.3",
99
- "typedoc": "^0.28.7",
110
+ "typedoc": "^0.28.9",
100
111
  "typedoc-plugin-markdown": "^4.8.0",
101
- "typescript": "^5.8.3",
102
- "typescript-eslint": "^8.38.0",
112
+ "typescript": "^5.9.2",
113
+ "typescript-eslint": "^8.39.0",
103
114
  "vitest": "^3.2.4"
104
115
  },
105
116
  "engines": {
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env -S npx tsx
2
+
3
+ import * as cmd from 'cmd-ts';
4
+ import { assertRepoIsClean } from '../functions/index.mjs';
5
+
6
+ const cmdDef = cmd.command({
7
+ name: 'assert-repo-is-clean-cli',
8
+ version: '6.0.1',
9
+ args: {
10
+ silent: cmd.flag({
11
+ long: 'silent',
12
+ type: cmd.optional(cmd.boolean),
13
+ description: 'If true, suppresses output messages (default: false)',
14
+ }),
15
+ },
16
+ handler: (args) => {
17
+ main(args).catch((error) => {
18
+ console.error('An error occurred:', error);
19
+ process.exit(1);
20
+ });
21
+ },
22
+ });
23
+
24
+ const main = async (args: Readonly<{ silent?: boolean }>): Promise<void> => {
25
+ await assertRepoIsClean({ silent: args.silent });
26
+ };
27
+
28
+ await cmd.run(cmdDef, process.argv.slice(2));
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env -S npx tsx
2
+
3
+ import * as cmd from 'cmd-ts';
4
+ import { checkShouldRunTypeChecks } from '../functions/index.mjs';
5
+
6
+ const cmdDef = cmd.command({
7
+ name: 'check-should-run-type-checks-cli',
8
+ version: '6.0.1',
9
+ args: {
10
+ pathsIgnore: cmd.multioption({
11
+ long: 'paths-ignore',
12
+ type: cmd.optional(cmd.array(cmd.string)),
13
+ description:
14
+ 'Patterns to ignore when checking if type checks should run. Supports exact file matches, directory prefixes (ending with "/"), and file extensions (starting with "**.")',
15
+ }),
16
+ baseBranch: cmd.option({
17
+ long: 'base-branch',
18
+ type: cmd.optional(cmd.string),
19
+ description:
20
+ 'Base branch to compare against for determining changed files. Defaults to "origin/main"',
21
+ }),
22
+ },
23
+ handler: (args) => {
24
+ main(args).catch((error) => {
25
+ console.error('An error occurred:', error);
26
+ process.exit(1);
27
+ });
28
+ },
29
+ });
30
+
31
+ const main = async (
32
+ args: Readonly<{
33
+ pathsIgnore?: readonly string[];
34
+ baseBranch?: string;
35
+ }>,
36
+ ): Promise<void> => {
37
+ await checkShouldRunTypeChecks({
38
+ pathsIgnore: args.pathsIgnore,
39
+ baseBranch: args.baseBranch,
40
+ });
41
+ };
42
+
43
+ await cmd.run(cmdDef, process.argv.slice(2));
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env -S npx tsx
2
+
3
+ import * as cmd from 'cmd-ts';
4
+ import { formatDiffFrom } from '../functions/index.mjs';
5
+
6
+ const cmdDef = cmd.command({
7
+ name: 'format-diff-from-cli',
8
+ version: '6.0.1',
9
+ args: {
10
+ base: cmd.positional({
11
+ type: cmd.string,
12
+ displayName: 'base',
13
+ description: 'Base branch name or commit hash to compare against',
14
+ }),
15
+ includeUntracked: cmd.flag({
16
+ long: 'include-untracked',
17
+ type: cmd.optional(cmd.boolean),
18
+ description:
19
+ 'Include untracked files in addition to diff files (default: true)',
20
+ }),
21
+ silent: cmd.flag({
22
+ long: 'silent',
23
+ type: cmd.optional(cmd.boolean),
24
+ description: 'If true, suppresses output messages (default: false)',
25
+ }),
26
+ },
27
+ handler: (args) => {
28
+ main(args).catch((error) => {
29
+ console.error('An error occurred:', error);
30
+ process.exit(1);
31
+ });
32
+ },
33
+ });
34
+
35
+ const main = async (
36
+ args: Readonly<{
37
+ base: string;
38
+ includeUntracked?: boolean;
39
+ silent?: boolean;
40
+ }>,
41
+ ): Promise<void> => {
42
+ const result = await formatDiffFrom(args.base, args);
43
+
44
+ if (result === 'err') {
45
+ process.exit(1);
46
+ }
47
+ };
48
+
49
+ await cmd.run(cmdDef, process.argv.slice(2));
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env -S npx tsx
2
+
3
+ import * as cmd from 'cmd-ts';
4
+ import { formatUntracked } from '../functions/index.mjs';
5
+
6
+ const cmdDef = cmd.command({
7
+ name: 'format-untracked-cli',
8
+ version: '6.0.1',
9
+ args: {
10
+ silent: cmd.flag({
11
+ long: 'silent',
12
+ type: cmd.optional(cmd.boolean),
13
+ description: 'If true, suppresses output messages (default: false)',
14
+ }),
15
+ },
16
+ handler: (args) => {
17
+ main(args).catch((error) => {
18
+ console.error('An error occurred:', error);
19
+ process.exit(1);
20
+ });
21
+ },
22
+ });
23
+
24
+ const main = async (args: Readonly<{ silent?: boolean }>): Promise<void> => {
25
+ const result = await formatUntracked({ silent: args.silent });
26
+ if (result === 'err') {
27
+ process.exit(1);
28
+ }
29
+ };
30
+
31
+ await cmd.run(cmdDef, process.argv.slice(2));