neutrinos-cli 2.0.0-beta.13 → 2.0.0-beta.14

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.
@@ -8,6 +8,7 @@ import { readLocalCliVersion } from './local-cli.js';
8
8
  import { migrations } from './migrations/index.js';
9
9
  import { compareVersions } from './migrations/version-compare.js';
10
10
  import { failed } from './logger.js';
11
+ import { doctor } from '../commands/doctor.js';
11
12
  const SYMBOLS = {
12
13
  pass: greenBright('✔'),
13
14
  warn: yellowBright('⚠'),
@@ -105,5 +106,8 @@ export function runMigration(wsPath, opts) {
105
106
  const lastVersion = applicable[applicable.length - 1].targetVersion;
106
107
  gitCommit(wsPath, lastVersion);
107
108
  }
108
- _log(greenBright(`\n${prefix}Migration complete.`) + ' Run "neutrinos doctor" to verify.\n');
109
+ _log(greenBright(`\n${prefix}Migration complete.\n`));
110
+ if (!dryRun) {
111
+ doctor(wsPath, {});
112
+ }
109
113
  }
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
+ import ts from 'typescript';
3
4
  export const migration = {
4
5
  targetVersion: '2.0.0-beta.7',
5
6
  description: 'Bump tsconfig target to ESNext, replace deprecated esbuild with oxc in Storybook config',
@@ -11,30 +12,31 @@ export const migration = {
11
12
  results.push({ name: 'tsconfig.json', status: 'skip', message: 'File not found' });
12
13
  }
13
14
  else {
14
- const raw = readFileSync(tsconfigPath, 'utf-8');
15
- const tsconfig = JSON.parse(raw);
16
- const opts = tsconfig.compilerOptions ?? {};
17
- let changed = false;
18
- if (opts['target'] !== 'ESNext') {
19
- opts['target'] = 'ESNext';
20
- changed = true;
15
+ // Use ts.readConfigFile to parse tsconfig (handles comments and trailing commas)
16
+ const { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
17
+ if (error || !config) {
18
+ results.push({ name: 'tsconfig.json', status: 'warn', message: 'Could not parse tsconfig.json' });
21
19
  }
22
- if (Array.isArray(opts['lib'])) {
23
- const lib = opts['lib'];
24
- const updated = lib.map((l) => (/^ES\d{4}$/i.test(l) ? 'ESNext' : l));
25
- if (JSON.stringify(updated) !== JSON.stringify(lib)) {
26
- opts['lib'] = updated;
20
+ else {
21
+ const opts = config.compilerOptions ?? {};
22
+ let content = readFileSync(tsconfigPath, 'utf-8');
23
+ let changed = false;
24
+ if (opts.target && opts.target !== 'ESNext') {
25
+ content = content.replace(/"target"\s*:\s*"[^"]*"/, '"target": "ESNext"');
27
26
  changed = true;
28
27
  }
29
- }
30
- if (changed) {
31
- tsconfig.compilerOptions = opts;
32
- if (!dryRun)
33
- writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 4) + '\n');
34
- results.push({ name: 'tsconfig.json', status: 'pass', message: 'Updated target and lib to ESNext' });
35
- }
36
- else {
37
- results.push({ name: 'tsconfig.json', status: 'skip', message: 'Already at ESNext' });
28
+ if (Array.isArray(opts.lib) && opts.lib.some((l) => /^ES\d{4}$/i.test(l))) {
29
+ content = content.replace(/"lib"\s*:\s*\[([^\]]*)\]/, (match) => match.replace(/"ES\d{4}"/g, '"ESNext"'));
30
+ changed = true;
31
+ }
32
+ if (changed) {
33
+ if (!dryRun)
34
+ writeFileSync(tsconfigPath, content);
35
+ results.push({ name: 'tsconfig.json', status: 'pass', message: 'Updated target and lib to ESNext' });
36
+ }
37
+ else {
38
+ results.push({ name: 'tsconfig.json', status: 'skip', message: 'Already at ESNext' });
39
+ }
38
40
  }
39
41
  }
40
42
  // Step 2: Replace deprecated esbuild config with build.keepNames in .storybook/main.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutrinos-cli",
3
- "version": "2.0.0-beta.13",
3
+ "version": "2.0.0-beta.14",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "neutrinos": "./dist/bin/cli.js"