@emeryld/manager 1.4.10 → 1.4.11
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/menu.js +2 -2
- package/dist/utils/package-filter.js +5 -4
- package/dist/utils/run.js +16 -0
- package/dist/workspace.js +24 -14
- package/package.json +1 -1
package/dist/menu.js
CHANGED
|
@@ -66,7 +66,7 @@ function makeManagerStepEntries(targets, packages, state) {
|
|
|
66
66
|
if (targets.length === 1)
|
|
67
67
|
await testSingle(targets[0]);
|
|
68
68
|
else
|
|
69
|
-
await testAll();
|
|
69
|
+
await testAll(targets);
|
|
70
70
|
state.lastStep = 'test';
|
|
71
71
|
},
|
|
72
72
|
},
|
|
@@ -120,7 +120,7 @@ function makeManagerStepEntries(targets, packages, state) {
|
|
|
120
120
|
if (targets.length === 1)
|
|
121
121
|
await testSingle(targets[0]);
|
|
122
122
|
else
|
|
123
|
-
await testAll();
|
|
123
|
+
await testAll(targets);
|
|
124
124
|
if (targets.length === 1)
|
|
125
125
|
await buildSingle(targets[0]);
|
|
126
126
|
else
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export function packageFilterArg(pkg) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const dir = pkg.relativeDir ?? '';
|
|
3
|
+
if (dir && dir !== '.')
|
|
4
|
+
return `./${dir}`;
|
|
5
|
+
if (dir === '.')
|
|
5
6
|
return '.';
|
|
6
|
-
return
|
|
7
|
+
return pkg.name ?? '.';
|
|
7
8
|
}
|
package/dist/utils/run.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
// src/utils/run.js
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
|
+
import { colors, logGlobal } from './log.js';
|
|
3
4
|
// Always execute commands from the workspace where the CLI is invoked.
|
|
4
5
|
// This makes installs from node_modules behave correctly instead of
|
|
5
6
|
// running in the package's own directory.
|
|
6
7
|
export const rootDir = process.cwd();
|
|
8
|
+
function describeArgs(args) {
|
|
9
|
+
const normalized = args.map((arg) => {
|
|
10
|
+
if (!/\s/.test(arg))
|
|
11
|
+
return arg;
|
|
12
|
+
return `"${arg.replace(/"/g, '\\"')}"`;
|
|
13
|
+
});
|
|
14
|
+
return normalized.join(' ');
|
|
15
|
+
}
|
|
16
|
+
function describeCommand(command, args) {
|
|
17
|
+
const argList = describeArgs(args);
|
|
18
|
+
if (!argList)
|
|
19
|
+
return colors.bold(command);
|
|
20
|
+
return `${colors.bold(command)} ${colors.dim(argList)}`;
|
|
21
|
+
}
|
|
7
22
|
export function run(command, args, options = {}) {
|
|
23
|
+
logGlobal(`Executing ${describeCommand(command, args)}`);
|
|
8
24
|
return new Promise((resolve, reject) => {
|
|
9
25
|
const child = spawn(command, args, {
|
|
10
26
|
cwd: rootDir,
|
package/dist/workspace.js
CHANGED
|
@@ -208,17 +208,19 @@ const BUILD_SCENARIO = {
|
|
|
208
208
|
singleArgs: (pkg) => ['run', '--filter', packageFilterArg(pkg), 'build'],
|
|
209
209
|
singleMessage: 'Running build…',
|
|
210
210
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
'test',
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
211
|
+
function hasTestScript(pkg) {
|
|
212
|
+
const scripts = pkg.json?.scripts ?? {};
|
|
213
|
+
const value = scripts.test;
|
|
214
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
215
|
+
}
|
|
216
|
+
async function runPackageTest(pkg) {
|
|
217
|
+
if (!hasTestScript(pkg)) {
|
|
218
|
+
logPkg(pkg, 'No test script found; skipping.', colors.yellow);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
logPkg(pkg, 'Running tests…');
|
|
222
|
+
await run('pnpm', ['run', 'test'], { cwd: pkg.path });
|
|
223
|
+
}
|
|
222
224
|
export async function runCleanInstall() {
|
|
223
225
|
logGlobal('Cleaning workspace…', colors.cyan);
|
|
224
226
|
await run('pnpm', ['run', 'clean']);
|
|
@@ -323,9 +325,17 @@ export async function buildPackageLocally(pkg) {
|
|
|
323
325
|
logPkg(pkg, 'Building local dist before publish…');
|
|
324
326
|
await run('pnpm', ['run', 'build'], { cwd: pkg.path });
|
|
325
327
|
}
|
|
326
|
-
export async function testAll() {
|
|
327
|
-
|
|
328
|
+
export async function testAll(targets) {
|
|
329
|
+
if (!targets.length) {
|
|
330
|
+
logGlobal('No packages selected for tests.', colors.yellow);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
logGlobal(`Running tests for ${targets.length} packages…`, colors.cyan);
|
|
334
|
+
for (const pkg of targets) {
|
|
335
|
+
// eslint-disable-next-line no-await-in-loop
|
|
336
|
+
await runPackageTest(pkg);
|
|
337
|
+
}
|
|
328
338
|
}
|
|
329
339
|
export async function testSingle(pkg) {
|
|
330
|
-
await
|
|
340
|
+
await runPackageTest(pkg);
|
|
331
341
|
}
|