ts-repo-utils 6.2.0 → 7.0.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 (34) hide show
  1. package/README.md +148 -32
  2. package/dist/cmd/assert-repo-is-clean.mjs +1 -1
  3. package/dist/cmd/check-should-run-type-checks.mjs +1 -1
  4. package/dist/cmd/format-diff-from.mjs +1 -1
  5. package/dist/cmd/format-uncommitted.mjs +1 -1
  6. package/dist/cmd/gen-index-ts.mjs +1 -1
  7. package/dist/functions/assert-repo-is-clean.d.mts.map +1 -1
  8. package/dist/functions/assert-repo-is-clean.mjs +30 -30
  9. package/dist/functions/assert-repo-is-clean.mjs.map +1 -1
  10. package/dist/functions/diff.d.mts +2 -2
  11. package/dist/functions/diff.mjs +4 -4
  12. package/dist/functions/diff.mjs.map +1 -1
  13. package/dist/functions/exec-async.d.mts +3 -3
  14. package/dist/functions/exec-async.d.mts.map +1 -1
  15. package/dist/functions/exec-async.mjs +5 -5
  16. package/dist/functions/exec-async.mjs.map +1 -1
  17. package/dist/functions/format.d.mts.map +1 -1
  18. package/dist/functions/format.mjs +12 -25
  19. package/dist/functions/format.mjs.map +1 -1
  20. package/dist/functions/gen-index.d.mts +2 -1
  21. package/dist/functions/gen-index.d.mts.map +1 -1
  22. package/dist/functions/gen-index.mjs +10 -8
  23. package/dist/functions/gen-index.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/src/cmd/assert-repo-is-clean.mts +1 -1
  26. package/src/cmd/check-should-run-type-checks.mts +1 -1
  27. package/src/cmd/format-diff-from.mts +1 -1
  28. package/src/cmd/format-uncommitted.mts +1 -1
  29. package/src/cmd/gen-index-ts.mts +1 -1
  30. package/src/functions/assert-repo-is-clean.mts +43 -34
  31. package/src/functions/diff.mts +4 -4
  32. package/src/functions/exec-async.mts +20 -28
  33. package/src/functions/format.mts +14 -25
  34. package/src/functions/gen-index.mts +16 -10
package/README.md CHANGED
@@ -86,9 +86,9 @@ npm exec -- format-uncommitted --silent
86
86
 
87
87
  **Options:**
88
88
 
89
- - `--exclude-untracked` - Exclude untracked files in addition to diff files (default: false)
90
- - `--exclude-modified` - Exclude modified files in addition to diff files (default: false)
91
- - `--exclude-staged` - Exclude staged files in addition to diff files (default: false)
89
+ - `--exclude-untracked` - Exclude untracked files (default: false)
90
+ - `--exclude-modified` - Exclude modified files (default: false)
91
+ - `--exclude-staged` - Exclude staged files (default: false)
92
92
  - `--silent` - Suppress output messages (default: false)
93
93
 
94
94
  ### `format-diff-from`
@@ -115,9 +115,9 @@ npm exec -- format-diff-from main --silent
115
115
  **Options:**
116
116
 
117
117
  - `<base>` - Base branch name or commit hash to compare against (required)
118
- - `--exclude-untracked` - Exclude untracked files in addition to diff files (default: false)
119
- - `--exclude-modified` - Exclude modified files in addition to diff files (default: false)
120
- - `--exclude-staged` - Exclude staged files in addition to diff files (default: false)
118
+ - `--exclude-untracked` - Exclude untracked files (default: false)
119
+ - `--exclude-modified` - Exclude modified files (default: false)
120
+ - `--exclude-staged` - Exclude staged files (default: false)
121
121
  - `--silent` - Suppress output messages (default: false)
122
122
 
123
123
  ### `check-should-run-type-checks`
@@ -283,9 +283,49 @@ import { assertRepoIsClean } from 'ts-repo-utils';
283
283
  await assertRepoIsClean();
284
284
  ```
285
285
 
286
+ **Options:**
287
+
288
+ - `silent?` - Suppress output messages (default: false)
289
+
290
+ #### Getting Git diff files
291
+
292
+ ##### `getUntrackedFiles(options?)`
293
+
294
+ Get untracked files from the working tree (files not added to git).
295
+ Runs `git ls-files --others --exclude-standard [--deleted]`
296
+
297
+ ##### `getModifiedFiles(options?)`
298
+
299
+ Get modified files from the working tree (files that have been changed but not staged).
300
+ Runs `git diff --name-only [--diff-filter=d]`
301
+
302
+ ##### `getStagedFiles(options?)`
303
+
304
+ Get files that are staged for commit (files added with git add).
305
+ Runs `git diff --staged --name-only [--diff-filter=d]`
306
+
307
+ ##### `getDiffFrom(base: string, options?)`
308
+
309
+ Get files that differ from the specified base branch or commit.
310
+ Runs `git diff --name-only <base> [--diff-filter=d]`
311
+
312
+ **Common options:**
313
+
314
+ - `excludeDeleted?: boolean` - Exclude deleted files (for formatters etc.) (default: true)
315
+ - `silent?: boolean` - Don't log command/output (default: false)
316
+
317
+ **Common Return Type:**
318
+
319
+ ```typescript
320
+ type Ret = Result<
321
+ readonly string[],
322
+ ExecException | Readonly<{ message: string }>
323
+ >;
324
+ ```
325
+
286
326
  ### Command Execution
287
327
 
288
- #### `$(command: string, options?: { silent?: boolean; timeout?: number }): Promise<ExecResult>`
328
+ #### `$(command: string, options?: ExecOptions): Promise<ExecResult>`
289
329
 
290
330
  Executes a shell command asynchronously with timeout support and type-safe results.
291
331
 
@@ -304,45 +344,69 @@ if (result.type === 'ok') {
304
344
  **Options:**
305
345
 
306
346
  - `silent?: boolean` - Don't log command/output (default: false)
307
- - `timeout?: number` - Timeout in milliseconds (default: 30000)
347
+ - `'node:child_process'` `exec` function options
308
348
 
309
349
  **Return Type:**
310
350
 
311
351
  ```typescript
312
- type ExecResult = Readonly<
313
- | { type: 'ok'; stdout: string; stderr: string }
314
- | { type: 'error'; exception: ExecException }
352
+ type Ret = Promise<
353
+ Result<
354
+ Readonly<{ stdout: string | Buffer; stderr: string | Buffer }>,
355
+ import('node:child_process').ExecException
356
+ >
315
357
  >;
316
358
  ```
317
359
 
318
360
  ### Code Formatting Utilities
319
361
 
320
- #### `formatFiles(pathGlob: string): Promise<'ok' | 'err'>`
362
+ #### `formatFilesGlob(pathGlob: string): Promise<Result<undefined, unknown>>`
321
363
 
322
364
  Format files matching a glob pattern using Prettier.
323
365
 
324
366
  ```typescript
