ts-repo-utils 7.8.2 → 7.9.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 +10 -0
  2. package/dist/cmd/assert-repo-is-clean.mjs +1 -1
  3. package/dist/cmd/assert-repo-is-clean.mjs.map +1 -1
  4. package/dist/cmd/check-should-run-type-checks.mjs +1 -1
  5. package/dist/cmd/check-should-run-type-checks.mjs.map +1 -1
  6. package/dist/cmd/format-diff-from.mjs +1 -1
  7. package/dist/cmd/format-diff-from.mjs.map +1 -1
  8. package/dist/cmd/format-uncommitted.mjs +1 -1
  9. package/dist/cmd/format-uncommitted.mjs.map +1 -1
  10. package/dist/cmd/gen-index-ts.mjs +1 -1
  11. package/dist/cmd/gen-index-ts.mjs.map +1 -1
  12. package/dist/entry-point.d.mts.map +1 -1
  13. package/dist/functions/assert-ext.d.mts.map +1 -1
  14. package/dist/functions/assert-ext.mjs.map +1 -1
  15. package/dist/functions/assert-path-exists.d.mts.map +1 -1
  16. package/dist/functions/assert-path-exists.mjs.map +1 -1
  17. package/dist/functions/assert-repo-is-clean.d.mts.map +1 -1
  18. package/dist/functions/assert-repo-is-clean.mjs.map +1 -1
  19. package/dist/functions/create-result-assert.d.mts.map +1 -1
  20. package/dist/functions/create-result-assert.mjs.map +1 -1
  21. package/dist/functions/exec-async.mjs.map +1 -1
  22. package/dist/functions/format.d.mts +4 -4
  23. package/dist/functions/format.d.mts.map +1 -1
  24. package/dist/functions/format.mjs +3 -3
  25. package/dist/functions/format.mjs.map +1 -1
  26. package/dist/functions/gen-index.d.mts.map +1 -1
  27. package/dist/functions/gen-index.mjs.map +1 -1
  28. package/dist/functions/should-run.d.mts.map +1 -1
  29. package/dist/functions/should-run.mjs.map +1 -1
  30. package/dist/functions/workspace-utils/execute-parallel.d.mts.map +1 -1
  31. package/dist/functions/workspace-utils/execute-parallel.mjs.map +1 -1
  32. package/dist/functions/workspace-utils/get-workspace-packages.d.mts.map +1 -1
  33. package/dist/functions/workspace-utils/get-workspace-packages.mjs.map +1 -1
  34. package/dist/functions/workspace-utils/run-cmd-in-parallel.d.mts.map +1 -1
  35. package/dist/functions/workspace-utils/run-cmd-in-parallel.mjs.map +1 -1
  36. package/dist/functions/workspace-utils/run-cmd-in-stages.d.mts.map +1 -1
  37. package/dist/functions/workspace-utils/run-cmd-in-stages.mjs.map +1 -1
  38. package/dist/node-global.d.mts.map +1 -1
  39. package/package.json +17 -19
  40. package/src/cmd/assert-repo-is-clean.mts +2 -1
  41. package/src/cmd/check-should-run-type-checks.mts +2 -1
  42. package/src/cmd/format-diff-from.mts +2 -1
  43. package/src/cmd/format-uncommitted.mts +3 -1
  44. package/src/cmd/gen-index-ts.mts +8 -2
  45. package/src/entry-point.mts +1 -0
  46. package/src/functions/assert-ext.mts +4 -0
  47. package/src/functions/assert-path-exists.mts +2 -0
  48. package/src/functions/assert-repo-is-clean.mts +9 -0
  49. package/src/functions/create-result-assert.mts +1 -0
  50. package/src/functions/diff.test.mts +76 -0
  51. package/src/functions/exec-async.mts +4 -0
  52. package/src/functions/exec-async.test.mts +42 -0
  53. package/src/functions/format.mts +26 -7
  54. package/src/functions/format.test.mts +109 -0
  55. package/src/functions/gen-index.mts +16 -0
  56. package/src/functions/should-run.mts +2 -0
  57. package/src/functions/workspace-utils/execute-parallel.mts +23 -0
  58. package/src/functions/workspace-utils/get-workspace-packages.mts +5 -0
  59. package/src/functions/workspace-utils/run-cmd-in-parallel.mts +5 -0
  60. package/src/functions/workspace-utils/run-cmd-in-stages.mts +5 -0
  61. package/src/functions/workspace-utils/run-cmd-in-stages.test.mts +13 -0
  62. package/src/node-global.mts +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-repo-utils",
