ts-repo-utils 6.0.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.
- package/README.md +60 -17
- package/dist/cmd/assert-repo-is-clean.mjs +21 -21
- package/dist/cmd/check-should-run-type-checks.mjs +30 -28
- package/dist/cmd/format-diff-from.mjs +34 -33
- package/dist/cmd/format-untracked.mjs +23 -23
- package/dist/cmd/gen-index-ts.mjs +102 -86
- package/package.json +8 -8
- package/src/cmd/assert-repo-is-clean.mts +1 -1
- package/src/cmd/check-should-run-type-checks.mts +1 -1
- package/src/cmd/format-diff-from.mts +1 -1
- package/src/cmd/format-untracked.mts +1 -1
- package/src/cmd/gen-index-ts.mts +1 -1
package/README.md
CHANGED
|
@@ -25,19 +25,19 @@ Generates index.ts files recursively in target directories with automatic barrel
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
# Basic usage with required options
|
|
28
|
-
|
|
28
|
+
npm exec -- gen-index-ts ./src --target-ext .mts --index-ext .mts --export-ext .mjs
|
|
29
29
|
|
|
30
30
|
# With formatting command
|
|
31
|
-
|
|
31
|
+
npm exec -- gen-index-ts ./src --target-ext .mts --index-ext .mts --export-ext .mjs --fmt 'npm run fmt'
|
|
32
32
|
|
|
33
33
|
# Multiple target extensions
|
|
34
|
-
|
|
34
|
+
npm exec -- gen-index-ts ./src --target-ext .mts --target-ext .tsx --index-ext .mts --export-ext .mjs
|
|
35
35
|
|
|
36
36
|
# With exclude patterns
|
|
37
|
-
|
|
37
|
+
npm exec -- gen-index-ts ./src --target-ext .ts --index-ext .ts --export-ext .js --exclude '*.test.ts' --exclude '*.spec.ts'
|
|
38
38
|
|
|
39
39
|
# Example in npm scripts
|
|
40
|
-
"gi": "gen-index-ts ./src
|
|
40
|
+
"gi": "gen-index-ts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --fmt 'npm run fmt'"
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
**Options:**
|
|
@@ -56,16 +56,16 @@ Checks if repository is clean and exits with code 1 if it has uncommitted change
|
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
# Basic usage
|
|
59
|
-
|
|
59
|
+
npm exec -- assert-repo-is-clean
|
|
60
60
|
|
|
61
61
|
# Silent mode
|
|
62
|
-
|
|
62
|
+
npm exec -- assert-repo-is-clean --silent
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
```yaml
|
|
66
66
|
# Example in GitHub Actions
|
|
67
67
|
- name: Check if there is no file diff
|
|
68
|
-
run:
|
|
68
|
+
run: npm exec -- assert-repo-is-clean
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
**Options:**
|
|
@@ -78,10 +78,10 @@ Formats only untracked/modified files using Prettier.
|
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
80
|
# Basic usage
|
|
81
|
-
|
|
81
|
+
npm exec -- format-untracked
|
|
82
82
|
|
|
83
83
|
# Silent mode
|
|
84
|
-
|
|
84
|
+
npm exec -- format-untracked --silent
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
**Options:**
|
|
@@ -94,16 +94,16 @@ Formats only files that differ from the specified base branch or commit.
|
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
96
|
# Format files different from main branch
|
|
97
|
-
|
|
97
|
+
npm exec -- format-diff-from main
|
|
98
98
|
|
|
99
99
|
# Format files different from origin/main
|
|
100
|
-
|
|
100
|
+
npm exec -- format-diff-from origin/main
|
|
101
101
|
|
|
102
102
|
# Exclude untracked files
|
|
103
|
-
|
|
103
|
+
npm exec -- format-diff-from main --exclude-untracked
|
|
104
104
|
|
|
105
105
|
# Silent mode
|
|
106
|
-
|
|
106
|
+
npm exec -- format-diff-from main --silent
|
|
107
107
|
|
|
108
108
|
# Example in npm scripts
|
|
109
109
|
"fmt": "format-diff-from origin/main"
|
|
@@ -116,6 +116,49 @@ npx format-diff-from main --silent
|
|
|
116
116
|
- `--exclude-untracked` - Exclude untracked files, only format diff files (optional)
|
|
117
117
|
- `--silent` - Suppress output messages (optional)
|
|
118
118
|
|
|
119
|
+
### `check-should-run-type-checks`
|
|
120
|
+
|
|
121
|
+
Checks if TypeScript type checks should run based on the diff from a base branch. Optimizes CI/CD pipelines by skipping type checks when only non-TypeScript files are changed.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Basic usage (compares against origin/main)
|
|
125
|
+
npm exec -- check-should-run-type-checks
|
|
126
|
+
|
|
127
|
+
# Custom base branch
|
|
128
|
+
npm exec -- check-should-run-type-checks --base-branch origin/develop
|
|
129
|
+
|
|
130
|
+
# Custom ignore patterns
|
|
131
|
+
npm exec -- check-should-run-type-checks \
|
|
132
|
+
--paths-ignore '.github/' \
|
|
133
|
+
--paths-ignore 'docs/' \
|
|
134
|
+
--paths-ignore '**.md' \
|
|
135
|
+
--paths-ignore '**.yml'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
# Example in GitHub Actions
|
|
140
|
+
- name: Check if type checks should run
|
|
141
|
+
id: check_diff
|
|
142
|
+
run: npm exec -- check-should-run-type-checks
|
|
143
|
+
|
|
144
|
+
- name: Run type checks
|
|
145
|
+
if: steps.check_diff.outputs.should_run == 'true'
|
|
146
|
+
run: npm run type-check
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Options:**
|
|
150
|
+
|
|
151
|
+
- `--paths-ignore` - Patterns to ignore when checking if type checks should run (optional, can be specified multiple times)
|
|
152
|
+
- Supports exact file matches: `.cspell.json`
|
|
153
|
+
- Directory prefixes: `docs/` (matches any file in docs directory)
|
|
154
|
+
- File extensions: `**.md` (matches any markdown file)
|
|
155
|
+
- Default: `['LICENSE', '.editorconfig', '.gitignore', '.cspell.json', '.markdownlint-cli2.mjs', '.npmignore', '.prettierignore', '.prettierrc', 'docs/', '**.md', '**.txt']`
|
|
156
|
+
- `--base-branch` - Base branch to compare against for determining changed files (default: `origin/main`)
|
|
157
|
+
|
|
158
|
+
**GitHub Actions Integration:**
|
|
159
|
+
|
|
160
|
+
When running in GitHub Actions, the command sets the `GITHUB_OUTPUT` environment variable with `should_run=true` or `should_run=false`, which can be used in subsequent steps.
|
|
161
|
+
|
|
119
162
|
### Usage in npm scripts
|
|
120
163
|
|
|
121
164
|
The CLI commands are commonly used in npm scripts for automation:
|
|
@@ -124,7 +167,7 @@ The CLI commands are commonly used in npm scripts for automation:
|
|
|
124
167
|
{
|
|
125
168
|
"scripts": {
|
|
126
169
|
"fmt": "format-diff-from origin/main",
|
|
127
|
-
"gi": "gen-index-ts ./src
|
|
170
|
+
"gi": "gen-index-ts ./src --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --fmt 'npm run fmt'",
|
|
128
171
|
"check:clean": "assert-repo-is-clean"
|
|
129
172
|
}
|
|
130
173
|
}
|
|
@@ -139,13 +182,13 @@ These commands are particularly useful in CI/CD pipelines:
|
|
|
139
182
|
- name: Format check
|
|
140
183
|
run: |
|
|
141
184
|
npm run fmt
|
|
142
|
-
|
|
185
|
+
npm exec -- assert-repo-is-clean
|
|
143
186
|
|
|
144
187
|
# Check for uncommitted changes after build
|
|
145
188
|
- name: Build
|
|
146
189
|
run: npm run build
|
|
147
190
|
- name: Check if there is no file diff
|
|
148
|
-
run:
|
|
191
|
+
run: npm exec -- assert-repo-is-clean
|
|
149
192
|
```
|
|
150
193
|
|
|
151
194
|
## API Reference
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import 'child_process';
|
|
2
3
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import '
|
|
4
|
-
import '../node-global.mjs';
|
|
5
|
-
import { assertRepoIsClean } from '../functions/assert-repo-is-clean.mjs';
|
|
4
|
+
import 'micromatch';
|
|
6
5
|
import 'node:child_process';
|
|
7
6
|
import 'prettier';
|
|
8
|
-
import '
|
|
9
|
-
import '
|
|
7
|
+
import 'ts-data-forge';
|
|
8
|
+
import { assertRepoIsClean } from '../functions/assert-repo-is-clean.mjs';
|
|
9
|
+
import '../node-global.mjs';
|
|
10
10
|
|
|
11
11
|
const cmdDef = cmd.command({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
name: 'assert-repo-is-clean-cli',
|
|
13
|
+
version: '6.0.1',
|
|
14
|
+
args: {
|
|
15
|
+
silent: cmd.flag({
|
|
16
|
+
long: 'silent',
|
|
17
|
+
type: cmd.optional(cmd.boolean),
|
|
18
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
handler: (args) => {
|
|
22
|
+
main(args).catch((error) => {
|
|
23
|
+
console.error('An error occurred:', error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
27
|
});
|
|
28
28
|
const main = async (args) => {
|
|
29
|
-
|
|
29
|
+
await assertRepoIsClean({ silent: args.silent });
|
|
30
30
|
};
|
|
31
31
|
await cmd.run(cmdDef, process.argv.slice(2));
|
|
32
32
|
//# sourceMappingURL=assert-repo-is-clean.mjs.map
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import 'child_process';
|
|
2
3
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import '
|
|
4
|
-
import '../node-global.mjs';
|
|
4
|
+
import 'micromatch';
|
|
5
5
|
import 'node:child_process';
|
|
6
6
|
import 'prettier';
|
|
7
|
-
import '
|
|
7
|
+
import 'ts-data-forge';
|
|
8
8
|
import { checkShouldRunTypeChecks } from '../functions/should-run.mjs';
|
|
9
|
-
import '
|
|
9
|
+
import '../node-global.mjs';
|
|
10
10
|
|
|
11
11
|
const cmdDef = cmd.command({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
name: 'check-should-run-type-checks-cli',
|
|
13
|
+
version: '6.0.1',
|
|
14
|
+
args: {
|
|
15
|
+
pathsIgnore: cmd.multioption({
|
|
16
|
+
long: 'paths-ignore',
|
|
17
|
+
type: cmd.optional(cmd.array(cmd.string)),
|
|
18
|
+
description:
|
|
19
|
+
'Patterns to ignore when checking if type checks should run. Supports exact file matches, directory prefixes (ending with "/"), and file extensions (starting with "**.")',
|
|
20
|
+
}),
|
|
21
|
+
baseBranch: cmd.option({
|
|
22
|
+
long: 'base-branch',
|
|
23
|
+
type: cmd.optional(cmd.string),
|
|
24
|
+
description:
|
|
25
|
+
'Base branch to compare against for determining changed files. Defaults to "origin/main"',
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
handler: (args) => {
|
|
29
|
+
main(args).catch((error) => {
|
|
30
|
+
console.error('An error occurred:', error);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
},
|
|
32
34
|
});
|
|
33
35
|
const main = async (args) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
await checkShouldRunTypeChecks({
|
|
37
|
+
pathsIgnore: args.pathsIgnore,
|
|
38
|
+
baseBranch: args.baseBranch,
|
|
39
|
+
});
|
|
38
40
|
};
|
|
39
41
|
await cmd.run(cmdDef, process.argv.slice(2));
|
|
40
42
|
//# sourceMappingURL=check-should-run-type-checks.mjs.map
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import 'child_process';
|
|
2
3
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import '
|
|
4
|
-
import '../node-global.mjs';
|
|
4
|
+
import 'micromatch';
|
|
5
5
|
import 'node:child_process';
|
|
6
|
+
import 'ts-data-forge';
|
|
6
7
|
import { formatDiffFrom } from '../functions/format.mjs';
|
|
7
|
-
import '
|
|
8
|
-
import 'child_process';
|
|
8
|
+
import '../node-global.mjs';
|
|
9
9
|
|
|
10
10
|
const cmdDef = cmd.command({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
11
|
+
name: 'format-diff-from-cli',
|
|
12
|
+
version: '6.0.1',
|
|
13
|
+
args: {
|
|
14
|
+
base: cmd.positional({
|
|
15
|
+
type: cmd.string,
|
|
16
|
+
displayName: 'base',
|
|
17
|
+
description: 'Base branch name or commit hash to compare against',
|
|
18
|
+
}),
|
|
19
|
+
includeUntracked: cmd.flag({
|
|
20
|
+
long: 'include-untracked',
|
|
21
|
+
type: cmd.optional(cmd.boolean),
|
|
22
|
+
description:
|
|
23
|
+
'Include untracked files in addition to diff files (default: true)',
|
|
24
|
+
}),
|
|
25
|
+
silent: cmd.flag({
|
|
26
|
+
long: 'silent',
|
|
27
|
+
type: cmd.optional(cmd.boolean),
|
|
28
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
handler: (args) => {
|
|
32
|
+
main(args).catch((error) => {
|
|
33
|
+
console.error('An error occurred:', error);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
36
37
|
});
|
|
37
38
|
const main = async (args) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const result = await formatDiffFrom(args.base, args);
|
|
40
|
+
if (result === 'err') {
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
42
43
|
};
|
|
43
44
|
await cmd.run(cmdDef, process.argv.slice(2));
|
|
44
45
|
//# sourceMappingURL=format-diff-from.mjs.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import 'child_process';
|
|
2
3
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import '
|
|
4
|
-
import '../node-global.mjs';
|
|
4
|
+
import 'micromatch';
|
|
5
5
|
import 'node:child_process';
|
|
6
|
+
import 'ts-data-forge';
|
|
6
7
|
import { formatUntracked } from '../functions/format.mjs';
|
|
7
|
-
import '
|
|
8
|
-
import 'child_process';
|
|
8
|
+
import '../node-global.mjs';
|
|
9
9
|
|
|
10
10
|
const cmdDef = cmd.command({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
name: 'format-untracked-cli',
|
|
12
|
+
version: '6.0.1',
|
|
13
|
+
args: {
|
|
14
|
+
silent: cmd.flag({
|
|
15
|
+
long: 'silent',
|
|
16
|
+
type: cmd.optional(cmd.boolean),
|
|
17
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
handler: (args) => {
|
|
21
|
+
main(args).catch((error) => {
|
|
22
|
+
console.error('An error occurred:', error);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
26
|
});
|
|
27
27
|
const main = async (args) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const result = await formatUntracked({ silent: args.silent });
|
|
29
|
+
if (result === 'err') {
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
32
|
};
|
|
33
33
|
await cmd.run(cmdDef, process.argv.slice(2));
|
|
34
34
|
//# sourceMappingURL=format-untracked.mjs.map
|
|
@@ -1,103 +1,119 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import 'child_process';
|
|
2
3
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import 'ts-data-forge';
|
|
4
|
-
import '../node-global.mjs';
|
|
5
4
|
import 'node:child_process';
|
|
6
5
|
import 'prettier';
|
|
6
|
+
import 'ts-data-forge';
|
|
7
7
|
import { genIndex } from '../functions/gen-index.mjs';
|
|
8
|
-
import '
|
|
8
|
+
import '../node-global.mjs';
|
|
9
9
|
|
|
10
10
|
const extensionType = cmd.extendType(cmd.string, {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
from: (s) => {
|
|
12
|
+
if (!s.startsWith('.')) {
|
|
13
|
+
throw new Error(`ext should start with '.'`);
|
|
14
|
+
}
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
16
|
+
return Promise.resolve(s);
|
|
17
|
+
},
|
|
18
18
|
});
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
const nonEmptyArray = (t, commandName) =>
|
|
20
|
+
const nonEmptyArray = (t, commandName) =>
|
|
21
|
+
cmd.extendType(cmd.array(t), {
|
|
21
22
|
from: (arr) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (arr.length === 0) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`No value provided for --${commandName}. At least one value is required.`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
29
|
+
return Promise.resolve(arr);
|
|
27
30
|
},
|
|
28
|
-
});
|
|
31
|
+
});
|
|
29
32
|
const cmdDef = cmd.command({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
name: 'gen-index-ts-cli',
|
|
34
|
+
version: '6.0.1',
|
|
35
|
+
args: {
|
|
36
|
+
// required args
|
|
37
|
+
targetDirectory: cmd.positional({
|
|
38
|
+
type: cmd.string,
|
|
39
|
+
displayName: 'target-directory',
|
|
40
|
+
description:
|
|
41
|
+
'Directory where the index file will be generated (Comma-separated list can be used)',
|
|
42
|
+
}),
|
|
43
|
+
targetExtensions: cmd.multioption({
|
|
44
|
+
long: 'target-ext',
|
|
45
|
+
type: nonEmptyArray(extensionType, 'target-ext'),
|
|
46
|
+
description: 'File extensions to include in the index file',
|
|
47
|
+
}),
|
|
48
|
+
indexFileExtension: cmd.option({
|
|
49
|
+
long: 'index-ext',
|
|
50
|
+
type: extensionType,
|
|
51
|
+
description: 'Extension of the index file to be generated',
|
|
52
|
+
}),
|
|
53
|
+
exportStatementExtension: cmd.option({
|
|
54
|
+
long: 'export-ext',
|
|
55
|
+
type: cmd.union([
|
|
56
|
+
extensionType,
|
|
57
|
+
cmd.extendType(cmd.string, {
|
|
58
|
+
from: (s) => {
|
|
59
|
+
if (s !== 'none') {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`export-ext should be 'none' or a valid extension`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return Promise.resolve('none');
|
|
65
|
+
},
|
|
43
66
|
}),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
long: 'fmt',
|
|
72
|
-
type: cmd.optional(cmd.string),
|
|
73
|
-
description: 'Command to format after generating the index file (e.g., "npm run fmt")',
|
|
74
|
-
}),
|
|
75
|
-
silent: cmd.flag({
|
|
76
|
-
long: 'silent',
|
|
77
|
-
type: cmd.optional(cmd.boolean),
|
|
78
|
-
description: 'If true, suppresses output messages (default: false)',
|
|
79
|
-
}),
|
|
80
|
-
},
|
|
81
|
-
handler: (args) => {
|
|
82
|
-
console.log(args);
|
|
83
|
-
main(args).catch((error) => {
|
|
84
|
-
console.error('An error occurred:', error);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
const main = async ({ targetDirectory, targetExtensions, exportStatementExtension, indexFileExtension, exclude, formatCommand, silent, }) => {
|
|
90
|
-
await genIndex({
|
|
91
|
-
targetDirectory: targetDirectory.includes(',')
|
|
92
|
-
? targetDirectory.split(',').map((dir) => dir.trim())
|
|
93
|
-
: targetDirectory,
|
|
94
|
-
exportStatementExtension,
|
|
95
|
-
targetExtensions,
|
|
96
|
-
exclude,
|
|
97
|
-
indexFileExtension,
|
|
98
|
-
formatCommand,
|
|
99
|
-
silent,
|
|
67
|
+
]),
|
|
68
|
+
description: 'Extension of the export statements in the index file',
|
|
69
|
+
}),
|
|
70
|
+
// optional args
|
|
71
|
+
exclude: cmd.multioption({
|
|
72
|
+
long: 'exclude',
|
|
73
|
+
type: cmd.optional(cmd.array(cmd.string)),
|
|
74
|
+
description:
|
|
75
|
+
'Glob patterns of files to exclude from the index file (e.g., "*.d.mts", "*.test.mts")',
|
|
76
|
+
}),
|
|
77
|
+
formatCommand: cmd.option({
|
|
78
|
+
long: 'fmt',
|
|
79
|
+
type: cmd.optional(cmd.string),
|
|
80
|
+
description:
|
|
81
|
+
'Command to format after generating the index file (e.g., "npm run fmt")',
|
|
82
|
+
}),
|
|
83
|
+
silent: cmd.flag({
|
|
84
|
+
long: 'silent',
|
|
85
|
+
type: cmd.optional(cmd.boolean),
|
|
86
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
handler: (args) => {
|
|
90
|
+
console.log(args);
|
|
91
|
+
main(args).catch((error) => {
|
|
92
|
+
console.error('An error occurred:', error);
|
|
93
|
+
process.exit(1);
|
|
100
94
|
});
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
const main = async ({
|
|
98
|
+
targetDirectory,
|
|
99
|
+
targetExtensions,
|
|
100
|
+
exportStatementExtension,
|
|
101
|
+
indexFileExtension,
|
|
102
|
+
exclude,
|
|
103
|
+
formatCommand,
|
|
104
|
+
silent,
|
|
105
|
+
}) => {
|
|
106
|
+
await genIndex({
|
|
107
|
+
targetDirectory: targetDirectory.includes(',')
|
|
108
|
+
? targetDirectory.split(',').map((dir) => dir.trim())
|
|
109
|
+
: targetDirectory,
|
|
110
|
+
exportStatementExtension,
|
|
111
|
+
targetExtensions,
|
|
112
|
+
exclude,
|
|
113
|
+
indexFileExtension,
|
|
114
|
+
formatCommand,
|
|
115
|
+
silent,
|
|
116
|
+
});
|
|
101
117
|
};
|
|
102
118
|
await cmd.run(cmdDef, process.argv.slice(2));
|
|
103
119
|
//# sourceMappingURL=gen-index-ts.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-repo-utils",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"import": {
|
|
19
|
-
"types": "./dist/
|
|
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/
|
|
25
|
+
"types": "./dist/types.d.mts",
|
|
26
26
|
"bin": {
|
|
27
27
|
"assert-repo-is-clean": "./src/cmd/assert-repo-is-clean.mts",
|
|
28
28
|
"check-should-run-type-checks": "./src/cmd/check-should-run-type-checks.mts",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"@semantic-release/github": "^11.0.3",
|
|
83
83
|
"@semantic-release/npm": "^12.0.2",
|
|
84
84
|
"@semantic-release/release-notes-generator": "^14.0.3",
|
|
85
|
-
"@types/node": "^24.1
|
|
85
|
+
"@types/node": "^24.2.1",
|
|
86
86
|
"@vitest/coverage-v8": "^3.2.4",
|
|
87
87
|
"@vitest/ui": "^3.2.4",
|
|
88
88
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
89
89
|
"cspell": "^9.2.0",
|
|
90
90
|
"dedent": "^1.6.0",
|
|
91
|
-
"eslint": "^9.
|
|
91
|
+
"eslint": "^9.33.0",
|
|
92
92
|
"eslint-import-resolver-typescript": "4.4.4",
|
|
93
93
|
"eslint-plugin-array-func": "5.0.2",
|
|
94
94
|
"eslint-plugin-functional": "9.0.2",
|
|
@@ -107,10 +107,10 @@
|
|
|
107
107
|
"semantic-release": "^24.2.7",
|
|
108
108
|
"ts-type-forge": "^2.1.1",
|
|
109
109
|
"tslib": "^2.8.1",
|
|
110
|
-
"typedoc": "^0.28.
|
|
110
|
+
"typedoc": "^0.28.9",
|
|
111
111
|
"typedoc-plugin-markdown": "^4.8.0",
|
|
112
|
-
"typescript": "^5.
|
|
113
|
-
"typescript-eslint": "^8.
|
|
112
|
+
"typescript": "^5.9.2",
|
|
113
|
+
"typescript-eslint": "^8.39.0",
|
|
114
114
|
"vitest": "^3.2.4"
|
|
115
115
|
},
|
|
116
116
|
"engines": {
|
package/src/cmd/gen-index-ts.mts
CHANGED