325
- import { formatFiles } from 'ts-repo-utils';
367
+ import { formatFilesGlob } from 'ts-repo-utils';
326
368
 
327
369
  // Format all TypeScript files in src
328
- await formatFiles('src/**/*.ts');
370
+ await formatFilesGlob('src/**/*.ts');
329
371
 
330
372
  // Format specific files
331
- await formatFiles('src/{index,utils}.ts');
373
+ await formatFilesGlob('src/{index,utils}.ts');
332
374
  ```
333
375
 
334
- #### `formatUntracked(): Promise<'ok' | 'err'>`
376
+ **Options:**
377
+
378
+ - `silent?` - Suppress output messages (default: false)
379
+
380
+ #### `formatUncommittedFiles(): Promise<Result>`
335
381
 
336
382
  Format only files that have been changed according to git status.
337
383
 
338
384
  ```typescript
339
- import { formatUntracked } from 'ts-repo-utils';
385
+ import { formatUncommittedFiles } from 'ts-repo-utils';
340
386
 
341
387
  // Format only modified files
342
- await formatUntracked();
388
+ await formatUncommittedFiles();
343
389
  ```
344
390
 
345
- #### `formatDiffFrom(base: string): Promise<'ok' | 'err'>`
391
+ **Options:**
392
+
393
+ - `untracked?` - Format untracked files (default: true)
394
+ - `modified?` - Format modified files (default: true)
395
+ - `staged?` - Format staged files (default: true)
396
+ - `silent?` - Suppress output messages (default: false)
397
+
398
+ **Return Type:**
399
+
400
+ ```typescript
401
+ type Ret = Promise<
402
+ Result<
403
+ undefined,
404
+ ExecException | Readonly<{ message: string }> | readonly unknown[]
405
+ >
406
+ >;
407
+ ```
408
+
409
+ #### `formatDiffFrom(base: string): Promise<Result>`
346
410
 
347
411
  Format only files that differ from the specified base branch or commit.
348
412
 
@@ -356,9 +420,27 @@ await formatDiffFrom('main');
356
420
  await formatDiffFrom('abc123');
357
421
  ```
358
422
 
423
+ **Options:**
424
+
425
+ - `includeUntracked?` - Include untracked files in addition to diff files (default: true)
426
+ - `includeModified?` - Include modified files in addition to diff files (default: true)
427
+ - `includeStaged?` - Include staged files in addition to diff files (default: true)
428
+ - `silent?` - Suppress output messages (default: false)
429
+
430
+ **Return Type:**
431
+
432
+ ```typescript
433
+ type Ret = Promise<
434
+ Result<
435
+ undefined,
436
+ ExecException | Readonly<{ message: string }> | readonly unknown[]
437
+ >
438
+ >;
439
+ ```
440
+
359
441
  ### Index File Generation
360
442
 
361
- #### `genIndex(config: GenIndexConfig): Promise<void>`
443
+ #### `genIndex(config: GenIndexConfig): Promise<Result<undefined, unknown>>`
362
444
 
363
445
  Generates index files recursively in target directories with automatic barrel exports.
364
446
 
@@ -367,9 +449,7 @@ import { genIndex } from 'ts-repo-utils';
367
449
 
368
450
  await genIndex({
369
451
  targetDirectory: './src',
370
- sourceExtension: '.ts',
371
- exportExtension: '.js',
372
- excludePatterns: ['*.test.ts', '*.spec.ts'],
452
+ exclude: ['*.test.ts', '*.spec.ts'],
373
453
  });
374
454
  ```
375
455
 
@@ -377,10 +457,41 @@ await genIndex({
377
457
 
378
458
  ```typescript
379
459
  type GenIndexConfig = DeepReadonly<{
380
- targetDirectory: string | string[]; // Target directories to generate index files for
381
- sourceExtension?: `.${string}`; // File extension of source files (default: '.mts')
382
- exportExtension?: `.${string}`; // Extension to use in exports (default: '.mjs')
383
- excludePatterns?: string[]; // Glob patterns to exclude (default: excludes .d.* and .test.*)
460
+ /**
461
+ * Target directories to generate index files for (string or array of
462
+ * strings)
463
+ */
464
+ targetDirectory: string | readonly string[];
465
+
466
+ /**
467
+ * Glob patterns of files or predicate function to exclude from exports
468
+ * (default: excludes `'**\/*.{test,spec}.?(c|m)[jt]s?(x)'` and
469
+ * `'**\/*.d.?(c|m)ts'`)
470
+ */
471
+ exclude?:
472
+ | readonly string[]
473
+ | ((
474
+ args: Readonly<{
475
+ absolutePath: string;
476
+ relativePath: string;
477
+ fileName: string;
478
+ }>,
479
+ ) => boolean);
480
+
481
+ /** File extensions of source files to export (default: ['.ts', '.tsx']) */
482
+ targetExtensions?: readonly `.${string}`[];
483
+
484
+ /** File extension of index files to generate (default: '.ts') */
485
+ indexFileExtension?: `.${string}`;
486
+
487
+ /** File extension to use in export statements (default: '.js') */
488
+ exportStatementExtension?: `.${string}` | 'none';
489
+
490
+ /** Command to run for formatting generated files (optional) */
491
+ formatCommand?: string;
492
+
493
+ /** Whether to suppress output during execution (default: false) */
494
+ silent?: boolean;
384
495
  }>;
385
496
  ```
386
497
 
@@ -392,6 +503,11 @@ type GenIndexConfig = DeepReadonly<{
392
503
  - Works with both single directories and directory arrays
393
504
  - Respects source and export extension configuration
394
505
 
506
+ **Benefits:**
507
+
508
+ - Prevents forgetting to export libraries
509
+ - tsc can detect duplicate variables, type names, etc.
510
+
395
511
  ## Key Features
396
512
 
397
513
  - **Type Safety**: All functions use strict TypeScript types with readonly parameters
@@ -410,14 +526,14 @@ type GenIndexConfig = DeepReadonly<{
410
526
  ```typescript
411
527
  import { formatUntracked, assertExt, assertRepoIsClean } from 'ts-repo-utils';
412
528
 
413
- // Format changed files
414
- await formatUntracked();
415
-
416
529
  // Validate file extensions
417
530
  await assertExt({
418
531
  directories: [{ path: './src', extension: '.ts' }],
419
532
  });
420
533
 
534
+ // Format changed files
535
+ await formatUncommittedFiles();
536
+
421
537
  // Ensure repository is clean (exits if dirty)
422
538
  await assertRepoIsClean();
423
539
  ```
@@ -425,7 +541,7 @@ await assertRepoIsClean();
425
541
  ### Build Pipeline
426
542
 
427
543
  ```typescript
428
- import { assertExt, genIndex, $, formatFiles } from 'ts-repo-utils';
544
+ import { assertExt, genIndex, $, formatFilesGlob } from 'ts-repo-utils';
429
545
 
430
546
  // Validate extensions