3
- "version": "7.8.2",
3
+ "version": "7.9.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -47,15 +47,14 @@
47
47
  "fmt": "pnpm run z:format-uncommitted",
48
48
  "fmt:diff": "pnpm run z:format-diff-from origin/main",
49
49
  "fmt:full": "prettier --write .",
50
- "gh:apply-all": "run-s gh:apply-variables gh:apply-rulesets gh:apply-repository-settings",
51
- "gh:apply-repository-settings": "tsx --env-file=.env scripts/github/repository/apply.mts",
52
- "gh:apply-rulesets": "tsx --env-file=.env scripts/github/ruleset/apply.mts",
53
- "gh:apply-variables": "tsx --env-file=.env scripts/github/variables/apply.mts",
54
- "gh:backup-all": "run-s gh:backup-rulesets gh:backup-repository-settings",
55
- "gh:backup-repository-settings": "tsx --env-file=.env scripts/github/repository/backup.mts",
56
- "gh:backup-rulesets": "tsx --env-file=.env scripts/github/ruleset/backup.mts",
57
- "gi": "run-s gi:scripts gi:src fmt",
58
- "gi:scripts": "pnpm run z:gen-index-ts ./scripts/github --index-ext .mts --export-ext .mjs --target-ext .mts --exclude cmd --exclude apply.mts --exclude octokit.mts",
50
+ "gh:apply-all": "gh-apply-all",
51
+ "gh:apply-repository-settings": "gh-apply-repository-settings",
52
+ "gh:apply-rulesets": "gh-apply-rulesets",
53
+ "gh:apply-variables": "gh-apply-variables",
54
+ "gh:backup-all": "gh-backup-all",
55
+ "gh:backup-repository-settings": "gh-backup-repository-settings",
56
+ "gh:backup-rulesets": "gh-backup-rulesets",
57
+ "gi": "run-s gi:src fmt",
59
58
  "gi:src": "pnpm run z:gen-index-ts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --exclude entry-point.mts --exclude cmd --exclude node-global.mts",
60
59
  "lint": "eslint .",
61
60
  "lint:fix": "eslint . --fix",
@@ -89,7 +88,6 @@
89
88
  "tsx": "^4.20.6"
90
89
  },
91
90
  "devDependencies": {
92
- "@octokit/core": "7.0.6",
93
91
  "@rollup/plugin-replace": "^6.0.3",
94
92
  "@rollup/plugin-strip": "^3.0.4",
95
93
  "@rollup/plugin-typescript": "^12.3.0",
@@ -98,35 +96,35 @@
98
96
  "@semantic-release/exec": "^7.1.0",
99
97
  "@semantic-release/git": "^10.0.1",
100
98
  "@semantic-release/github": "^12.0.2",
101
- "@semantic-release/npm": "^13.1.1",
99
+ "@semantic-release/npm": "^13.1.2",
102
100
  "@semantic-release/release-notes-generator": "^14.1.0",
103
101
  "@types/node": "^24.10.1",
104
- "@vitest/coverage-v8": "^4.0.8",
105
- "@vitest/ui": "^4.0.8",
102
+ "@vitest/coverage-v8": "^4.0.9",
103
+ "@vitest/ui": "^4.0.9",
106
104
  "conventional-changelog-conventionalcommits": "^9.1.0",
107
- "cspell": "^9.3.1",
105
+ "cspell": "^9.3.2",
108
106
  "dedent": "^1.7.0",
109
107
  "eslint": "9.39.1",
110
- "eslint-config-typed": "^3.5.2",
108
+ "eslint-config-typed": "^3.13.3",
111
109
  "fast-glob": "^3.3.3",
110
+ "github-settings-as-code": "^1.0.6",
112
111
  "jiti": "^2.6.1",
113
112
  "markdownlint": "^0.39.0",
114
113
  "markdownlint-cli2": "^0.19.0",
115
114
  "npm-run-all2": "^8.0.4",
116
- "octokit-safe-types": "^1.2.0",
117
115
  "prettier": "^3.6.2",
118
116
  "prettier-plugin-organize-imports": "^4.3.0",
119
117
  "prettier-plugin-packagejson": "^2.5.19",
120
118
  "rollup": "^4.53.2",
121
119
  "semantic-release": "^25.0.2",
122
- "ts-fortress": "^6.0.0",
120
+ "ts-fortress": "^6.1.0",
123
121
  "ts-type-forge": "^2.3.0",
124
122
  "tslib": "^2.8.1",
125
123
  "tsx": "^4.20.6",
126
124
  "typedoc": "^0.28.14",
127
125
  "typedoc-plugin-markdown": "^4.9.0",
128
126
  "typescript": "^5.9.3",
129
- "vitest": "^4.0.8"
127
+ "vitest": "^4.0.9"
130
128
  },
