ts-repo-utils 5.2.1 → 6.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.
- package/README.md +133 -0
- package/dist/cmd/assert-repo-is-clean.d.mts +3 -0
- package/dist/cmd/assert-repo-is-clean.d.mts.map +1 -0
- package/dist/cmd/assert-repo-is-clean.mjs +32 -0
- package/dist/cmd/assert-repo-is-clean.mjs.map +1 -0
- package/dist/cmd/check-should-run-type-checks.d.mts +3 -0
- package/dist/cmd/check-should-run-type-checks.d.mts.map +1 -0
- package/dist/cmd/check-should-run-type-checks.mjs +40 -0
- package/dist/cmd/check-should-run-type-checks.mjs.map +1 -0
- package/dist/cmd/format-diff-from.d.mts +3 -0
- package/dist/cmd/format-diff-from.d.mts.map +1 -0
- package/dist/cmd/format-diff-from.mjs +44 -0
- package/dist/cmd/format-diff-from.mjs.map +1 -0
- package/dist/cmd/format-untracked.d.mts +3 -0
- package/dist/cmd/format-untracked.d.mts.map +1 -0
- package/dist/cmd/format-untracked.mjs +34 -0
- package/dist/cmd/format-untracked.mjs.map +1 -0
- package/dist/cmd/gen-index-ts.d.mts +3 -0
- package/dist/cmd/gen-index-ts.d.mts.map +1 -0
- package/dist/cmd/gen-index-ts.mjs +103 -0
- package/dist/cmd/gen-index-ts.mjs.map +1 -0
- package/dist/functions/exec-async.d.mts +18 -9
- package/dist/functions/exec-async.d.mts.map +1 -1
- package/dist/functions/exec-async.mjs +7 -13
- package/dist/functions/exec-async.mjs.map +1 -1
- package/dist/functions/format.mjs +1 -1
- package/dist/functions/gen-index.d.mts +5 -11
- package/dist/functions/gen-index.d.mts.map +1 -1
- package/dist/functions/gen-index.mjs +21 -15
- package/dist/functions/gen-index.mjs.map +1 -1
- package/dist/functions/should-run.d.mts +53 -13
- package/dist/functions/should-run.d.mts.map +1 -1
- package/dist/functions/should-run.mjs +82 -23
- package/dist/functions/should-run.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/package.json +18 -7
- package/src/cmd/assert-repo-is-clean.mts +28 -0
- package/src/cmd/check-should-run-type-checks.mts +43 -0
- package/src/cmd/format-diff-from.mts +49 -0
- package/src/cmd/format-untracked.mts +31 -0
- package/src/cmd/gen-index-ts.mts +147 -0
- package/src/functions/exec-async.mts +62 -27
- package/src/functions/exec-async.test.mts +501 -0
- package/src/functions/gen-index.mts +36 -30
- package/src/functions/should-run.mts +92 -27
- package/src/index.mts +0 -2
package/README.md
CHANGED
|
@@ -15,6 +15,139 @@ A comprehensive toolkit for managing TypeScript projects with strict ESM support
|
|
|
15
15
|
npm install ts-repo-utils
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
## CLI Commands
|
|
19
|
+
|
|
20
|
+
`ts-repo-utils` provides several CLI commands that can be used directly or through npm scripts.
|
|
21
|
+
|
|
22
|
+
### `gen-index-ts`
|
|
23
|
+
|
|
24
|
+
Generates index.ts files recursively in target directories with automatic barrel exports.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Basic usage with required options
|
|
28
|
+
npx gen-index-ts ./src --target-ext .mts --index-ext .mts --export-ext .mjs
|
|
29
|
+
|
|
30
|
+
# With formatting command
|
|
31
|
+
npx gen-index-ts ./src --target-ext .mts --index-ext .mts --export-ext .mjs --fmt 'npm run fmt'
|
|
32
|
+
|
|
33
|
+
# Multiple target extensions
|
|
34
|
+
npx gen-index-ts ./src --target-ext .mts --target-ext .tsx --index-ext .mts --export-ext .mjs
|
|
35
|
+
|
|
36
|
+
# With exclude patterns
|
|
37
|
+
npx gen-index-ts ./src --target-ext .ts --index-ext .ts --export-ext .js --exclude '*.test.ts' --exclude '*.spec.ts'
|
|
38
|
+
|
|
39
|
+
# Example in npm scripts
|
|
40
|
+
"gi": "gen-index-ts ./src/functions --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --fmt 'npm run fmt'"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Options:**
|
|
44
|
+
|
|
45
|
+
- `<target-directory>` - Directory where the index file will be generated (comma-separated list can be used)
|
|
46
|
+
- `--target-ext` - File extensions to include in the index file (required, can be specified multiple times)
|
|
47
|
+
- `--index-ext` - Extension of the index file to be generated (required)
|
|
48
|
+
- `--export-ext` - Extension of the export statements in the index file (required, or 'none')
|
|
49
|
+
- `--exclude` - Glob patterns of files to exclude (optional, can be specified multiple times)
|
|
50
|
+
- `--fmt` - Command to format after generating the index file (optional)
|
|
51
|
+
- `--silent` - Suppress output messages (optional)
|
|
52
|
+
|
|
53
|
+
### `assert-repo-is-clean`
|
|
54
|
+
|
|
55
|
+
Checks if repository is clean and exits with code 1 if it has uncommitted changes.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Basic usage
|
|
59
|
+
npx assert-repo-is-clean
|
|
60
|
+
|
|
61
|
+
# Silent mode
|
|
62
|
+
npx assert-repo-is-clean --silent
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
# Example in GitHub Actions
|
|
67
|
+
- name: Check if there is no file diff
|
|
68
|
+
run: npx tsx ./src/cmd/assert-repo-is-clean.mts
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Options:**
|
|
72
|
+
|
|
73
|
+
- `--silent` - Suppress output messages (optional)
|
|
74
|
+
|
|
75
|
+
### `format-untracked`
|
|
76
|
+
|
|
77
|
+
Formats only untracked/modified files using Prettier.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Basic usage
|
|
81
|
+
npx format-untracked
|
|
82
|
+
|
|
83
|
+
# Silent mode
|
|
84
|
+
npx format-untracked --silent
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Options:**
|
|
88
|
+
|
|
89
|
+
- `--silent` - Suppress output messages (optional)
|
|
90
|
+
|
|
91
|
+
### `format-diff-from`
|
|
92
|
+
|
|
93
|
+
Formats only files that differ from the specified base branch or commit.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Format files different from main branch
|
|
97
|
+
npx format-diff-from main
|
|
98
|
+
|
|
99
|
+
# Format files different from origin/main
|
|
100
|
+
npx format-diff-from origin/main
|
|
101
|
+
|
|
102
|
+
# Exclude untracked files
|
|
103
|
+
npx format-diff-from main --exclude-untracked
|
|
104
|
+
|
|
105
|
+
# Silent mode
|
|
106
|
+
npx format-diff-from main --silent
|
|
107
|
+
|
|
108
|
+
# Example in npm scripts
|
|
109
|
+
"fmt": "format-diff-from origin/main"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Options:**
|
|
113
|
+
|
|
114
|
+
- `<base>` - Base branch name or commit hash to compare against (required)
|
|
115
|
+
- `--include-untracked` - Include untracked files in addition to diff files (default: true)
|
|
116
|
+
- `--exclude-untracked` - Exclude untracked files, only format diff files (optional)
|
|
117
|
+
- `--silent` - Suppress output messages (optional)
|
|
118
|
+
|
|
119
|
+
### Usage in npm scripts
|
|
120
|
+
|
|
121
|
+
The CLI commands are commonly used in npm scripts for automation:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"scripts": {
|
|
126
|
+
"fmt": "format-diff-from origin/main",
|
|
127
|
+
"gi": "gen-index-ts ./src/functions --index-ext .mts --export-ext .mjs --target-ext .mts --target-ext .tsx --fmt 'npm run fmt'",
|
|
128
|
+
"check:clean": "assert-repo-is-clean"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Usage in CI/CD
|
|
134
|
+
|
|
135
|
+
These commands are particularly useful in CI/CD pipelines:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
# GitHub Actions example
|
|
139
|
+
- name: Format check
|
|
140
|
+
run: |
|
|
141
|
+
npm run fmt
|
|
142
|
+
npx assert-repo-is-clean
|
|
143
|
+
|
|
144
|
+
# Check for uncommitted changes after build
|
|
145
|
+
- name: Build
|
|
146
|
+
run: npm run build
|
|
147
|
+
- name: Check if there is no file diff
|
|
148
|
+
run: npx tsx ./src/cmd/assert-repo-is-clean.mts
|
|
149
|
+
```
|
|
150
|
+
|
|
18
151
|
## API Reference
|
|
19
152
|
|
|
20
153
|
### Path and File System Utilities
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-repo-is-clean.d.mts","sourceRoot":"","sources":["../../src/cmd/assert-repo-is-clean.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import { assertRepoIsClean } from '../functions/assert-repo-is-clean.mjs';
|
|
6
|
+
import 'node:child_process';
|
|
7
|
+
import 'prettier';
|
|
8
|
+
import 'micromatch';
|
|
9
|
+
import 'child_process';
|
|
10
|
+
|
|
11
|
+
const cmdDef = cmd.command({
|
|
12
|
+
name: 'assert-repo-is-clean-cli',
|
|
13
|
+
version: '6.0.0',
|
|
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
|
+
});
|
|
28
|
+
const main = async (args) => {
|
|
29
|
+
await assertRepoIsClean({ silent: args.silent });
|
|
30
|
+
};
|
|
31
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
32
|
+
//# sourceMappingURL=assert-repo-is-clean.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-repo-is-clean.mjs","sources":["../../src/cmd/assert-repo-is-clean.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAKA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,IAAI,EAAE,0BAA0B;AAChC,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;AACf,YAAA,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;AAC/B,YAAA,WAAW,EAAE,sDAAsD;SACpE,CAAC;AACH,KAAA;AACD,IAAA,OAAO,EAAE,CAAC,IAAI,KAAI;QAChB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACzB,YAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC;AAC1C,YAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,CAAC;IACJ,CAAC;AACF,CAAA,CAAC;AAEF,MAAM,IAAI,GAAG,OAAO,IAAoC,KAAmB;IACzE,MAAM,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-should-run-type-checks.d.mts","sourceRoot":"","sources":["../../src/cmd/check-should-run-type-checks.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import 'node:child_process';
|
|
6
|
+
import 'prettier';
|
|
7
|
+
import 'micromatch';
|
|
8
|
+
import { checkShouldRunTypeChecks } from '../functions/should-run.mjs';
|
|
9
|
+
import 'child_process';
|
|
10
|
+
|
|
11
|
+
const cmdDef = cmd.command({
|
|
12
|
+
name: 'check-should-run-type-checks-cli',
|
|
13
|
+
version: '6.0.0',
|
|
14
|
+
args: {
|
|
15
|
+
pathsIgnore: cmd.multioption({
|
|
16
|
+
long: 'paths-ignore',
|
|
17
|
+
type: cmd.optional(cmd.array(cmd.string)),
|
|
18
|
+
description: 'Patterns to ignore when checking if type checks should run. Supports exact file matches, directory prefixes (ending with "/"), and file extensions (starting with "**.")',
|
|
19
|
+
}),
|
|
20
|
+
baseBranch: cmd.option({
|
|
21
|
+
long: 'base-branch',
|
|
22
|
+
type: cmd.optional(cmd.string),
|
|
23
|
+
description: 'Base branch to compare against for determining changed files. Defaults to "origin/main"',
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
handler: (args) => {
|
|
27
|
+
main(args).catch((error) => {
|
|
28
|
+
console.error('An error occurred:', error);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const main = async (args) => {
|
|
34
|
+
await checkShouldRunTypeChecks({
|
|
35
|
+
pathsIgnore: args.pathsIgnore,
|
|
36
|
+
baseBranch: args.baseBranch,
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
40
|
+
//# sourceMappingURL=check-should-run-type-checks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-should-run-type-checks.mjs","sources":["../../src/cmd/check-should-run-type-checks.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAKA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,IAAI,EAAE,kCAAkC;AACxC,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC;AAC3B,YAAA,IAAI,EAAE,cAAc;AACpB,YAAA,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACzC,YAAA,WAAW,EACT,0KAA0K;SAC7K,CAAC;AACF,QAAA,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC;AACrB,YAAA,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC;AAC9B,YAAA,WAAW,EACT,yFAAyF;SAC5F,CAAC;AACH,KAAA;AACD,IAAA,OAAO,EAAE,CAAC,IAAI,KAAI;QAChB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACzB,YAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC;AAC1C,YAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,CAAC;IACJ,CAAC;AACF,CAAA,CAAC;AAEF,MAAM,IAAI,GAAG,OACX,IAGE,KACe;AACjB,IAAA,MAAM,wBAAwB,CAAC;QAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;AAC5B,KAAA,CAAC;AACJ,CAAC;AAED,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-diff-from.d.mts","sourceRoot":"","sources":["../../src/cmd/format-diff-from.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import 'node:child_process';
|
|
6
|
+
import { formatDiffFrom } from '../functions/format.mjs';
|
|
7
|
+
import 'micromatch';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
|
|
10
|
+
const cmdDef = cmd.command({
|
|
11
|
+
name: 'format-diff-from-cli',
|
|
12
|
+
version: '6.0.0',
|
|
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: 'Include untracked files in addition to diff files (default: true)',
|
|
23
|
+
}),
|
|
24
|
+
silent: cmd.flag({
|
|
25
|
+
long: 'silent',
|
|
26
|
+
type: cmd.optional(cmd.boolean),
|
|
27
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
handler: (args) => {
|
|
31
|
+
main(args).catch((error) => {
|
|
32
|
+
console.error('An error occurred:', error);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const main = async (args) => {
|
|
38
|
+
const result = await formatDiffFrom(args.base, args);
|
|
39
|
+
if (result === 'err') {
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
44
|
+
//# sourceMappingURL=format-diff-from.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-diff-from.mjs","sources":["../../src/cmd/format-diff-from.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAKA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,IAAI,EAAE,sBAAsB;AAC5B,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,GAAG,CAAC,UAAU,CAAC;YACnB,IAAI,EAAE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|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import 'node:child_process';
|
|
6
|
+
import { formatUntracked } from '../functions/format.mjs';
|
|
7
|
+
import 'micromatch';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
|
|
10
|
+
const cmdDef = cmd.command({
|
|
11
|
+
name: 'format-untracked-cli',
|
|
12
|
+
version: '6.0.0',
|
|
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
|
+
});
|
|
27
|
+
const main = async (args) => {
|
|
28
|
+
const result = await formatUntracked({ silent: args.silent });
|
|
29
|
+
if (result === 'err') {
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
34
|
+
//# sourceMappingURL=format-untracked.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-untracked.mjs","sources":["../../src/cmd/format-untracked.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAKA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,IAAI,EAAE,sBAAsB;AAC5B,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;AACf,YAAA,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;AAC/B,YAAA,WAAW,EAAE,sDAAsD;SACpE,CAAC;AACH,KAAA;AACD,IAAA,OAAO,EAAE,CAAC,IAAI,KAAI;QAChB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACzB,YAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC;AAC1C,YAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,CAAC;IACJ,CAAC;AACF,CAAA,CAAC;AAEF,MAAM,IAAI,GAAG,OAAO,IAAoC,KAAmB;AACzE,IAAA,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAC7D,IAAA,IAAI,MAAM,KAAK,KAAK,EAAE;AACpB,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjB;AACF,CAAC;AAED,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-index-ts.d.mts","sourceRoot":"","sources":["../../src/cmd/gen-index-ts.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import 'node:child_process';
|
|
6
|
+
import 'prettier';
|
|
7
|
+
import { genIndex } from '../functions/gen-index.mjs';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
|
|
10
|
+
const extensionType = cmd.extendType(cmd.string, {
|
|
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
|
+
});
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
const nonEmptyArray = (t, commandName) => cmd.extendType(cmd.array(t), {
|
|
21
|
+
from: (arr) => {
|
|
22
|
+
if (arr.length === 0) {
|
|
23
|
+
throw new Error(`No value provided for --${commandName}. At least one value is required.`);
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
26
|
+
return Promise.resolve(arr);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const cmdDef = cmd.command({
|
|
30
|
+
name: 'gen-index-ts-cli',
|
|
31
|
+
version: '6.0.0',
|
|
32
|
+
args: {
|
|
33
|
+
// required args
|
|
34
|
+
targetDirectory: cmd.positional({
|
|
35
|
+
type: cmd.string,
|
|
36
|
+
displayName: 'target-directory',
|
|
37
|
+
description: 'Directory where the index file will be generated (Comma-separated list can be used)',
|
|
38
|
+
}),
|
|
39
|
+
targetExtensions: cmd.multioption({
|
|
40
|
+
long: 'target-ext',
|
|
41
|
+
type: nonEmptyArray(extensionType, 'target-ext'),
|
|
42
|
+
description: 'File extensions to include in the index file',
|
|
43
|
+
}),
|
|
44
|
+
indexFileExtension: cmd.option({
|
|
45
|
+
long: 'index-ext',
|
|
46
|
+
type: extensionType,
|
|
47
|
+
description: 'Extension of the index file to be generated',
|
|
48
|
+
}),
|
|
49
|
+
exportStatementExtension: cmd.option({
|
|
50
|
+
long: 'export-ext',
|
|
51
|
+
type: cmd.union([
|
|
52
|
+
extensionType,
|
|
53
|
+
cmd.extendType(cmd.string, {
|
|
54
|
+
from: (s) => {
|
|
55
|
+
if (s !== 'none') {
|
|
56
|
+
throw new Error(`export-ext should be 'none' or a valid extension`);
|
|
57
|
+
}
|
|
58
|
+
return Promise.resolve('none');
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
]),
|
|
62
|
+
description: 'Extension of the export statements in the index file',
|
|
63
|
+
}),
|
|
64
|
+
// optional args
|
|
65
|
+
exclude: cmd.multioption({
|
|
66
|
+
long: 'exclude',
|
|
67
|
+
type: cmd.optional(cmd.array(cmd.string)),
|
|
68
|
+
description: 'Glob patterns of files to exclude from the index file (e.g., "*.d.mts", "*.test.mts")',
|
|
69
|
+
}),
|
|
70
|
+
formatCommand: cmd.option({
|
|
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,
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
103
|
+
//# sourceMappingURL=gen-index-ts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-index-ts.mjs","sources":["../../src/cmd/gen-index-ts.mts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;AACH,KAAA;AACD,IAAA,OAAO,EAAE,CAAC,IAAI,KAAI;AAChB,QAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAWjB,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAI;AACzB,YAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC;AAC1C,YAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB,QAAA,CAAC,CAAC;KACH;AACF,CAAA,CAAC;AAEF,MAAM,IAAI,GAAG,OAAO,EAClB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,MAAM,GASN,KAAmB;AACnB,IAAA,MAAM,QAAQ,CAAC;AACb,QAAA,eAAe,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG;AAC3C,cAAE,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,EAAE;AACpD,cAAE,eAAe;QACnB,wBAAwB;QACxB,gBAAgB;QAChB,OAAO;QACP,kBAAkB;QAClB,aAAa;QACb,MAAM;AACP,KAAA,CAAC;AACJ,CAAC;AAED,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { type ExecException } from 'node:child_process';
|
|
1
|
+
import { type ExecException, type ExecOptions as ExecOptions_ } from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
|
+
type ExecOptionsCustom = Readonly<{
|
|
4
|
+
silent?: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
type ExecOptions = DeepReadonly<ExecOptions_ & ExecOptionsCustom>;
|
|
7
|
+
type ExecResult<T extends string | Buffer> = Result<Readonly<{
|
|
8
|
+
stdout: T;
|
|
9
|
+
stderr: T;
|
|
10
|
+
}>, ExecException>;
|
|
3
11
|
/**
|
|
4
12
|
* Executes a shell command asynchronously.
|
|
5
13
|
*
|
|
6
|
-
* @param
|
|
14
|
+
* @param command - The command to execute.
|
|
7
15
|
* @param options - Optional configuration for command execution.
|
|
8
16
|
* @returns A promise that resolves with the command result.
|
|
9
17
|
*/
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}>)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
18
|
+
export declare function $(command: string, options?: ExecOptionsCustom): Promise<ExecResult<string>>;
|
|
19
|
+
export declare function $(command: string, options: Readonly<{
|
|
20
|
+
encoding: 'buffer' | null;
|
|
21
|
+
} & ExecOptions>): Promise<ExecResult<Buffer>>;
|
|
22
|
+
export declare function $(command: string, options: Readonly<{
|
|
23
|
+
encoding: BufferEncoding;
|
|
24
|
+
} & ExecOptions>): Promise<ExecResult<string>>;
|
|
25
|
+
export {};
|
|
17
26
|
//# sourceMappingURL=exec-async.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-async.d.mts","sourceRoot":"","sources":["../../src/functions/exec-async.mts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,KAAK,WAAW,GAAG,YAAY,CAAC,YAAY,GAAG,iBAAiB,CAAC,CAAC;AAElE,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CACjD,QAAQ,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,EAClC,aAAa,CACd,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/B,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EACf,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,EACf,OAAO,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,cAAc,CAAA;CAAE,GAAG,WAAW,CAAC,GAC5D,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { exec } from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @param cmd - The command to execute.
|
|
8
|
-
* @param options - Optional configuration for command execution.
|
|
9
|
-
* @returns A promise that resolves with the command result.
|
|
10
|
-
*/
|
|
11
|
-
const $ = (cmd, options = {}) => {
|
|
12
|
-
const { silent = false, timeout = 30000 } = options;
|
|
4
|
+
function $(command, options) {
|
|
5
|
+
const { silent = false, ...restOptions } = options ?? {};
|
|
13
6
|
if (!silent) {
|
|
14
|
-
echo(`$ ${
|
|
7
|
+
echo(`$ ${command}`);
|
|
15
8
|
}
|
|
16
9
|
return new Promise((resolve) => {
|
|
17
|
-
const execOptions = { timeout };
|
|
18
10
|
// eslint-disable-next-line security/detect-child-process
|
|
19
|
-
exec(
|
|
11
|
+
exec(command,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
13
|
+
restOptions, (error, stdout, stderr) => {
|
|
20
14
|
if (!silent) {
|
|
21
15
|
if (stdout !== '') {
|
|
22
16
|
echo(stdout);
|
|
@@ -33,7 +27,7 @@ const $ = (cmd, options = {}) => {
|
|
|
33
27
|
}
|
|
34
28
|
});
|
|
35
29
|
});
|
|
36
|
-
}
|
|
30
|
+
}
|
|
37
31
|
|
|
38
32
|
export { $ };
|
|
39
33
|
//# sourceMappingURL=exec-async.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-async.mjs","sources":["../../src/functions/exec-async.mts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
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,CAAE,CAAC;IACtB;AAEA,IAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;;AAE7B,QAAA,IAAI,CACF,OAAO;;QAEP,WAEgB,EAChB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,KAAI;YACxB,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,IAAI,MAAM,KAAK,EAAE,EAAE;oBACjB,IAAI,CAAC,MAAM,CAAC;gBACd;AACA,gBAAA,IAAI,MAAM,KAAK,EAAE,EAAE;AACjB,oBAAA,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;gBACvB;YACF;AAEA,YAAA,IAAI,KAAK,KAAK,IAAI,EAAE;gBAClB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC5B;iBAAO;AACL,gBAAA,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACxC;AACF,QAAA,CAAC,CACF;AACH,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as prettier from 'prettier';
|
|
2
2
|
import { Result, Arr } from 'ts-data-forge';
|
|
3
3
|
import '../node-global.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { getDiffFrom, getUntrackedFiles } from './diff.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Format a list of files using Prettier
|
|
@@ -5,26 +5,20 @@ export type GenIndexConfig = DeepReadonly<{
|
|
|
5
5
|
targetDirectory: string | readonly string[];
|
|
6
6
|
/**
|
|
7
7
|
* Glob patterns of files or predicate function to exclude from exports
|
|
8
|
-
* (default: excludes `'**\/*.{test,spec}.?(c|m)[jt]s?(x)'`
|
|
8
|
+
* (default: excludes `'**\/*.{test,spec}.?(c|m)[jt]s?(x)'` and
|
|
9
|
+
* `'**\/*.d.?(c|m)ts'`)
|
|
9
10
|
*/
|
|
10
11
|
exclude?: readonly string[] | ((args: Readonly<{
|
|
11
12
|
absolutePath: string;
|
|
12
13
|
relativePath: string;
|
|
13
14
|
fileName: string;
|
|
14
15
|
}>) => boolean);
|
|
15
|
-
/**
|
|
16
|
-
* Glob patterns of files or predicate function to exclude from exports
|
|
17
|
-
* (default: excludes `'**\/*.{test,spec}.?(c|m)[jt]s?(x)'`)
|
|
18
|
-
*
|
|
19
|
-
* @deprecated Use `exclude` instead.
|
|
20
|
-
*/
|
|
21
|
-
excludePatterns?: readonly string[];
|
|
22
16
|
/** File extensions of source files to export (default: ['.ts', '.tsx']) */
|
|
23
|
-
|
|
17
|
+
targetExtensions?: readonly `.${string}`[];
|
|
24
18
|
/** File extension of index files to generate (default: '.ts') */
|
|
25
|
-
|
|
19
|
+
indexFileExtension?: `.${string}`;
|
|
26
20
|
/** File extension to use in export statements (default: '.js') */
|
|
27
|
-
|
|
21
|
+
exportStatementExtension?: `.${string}` | 'none';
|
|
28
22
|
/** Command to run for formatting generated files (optional) */
|
|
29
23
|
formatCommand?: string;
|
|
30
24
|
/** Whether to suppress output during execution (default: false) */
|
|
@@ -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,kFAAkF;IAClF,eAAe,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAE5C
|
|
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,kFAAkF;IAClF,eAAe,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAE5C;;;;OAIG;IACH,OAAO,CAAC,EACJ,SAAS,MAAM,EAAE,GACjB,CAAC,CACC,IAAI,EAAE,QAAQ,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,KACC,OAAO,CAAC,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,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,CA8CnE,CAAC"}
|