ts-repo-utils 7.7.2 → 7.8.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 (62) hide show
  1. package/README.md +197 -144
  2. package/dist/cmd/assert-repo-is-clean.d.mts +1 -1
  3. package/dist/cmd/assert-repo-is-clean.mjs +2 -2
  4. package/dist/cmd/assert-repo-is-clean.mjs.map +1 -1
  5. package/dist/cmd/check-should-run-type-checks.d.mts +1 -1
  6. package/dist/cmd/check-should-run-type-checks.mjs +2 -2
  7. package/dist/cmd/check-should-run-type-checks.mjs.map +1 -1
  8. package/dist/cmd/format-diff-from.d.mts +1 -1
  9. package/dist/cmd/format-diff-from.mjs +2 -2
  10. package/dist/cmd/format-diff-from.mjs.map +1 -1
  11. package/dist/cmd/format-uncommitted.d.mts +1 -1
  12. package/dist/cmd/format-uncommitted.mjs +2 -2
  13. package/dist/cmd/format-uncommitted.mjs.map +1 -1
  14. package/dist/cmd/gen-index-ts.d.mts +1 -1
  15. package/dist/cmd/gen-index-ts.mjs +2 -2
  16. package/dist/cmd/gen-index-ts.mjs.map +1 -1
  17. package/dist/entry-point.mjs +2 -1
  18. package/dist/entry-point.mjs.map +1 -1
  19. package/dist/functions/assert-ext.d.mts +20 -1
  20. package/dist/functions/assert-ext.d.mts.map +1 -1
  21. package/dist/functions/assert-ext.mjs +52 -35
  22. package/dist/functions/assert-ext.mjs.map +1 -1
  23. package/dist/functions/create-result-assert.d.mts +18 -0
  24. package/dist/functions/create-result-assert.d.mts.map +1 -0
  25. package/dist/functions/create-result-assert.mjs +40 -0
  26. package/dist/functions/create-result-assert.mjs.map +1 -0
  27. package/dist/functions/exec-async.d.mts +5 -6
  28. package/dist/functions/exec-async.d.mts.map +1 -1
  29. package/dist/functions/exec-async.mjs +26 -7
  30. package/dist/functions/exec-async.mjs.map +1 -1
  31. package/dist/functions/index.d.mts +1 -0
  32. package/dist/functions/index.d.mts.map +1 -1
  33. package/dist/functions/index.mjs +2 -1
  34. package/dist/functions/index.mjs.map +1 -1
  35. package/dist/functions/should-run.d.mts +1 -1
  36. package/dist/functions/should-run.mjs +1 -1
  37. package/dist/functions/workspace-utils/execute-parallel.mjs.map +1 -1
  38. package/dist/functions/workspace-utils/get-workspace-packages.d.mts.map +1 -1
  39. package/dist/functions/workspace-utils/get-workspace-packages.mjs +2 -2
  40. package/dist/functions/workspace-utils/get-workspace-packages.mjs.map +1 -1
  41. package/dist/index.mjs +2 -1
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/node-global.d.mts +2 -0
  44. package/dist/node-global.d.mts.map +1 -1
  45. package/dist/node-global.mjs +3 -1
  46. package/dist/node-global.mjs.map +1 -1
  47. package/package.json +50 -38
  48. package/src/cmd/assert-repo-is-clean.mts +3 -3
  49. package/src/cmd/check-should-run-type-checks.mts +3 -3
  50. package/src/cmd/format-diff-from.mts +3 -3
  51. package/src/cmd/format-uncommitted.mts +3 -3
  52. package/src/cmd/gen-index-ts.mts +4 -4
  53. package/src/functions/assert-ext.mts +78 -52
  54. package/src/functions/create-result-assert.mts +59 -0
  55. package/src/functions/exec-async.mts +71 -14
  56. package/src/functions/exec-async.test.mts +5 -5
  57. package/src/functions/index.mts +1 -0
  58. package/src/functions/should-run.mts +1 -1
  59. package/src/functions/workspace-utils/execute-parallel.mts +1 -1
  60. package/src/functions/workspace-utils/get-workspace-packages.mts +12 -14
  61. package/src/functions/workspace-utils/run-cmd-in-stages.test.mts +5 -8
  62. package/src/node-global.mts +4 -1
