ts-repo-utils 2.3.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"assert-path-exists.d.mts","sourceRoot":"","sources":["../../src/functions/assert-path-exists.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAOlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,oBAAoB,KACnB,OAAO,CAAC,IAAI,CAKd,CAAC"}
1
+ {"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 fs_.access(filePath);
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":["fs"],"mappings":";;;AAGA;;;;AAIG;MACU,UAAU,GAAG,OAAO,QAAgB,KAAsB;AACrE,IAAA,IAAI;AACF,QAAA,MAAMA,GAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;AACzB,QAAA,OAAO,IAAI;;AACX,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;;AAEhB;AAEA;;;;AAIG;AACI,MAAM,gBAAgB,GAAG,OAC9B,QAAgB,EAChB,WAAW,GAAG,MAAM,KACH;IACjB,IAAI,EAAE,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC,EAAE;AACjC,QAAA,IAAI,CAAC,CAAA,EAAG,WAAW,oBAAoB,QAAQ,CAAA,CAAE,CAAC;AAClD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;;AAEnB;;;;"}
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;;;;"}
@@ -11,7 +11,7 @@ export declare const repoIsDirty: (options?: Readonly<{
11
11
  * Checks if the repository is dirty and exits with code 1 if it is.
12
12
  * Shows git status and diff output before exiting.
13
13
  */
14
- export declare const assertRepoIsDirty: (options?: Readonly<{
14
+ export declare const assertRepoIsClean: (options?: Readonly<{
15
15
  silent?: boolean;
16
16
  }>) => Promise<void>;
17
17
  //# sourceMappingURL=assert-repo-is-dirty.d.mts.map
@@ -14,7 +14,7 @@ const repoIsDirty = async (options) => {
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 assertRepoIsDirty = async (options) => {
17
+ const assertRepoIsClean = async (options) => {
18
18
  try {
19
19
  const status = await getGitStatus({ silent: options?.silent ?? false });
20
20
  if (!status.isDirty) {
@@ -62,5 +62,5 @@ const getGitStatus = async (options) => {
62
62
  };
63
63
  };
64
64
 
65
- export { assertRepoIsDirty, repoIsDirty };
65
+ export { assertRepoIsClean, repoIsDirty };
66
66
  //# sourceMappingURL=assert-repo-is-dirty.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.mts","sourceRoot":"","sources":["../../src/functions/format.mts"],"names":[],"mappings":"AAIA,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,CA6DtB,CAAC"}
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
 
@@ -25,7 +23,7 @@ const formatFilesList = async (files, options) => {
25
23
  const results = await Promise.allSettled(files.map(async (filePath) => {
26
24
  try {
27
25
  // Read file content
28
- const content = await readFile(filePath, 'utf8');
26
+ const content = await fs.readFile(filePath, 'utf8');
29
27
  // Resolve prettier config for this file
30
28
  const prettierOptions = await prettier.resolveConfig(filePath);
31
29
  // Check if file is ignored by prettier
@@ -45,7 +43,7 @@ const formatFilesList = async (files, options) => {
45
43
  });
46
44
  // Only write if content changed
47
45
  if (formatted !== content) {
48
- await writeFile(filePath, formatted, 'utf8');
46
+ await fs.writeFile(filePath, formatted, 'utf8');
49
47
  if (!silent) {
50
48
  echo(`Formatted: ${filePath}`);
51
49
  }
@@ -69,7 +67,7 @@ const formatFiles = async (pathGlob, options) => {
69
67
  const silent = options?.silent ?? false;
70
68
  try {
71
69
  // Find all files matching the glob
72
- const files = await glob_(pathGlob, {
70
+ const files = await glob(pathGlob, {
73
71
  absolute: true,
74
72
  ignore: ['**/node_modules/**', '**/.git/**'],
75
73
  dot: true,
@@ -115,7 +113,7 @@ const formatUntracked = async (options) => {
115
113
  // Filter out non-existent files before formatting
116
114
  const fileExistenceChecks = await Promise.allSettled(files.map(async (filePath) => {
117
115
  try {
118
- await readFile(filePath, 'utf8');
116
+ await fs.readFile(filePath, 'utf8');
119
117
  return filePath;
120
118
  }
121
119
  catch {
@@ -155,7 +153,7 @@ const formatDiffFrom = async (base, options) => {
155
153
  return 'err';
156
154
  }
157
155
  const diffFiles = diffFromBaseResult.value;
158
- let allFiles = diffFiles;
156
+ let mut_allFiles = diffFiles;
159
157
  // If includeUntracked is true, also get untracked files
160
158
  if (options?.includeUntracked ?? true) {
161
159
  const untrackedFilesResult = await getUntrackedFiles({
@@ -167,24 +165,23 @@ const formatDiffFrom = async (base, options) => {
167
165
  }
168
166
  const untrackedFiles = untrackedFilesResult.value;
169
167
  // Combine and deduplicate files
170
- const uniqueFiles = new Set([...diffFiles, ...untrackedFiles]);
171
- allFiles = Array.from(uniqueFiles);
168
+ mut_allFiles = Arr.uniq([...diffFiles, ...untrackedFiles]);
172
169
  if (!silent) {
173
- echo(`Formatting files that differ from ${base} and untracked files:`, allFiles);
170
+ echo(`Formatting files that differ from ${base} and untracked files:`, mut_allFiles);
174
171
  }
175
172
  }
176
173
  else {
177
174
  if (!silent) {
178
- echo(`Formatting files that differ from ${base}:`, allFiles);
175
+ echo(`Formatting files that differ from ${base}:`, mut_allFiles);
179
176
  }
180
177
  }
181
- if (allFiles.length === 0) {
178
+ if (mut_allFiles.length === 0) {
182
179
  if (!silent) {
183
180
  echo(`No files to format`);
184
181
  }
185
182
  return 'ok';
186
183
  }
187
- return await formatFilesList(allFiles, { silent });
184
+ return await formatFilesList(mut_allFiles, { silent });
188
185
  }
189
186
  catch (error) {
190
187
  console.error('Error in formatDiffFrom:', error);
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","sources":["../../src/functions/format.mts"],"sourcesContent":[null],"names":["glob"],"mappings":";;;;;;;AAOA;;;;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,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;;YAGhD,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;;YAG9D,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE;AACpD,gBAAA,UAAU,EAAE,iBAAiB;AAC9B,aAAA,CAAC;AAEF,YAAA,IA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js';
2
2
  export { assertPathExists, pathExists } from './assert-path-exists.mjs';
3
- export { assertRepoIsDirty, repoIsDirty } from './assert-repo-is-dirty.mjs';
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 { assertRepoIsDirty, repoIsDirty } from './functions/assert-repo-is-dirty.mjs';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-repo-utils",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -1,4 +1,3 @@
1
- import * as fs from 'node:fs/promises';
2
1
  import '../node-global.mjs';
3
2
 
4
3
  /**
@@ -17,7 +17,7 @@ export const repoIsDirty = async (
17
17
  * Checks if the repository is dirty and exits with code 1 if it is.
18
18
  * Shows git status and diff output before exiting.
19
19
  */
20
- export const assertRepoIsDirty = async (
20
+ export const assertRepoIsClean = async (
21
21
  options?: Readonly<{ silent?: boolean }>,
22
22
  ): Promise<void> => {
23
23
  try {
@@ -1,5 +1,3 @@
1
- import { rm, writeFile } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
1
  import { Result } from 'ts-data-forge';
4
2
  import '../node-global.mjs';
5
3
  import { getDiffFrom, getUntrackedFiles } from './diff.mjs';
@@ -13,7 +11,7 @@ describe('diff', () => {
13
11
  for (const file of testFiles) {
14
12
  try {
15
13
  // eslint-disable-next-line no-await-in-loop
16
- await rm(file, { force: true });
14
+ await fs.rm(file, { force: true });
17
15
  } catch {
18
16
  // Ignore cleanup errors
19
17
  }
@@ -34,10 +32,10 @@ describe('diff', () => {
34
32
  test('should detect newly created files', async () => {
35
33
  // Create a new file in project root
36
34
  const testFileName = 'test-new-file.tmp';
37
- const testFilePath = join(process.cwd(), testFileName);
35
+ const testFilePath = path.join(process.cwd(), testFileName);
38
36
  testFiles.push(testFilePath);
39
37
 
40
- await writeFile(testFilePath, 'test content');
38
+ await fs.writeFile(testFilePath, 'test content');
41
39
 
42
40
  const result = await getUntrackedFiles({ silent: true });
43
41
 
@@ -51,17 +49,17 @@ describe('diff', () => {
51
49
  test('should detect modified existing files', async () => {
52
50
  // Use an existing file in the project that we can modify safely
53
51
  const testFileName = 'test-modify-file.tmp';
54
- const testFilePath = join(process.cwd(), testFileName);
52
+ const testFilePath = path.join(process.cwd(), testFileName);
55
53
  testFiles.push(testFilePath);
56
54
 
57
55
  // Create and commit the file first
58
- await writeFile(testFilePath, 'initial content');
56
+ await fs.writeFile(testFilePath, 'initial content');
59
57
 
60
58
  // Add to git to track it
61
59
  await $(`git add ${testFileName}`, { silent: true });
62
60
 
63
61
  // Modify the file
64
- await writeFile(testFilePath, 'modified content');
62
+ await fs.writeFile(testFilePath, 'modified content');
65
63
 
66
64
  const result = await getUntrackedFiles({ silent: true });
67
65
 
@@ -77,19 +75,19 @@ describe('diff', () => {
77
75
 
78
76
  test('should detect multiple types of changes', async () => {
79
77
  // Create multiple test files
80
- const newFile = join(process.cwd(), 'test-new-file.tmp');
81
- const modifyFile = join(process.cwd(), 'test-modify-file.tmp');
78
+ const newFile = path.join(process.cwd(), 'test-new-file.tmp');
79
+ const modifyFile = path.join(process.cwd(), 'test-modify-file.tmp');
82
80
  testFiles.push(newFile, modifyFile);
83
81
 
84
82
  // Create new file
85
- await writeFile(newFile, 'new file content');
83
+ await fs.writeFile(newFile, 'new file content');
86
84
 
87
85
  // Create and track another file
88
- await writeFile(modifyFile, 'initial content');
86
+ await fs.writeFile(modifyFile, 'initial content');
89
87
  await $(`git add test-modify-file.tmp`, { silent: true });
90
88
 
91
89
  // Modify the tracked file
92
- await writeFile(modifyFile, 'modified content');
90
+ await fs.writeFile(modifyFile, 'modified content');
93
91
 
94
92
  const result = await getUntrackedFiles({ silent: true });
95
93
 
@@ -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 { Arr, Result } from 'ts-data-forge';
5
3
  import '../node-global.mjs';
6
4
  import { getDiffFrom, getUntrackedFiles } from './diff.mjs';
7
5
 
@@ -32,7 +30,7 @@ export const formatFilesList = async (
32
30
  files.map(async (filePath) => {
33
31
  try {
34
32
  // Read file content
35
- const content = await readFile(filePath, 'utf8');
33
+ const content = await fs.readFile(filePath, 'utf8');
36
34
 
37
35
  // Resolve prettier config for this file
38
36
  const prettierOptions = await prettier.resolveConfig(filePath);
@@ -57,7 +55,7 @@ export const formatFilesList = async (
57
55
 
58
56
  // Only write if content changed
59
57
  if (formatted !== content) {
60
- await writeFile(filePath, formatted, 'utf8');
58
+ await fs.writeFile(filePath, formatted, 'utf8');
61
59
  if (!silent) {
62
60
  echo(`Formatted: ${filePath}`);
63
61
  }
@@ -144,7 +142,7 @@ export const formatUntracked = async (
144
142
  const fileExistenceChecks = await Promise.allSettled(
145
143
  files.map(async (filePath) => {
146
144
  try {
147
- await readFile(filePath, 'utf8');
145
+ await fs.readFile(filePath, 'utf8');
148
146
  return filePath;
149
147
  } catch {
150
148
  if (!silent) {
@@ -195,7 +193,7 @@ export const formatDiffFrom = async (
195
193
  }
196
194
 
197
195
  const diffFiles = diffFromBaseResult.value;
198
- let allFiles = diffFiles;
196
+ let mut_allFiles = diffFiles;
199
197
 
200
198
  // If includeUntracked is true, also get untracked files
201
199
  if (options?.includeUntracked ?? true) {
@@ -214,29 +212,28 @@ export const formatDiffFrom = async (
214
212
  const untrackedFiles = untrackedFilesResult.value;
215
213
 
216
214
  // Combine and deduplicate files
217
- const uniqueFiles = new Set([...diffFiles, ...untrackedFiles]);
218
- allFiles = Array.from(uniqueFiles);
215
+ mut_allFiles = Arr.uniq([...diffFiles, ...untrackedFiles]);
219
216
 
220
217
  if (!silent) {
221
218
  echo(
222
219
  `Formatting files that differ from ${base} and untracked files:`,
223
- allFiles,
220
+ mut_allFiles,
224
221
  );
225
222
  }
226
223
  } else {
227
224
  if (!silent) {
228
- echo(`Formatting files that differ from ${base}:`, allFiles);
225
+ echo(`Formatting files that differ from ${base}:`, mut_allFiles);
229
226
  }
230
227
  }
231
228
 
232
- if (allFiles.length === 0) {
229
+ if (mut_allFiles.length === 0) {
233
230
  if (!silent) {
234
231
  echo(`No files to format`);
235
232
  }
236
233
  return 'ok';
237
234
  }
238
235
 
239
- return await formatFilesList(allFiles, { silent });
236
+ return await formatFilesList(mut_allFiles, { silent });
240
237
  } catch (error) {
241
238
  console.error('Error in formatDiffFrom:', error);
242
239
  return 'err';
@@ -1,7 +1,6 @@
1
1
  import dedent from 'dedent';
2
- import * as fs from 'node:fs/promises';
3
- import * as path from 'node:path';
4
2
  import { Result } from 'ts-data-forge';
3
+ import '../node-global.mjs';
5
4
  import { getDiffFrom, getUntrackedFiles } from './diff.mjs';
6
5
  import { formatDiffFrom, formatFiles, formatFilesList } from './format.mjs';
7
6