ts-repo-utils 6.2.0 → 7.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 (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 +7 -8
  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 +25 -35
  33. package/src/functions/format.mts +14 -25
  34. package/src/functions/gen-index.mts +16 -10
@@ -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