@naturalcycles/dev-lib 20.18.2 → 20.19.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.
@@ -47,19 +47,19 @@ export function defineVitestConfig(config, cwd) {
47
47
 
48
48
  const { silent, pool, maxWorkers, isolate } = mergedConfig.test
49
49
 
50
- console.log({
51
- testType,
52
- silent,
53
- isCI,
54
- runsInIDE,
55
- // include,
56
- // exclude,
57
- pool,
58
- isolate,
59
- maxWorkers,
60
- // setupFiles,
61
- // cwd,
62
- })
50
+ // In workspace mode, cwd differs from process.cwd() (which is the monorepo root)
51
+ const isWorkspaceMode = cwd && process.cwd() !== cwd
52
+ if (!isWorkspaceMode) {
53
+ console.log({
54
+ testType,
55
+ silent,
56
+ isCI,
57
+ runsInIDE,
58
+ pool,
59
+ isolate,
60
+ maxWorkers,
61
+ })
62
+ }
63
63
 
64
64
  return mergedConfig
65
65
  }
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { select, Separator } from '@inquirer/prompts';
3
2
  import { _by } from '@naturalcycles/js-lib/array/array.util.js';
4
3
  import { _assert } from '@naturalcycles/js-lib/error/assert.js';
5
4
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
@@ -9,7 +8,6 @@ import { runCommitlint } from '../commitlint.js';
9
8
  import { eslintAll, lintAllCommand, lintStagedCommand, requireOxlintConfig, runBiome, runOxlint, runPrettier, stylelintAll, } from '../lint.util.js';
10
9
  import { runTest } from '../test.util.js';
11
10
  const commands = [
12
- new Separator(), // build
13
11
  { name: 'check', fn: check, desc: '"Run all possible checks": lint, typecheck, then test.' },
14
12
  { name: 'bt', fn: bt, desc: 'Build & Test: run "typecheck" (via oxlint) and then "test".' },
15
13
  {
@@ -42,7 +40,6 @@ const commands = [
42
40
  fn: cleanBuild,
43
41
  desc: 'Cleans ./dist, then runs the build.',
44
42
  },
45
- new Separator(), // test
46
43
  { name: 'test', fn: runTest, desc: 'Run vitest for *.test.ts files.' },
47
44
  {
48
45
  name: 'test-integration',
@@ -59,7 +56,6 @@ const commands = [
59
56
  fn: () => runTest({ leaks: true }),
60
57
  desc: 'Run vitest --detectLeaks for *.test.ts files.',
61
58
  },
62
- new Separator(), // lint
63
59
  {
64
60
  name: 'lint',
65
61
  fn: lintAllCommand,
@@ -107,7 +103,6 @@ const commands = [
107
103
  },
108
104
  { name: 'stylelint-no-fix', cliOnly: true, fn: () => stylelintAll(false) },
109
105
  { name: 'commitlint', fn: runCommitlint, desc: 'Run commitlint.', cliOnly: true },
110
- new Separator(), // interactive-only
111
106
  {
112
107
  name: 'exit',
113
108
  fn: () => console.log('see you!'),
@@ -127,27 +122,31 @@ const commands = [
127
122
  // })
128
123
  // },
129
124
  ];
130
- const commandMap = _by(commands.filter(c => !(c instanceof Separator)), c => c.name);
125
+ const commandMap = _by(commands, c => c.name);
131
126
  const { CI } = process.env;
132
127
  runScript(async () => {
133
128
  let cmd = process.argv.find(s => commandMap[s] && !commandMap[s].interactiveOnly);
134
129
  if (!cmd) {
135
130
  // interactive mode
136
131
  _assert(!CI, 'interactive dev-lib should not be run in CI');
137
- cmd = await select({
132
+ const { default: prompts } = await import('prompts');
133
+ const response = await prompts({
134
+ type: 'select',
135
+ name: 'cmd',
138
136
  message: 'Select command',
139
- pageSize: 30,
137
+ // @ts-expect-error types are wrong
138
+ optionsPerPage: 30,
140
139
  choices: commands
141
- .filter(c => c instanceof Separator || !c.cliOnly)
142
- .map(c => {
143
- if (c instanceof Separator)
144
- return c;
145
- return {
146
- value: c.name,
147
- description: c.desc,
148
- };
149
- }),
140
+ .filter(c => !c.cliOnly)
141
+ .map(c => ({
142
+ title: c.name,
143
+ value: c.name,
144
+ description: c.desc,
145
+ })),
150
146
  });
147
+ cmd = response.cmd;
148
+ if (!cmd)
149
+ return; // user cancelled
151
150
  }
152
151
  await commandMap[cmd].fn();
153
152
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "20.18.2",
4
+ "version": "20.19.0",
5
5
  "dependencies": {
6
6
  "@biomejs/biome": "^2",
7
7
  "@eslint/js": "^9",
8
- "@inquirer/prompts": "^8",
8
+ "prompts": "^2",
9
9
  "@naturalcycles/js-lib": "^15",
10
10
  "@naturalcycles/nodejs-lib": "^15",
11
11
  "@vitest/coverage-v8": "^4",
@@ -42,7 +42,8 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/mitm": "^1",
45
- "@types/node": "^25"
45
+ "@types/node": "^25",
46
+ "@types/prompts": "^2"
46
47
  },
47
48
  "exports": {
48
49
  "./cfg/": "./cfg/",