431
547
  await assertExt({
@@ -445,7 +561,7 @@ await $('tsc --noEmit');
445
561
  await $('rollup -c');
446
562
 
447
563
  // Format output
448
- await formatFiles('dist/**/*.js');
564
+ await formatFilesGlob('dist/**/*.js');
449
565
  ```
450
566
 
451
567
  ### Project Validation
@@ -10,7 +10,7 @@ import 'child_process';
10
10
 
11
11
  const cmdDef = cmd.command({
12
12
  name: 'assert-repo-is-clean-cli',
13
- version: '6.2.0',
13
+ version: '7.0.0',
14
14
  args: {
15
15
  silent: cmd.flag({
16
16
  long: 'silent',
@@ -10,7 +10,7 @@ import 'child_process';
10
10
 
11
11
  const cmdDef = cmd.command({
12
12
  name: 'check-should-run-type-checks-cli',
13
- version: '6.2.0',
13
+ version: '7.0.0',
14
14
  args: {
15
15
  pathsIgnore: cmd.multioption({
16
16
  long: 'paths-ignore',
@@ -9,7 +9,7 @@ import 'child_process';
9
9
 
10
10
  const cmdDef = cmd.command({
11
11
  name: 'format-diff-from-cli',
12
- version: '6.2.0',
12
+ version: '7.0.0',
13
13
  args: {
14
14
  base: cmd.positional({
15
15
  type: cmd.string,
@@ -9,7 +9,7 @@ import 'child_process';
9
9
 
10
10
  const cmdDef = cmd.command({
11
11
  name: 'format-uncommitted-cli',
12
- version: '6.2.0',
12
+ version: '7.0.0',
13
13
  args: {
14
14
  excludeUntracked: cmd.flag({
15
15
  long: 'exclude-untracked',
@@ -28,7 +28,7 @@ const nonEmptyArray = (t, commandName) => cmd.extendType(cmd.array(t), {
28
28
  });
29
29
  const cmdDef = cmd.command({
30
30
  name: 'gen-index-ts-cli',
31
- version: '6.2.0',
31
+ version: '7.0.0',
32
32
  args: {
33
33
  // required args
34
34
  targetDirectory: cmd.positional({
@@ -1 +1 @@
1
- {"version":3,"file":"assert-repo-is-clean.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-clean.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,OAAO,CAGjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,CAiCd,CAAC"}
1
+ {"version":3,"file":"assert-repo-is-clean.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-clean.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,CAkCd,CAAC"}
@@ -9,41 +9,41 @@ import '../node-global.mjs';
9
9
  */
10
10
  const repoIsDirty = async (options) => {
11
11
  const status = await getGitStatus({ silent: options?.silent ?? false });
12
- return status.isDirty;
12
+ if (Result.isErr(status)) {
13
+ throw new Error(`Failed to get git status: ${status.value}`);
14
+ }
15
+ return status.value.isDirty;
13
16
  };
14
17
  /**
15
18
  * Checks if the repository is clean and exits with code 1 if it is dirty. Shows
16
19
  * git status and diff output before exiting.
17
20
  */
18
21
  const assertRepoIsClean = async (options) => {
19
- try {
20
- const status = await getGitStatus({ silent: options?.silent ?? false });
21
- if (!status.isDirty) {
22
- echo('Repo is clean\n');
23
- return;
24
- }
25
- echo('Repo is dirty\n');
26
- echo('Changed files:\n');
27
- echo(status.stdout);
28
- // Show files not tracked by git and unstaged changes
29
- const addResult = await $('git add -N .', {
30
- silent: options?.silent ?? false,
31
- });
32
- if (Result.isErr(addResult)) {
33
- echo('Warning: Failed to add untracked files for diff\n');
34
- }
35
- const diffResult = await $('git diff', {
36
- silent: options?.silent ?? false,
37
- });
38
- if (Result.isErr(diffResult)) {
39
- echo('Warning: Failed to show diff\n');
40
- }
41
- process.exit(1);
22
+ const silent = options?.silent ?? false;
23
+ const conditionalEcho = silent ? () => { } : echo;
24
+ const gitStatusResult = await getGitStatus({ silent });
25
+ if (Result.isErr(gitStatusResult)) {
26
+ conditionalEcho(gitStatusResult.value);
27
+ return;
28
+ }
29
+ const gitStatus = gitStatusResult.value;
30
+ if (!gitStatus.isDirty) {
31
+ conditionalEcho('Repo is clean\n');
32
+ return;
42
33
  }
43
- catch (error) {
44
- echo(`Error checking repository status: ${String(error)}\n`);
45
- process.exit(1);
34
+ conditionalEcho('Repo is dirty\n');
35
+ conditionalEcho('Changed files:\n');
36
+ conditionalEcho(gitStatus.stdout);
37
+ // Show files not tracked by git and unstaged changes
38
+ const addResult = await $('git add -N .', { silent });
39
+ if (Result.isErr(addResult)) {
40
+ conditionalEcho('Warning: Failed to add untracked files for diff\n');
46
41
  }
42
+ const diffResult = await $('git diff', { silent });
43
+ if (Result.isErr(diffResult)) {
44
+ conditionalEcho('Warning: Failed to show diff\n');
45
+ }
46
+ process.exit(1);
47
47
  };
48
48
  /**
49
49
  * Gets the git status of the repository.
@@ -55,13 +55,13 @@ const getGitStatus = async (options) => {
55
55
  silent: options?.silent ?? false,
56
56
  });
57
57
  if (Result.isErr(res)) {
58
- throw new Error(`Failed to get git status: ${res.value.message}`);
58
+ return Result.err(`Failed to get git status: ${res.value.message}`);
59
59
  }
60
60
  const { stdout } = res.value;
61
- return {
61
+ return Result.ok({
62
62
  isDirty: stdout.trim() !== '',
63
63
  stdout,
64
- };
64
+ });
65
65
  };
66
66
 
67
67
  export { assertRepoIsClean, repoIsDirty };
@@ -1 +1 @@
1
- {"version":3,"file":"assert-repo-is-clean.mjs","sources":["../../src/functions/assert-repo-is-clean.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;AAKG;MACU,WAAW,GAAG,OACzB,OAAwC,KACpB;AACpB,IAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC,OAAO;AACvB;AAEA;;;AAGG;MACU,iBAAiB,GAAG,OAC/B,OAAwC,KACvB;AACjB,IAAA,IAAI;AACF,QAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;AAEvE,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,iBAAiB,CAAC;YACvB;QACF;QAEA,IAAI,CAAC,iBAAiB,CAAC;QACvB,IAAI,CAAC,kBAAkB,CAAC;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,MAAM,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DAAmD,CAAC;IACtE;IAEA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC;AAClD,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;QAC5B,eAAe,CAAC,gCAAgC,CAAC;IACnD;AAEA,IAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB;AAEA;;;;AAIG;AACH,MAAM,YAAY,GAAG,OACnB,OAAwC,KAStC;AACF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,wBAAwB,EAAE;AAC5C,QAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;AACjC,KAAA,CAAC;AAEF,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;AACrB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA,0BAAA,EAA6B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;IACrE;AAEA,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK;IAE5B,OAAO,MAAM,CAAC,EAAE,CAAC;AACf,QAAA,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;QAC7B,MAAM;AACP,KAAA,CAAC;AACJ,CAAC;;;;"}
@@ -14,8 +14,8 @@ export declare const getUntrackedFiles: (options?: Readonly<{
14
14
  message: string;
15
15
  }>>>;
16
16
  /**
17
- * Get untracked files from the working tree (files not added to git). Runs `git
18
- * git diff --staged --name-only [--diff-filter=d]`
17
+ * Get modified files from the working tree (files that have been changed but
18
+ * not staged). Runs `git diff --name-only [--diff-filter=d]`
19
19
  */
20
20
  export declare const getModifiedFiles: (options?: Readonly<{
21
21
  /** @default true */
@@ -12,12 +12,12 @@ const getUntrackedFiles = async (options) => cmdResultToFiles({
12
12
  options,
13
13
  });
14
14
  /**
15
- * Get untracked files from the working tree (files not added to git). Runs `git
16
- * git diff --staged --name-only [--diff-filter=d]`
15
+ * Get modified files from the working tree (files that have been changed but
16
+ * not staged). Runs `git diff --name-only [--diff-filter=d]`
17
17
  */
18
18
  const getModifiedFiles = async (options) => cmdResultToFiles({
19
19
  cmd: `git diff --name-only`,
20
- cmdOptionToExcludeDeleted: '--diff-filter=d',
20
+ cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
21
21
  cmdOptionToIncludeDeleted: '',
22
22
  options,
23
23
  });
@@ -27,7 +27,7 @@ const getModifiedFiles = async (options) => cmdResultToFiles({
27
27
  */
28
28
  const getStagedFiles = async (options) => cmdResultToFiles({
29
29
  cmd: `git diff --staged --name-only`,
30
- cmdOptionToExcludeDeleted: '--diff-filter=d',
30
+ cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
31
31
  cmdOptionToIncludeDeleted: '',
32
32
  options,
33
33
  });
@@ -1 +1 @@
1
- {"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;AAGG;AACI,MAAM,iBAAiB,GAAG,OAC/B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,wCAAA,CAA0C;AAC/C,IAAA,yBAAyB,EAAE,EAAE;AAC7B,IAAA,yBAAyB,EAAE,WAAW;IACtC,OAAO;AACR,CAAA;AAEH;;;AAGG;AACI,MAAM,gBAAgB,GAAG,OAC9B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,oBAAA,CAAsB;AAC3B,IAAA,yBAAyB,EAAE,iBAAiB;AAC5C,IAAA,yBAAyB,EAAE,EAAE;IAC7B,OAAO;AACR,CAAA;AAEH;;;AAGG;AACI,MAAM,cAAc,GAAG,OAC5B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,6BAAA,CAA+B;AACpC,IAAA,yBAAyB,EAAE,iBAAiB;AAC5C,IAAA,yBAAyB,EA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A,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK;;IAG/B,MAAM,KAAK,GAAG;SACX,KAAK,CAAC,IAAI;SACV,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;SACzB,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;AAEhC,IAAA,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;AACzB,CAAC;;;;"}
@@ -1,13 +1,13 @@
1
- import { type ExecException, type ExecOptions as ExecOptions_ } from 'node:child_process';
1
+ import * as childProcess from 'node:child_process';
2
2
  import { Result } from 'ts-data-forge';
3
3
  type ExecOptionsCustom = Readonly<{
4
4
  silent?: boolean;
5
5
  }>;
6
- export type ExecOptions = DeepReadonly<ExecOptions_ & ExecOptionsCustom>;
6
+ export type ExecOptions = childProcess.ExecOptions & ExecOptionsCustom;
7
7
  export type ExecResult<T extends string | Buffer> = Result<Readonly<{
8
8
  stdout: T;
9
9
  stderr: T;
10
- }>, ExecException>;
10
+ }>, childProcess.ExecException>;
11
11
  /**
12
12
  * Executes a shell command asynchronously.
13
13
  *
@@ -1 +1 @@
1
- {"version":3,"file":"exec-async.d.mts","sourceRoot":"","sources":["../../src/functions/exec-async.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,YAAY,GAAG,iBAAiB,CAAC,CAAC;AAEzE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CACxD,QAAQ,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;I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AAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/B,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EAEf,OAAO,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,GAAG,WAAW,CAAC,GAC7D,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/B,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EAEf,OAAO,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,cAAc,CAAA;CAAE,GAAG,WAAW,CAAC,GAC5D,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC"}
@@ -1,16 +1,16 @@
1
- import { exec } from 'node:child_process';
1
+ import * as childProcess from 'node:child_process';
2
2
  import { Result } from 'ts-data-forge';
3
3
 
4
- function $(command, options) {
4
+ function $(command,
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ options) {
5
7
  const { silent = false, ...restOptions } = options ?? {};
6
8
  if (!silent) {
7
9
  echo(`$ ${command}`);
8
10
  }
9
11
  return new Promise((resolve) => {
10
12
  // eslint-disable-next-line security/detect-child-process
11
- exec(command,
12
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
13
- restOptions, (error, stdout, stderr) => {
13
+ childProcess.exec(command, restOptions, (error, stdout, stderr) => {
14
14
  if (!silent) {
15
15
  if (stdout !== '') {
16
16
  echo(stdout);
@@ -1 +1 @@
1
- {"version":3,"file":"exec-async.mjs","sources":["../../src/functions/exec-async.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAwCM,SAAU,CAAC,CACf,OAAe,EACf,OAEC,EAAA;AAED,IAAA,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,IAAI,EAAE;IAExD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,IAAI,CAAC,CAAA,EAAA,EAAK,OAAO,CAAA,C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AAsB,GACjC,UAAU,QAAQ,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,KACD,OAAO,CACR,MAAM,CACJ,SAAS,EACT,aAAa,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,OAAO,EAAE,CACnE,CAsDF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,UAAU,QAAQ,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,KACD,OAAO,CACR,MAAM,CACJ,SAAS,EACP,aAAa,GACb,QAAQ,CAAC;IACP,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,GACF,SAAS,OAAO,EAAE,CACrB,CA8EF,CAAC"}
@@ -10,15 +10,12 @@ import { getDiffFrom, getUntrackedFiles, getModifiedFiles, getStagedFiles } from
10
10
  */
11
11
  const formatFiles = async (files, options) => {
12
12
  const silent = options?.silent ?? false;
13
+ const conditionalEcho = silent ? () => { } : echo;
13
14
  if (files.length === 0) {
14
- if (!silent) {
15
- echo('No files to format');
16
- }
15
+ conditionalEcho('No files to format');
17
16
  return Result.ok(undefined);
18
17
  }
19
- if (!silent) {
20
- echo(`Formatting ${files.length} files...`);
21
- }
18
+ conditionalEcho(`Formatting ${files.length} files...`);
22
19
  // Format each file
23
20
  const results =
24
21
  // NOTE: Using Promise.allSettled to ensure all files are processed even if some fail
@@ -30,9 +27,7 @@ const formatFiles = async (files, options) => {
30
27
  }
31
28
  catch {
32
29
  // File doesn't exist, skip it
33
- if (!silent) {
34
- echo(`Skipping non-existent file: ${filePath}`);
35
- }
30
+ conditionalEcho(`Skipping non-existent file: ${filePath}`);
36
31
  return Result.ok(undefined);
37
32
  }
38
33
  // Read file content
@@ -44,9 +39,7 @@ const formatFiles = async (files, options) => {
44
39
  ignorePath: '.prettierignore',
45
40
  });
46
41
  if (fileInfo.ignored) {
47
- if (!silent) {
48
- echo(`Skipping ignored file: ${filePath}`);
49
- }
42
+ conditionalEcho(`Skipping ignored file: ${filePath}`);
50
43
  return Result.ok(undefined);
51
44
  }
52
45
  // Format the content
@@ -56,15 +49,11 @@ const formatFiles = async (files, options) => {
56
49
  });
57
50
  // Only write if content changed
58
51
  if (formatted === content) {
59
- if (!silent) {
60
- echo(`Unchanged: ${filePath}`);
61
- }
52
+ conditionalEcho(`Unchanged: ${filePath}`);
62
53
  }
63
54
  else {
64
55
  await fs.writeFile(filePath, formatted, 'utf8');
65
- if (!silent) {
66
- echo(`Formatted: ${filePath}`);
67
- }
56
+ conditionalEcho(`Formatted: ${filePath}`);
68
57
  }
69
58
  return Result.ok(undefined);
70
59
  }
@@ -101,6 +90,7 @@ const formatFiles = async (files, options) => {
101
90
  */
102
91
  const formatFilesGlob = async (pathGlob, options) => {
103
92
  const silent = options?.silent ?? false;
93
+ const conditionalEcho = silent ? () => { } : echo;
104
94
  try {
105
95
  // Find all files matching the glob
106
96
  const files = await glob(pathGlob, {
@@ -109,9 +99,7 @@ const formatFilesGlob = async (pathGlob, options) => {
109
99
  dot: true,
110
100
  });
111
101
  if (files.length === 0) {
112
- if (!silent) {
113
- echo('No files found matching pattern:', pathGlob);
114
- }
102
+ conditionalEcho('No files found matching pattern:', pathGlob);
115
103
  return Result.ok(undefined);
116
104
  }
117
105
  return await formatFiles(files, { silent });
@@ -179,6 +167,7 @@ const formatUncommittedFiles = async (options) => {
179
167
  const formatDiffFrom = async (base, options) => {
180
168
  // const silent = options?.silent ?? false;
181
169
  const { silent = false, includeUntracked = true, includeModified = true, includeStaged = true, } = options ?? {};
170
+ const conditionalEcho = silent ? () => { } : echo;
182
171
  // Get files that differ from base branch/commit (excluding deleted files)
183
172
  const diffFromBaseResult = await getDiffFrom(base, {
184
173
  silent,
@@ -224,12 +213,10 @@ const formatDiffFrom = async (base, options) => {
224
213
  .map((s, i) => i !== includedFileTypes.length - 1 ? `, ${s}` : ` and ${s}`)
225
214
  .join(''),
226
215
  ].join('');
227
- echo(`${message}:`, allFiles);
216
+ conditionalEcho(`${message}:`, allFiles);
228
217
  }
229
218
  if (allFiles.length === 0) {
230
- if (!silent) {
231
- echo('No files to format');
232
- }
219
+ conditionalEcho('No files to format');
233
220
  return Result.ok(undefined);
234
221
  }
235
222
  return formatFiles(allFiles, { silent });
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAWA;;;;AAIG;AACI,MAAM,WAAW,GAAG,OACzB,KAAwB,EACxB,OAAwC,KACU;AAClD,IAAA,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK;AAEvC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,CAAC,oBAAoB,CAAC;QAC5B;AACA,QAAA,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7B;IAEA,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,IAAI,CAAC,CAAA,WAAA,EAAc,KAAK,CAAC,MAAM,CAAA,SAAA,CAAW,CAAC;IAC7C;;AAGA,IAAA,MAAM,OAAO;;AAEX,IAAA,MAAM,OAAO,CAAC,UAAU,CACtB,KAAK,CAAC,GAAG,CAAC,OAAO,QAAQ,KAAI;AAC3B,QAAA,IAAI;;AAEF,YAAA,IAAI;AACF,gBAAA,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC3B;AAAE,YAAA,MAAM;;gBAEN,IAAI,CAAC,MAAM,EAAE;AACX,oB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a,GAAG,cAAc,GAAG,SAAS;AAC3C,SAAA,CAAC,MAAM,CAAC,cAAc,CAAC;AAExB,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,CAAA,kCAAA,EAAqC,IAAI,CAAA,CAAE;YAC3C;iBACG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KACR,CAAC,KAAK,iBAAiB,CAAC,MAAM,GAAG,CAAC,GAAG,CAAA,EAAA,EAAK,CAAC,CAAA,CAAE,GAAG,CAAA,KAAA,EAAQ,CAAC,CAAA,CAAE;iBAE5D,IAAI,CAAC,EAAE,CAAC;AACZ,SAAA,CAAC,IAAI,CAAC,EAAE,CAAC;AAEV,QAAA,eAAe,CAAC,CAAA,EAAG,OAAO,GAAG,EAAE,QAAQ,CAAC;IAC1C;AAEA,IAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,eAAe,CAAC,oBAAoB,CAAC;AACrC,QAAA,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7B;IAEA,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC;AAC1C;;;;"}
@@ -1,3 +1,4 @@
1
+ import { Result } from 'ts-data-forge';
1
2
  import '../node-global.mjs';
2
3
  /** Configuration for index file generation. */
3
4
  export type GenIndexConfig = DeepReadonly<{
@@ -30,5 +31,5 @@ export type GenIndexConfig = DeepReadonly<{
30
31
  * @param config - Configuration for index file generation
31
32
  * @throws Error if any step fails.
32
33
  */
33
- export declare const genIndex: (config: GenIndexConfig) => Promise<void>;
34
+ export declare const genIndex: (config: GenIndexConfig) => Promise<Result<undefined, unknown>>;
34
35
  //# sourceMappingURL=gen-index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AAEA,OAAO,oBAAoB,CAAC;AAG5B,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;IACxC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,CAAC;IAElB,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,SAAS,IAAI,MAAM,EAAE,EAAE,CAAC;IAE3C,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAElC,kEAAkE;IAClE,wBAAwB,CAAC,EAAE,IAAI,MAAM,EAAE,GAAG,MAAM,CAAC;IAEjD,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AA4BH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,QAAQ,cAAc,KACrB,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAkDpC,CAAC"}
@@ -17,9 +17,10 @@ const defaultConfig = {
17
17
  * @throws Error if any step fails.
18
18
  */
19
19
  const genIndex = async (config) => {
20
- echo('Starting index file generation...\n');
21
20
  // Merge config with defaults
22
21
  const filledConfig = fillConfig(config);
22
+ const conditionalEcho = filledConfig.silent ? () => { } : echo;
23
+ conditionalEcho('Starting index file generation...\n');
23
24
  // Normalize target directories to array
24
25
  const targetDirs = typeof config.targetDirectory === 'string'
25
26
  ? [config.targetDirectory]
@@ -32,29 +33,30 @@ const genIndex = async (config) => {
32
33
  await assertPathExists(resolvedDir, `Target directory: ${dir}`);
33
34
  }
34
35
  // Step 2: Generate index files
35
- echo('Generating index files...');
36
+ conditionalEcho('Generating index files...');
36
37
  for (const dir of targetDirs) {
37
38
  const resolvedDir = path.resolve(dir);
38
39
  // eslint-disable-next-line no-await-in-loop
39
40
  await generateIndexFileForDir(resolvedDir, filledConfig);
40
41
  }
41
- echo('✓ Index files generated\n');
42
+ conditionalEcho('✓ Index files generated\n');
42
43
  // Step 3: Format generated files
43
44
  if (filledConfig.formatCommand !== undefined) {
44
- echo('Formatting generated files...');
45
+ conditionalEcho('Formatting generated files...');
45
46
  const fmtResult = await $(filledConfig.formatCommand, {
46
47
  silent: filledConfig.silent,
47
48
  });
48
49
  if (Result.isErr(fmtResult)) {
49
50
  throw new Error(`Formatting failed: ${fmtResult.value.message}`);
50
51
  }
51
- echo('✓ Formatting completed\n');
52
+ conditionalEcho('✓ Formatting completed\n');
52
53
  }
53
- echo('✅ Index file generation completed successfully!\n');
54
+ conditionalEcho('✅ Index file generation completed successfully!\n');
55
+ return Result.ok(undefined);
54
56
  }
55
57
  catch (error) {
56
- echo(`❌ Index generation failed: ${String(error)}\n`);
57
- throw error;
58
+ conditionalEcho(`❌ Index generation failed: ${String(error)}\n`);
59
+ return Result.err(error);
58
60
  }
59
61
  };
60
62
  const fillConfig = (config) => {
@@ -1 +1 @@
1
- {"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAyCA,MAAM,aAAa,GAAG;AACpB,IAAA,OAAO,EAAE,CAAC,kCAAkC,EAAE,iBAAiB,CAAC;AAChE,IAAA,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;AACjC,IAAA,kBAAkB,EAAE,KAAK;IACzB,wBAAwB,EAAE,KAAK;AAC/B,IAAA,MAAM,EAAE,KAAK;CAGd;AAkBD;;;;;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;;Q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AA,iBAAA,EAAoB,MAAM,CAAA,EAAA;cAC1B,oBAAoB,MAAM,CAAA,MAAA,EAAS,MAAM,CAAC,wBAAwB,IAAI,CAC3E;AACD,QAAA,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AAC5B,YAAA,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAElE,YAAA,OAAO,MAAM,CAAC,wBAAwB,KAAK;kBACvC,CAAA,iBAAA,EAAoB,kBAAkB,CAAA,EAAA;kBACtC,oBAAoB,kBAAkB,CAAA,EAAG,MAAM,CAAC,wBAAwB,IAAI;AAClF,QAAA,CAAC,CAAC;KACH;AAED,IAAA,OAAO,gBAAgB,CAAC,MAAM,KAAK;AACjC,UAAE;AACF,UAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-repo-utils",
3
- "version": "6.2.0",
3
+ "version": "7.0.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -5,7 +5,7 @@ import { assertRepoIsClean } from '../functions/index.mjs';
5
5
 
6
6
  const cmdDef = cmd.command({
7
7
  name: 'assert-repo-is-clean-cli',
8
- version: '6.2.0',
8
+ version: '7.0.0',
9
9
  args: {
10
10
  silent: cmd.flag({
11
11
  long: 'silent',
@@ -5,7 +5,7 @@ import { checkShouldRunTypeChecks } from '../functions/index.mjs';
5
5
 
6
6
  const cmdDef = cmd.command({
7
7
  name: 'check-should-run-type-checks-cli',
8
- version: '6.2.0',
8
+ version: '7.0.0',
9
9
  args: {
10
10
  pathsIgnore: cmd.multioption({
11
11
  long: 'paths-ignore',
@@ -6,7 +6,7 @@ import { formatDiffFrom } from '../functions/index.mjs';
6
6
 
7
7
  const cmdDef = cmd.command({
8
8
  name: 'format-diff-from-cli',
9
- version: '6.2.0',
9
+ version: '7.0.0',
10
10
  args: {
11
11
  base: cmd.positional({
12
12
  type: cmd.string,
@@ -6,7 +6,7 @@ import { formatUncommittedFiles } from '../functions/index.mjs';
6
6
 
7
7
  const cmdDef = cmd.command({
8
8
  name: 'format-uncommitted-cli',
9
- version: '6.2.0',
9
+ version: '7.0.0',
10
10
  args: {
11
11
  excludeUntracked: cmd.flag({
12
12
  long: 'exclude-untracked',
@@ -38,7 +38,7 @@ const nonEmptyArray = <T extends cmd.Type<any, any>>(
38
38
 
39
39
  const cmdDef = cmd.command({
40
40
  name: 'gen-index-ts-cli',
41
- version: '6.2.0',
41
+ version: '7.0.0',
42
42
  args: {
43
43
  // required args
44
44
  targetDirectory: cmd.positional({
@@ -11,7 +11,10 @@ export const repoIsDirty = async (
11
11
  options?: Readonly<{ silent?: boolean }>,
12
12
  ): Promise<boolean> => {
13
13
  const status = await getGitStatus({ silent: options?.silent ?? false });
14
- return status.isDirty;
14
+ if (Result.isErr(status)) {
15
+ throw new Error(`Failed to get git status: ${status.value}`);
16
+ }
17
+ return status.value.isDirty;
15
18
  };
16
19
 
17
20
  /**
@@ -21,38 +24,39 @@ export const repoIsDirty = async (
21
24
  export const assertRepoIsClean = async (
22
25
  options?: Readonly<{ silent?: boolean }>,
23
26
  ): Promise<void> => {
24
- try {
25
- const status = await getGitStatus({ silent: options?.silent ?? false });
27
+ const silent = options?.silent ?? false;
28
+ const conditionalEcho = silent ? () => {} : echo;
29
+
30
+ const gitStatusResult = await getGitStatus({ silent });
31
+
32
+ if (Result.isErr(gitStatusResult)) {
33
+ conditionalEcho(gitStatusResult.value);
34
+ return;
35
+ }
26
36
 
27
- if (!status.isDirty) {
28
- echo('Repo is clean\n');
29
- return;
30
- }
37
+ const gitStatus = gitStatusResult.value;
31
38
 
32
- echo('Repo is dirty\n');
33
- echo('Changed files:\n');
34
- echo(status.stdout);
39
+ if (!gitStatus.isDirty) {
40
+ conditionalEcho('Repo is clean\n');
41
+ return;
42
+ }
35
43
 
36
- // Show files not tracked by git and unstaged changes
37
- const addResult = await $('git add -N .', {
38
- silent: options?.silent ?? false,
39
- });
40
- if (Result.isErr(addResult)) {
41
- echo('Warning: Failed to add untracked files for diff\n');
42
- }
44
+ conditionalEcho('Repo is dirty\n');
45
+ conditionalEcho('Changed files:\n');
46
+ conditionalEcho(gitStatus.stdout);
43
47
 
44
- const diffResult = await $('git diff', {
45
- silent: options?.silent ?? false,
46
- });
47
- if (Result.isErr(diffResult)) {
48
- echo('Warning: Failed to show diff\n');
49
- }
48
+ // Show files not tracked by git and unstaged changes
49
+ const addResult = await $('git add -N .', { silent });
50
+ if (Result.isErr(addResult)) {
51
+ conditionalEcho('Warning: Failed to add untracked files for diff\n');
52
+ }
50
53
 
51
- process.exit(1);
52
- } catch (error) {
53
- echo(`Error checking repository status: ${String(error)}\n`);
54
- process.exit(1);
54
+ const diffResult = await $('git diff', { silent });
55
+ if (Result.isErr(diffResult)) {
56
+ conditionalEcho('Warning: Failed to show diff\n');
55
57
  }
58
+
59
+ process.exit(1);
56
60
  };
57
61
 
58
62
  /**
@@ -62,22 +66,27 @@ export const assertRepoIsClean = async (
62
66
  */
63
67
  const getGitStatus = async (
64
68
  options?: Readonly<{ silent?: boolean }>,
65
- ): Promise<{
66
- isDirty: boolean;
67
- stdout: string;
68
- }> => {
69
+ ): Promise<
70
+ Result<
71
+ Readonly<{
72
+ isDirty: boolean;
73
+ stdout: string;
74
+ }>,
75
+ string
76
+ >
77
+ > => {
69
78
  const res = await $('git status --porcelain', {
70
79
  silent: options?.silent ?? false,
71
80
  });
72
81
 
73
82
  if (Result.isErr(res)) {
74
- throw new Error(`Failed to get git status: ${res.value.message}`);
83
+ return Result.err(`Failed to get git status: ${res.value.message}`);
75
84
  }
76
85
 
77
86
  const { stdout } = res.value;
78
87
 
79
- return {
88
+ return Result.ok({
80
89
  isDirty: stdout.trim() !== '',
81
90
  stdout,
82
- };
91
+ });
83
92
  };
@@ -24,8 +24,8 @@ export const getUntrackedFiles = async (
24
24
  });
25
25
 
26
26
  /**
27
- * Get untracked files from the working tree (files not added to git). Runs `git
28
- * git diff --staged --name-only [--diff-filter=d]`
27
+ * Get modified files from the working tree (files that have been changed but
28
+ * not staged). Runs `git diff --name-only [--diff-filter=d]`
29
29
  */
30
30
  export const getModifiedFiles = async (
31
31
  options?: Readonly<{
@@ -39,7 +39,7 @@ export const getModifiedFiles = async (
39
39
  > =>
40
40
  cmdResultToFiles({
41
41
  cmd: `git diff --name-only`,
42
- cmdOptionToExcludeDeleted: '--diff-filter=d',
42
+ cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
43
43
  cmdOptionToIncludeDeleted: '',
44
44
  options,
45
45
  });
@@ -60,7 +60,7 @@ export const getStagedFiles = async (
60
60
  > =>
61
61
  cmdResultToFiles({
62
62
  cmd: `git diff --staged --name-only`,
63
- cmdOptionToExcludeDeleted: '--diff-filter=d',
63
+ cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
64
64
  cmdOptionToIncludeDeleted: '',
65
65
  options,
66
66
  });
@@ -1,19 +1,15 @@
1
- import {
2
- exec,
3
- type ExecException,
4
- type ExecOptions as ExecOptions_,
5
- } from 'node:child_process';
1
+ import * as childProcess from 'node:child_process';
6
2
  import { Result } from 'ts-data-forge';
7
3
 
8
4
  type ExecOptionsCustom = Readonly<{
9
5
  silent?: boolean;
10
6
  }>;
11
7
 
12
- export type ExecOptions = DeepReadonly<ExecOptions_ & ExecOptionsCustom>;
8
+ export type ExecOptions = childProcess.ExecOptions & ExecOptionsCustom;
13
9
 
14
10
  export type ExecResult<T extends string | Buffer> = Result<
15
11
  Readonly<{ stdout: T; stderr: T }>,
16
- ExecException
12
+ childProcess.ExecException
17
13
  >;
18
14
 
19
15
  /**
@@ -30,16 +26,19 @@ export function $(
30
26
 
31
27
  export function $(
32
28
  command: string,
29
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
33
30
  options: Readonly<{ encoding: 'buffer' | null } & ExecOptions>,
34
31
  ): Promise<ExecResult<Buffer>>;
35
32
 
36
33
  export function $(
37
34
  command: string,
35
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
38
36
  options: Readonly<{ encoding: BufferEncoding } & ExecOptions>,
39
37
  ): Promise<ExecResult<string>>;
40
38
 
41
39
  export function $(
42
40
  command: string,
41
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
43
42
  options?: Readonly<
44
43
  { encoding?: BufferEncoding | 'buffer' | null } & ExecOptions
45
44
  >,
@@ -52,28 +51,21 @@ export function $(
52
51
 
53
52
  return new Promise((resolve) => {
54
53
  // eslint-disable-next-line security/detect-child-process
55
- exec(
56
- command,
57
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
58
- restOptions as {
59
- encoding?: 'buffer' | null | BufferEncoding;
60
- } & ExecOptions_,
61
- (error, stdout, stderr) => {
62
- if (!silent) {
63
- if (stdout !== '') {
64
- echo(stdout);
65
- }
66
- if (stderr !== '') {
67
- console.error(stderr);
68
- }
54
+ childProcess.exec(command, restOptions, (error, stdout, stderr) => {
55
+ if (!silent) {
56
+ if (stdout !== '') {
57
+ echo(stdout);
69
58
  }
70
-
71
- if (error !== null) {
72
- resolve(Result.err(error));
73
- } else {
74
- resolve(Result.ok({ stdout, stderr }));
59
+ if (stderr !== '') {
60
+ console.error(stderr);
75
61
  }
76
- },
77
- );
62
+ }
63
+
64
+ if (error !== null) {
65
+ resolve(Result.err(error));
66
+ } else {
67
+ resolve(Result.ok({ stdout, stderr }));
68
+ }
69
+ });
78
70
  });
79
71
  }
@@ -20,16 +20,14 @@ export const formatFiles = async (
20
20
  ): Promise<Result<undefined, readonly unknown[]>> => {
21
21
  const silent = options?.silent ?? false;
22
22
 
23
+ const conditionalEcho = silent ? () => {} : echo;
24
+
23
25
  if (files.length === 0) {
24
- if (!silent) {
25
- echo('No files to format');
26
- }
26
+ conditionalEcho('No files to format');
27
27
  return Result.ok(undefined);
28
28
  }
29
29
 
30
- if (!silent) {
31
- echo(`Formatting ${files.length} files...`);
32
- }
30
+ conditionalEcho(`Formatting ${files.length} files...`);
33
31
 
34
32
  // Format each file
35
33
  const results: readonly PromiseSettledResult<Result<undefined, unknown>>[] =
@@ -42,9 +40,7 @@ export const formatFiles = async (
42
40
  await fs.access(filePath);
43
41
  } catch {
44
42
  // File doesn't exist, skip it
45
- if (!silent) {
46
- echo(`Skipping non-existent file: ${filePath}`);
47
- }
43
+ conditionalEcho(`Skipping non-existent file: ${filePath}`);
48
44
  return Result.ok(undefined);
49
45
  }
50
46
 
@@ -60,9 +56,7 @@ export const formatFiles = async (
60
56
  });
61
57
 
62
58
  if (fileInfo.ignored) {
63
- if (!silent) {
64
- echo(`Skipping ignored file: ${filePath}`);
65
- }
59
+ conditionalEcho(`Skipping ignored file: ${filePath}`);
66
60
  return Result.ok(undefined);
67
61
  }
68
62
 
@@ -74,14 +68,10 @@ export const formatFiles = async (
74
68
 
75
69
  // Only write if content changed
76
70
  if (formatted === content) {
77
- if (!silent) {
78
- echo(`Unchanged: ${filePath}`);
79
- }
71
+ conditionalEcho(`Unchanged: ${filePath}`);
80
72
  } else {
81
73
  await fs.writeFile(filePath, formatted, 'utf8');
82
- if (!silent) {
83
- echo(`Formatted: ${filePath}`);
84
- }
74
+ conditionalEcho(`Formatted: ${filePath}`);
85
75
  }
86
76
 
87
77
  return Result.ok(undefined);
@@ -124,6 +114,7 @@ export const formatFilesGlob = async (
124
114
  options?: Readonly<{ silent?: boolean }>,
125
115
  ): Promise<Result<undefined, unknown>> => {
126
116
  const silent = options?.silent ?? false;
117
+ const conditionalEcho = silent ? () => {} : echo;
127
118
 
128
119
  try {
129
120
  // Find all files matching the glob
@@ -134,9 +125,7 @@ export const formatFilesGlob = async (
134
125
  });
135
126
 
136
127
  if (files.length === 0) {
137
- if (!silent) {
138
- echo('No files found matching pattern:', pathGlob);
139
- }
128
+ conditionalEcho('No files found matching pattern:', pathGlob);
140
129
  return Result.ok(undefined);
141
130
  }
142
131
 
@@ -260,6 +249,8 @@ export const formatDiffFrom = async (
260
249
  includeStaged = true,
261
250
  } = options ?? {};
262
251
 
252
+ const conditionalEcho = silent ? () => {} : echo;
253
+
263
254
  // Get files that differ from base branch/commit (excluding deleted files)
264
255
  const diffFromBaseResult = await getDiffFrom(base, {
265
256
  silent,
@@ -317,13 +308,11 @@ export const formatDiffFrom = async (
317
308
  .join(''),
318
309
  ].join('');
319
310
 
320
- echo(`${message}:`, allFiles);
311
+ conditionalEcho(`${message}:`, allFiles);
321
312
  }
322
313
 
323
314
  if (allFiles.length === 0) {
324
- if (!silent) {
325
- echo('No files to format');
326
- }
315
+ conditionalEcho('No files to format');
327
316
  return Result.ok(undefined);
328
317
  }
329
318
 
@@ -71,12 +71,16 @@ type GenIndexConfigInternal = DeepReadonly<{
71
71
  * @param config - Configuration for index file generation
72
72
  * @throws Error if any step fails.
73
73
  */
74
- export const genIndex = async (config: GenIndexConfig): Promise<void> => {
75
- echo('Starting index file generation...\n');
76
-
74
+ export const genIndex = async (
75
+ config: GenIndexConfig,
76
+ ): Promise<Result<undefined, unknown>> => {
77
77
  // Merge config with defaults
78
78
  const filledConfig: GenIndexConfigInternal = fillConfig(config);
79
79
 
80
+ const conditionalEcho = filledConfig.silent ? () => {} : echo;
81
+
82
+ conditionalEcho('Starting index file generation...\n');
83
+
80
84
  // Normalize target directories to array
81
85
  const targetDirs =
82
86
  typeof config.targetDirectory === 'string'
@@ -92,30 +96,32 @@ export const genIndex = async (config: GenIndexConfig): Promise<void> => {
92
96
  }
93
97
 
94
98
  // Step 2: Generate index files
95
- echo('Generating index files...');
99
+ conditionalEcho('Generating index files...');
96
100
  for (const dir of targetDirs) {
97
101
  const resolvedDir = path.resolve(dir);
98
102
  // eslint-disable-next-line no-await-in-loop
99
103
  await generateIndexFileForDir(resolvedDir, filledConfig);
100
104
  }
101
- echo('✓ Index files generated\n');
105
+ conditionalEcho('✓ Index files generated\n');
102
106
 
103
107
  // Step 3: Format generated files
104
108
  if (filledConfig.formatCommand !== undefined) {
105
- echo('Formatting generated files...');
109
+ conditionalEcho('Formatting generated files...');
106
110
  const fmtResult = await $(filledConfig.formatCommand, {
107
111
  silent: filledConfig.silent,
108
112
  });
109
113
  if (Result.isErr(fmtResult)) {
110
114
  throw new Error(`Formatting failed: ${fmtResult.value.message}`);
111
115
  }
112
- echo('✓ Formatting completed\n');
116
+ conditionalEcho('✓ Formatting completed\n');
113
117
  }
114
118
 
115
- echo('✅ Index file generation completed successfully!\n');
119
+ conditionalEcho('✅ Index file generation completed successfully!\n');
120
+
121
+ return Result.ok(undefined);
116
122
  } catch (error) {
117
- echo(`❌ Index generation failed: ${String(error)}\n`);
118
- throw error;
123
+ conditionalEcho(`❌ Index generation failed: ${String(error)}\n`);
124
+ return Result.err(error);
119
125
  }
120
126
  };
121
127