ts-repo-utils 2.2.2 → 2.3.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/dist/functions/assert-path-exists.d.mts.map +1 -1
- package/dist/functions/assert-path-exists.mjs +1 -2
- package/dist/functions/assert-path-exists.mjs.map +1 -1
- package/dist/functions/assert-repo-is-dirty.d.mts +6 -2
- package/dist/functions/assert-repo-is-dirty.d.mts.map +1 -1
- package/dist/functions/assert-repo-is-dirty.mjs +15 -9
- package/dist/functions/assert-repo-is-dirty.mjs.map +1 -1
- package/dist/functions/diff.d.mts +4 -0
- package/dist/functions/diff.d.mts.map +1 -1
- package/dist/functions/diff.mjs +16 -14
- package/dist/functions/diff.mjs.map +1 -1
- package/dist/functions/exec-async.mjs +2 -2
- package/dist/functions/exec-async.mjs.map +1 -1
- package/dist/functions/format.d.mts +12 -3
- package/dist/functions/format.d.mts.map +1 -1
- package/dist/functions/format.mjs +64 -33
- package/dist/functions/format.mjs.map +1 -1
- package/dist/functions/gen-index.d.mts +4 -1
- package/dist/functions/gen-index.d.mts.map +1 -1
- package/dist/functions/gen-index.mjs +5 -2
- package/dist/functions/gen-index.mjs.map +1 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/functions/assert-path-exists.mts +0 -1
- package/src/functions/assert-repo-is-dirty.mts +20 -8
- package/src/functions/diff.mts +24 -16
- package/src/functions/diff.test.mts +45 -32
- package/src/functions/exec-async.mts +2 -2
- package/src/functions/format.mts +76 -35
- package/src/functions/format.test.mts +28 -15
- package/src/functions/gen-index.mts +8 -2
|
@@ -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":"AAAA,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,3 @@
|
|
|
1
|
-
import * as fs_ from 'node:fs/promises';
|
|
2
1
|
import '../node-global.mjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -8,7 +7,7 @@ import '../node-global.mjs';
|
|
|
8
7
|
*/
|
|
9
8
|
const pathExists = async (filePath) => {
|
|
10
9
|
try {
|
|
11
|
-
await
|
|
10
|
+
await fs.access(filePath);
|
|
12
11
|
return true;
|
|
13
12
|
}
|
|
14
13
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-path-exists.mjs","sources":["../../src/functions/assert-path-exists.mts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"assert-path-exists.mjs","sources":["../../src/functions/assert-path-exists.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;;;;AAIG;MACU,UAAU,GAAG,OAAO,QAAgB,KAAsB;AACrE,IAAA,IAAI;AACF,QAAA,MAAM,EAAE,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,CAAA,EAAG,WAAW,oBAAoB,QAAQ,CAAA,CAAE,CAAC;AAClD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEnB;;;;"}
|
|
@@ -4,10 +4,14 @@ import '../node-global.mjs';
|
|
|
4
4
|
* @returns True if the repo is dirty, false otherwise.
|
|
5
5
|
* @throws Error if git command fails.
|
|
6
6
|
*/
|
|
7
|
-
export declare const repoIsDirty: (
|
|
7
|
+
export declare const repoIsDirty: (options?: Readonly<{
|
|
8
|
+
silent?: boolean;
|
|
9
|
+
}>) => Promise<boolean>;
|
|
8
10
|
/**
|
|
9
11
|
* Checks if the repository is dirty and exits with code 1 if it is.
|
|
10
12
|
* Shows git status and diff output before exiting.
|
|
11
13
|
*/
|
|
12
|
-
export declare const
|
|
14
|
+
export declare const assertRepoIsClean: (options?: Readonly<{
|
|
15
|
+
silent?: boolean;
|
|
16
|
+
}>) => Promise<void>;
|
|
13
17
|
//# sourceMappingURL=assert-repo-is-dirty.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-repo-is-dirty.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-dirty.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"assert-repo-is-dirty.d.mts","sourceRoot":"","sources":["../../src/functions/assert-repo-is-dirty.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,OAAO,CAGjB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,CAiCd,CAAC"}
|
|
@@ -6,17 +6,17 @@ import '../node-global.mjs';
|
|
|
6
6
|
* @returns True if the repo is dirty, false otherwise.
|
|
7
7
|
* @throws Error if git command fails.
|
|
8
8
|
*/
|
|
9
|
-
const repoIsDirty = async () => {
|
|
10
|
-
const status = await getGitStatus();
|
|
9
|
+
const repoIsDirty = async (options) => {
|
|
10
|
+
const status = await getGitStatus({ silent: options?.silent ?? false });
|
|
11
11
|
return status.isDirty;
|
|
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
|
-
const
|
|
17
|
+
const assertRepoIsClean = async (options) => {
|
|
18
18
|
try {
|
|
19
|
-
const status = await getGitStatus();
|
|
19
|
+
const status = await getGitStatus({ silent: options?.silent ?? false });
|
|
20
20
|
if (!status.isDirty) {
|
|
21
21
|
echo('Repo is clean\n');
|
|
22
22
|
return;
|
|
@@ -25,11 +25,15 @@ const assertRepoIsDirty = async () => {
|
|
|
25
25
|
echo('Changed files:\n');
|
|
26
26
|
echo(status.stdout);
|
|
27
27
|
// Show files not tracked by git and unstaged changes
|
|
28
|
-
const addResult = await $('git add -N .'
|
|
28
|
+
const addResult = await $('git add -N .', {
|
|
29
|
+
silent: options?.silent ?? false,
|
|
30
|
+
});
|
|
29
31
|
if (Result.isErr(addResult)) {
|
|
30
32
|
echo('Warning: Failed to add untracked files for diff\n');
|
|
31
33
|
}
|
|
32
|
-
const diffResult = await $('git diff'
|
|
34
|
+
const diffResult = await $('git diff', {
|
|
35
|
+
silent: options?.silent ?? false,
|
|
36
|
+
});
|
|
33
37
|
if (Result.isErr(diffResult)) {
|
|
34
38
|
echo('Warning: Failed to show diff\n');
|
|
35
39
|
}
|
|
@@ -44,8 +48,10 @@ const assertRepoIsDirty = async () => {
|
|
|
44
48
|
* Gets the git status of the repository.
|
|
45
49
|
* @returns An object containing status information.
|
|
46
50
|
*/
|
|
47
|
-
const getGitStatus = async () => {
|
|
48
|
-
const res = await $('git status --porcelain'
|
|
51
|
+
const getGitStatus = async (options) => {
|
|
52
|
+
const res = await $('git status --porcelain', {
|
|
53
|
+
silent: options?.silent ?? false,
|
|
54
|
+
});
|
|
49
55
|
if (Result.isErr(res)) {
|
|
50
56
|
throw new Error(`Failed to get git status: ${res.value.message}`);
|
|
51
57
|
}
|
|
@@ -56,5 +62,5 @@ const getGitStatus = async () => {
|
|
|
56
62
|
};
|
|
57
63
|
};
|
|
58
64
|
|
|
59
|
-
export {
|
|
65
|
+
export { assertRepoIsClean, repoIsDirty };
|
|
60
66
|
//# sourceMappingURL=assert-repo-is-dirty.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert-repo-is-dirty.mjs","sources":["../../src/functions/assert-repo-is-dirty.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;AAIG;
|
|
1
|
+
{"version":3,"file":"assert-repo-is-dirty.mjs","sources":["../../src/functions/assert-repo-is-dirty.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;AAIG;MACU,WAAW,GAAG,OACzB,OAAwC,KACpB;AACpB,IAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC,OAAO;AACvB;AAEA;;;AAGG;MACU,iBAAiB,GAAG,OAC/B,OAAwC,KACvB;AACjB,IAAA,IAAI;AACF,QAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC;AAEvE,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,iBAAiB,CAAC;YACvB;;QAGF,IAAI,CAAC,iBAAiB,CAAC;QACvB,IAAI,CAAC,kBAAkB,CAAC;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;;AAGnB,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE;AACxC,YAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;AACjC,SAAA,CAAC;AACF,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;YAC3B,IAAI,CAAC,mDAAmD,CAAC;;AAG3D,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,UAAU,EAAE;AACrC,YAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;AACjC,SAAA,CAAC;AACF,QAAA,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;YAC5B,IAAI,CAAC,gCAAgC,CAAC;;AAGxC,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;IACf,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,qCAAqC,MAAM,CAAC,KAAK,CAAC,CAAA,EAAA,CAAI,CAAC;AAC5D,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEnB;AAEA;;;AAGG;AACH,MAAM,YAAY,GAAG,OACnB,OAAwC,KAIrC;AACH,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;QACrB,MAAM,IAAI,KAAK,CAAC,CAAA,0BAAA,EAA6B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAA,CAAE,CAAC;;AAGnE,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK;IAE5B,OAAO;AACL,QAAA,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;QAC7B,MAAM;KACP;AACH,CAAC;;;;"}
|
|
@@ -7,6 +7,8 @@ import '../node-global.mjs';
|
|
|
7
7
|
export declare const getUntrackedFiles: (options?: Readonly<{
|
|
8
8
|
/** @default true */
|
|
9
9
|
excludeDeleted?: boolean;
|
|
10
|
+
/** @default false */
|
|
11
|
+
silent?: boolean;
|
|
10
12
|
}>) => Promise<Result<readonly string[], ExecException | Readonly<{
|
|
11
13
|
message: string;
|
|
12
14
|
}>>>;
|
|
@@ -16,6 +18,8 @@ export declare const getUntrackedFiles: (options?: Readonly<{
|
|
|
16
18
|
export declare const getDiffFrom: (base: string, options?: Readonly<{
|
|
17
19
|
/** @default true */
|
|
18
20
|
excludeDeleted?: boolean;
|
|
21
|
+
/** @default false */
|
|
22
|
+
silent?: boolean;
|
|
19
23
|
}>) => Promise<Result<readonly string[], ExecException | Readonly<{
|
|
20
24
|
message: string;
|
|
21
25
|
}>>>;
|
|
@@ -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;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IACjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;
|
|
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;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IACjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,KACD,OAAO,CACR,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,aAAa,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CA2BzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,UAAU,QAAQ,CAAC;IACjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC,KACD,OAAO,CACR,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,aAAa,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CA2BzE,CAAC"}
|
package/dist/functions/diff.mjs
CHANGED
|
@@ -6,7 +6,13 @@ import '../node-global.mjs';
|
|
|
6
6
|
*/
|
|
7
7
|
const getUntrackedFiles = async (options) => {
|
|
8
8
|
// Get changed files from git status
|
|
9
|
-
const result = await $(
|
|
9
|
+
const result = await $([
|
|
10
|
+
`git ls-files --others --exclude-standard`,
|
|
11
|
+
// Append '--deleted' to include deleted files only if excludeDeleted is explicitly false
|
|
12
|
+
(options?.excludeDeleted ?? true) ? '' : '--deleted',
|
|
13
|
+
]
|
|
14
|
+
.filter((s) => s !== '')
|
|
15
|
+
.join(' '), { silent: options?.silent ?? false });
|
|
10
16
|
if (Result.isErr(result)) {
|
|
11
17
|
return result;
|
|
12
18
|
}
|
|
@@ -14,18 +20,8 @@ const getUntrackedFiles = async (options) => {
|
|
|
14
20
|
// Parse git status output
|
|
15
21
|
const files = stdout
|
|
16
22
|
.split('\n')
|
|
17
|
-
.
|
|
18
|
-
.
|
|
19
|
-
// Status format: "XY filename" where X and Y are status codes
|
|
20
|
-
const match = /^..\s+(.+)$/u.exec(line);
|
|
21
|
-
return match?.[1];
|
|
22
|
-
})
|
|
23
|
-
.filter((file) =>
|
|
24
|
-
// Filter out deleted files (status starts with 'D')
|
|
25
|
-
file !== undefined &&
|
|
26
|
-
((options?.excludeDeleted ?? true)
|
|
27
|
-
? !stdout.includes(`D ${file}`)
|
|
28
|
-
: true));
|
|
23
|
+
.map((s) => s.trim())
|
|
24
|
+
.filter((s) => s !== '');
|
|
29
25
|
return Result.ok(files);
|
|
30
26
|
};
|
|
31
27
|
/**
|
|
@@ -33,7 +29,13 @@ const getUntrackedFiles = async (options) => {
|
|
|
33
29
|
*/
|
|
34
30
|
const getDiffFrom = async (base, options) => {
|
|
35
31
|
// Get files that differ from base branch/commit (excluding deleted files)
|
|
36
|
-
const result = await $(
|
|
32
|
+
const result = await $([
|
|
33
|
+
`git diff --name-only`,
|
|
34
|
+
base,
|
|
35
|
+
(options?.excludeDeleted ?? true) ? '--diff-filter=d' : '',
|
|
36
|
+
]
|
|
37
|
+
.filter((s) => s !== '')
|
|
38
|
+
.join(' '), { silent: options?.silent ?? false });
|
|
37
39
|
if (Result.isErr(result)) {
|
|
38
40
|
return result;
|
|
39
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;AAEG;MACU,iBAAiB,GAAG,OAC/B,
|
|
1
|
+
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAIA;;AAEG;MACU,iBAAiB,GAAG,OAC/B,OAKE,KAGA;;AAEF,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,CACpB;QACE,CAAA,wCAAA,CAA0C;;AAE1C,QAAA,CAAC,OAAO,EAAE,cAAc,IAAI,IAAI,IAAI,EAAE,GAAG,WAAW;AACrD;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;;AAGf,IAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK;;IAG/B,MAAM,KAAK,GAAG;SACX,KAAK,CAAC,IAAI;SACV,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;SACnB,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;AAE1B,IAAA,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;AACzB;AAEA;;AAEG;AACI,MAAM,WAAW,GAAG,OACzB,IAAY,EACZ,OAKE,KAGA;;AAEF,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,CACpB;QACE,CAAA,oBAAA,CAAsB;QACtB,IAAI;AACJ,QAAA,CAAC,OAAO,EAAE,cAAc,IAAI,IAAI,IAAI,iBAAiB,GAAG,EAAE;AAC3D;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;;AAGf,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;;;;"}
|
|
@@ -10,14 +10,14 @@ import { Result } from 'ts-data-forge';
|
|
|
10
10
|
const $ = (cmd, options = {}) => {
|
|
11
11
|
const { silent = false, timeout = 30000 } = options;
|
|
12
12
|
if (!silent) {
|
|
13
|
-
|
|
13
|
+
echo(`$ ${cmd}`);
|
|
14
14
|
}
|
|
15
15
|
return new Promise((resolve) => {
|
|
16
16
|
const execOptions = { timeout };
|
|
17
17
|
exec(cmd, execOptions, (error, stdout, stderr) => {
|
|
18
18
|
if (!silent) {
|
|
19
19
|
if (stdout !== '') {
|
|
20
|
-
|
|
20
|
+
echo(stdout);
|
|
21
21
|
}
|
|
22
22
|
if (stderr !== '') {
|
|
23
23
|
console.error(stderr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-async.mjs","sources":["../../src/functions/exec-async.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;AAKG;AACI,MAAM,CAAC,GAAG,CACf,GAAW,EACX,OAAA,GAA4D,EAAE,KAG5D;IACF,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO;IAEnD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,
|
|
1
|
+
{"version":3,"file":"exec-async.mjs","sources":["../../src/functions/exec-async.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;AAKG;AACI,MAAM,CAAC,GAAG,CACf,GAAW,EACX,OAAA,GAA4D,EAAE,KAG5D;IACF,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO;IAEnD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,IAAI,CAAC,CAAA,EAAA,EAAK,GAAG,CAAA,CAAE,CAAC;;AAGlB,IAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;AAC7B,QAAA,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE;AAE/B,QAAA,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,KAAI;YAC/C,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,IAAI,MAAM,KAAK,EAAE,EAAE;oBACjB,IAAI,CAAC,MAAM,CAAC;;AAEd,gBAAA,IAAI,MAAM,KAAK,EAAE,EAAE;AACjB,oBAAA,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;;;AAIzB,YAAA,IAAI,KAAK,KAAK,IAAI,EAAE;gBAClB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;;iBACrB;AACL,gBAAA,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;;AAE1C,SAAC,CAAC;AACJ,KAAC,CAAC;AACJ;;;;"}
|
|
@@ -4,26 +4,35 @@ import '../node-global.mjs';
|
|
|
4
4
|
* @param files - Array of file paths to format
|
|
5
5
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
6
6
|
*/
|
|
7
|
-
export declare const formatFilesList: (files: readonly string[]
|
|
7
|
+
export declare const formatFilesList: (files: readonly string[], options?: Readonly<{
|
|
8
|
+
silent?: boolean;
|
|
9
|
+
}>) => Promise<"ok" | "err">;
|
|
8
10
|
/**
|
|
9
11
|
* Format files matching the given glob pattern using Prettier
|
|
10
12
|
* @param pathGlob - Glob pattern to match files
|
|
11
13
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
12
14
|
*/
|
|
13
|
-
export declare const formatFiles: (pathGlob: string
|
|
15
|
+
export declare const formatFiles: (pathGlob: string, options?: Readonly<{
|
|
16
|
+
silent?: boolean;
|
|
17
|
+
}>) => Promise<"ok" | "err">;
|
|
14
18
|
/**
|
|
15
19
|
* Format only files that have been changed (git status)
|
|
20
|
+
* @param options - Options for formatting
|
|
16
21
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
17
22
|
*/
|
|
18
|
-
export declare const formatUntracked: (
|
|
23
|
+
export declare const formatUntracked: (options?: Readonly<{
|
|
24
|
+
silent?: boolean;
|
|
25
|
+
}>) => Promise<"ok" | "err">;
|
|
19
26
|
/**
|
|
20
27
|
* Format only files that differ from the specified base branch or commit
|
|
21
28
|
* @param base - Base branch name or commit hash to compare against (defaults to 'main')
|
|
22
29
|
* @param options - Options for formatting
|
|
23
30
|
* @param options.includeUntracked - Include untracked files in addition to diff files (default is true)
|
|
31
|
+
* @param options.silent - Silent mode to suppress command output (default is false)
|
|
24
32
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
25
33
|
*/
|
|
26
34
|
export declare const formatDiffFrom: (base: string, options?: Readonly<{
|
|
27
35
|
includeUntracked?: boolean;
|
|
36
|
+
silent?: boolean;
|
|
28
37
|
}>) => Promise<"ok" | "err">;
|
|
29
38
|
//# 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":"AAEA,OAAO,oBAAoB,CAAC;AAG5B;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,SAAS,MAAM,EAAE,EACxB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,GAAG,KAAK,CA2DtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,EAChB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,GAAG,KAAK,CAuBtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,GAAG,KAAK,CAqDtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,UAAU,QAAQ,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACnE,OAAO,CAAC,IAAI,GAAG,KAAK,CA4DtB,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import glob_ from 'fast-glob';
|
|
2
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
1
|
import * as prettier from 'prettier';
|
|
4
|
-
import { Result } from 'ts-data-forge';
|
|
2
|
+
import { Result, Arr } from 'ts-data-forge';
|
|
5
3
|
import '../node-global.mjs';
|
|
6
4
|
import { getUntrackedFiles, getDiffFrom } from './diff.mjs';
|
|
7
5
|
|
|
@@ -10,36 +8,45 @@ import { getUntrackedFiles, getDiffFrom } from './diff.mjs';
|
|
|
10
8
|
* @param files - Array of file paths to format
|
|
11
9
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
12
10
|
*/
|
|
13
|
-
const formatFilesList = async (files) => {
|
|
11
|
+
const formatFilesList = async (files, options) => {
|
|
12
|
+
const silent = options?.silent ?? false;
|
|
14
13
|
if (files.length === 0) {
|
|
15
|
-
|
|
14
|
+
if (!silent) {
|
|
15
|
+
echo('No files to format');
|
|
16
|
+
}
|
|
16
17
|
return 'ok';
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
if (!silent) {
|
|
20
|
+
echo(`Formatting ${files.length} files...`);
|
|
21
|
+
}
|
|
19
22
|
// Format each file
|
|
20
23
|
const results = await Promise.allSettled(files.map(async (filePath) => {
|
|
21
24
|
try {
|
|
22
25
|
// Read file content
|
|
23
|
-
const content = await readFile(filePath, 'utf8');
|
|
26
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
24
27
|
// Resolve prettier config for this file
|
|
25
|
-
const
|
|
28
|
+
const prettierOptions = await prettier.resolveConfig(filePath);
|
|
26
29
|
// Check if file is ignored by prettier
|
|
27
30
|
const fileInfo = await prettier.getFileInfo(filePath, {
|
|
28
31
|
ignorePath: '.prettierignore',
|
|
29
32
|
});
|
|
30
33
|
if (fileInfo.ignored) {
|
|
31
|
-
|
|
34
|
+
if (!silent) {
|
|
35
|
+
echo(`Skipping ignored file: ${filePath}`);
|
|
36
|
+
}
|
|
32
37
|
return;
|
|
33
38
|
}
|
|
34
39
|
// Format the content
|
|
35
40
|
const formatted = await prettier.format(content, {
|
|
36
|
-
...
|
|
41
|
+
...prettierOptions,
|
|
37
42
|
filepath: filePath,
|
|
38
43
|
});
|
|
39
44
|
// Only write if content changed
|
|
40
45
|
if (formatted !== content) {
|
|
41
|
-
await writeFile(filePath, formatted, 'utf8');
|
|
42
|
-
|
|
46
|
+
await fs.writeFile(filePath, formatted, 'utf8');
|
|
47
|
+
if (!silent) {
|
|
48
|
+
echo(`Formatted: ${filePath}`);
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
catch (error) {
|
|
@@ -56,19 +63,22 @@ const formatFilesList = async (files) => {
|
|
|
56
63
|
* @param pathGlob - Glob pattern to match files
|
|
57
64
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
58
65
|
*/
|
|
59
|
-
const formatFiles = async (pathGlob) => {
|
|
66
|
+
const formatFiles = async (pathGlob, options) => {
|
|
67
|
+
const silent = options?.silent ?? false;
|
|
60
68
|
try {
|
|
61
69
|
// Find all files matching the glob
|
|
62
|
-
const files = await
|
|
70
|
+
const files = await glob(pathGlob, {
|
|
63
71
|
absolute: true,
|
|
64
72
|
ignore: ['**/node_modules/**', '**/.git/**'],
|
|
65
73
|
dot: true,
|
|
66
74
|
});
|
|
67
75
|
if (files.length === 0) {
|
|
68
|
-
|
|
76
|
+
if (!silent) {
|
|
77
|
+
echo('No files found matching pattern:', pathGlob);
|
|
78
|
+
}
|
|
69
79
|
return 'ok';
|
|
70
80
|
}
|
|
71
|
-
return await formatFilesList(files);
|
|
81
|
+
return await formatFilesList(files, { silent });
|
|
72
82
|
}
|
|
73
83
|
catch (error) {
|
|
74
84
|
console.error('Error in formatFiles:', error);
|
|
@@ -77,36 +87,46 @@ const formatFiles = async (pathGlob) => {
|
|
|
77
87
|
};
|
|
78
88
|
/**
|
|
79
89
|
* Format only files that have been changed (git status)
|
|
90
|
+
* @param options - Options for formatting
|
|
80
91
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
81
92
|
*/
|
|
82
|
-
const formatUntracked = async () => {
|
|
93
|
+
const formatUntracked = async (options) => {
|
|
94
|
+
const silent = options?.silent ?? false;
|
|
83
95
|
try {
|
|
84
|
-
const untrackedFilesResult = await getUntrackedFiles(
|
|
96
|
+
const untrackedFilesResult = await getUntrackedFiles({
|
|
97
|
+
silent,
|
|
98
|
+
});
|
|
85
99
|
if (Result.isErr(untrackedFilesResult)) {
|
|
86
100
|
console.error('Error getting changed files:', untrackedFilesResult.value);
|
|
87
101
|
return 'err';
|
|
88
102
|
}
|
|
89
103
|
const files = untrackedFilesResult.value;
|
|
90
104
|
if (files.length === 0) {
|
|
91
|
-
|
|
105
|
+
if (!silent) {
|
|
106
|
+
echo('No changed files to format');
|
|
107
|
+
}
|
|
92
108
|
return 'ok';
|
|
93
109
|
}
|
|
94
|
-
|
|
110
|
+
if (!silent) {
|
|
111
|
+
echo('Formatting changed files:', files);
|
|
112
|
+
}
|
|
95
113
|
// Filter out non-existent files before formatting
|
|
96
114
|
const fileExistenceChecks = await Promise.allSettled(files.map(async (filePath) => {
|
|
97
115
|
try {
|
|
98
|
-
await readFile(filePath, 'utf8');
|
|
116
|
+
await fs.readFile(filePath, 'utf8');
|
|
99
117
|
return filePath;
|
|
100
118
|
}
|
|
101
119
|
catch {
|
|
102
|
-
|
|
120
|
+
if (!silent) {
|
|
121
|
+
echo(`Skipping non-existent file: ${filePath}`);
|
|
122
|
+
}
|
|
103
123
|
return undefined;
|
|
104
124
|
}
|
|
105
125
|
}));
|
|
106
126
|
const existingFiles = fileExistenceChecks
|
|
107
127
|
.filter((result) => result.status === 'fulfilled' && result.value !== undefined)
|
|
108
128
|
.map((result) => result.value);
|
|
109
|
-
return await formatFilesList(existingFiles);
|
|
129
|
+
return await formatFilesList(existingFiles, { silent });
|
|
110
130
|
}
|
|
111
131
|
catch (error) {
|
|
112
132
|
console.error('Error in formatUntracked:', error);
|
|
@@ -118,39 +138,50 @@ const formatUntracked = async () => {
|
|
|
118
138
|
* @param base - Base branch name or commit hash to compare against (defaults to 'main')
|
|
119
139
|
* @param options - Options for formatting
|
|
120
140
|
* @param options.includeUntracked - Include untracked files in addition to diff files (default is true)
|
|
141
|
+
* @param options.silent - Silent mode to suppress command output (default is false)
|
|
121
142
|
* @returns 'ok' if successful, 'err' if any errors occurred
|
|
122
143
|
*/
|
|
123
144
|
const formatDiffFrom = async (base, options) => {
|
|
145
|
+
const silent = options?.silent ?? false;
|
|
124
146
|
try {
|
|
125
147
|
// Get files that differ from base branch/commit (excluding deleted files)
|
|
126
|
-
const diffFromBaseResult = await getDiffFrom(base
|
|
148
|
+
const diffFromBaseResult = await getDiffFrom(base, {
|
|
149
|
+
silent,
|
|
150
|
+
});
|
|
127
151
|
if (Result.isErr(diffFromBaseResult)) {
|
|
128
152
|
console.error('Error getting changed files:', diffFromBaseResult.value);
|
|
129
153
|
return 'err';
|
|
130
154
|
}
|
|
131
155
|
const diffFiles = diffFromBaseResult.value;
|
|
132
|
-
let
|
|
156
|
+
let mut_allFiles = diffFiles;
|
|
133
157
|
// If includeUntracked is true, also get untracked files
|
|
134
158
|
if (options?.includeUntracked ?? true) {
|
|
135
|
-
const untrackedFilesResult = await getUntrackedFiles(
|
|
159
|
+
const untrackedFilesResult = await getUntrackedFiles({
|
|
160
|
+
silent,
|
|
161
|
+
});
|
|
136
162
|
if (Result.isErr(untrackedFilesResult)) {
|
|
137
163
|
console.error('Error getting untracked files:', untrackedFilesResult.value);
|
|
138
164
|
return 'err';
|
|
139
165
|
}
|
|
140
166
|
const untrackedFiles = untrackedFilesResult.value;
|
|
141
167
|
// Combine and deduplicate files
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
mut_allFiles = Arr.uniq([...diffFiles, ...untrackedFiles]);
|
|
169
|
+
if (!silent) {
|
|
170
|
+
echo(`Formatting files that differ from ${base} and untracked files:`, mut_allFiles);
|
|
171
|
+
}
|
|
145
172
|
}
|
|
146
173
|
else {
|
|
147
|
-
|
|
174
|
+
if (!silent) {
|
|
175
|
+
echo(`Formatting files that differ from ${base}:`, mut_allFiles);
|
|
176
|
+
}
|
|
148
177
|
}
|
|
149
|
-
if (
|
|
150
|
-
|
|
178
|
+
if (mut_allFiles.length === 0) {
|
|
179
|
+
if (!silent) {
|
|
180
|
+
echo(`No files to format`);
|
|
181
|
+
}
|
|
151
182
|
return 'ok';
|
|
152
183
|
}
|
|
153
|
-
return await formatFilesList(
|
|
184
|
+
return await formatFilesList(mut_allFiles, { silent });
|
|
154
185
|
}
|
|
155
186
|
catch (error) {
|
|
156
187
|
console.error('Error in formatDiffFrom:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAKA;;;;AAIG;AACI,MAAM,eAAe,GAAG,OAC7B,KAAwB,EACxB,OAAwC,KACf;AACzB,IAAA,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK;AAEvC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,IAAI,CAAC,MAAM,EAAE;YACX,IAAI,CAAC,oBAAoB,CAAC;;AAE5B,QAAA,OAAO,IAAI;;IAGb,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,IAAI,CAAC,CAAA,WAAA,EAAc,KAAK,CAAC,MAAM,CAAA,SAAA,CAAW,CAAC;;;AAI7C,IAAA,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CACtC,KAAK,CAAC,GAAG,CAAC,OAAO,QAAQ,KAAI;AAC3B,QAAA,IAAI;;YAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;;YAG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AM,oBAAoB,GAAG,MAAM,iBAAiB,CAAC;gBACnD,MAAM;AACP,aAAA,CAAC;AAEF,YAAA,IAAI,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE;gBACtC,OAAO,CAAC,KAAK,CACX,gCAAgC,EAChC,oBAAoB,CAAC,KAAK,CAC3B;AACD,gBAAA,OAAO,KAAK;;AAGd,YAAA,MAAM,cAAc,GAAG,oBAAoB,CAAC,KAAK;;AAGjD,YAAA,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,cAAc,CAAC,CAAC;YAE1D,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,IAAI,CACF,CAAA,kCAAA,EAAqC,IAAI,uBAAuB,EAChE,YAAY,CACb;;;aAEE;YACL,IAAI,CAAC,MAAM,EAAE;AACX,gBAAA,IAAI,CAAC,CAAA,kCAAA,EAAqC,IAAI,GAAG,EAAE,YAAY,CAAC;;;AAIpE,QAAA,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7B,IAAI,CAAC,MAAM,EAAE;gBACX,IAAI,CAAC,CAAA,kBAAA,CAAoB,CAAC;;AAE5B,YAAA,OAAO,IAAI;;QAGb,OAAO,MAAM,eAAe,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC;;IACtD,OAAO,KAAK,EAAE;AACd,QAAA,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC;AAChD,QAAA,OAAO,KAAK;;AAEhB;;;;"}
|
|
@@ -15,7 +15,10 @@ export type GenIndexConfig = DeepReadonly<{
|
|
|
15
15
|
/**
|
|
16
16
|
* Generates index.mts files recursively in `config.targetDirectory`.
|
|
17
17
|
* @param config - Configuration for index file generation
|
|
18
|
+
* @param options - Additional options
|
|
18
19
|
* @throws Error if any step fails.
|
|
19
20
|
*/
|
|
20
|
-
export declare const genIndex: (config: GenIndexConfig
|
|
21
|
+
export declare const genIndex: (config: GenIndexConfig, options?: Readonly<{
|
|
22
|
+
silent?: boolean;
|
|
23
|
+
}>) => Promise<void>;
|
|
21
24
|
//# sourceMappingURL=gen-index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AAEA,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
|
|
1
|
+
{"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AAEA,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;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,QAAQ,cAAc,EACtB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,IAAI,CA4Cd,CAAC"}
|
|
@@ -6,9 +6,10 @@ import { assertPathExists } from './assert-path-exists.mjs';
|
|
|
6
6
|
/**
|
|
7
7
|
* Generates index.mts files recursively in `config.targetDirectory`.
|
|
8
8
|
* @param config - Configuration for index file generation
|
|
9
|
+
* @param options - Additional options
|
|
9
10
|
* @throws Error if any step fails.
|
|
10
11
|
*/
|
|
11
|
-
const genIndex = async (config) => {
|
|
12
|
+
const genIndex = async (config, options) => {
|
|
12
13
|
echo('Starting index file generation...\n');
|
|
13
14
|
// Merge config with defaults
|
|
14
15
|
const filledConfig = fillConfig(config);
|
|
@@ -33,7 +34,9 @@ const genIndex = async (config) => {
|
|
|
33
34
|
echo('✓ Index files generated\n');
|
|
34
35
|
// Step 3: Format generated files
|
|
35
36
|
echo('3. Formatting generated files...');
|
|
36
|
-
const fmtResult = await $('npm run fmt'
|
|
37
|
+
const fmtResult = await $('npm run fmt', {
|
|
38
|
+
silent: options?.silent ?? false,
|
|
39
|
+
});
|
|
37
40
|
if (Result.isErr(fmtResult)) {
|
|
38
41
|
throw new Error(`Formatting failed: ${fmtResult.value.message}`);
|
|
39
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAsBA
|
|
1
|
+
{"version":3,"file":"gen-index.mjs","sources":["../../src/functions/gen-index.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAsBA;;;;;AAKG;AACI,MAAM,QAAQ,GAAG,OACtB,MAAsB,EACtB,OAAwC,KACvB;IACjB,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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,YAAA,OAAO,oBAAoB,kBAAkB,CAAA,EAAG,MAAM,CAAC,eAAe,IAAI;AAC5E,SAAC,CAAC;KACH;AAED,IAAA,OAAO,gBAAgB,CAAC,MAAM,KAAK;AACjC,UAAE;AACF,UAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC;;;;"}
|
package/dist/functions/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { assertExt } from './assert-ext.mjs';
|
|
2
2
|
export { assertPathExists, pathExists } from './assert-path-exists.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export { assertRepoIsClean, repoIsDirty } from './assert-repo-is-dirty.mjs';
|
|
4
4
|
export { getDiffFrom, getUntrackedFiles } from './diff.mjs';
|
|
5
5
|
export { $ } from './exec-async.mjs';
|
|
6
6
|
export { formatDiffFrom, formatFiles, formatFilesList, formatUntracked } from './format.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { assertExt } from './functions/assert-ext.mjs';
|
|
2
2
|
export { assertPathExists, pathExists } from './functions/assert-path-exists.mjs';
|
|
3
|
-
export {
|
|
3
|
+
export { assertRepoIsClean, repoIsDirty } from './functions/assert-repo-is-dirty.mjs';
|
|
4
4
|
export { getDiffFrom, getUntrackedFiles } from './functions/diff.mjs';
|
|
5
5
|
export { $ } from './functions/exec-async.mjs';
|
|
6
6
|
export { formatDiffFrom, formatFiles, formatFilesList, formatUntracked } from './functions/format.mjs';
|
package/package.json
CHANGED