ts-repo-utils 6.1.0 → 6.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 +11 -7
- 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 +29 -8
- package/dist/cmd/format-diff-from.mjs.map +1 -1
- package/dist/cmd/format-uncommitted.d.mts +3 -0
- package/dist/cmd/format-uncommitted.d.mts.map +1 -0
- package/dist/cmd/format-uncommitted.mjs +59 -0
- package/dist/cmd/format-uncommitted.mjs.map +1 -0
- package/dist/cmd/gen-index-ts.mjs +1 -1
- package/dist/functions/diff.d.mts +32 -2
- package/dist/functions/diff.d.mts.map +1 -1
- package/dist/functions/diff.mjs +47 -29
- package/dist/functions/diff.mjs.map +1 -1
- package/dist/functions/exec-async.d.mts +2 -2
- package/dist/functions/exec-async.d.mts.map +1 -1
- package/dist/functions/format.d.mts +20 -11
- package/dist/functions/format.d.mts.map +1 -1
- package/dist/functions/format.mjs +134 -95
- package/dist/functions/format.mjs.map +1 -1
- package/dist/functions/index.mjs +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- 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 +35 -9
- package/src/cmd/format-uncommitted.mts +67 -0
- package/src/cmd/gen-index-ts.mts +1 -1
- package/src/functions/diff.mts +85 -32
- package/src/functions/diff.test.mts +569 -102
- package/src/functions/exec-async.mts +2 -2
- package/src/functions/exec-async.test.mts +77 -47
- package/src/functions/format.mts +224 -141
- package/src/functions/format.test.mts +625 -20
- package/src/functions/workspace-utils/run-cmd-in-stages.test.mts +266 -0
- package/dist/cmd/format-untracked.d.mts +0 -3
- package/dist/cmd/format-untracked.d.mts.map +0 -1
- package/dist/cmd/format-untracked.mjs +0 -34
- package/dist/cmd/format-untracked.mjs.map +0 -1
- package/src/cmd/format-untracked.mts +0 -31
package/README.md
CHANGED
|
@@ -72,21 +72,24 @@ npm exec -- assert-repo-is-clean --silent
|
|
|
72
72
|
|
|
73
73
|
- `--silent` - Suppress output messages (optional)
|
|
74
74
|
|
|
75
|
-
### `format-
|
|
75
|
+
### `format-uncommitted`
|
|
76
76
|
|
|
77
77
|
Formats only untracked/modified files using Prettier.
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
80
|
# Basic usage
|
|
81
|
-
npm exec -- format-
|
|
81
|
+
npm exec -- format-uncommitted
|
|
82
82
|
|
|
83
83
|
# Silent mode
|
|
84
|
-
npm exec -- format-
|
|
84
|
+
npm exec -- format-uncommitted --silent
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
**Options:**
|
|
88
88
|
|
|
89
|
-
- `--
|
|
89
|
+
- `--exclude-untracked` - Exclude untracked files in addition to diff files (default: false)
|
|
90
|
+
- `--exclude-modified` - Exclude modified files in addition to diff files (default: false)
|
|
91
|
+
- `--exclude-staged` - Exclude staged files in addition to diff files (default: false)
|
|
92
|
+
- `--silent` - Suppress output messages (default: false)
|
|
90
93
|
|
|
91
94
|
### `format-diff-from`
|
|
92
95
|
|
|
@@ -112,9 +115,10 @@ npm exec -- format-diff-from main --silent
|
|
|
112
115
|
**Options:**
|
|
113
116
|
|
|
114
117
|
- `<base>` - Base branch name or commit hash to compare against (required)
|
|
115
|
-
- `--
|
|
116
|
-
- `--exclude-
|
|
117
|
-
- `--
|
|
118
|
+
- `--exclude-untracked` - Exclude untracked files in addition to diff files (default: false)
|
|
119
|
+
- `--exclude-modified` - Exclude modified files in addition to diff files (default: false)
|
|
120
|
+
- `--exclude-staged` - Exclude staged files in addition to diff files (default: false)
|
|
121
|
+
- `--silent` - Suppress output messages (default: false)
|
|
118
122
|
|
|
119
123
|
### `check-should-run-type-checks`
|
|
120
124
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
2
|
import * as cmd from 'cmd-ts';
|
|
3
|
-
import 'ts-data-forge';
|
|
3
|
+
import { Result } from 'ts-data-forge';
|
|
4
4
|
import '../node-global.mjs';
|
|
5
5
|
import 'node:child_process';
|
|
6
6
|
import { formatDiffFrom } from '../functions/format.mjs';
|
|
@@ -9,17 +9,27 @@ import 'child_process';
|
|
|
9
9
|
|
|
10
10
|
const cmdDef = cmd.command({
|
|
11
11
|
name: 'format-diff-from-cli',
|
|
12
|
-
version: '6.
|
|
12
|
+
version: '6.2.0',
|
|
13
13
|
args: {
|
|
14
14
|
base: cmd.positional({
|
|
15
15
|
type: cmd.string,
|
|
16
16
|
displayName: 'base',
|
|
17
17
|
description: 'Base branch name or commit hash to compare against',
|
|
18
18
|
}),
|
|
19
|
-
|
|
20
|
-
long: '
|
|
19
|
+
excludeUntracked: cmd.flag({
|
|
20
|
+
long: 'exclude-untracked',
|
|
21
21
|
type: cmd.optional(cmd.boolean),
|
|
22
|
-
description: '
|
|
22
|
+
description: 'Exclude untracked files in addition to diff files (default: false)',
|
|
23
|
+
}),
|
|
24
|
+
excludeModified: cmd.flag({
|
|
25
|
+
long: 'exclude-modified',
|
|
26
|
+
type: cmd.optional(cmd.boolean),
|
|
27
|
+
description: 'Exclude modified files in addition to diff files (default: false)',
|
|
28
|
+
}),
|
|
29
|
+
excludeStaged: cmd.flag({
|
|
30
|
+
long: 'exclude-staged',
|
|
31
|
+
type: cmd.optional(cmd.boolean),
|
|
32
|
+
description: 'Exclude staged files in addition to diff files (default: false)',
|
|
23
33
|
}),
|
|
24
34
|
silent: cmd.flag({
|
|
25
35
|
long: 'silent',
|
|
@@ -28,15 +38,26 @@ const cmdDef = cmd.command({
|
|
|
28
38
|
}),
|
|
29
39
|
},
|
|
30
40
|
handler: (args) => {
|
|
31
|
-
main(
|
|
41
|
+
main({
|
|
42
|
+
base: args.base,
|
|
43
|
+
excludeUntracked: args.excludeUntracked ?? false,
|
|
44
|
+
excludeModified: args.excludeModified ?? false,
|
|
45
|
+
excludeStaged: args.excludeStaged ?? false,
|
|
46
|
+
silent: args.silent ?? false,
|
|
47
|
+
}).catch((error) => {
|
|
32
48
|
console.error('An error occurred:', error);
|
|
33
49
|
process.exit(1);
|
|
34
50
|
});
|
|
35
51
|
},
|
|
36
52
|
});
|
|
37
53
|
const main = async (args) => {
|
|
38
|
-
const result = await formatDiffFrom(args.base,
|
|
39
|
-
|
|
54
|
+
const result = await formatDiffFrom(args.base, {
|
|
55
|
+
includeUntracked: !args.excludeUntracked,
|
|
56
|
+
includeModified: !args.excludeModified,
|
|
57
|
+
includeStaged: !args.excludeStaged,
|
|
58
|
+
silent: args.silent,
|
|
59
|
+
});
|
|
60
|
+
if (Result.isErr(result)) {
|
|
40
61
|
process.exit(1);
|
|
41
62
|
}
|
|
42
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-diff-from.mjs","sources":["../../src/cmd/format-diff-from.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"format-diff-from.mjs","sources":["../../src/cmd/format-diff-from.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAMA,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,GAAG,CAAC,MAAM;AAChB,YAAA,WAAW,EAAE,MAAM;AACnB,YAAA,WAAW,EAAE,oDAAoD;SAClE,CAAC;AACF,QAAA,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC;AACzB,YAAA,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC;AAC/B,YAAA,WAAW,EACT,oEAAoE;SACvE,CAAC;AACF,QAAA,eAAe,EAAE,GAAG,CA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IAAI,CAAC,gBAAgB;AACxC,QAAA,eAAe,EAAE,CAAC,IAAI,CAAC,eAAe;AACtC,QAAA,aAAa,EAAE,CAAC,IAAI,CAAC,aAAa;QAClC,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,KAAA,CAAC;AAEF,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,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":"format-uncommitted.d.mts","sourceRoot":"","sources":["../../src/cmd/format-uncommitted.mts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env -S npx tsx
|
|
2
|
+
import * as cmd from 'cmd-ts';
|
|
3
|
+
import { Result } from 'ts-data-forge';
|
|
4
|
+
import '../node-global.mjs';
|
|
5
|
+
import 'node:child_process';
|
|
6
|
+
import { formatUncommittedFiles } from '../functions/format.mjs';
|
|
7
|
+
import 'micromatch';
|
|
8
|
+
import 'child_process';
|
|
9
|
+
|
|
10
|
+
const cmdDef = cmd.command({
|
|
11
|
+
name: 'format-uncommitted-cli',
|
|
12
|
+
version: '6.2.0',
|
|
13
|
+
args: {
|
|
14
|
+
excludeUntracked: cmd.flag({
|
|
15
|
+
long: 'exclude-untracked',
|
|
16
|
+
type: cmd.optional(cmd.boolean),
|
|
17
|
+
description: 'Exclude untracked files in addition to diff files (default: false)',
|
|
18
|
+
}),
|
|
19
|
+
excludeModified: cmd.flag({
|
|
20
|
+
long: 'exclude-modified',
|
|
21
|
+
type: cmd.optional(cmd.boolean),
|
|
22
|
+
description: 'Exclude modified files in addition to diff files (default: false)',
|
|
23
|
+
}),
|
|
24
|
+
excludeStaged: cmd.flag({
|
|
25
|
+
long: 'exclude-staged',
|
|
26
|
+
type: cmd.optional(cmd.boolean),
|
|
27
|
+
description: 'Exclude staged files in addition to diff files (default: false)',
|
|
28
|
+
}),
|
|
29
|
+
silent: cmd.flag({
|
|
30
|
+
long: 'silent',
|
|
31
|
+
type: cmd.optional(cmd.boolean),
|
|
32
|
+
description: 'If true, suppresses output messages (default: false)',
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
35
|
+
handler: (args) => {
|
|
36
|
+
main({
|
|
37
|
+
excludeUntracked: args.excludeUntracked ?? false,
|
|
38
|
+
excludeModified: args.excludeModified ?? false,
|
|
39
|
+
excludeStaged: args.excludeStaged ?? false,
|
|
40
|
+
silent: args.silent ?? false,
|
|
41
|
+
}).catch((error) => {
|
|
42
|
+
console.error('An error occurred:', error);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const main = async (args) => {
|
|
48
|
+
const result = await formatUncommittedFiles({
|
|
49
|
+
untracked: !args.excludeUntracked,
|
|
50
|
+
modified: !args.excludeModified,
|
|
51
|
+
staged: !args.excludeStaged,
|
|
52
|
+
silent: args.silent,
|
|
53
|
+
});
|
|
54
|
+
if (Result.isErr(result)) {
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
await cmd.run(cmdDef, process.argv.slice(2));
|
|
59
|
+
//# sourceMappingURL=format-uncommitted.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-uncommitted.mjs","sources":["../../src/cmd/format-uncommitted.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAMA,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,IAAI,EAAE,wBAAwB;AAC9B,IAAA,OAAO,EAAE,OAAO;AAChB,IAAA,IAAI,EAAE;AACJ,QAAA,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC;AACzB,YAAA,IAAI,EAA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AAG,OACX,IAKE,KACe;AACjB,IAAA,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC;AAC1C,QAAA,SAAS,EAAE,CAAC,IAAI,CAAC,gBAAgB;AACjC,QAAA,QAAQ,EAAE,CAAC,IAAI,CAAC,eAAe;AAC/B,QAAA,MAAM,EAAE,CAAC,IAAI,CAAC,aAAa;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;AACpB,KAAA,CAAC;AACF,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,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"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type ExecException } from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
3
|
import '../node-global.mjs';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
6
|
+
* ls-files --others --exclude-standard [--deleted]`
|
|
7
|
+
*/
|
|
5
8
|
export declare const getUntrackedFiles: (options?: Readonly<{
|
|
6
9
|
/** @default true */
|
|
7
10
|
excludeDeleted?: boolean;
|
|
@@ -10,7 +13,34 @@ export declare const getUntrackedFiles: (options?: Readonly<{
|
|
|
10
13
|
}>) => Promise<Result<readonly string[], ExecException | Readonly<{
|
|
11
14
|
message: string;
|
|
12
15
|
}>>>;
|
|
13
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
18
|
+
* git diff --staged --name-only [--diff-filter=d]`
|
|
19
|
+
*/
|
|
20
|
+
export declare const getModifiedFiles: (options?: Readonly<{
|
|
21
|
+
/** @default true */
|
|
22
|
+
excludeDeleted?: boolean;
|
|
23
|
+
/** @default false */
|
|
24
|
+
silent?: boolean;
|
|
25
|
+
}>) => Promise<Result<readonly string[], ExecException | Readonly<{
|
|
26
|
+
message: string;
|
|
27
|
+
}>>>;
|
|
28
|
+
/**
|
|
29
|
+
* Get files that are staged for commit (files added with git add). Runs `git
|
|
30
|
+
* diff --staged --name-only [--diff-filter=d]`
|
|
31
|
+
*/
|
|
32
|
+
export declare const getStagedFiles: (options?: Readonly<{
|
|
33
|
+
/** @default true */
|
|
34
|
+
excludeDeleted?: boolean;
|
|
35
|
+
/** @default false */
|
|
36
|
+
silent?: boolean;
|
|
37
|
+
}>) => Promise<Result<readonly string[], ExecException | Readonly<{
|
|
38
|
+
message: string;
|
|
39
|
+
}>>>;
|
|
40
|
+
/**
|
|
41
|
+
* Get files that differ from the specified base branch or commit. Runs `git
|
|
42
|
+
* diff --name-only <base> [--diff-filter=d]`
|
|
43
|
+
*/
|
|
14
44
|
export declare const getDiffFrom: (base: string, options?: Readonly<{
|
|
15
45
|
/** @default true */
|
|
16
46
|
excludeDeleted?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.mts","sourceRoot":"","sources":["../../src/functions/diff.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,oBAAoB,CAAC;AAE5B
|
|
1
|
+
{"version":3,"file":"diff.d.mts","sourceRoot":"","sources":["../../src/functions/diff.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IACjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB;IACrB,MAAM,CAAC,EA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node-global.mjs';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
6
|
+
* ls-files --others --exclude-standard [--deleted]`
|
|
7
|
+
*/
|
|
8
|
+
const getUntrackedFiles = async (options) => cmdResultToFiles({
|
|
9
|
+
cmd: `git ls-files --others --exclude-standard`,
|
|
10
|
+
cmdOptionToExcludeDeleted: '',
|
|
11
|
+
cmdOptionToIncludeDeleted: '--deleted',
|
|
12
|
+
options,
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
16
|
+
* git diff --staged --name-only [--diff-filter=d]`
|
|
17
|
+
*/
|
|
18
|
+
const getModifiedFiles = async (options) => cmdResultToFiles({
|
|
19
|
+
cmd: `git diff --name-only`,
|
|
20
|
+
cmdOptionToExcludeDeleted: '--diff-filter=d',
|
|
21
|
+
cmdOptionToIncludeDeleted: '',
|
|
22
|
+
options,
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Get files that are staged for commit (files added with git add). Runs `git
|
|
26
|
+
* diff --staged --name-only [--diff-filter=d]`
|
|
27
|
+
*/
|
|
28
|
+
const getStagedFiles = async (options) => cmdResultToFiles({
|
|
29
|
+
cmd: `git diff --staged --name-only`,
|
|
30
|
+
cmdOptionToExcludeDeleted: '--diff-filter=d',
|
|
31
|
+
cmdOptionToIncludeDeleted: '',
|
|
32
|
+
options,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Get files that differ from the specified base branch or commit. Runs `git
|
|
36
|
+
* diff --name-only <base> [--diff-filter=d]`
|
|
37
|
+
*/
|
|
38
|
+
const getDiffFrom = async (base, options) => cmdResultToFiles({
|
|
39
|
+
cmd: `git diff --name-only ${base}`,
|
|
40
|
+
cmdOptionToExcludeDeleted: '--diff-filter=d',
|
|
41
|
+
cmdOptionToIncludeDeleted: '',
|
|
42
|
+
options,
|
|
43
|
+
});
|
|
44
|
+
const cmdResultToFiles = async ({ cmd, cmdOptionToExcludeDeleted, cmdOptionToIncludeDeleted, options, }) => {
|
|
7
45
|
const result = await $([
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
46
|
+
cmd,
|
|
47
|
+
(options?.excludeDeleted ?? true)
|
|
48
|
+
? cmdOptionToExcludeDeleted
|
|
49
|
+
: cmdOptionToIncludeDeleted,
|
|
11
50
|
]
|
|
12
51
|
.filter((s) => s !== '')
|
|
13
52
|
.join(' '), { silent: options?.silent ?? false });
|
|
@@ -15,28 +54,7 @@ const getUntrackedFiles = async (options) => {
|
|
|
15
54
|
return result;
|
|
16
55
|
}
|
|
17
56
|
const { stdout } = result.value;
|
|
18
|
-
// Parse git
|
|
19
|
-
const files = stdout
|
|
20
|
-
.split('\n')
|
|
21
|
-
.map((s) => s.trim())
|
|
22
|
-
.filter((s) => s !== '');
|
|
23
|
-
return Result.ok(files);
|
|
24
|
-
};
|
|
25
|
-
/** Get files that differ from the specified base branch or commit */
|
|
26
|
-
const getDiffFrom = async (base, options) => {
|
|
27
|
-
// Get files that differ from base branch/commit (excluding deleted files)
|
|
28
|
-
const result = await $([
|
|
29
|
-
`git diff --name-only`,
|
|
30
|
-
base,
|
|
31
|
-
(options?.excludeDeleted ?? true) ? '--diff-filter=d' : '',
|
|
32
|
-
]
|
|
33
|
-
.filter((s) => s !== '')
|
|
34
|
-
.join(' '), { silent: options?.silent ?? false });
|
|
35
|
-
if (Result.isErr(result)) {
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
const { stdout } = result.value;
|
|
39
|
-
// Parse git diff output
|
|
57
|
+
// Parse git output
|
|
40
58
|
const files = stdout
|
|
41
59
|
.split('\n')
|
|
42
60
|
.map((line) => line.trim())
|
|
@@ -44,5 +62,5 @@ const getDiffFrom = async (base, options) => {
|
|
|
44
62
|
return Result.ok(files);
|
|
45
63
|
};
|
|
46
64
|
|
|
47
|
-
export { getDiffFrom, getUntrackedFiles };
|
|
65
|
+
export { getDiffFrom, getModifiedFiles, getStagedFiles, getUntrackedFiles };
|
|
48
66
|
//# sourceMappingURL=diff.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;
|
|
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,WAAW;IACtC,OAAO;AACR,CAAA;AAEH;;;AAGG;AACI,MAAM,gBAAgB,GAAG,OAC9B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,oBAAA,CAAsB;AAC3B,IAAA,yBAAyB,EAAE,iBAAiB;AAC5C,IAAA,yBAAyB,EAAE,EAAE;IAC7B,OAAO;AACR,CAAA;AAEH;;;AAGG;AACI,MAAM,cAAc,GAAG,OAC5B,OAKE,KAIF,gBAAgB,CAAC;AACf,IAAA,GAAG,EAAE,CAAA,6BAAA,CAA+B;AACpC,IAAA,yBAAyB,EAAE,iBAAiB;AAC5C,IAAA,yBAAyB,EAAE,EAAE;IAC7B,OAAO;AACR,CAAA;AAEH;;;AAGG;AACI,MAAM,WAAW,GAAG,OACzB,IAAY,EACZ,OAKE,KAIF,gBAAgB,CAAC;IACf,GAAG,EAAE,CAAA,qBAAA,EAAwB,IAAI,CAAA,CAAE;AACnC,IAAA,yBAAyB,EAAE,iBAAiB;AAC5C,IAAA,yBAAyB,EAAE,EAAE;IAC7B,OAAO;AACR,CAAA;AAEH,MAAM,gBAAgB,GAAG,OAAO,EAC9B,GAAG,EACH,yBAAyB,EACzB,yBAAyB,EACzB,OAAO,GAWP,KAEE;AACF,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,CACpB;QACE,GAAG;AACH,QAAA,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;;;;"}
|
|
@@ -3,8 +3,8 @@ import { Result } from 'ts-data-forge';
|
|
|
3
3
|
type ExecOptionsCustom = Readonly<{
|
|
4
4
|
silent?: boolean;
|
|
5
5
|
}>;
|
|
6
|
-
type ExecOptions = DeepReadonly<ExecOptions_ & ExecOptionsCustom>;
|
|
7
|
-
type ExecResult<T extends string | Buffer> = Result<Readonly<{
|
|
6
|
+
export type ExecOptions = DeepReadonly<ExecOptions_ & ExecOptionsCustom>;
|
|
7
|
+
export type ExecResult<T extends string | Buffer> = Result<Readonly<{
|
|
8
8
|
stdout: T;
|
|
9
9
|
stderr: T;
|
|
10
10
|
}>, ExecException>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-async.d.mts","sourceRoot":"","sources":["../../src/functions/exec-async.mts"],"names":[],"mappings":"AAAA,OAAO,E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Q,EAAE,cAAc,CAAA;CAAE,GAAG,WAAW,CAAC,GAC5D,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
+
import { type ExecException } from 'node:child_process';
|
|
2
|
+
import { Result } from 'ts-data-forge';
|
|
1
3
|
import '../node-global.mjs';
|
|
2
4
|
/**
|
|
3
5
|
* Format a list of files using Prettier
|
|
4
6
|
*
|
|
5
7
|
* @param files - Array of file paths to format
|
|
6
|
-
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
7
8
|
*/
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const formatFiles: (files: readonly string[], options?: Readonly<{
|
|
9
10
|
silent?: boolean;
|
|
10
|
-
}>) => Promise<
|
|
11
|
+
}>) => Promise<Result<undefined, readonly unknown[]>>;
|
|
11
12
|
/**
|
|
12
13
|
* Format files matching the given glob pattern using Prettier
|
|
13
14
|
*
|
|
14
15
|
* @param pathGlob - Glob pattern to match files
|
|
15
|
-
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
16
16
|
*/
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const formatFilesGlob: (pathGlob: string, options?: Readonly<{
|
|
18
18
|
silent?: boolean;
|
|
19
|
-
}>) => Promise<
|
|
19
|
+
}>) => Promise<Result<undefined, unknown>>;
|
|
20
20
|
/**
|
|
21
21
|
* Format only files that have been changed (git status)
|
|
22
22
|
*
|
|
23
23
|
* @param options - Options for formatting
|
|
24
|
-
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
25
24
|
*/
|
|
26
|
-
export declare const
|
|
25
|
+
export declare const formatUncommittedFiles: (options?: Readonly<{
|
|
26
|
+
untracked?: boolean;
|
|
27
|
+
modified?: boolean;
|
|
28
|
+
staged?: boolean;
|
|
27
29
|
silent?: boolean;
|
|
28
|
-
}>) => Promise<
|
|
30
|
+
}>) => Promise<Result<undefined, ExecException | Readonly<{
|
|
31
|
+
message: string;
|
|
32
|
+
}> | readonly unknown[]>>;
|
|
29
33
|
/**
|
|
30
34
|
* Format only files that differ from the specified base branch or commit
|
|
31
35
|
*
|
|
@@ -34,12 +38,17 @@ export declare const formatUntracked: (options?: Readonly<{
|
|
|
34
38
|
* @param options - Options for formatting
|
|
35
39
|
* @param options.includeUntracked - Include untracked files in addition to diff
|
|
36
40
|
* files (default is true)
|
|
41
|
+
* @param options.includeStaged - Include staged files in addition to diff files
|
|
42
|
+
* (default is true)
|
|
37
43
|
* @param options.silent - Silent mode to suppress command output (default is
|
|
38
44
|
* false)
|
|
39
|
-
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
40
45
|
*/
|
|
41
46
|
export declare const formatDiffFrom: (base: string, options?: Readonly<{
|
|
42
47
|
includeUntracked?: boolean;
|
|
48
|
+
includeModified?: boolean;
|
|
49
|
+
includeStaged?: boolean;
|
|
43
50
|
silent?: boolean;
|
|
44
|
-
}>) => Promise<
|
|
51
|
+
}>) => Promise<Result<undefined, ExecException | Readonly<{
|
|
52
|
+
message: string;
|
|
53
|
+
}> | readonly unknown[]>>;
|
|
45
54
|
//# sourceMappingURL=format.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","sourceRoot":"","sources":["../../src/functions/format.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format.d.mts","sourceRoot":"","sources":["../../src/functions/format.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAuB,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,oBAAoB,CAAC;AAQ5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,SAAS,MAAM,EAAE,EACxB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAC,CA+F/C,CAAC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