@emeryld/manager 1.4.9 → 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 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
- if (pkg.name)
3
- return pkg.name;
4
- if (!pkg.relativeDir || pkg.relativeDir === '.')
2
+ const dir = pkg.relativeDir ?? '';
3
+ if (dir && dir !== '.')
4
+ return `./${dir}`;
5
+ if (dir === '.')
5
6
  return '.';
6
- return `./${pkg.relativeDir}`;
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
- const TEST_SCENARIO = {
212
- allArgs: ['test'],
213
- allMessage: 'Running tests for all packages…',
214
- singleArgs: (pkg) => [
215
- 'run',
216
- '--filter',
217
- pkg.dirName,
218
- 'test',
219
- ],
220
- singleMessage: 'Running tests…',
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
- await runLifecycleScenario(undefined, TEST_SCENARIO);
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 runLifecycleScenario(pkg, TEST_SCENARIO);
340
+ await runPackageTest(pkg);
331
341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/manager",
3
- "version": "1.4.9",
3
+ "version": "1.4.11",
4
4
  "description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
5
5
  "license": "MIT",
6
6
  "type": "module",