ts-repo-utils 1.1.0 → 1.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 CHANGED
@@ -100,7 +100,7 @@ await assertRepoIsDirty();
100
100
 
101
101
  ### Command Execution
102
102
 
103
- #### `$(command: string, options?: ExecOptions): Promise<ExecResult>`
103
+ #### `$(command: string, options?: { silent?: boolean; timeout?: number }): Promise<ExecResult>`
104
104
 
105
105
  Executes a shell command asynchronously with timeout support and type-safe results.
106
106
 
@@ -116,14 +116,14 @@ if (result.type === 'ok') {
116
116
  }
117
117
  ```
118
118
 
119
- **Types:**
119
+ **Options:**
120
120
 
121
- ```typescript
122
- type ExecOptions = Readonly<{
123
- silent?: boolean; // Don't log command/output (default: false)
124
- timeout?: number; // Timeout in milliseconds (default: 30000)
125
- }>;
121
+ - `silent?: boolean` - Don't log command/output (default: false)
122
+ - `timeout?: number` - Timeout in milliseconds (default: 30000)
126
123
 
124
+ **Return Type:**
125
+
126
+ ```typescript
127
127
  type ExecResult = Readonly<
128
128
  | { type: 'ok'; stdout: string; stderr: string }
129
129
  | { type: 'error'; exception: ExecException }
@@ -175,7 +175,7 @@ await formatDiffFrom('abc123');
175
175
 
176
176
  #### `genIndex(config: GenIndexConfig): Promise<void>`
177
177
 
178
- Generates index.mts files recursively in target directories with automatic barrel exports.
178
+ Generates index files recursively in target directories with automatic barrel exports.
179
179
 
180
180
  ```typescript
181
181
  import { genIndex } from 'ts-repo-utils';
