ts-repo-utils 3.1.0 → 3.1.2
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-ext.mjs.map +1 -1
- package/dist/functions/assert-path-exists.mjs.map +1 -1
- package/dist/functions/assert-repo-is-clean.mjs.map +1 -1
- package/dist/functions/diff.mjs.map +1 -1
- package/dist/functions/exec-async.mjs.map +1 -1
- package/dist/functions/format.mjs.map +1 -1
- package/dist/functions/gen-index.d.mts +4 -4
- package/dist/functions/gen-index.d.mts.map +1 -1
- package/dist/functions/gen-index.mjs +5 -4
- package/dist/functions/gen-index.mjs.map +1 -1
- package/dist/functions/index.mjs +2 -1
- package/dist/functions/index.mjs.map +1 -1
- package/dist/functions/should-run.mjs.map +1 -1
- package/dist/functions/workspace-utils/execute-parallel.d.mts +25 -0
- package/dist/functions/workspace-utils/execute-parallel.d.mts.map +1 -0
- package/dist/functions/workspace-utils/execute-parallel.mjs +162 -0
- package/dist/functions/workspace-utils/execute-parallel.mjs.map +1 -0
- package/dist/functions/workspace-utils/get-workspace-packages.d.mts +1 -29
- package/dist/functions/workspace-utils/get-workspace-packages.d.mts.map +1 -1
- package/dist/functions/workspace-utils/get-workspace-packages.mjs +11 -163
- package/dist/functions/workspace-utils/get-workspace-packages.mjs.map +1 -1
- package/dist/functions/workspace-utils/index.d.mts +2 -0
- package/dist/functions/workspace-utils/index.d.mts.map +1 -1
- package/dist/functions/workspace-utils/index.mjs +2 -1
- package/dist/functions/workspace-utils/index.mjs.map +1 -1
- package/dist/functions/workspace-utils/run-cmd-in-parallel.d.mts.map +1 -1
- package/dist/functions/workspace-utils/run-cmd-in-parallel.mjs +2 -1
- package/dist/functions/workspace-utils/run-cmd-in-parallel.mjs.map +1 -1
- package/dist/functions/workspace-utils/run-cmd-in-stages.d.mts.map +1 -1
- package/dist/functions/workspace-utils/run-cmd-in-stages.mjs +2 -1
- package/dist/functions/workspace-utils/run-cmd-in-stages.mjs.map +1 -1
- package/dist/functions/workspace-utils/types.d.mts +7 -0
- package/dist/functions/workspace-utils/types.d.mts.map +1 -0
- package/dist/functions/workspace-utils/types.mjs +2 -0
- package/dist/functions/workspace-utils/types.mjs.map +1 -0
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -14
- package/src/functions/gen-index.mts +10 -7
- package/src/functions/workspace-utils/execute-parallel.mts +247 -0
- package/src/functions/workspace-utils/get-workspace-packages.mts +12 -251
- package/src/functions/workspace-utils/index.mts +2 -0
- package/src/functions/workspace-utils/run-cmd-in-parallel.mts +2 -4
- package/src/functions/workspace-utils/run-cmd-in-stages.mts +2 -4
- package/src/functions/workspace-utils/types.mts +7 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
|
-
import {
|
|
3
|
-
import { Result, isNotUndefined, pipe, isRecord, hasKey, isString, createPromise } from 'ts-data-forge';
|
|
2
|
+
import { Result, Json, isNotUndefined, isRecord, hasKey, isString } from 'ts-data-forge';
|
|
4
3
|
import '../../node-global.mjs';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -18,19 +17,24 @@ const getWorkspacePackages = async (rootPackageJsonDir) => {
|
|
|
18
17
|
const matches = await glob(pattern, {
|
|
19
18
|
cwd: rootPackageJsonDir,
|
|
20
19
|
ignore: ['**/node_modules/**'],
|
|
20
|
+
onlyDirectories: true,
|
|
21
|
+
absolute: true,
|
|
21
22
|
});
|
|
22
23
|
const packageJsonList = await Promise.all(matches.map(async (match) => {
|
|
23
|
-
const
|
|
24
|
-
const result = await Result.fromPromise(fs.readFile(
|
|
24
|
+
const maybePackagePath = path.join(match, 'package.json');
|
|
25
|
+
const result = await Result.fromPromise(fs.readFile(maybePackagePath, 'utf8'));
|
|
25
26
|
if (Result.isErr(result))
|
|
26
27
|
return undefined;
|
|
27
|
-
|
|
28
|
+
const parsed = Json.parse(result.value);
|
|
29
|
+
if (Result.isErr(parsed))
|
|
30
|
+
return undefined;
|
|
31
|
+
return [maybePackagePath, parsed.value];
|
|
28
32
|
}));
|
|
29
33
|
const packageInfos = await Promise.all(packageJsonList
|
|
30
34
|
.filter(isNotUndefined)
|
|
31
35
|
.map(([packagePath, packageJson]) => ({
|
|
32
36
|
name: getStrFromJsonValue(packageJson, 'name'),
|
|
33
|
-
path: packagePath,
|
|
37
|
+
path: path.dirname(packagePath),
|
|
34
38
|
packageJson,
|
|
35
39
|
dependencies: {
|
|
36
40
|
...getKeyValueRecordFromJsonValue(packageJson, 'dependencies'),
|
|
@@ -64,162 +68,6 @@ const getKeyValueRecordFromJsonValue = (value, key) => {
|
|
|
64
68
|
const entries = Object.entries(obj).filter((entry) => isString(entry[1]));
|
|
65
69
|
return Object.fromEntries(entries);
|
|
66
70
|
};
|
|
67
|
-
/**
|
|
68
|
-
* Builds a dependency graph from the given packages, mapping each package name
|
|
69
|
-
* to its internal workspace dependencies.
|
|
70
|
-
* @param packages - Array of Package objects to analyze
|
|
71
|
-
* @returns A readonly map where keys are package names and values are arrays of their dependency package names
|
|
72
|
-
*/
|
|
73
|
-
const buildDependencyGraph = (packages) => {
|
|
74
|
-
const packageMap = new Map(packages.map((p) => [p.name, p]));
|
|
75
|
-
const graph = new Map();
|
|
76
|
-
for (const pkg of packages) {
|
|
77
|
-
const deps = Object.keys(pkg.dependencies).filter((depName) => packageMap.has(depName));
|
|
78
|
-
graph.set(pkg.name, deps);
|
|
79
|
-
}
|
|
80
|
-
return graph;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Performs a topological sort on packages based on their dependencies,
|
|
84
|
-
* ensuring dependencies are ordered before their dependents.
|
|
85
|
-
* @param packages - Array of Package objects to sort
|
|
86
|
-
* @returns An array of packages in dependency order (dependencies first)
|
|
87
|
-
*/
|
|
88
|
-
const topologicalSortPackages = (packages) => {
|
|
89
|
-
const graph = buildDependencyGraph(packages);
|
|
90
|
-
const visited = new Set();
|
|
91
|
-
const result = [];
|
|
92
|
-
const packageMap = new Map(packages.map((p) => [p.name, p]));
|
|
93
|
-
const visit = (pkgName) => {
|
|
94
|
-
if (visited.has(pkgName))
|
|
95
|
-
return;
|
|
96
|
-
visited.add(pkgName);
|
|
97
|
-
const deps = graph.get(pkgName) ?? [];
|
|
98
|
-
for (const dep of deps) {
|
|
99
|
-
visit(dep);
|
|
100
|
-
}
|
|
101
|
-
result.push(pkgName);
|
|
102
|
-
};
|
|
103
|
-
for (const pkg of packages) {
|
|
104
|
-
visit(pkg.name);
|
|
105
|
-
}
|
|
106
|
-
return result
|
|
107
|
-
.map((pkgName) => packageMap.get(pkgName))
|
|
108
|
-
.filter(isNotUndefined);
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Executes a npm script in a specific package directory.
|
|
112
|
-
* @param pkg - The package object containing path and metadata
|
|
113
|
-
* @param scriptName - The name of the npm script to execute
|
|
114
|
-
* @param options - Configuration options
|
|
115
|
-
* @param options.prefix - Whether to prefix output with package name (default: true)
|
|
116
|
-
* @returns A promise that resolves to execution result with exit code or skipped flag
|
|
117
|
-
*/
|
|
118
|
-
const executeScript = (pkg, scriptName, { prefix = true } = {}) => pipe(createPromise((resolve, reject) => {
|
|
119
|
-
const packageJsonScripts = isRecord(pkg.packageJson) && isRecord(pkg.packageJson['scripts'])
|
|
120
|
-
? pkg.packageJson['scripts']
|
|
121
|
-
: {};
|
|
122
|
-
const hasScript = hasKey(packageJsonScripts, scriptName);
|
|
123
|
-
if (!hasScript) {
|
|
124
|
-
resolve({ skipped: true });
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const prefixStr = prefix ? `[${pkg.name}] ` : '';
|
|
128
|
-
const proc = spawn('npm', ['run', scriptName], {
|
|
129
|
-
cwd: pkg.path,
|
|
130
|
-
shell: true,
|
|
131
|
-
stdio: 'pipe',
|
|
132
|
-
});
|
|
133
|
-
proc.stdout.on('data', (data) => {
|
|
134
|
-
process.stdout.write(prefixStr + data.toString());
|
|
135
|
-
});
|
|
136
|
-
proc.stderr.on('data', (data) => {
|
|
137
|
-
process.stderr.write(prefixStr + data.toString());
|
|
138
|
-
});
|
|
139
|
-
proc.on('close', (code) => {
|
|
140
|
-
if (code === 0) {
|
|
141
|
-
resolve({ code });
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
reject(new Error(`${pkg.name} exited with code ${code}`));
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
proc.on('error', reject);
|
|
148
|
-
})).map((result) => result.then(Result.mapErr((err) => {
|
|
149
|
-
const errorMessage = err instanceof Error
|
|
150
|
-
? err.message
|
|
151
|
-
: isRecord(err) && hasKey(err, 'message')
|
|
152
|
-
? (err.message?.toString() ?? 'Unknown error message')
|
|
153
|
-
: 'Unknown error';
|
|
154
|
-
console.error(`\nError in ${pkg.name}:`, errorMessage);
|
|
155
|
-
return err instanceof Error ? err : new Error(errorMessage);
|
|
156
|
-
}))).value;
|
|
157
|
-
/**
|
|
158
|
-
* Executes a npm script across multiple packages in parallel with a concurrency limit.
|
|
159
|
-
* @param packages - Array of Package objects to execute the script in
|
|
160
|
-
* @param scriptName - The name of the npm script to execute
|
|
161
|
-
* @param concurrency - Maximum number of packages to process simultaneously (default: 3)
|
|
162
|
-
* @returns A promise that resolves to an array of execution results
|
|
163
|
-
*/
|
|
164
|
-
const executeParallel = async (packages, scriptName, concurrency = 3) => {
|
|
165
|
-
const mut_resultPromises = [];
|
|
166
|
-
const executing = new Set();
|
|
167
|
-
for (const pkg of packages) {
|
|
168
|
-
const promise = executeScript(pkg, scriptName);
|
|
169
|
-
mut_resultPromises.push(promise);
|
|
170
|
-
const wrappedPromise = promise.finally(() => {
|
|
171
|
-
executing.delete(wrappedPromise);
|
|
172
|
-
});
|
|
173
|
-
executing.add(wrappedPromise);
|
|
174
|
-
// If we reach concurrency limit, wait for one to finish
|
|
175
|
-
if (executing.size >= concurrency) {
|
|
176
|
-
// eslint-disable-next-line no-await-in-loop
|
|
177
|
-
await Promise.race(executing);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return Promise.all(mut_resultPromises);
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Executes a npm script across packages in dependency order stages.
|
|
184
|
-
* Packages are grouped into stages where each stage contains packages whose
|
|
185
|
-
* dependencies have been completed in previous stages.
|
|
186
|
-
* @param packages - Array of Package objects to execute the script in
|
|
187
|
-
* @param scriptName - The name of the npm script to execute
|
|
188
|
-
* @param concurrency - Maximum number of packages to process simultaneously within each stage (default: 3)
|
|
189
|
-
* @returns A promise that resolves when all stages are complete
|
|
190
|
-
*/
|
|
191
|
-
const executeStages = async (packages, scriptName, concurrency = 3) => {
|
|
192
|
-
const sorted = topologicalSortPackages(packages);
|
|
193
|
-
const stages = [];
|
|
194
|
-
const completed = new Set();
|
|
195
|
-
const dependencyGraph = buildDependencyGraph(packages);
|
|
196
|
-
while (completed.size < sorted.length) {
|
|
197
|
-
const stage = [];
|
|
198
|
-
for (const pkg of sorted) {
|
|
199
|
-
if (completed.has(pkg.name))
|
|
200
|
-
continue;
|
|
201
|
-
const deps = dependencyGraph.get(pkg.name) ?? [];
|
|
202
|
-
const depsCompleted = deps.every((dep) => completed.has(dep));
|
|
203
|
-
if (depsCompleted) {
|
|
204
|
-
stage.push(pkg);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (stage.length === 0) {
|
|
208
|
-
throw new Error('Circular dependency detected');
|
|
209
|
-
}
|
|
210
|
-
stages.push(stage);
|
|
211
|
-
for (const pkg of stage)
|
|
212
|
-
completed.add(pkg.name);
|
|
213
|
-
}
|
|
214
|
-
console.log(`\nExecuting ${scriptName} in ${stages.length} stages...\n`);
|
|
215
|
-
for (const [i, stage] of stages.entries()) {
|
|
216
|
-
if (stage.length > 0) {
|
|
217
|
-
console.log(`Stage ${i + 1}: ${stage.map((p) => p.name).join(', ')}`);
|
|
218
|
-
// eslint-disable-next-line no-await-in-loop
|
|
219
|
-
await executeParallel(stage, scriptName, concurrency);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
71
|
|
|
224
|
-
export {
|
|
72
|
+
export { getWorkspacePackages };
|
|
225
73
|
//# sourceMappingURL=get-workspace-packages.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-workspace-packages.mjs","sources":["../../../src/functions/workspace-utils/get-workspace-packages.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"get-workspace-packages.mjs","sources":["../../../src/functions/workspace-utils/get-workspace-packages.mts"],"sourcesContent":[null],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/index.mts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/index.mts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { executeParallel, executeStages
|
|
1
|
+
export { executeParallel, executeStages } from './execute-parallel.mjs';
|
|
2
|
+
export { getWorkspacePackages } from './get-workspace-packages.mjs';
|
|
2
3
|
export { runCmdInParallelAcrossWorkspaces } from './run-cmd-in-parallel.mjs';
|
|
3
4
|
export { runCmdInStagesAcrossWorkspaces } from './run-cmd-in-stages.mjs';
|
|
4
5
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cmd-in-parallel.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/run-cmd-in-parallel.mts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"run-cmd-in-parallel.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/run-cmd-in-parallel.mts"],"names":[],"mappings":";AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,gCAAgC,GAAU,mEAKpD,QAAQ,CAAC;IACV,kBAAkB,EAAE,MAAM,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3D,CAAC,KAAG,OAAO,CAAC,IAAI,CAkBhB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
|
-
import {
|
|
2
|
+
import { executeParallel } from './execute-parallel.mjs';
|
|
3
|
+
import { getWorkspacePackages } from './get-workspace-packages.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Executes a npm script command across all workspace packages in parallel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cmd-in-parallel.mjs","sources":["../../../src/functions/workspace-utils/run-cmd-in-parallel.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-cmd-in-parallel.mjs","sources":["../../../src/functions/workspace-utils/run-cmd-in-parallel.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;AAQG;AACI,MAAM,gCAAgC,GAAG,OAAO,EACrD,kBAAkB,EAClB,GAAG,EACH,WAAW,GAAG,CAAC,EACf,sBAAsB,GAMtB,KAAmB;AACnB,IAAA,IAAI;AACF,QAAA,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,kBAAkB,CAAC;AAE/D,QAAA,MAAM,gBAAgB,GACpB,sBAAsB,KAAK;AACzB,cAAE;AACF,cAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEhE,MAAM,eAAe,CAAC,gBAAgB,EAAE,GAAG,EAAE,WAAW,CAAC;AACzD,QAAA,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,CAAA,uBAAA,CAAyB,CAAC;IAClD;IAAE,OAAO,GAAG,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CACX,CAAA,IAAA,EAAO,GAAG,CAAA,QAAA,CAAU,EACpB,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC7D;AACD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cmd-in-stages.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/run-cmd-in-stages.mts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"run-cmd-in-stages.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/run-cmd-in-stages.mts"],"names":[],"mappings":";AAKA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,8BAA8B,GAAU,mEAKlD,QAAQ,CAAC;IACV,kBAAkB,EAAE,MAAM,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3D,CAAC,KAAG,OAAO,CAAC,IAAI,CAkBhB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env tsx
|
|
2
|
-
import {
|
|
2
|
+
import { executeStages } from './execute-parallel.mjs';
|
|
3
|
+
import { getWorkspacePackages } from './get-workspace-packages.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Executes a npm script command across all workspace packages in dependency order stages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cmd-in-stages.mjs","sources":["../../../src/functions/workspace-utils/run-cmd-in-stages.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-cmd-in-stages.mjs","sources":["../../../src/functions/workspace-utils/run-cmd-in-stages.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;;;;;;;;;;AAUG;AACI,MAAM,8BAA8B,GAAG,OAAO,EACnD,kBAAkB,EAClB,GAAG,EACH,WAAW,GAAG,CAAC,EACf,sBAAsB,GAMtB,KAAmB;AACnB,IAAA,IAAI;AACF,QAAA,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,kBAAkB,CAAC;AAE/D,QAAA,MAAM,gBAAgB,GACpB,sBAAsB,KAAK;AACzB,cAAE;AACF,cAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEhE,MAAM,aAAa,CAAC,gBAAgB,EAAE,GAAG,EAAE,WAAW,CAAC;AACvD,QAAA,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,CAAA,uBAAA,CAAyB,CAAC;IAClD;IAAE,OAAO,GAAG,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CACX,CAAA,IAAA,EAAO,GAAG,CAAA,QAAA,CAAU,EACpB,GAAG,YAAY,KAAK,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC7D;AACD,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjB;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/functions/workspace-utils/types.mts"],"names":[],"mappings":"AACA,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,8 @@ export { $ } from './functions/exec-async.mjs';
|
|
|
6
6
|
export { formatDiffFrom, formatFiles, formatFilesList, formatUntracked } from './functions/format.mjs';
|
|
7
7
|
export { genIndex } from './functions/gen-index.mjs';
|
|
8
8
|
export { checkShouldRunTypeChecks } from './functions/should-run.mjs';
|
|
9
|
-
export { executeParallel, executeStages
|
|
9
|
+
export { executeParallel, executeStages } from './functions/workspace-utils/execute-parallel.mjs';
|
|
10
|
+
export { getWorkspacePackages } from './functions/workspace-utils/get-workspace-packages.mjs';
|
|
10
11
|
export { runCmdInParallelAcrossWorkspaces } from './functions/workspace-utils/run-cmd-in-parallel.mjs';
|
|
11
12
|
export { runCmdInStagesAcrossWorkspaces } from './functions/workspace-utils/run-cmd-in-stages.mjs';
|
|
12
13
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-repo-utils",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript"
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"build": "
|
|
34
|
-
"check-all": "
|
|
35
|
-
"check:ext": "
|
|
33
|
+
"build": "tsx ./scripts/cmd/build.mjs",
|
|
34
|
+
"check-all": "tsx ./scripts/cmd/check-all.mjs",
|
|
35
|
+
"check:ext": "tsx ./scripts/cmd/check-ext.mjs",
|
|
36
36
|
"cspell": "cspell \"**\" --gitignore --gitignore-root ./ --no-progress",
|
|
37
|
-
"doc": "
|
|
38
|
-
"fmt": "
|
|
37
|
+
"doc": "tsx ./scripts/cmd/gen-docs.mjs",
|
|
38
|
+
"fmt": "tsx ./scripts/cmd/fmt-diff.mjs",
|
|
39
39
|
"fmt:full": "prettier --write .",
|
|
40
|
-
"gi": "
|
|
40
|
+
"gi": "tsx ./scripts/cmd/gi.mjs",
|
|
41
41
|
"lint": "eslint .",
|
|
42
42
|
"lint:fix": "eslint . --fix",
|
|
43
43
|
"md": "markdownlint-cli2",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"tscw": "tsc --noEmit --watch",
|
|
51
51
|
"type-check": "tsc --noEmit",
|
|
52
52
|
"update-packages": "npx npm-check-updates -u --install always --reject @types/node",
|
|
53
|
-
"z:node-esm": "node --import tsx/esm",
|
|
54
53
|
"z:vitest": "vitest --config ./configs/vitest.config.ts"
|
|
55
54
|
},
|
|
56
55
|
"dependencies": {
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"ts-data-forge": "^2.0.0"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@eslint/js": "^9.
|
|
63
|
+
"@eslint/js": "^9.31.0",
|
|
65
64
|
"@rollup/plugin-replace": "^6.0.2",
|
|
66
65
|
"@rollup/plugin-strip": "^3.0.4",
|
|
67
66
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
@@ -75,21 +74,21 @@
|
|
|
75
74
|
"@types/node": "^20.19.4",
|
|
76
75
|
"@vitest/coverage-v8": "^3.2.4",
|
|
77
76
|
"@vitest/ui": "^3.2.4",
|
|
78
|
-
"conventional-changelog-conventionalcommits": "^9.
|
|
79
|
-
"cspell": "^9.1.
|
|
77
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
78
|
+
"cspell": "^9.1.3",
|
|
80
79
|
"dedent": "^1.6.0",
|
|
81
80
|
"eslint": "^9.30.1",
|
|
82
81
|
"markdownlint-cli2": "^0.18.1",
|
|
83
82
|
"prettier-plugin-organize-imports": "^4.1.0",
|
|
84
83
|
"prettier-plugin-packagejson": "^2.5.18",
|
|
85
|
-
"rollup": "^4.
|
|
86
|
-
"semantic-release": "^24.2.
|
|
84
|
+
"rollup": "^4.45.0",
|
|
85
|
+
"semantic-release": "^24.2.7",
|
|
87
86
|
"ts-type-forge": "^2.0.3",
|
|
88
87
|
"tsx": "^4.20.3",
|
|
89
88
|
"typedoc": "^0.28.7",
|
|
90
89
|
"typedoc-plugin-markdown": "^4.7.0",
|
|
91
90
|
"typescript": "^5.8.3",
|
|
92
|
-
"typescript-eslint": "^8.
|
|
91
|
+
"typescript-eslint": "^8.36.0",
|
|
93
92
|
"vitest": "^3.2.4"
|
|
94
93
|
},
|
|
95
94
|
"engines": {
|
|
@@ -7,6 +7,9 @@ import { assertPathExists } from './assert-path-exists.mjs';
|
|
|
7
7
|
* Configuration for index file generation.
|
|
8
8
|
*/
|
|
9
9
|
export type GenIndexConfig = DeepReadonly<{
|
|
10
|
+
/** Command to run for formatting generated files (default: 'npm run fmt') */
|
|
11
|
+
formatCommand: string;
|
|
12
|
+
|
|
10
13
|
/** Target directories to generate index files for (string or array of strings) */
|
|
11
14
|
targetDirectory: string | string[];
|
|
12
15
|
|
|
@@ -18,18 +21,16 @@ export type GenIndexConfig = DeepReadonly<{
|
|
|
18
21
|
|
|
19
22
|
/** Glob patterns of files to exclude from exports (default: excludes .d.* and .test.* files) */
|
|
20
23
|
excludePatterns?: string[];
|
|
24
|
+
|
|
25
|
+
silent?: boolean;
|
|
21
26
|
}>;
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* Generates index.mts files recursively in `config.targetDirectory`.
|
|
25
30
|
* @param config - Configuration for index file generation
|
|
26
|
-
* @param options - Additional options
|
|
27
31
|
* @throws Error if any step fails.
|
|
28
32
|
*/
|
|
29
|
-
export const genIndex = async (
|
|
30
|
-
config: GenIndexConfig,
|
|
31
|
-
options?: Readonly<{ silent?: boolean }>,
|
|
32
|
-
): Promise<void> => {
|
|
33
|
+
export const genIndex = async (config: GenIndexConfig): Promise<void> => {
|
|
33
34
|
echo('Starting index file generation...\n');
|
|
34
35
|
|
|
35
36
|
// Merge config with defaults
|
|
@@ -60,8 +61,8 @@ export const genIndex = async (
|
|
|
60
61
|
|
|
61
62
|
// Step 3: Format generated files
|
|
62
63
|
echo('3. Formatting generated files...');
|
|
63
|
-
const fmtResult = await $(
|
|
64
|
-
silent:
|
|
64
|
+
const fmtResult = await $(filledConfig.formatCommand, {
|
|
65
|
+
silent: filledConfig.silent,
|
|
65
66
|
});
|
|
66
67
|
if (Result.isErr(fmtResult)) {
|
|
67
68
|
throw new Error(`Formatting failed: ${fmtResult.value.message}`);
|
|
@@ -80,6 +81,7 @@ const fillConfig = (config: GenIndexConfig): DeepRequired<GenIndexConfig> => {
|
|
|
80
81
|
const exportExtension = config.exportExtension ?? '.mjs'; // For ESM imports, .mts resolves to .mjs
|
|
81
82
|
|
|
82
83
|
return {
|
|
84
|
+
formatCommand: config.formatCommand,
|
|
83
85
|
targetDirectory: config.targetDirectory,
|
|
84
86
|
sourceExtension,
|
|
85
87
|
exportExtension,
|
|
@@ -87,6 +89,7 @@ const fillConfig = (config: GenIndexConfig): DeepRequired<GenIndexConfig> => {
|
|
|
87
89
|
`*.d${sourceExtension}`,
|
|
88
90
|
`*.test${sourceExtension}`,
|
|
89
91
|
],
|
|
92
|
+
silent: config.silent ?? false,
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
95
|
|