ts-repo-utils 6.2.0 → 7.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 +148 -32
- package/dist/cmd/assert-repo-is-clean.mjs +1 -1
- package/dist/cmd/check-should-run-type-checks.mjs +1 -1
- package/dist/cmd/format-diff-from.mjs +1 -1
- package/dist/cmd/format-uncommitted.mjs +1 -1
- package/dist/cmd/gen-index-ts.mjs +1 -1
- package/dist/functions/assert-repo-is-clean.d.mts.map +1 -1
- package/dist/functions/assert-repo-is-clean.mjs +30 -30
- package/dist/functions/assert-repo-is-clean.mjs.map +1 -1
- package/dist/functions/diff.d.mts +2 -2
- package/dist/functions/diff.mjs +4 -4
- package/dist/functions/diff.mjs.map +1 -1
- package/dist/functions/exec-async.d.mts +7 -8
- package/dist/functions/exec-async.d.mts.map +1 -1
- package/dist/functions/exec-async.mjs +5 -5
- package/dist/functions/exec-async.mjs.map +1 -1
- package/dist/functions/format.d.mts.map +1 -1
- package/dist/functions/format.mjs +12 -25
- package/dist/functions/format.mjs.map +1 -1
- package/dist/functions/gen-index.d.mts +2 -1
- package/dist/functions/gen-index.d.mts.map +1 -1
- package/dist/functions/gen-index.mjs +10 -8
- package/dist/functions/gen-index.mjs.map +1 -1
- package/package.json +1 -1
- 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-uncommitted.mts +1 -1
- package/src/cmd/gen-index-ts.mts +1 -1
- package/src/functions/assert-repo-is-clean.mts +43 -34
- package/src/functions/diff.mts +4 -4
- package/src/functions/exec-async.mts +25 -35
- package/src/functions/format.mts +14 -25
- package/src/functions/gen-index.mts +16 -10
package/README.md
CHANGED
|
@@ -86,9 +86,9 @@ npm exec -- format-uncommitted --silent
|
|
|
86
86
|
|
|
87
87
|
**Options:**
|
|
88
88
|
|
|
89
|
-
- `--exclude-untracked` - Exclude untracked files
|
|
90
|
-
- `--exclude-modified` - Exclude modified files
|
|
91
|
-
- `--exclude-staged` - Exclude staged files
|
|
89
|
+
- `--exclude-untracked` - Exclude untracked files (default: false)
|
|
90
|
+
- `--exclude-modified` - Exclude modified files (default: false)
|
|
91
|
+
- `--exclude-staged` - Exclude staged files (default: false)
|
|
92
92
|
- `--silent` - Suppress output messages (default: false)
|
|
93
93
|
|
|
94
94
|
### `format-diff-from`
|
|
@@ -115,9 +115,9 @@ npm exec -- format-diff-from main --silent
|
|
|
115
115
|
**Options:**
|
|
116
116
|
|
|
117
117
|
- `<base>` - Base branch name or commit hash to compare against (required)
|
|
118
|
-
- `--exclude-untracked` - Exclude untracked files
|
|
119
|
-
- `--exclude-modified` - Exclude modified files
|
|
120
|
-
- `--exclude-staged` - Exclude staged files
|
|
118
|
+
- `--exclude-untracked` - Exclude untracked files (default: false)
|
|
119
|
+
- `--exclude-modified` - Exclude modified files (default: false)
|
|
120
|
+
- `--exclude-staged` - Exclude staged files (default: false)
|
|
121
121
|
- `--silent` - Suppress output messages (default: false)
|
|
122
122
|
|
|
123
123
|
### `check-should-run-type-checks`
|
|
@@ -283,9 +283,49 @@ import { assertRepoIsClean } from 'ts-repo-utils';
|
|
|
283
283
|
await assertRepoIsClean();
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
+
**Options:**
|
|
287
|
+
|
|
288
|
+
- `silent?` - Suppress output messages (default: false)
|
|
289
|
+
|
|
290
|
+
#### Getting Git diff files
|
|
291
|
+
|
|
292
|
+
##### `getUntrackedFiles(options?)`
|
|
293
|
+
|
|
294
|
+
Get untracked files from the working tree (files not added to git).
|
|
295
|
+
Runs `git ls-files --others --exclude-standard [--deleted]`
|
|
296
|
+
|
|
297
|
+
##### `getModifiedFiles(options?)`
|
|
298
|
+
|
|
299
|
+
Get modified files from the working tree (files that have been changed but not staged).
|
|
300
|
+
Runs `git diff --name-only [--diff-filter=d]`
|
|
301
|
+
|
|
302
|
+
##### `getStagedFiles(options?)`
|
|
303
|
+
|
|
304
|
+
Get files that are staged for commit (files added with git add).
|
|
305
|
+
Runs `git diff --staged --name-only [--diff-filter=d]`
|
|
306
|
+
|
|
307
|
+
##### `getDiffFrom(base: string, options?)`
|
|
308
|
+
|
|
309
|
+
Get files that differ from the specified base branch or commit.
|
|
310
|
+
Runs `git diff --name-only <base> [--diff-filter=d]`
|
|
311
|
+
|
|
312
|
+
**Common options:**
|
|
313
|
+
|
|
314
|
+
- `excludeDeleted?: boolean` - Exclude deleted files (for formatters etc.) (default: true)
|
|
315
|
+
- `silent?: boolean` - Don't log command/output (default: false)
|
|
316
|
+
|
|
317
|
+
**Common Return Type:**
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
type Ret = Result<
|
|
321
|
+
readonly string[],
|
|
322
|
+
ExecException | Readonly<{ message: string }>
|
|
323
|
+
>;
|
|
324
|
+
```
|
|
325
|
+
|
|
286
326
|
### Command Execution
|
|
287
327
|
|
|
288
|
-
#### `$(command: string, options?:
|
|
328
|
+
#### `$(command: string, options?: ExecOptions): Promise<ExecResult>`
|
|
289
329
|
|
|
290
330
|
Executes a shell command asynchronously with timeout support and type-safe results.
|
|
291
331
|
|
|
@@ -304,45 +344,69 @@ if (result.type === 'ok') {
|
|
|
304
344
|
**Options:**
|
|
305
345
|
|
|
306
346
|
- `silent?: boolean` - Don't log command/output (default: false)
|
|
307
|
-
- `
|
|
347
|
+
- `'node:child_process'` `exec` function options
|
|
308
348
|
|
|
309
349
|
**Return Type:**
|
|
310
350
|
|
|
311
351
|
```typescript
|
|
312
|
-
type
|
|
313
|
-
|
|
314
|
-
|
|
352
|
+
type Ret = Promise<
|
|
353
|
+
Result<
|
|
354
|
+
Readonly<{ stdout: string | Buffer; stderr: string | Buffer }>,
|
|
355
|
+
import('node:child_process').ExecException
|
|
356
|
+
>
|
|
315
357
|
>;
|
|
316
358
|
```
|
|
317
359
|
|
|
318
360
|
### Code Formatting Utilities
|
|
319
361
|
|
|
320
|
-
#### `
|
|
362
|
+
#### `formatFilesGlob(pathGlob: string): Promise<Result<undefined, unknown>>`
|
|
321
363
|
|
|
322
364
|
Format files matching a glob pattern using Prettier.
|
|
323
365
|
|
|
324
366
|
```typescript
|
|
325
|
-
import {
|
|
367
|
+
import { formatFilesGlob } from 'ts-repo-utils';
|
|
326
368
|
|
|
327
369
|
// Format all TypeScript files in src
|
|
328
|
-
await
|
|
370
|
+
await formatFilesGlob('src/**/*.ts');
|
|
329
371
|
|
|
330
372
|
// Format specific files
|
|
331
|
-
await
|
|
373
|
+
await formatFilesGlob('src/{index,utils}.ts');
|
|
332
374
|
```
|
|
333
375
|
|
|
334
|
-
|
|
376
|
+
**Options:**
|
|
377
|
+
|
|
378
|
+
- `silent?` - Suppress output messages (default: false)
|
|
379
|
+
|
|
380
|
+
#### `formatUncommittedFiles(): Promise<Result>`
|
|
335
381
|
|
|
336
382
|
Format only files that have been changed according to git status.
|
|
337
383
|
|
|
338
384
|
```typescript
|
|
339
|
-
import {
|
|
385
|
+
import { formatUncommittedFiles } from 'ts-repo-utils';
|
|
340
386
|
|
|
341
387
|
// Format only modified files
|
|
342
|
-
await
|
|
388
|
+
await formatUncommittedFiles();
|
|
343
389
|
```
|
|
344
390
|
|
|
345
|
-
|
|
391
|
+
**Options:**
|
|
392
|
+
|
|
393
|
+
- `untracked?` - Format untracked files (default: true)
|
|
394
|
+
- `modified?` - Format modified files (default: true)
|
|
395
|
+
- `staged?` - Format staged files (default: true)
|
|
396
|
+
- `silent?` - Suppress output messages (default: false)
|
|
397
|
+
|
|
398
|
+
**Return Type:**
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
type Ret = Promise<
|
|
402
|
+
Result<
|
|
403
|
+
undefined,
|
|
404
|
+
ExecException | Readonly<{ message: string }> | readonly unknown[]
|
|
405
|
+
>
|
|
406
|
+
>;
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
#### `formatDiffFrom(base: string): Promise<Result>`
|
|
346
410
|
|
|
347
411
|
Format only files that differ from the specified base branch or commit.
|
|
348
412
|
|
|
@@ -356,9 +420,27 @@ await formatDiffFrom('main');
|
|
|
356
420
|
await formatDiffFrom('abc123');
|
|
357
421
|
```
|
|
358
422
|
|
|
423
|
+
**Options:**
|
|
424
|
+
|
|
425
|
+
- `includeUntracked?` - Include untracked files in addition to diff files (default: true)
|
|
426
|
+
- `includeModified?` - Include modified files in addition to diff files (default: true)
|
|
427
|
+
- `includeStaged?` - Include staged files in addition to diff files (default: true)
|
|
428
|
+
- `silent?` - Suppress output messages (default: false)
|
|
429
|
+
|
|
430
|
+
**Return Type:**
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
type Ret = Promise<
|
|
434
|
+
Result<
|
|
435
|
+
undefined,
|
|
436
|
+
ExecException | Readonly<{ message: string }> | readonly unknown[]
|
|
437
|
+
>
|
|
438
|
+
>;
|
|
439
|
+
```
|
|
440
|
+
|
|
359
441
|
### Index File Generation
|
|
360
442
|
|
|
361
|
-
#### `genIndex(config: GenIndexConfig): Promise<
|
|
443
|
+
#### `genIndex(config: GenIndexConfig): Promise<Result<undefined, unknown>>`
|
|
362
444
|
|
|
363
445
|
Generates index files recursively in target directories with automatic barrel exports.
|
|
364
446
|
|
|
@@ -367,9 +449,7 @@ import { genIndex } from 'ts-repo-utils';
|
|
|
367
449
|
|
|
368
450
|
await genIndex({
|
|
369
451
|
targetDirectory: './src',
|
|
370
|
-
|
|
371
|
-
exportExtension: '.js',
|
|
372
|
-
excludePatterns: ['*.test.ts', '*.spec.ts'],
|
|
452
|
+
exclude: ['*.test.ts', '*.spec.ts'],
|
|
373
453
|
});
|
|
374
454
|
```
|
|
375
455
|
|
|
@@ -377,10 +457,41 @@ await genIndex({
|
|
|
377
457
|
|
|
378
458
|
```typescript
|
|
379
459
|
type GenIndexConfig = DeepReadonly<{
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
460
|
+
/**
|
|
461
|
+
* Target directories to generate index files for (string or array of
|
|
462
|
+
* strings)
|
|
463
|
+
*/
|
|
464
|
+
targetDirectory: string | readonly string[];
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Glob patterns of files or predicate function to exclude from exports
|
|
468
|
+
* (default: excludes `'**\/*.{test,spec}.?(c|m)[jt]s?(x)'` and
|
|
469
|
+
* `'**\/*.d.?(c|m)ts'`)
|
|
470
|
+
*/
|
|
471
|
+
exclude?:
|
|
472
|
+
| readonly string[]
|
|
473
|
+
| ((
|
|
474
|
+
args: Readonly<{
|
|
475
|
+
absolutePath: string;
|
|
476
|
+
relativePath: string;
|
|
477
|
+
fileName: string;
|
|
478
|
+
}>,
|
|
479
|
+
) => boolean);
|
|
480
|
+
|
|
481
|
+
/** File extensions of source files to export (default: ['.ts', '.tsx']) */
|
|
482
|
+
targetExtensions?: readonly `.${string}`[];
|
|
483
|
+
|
|
484
|
+
/** File extension of index files to generate (default: '.ts') */
|
|
485
|
+
indexFileExtension?: `.${string}`;
|
|
486
|
+
|
|
487
|
+
/** File extension to use in export statements (default: '.js') */
|
|
488
|
+
exportStatementExtension?: `.${string}` | 'none';
|
|
489
|
+
|
|
490
|
+
/** Command to run for formatting generated files (optional) */
|
|
491
|
+
formatCommand?: string;
|
|
492
|
+
|
|
493
|
+
/** Whether to suppress output during execution (default: false) */
|
|
494
|
+
silent?: boolean;
|
|
384
495
|
}>;
|
|
385
496
|
```
|
|
386
497
|
|
|
@@ -392,6 +503,11 @@ type GenIndexConfig = DeepReadonly<{
|
|
|
392
503
|
- Works with both single directories and directory arrays
|
|
393
504
|
- Respects source and export extension configuration
|
|
394
505
|
|
|
506
|
+
**Benefits:**
|
|
507
|
+
|
|
508
|
+
- Prevents forgetting to export libraries
|
|
509
|
+
- tsc can detect duplicate variables, type names, etc.
|
|
510
|
+
|
|
395
511
|
## Key Features
|
|
396
512
|
|
|
397
513
|
- **Type Safety**: All functions use strict TypeScript types with readonly parameters
|
|
@@ -410,14 +526,14 @@ type GenIndexConfig = DeepReadonly<{
|
|
|
410
526
|
```typescript
|
|
411
527
|
import { formatUntracked, assertExt, assertRepoIsClean } from 'ts-repo-utils';
|
|
412
528
|
|
|
413
|
-
// Format changed files
|
|
414
|
-
await formatUntracked();
|
|
415
|
-
|
|
416
529
|
// Validate file extensions
|
|
417
530
|
await assertExt({
|
|
418
531
|
directories: [{ path: './src', extension: '.ts' }],
|
|
419
532
|
});
|
|
420
533
|
|
|
534
|
+
// Format changed files
|
|
535
|
+
await formatUncommittedFiles();
|
|
536
|
+
|
|
421
537
|
// Ensure repository is clean (exits if dirty)
|
|
422
538
|
await assertRepoIsClean();
|
|
423
539
|
```
|
|
@@ -425,7 +541,7 @@ await assertRepoIsClean();
|
|
|
425
541
|
### Build Pipeline
|
|
426
542
|
|
|
427
543
|
```typescript
|
|
428
|
-
import { assertExt, genIndex, $,
|
|
544
|
+
import { assertExt, genIndex, $, formatFilesGlob } from 'ts-repo-utils';
|
|
429
545
|
|
|
430
546
|
// Validate extensions
|
|
431
547
|
await assertExt({
|
|
@@ -445,7 +561,7 @@ await $('tsc --noEmit');
|
|
|
445
561
|
await $('rollup -c');
|
|
446
562
|
|
|
447
563
|
// Format output
|
|
448
|
-
await
|
|
564
|
+
await formatFilesGlob('dist/**/*.js');
|
|
449
565
|
```
|
|
450
566
|
|
|
451
567
|
### Project Validation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-repo-is-clean.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-clean.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"assert-repo-is-clean.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-clean.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,CAkCd,CAAC"}
|
|
@@ -9,41 +9,41 @@ import '../node-global.mjs';
|
|
|
9
9
|
*/
|
|
10
10
|
const repoIsDirty = async (options) => {
|
|
11
11
|
const status = await getGitStatus({ silent: options?.silent ?? false });
|
|
12
|
-
|
|
12
|
+
if (Result.isErr(status)) {
|
|
13
|
+
throw new Error(`Failed to get git status: ${status.value}`);
|
|
14
|
+
}
|
|
15
|
+
return status.value.isDirty;
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* Checks if the repository is clean and exits with code 1 if it is dirty. Shows
|
|
16
19
|
* git status and diff output before exiting.
|
|
17
20
|
*/
|
|
18
21
|
const assertRepoIsClean = async (options) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
silent: options?.silent ?? false,
|
|
31
|
-
});
|
|
32
|
-
if (Result.isErr(addResult)) {
|
|
33
|
-
echo('Warning: Failed to add untracked files for diff\n');
|
|
34
|
-
}
|
|
35
|
-
const diffResult = await $('git diff', {
|
|
36
|
-
silent: options?.silent ?? false,
|
|
37
|
-
});
|
|
38
|
-
if (Result.isErr(diffResult)) {
|
|
39
|
-
echo('Warning: Failed to show diff\n');
|
|
40
|
-
}
|
|
41
|
-
process.exit(1);
|
|
22
|
+
const silent = options?.silent ?? false;
|
|
23
|
+
const conditionalEcho = silent ? () => { } : echo;
|
|
24
|
+
const gitStatusResult = await getGitStatus({ silent });
|
|
25
|
+
if (Result.isErr(gitStatusResult)) {
|
|
26
|
+
conditionalEcho(gitStatusResult.value);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const gitStatus = gitStatusResult.value;
|
|
30
|
+
if (!gitStatus.isDirty) {
|
|
31
|
+
conditionalEcho('Repo is clean\n');
|
|
32
|
+
return;
|
|
42
33
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
conditionalEcho('Repo is dirty\n');
|
|
35
|
+
conditionalEcho('Changed files:\n');
|
|
36
|
+
conditionalEcho(gitStatus.stdout);
|
|
37
|
+
// Show files not tracked by git and unstaged changes
|
|
38
|
+
const addResult = await $('git add -N .', { silent });
|
|
39
|
+
if (Result.isErr(addResult)) {
|
|
40
|
+
conditionalEcho('Warning: Failed to add untracked files for diff\n');
|
|
46
41
|
}
|
|
42
|
+
const diffResult = await $('git diff', { silent });
|
|
43
|
+
if (Result.isErr(diffResult)) {
|
|
44
|
+
conditionalEcho('Warning: Failed to show diff\n');
|
|
45
|
+
}
|
|
46
|
+
process.exit(1);
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* Gets the git status of the repository.
|
|
@@ -55,13 +55,13 @@ const getGitStatus = async (options) => {
|
|
|
55
55
|
silent: options?.silent ?? false,
|
|
56
56
|
});
|
|
57
57
|
if (Result.isErr(res)) {
|
|
58
|
-
|
|
58
|
+
return Result.err(`Failed to get git status: ${res.value.message}`);
|
|
59
59
|
}
|
|
60
60
|
const { stdout } = res.value;
|
|
61
|
-
return {
|
|
61
|
+
return Result.ok({
|
|
62
62
|
isDirty: stdout.trim() !== '',
|
|
63
63
|
stdout,
|
|
64
|
-
};
|
|
64
|
+
});
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
export { assertRepoIsClean, repoIsDirty };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-repo-is-clean.mjs","sources":["../../src/functions/assert-repo-is-clean.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;AAKG;MACU,WAAW,GAAG,OACzB,OAAwC,KACpB;AACpB,IAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"assert-repo-is-clean.mjs","sources":["../../src/functions/assert-repo-is-clean.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;AAKG;MACU,WAAW,GAAG,OACzB,OAAwC,KACpB;AACpB,IAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;AACvE,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,KAAK,CAAA,CAAE,CAAC;IAC9D;AACA,IAAA,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO;AAC7B;AAEA;;;AAGG;MACU,iBAAiB,GAAG,OAC/B,OAAwC,KACvB;AACjB,IAAA,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK;AACvC,IAAA,MAAM,eAAe,GAAG,MAAM,GAAG,MAAK,EAAE,CAAC,GAAG,IAAI;IAEhD,MAAM,eAAe,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;AAEtD,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE;AACjC,QAAA,eAAe,CAAC,eAAe,CAAC,KAAK,CAAC;QACtC;IACF;AAEA,IAAA,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK;AAEvC,IAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;QACtB,eAAe,CAAC,iBAAiB,CAAC;QAClC;IACF;IAEA,eAAe,CAAC,iBAAiB,CAAC;IAClC,eAAe,CAAC,kBAAkB,CAAC;AACnC,IAAA,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC;;IAGjC,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,CAAC;AACrD,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;QAC3B,eAAe,CAAC,mDAAmD,CAAC;IACtE;IAEA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC;AAClD,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;QAC5B,eAAe,CAAC,gCAAgC,CAAC;IACnD;AAEA,IAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACjB;AAEA;;;;AAIG;AACH,MAAM,YAAY,GAAG,OACnB,OAAwC,KAStC;AACF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,wBAAwB,EAAE;AAC5C,QAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;AACjC,KAAA,CAAC;AAEF,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;AACrB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA,0BAAA,EAA6B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;IACrE;AAEA,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK;IAE5B,OAAO,MAAM,CAAC,EAAE,CAAC;AACf,QAAA,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;QAC7B,MAAM;AACP,KAAA,CAAC;AACJ,CAAC;;;;"}
|
|
@@ -14,8 +14,8 @@ export declare const getUntrackedFiles: (options?: Readonly<{
|
|
|
14
14
|
message: string;
|
|
15
15
|
}>>>;
|
|
16
16
|
/**
|
|
17
|
-
* Get
|
|
18
|
-
* git diff --
|
|
17
|
+
* Get modified files from the working tree (files that have been changed but
|
|
18
|
+
* not staged). Runs `git diff --name-only [--diff-filter=d]`
|
|
19
19
|
*/
|
|
20
20
|
export declare const getModifiedFiles: (options?: Readonly<{
|
|
21
21
|
/** @default true */
|
package/dist/functions/diff.mjs
CHANGED
|
@@ -12,12 +12,12 @@ const getUntrackedFiles = async (options) => cmdResultToFiles({
|
|
|
12
12
|
options,
|
|
13
13
|
});
|
|
14
14
|
/**
|
|
15
|
-
* Get
|
|
16
|
-
* git diff --
|
|
15
|
+
* Get modified files from the working tree (files that have been changed but
|
|
16
|
+
* not staged). Runs `git diff --name-only [--diff-filter=d]`
|
|
17
17
|
*/
|
|
18
18
|
const getModifiedFiles = async (options) => cmdResultToFiles({
|
|
19
19
|
cmd: `git diff --name-only`,
|
|
20
|
-
cmdOptionToExcludeDeleted: '--diff-filter=d',
|
|
20
|
+
cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
|
|
21
21
|
cmdOptionToIncludeDeleted: '',
|
|
22
22
|
options,
|
|
23
23
|
});
|
|
@@ -27,7 +27,7 @@ const getModifiedFiles = async (options) => cmdResultToFiles({
|
|
|
27
27
|
*/
|
|
28
28
|
const getStagedFiles = async (options) => cmdResultToFiles({
|
|
29
29
|
cmd: `git diff --staged --name-only`,
|
|
30
|
-
cmdOptionToExcludeDeleted: '--diff-filter=d',
|
|
30
|
+
cmdOptionToExcludeDeleted: '--diff-filter=d', // lower case 'd' means exclude deleted files
|
|
31
31
|
cmdOptionToIncludeDeleted: '',
|
|
32
32
|
options,
|
|
33
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;;AAGG;AACI,MAAM,iBAAiB,GAAG,OAC/B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,wCAAA,CAA0C;AAC/C,IAAA,yBAAyB,EAAE,EAAE;AAC7B,IAAA,yBAAyB,EAAE,WA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AA,CAAC,OAAO,EAAE,cAAc,IAAI,IAAI;AAC9B,cAAE;AACF,cAAE,yBAAyB;AAC9B;SACE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE;AACtB,SAAA,IAAI,CAAC,GAAG,CAAC,EACZ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CACrC;AAED,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,QAAA,OAAO,MAAM;IACf;AAEA,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK;;IAG/B,MAAM,KAAK,GAAG;SACX,KAAK,CAAC,IAAI;SACV,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;SACzB,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;AAEhC,IAAA,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;AACzB,CAAC;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as childProcess from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
3
|
type ExecOptionsCustom = Readonly<{
|
|
4
4
|
silent?: boolean;
|
|
5
5
|
}>;
|
|
6
|
-
export type ExecOptions =
|
|
6
|
+
export type ExecOptions = childProcess.ExecOptions & ExecOptionsCustom;
|
|
7
7
|
export type ExecResult<T extends string | Buffer> = Result<Readonly<{
|
|
8
8
|
stdout: T;
|
|
9
9
|
stderr: T;
|
|
10
|
-
}>, ExecException>;
|
|
10
|
+
}>, childProcess.ExecException>;
|
|
11
11
|
/**
|
|
12
12
|
* Executes a shell command asynchronously.
|
|
13
13
|
*
|
|
@@ -15,12 +15,11 @@ export type ExecResult<T extends string | Buffer> = Result<Readonly<{
|
|
|
15
15
|
* @param options - Optional configuration for command execution.
|
|
16
16
|
* @returns A promise that resolves with the command result.
|
|
17
17
|
*/
|
|
18
|
-
export declare function $(command: string, options?: ExecOptionsCustom
|
|
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<{
|
|
18
|
+
export declare function $(command: string, options?: ExecOptionsCustom | Readonly<{
|
|
23
19
|
encoding: BufferEncoding;
|
|
24
20
|
} & ExecOptions>): Promise<ExecResult<string>>;
|
|
21
|
+
export declare function $(command: string, options?: Readonly<{
|
|
22
|
+
encoding: 'buffer' | null;
|
|
23
|
+
} & ExecOptions>): Promise<ExecResult<Buffer>>;
|
|
25
24
|
export {};
|
|
26
25
|
//# 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,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,GAAG,iBAAiB,CAAC;AAEvE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CACxD,QAAQ,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,EAClC,YAAY,CAAC,aAAa,CAC3B,CAAC;AAEF;;;;;;GAMG;AAEH,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EAEf,OAAO,CAAC,EACJ,iBAAiB,GACjB,QAAQ,CAAC;IAAE,QAAQ,EAAE,cAAc,CAAA;CAAE,GAAG,WAAW,CAAC,GACvD,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/B,wBAAgB,CAAC,CACf,OAAO,EAAE,MAAM,EAEf,OAAO,CAAC,EAAE,QAAQ,CAAC;IAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,GAAG,WAAW,CAAC,GAC9D,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as childProcess from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
3
|
|
|
4
|
-
function $(command,
|
|
4
|
+
function $(command,
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
6
|
+
options) {
|
|
5
7
|
const { silent = false, ...restOptions } = options ?? {};
|
|
6
8
|
if (!silent) {
|
|
7
9
|
echo(`$ ${command}`);
|
|
8
10
|
}
|
|
9
11
|
return new Promise((resolve) => {
|
|
10
12
|
// eslint-disable-next-line security/detect-child-process
|
|
11
|
-
exec(command,
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
13
|
-
restOptions, (error, stdout, stderr) => {
|
|
13
|
+
childProcess.exec(command, restOptions, (error, stdout, stderr) => {
|
|
14
14
|
if (!silent) {
|
|
15
15
|
if (stdout !== '') {
|
|
16
16
|
echo(stdout);
|
|
@@ -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":";;;AAoCM,SAAU,CAAC,CACf,OAAe;AACf;AACA,OAEC,EAAA;AAED,IAAA,MAAM,EAAE,MAAM,GAAG,KAAK,E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