@@ -201,11 +201,11 @@ type GenIndexConfig = DeepReadonly<{
201
201
 
202
202
  **Features:**
203
203
 
204
- - Validates file extensions before generation
205
204
  - Creates barrel exports for all subdirectories
206
- - Supports complex glob exclusion patterns
207
- - Automatically formats generated files
205
+ - Supports complex glob exclusion patterns (using micromatch)
206
+ - Automatically formats generated files using project's prettier config
208
207
  - Works with both single directories and directory arrays
208
+ - Respects source and export extension configuration
209
209
 
210
210
  ## Key Features
211
211
 
@@ -223,7 +223,7 @@ type GenIndexConfig = DeepReadonly<{
223
223
  ### Pre-commit Hook
224
224
 
225
225
  ```typescript
226
- import { formatChanged, assertExt, repoIsDirty } from 'ts-repo-utils';
226
+ import { formatChanged, assertExt, assertRepoIsDirty } from 'ts-repo-utils';
227
227
 
228
228
  // Format changed files
229
229
  await formatChanged();
@@ -233,7 +233,7 @@ await assertExt({
233
233
  directories: [{ path: './src', extension: '.ts' }],
234
234
  });
235
235
 
236
- // Ensure no uncommitted changes remain
236
+ // Ensure repository is clean (exits if dirty)
237
237
  await assertRepoIsDirty();
238
238
  ```
239
239
 
@@ -1 +1 @@
1
- {"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AACA,OAAO,oBAAoB,CAAC;AAI5B;;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;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,CA4DnE,CAAC"}
1
+ {"version":3,"file":"gen-index.d.mts","sourceRoot":"","sources":["../../src/functions/gen-index.mts"],"names":[],"mappings":"AACA,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;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAU,QAAQ,cAAc,KAAG,OAAO,CAAC,IAAI,CA0CnE,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import micromatch from 'micromatch';
2
2
  import '../node-global.mjs';
3
- import { assertExt } from './assert-ext.mjs';
4
3
  import { assertPathExists } from './assert-path-exists.mjs';
5
4
 
6
5
  /**
@@ -17,30 +16,13 @@ const genIndex = async (config) => {
17
16
  ? [config.targetDirectory]
18
17
  : config.targetDirectory;
19
18
  try {
20
- // Step 1: Validate file extensions
21
- echo('1. Validating file extensions...');
22
- await assertExt({
23
- directories: [
24
- {
25
- path: path.resolve(projectRootPath, './src'),
26
- extension: '.mts',
27
- ignorePatterns: ['tsconfig.json', 'globals.d.mts'],
28
- },
29
- {
30
- path: path.resolve(projectRootPath, './scripts'),
31
- extension: '.mts',
32
- ignorePatterns: ['tsconfig.json'],
33
- },
34
- ],
35
- });
36
- echo('✓ File extensions validated\n');
37
- // Step 2: Verify target directories exist
19
+ // Step 1: Verify target directories exist
38
20
  for (const dir of targetDirs) {
39
21
  const resolvedDir = path.resolve(dir);
40
22
  // eslint-disable-next-line no-await-in-loop
41
23
  await assertPathExists(resolvedDir, `Target directory: ${dir}`);
42
24
  }
43
- // Step 3: Generate index files
25
+ // Step 2: Generate index files
44
26
  echo('2. Generating index files...');
45
27
  for (const dir of targetDirs) {
46
28
  const resolvedDir = path.resolve(dir);
@@ -48,7 +30,7 @@ const genIndex = async (config) => {
48
30
  await generateIndexFileForDir(resolvedDir, filledConfig);
49
31
  }
50
32
  echo('✓ Index files generated\n');
51
- // Step 4: Format generated files
33
+ // Step 3: Format generated files
52
34
  echo('3. Formatting generated files...');
53
35
  const fmtResult = await $('npm run fmt');
54
36
  if (fmtResult.type === 'error') {
@@ -1 +1 @@
1
- {"version":3,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A,EAAoB,MAAM,CAAS,MAAA,EAAA,MAAM,CAAC,eAAe,IAAI,CAC1E;AACD,QAAA,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AAC5B,YAAA,MAAM,kBAAkB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,eAAe,CAAC;AAEtE,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;;;;"}
@@ -2,11 +2,9 @@ import { default as glob_ } from 'fast-glob';
2
2
  import * as fs_ from 'node:fs/promises';
3
3
  import * as path_ from 'node:path';
4
4
  import { $ as $_ } from './functions/exec-async.mjs';
5
- import { projectRootPath as projectRootPath_ } from './project-root-path.mjs';
6
5
  declare global {
7
6
  const $: typeof $_;
8
7
  const echo: typeof console.log;
9
- const projectRootPath: typeof projectRootPath_;
10
8
  const path: typeof path_;
11
9
  const fs: typeof fs_;
12
10
  const glob: typeof glob_;
@@ -1 +1 @@
1
- {"version":3,"file":"node-global.d.mts","sourceRoot":"","sources":["../src/node-global.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAc9E,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,IAAI,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAC/B,MAAM,eAAe,EAAE,OAAO,gBAAgB,CAAC;IAE/C,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,EAAE,EAAE,OAAO,GAAG,CAAC;IACrB,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;CAC1B"}
1
+ {"version":3,"file":"node-global.d.mts","sourceRoot":"","sources":["../src/node-global.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAarD,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,IAAI,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAE/B,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;IACzB,MAAM,EAAE,EAAE,OAAO,GAAG,CAAC;IACrB,MAAM,IAAI,EAAE,OAAO,KAAK,CAAC;CAC1B"}
@@ -1,14 +1,12 @@
1
1
  import glob_ from 'fast-glob';
2
2
  import * as fs_ from 'node:fs/promises';
3
- import * as path from 'node:path';
3
+ import * as path_ from 'node:path';
4
4
  import { $ } from './functions/exec-async.mjs';
5
- import { projectRootPath } from './project-root-path.mjs';
6
5
 
7
6
  const globalsDef = {
8
7
  $: $,
9
8
  echo: console.log,
10
- projectRootPath: projectRootPath,
11
- path: path,
9
+ path: path_,
12
10
  fs: fs_,
13
11
  glob: glob_,
14
12
  };
@@ -1 +1 @@
1
- {"version":3,"file":"node-global.mjs","sources":["../src/node-global.mts"],"sourcesContent":[null],"names":["$_","projectRootPath_","path_"],"mappings":";;;;;;AAMA,MAAM,UAAU,GAAG;AACjB,IAAA,CAAC,EAAEA,CAAE;IACL,IAAI,EAAE,OAAO,CAAC,GAAG;AACjB,IAAA,eAAe,EAAEC,eAAgB;AAEjC,IAAA,IAAI,EAAEC,IAAK;AACX,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,IAAI,EAAE,KAAK;CACH;AAEV,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC"}
1
+ {"version":3,"file":"node-global.mjs","sources":["../src/node-global.mts"],"sourcesContent":[null],"names":["$_"],"mappings":";;;;;AAKA,MAAM,UAAU,GAAG;AACjB,IAAA,CAAC,EAAEA,CAAE;IACL,IAAI,EAAE,OAAO,CAAC,GAAG;AAEjB,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,IAAI,EAAE,KAAK;CACH;AAEV,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-repo-utils",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript"
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "license": "Apache-2.0",
13
13
  "author": "noshiro-pf <noshiro.pf@gmail.com>",
14
- "sideEffects": false,
14
+ "sideEffects": true,
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
@@ -30,12 +30,13 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "scripts": {
33
- "build": "npm run z:node-eval -- \"import { build } from './scripts/functions/build.mjs'; build();\"",
33
+ "build": "npm run z:node-esm -- ./scripts/cmd/build.mjs",
34
34
  "check-all": "npm run z:node-esm -- ./scripts/cmd/check-all.mjs",
35
35
  "check:ext": "npm run z:node-esm -- ./scripts/cmd/check-ext.mjs",
36
36
  "cspell": "cspell \"**\" --gitignore --gitignore-root ./ --no-progress",
37
- "doc": "npm run z:node-eval -- \"import { genDocs } from './scripts/functions/gen-docs.mjs'; genDocs();\"",
38
- "fmt": "prettier --write .",
37
+ "doc": "npm run z:node-esm -- ./scripts/cmd/gen-docs.mjs",
38
+ "fmt": "npm run z:node-esm -- ./scripts/cmd/fmt-diff.mjs",
39
+ "fmt:full": "prettier --write .",
39
40
  "gi": "npm run z:node-esm -- ./scripts/cmd/gi.mjs",
40
41
  "lint": "eslint .",
41
42
  "lint:fix": "eslint . --fix",
@@ -50,7 +51,6 @@
50
51
  "type-check": "tsc --noEmit",
51
52
  "update-packages": "npx npm-check-updates -u --install always --reject @types/node",
52
53
  "z:node-esm": "node --import tsx/esm",
53
- "z:node-eval": "npm run z:node-esm -- --input-type=module --eval",
54
54
  "z:vitest": "vitest --config ./configs/vitest.config.ts"
55
55
  },
56
56
  "dependencies": {
@@ -1,6 +1,5 @@
1
1
  import micromatch from 'micromatch';
2
2
  import '../node-global.mjs';
3
- import { assertExt } from './assert-ext.mjs';
4
3
  import { assertPathExists } from './assert-path-exists.mjs';
5
4
 
6
5
  /**
@@ -38,32 +37,14 @@ export const genIndex = async (config: GenIndexConfig): Promise<void> => {
38
37
  : config.targetDirectory;
39
38
 
40
39
  try {
41
- // Step 1: Validate file extensions
42
- echo('1. Validating file extensions...');
43
- await assertExt({
44
- directories: [
45
- {
46
- path: path.resolve(projectRootPath, './src'),
47
- extension: '.mts',
48
- ignorePatterns: ['tsconfig.json', 'globals.d.mts'],
49
- },
50
- {
51
- path: path.resolve(projectRootPath, './scripts'),
52
- extension: '.mts',
53
- ignorePatterns: ['tsconfig.json'],
54
- },
55
- ],
56
- });
57
- echo('✓ File extensions validated\n');
58
-
59
- // Step 2: Verify target directories exist
40
+ // Step 1: Verify target directories exist
60
41
  for (const dir of targetDirs) {
61
42
  const resolvedDir = path.resolve(dir);
62
43
  // eslint-disable-next-line no-await-in-loop
63
44
  await assertPathExists(resolvedDir, `Target directory: ${dir}`);
64
45
  }
65
46
 
66
- // Step 3: Generate index files
47
+ // Step 2: Generate index files
67
48
  echo('2. Generating index files...');
68
49
  for (const dir of targetDirs) {
69
50
  const resolvedDir = path.resolve(dir);
@@ -72,7 +53,7 @@ export const genIndex = async (config: GenIndexConfig): Promise<void> => {
72
53
  }
73
54
  echo('✓ Index files generated\n');
74
55
 
75
- // Step 4: Format generated files
56
+ // Step 3: Format generated files
76
57
  echo('3. Formatting generated files...');
77
58
  const fmtResult = await $('npm run fmt');
78
59
  if (fmtResult.type === 'error') {
@@ -2,12 +2,10 @@ import { default as glob_ } from 'fast-glob';
2
2
  import * as fs_ from 'node:fs/promises';
3
3
  import * as path_ from 'node:path';
4
4
  import { $ as $_ } from './functions/exec-async.mjs';
5
- import { projectRootPath as projectRootPath_ } from './project-root-path.mjs';
6
5
 
7
6
  const globalsDef = {
8
7
  $: $_,
9
8
  echo: console.log,
10
- projectRootPath: projectRootPath_,
11
9
 
12
10
  path: path_,
13
11
  fs: fs_,
@@ -19,7 +17,6 @@ Object.assign(globalThis, globalsDef);
19
17
  declare global {
20
18
  const $: typeof $_;
21
19
  const echo: typeof console.log;
22
- const projectRootPath: typeof projectRootPath_;
23
20
 
24
21
  const path: typeof path_;
25
22
  const fs: typeof fs_;
@@ -1,2 +0,0 @@
1
- export declare const projectRootPath: string;
2
- //# sourceMappingURL=project-root-path.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-root-path.d.mts","sourceRoot":"","sources":["../src/project-root-path.mts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,QAA0C,CAAC"}
@@ -1,6 +0,0 @@
1
- import * as path from 'node:path';
2
-
3
- const projectRootPath = path.resolve(import.meta.dirname, '..');
4
-
5
- export { projectRootPath };
6
- //# sourceMappingURL=project-root-path.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-root-path.mjs","sources":["../src/project-root-path.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEa,MAAA,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI;;;;"}
@@ -1,3 +0,0 @@
1
- import * as path from 'node:path';
2
-
3
- export const projectRootPath = path.resolve(import.meta.dirname, '..');