ts-repo-utils 8.2.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/entry-point.mjs +1 -1
- package/dist/functions/diff.d.mts +8 -0
- package/dist/functions/diff.d.mts.map +1 -1
- package/dist/functions/diff.mjs +23 -3
- package/dist/functions/diff.mjs.map +1 -1
- package/dist/functions/format.d.mts.map +1 -1
- package/dist/functions/format.mjs +19 -8
- package/dist/functions/format.mjs.map +1 -1
- package/dist/functions/index.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +14 -14
- 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/diff.mts +30 -2
- package/src/functions/diff.test.mts +14 -14
- package/src/functions/format.mts +35 -7
- package/src/functions/format.test.mts +11 -0
package/dist/entry-point.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export { assertExt, checkExt } from './functions/assert-ext.mjs';
|
|
|
3
3
|
export { assertPathExists, pathExists } from './functions/assert-path-exists.mjs';
|
|
4
4
|
export { assertRepoIsClean, repoIsDirty } from './functions/assert-repo-is-clean.mjs';
|
|
5
5
|
export { createResultAssert } from './functions/create-result-assert.mjs';
|
|
6
|
-
export { getDiffFrom, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './functions/diff.mjs';
|
|
6
|
+
export { getDiffFrom, getGitRoot, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './functions/diff.mjs';
|
|
7
7
|
export { $ } from './functions/exec-async.mjs';
|
|
8
8
|
export { formatDiffFrom, formatFiles, formatFilesGlob, formatUncommittedFiles } from './functions/format.mjs';
|
|
9
9
|
export { genIndex } from './functions/gen-index.mjs';
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { type ExecException } from 'node:child_process';
|
|
2
2
|
import '../node-global.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Get the git repository root directory
|
|
5
|
+
*/
|
|
6
|
+
export declare const getGitRoot: (options?: Readonly<{
|
|
7
|
+
silent?: boolean;
|
|
8
|
+
}>) => Promise<Result<string, ExecException | Readonly<{
|
|
9
|
+
message: string;
|
|
10
|
+
}>>>;
|
|
3
11
|
/**
|
|
4
12
|
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
5
13
|
* ls-files --others --exclude-standard [--deleted]`
|
|
@@ -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;AAExD,OAAO,oBAAoB,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;AAExD,OAAO,oBAAoB,CAAC;AAG5B;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,CAAC;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,KACvC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAUvE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,QAAQ,CAAC;IACjB,oBAAoB;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB;IACrB,MAAM,CAAC,EAAE,OAAO,C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|
|
3
|
+
import { $ } from './exec-async.mjs';
|
|
3
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Get the git repository root directory
|
|
7
|
+
*/
|
|
8
|
+
const getGitRoot = async (options) => {
|
|
9
|
+
const result = await $('git rev-parse --show-toplevel', {
|
|
10
|
+
silent: options?.silent ?? false,
|
|
11
|
+
});
|
|
12
|
+
if (Result.isErr(result)) {
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
return Result.ok(result.value.stdout.trim());
|
|
16
|
+
};
|
|
4
17
|
/**
|
|
5
18
|
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
6
19
|
* ls-files --others --exclude-standard [--deleted]`
|
|
@@ -42,6 +55,12 @@ const getDiffFrom = async (base, options) => cmdResultToFiles({
|
|
|
42
55
|
options,
|
|
43
56
|
});
|
|
44
57
|
const cmdResultToFiles = async ({ cmd, cmdOptionToExcludeDeleted, cmdOptionToIncludeDeleted, options, }) => {
|
|
58
|
+
// Get git root directory
|
|
59
|
+
const gitRootResult = await getGitRoot({ silent: options?.silent ?? false });
|
|
60
|
+
if (Result.isErr(gitRootResult)) {
|
|
61
|
+
return gitRootResult;
|
|
62
|
+
}
|
|
63
|
+
const gitRoot = gitRootResult.value;
|
|
45
64
|
const result = await $([
|
|
46
65
|
cmd,
|
|
47
66
|
(options?.excludeDeleted ?? true)
|
|
@@ -54,13 +73,14 @@ const cmdResultToFiles = async ({ cmd, cmdOptionToExcludeDeleted, cmdOptionToInc
|
|
|
54
73
|
return result;
|
|
55
74
|
}
|
|
56
75
|
const { stdout } = result.value;
|
|
57
|
-
// Parse git output
|
|
76
|
+
// Parse git output and convert to absolute paths
|
|
58
77
|
const files = stdout
|
|
59
78
|
.split('\n')
|
|
60
79
|
.map((line) => line.trim())
|
|
61
|
-
.filter((line) => line !== '')
|
|
80
|
+
.filter((line) => line !== '')
|
|
81
|
+
.map((relativePath) => path.join(gitRoot, relativePath));
|
|
62
82
|
return Result.ok(files);
|
|
63
83
|
};
|
|
64
84
|
|
|
65
|
-
export { getDiffFrom, getModifiedFiles, getStagedFiles, getUntrackedFiles };
|
|
85
|
+
export { getDiffFrom, getGitRoot, getModifiedFiles, getStagedFiles, getUntrackedFiles };
|
|
66
86
|
//# sourceMappingURL=diff.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"diff.mjs","sources":["../../src/functions/diff.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;AAEG;MACU,UAAU,GAAG,OACxB,OAAwC,KACkC;AAC1E,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,+BAA+B,EAAE;AACtD,QAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,KAAK;AACjC,KAAA,CAAC;AAEF,IAAA,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACxB,QAAA,OAAO,MAAM;IACf;AAEA,IAAA,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAC9C;AAEA;;;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;IAC3B,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,G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AI,CAAC,IAAI,EAAE;SACzB,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE;AAC5B,SAAA,GAAG,CAAC,CAAC,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AAE1D,IAAA,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC;AACzB,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","sourceRoot":"","sources":["../../src/functions/format.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"format.d.mts","sourceRoot":"","sources":["../../src/functions/format.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,oBAAoB,CAAC;AAU5B;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,OAAO,SAAS,MAAM,EAAE,EACxB,UAAU,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IACjD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC,KACD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,CAAC,CAsI/C,CAAC;AA+DF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,UAAU,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAClD,CAAC,KACD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAmCpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,UAAU,QAAQ,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAClD,CAAC,KACD,OAAO,CACR,MAAM,CACJ,SAAS,EACT,aAAa,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,SAAS,OAAO,EAAE,CACnE,CA+DF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EACZ,UAAU,QAAQ,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAClD,CAAC,KACD,OAAO,CACR,MAAM,CACJ,SAAS,EACP,aAAa,GACb,QAAQ,CAAC;IACP,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,GACF,SAAS,OAAO,EAAE,CACrB,CAwFF,CAAC"}
|
|
@@ -2,7 +2,7 @@ import * as prettier from 'prettier';
|
|
|
2
2
|
import { Result, Arr, isNotUndefined, pipe } from 'ts-data-forge';
|
|
3
3
|
import '../node-global.mjs';
|
|
4
4
|
import { pathExists } from './assert-path-exists.mjs';
|
|
5
|
-
import { getDiffFrom, getUntrackedFiles, getModifiedFiles, getStagedFiles } from './diff.mjs';
|
|
5
|
+
import { getDiffFrom, getUntrackedFiles, getModifiedFiles, getStagedFiles, getGitRoot } from './diff.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Format a list of files using Prettier
|
|
@@ -18,6 +18,17 @@ const formatFiles = async (files, options) => {
|
|
|
18
18
|
return Result.ok(undefined);
|
|
19
19
|
}
|
|
20
20
|
conditionalEcho(`Formatting ${files.length} files...`);
|
|
21
|
+
// Get git root for display purposes
|
|
22
|
+
const gitRootResult = await getGitRoot({ silent: true });
|
|
23
|
+
const gitRoot = Result.isOk(gitRootResult) ? gitRootResult.value : undefined;
|
|
24
|
+
// Helper function to get display path (relative to git root if available)
|
|
25
|
+
const getDisplayPath = (filePath) => {
|
|
26
|
+
if (gitRoot === undefined) {
|
|
27
|
+
return filePath;
|
|
28
|
+
}
|
|
29
|
+
const relativePath = path.relative(gitRoot, filePath);
|
|
30
|
+
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
31
|
+
};
|
|
21
32
|
// Format each file
|
|
22
33
|
const results =
|
|
23
34
|
// NOTE: Using Promise.allSettled to ensure all files are processed even if some fail
|
|
@@ -25,11 +36,11 @@ const formatFiles = async (files, options) => {
|
|
|
25
36
|
try {
|
|
26
37
|
// Check if file exists first
|
|
27
38
|
if (!(await pathExists(filePath))) {
|
|
28
|
-
conditionalEcho(`Skipping non-existent file: ${filePath}`);
|
|
39
|
+
conditionalEcho(`Skipping non-existent file: ${getDisplayPath(filePath)}`);
|
|
29
40
|
return Result.ok(undefined);
|
|
30
41
|
}
|
|
31
42
|
if (!noIgnore && (options?.ignore ?? defaultIgnoreFn)(filePath)) {
|
|
32
|
-
conditionalEcho(`Skipping ignored file: ${filePath}`);
|
|
43
|
+
conditionalEcho(`Skipping ignored file: ${getDisplayPath(filePath)}`);
|
|
33
44
|
return Result.ok(undefined);
|
|
34
45
|
}
|
|
35
46
|
// Check if file is ignored by prettier
|
|
@@ -37,14 +48,14 @@ const formatFiles = async (files, options) => {
|
|
|
37
48
|
ignorePath: '.prettierignore',
|
|
38
49
|
});
|
|
39
50
|
if (!noIgnore && fileInfo.ignored) {
|
|
40
|
-
conditionalEcho(`Skipping ignored file: ${filePath}`);
|
|
51
|
+
conditionalEcho(`Skipping ignored file: ${getDisplayPath(filePath)}`);
|
|
41
52
|
return Result.ok(undefined);
|
|
42
53
|
}
|
|
43
54
|
if (!noIgnore &&
|
|
44
55
|
(options?.ignoreUnknown ?? true) &&
|
|
45
56
|
fileInfo.inferredParser === null) {
|
|
46
57
|
// Silently skip files with no parser
|
|
47
|
-
conditionalEcho(`Skipping file (no parser): ${filePath}`);
|
|
58
|
+
conditionalEcho(`Skipping file (no parser): ${getDisplayPath(filePath)}`);
|
|
48
59
|
return Result.ok(undefined);
|
|
49
60
|
}
|
|
50
61
|
// Read file content
|
|
@@ -58,17 +69,17 @@ const formatFiles = async (files, options) => {
|
|
|
58
69
|
});
|
|
59
70
|
// Only write if content changed
|
|
60
71
|
if (formatted === content) {
|
|
61
|
-
conditionalEcho(`Unchanged: ${filePath}`);
|
|
72
|
+
conditionalEcho(`Unchanged: ${getDisplayPath(filePath)}`);
|
|
62
73
|
}
|
|
63
74
|
else {
|
|
64
75
|
await fs.writeFile(filePath, formatted, 'utf8');
|
|
65
|
-
conditionalEcho(`Formatted: ${filePath}`);
|
|
76
|
+
conditionalEcho(`Formatted: ${getDisplayPath(filePath)}`);
|
|
66
77
|
}
|
|
67
78
|
return Result.ok(undefined);
|
|
68
79
|
}
|
|
69
80
|
catch (error) {
|
|
70
81
|
if (!silent) {
|
|
71
|
-
console.error(`Error formatting ${filePath}:`, error);
|
|
82
|
+
console.error(`Error formatting ${getDisplayPath(filePath)}:`, error);
|
|
72
83
|
}
|
|
73
84
|
return Result.err(error);
|
|
74
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAaA;;;;AAIG;AACI,MAAM,WAAW,GAAG,OACzB,KAAwB,EACxB,OAIE,KACgD;AAClD,IAAA,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK;AAEvC,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,MAAM,KAAK,KAAK;AAE1C,IAAA,MAAM,eAAe,GAAG,MAAM,GAAG,MAAK,EAAE,CAAC,GAAG,IAAI;AAEhD,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,eAAe,CAAC,oBAAoB,CAAC;AAErC,QAAA,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7B;AAEA,IAAA,eAAe,CAAC,CAAA,WAAA,EAAc,KAAK,CAAC,MAAM,CAAA,SAAA,CAAW,CAAC;;IAGtD,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAExD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,KAAK,GAAG,SAAS;;AAG5E,IAAA,MAAM,cAAc,GAAG,CAAC,QAAgB,KAAY;AAClD,QAAA,IAAI,OAAO,KAAK,SAAS,EAAE;AACzB,YAAA,OAAO,QAAQ;QACjB;QAEA,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;AAErD,QAAA,OAAO,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,GAAG,YAAY;AAChE,IAAA,CAAC;;AAGD,IAAA,MAAM,OAAO;;AAEX,IAAA,MAAM,OAAO,CAAC,UAAU,CACtB,KAAK,CAAC,GAAG,CAAC,OAAO,QAAQ,KAAI;AAC3B,QAAA,IAAI;;YA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Q,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,eAAe,CAAC,oBAAoB,CAAC;AAErC,QAAA,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC;IAC7B;IAEA,OAAO,WAAW,CAAC,QAAQ,EAAE;QAC3B,MAAM;QACN,aAAa;QACb,MAAM;AACP,KAAA,CAAC;AACJ;;;;"}
|
package/dist/functions/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ export { assertExt, checkExt } from './assert-ext.mjs';
|
|
|
2
2
|
export { assertPathExists, pathExists } from './assert-path-exists.mjs';
|
|
3
3
|
export { assertRepoIsClean, repoIsDirty } from './assert-repo-is-clean.mjs';
|
|
4
4
|
export { createResultAssert } from './create-result-assert.mjs';
|
|
5
|
-
export { getDiffFrom, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './diff.mjs';
|
|
5
|
+
export { getDiffFrom, getGitRoot, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './diff.mjs';
|
|
6
6
|
export { $ } from './exec-async.mjs';
|
|
7
7
|
export { formatDiffFrom, formatFiles, formatFilesGlob, formatUncommittedFiles } from './format.mjs';
|
|
8
8
|
export { genIndex } from './gen-index.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ export { assertExt, checkExt } from './functions/assert-ext.mjs';
|
|
|
2
2
|
export { assertPathExists, pathExists } from './functions/assert-path-exists.mjs';
|
|
3
3
|
export { assertRepoIsClean, repoIsDirty } from './functions/assert-repo-is-clean.mjs';
|
|
4
4
|
export { createResultAssert } from './functions/create-result-assert.mjs';
|
|
5
|
-
export { getDiffFrom, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './functions/diff.mjs';
|
|
5
|
+
export { getDiffFrom, getGitRoot, getModifiedFiles, getStagedFiles, getUntrackedFiles } from './functions/diff.mjs';
|
|
6
6
|
export { $ } from './functions/exec-async.mjs';
|
|
7
7
|
export { formatDiffFrom, formatFiles, formatFilesGlob, formatUncommittedFiles } from './functions/format.mjs';
|
|
8
8
|
export { genIndex } from './functions/gen-index.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-repo-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
"@nodelib/fs.walk": "^3.0.1",
|
|
91
91
|
"@sindresorhus/is": "^7.2.0",
|
|
92
92
|
"@types/micromatch": "^4.0.10",
|
|
93
|
-
"cmd-ts": "^0.
|
|
93
|
+
"cmd-ts": "^0.15.0",
|
|
94
94
|
"fast-glob": "^3.3.3",
|
|
95
95
|
"micromatch": "^4.0.8",
|
|
96
|
-
"ts-data-forge": "^6.
|
|
96
|
+
"ts-data-forge": "^6.5.0",
|
|
97
97
|
"tsx": "^4.21.0"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
@@ -104,33 +104,33 @@
|
|
|
104
104
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
105
105
|
"@semantic-release/exec": "7.1.0",
|
|
106
106
|
"@semantic-release/git": "10.0.1",
|
|
107
|
-
"@semantic-release/github": "12.0.
|
|
108
|
-
"@semantic-release/npm": "13.1.
|
|
107
|
+
"@semantic-release/github": "12.0.6",
|
|
108
|
+
"@semantic-release/npm": "13.1.4",
|
|
109
109
|
"@semantic-release/release-notes-generator": "14.1.0",
|
|
110
|
-
"@types/node": "25.2
|
|
110
|
+
"@types/node": "25.3.2",
|
|
111
111
|
"@vitest/coverage-v8": "4.0.18",
|
|
112
112
|
"@vitest/ui": "4.0.18",
|
|
113
113
|
"conventional-changelog-conventionalcommits": "9.1.0",
|
|
114
114
|
"cspell": "9.6.4",
|
|
115
115
|
"dedent": "1.7.1",
|
|
116
116
|
"eslint": "9.39.2",
|
|
117
|
-
"eslint-config-typed": "4.6.
|
|
118
|
-
"github-settings-as-code": "1.1.
|
|
117
|
+
"eslint-config-typed": "4.6.4",
|
|
118
|
+
"github-settings-as-code": "1.1.9",
|
|
119
119
|
"jiti": "2.6.1",
|
|
120
120
|
"markdownlint": "0.40.0",
|
|
121
|
-
"markdownlint-cli2": "0.
|
|
121
|
+
"markdownlint-cli2": "0.21.0",
|
|
122
122
|
"npm-run-all2": "8.0.4",
|
|
123
123
|
"prettier": "3.8.1",
|
|
124
124
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
125
125
|
"prettier-plugin-packagejson": "3.0.0",
|
|
126
|
-
"rollup": "4.
|
|
126
|
+
"rollup": "4.59.0",
|
|
127
127
|
"semantic-release": "25.0.3",
|
|
128
|
-
"ts-codemod-lib": "^2.0.
|
|
129
|
-
"ts-repo-utils": "^8.
|
|
128
|
+
"ts-codemod-lib": "^2.0.5",
|
|
129
|
+
"ts-repo-utils": "^8.2.0",
|
|
130
130
|
"ts-type-forge": "2.3.1",
|
|
131
131
|
"tslib": "2.8.1",
|
|
132
|
-
"typedoc": "0.28.
|
|
133
|
-
"typedoc-github-theme": "0.
|
|
132
|
+
"typedoc": "0.28.17",
|
|
133
|
+
"typedoc-github-theme": "0.4.0",
|
|
134
134
|
"typescript": "5.9.3",
|
|
135
135
|
"vite": "7.3.1",
|
|
136
136
|
"vitest": "4.0.18"
|
package/src/cmd/gen-index-ts.mts
CHANGED
package/src/functions/diff.mts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { type ExecException } from 'node:child_process';
|
|
2
2
|
import { Result } from 'ts-data-forge';
|
|
3
3
|
import '../node-global.mjs';
|
|
4
|
+
import { $ } from './exec-async.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the git repository root directory
|
|
8
|
+
*/
|
|
9
|
+
export const getGitRoot = async (
|
|
10
|
+
options?: Readonly<{ silent?: boolean }>,
|
|
11
|
+
): Promise<Result<string, ExecException | Readonly<{ message: string }>>> => {
|
|
12
|
+
const result = await $('git rev-parse --show-toplevel', {
|
|
13
|
+
silent: options?.silent ?? false,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
if (Result.isErr(result)) {
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return Result.ok(result.value.stdout.trim());
|
|
21
|
+
};
|
|
4
22
|
|
|
5
23
|
/**
|
|
6
24
|
* Get untracked files from the working tree (files not added to git). Runs `git
|
|
@@ -105,6 +123,15 @@ const cmdResultToFiles = async ({
|
|
|
105
123
|
}>): Promise<
|
|
106
124
|
Result<readonly string[], ExecException | Readonly<{ message: string }>>
|
|
107
125
|
> => {
|
|
126
|
+
// Get git root directory
|
|
127
|
+
const gitRootResult = await getGitRoot({ silent: options?.silent ?? false });
|
|
128
|
+
|
|
129
|
+
if (Result.isErr(gitRootResult)) {
|
|
130
|
+
return gitRootResult;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const gitRoot = gitRootResult.value;
|
|
134
|
+
|
|
108
135
|
const result = await $(
|
|
109
136
|
[
|
|
110
137
|
cmd,
|
|
@@ -123,11 +150,12 @@ const cmdResultToFiles = async ({
|
|
|
123
150
|
|
|
124
151
|
const { stdout } = result.value;
|
|
125
152
|
|
|
126
|
-
// Parse git output
|
|
153
|
+
// Parse git output and convert to absolute paths
|
|
127
154
|
const files = stdout
|
|
128
155
|
.split('\n')
|
|
129
156
|
.map((line) => line.trim())
|
|
130
|
-
.filter((line) => line !== '')
|
|
157
|
+
.filter((line) => line !== '')
|
|
158
|
+
.map((relativePath) => path.join(gitRoot, relativePath));
|
|
131
159
|
|
|
132
160
|
return Result.ok(files);
|
|
133
161
|
};
|
|
@@ -134,7 +134,7 @@ describe('diff', () => {
|
|
|
134
134
|
if (Result.isOk(result)) {
|
|
135
135
|
const files = result.value;
|
|
136
136
|
|
|
137
|
-
expect(files).toContain(
|
|
137
|
+
expect(files).toContain(testFilePath);
|
|
138
138
|
}
|
|
139
139
|
} finally {
|
|
140
140
|
await cleanup();
|
|
@@ -168,7 +168,7 @@ describe('diff', () => {
|
|
|
168
168
|
if (Result.isOk(result)) {
|
|
169
169
|
const files = result.value;
|
|
170
170
|
|
|
171
|
-
expect(files).not.toContain(
|
|
171
|
+
expect(files).not.toContain(testFilePath);
|
|
172
172
|
}
|
|
173
173
|
} finally {
|
|
174
174
|
await cleanup();
|
|
@@ -210,9 +210,9 @@ describe('diff', () => {
|
|
|
210
210
|
if (Result.isOk(result)) {
|
|
211
211
|
const files = result.value;
|
|
212
212
|
|
|
213
|
-
expect(files).toContain(
|
|
213
|
+
expect(files).toContain(newFilePath);
|
|
214
214
|
|
|
215
|
-
expect(files).not.toContain(
|
|
215
|
+
expect(files).not.toContain(modifyFilePath);
|
|
216
216
|
}
|
|
217
217
|
} finally {
|
|
218
218
|
await cleanup();
|
|
@@ -348,7 +348,7 @@ describe('diff', () => {
|
|
|
348
348
|
if (Result.isOk(result)) {
|
|
349
349
|
const files = result.value;
|
|
350
350
|
|
|
351
|
-
expect(files).toContain(
|
|
351
|
+
expect(files).toContain(testFilePath);
|
|
352
352
|
}
|
|
353
353
|
} finally {
|
|
354
354
|
await cleanup();
|
|
@@ -386,9 +386,9 @@ describe('diff', () => {
|
|
|
386
386
|
if (Result.isOk(result)) {
|
|
387
387
|
const files = result.value;
|
|
388
388
|
|
|
389
|
-
expect(files).toContain(
|
|
389
|
+
expect(files).toContain(filePath1);
|
|
390
390
|
|
|
391
|
-
expect(files).toContain(
|
|
391
|
+
expect(files).toContain(filePath2);
|
|
392
392
|
}
|
|
393
393
|
} finally {
|
|
394
394
|
await cleanup();
|
|
@@ -433,7 +433,7 @@ describe('diff', () => {
|
|
|
433
433
|
if (Result.isOk(resultExclude)) {
|
|
434
434
|
const files = resultExclude.value;
|
|
435
435
|
|
|
436
|
-
expect(files).not.toContain(
|
|
436
|
+
expect(files).not.toContain(testFilePath);
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
// Test with excludeDeleted = false
|
|
@@ -457,7 +457,7 @@ describe('diff', () => {
|
|
|
457
457
|
if (Result.isOk(resultInclude)) {
|
|
458
458
|
const files = resultInclude.value;
|
|
459
459
|
|
|
460
|
-
expect(files).toContain(
|
|
460
|
+
expect(files).toContain(testFilePath);
|
|
461
461
|
}
|
|
462
462
|
} else {
|
|
463
463
|
// If the file is not properly staged for deletion, just log and skip the assertion
|
|
@@ -579,7 +579,7 @@ describe('diff', () => {
|
|
|
579
579
|
if (Result.isOk(result)) {
|
|
580
580
|
const files = result.value;
|
|
581
581
|
|
|
582
|
-
expect(files).toContain(
|
|
582
|
+
expect(files).toContain(testFilePath);
|
|
583
583
|
}
|
|
584
584
|
} finally {
|
|
585
585
|
await cleanup();
|
|
@@ -626,9 +626,9 @@ describe('diff', () => {
|
|
|
626
626
|
if (Result.isOk(result)) {
|
|
627
627
|
const files = result.value;
|
|
628
628
|
|
|
629
|
-
expect(files).toContain(
|
|
629
|
+
expect(files).toContain(filePath1);
|
|
630
630
|
|
|
631
|
-
expect(files).toContain(
|
|
631
|
+
expect(files).toContain(filePath2);
|
|
632
632
|
}
|
|
633
633
|
} finally {
|
|
634
634
|
await cleanup();
|
|
@@ -669,7 +669,7 @@ describe('diff', () => {
|
|
|
669
669
|
if (Result.isOk(resultExclude)) {
|
|
670
670
|
const files = resultExclude.value;
|
|
671
671
|
|
|
672
|
-
expect(files).not.toContain(
|
|
672
|
+
expect(files).not.toContain(testFilePath);
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
// Test with excludeDeleted = false
|
|
@@ -683,7 +683,7 @@ describe('diff', () => {
|
|
|
683
683
|
if (Result.isOk(resultInclude)) {
|
|
684
684
|
const files = resultInclude.value;
|
|
685
685
|
|
|
686
|
-
expect(files).toContain(
|
|
686
|
+
expect(files).toContain(testFilePath);
|
|
687
687
|
}
|
|
688
688
|
} finally {
|
|
689
689
|
await cleanup();
|
package/src/functions/format.mts
CHANGED
|
@@ -5,6 +5,7 @@ import '../node-global.mjs';
|
|
|
5
5
|
import { pathExists } from './assert-path-exists.mjs';
|
|
6
6
|
import {
|
|
7
7
|
getDiffFrom,
|
|
8
|
+
getGitRoot,
|
|
8
9
|
getModifiedFiles,
|
|
9
10
|
getStagedFiles,
|
|
10
11
|
getUntrackedFiles,
|
|
@@ -37,6 +38,22 @@ export const formatFiles = async (
|
|
|
37
38
|
|
|
38
39
|
conditionalEcho(`Formatting ${files.length} files...`);
|
|
39
40
|
|
|
41
|
+
// Get git root for display purposes
|
|
42
|
+
const gitRootResult = await getGitRoot({ silent: true });
|
|
43
|
+
|
|
44
|
+
const gitRoot = Result.isOk(gitRootResult) ? gitRootResult.value : undefined;
|
|
45
|
+
|
|
46
|
+
// Helper function to get display path (relative to git root if available)
|
|
47
|
+
const getDisplayPath = (filePath: string): string => {
|
|
48
|
+
if (gitRoot === undefined) {
|
|
49
|
+
return filePath;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const relativePath = path.relative(gitRoot, filePath);
|
|
53
|
+
|
|
54
|
+
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
55
|
+
};
|
|
56
|
+
|
|
40
57
|
// Format each file
|
|
41
58
|
const results: readonly PromiseSettledResult<Result<undefined, unknown>>[] =
|
|
42
59
|
// NOTE: Using Promise.allSettled to ensure all files are processed even if some fail
|
|
@@ -45,13 +62,17 @@ export const formatFiles = async (
|
|
|
45
62
|
try {
|
|
46
63
|
// Check if file exists first
|
|
47
64
|
if (!(await pathExists(filePath))) {
|
|
48
|
-
conditionalEcho(
|
|
65
|
+
conditionalEcho(
|
|
66
|
+
`Skipping non-existent file: ${getDisplayPath(filePath)}`,
|
|
67
|
+
);
|
|
49
68
|
|
|
50
69
|
return Result.ok(undefined);
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
if (!noIgnore && (options?.ignore ?? defaultIgnoreFn)(filePath)) {
|
|
54
|
-
conditionalEcho(
|
|
73
|
+
conditionalEcho(
|
|
74
|
+
`Skipping ignored file: ${getDisplayPath(filePath)}`,
|
|
75
|
+
);
|
|
55
76
|
|
|
56
77
|
return Result.ok(undefined);
|
|
57
78
|
}
|
|
@@ -62,7 +83,9 @@ export const formatFiles = async (
|
|
|
62
83
|
});
|
|
63
84
|
|
|
64
85
|
if (!noIgnore && fileInfo.ignored) {
|
|
65
|
-
conditionalEcho(
|
|
86
|
+
conditionalEcho(
|
|
87
|
+
`Skipping ignored file: ${getDisplayPath(filePath)}`,
|
|
88
|
+
);
|
|
66
89
|
|
|
67
90
|
return Result.ok(undefined);
|
|
68
91
|
}
|
|
@@ -73,7 +96,9 @@ export const formatFiles = async (
|
|
|
73
96
|
fileInfo.inferredParser === null
|
|
74
97
|
) {
|
|
75
98
|
// Silently skip files with no parser
|
|
76
|
-
conditionalEcho(
|
|
99
|
+
conditionalEcho(
|
|
100
|
+
`Skipping file (no parser): ${getDisplayPath(filePath)}`,
|
|
101
|
+
);
|
|
77
102
|
|
|
78
103
|
return Result.ok(undefined);
|
|
79
104
|
}
|
|
@@ -92,17 +117,20 @@ export const formatFiles = async (
|
|
|
92
117
|
|
|
93
118
|
// Only write if content changed
|
|
94
119
|
if (formatted === content) {
|
|
95
|
-
conditionalEcho(`Unchanged: ${filePath}`);
|
|
120
|
+
conditionalEcho(`Unchanged: ${getDisplayPath(filePath)}`);
|
|
96
121
|
} else {
|
|
97
122
|
await fs.writeFile(filePath, formatted, 'utf8');
|
|
98
123
|
|
|
99
|
-
conditionalEcho(`Formatted: ${filePath}`);
|
|
124
|
+
conditionalEcho(`Formatted: ${getDisplayPath(filePath)}`);
|
|
100
125
|
}
|
|
101
126
|
|
|
102
127
|
return Result.ok(undefined);
|
|
103
128
|
} catch (error) {
|
|
104
129
|
if (!silent) {
|
|
105
|
-
console.error(
|
|
130
|
+
console.error(
|
|
131
|
+
`Error formatting ${getDisplayPath(filePath)}:`,
|
|
132
|
+
error,
|
|
133
|
+
);
|
|
106
134
|
}
|
|
107
135
|
|
|
108
136
|
return Result.err(error);
|
|
@@ -3,6 +3,7 @@ import { Result } from 'ts-data-forge';
|
|
|
3
3
|
import '../node-global.mjs';
|
|
4
4
|
import {
|
|
5
5
|
getDiffFrom,
|
|
6
|
+
getGitRoot,
|
|
6
7
|
getModifiedFiles,
|
|
7
8
|
getStagedFiles,
|
|
8
9
|
getUntrackedFiles,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
|
|
17
18
|
vi.mock(import('./diff.mjs'), () => ({
|
|
18
19
|
getDiffFrom: vi.fn(),
|
|
20
|
+
getGitRoot: vi.fn(),
|
|
19
21
|
getModifiedFiles: vi.fn(),
|
|
20
22
|
getStagedFiles: vi.fn(),
|
|
21
23
|
getUntrackedFiles: vi.fn(),
|
|
@@ -46,6 +48,8 @@ describe(formatFilesGlob, () => {
|
|
|
46
48
|
test('should format files matching glob pattern', async () => {
|
|
47
49
|
vi.clearAllMocks();
|
|
48
50
|
|
|
51
|
+
vi.mocked(getGitRoot).mockResolvedValue(Result.ok(testDir));
|
|
52
|
+
|
|
49
53
|
// Setup test directory
|
|
50
54
|
await fs.mkdir(testDir, { recursive: true });
|
|
51
55
|
|
|
@@ -119,6 +123,8 @@ describe(formatFilesGlob, () => {
|
|
|
119
123
|
test('should handle nested directories with glob pattern', async () => {
|
|
120
124
|
vi.clearAllMocks();
|
|
121
125
|
|
|
126
|
+
vi.mocked(getGitRoot).mockResolvedValue(Result.ok(testDir));
|
|
127
|
+
|
|
122
128
|
// Setup test directory with nested structure
|
|
123
129
|
await fs.mkdir(path.join(testDir, 'src', 'utils'), { recursive: true });
|
|
124
130
|
|
|
@@ -180,6 +186,8 @@ describe(formatFiles, () => {
|
|
|
180
186
|
test('should format a list of files', async () => {
|
|
181
187
|
vi.clearAllMocks();
|
|
182
188
|
|
|
189
|
+
vi.mocked(getGitRoot).mockResolvedValue(Result.ok(testDir));
|
|
190
|
+
|
|
183
191
|
await fs.mkdir(testDir, { recursive: true });
|
|
184
192
|
|
|
185
193
|
try {
|
|
@@ -263,6 +271,9 @@ describe(formatUncommittedFiles, () => {
|
|
|
263
271
|
const setupTest = async (): Promise<void> => {
|
|
264
272
|
vi.clearAllMocks();
|
|
265
273
|
|
|
274
|
+
// Mock getGitRoot to return testDir as git root for relative path display
|
|
275
|
+
vi.mocked(getGitRoot).mockResolvedValue(Result.ok(testDir));
|
|
276
|
+
|
|
266
277
|
await fs.mkdir(testDir, { recursive: true });
|
|
267
278
|
};
|
|
268
279
|
|