ts-repo-utils 1.0.1 → 1.2.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 +21 -27
- package/dist/functions/assert-ext.d.mts +1 -1
- package/dist/functions/assert-ext.d.mts.map +1 -1
- package/dist/functions/assert-ext.mjs +3 -2
- package/dist/functions/assert-ext.mjs.map +1 -1
- package/dist/functions/assert-path-exists.d.mts +3 -3
- package/dist/functions/assert-path-exists.d.mts.map +1 -1
- package/dist/functions/assert-path-exists.mjs +5 -4
- package/dist/functions/assert-path-exists.mjs.map +1 -1
- package/dist/functions/assert-repo-is-dirty.d.mts +1 -1
- package/dist/functions/assert-repo-is-dirty.mjs +1 -1
- package/dist/functions/gen-index.d.mts.map +1 -1
- package/dist/functions/gen-index.mjs +3 -21
- package/dist/functions/gen-index.mjs.map +1 -1
- package/dist/node-global.d.mts +0 -2
- package/dist/node-global.d.mts.map +1 -1
- package/dist/node-global.mjs +2 -4
- package/dist/node-global.mjs.map +1 -1
- package/package.json +6 -6
- package/src/functions/assert-ext.mts +3 -2
- package/src/functions/assert-path-exists.mts +5 -4
- package/src/functions/assert-repo-is-dirty.mts +1 -1
- package/src/functions/gen-index.mts +3 -22
- package/src/node-global.mts +0 -3
- package/dist/project-root-path.d.mts +0 -2
- package/dist/project-root-path.d.mts.map +0 -1
- package/dist/project-root-path.mjs +0 -6
- package/dist/project-root-path.mjs.map +0 -1
- package/src/project-root-path.mts +0 -3
package/README.md
CHANGED
|
@@ -27,23 +27,20 @@ console.log(exists); // true or false
|
|
|
27
27
|
|
|
28
28
|
#### `assertPathExists(filePath: string, description?: string): Promise<void>`
|
|
29
29
|
|
|
30
|
-
Validates that a path exists and
|
|
30
|
+
Validates that a path exists and exits with code 1 if it doesn't.
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
33
33
|
import { assertPathExists } from 'ts-repo-utils';
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error('Entry point file does not exist');
|
|
39
|
-
}
|
|
35
|
+
// If the file doesn't exist, this will exit the process with code 1
|
|
36
|
+
await assertPathExists('./src/index.ts', 'Entry point file');
|
|
40
37
|
```
|
|
41
38
|
|
|
42
39
|
### File Extension Validation
|
|
43
40
|
|
|
44
41
|
#### `assertExt(config: CheckExtConfig): Promise<void>`
|
|
45
42
|
|
|
46
|
-
Validates that all files in specified directories have the correct extensions.
|
|
43
|
+
Validates that all files in specified directories have the correct extensions. Exits with code 1 if any files have incorrect extensions.
|
|
47
44
|
|
|
48
45
|
```typescript
|
|
49
46
|
import { assertExt } from 'ts-repo-utils';
|
|
@@ -103,7 +100,7 @@ await assertRepoIsDirty();
|
|
|
103
100
|
|
|
104
101
|
### Command Execution
|
|
105
102
|
|
|
106
|
-
#### `$(command: string, options?:
|
|
103
|
+
#### `$(command: string, options?: { silent?: boolean; timeout?: number }): Promise<ExecResult>`
|
|
107
104
|
|
|
108
105
|
Executes a shell command asynchronously with timeout support and type-safe results.
|
|
109
106
|
|
|
@@ -119,14 +116,14 @@ if (result.type === 'ok') {
|
|
|
119
116
|
}
|
|
120
117
|
```
|
|
121
118
|
|
|
122
|
-
**
|
|
119
|
+
**Options:**
|
|
123
120
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
silent?: boolean; // Don't log command/output (default: false)
|
|
127
|
-
timeout?: number; // Timeout in milliseconds (default: 30000)
|
|
128
|
-
}>;
|
|
121
|
+
- `silent?: boolean` - Don't log command/output (default: false)
|
|
122
|
+
- `timeout?: number` - Timeout in milliseconds (default: 30000)
|
|
129
123
|
|
|
124
|
+
**Return Type:**
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
130
127
|
type ExecResult = Readonly<
|
|
131
128
|
| { type: 'ok'; stdout: string; stderr: string }
|
|
132
129
|
| { type: 'error'; exception: ExecException }
|
|
@@ -178,7 +175,7 @@ await formatDiffFrom('abc123');
|
|
|
178
175
|
|
|
179
176
|
#### `genIndex(config: GenIndexConfig): Promise<void>`
|
|
180
177
|
|
|
181
|
-
Generates index
|
|
178
|
+
Generates index files recursively in target directories with automatic barrel exports.
|
|
182
179
|
|
|
183
180
|
```typescript
|
|
184
181
|
import { genIndex } from 'ts-repo-utils';
|
|
@@ -204,11 +201,11 @@ type GenIndexConfig = DeepReadonly<{
|
|
|
204
201
|
|
|
205
202
|
**Features:**
|
|
206
203
|
|
|
207
|
-
- Validates file extensions before generation
|
|
208
204
|
- Creates barrel exports for all subdirectories
|
|
209
|
-
- Supports complex glob exclusion patterns
|
|
210
|
-
- Automatically formats generated files
|
|
205
|
+
- Supports complex glob exclusion patterns (using micromatch)
|
|
206
|
+
- Automatically formats generated files using project's prettier config
|
|
211
207
|
- Works with both single directories and directory arrays
|
|
208
|
+
- Respects source and export extension configuration
|
|
212
209
|
|
|
213
210
|
## Key Features
|
|
214
211
|
|
|
@@ -226,7 +223,7 @@ type GenIndexConfig = DeepReadonly<{
|
|
|
226
223
|
### Pre-commit Hook
|
|
227
224
|
|
|
228
225
|
```typescript
|
|
229
|
-
import { formatChanged, assertExt,
|
|
226
|
+
import { formatChanged, assertExt, assertRepoIsDirty } from 'ts-repo-utils';
|
|
230
227
|
|
|
231
228
|
// Format changed files
|
|
232
229
|
await formatChanged();
|
|
@@ -236,7 +233,7 @@ await assertExt({
|
|
|
236
233
|
directories: [{ path: './src', extension: '.ts' }],
|
|
237
234
|
});
|
|
238
235
|
|
|
239
|
-
// Ensure
|
|
236
|
+
// Ensure repository is clean (exits if dirty)
|
|
240
237
|
await assertRepoIsDirty();
|
|
241
238
|
```
|
|
242
239
|
|
|
@@ -269,17 +266,14 @@ await formatFiles('dist/**/*.js');
|
|
|
269
266
|
### Project Validation
|
|
270
267
|
|
|
271
268
|
```typescript
|
|
272
|
-
import { pathExists, assertPathExists,
|
|
269
|
+
import { pathExists, assertPathExists, assertRepoIsDirty } from 'ts-repo-utils';
|
|
273
270
|
|
|
274
|
-
// Check required files exist
|
|
271
|
+
// Check required files exist (exits with code 1 if files don't exist)
|
|
275
272
|
await assertPathExists('./package.json', 'Package manifest');
|
|
276
273
|
await assertPathExists('./tsconfig.json', 'TypeScript config');
|
|
277
274
|
|
|
278
|
-
// Verify clean repository state
|
|
279
|
-
|
|
280
|
-
if (isDirty) {
|
|
281
|
-
throw new Error('Repository has uncommitted changes');
|
|
282
|
-
}
|
|
275
|
+
// Verify clean repository state (exits with code 1 if repo is dirty)
|
|
276
|
+
await assertRepoIsDirty();
|
|
283
277
|
```
|
|
284
278
|
|
|
285
279
|
## License
|
|
@@ -15,8 +15,8 @@ export type CheckExtConfig = DeepReadonly<{
|
|
|
15
15
|
}>;
|
|
16
16
|
/**
|
|
17
17
|
* Validates that all files in specified directories have the correct extensions.
|
|
18
|
+
* Exits with code 1 if any files have incorrect extensions.
|
|
18
19
|
* @param config - Configuration specifying directories and expected extensions.
|
|
19
|
-
* @throws Error with details of all incorrect files found.
|
|
20
20
|
*/
|
|
21
21
|
export declare const assertExt: (config: CheckExtConfig) => Promise<void>;
|
|
22
22
|
//# sourceMappingURL=assert-ext.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-ext.d.mts","sourceRoot":"","sources":["../../src/functions/assert-ext.mts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;IACxC,6DAA6D;IAC7D,WAAW,EAAE;QACX,8BAA8B;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,kDAAkD;QAClD,SAAS,EAAE,MAAM,CAAC;QAClB,sFAAsF;QACtF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,EAAE,CAAC;CACL,CAAC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"assert-ext.d.mts","sourceRoot":"","sources":["../../src/functions/assert-ext.mts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;IACxC,6DAA6D;IAC7D,WAAW,EAAE;QACX,8BAA8B;QAC9B,IAAI,EAAE,MAAM,CAAC;QACb,kDAAkD;QAClD,SAAS,EAAE,MAAM,CAAC;QAClB,sFAAsF;QACtF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B,EAAE,CAAC;CACL,CAAC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,CA4DpE,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { assertPathExists } from './assert-path-exists.mjs';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Validates that all files in specified directories have the correct extensions.
|
|
6
|
+
* Exits with code 1 if any files have incorrect extensions.
|
|
6
7
|
* @param config - Configuration specifying directories and expected extensions.
|
|
7
|
-
* @throws Error with details of all incorrect files found.
|
|
8
8
|
*/
|
|
9
9
|
const assertExt = async (config) => {
|
|
10
10
|
const allIncorrectFiles = [];
|
|
@@ -46,7 +46,8 @@ const assertExt = async (config) => {
|
|
|
46
46
|
'',
|
|
47
47
|
generateErrorMessage(),
|
|
48
48
|
].join('\n');
|
|
49
|
-
|
|
49
|
+
echo(errorMessage);
|
|
50
|
+
process.exit(1);
|
|
50
51
|
}
|
|
51
52
|
echo('✓ All files have correct extensions');
|
|
52
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-ext.mjs","sources":["../../src/functions/assert-ext.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAkBA;;;;AAIG;MACU,SAAS,GAAG,OAAO,MAAsB,KAAmB;IACvE,MAAM,iBAAiB,GAAa,EAAE;;IAGtC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,O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IAGjB,IAAI,CAAC,qCAAqC,CAAC;AAC7C;AAEA;;;;;;AAMG;AACH,MAAM,8BAA8B,GAAG,OACrC,GAAW,EACX,iBAAyB,EACzB,cAAkC,KACb;AACrB,IAAA,MAAM,gBAAgB,CAAC,GAAG,EAAE,WAAW,CAAC;AAExC,IAAA,MAAM,qBAAqB,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC;AAC9D,IAAA,MAAM,mBAAmB,GAAG,cAAc,IAAI,qBAAqB;;AAGnE,IAAA,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,OAAO,KAC7D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE,CACzD;IAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,CAAG,EAAA,GAAG,OAAO,EAAE;AACtC,QAAA,MAAM,EAAE,sBAAsB;AAC/B,KAAA,CAAC;AAEF,IAAA,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAClE,CAAC;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../node-global.mjs';
|
|
1
2
|
/**
|
|
2
3
|
* Checks if a file or directory exists.
|
|
3
4
|
* @param filePath - The path to check.
|
|
@@ -5,10 +6,9 @@
|
|
|
5
6
|
*/
|
|
6
7
|
export declare const pathExists: (filePath: string) => Promise<boolean>;
|
|
7
8
|
/**
|
|
8
|
-
* Validates that a path exists and
|
|
9
|
+
* Validates that a path exists and exits with code 1 if it doesn't.
|
|
9
10
|
* @param filePath - The path to validate.
|
|
10
|
-
* @param description - Description for error message.
|
|
11
|
-
* @throws Error if path doesn't exist.
|
|
11
|
+
* @param description - Description for error message (defaults to 'Path').
|
|
12
12
|
*/
|
|
13
13
|
export declare const assertPathExists: (filePath: string, description?: string) => Promise<void>;
|
|
14
14
|
//# sourceMappingURL=assert-path-exists.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-path-exists.d.mts","sourceRoot":"","sources":["../../src/functions/assert-path-exists.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert-path-exists.d.mts","sourceRoot":"","sources":["../../src/functions/assert-path-exists.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAOlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,oBAAoB,KACnB,OAAO,CAAC,IAAI,CAKd,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs_ from 'node:fs/promises';
|
|
2
|
+
import '../node-global.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Checks if a file or directory exists.
|
|
@@ -15,14 +16,14 @@ const pathExists = async (filePath) => {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
|
-
* Validates that a path exists and
|
|
19
|
+
* Validates that a path exists and exits with code 1 if it doesn't.
|
|
19
20
|
* @param filePath - The path to validate.
|
|
20
|
-
* @param description - Description for error message.
|
|
21
|
-
* @throws Error if path doesn't exist.
|
|
21
|
+
* @param description - Description for error message (defaults to 'Path').
|
|
22
22
|
*/
|
|
23
23
|
const assertPathExists = async (filePath, description = 'Path') => {
|
|
24
24
|
if (!(await pathExists(filePath))) {
|
|
25
|
-
|
|
25
|
+
echo(`${description} does not exist: ${filePath}`);
|
|
26
|
+
process.exit(1);
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-path-exists.mjs","sources":["../../src/functions/assert-path-exists.mts"],"sourcesContent":[null],"names":["fs"],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert-path-exists.mjs","sources":["../../src/functions/assert-path-exists.mts"],"sourcesContent":[null],"names":["fs"],"mappings":";;;AAGA;;;;AAIG;MACU,UAAU,GAAG,OAAO,QAAgB,KAAsB;AACrE,IAAA,IAAI;AACF,QAAA,MAAMA,GAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;AACzB,QAAA,OAAO,IAAI;;AACX,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;;AAEhB;AAEA;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,OAC9B,QAAgB,EAChB,WAAW,GAAG,MAAM,KACH;IACjB,IAAI,EAAE,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE;AACjC,QAAA,IAAI,CAAC,CAAG,EAAA,WAAW,oBAAoB,QAAQ,CAAA,CAAE,CAAC;AAClD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEnB;;;;"}
|
|
@@ -7,7 +7,7 @@ import '../node-global.mjs';
|
|
|
7
7
|
export declare const repoIsDirty: () => Promise<boolean>;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if the repository is dirty and exits with code 1 if it is.
|
|
10
|
-
*
|
|
10
|
+
* Shows git status and diff output before exiting.
|
|
11
11
|
*/
|
|
12
12
|
export declare const assertRepoIsDirty: () => Promise<void>;
|
|
13
13
|
//# sourceMappingURL=assert-repo-is-dirty.d.mts.map
|
|
@@ -11,7 +11,7 @@ const repoIsDirty = async () => {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Checks if the repository is dirty and exits with code 1 if it is.
|
|
14
|
-
*
|
|
14
|
+
* Shows git status and diff output before exiting.
|
|
15
15
|
*/
|
|
16
16
|
const assertRepoIsDirty = async () => {
|
|
17
17
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;IACxC,kFAAkF;IAClF,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEnC,iEAAiE;IACjE,eAAe,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAE/B,mEAAmE;IACnE,eAAe,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAE/B,gGAAgG;IAChG,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,CA0CnE,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import micromatch from 'micromatch';
|
|
2
2
|
import '../node-global.mjs';
|
|
3
|
-
import { assertExt } from './assert-ext.mjs';
|
|
4
3
|
import { assertPathExists } from './assert-path-exists.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -17,30 +16,13 @@ const genIndex = async (config) => {
|
|
|
17
16
|
? [config.targetDirectory]
|
|
18
17
|
: config.targetDirectory;
|
|
19
18
|
try {
|
|
20
|
-
// Step 1:
|
|
21
|
-
echo('1. Validating file extensions...');
|
|
22
|
-
await assertExt({
|
|
23
|
-
directories: [
|
|
24
|
-
{
|
|
25
|
-
path: path.resolve(projectRootPath, './src'),
|
|
26
|
-
extension: '.mts',
|
|
27
|
-
ignorePatterns: ['tsconfig.json', 'globals.d.mts'],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
path: path.resolve(projectRootPath, './scripts'),
|
|
31
|
-
extension: '.mts',
|
|
32
|
-
ignorePatterns: ['tsconfig.json'],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
});
|
|
36
|
-
echo('✓ File extensions validated\n');
|
|
37
|
-
// Step 2: Verify target directories exist
|
|
19
|
+
// Step 1: Verify target directories exist
|
|
38
20
|
for (const dir of targetDirs) {
|
|
39
21
|
const resolvedDir = path.resolve(dir);
|
|
40
22
|
// eslint-disable-next-line no-await-in-loop
|
|
41
23
|
await assertPathExists(resolvedDir, `Target directory: ${dir}`);
|
|
42
24
|
}
|
|
43
|
-
// Step
|
|
25
|
+
// Step 2: Generate index files
|
|
44
26
|
echo('2. Generating index files...');
|
|
45
27
|
for (const dir of targetDirs) {
|
|
46
28
|
const resolvedDir = path.resolve(dir);
|
|
@@ -48,7 +30,7 @@ const genIndex = async (config) => {
|
|
|
48
30
|
await generateIndexFileForDir(resolvedDir, filledConfig);
|
|
49
31
|
}
|
|
50
32
|
echo('✓ Index files generated\n');
|
|
51
|
-
// Step
|
|
33
|
+
// Step 3: Format generated files
|
|
52
34
|
echo('3. Formatting generated files...');
|
|
53
35
|
const fmtResult = await $('npm run fmt');
|
|
54
36
|
if (fmtResult.type === 'error') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAqBA;;;;AAIG;MACU,QAAQ,GAAG,OAAO,MAAsB,KAAmB;IACtE,IAAI,CAAC,qCAAqC,CAAC;;AAG3C,IAAA,MAAM,YAAY,GAAiC,UAAU,CAAC,MAAM,CAAC;;AAGrE,IAAA,MAAM,UAAU,GACd,OAAO,MAAM,CAAC,eAAe,KAAK;AAChC,UAAE,CAAC,MAAM,CAAC,eAAe;AACzB,UAAE,MAAM,CAAC,eAAe;AAE5B,IAAA,IAAI;;AAEF,QAAA,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;;YAEr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,gBAAgB,CAAC,MAAM,KAAK;AACjC,UAAE;AACF,UAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;;;;"}
|
package/dist/node-global.d.mts
CHANGED
|
@@ -2,11 +2,9 @@ import { default as glob_ } from 'fast-glob';
|
|
|
2
2
|
import * as fs_ from 'node:fs/promises';
|
|
3
3
|
import * as path_ from 'node:path';
|
|
4
4
|
import { $ as $_ } from './functions/exec-async.mjs';
|
|
5
|
-
import { projectRootPath as projectRootPath_ } from './project-root-path.mjs';
|
|
6
5
|
declare global {
|
|
7
6
|
const $: typeof $_;
|
|
8
7
|
const echo: typeof console.log;
|
|
9
|
-
const projectRootPath: typeof projectRootPath_;
|
|
10
8
|
const path: typeof path_;
|
|
11
9
|
const fs: typeof fs_;
|
|
12
10
|
const glob: typeof glob_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-global.d.mts","sourceRoot":"","sources":["../src/node-global.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"node-global.d.mts","sourceRoot":"","sources":["../src/node-global.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAarD,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,IAAI,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAE/B,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,EAAE,EAAE,OAAO,GAAG,CAAC;IACrB,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;CAC1B"}
|
package/dist/node-global.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import glob_ from 'fast-glob';
|
|
2
2
|
import * as fs_ from 'node:fs/promises';
|
|
3
|
-
import * as
|
|
3
|
+
import * as path_ from 'node:path';
|
|
4
4
|
import { $ } from './functions/exec-async.mjs';
|
|
5
|
-
import { projectRootPath } from './project-root-path.mjs';
|
|
6
5
|
|
|
7
6
|
const globalsDef = {
|
|
8
7
|
$: $,
|
|
9
8
|
echo: console.log,
|
|
10
|
-
|
|
11
|
-
path: path,
|
|
9
|
+
path: path_,
|
|
12
10
|
fs: fs_,
|
|
13
11
|
glob: glob_,
|
|
14
12
|
};
|
package/dist/node-global.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-global.mjs","sources":["../src/node-global.mts"],"sourcesContent":[null],"names":["$_"
|
|
1
|
+
{"version":3,"file":"node-global.mjs","sources":["../src/node-global.mts"],"sourcesContent":[null],"names":["$_"],"mappings":";;;;;AAKA,MAAM,UAAU,GAAG;AACjB,IAAA,CAAC,EAAEA,CAAE;IACL,IAAI,EAAE,OAAO,CAAC,GAAG;AAEjB,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,IAAI,EAAE,KAAK;CACH;AAEV,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-repo-utils",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"author": "noshiro-pf <noshiro.pf@gmail.com>",
|
|
14
|
-
"sideEffects":
|
|
14
|
+
"sideEffects": true,
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "npm run z:node-
|
|
33
|
+
"build": "npm run z:node-esm -- ./scripts/cmd/build.mjs",
|
|
34
34
|
"check-all": "npm run z:node-esm -- ./scripts/cmd/check-all.mjs",
|
|
35
35
|
"check:ext": "npm run z:node-esm -- ./scripts/cmd/check-ext.mjs",
|
|
36
36
|
"cspell": "cspell \"**\" --gitignore --gitignore-root ./ --no-progress",
|
|
37
|
-
"doc": "npm run z:node-
|
|
38
|
-
"fmt": "
|
|
37
|
+
"doc": "npm run z:node-esm -- ./scripts/cmd/gen-docs.mjs",
|
|
38
|
+
"fmt": "npm run z:node-esm -- ./scripts/cmd/fmt-diff.mjs",
|
|
39
|
+
"fmt:full": "prettier --write .",
|
|
39
40
|
"gi": "npm run z:node-esm -- ./scripts/cmd/gi.mjs",
|
|
40
41
|
"lint": "eslint .",
|
|
41
42
|
"lint:fix": "eslint . --fix",
|
|
@@ -50,7 +51,6 @@
|
|
|
50
51
|
"type-check": "tsc --noEmit",
|
|
51
52
|
"update-packages": "npx npm-check-updates -u --install always --reject @types/node",
|
|
52
53
|
"z:node-esm": "node --import tsx/esm",
|
|
53
|
-
"z:node-eval": "npm run z:node-esm -- --input-type=module --eval",
|
|
54
54
|
"z:vitest": "vitest --config ./configs/vitest.config.ts"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
@@ -18,8 +18,8 @@ export type CheckExtConfig = DeepReadonly<{
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Validates that all files in specified directories have the correct extensions.
|
|
21
|
+
* Exits with code 1 if any files have incorrect extensions.
|
|
21
22
|
* @param config - Configuration specifying directories and expected extensions.
|
|
22
|
-
* @throws Error with details of all incorrect files found.
|
|
23
23
|
*/
|
|
24
24
|
export const assertExt = async (config: CheckExtConfig): Promise<void> => {
|
|
25
25
|
const allIncorrectFiles: string[] = [];
|
|
@@ -76,7 +76,8 @@ export const assertExt = async (config: CheckExtConfig): Promise<void> => {
|
|
|
76
76
|
generateErrorMessage(),
|
|
77
77
|
].join('\n');
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
echo(errorMessage);
|
|
80
|
+
process.exit(1);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
echo('✓ All files have correct extensions');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
|
+
import '../node-global.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Checks if a file or directory exists.
|
|
@@ -15,16 +16,16 @@ export const pathExists = async (filePath: string): Promise<boolean> => {
|
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* Validates that a path exists and
|
|
19
|
+
* Validates that a path exists and exits with code 1 if it doesn't.
|
|
19
20
|
* @param filePath - The path to validate.
|
|
20
|
-
* @param description - Description for error message.
|
|
21
|
-
* @throws Error if path doesn't exist.
|
|
21
|
+
* @param description - Description for error message (defaults to 'Path').
|
|
22
22
|
*/
|
|
23
23
|
export const assertPathExists = async (
|
|
24
24
|
filePath: string,
|
|
25
25
|
description = 'Path',
|
|
26
26
|
): Promise<void> => {
|
|
27
27
|
if (!(await pathExists(filePath))) {
|
|
28
|
-
|
|
28
|
+
echo(`${description} does not exist: ${filePath}`);
|
|
29
|
+
process.exit(1);
|
|
29
30
|
}
|
|
30
31
|
};
|
|
@@ -12,7 +12,7 @@ export const repoIsDirty = async (): Promise<boolean> => {
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Checks if the repository is dirty and exits with code 1 if it is.
|
|
15
|
-
*
|
|
15
|
+
* Shows git status and diff output before exiting.
|
|
16
16
|
*/
|
|
17
17
|
export const assertRepoIsDirty = async (): Promise<void> => {
|
|
18
18
|
try {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import micromatch from 'micromatch';
|
|
2
2
|
import '../node-global.mjs';
|
|
3
|
-
import { assertExt } from './assert-ext.mjs';
|
|
4
3
|
import { assertPathExists } from './assert-path-exists.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -38,32 +37,14 @@ export const genIndex = async (config: GenIndexConfig): Promise<void> => {
|
|
|
38
37
|
: config.targetDirectory;
|
|
39
38
|
|
|
40
39
|
try {
|
|
41
|
-
// Step 1:
|
|
42
|
-
echo('1. Validating file extensions...');
|
|
43
|
-
await assertExt({
|
|
44
|
-
directories: [
|
|
45
|
-
{
|
|
46
|
-
path: path.resolve(projectRootPath, './src'),
|
|
47
|
-
extension: '.mts',
|
|
48
|
-
ignorePatterns: ['tsconfig.json', 'globals.d.mts'],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
path: path.resolve(projectRootPath, './scripts'),
|
|
52
|
-
extension: '.mts',
|
|
53
|
-
ignorePatterns: ['tsconfig.json'],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
echo('✓ File extensions validated\n');
|
|
58
|
-
|
|
59
|
-
// Step 2: Verify target directories exist
|
|
40
|
+
// Step 1: Verify target directories exist
|
|
60
41
|
for (const dir of targetDirs) {
|
|
61
42
|
const resolvedDir = path.resolve(dir);
|
|
62
43
|
// eslint-disable-next-line no-await-in-loop
|
|
63
44
|
await assertPathExists(resolvedDir, `Target directory: ${dir}`);
|
|
64
45
|
}
|
|
65
46
|
|
|
66
|
-
// Step
|
|
47
|
+
// Step 2: Generate index files
|
|
67
48
|
echo('2. Generating index files...');
|
|
68
49
|
for (const dir of targetDirs) {
|
|
69
50
|
const resolvedDir = path.resolve(dir);
|
|
@@ -72,7 +53,7 @@ export const genIndex = async (config: GenIndexConfig): Promise<void> => {
|
|
|
72
53
|
}
|
|
73
54
|
echo('✓ Index files generated\n');
|
|
74
55
|
|
|
75
|
-
// Step
|
|
56
|
+
// Step 3: Format generated files
|
|
76
57
|
echo('3. Formatting generated files...');
|
|
77
58
|
const fmtResult = await $('npm run fmt');
|
|
78
59
|
if (fmtResult.type === 'error') {
|
package/src/node-global.mts
CHANGED
|
@@ -2,12 +2,10 @@ import { default as glob_ } from 'fast-glob';
|
|
|
2
2
|
import * as fs_ from 'node:fs/promises';
|
|
3
3
|
import * as path_ from 'node:path';
|
|
4
4
|
import { $ as $_ } from './functions/exec-async.mjs';
|
|
5
|
-
import { projectRootPath as projectRootPath_ } from './project-root-path.mjs';
|
|
6
5
|
|
|
7
6
|
const globalsDef = {
|
|
8
7
|
$: $_,
|
|
9
8
|
echo: console.log,
|
|
10
|
-
projectRootPath: projectRootPath_,
|
|
11
9
|
|
|
12
10
|
path: path_,
|
|
13
11
|
fs: fs_,
|
|
@@ -19,7 +17,6 @@ Object.assign(globalThis, globalsDef);
|
|
|
19
17
|
declare global {
|
|
20
18
|
const $: typeof $_;
|
|
21
19
|
const echo: typeof console.log;
|
|
22
|
-
const projectRootPath: typeof projectRootPath_;
|
|
23
20
|
|
|
24
21
|
const path: typeof path_;
|
|
25
22
|
const fs: typeof fs_;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-root-path.d.mts","sourceRoot":"","sources":["../src/project-root-path.mts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,QAA0C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-root-path.mjs","sources":["../src/project-root-path.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEa,MAAA,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI;;;;"}
|