131
129
  "peerDependencies": {
132
130
  "prettier": "^3.6.2"
@@ -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: '7.8.2',
8
+ version: '7.9.0',
9
9
  args: {
10
10
  silent: cmd.flag({
11
11
  long: 'silent',
@@ -16,6 +16,7 @@ const cmdDef = cmd.command({
16
16
  handler: (args) => {
17
17
  main(args).catch((error: unknown) => {
18
18
  console.error('An error occurred:', error);
19
+
19
20
  process.exit(1);
20
21
  });
21
22
  },
@@ -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: '7.8.2',
8
+ version: '7.9.0',
9
9
  args: {
10
10
  pathsIgnore: cmd.multioption({
11
11
  long: 'paths-ignore',
@@ -23,6 +23,7 @@ const cmdDef = cmd.command({
23
23
  handler: (args) => {
24
24
  main(args).catch((error: unknown) => {
25
25
  console.error('An error occurred:', error);
26
+
26
27
  process.exit(1);
27
28
  });
28
29
  },
@@ -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: '7.8.2',
9
+ version: '7.9.0',
10
10
  args: {
11
11
  base: cmd.positional({
12
12
  type: cmd.string,
@@ -52,6 +52,7 @@ const cmdDef = cmd.command({
52
52
  silent: args.silent ?? false,
53
53
  }).catch((error: unknown) => {
54
54
  console.error('An error occurred:', error);
55
+
55
56
  process.exit(1);
56
57
  });
57
58
  },
@@ -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: '7.8.2',
9
+ version: '7.9.0',
10
10
  args: {
11
11
  excludeUntracked: cmd.flag({
12
12
  long: 'exclude-untracked',
@@ -46,6 +46,7 @@ const cmdDef = cmd.command({
46
46
  silent: args.silent ?? false,
47
47
  }).catch((error: unknown) => {
48
48
  console.error('An error occurred:', error);
49
+
49
50
  process.exit(1);
50
51
  });
51
52
  },
@@ -67,6 +68,7 @@ const main = async (
67
68
  ignoreUnknown: args.ignoreUnknown,
68
69
  silent: args.silent,
69
70
  });
71
+
70
72
  if (Result.isErr(result)) {
71
73
  process.exit(1);
72
74
  }
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import * as cmd from 'cmd-ts';
4
-
5
4
  // eslint-disable-next-line import-x/no-internal-modules
6
5
  import { type InputOf, type OutputOf } from 'cmd-ts/dist/esm/from.js';
7
6
  import { expectType } from 'ts-data-forge';
@@ -40,7 +39,7 @@ const nonEmptyArray = <T extends cmd.Type<any, any>>(
40
39
 
41
40
  const cmdDef = cmd.command({
42
41
  name: 'gen-index-ts-cli',
43
- version: '7.8.2',
42
+ version: '7.9.0',
44
43
  args: {
45
44
  // required args
46
45
  targetDirectory: cmd.positional({
@@ -71,6 +70,7 @@ const cmdDef = cmd.command({
71
70
  `export-ext should be 'none' or a valid extension`,
72
71
  );
73
72
  }
73
+
74
74
  return Promise.resolve('none' as const);
75
75
  },
76
76
  }),
@@ -101,16 +101,22 @@ const cmdDef = cmd.command({
101
101
  console.log(args);
102
102
 
103
103
  expectType<typeof args.targetDirectory, string>('=');
104
+
104
105
  expectType<typeof args.targetExtensions, NonEmptyArray<Ext>>('=');
106
+
105
107
  expectType<typeof args.exportStatementExtension, Ext | 'none'>('=');
108
+
106
109
  expectType<typeof args.indexFileExtension, Ext>('=');
107
110
 
108
111
  expectType<typeof args.exclude, string[] | undefined>('=');
112
+
109
113
  expectType<typeof args.formatCommand, string | undefined>('=');
114
+
110
115
  expectType<typeof args.silent, boolean | undefined>('=');
111
116
 
112
117
  main(args).catch((error: unknown) => {
113
118
  console.error('An error occurred:', error);
119
+
114
120
  process.exit(1);
115
121
  });
116
122
  },
@@ -1,2 +1,3 @@
1
1
  export { Result } from 'ts-data-forge';
2
+
2
3
  export * from './index.mjs';
@@ -50,6 +50,7 @@ export const checkExt = async (
50
50
  );
51
51
  } catch (error) {
52
52
  console.error(`Failed to check directory ${dir}: ${String(error)}`);
53
+
53
54
  return [];
54
55
  }
55
56
  }),
@@ -111,6 +112,7 @@ const getFilesWithIncorrectExtension = async (
111
112
  await assertPathExists(dir, 'Directory');
112
113
 
113
114
  const defaultIgnorePatterns = ['tsconfig.json', 'globals.d.*'];
115
+
114
116
  const finalIgnorePatterns = ignorePatterns ?? defaultIgnorePatterns;
115
117
 
116
118
  // Convert relative patterns to absolute paths for the glob ignore option
@@ -139,6 +141,7 @@ const describeExpectedExtensions = (config: CheckExtConfig): string => {
139
141
  > = Arr.groupBy(
140
142
  config.directories.map(({ path: dirPath, extension }) => {
141
143
  const relativePath = path.relative(process.cwd(), dirPath);
144
+
142
145
  const extKey = isString(extension) ? extension : extension.join(' or ');
143
146
 
144
147
  return {
@@ -155,6 +158,7 @@ const describeExpectedExtensions = (config: CheckExtConfig): string => {
155
158
  dirs.length === 1
156
159
  ? dirs[0]?.relativePath
157
160
  : dirs.map((d) => d.relativePath).join(', ');
161
+
158
162
  return `${dirList} should have ${ext} extension`;
159
163
  });
160
164
 
@@ -9,6 +9,7 @@ import '../node-global.mjs';
9
9
  export const pathExists = async (filePath: string): Promise<boolean> => {
10
10
  try {
11
11
  await fs.access(filePath);
12
+
12
13
  return true;
13
14
  } catch {
14
15
  return false;
@@ -27,6 +28,7 @@ export const assertPathExists = async (
27
28
  ): Promise<void> => {
28
29
  if (!(await pathExists(filePath))) {
29
30
  echo(`${description} does not exist: ${filePath}`);
31
+
30
32
  process.exit(1);
31
33
  }
32
34
  };
@@ -11,9 +11,11 @@ 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
+
14
15
  if (Result.isErr(status)) {
15
16
  throw new Error(`Failed to get git status: ${status.value}`);
16
17
  }
18
+
17
19
  return status.value.isDirty;
18
20
  };
19
21
 
@@ -25,12 +27,14 @@ export const assertRepoIsClean = async (
25
27
  options?: Readonly<{ silent?: boolean }>,
26
28
  ): Promise<void> => {
27
29
  const silent = options?.silent ?? false;
30
+
28
31
  const conditionalEcho = silent ? () => {} : echo;
29
32
 
30
33
  const gitStatusResult = await getGitStatus({ silent });
31
34
 
32
35
  if (Result.isErr(gitStatusResult)) {
33
36
  conditionalEcho(gitStatusResult.value);
37
+
34
38
  return;
35
39
  }
36
40
 
@@ -38,20 +42,25 @@ export const assertRepoIsClean = async (
38
42
 
39
43
  if (!gitStatus.isDirty) {
40
44
  conditionalEcho('Repo is clean\n');
45
+
41
46
  return;
42
47
  }
43
48
 
44
49
  conditionalEcho('Repo is dirty\n');
50
+
45
51
  conditionalEcho('Changed files:\n');
52
+
46
53
  conditionalEcho(gitStatus.stdout);
47
54
 
48
55
  // Show files not tracked by git and unstaged changes
49
56
  const addResult = await $('git add -N .', { silent });
57
+
50
58
  if (Result.isErr(addResult)) {
51
59
  conditionalEcho('Warning: Failed to add untracked files for diff\n');
52
60
  }
53
61
 
54
62
  const diffResult = await $('git diff', { silent });
63
+
55
64
  if (Result.isErr(diffResult)) {
56
65
  conditionalEcho('Warning: Failed to show diff\n');
57
66
  }
@@ -47,6 +47,7 @@ export const createResultAssert = <Config, Ok, Err>({
47
47
  } else {
48
48
  defaultOnError(result.value);
49
49
  }
50
+
50
51
  process.exit(exitCode);
51
52
  }
52
53