@@ -32,7 +32,7 @@ import { getDiffFrom } from './diff.mjs';
32
32
  * ```yaml
33
33
  * - name: Check if type checks should run
34
34
  * id: check_diff
35
- * run: npx check-should-run-type-checks
35
+ * run: npm exec check-should-run-type-checks
36
36
  *
37
37
  * - name: Run type checks
38
38
  * if: steps.check_diff.outputs.should_run == 'true'
@@ -57,7 +57,7 @@ export const executeParallel = async (
57
57
 
58
58
  const wrappedPromise = promise
59
59
  // eslint-disable-next-line @typescript-eslint/no-loop-func
60
- .catch((error) => {
60
+ .catch((error: unknown) => {
61
61
  mut_failed = true;
62
62
  throw error; // Re-throw to ensure fail-fast propagation
63
63
  })
@@ -63,20 +63,18 @@ export const getWorkspacePackages = async (
63
63
  }),
64
64
  );
65
65
 
66
- const packageInfos: readonly Package[] = await Promise.all(
67
- packageJsonList
68
- .filter(isNotUndefined)
69
- .map(([packagePath, packageJson]) => ({
70
- name: getStrFromJsonValue(packageJson, 'name'),
71
- path: path.dirname(packagePath),
72
- packageJson,
73
- dependencies: {
74
- ...getKeyValueRecordFromJsonValue(packageJson, 'dependencies'),
75
- ...getKeyValueRecordFromJsonValue(packageJson, 'devDependencies'),
76
- ...getKeyValueRecordFromJsonValue(packageJson, 'peerDependencies'),
77
- },
78
- })),
79
- );
66
+ const packageInfos: readonly Package[] = packageJsonList
67
+ .filter(isNotUndefined)
68
+ .map(([packagePath, packageJson]) => ({
69
+ name: getStrFromJsonValue(packageJson, 'name'),
70
+ path: path.dirname(packagePath),
71
+ packageJson,
72
+ dependencies: {
73
+ ...getKeyValueRecordFromJsonValue(packageJson, 'dependencies'),
74
+ ...getKeyValueRecordFromJsonValue(packageJson, 'devDependencies'),
75
+ ...getKeyValueRecordFromJsonValue(packageJson, 'peerDependencies'),
76
+ },
77
+ }));
80
78
 
81
79
  return packageInfos;
82
80
  });
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable vitest/no-restricted-vi-methods */
2
+ import { type MockInstance } from 'vitest';
2
3
  import '../../node-global.mjs';
3
4
  import { executeStages } from './execute-parallel.mjs';
4
5
  import { getWorkspacePackages } from './get-workspace-packages.mjs';
@@ -16,9 +17,9 @@ vi.mock('./get-workspace-packages.mjs', () => ({
16
17
 
17
18
  describe('runCmdInStagesAcrossWorkspaces', () => {
18
19
  type MockedSpies = Readonly<{
19
- consoleLogSpy: ReturnType<typeof vi.spyOn>;
20
- consoleErrorSpy: ReturnType<typeof vi.spyOn>;
21
- processExitSpy: ReturnType<typeof vi.spyOn>;
20
+ consoleLogSpy: MockInstance<typeof console.log>;
21
+ consoleErrorSpy: MockInstance<typeof console.error>;
22
+ processExitSpy: MockInstance<typeof process.exit>;
22
23
  }>;
23
24
 
24
25
  const setupSpies = (): MockedSpies => {
@@ -30,14 +31,10 @@ describe('runCmdInStagesAcrossWorkspaces', () => {
30
31
  .spyOn(console, 'error')
31
32
  .mockImplementation((): void => {});
32
33
 
33
- // eslint-disable-next-line total-functions/no-unsafe-type-assertion
34
34
  const processExitSpy = vi
35
35
  .spyOn(process, 'exit')
36
-
37
36
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
38
- .mockImplementation((): never => undefined as never) as ReturnType<
39
- typeof vi.spyOn
40
- >;
37
+ .mockImplementation((): never => undefined as never);
41
38
 
42
39
  return { consoleLogSpy, consoleErrorSpy, processExitSpy };
43
40
  };
@@ -1,8 +1,9 @@
1
- /* eslint-disable import/no-internal-modules */
1
+ /* eslint-disable import-x/no-internal-modules */
2
2
  import glob_ from 'fast-glob';
3
3
  import * as fs_ from 'node:fs/promises';
4
4
  import * as os_ from 'node:os';
5
5
  import * as path_ from 'node:path';
6
+ import { chdir as chdir_ } from 'node:process';
6
7
  import { Result as Result_ } from 'ts-data-forge';
7
8
  import { $ as $_ } from './functions/exec-async.mjs';
8
9
  import { isDirectlyExecuted as isDirectlyExecuted_ } from './functions/is-directly-executed.mjs';
@@ -19,6 +20,7 @@ const globalsDef = {
19
20
  $: $_,
20
21
  Result: Result_,
21
22
  echo: console.log,
23
+ cd: chdir_,
22
24
  isDirectlyExecuted: isDirectlyExecuted_,
23
25
  } as const;
24
26
 
@@ -35,5 +37,6 @@ declare global {
35
37
  const Result: typeof Result_;
36
38
  type Result<S, E> = Result_<S, E>;
37
39
  const echo: typeof console.log;
40
+ const cd: typeof chdir_;
38
41
  const isDirectlyExecuted: typeof isDirectlyExecuted_;
39
42
  }