neutrinos-cli 2.0.0-beta.17 → 2.0.0-beta.19

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.
@@ -14,6 +14,7 @@ import { fetchRegistryVersions, versionExists } from '../utils/registry.js';
14
14
  import { spawnCli } from '../utils/spawn-cli.js';
15
15
  import { resolveCliBin } from '../utils/path-utils.js';
16
16
  import { runMigration } from '../utils/migrate-runner.js';
17
+ import { gitAddAll, gitCommit } from '../utils/workspace-git-utils.js';
17
18
  import { doctor } from './doctor.js';
18
19
  import { failed } from '../utils/logger.js';
19
20
  const exec = promisify(execCb);
@@ -70,10 +71,12 @@ export async function migrate(wsPath, opts) {
70
71
  finally {
71
72
  rmSync(tmpDir, { recursive: true, force: true });
72
73
  }
73
- // Post-migration: install deps and run doctor (only on success, not dry-run)
74
+ // Post-migration: install deps, commit, run doctor (only on success, not dry-run)
74
75
  if (exitCode === 0 && !opts.dryRun) {
75
76
  _log(yellowBright('\nInstalling dependencies...\n'));
76
77
  execSync('npm install', { cwd: wsPath, stdio: 'inherit' });
78
+ gitAddAll(wsPath);
79
+ gitCommit(wsPath, `chore: migrate workspace to neutrinos-cli@${target}`);
77
80
  doctor(wsPath, {});
78
81
  }
79
82
  process.exit(exitCode);
@@ -5,6 +5,7 @@ import { join } from 'node:path';
5
5
  import { exit } from 'node:process';
6
6
  import { done, failed, inprogress } from '../utils/logger.js';
7
7
  import { getCliPackagePath, pluginJsonPath, pluginServerTemplatesPath, templatesPath } from '../utils/path-utils.js';
8
+ import { gitInit } from '../utils/workspace-git-utils.js';
8
9
  import { prettify } from '../utils/prettify.js';
9
10
  export const createWorkspace = async (dir, name) => {
10
11
  process.on('SIGINT', () => {
@@ -64,9 +65,7 @@ const createReadme = async (dir, name) => {
64
65
  };
65
66
  const initializeGit = (dir) => {
66
67
  writeFileSync(join(dir, '.gitignore'), ['node_modules', 'dist', 'build', 'coverage'].join('\n'));
67
- execSync('git init', {
68
- cwd: dir,
69
- });
68
+ gitInit(dir);
70
69
  done('Initialized git in workspace');
71
70
  };
72
71
  const cleanUp = (dir) => {
@@ -1,10 +1,10 @@
1
- import { execSync } from 'node:child_process';
2
- import { existsSync, readFileSync } from 'node:fs';
1
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
2
  import { join } from 'node:path';
4
3
  import { bold, greenBright, red, yellowBright } from 'colorette';
5
4
  import { log as _log } from 'node:console';
6
- import { getCliPackagePath } from './path-utils.js';
5
+ import { getCliPackagePath, wsPackageJsonPath } from './path-utils.js';
7
6
  import { readLocalCliVersion } from './local-cli.js';
7
+ import { isGitRepo, isGitDirty, gitSnapshot } from './workspace-git-utils.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';
@@ -29,28 +29,6 @@ function getRunningCliVersion() {
29
29
  const { version } = JSON.parse(readFileSync(getCliPackagePath(), 'utf-8'));
30
30
  return version;
31
31
  }
32
- function isGitRepo(wsPath) {
33
- try {
34
- execSync('git rev-parse --is-inside-work-tree', { cwd: wsPath, stdio: 'pipe' });
35
- return true;
36
- }
37
- catch {
38
- return false;
39
- }
40
- }
41
- function isGitDirty(wsPath) {
42
- const output = execSync('git status --porcelain', { cwd: wsPath, encoding: 'utf-8' });
43
- return output.trim().length > 0;
44
- }
45
- function gitSnapshot(wsPath) {
46
- execSync('git init', { cwd: wsPath, stdio: 'pipe' });
47
- execSync('git add -A', { cwd: wsPath, stdio: 'pipe' });
48
- execSync('git commit -m "chore: snapshot before migration"', { cwd: wsPath, stdio: 'pipe' });
49
- }
50
- function gitCommit(wsPath, version) {
51
- execSync('git add -A', { cwd: wsPath, stdio: 'pipe' });
52
- execSync(`git commit -m "chore: migrate workspace to neutrinos-cli@${version}"`, { cwd: wsPath, stdio: 'pipe' });
53
- }
54
32
  export function runMigration(wsPath, opts) {
55
33
  const dryRun = opts.dryRun ?? false;
56
34
  if (!existsSync(join(wsPath, 'node_modules'))) {
@@ -101,9 +79,17 @@ export function runMigration(wsPath, opts) {
101
79
  process.exit(1);
102
80
  }
103
81
  }
104
- if (!dryRun) {
105
- const lastVersion = applicable[applicable.length - 1].targetVersion;
106
- gitCommit(wsPath, lastVersion);
82
+ // Always pin neutrinos-cli devDependency to the running CLI version
83
+ const pkgPath = wsPackageJsonPath(wsPath);
84
+ const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf-8'));
85
+ const currentPin = pkgJson.devDependencies?.['neutrinos-cli'];
86
+ if (currentPin !== cliVersion) {
87
+ pkgJson.devDependencies ??= {};
88
+ pkgJson.devDependencies['neutrinos-cli'] = cliVersion;
89
+ if (!dryRun) {
90
+ writeFileSync(pkgPath, JSON.stringify(pkgJson, null, 4) + '\n');
91
+ }
92
+ printResult({ name: 'neutrinos-cli version', status: 'pass', message: `Pinned to ${cliVersion}` });
107
93
  }
108
94
  _log(greenBright(`\n${prefix}Migration complete.\n`));
109
95
  }
@@ -1,6 +1,6 @@
1
1
  import { cpSync, existsSync, globSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { getCliPackagePath, templatesPath } from '../path-utils.js';
3
+ import { templatesPath } from '../path-utils.js';
4
4
  // ── Frozen dependency targets ──────────────────────────────────────
5
5
  // These are snapshot values — never change them after release.
6
6
  const TARGET_DEPS = {
@@ -68,12 +68,9 @@ export const migration = {
68
68
  results.push({ name: `dependency ${dep}`, status: 'skip', message: `Already at ${version}` });
69
69
  }
70
70
  }
71
- // Update/add devDependencies
71
+ // Update/add devDependencies (neutrinos-cli pin is handled by the runner, not here)
72
72
  pkgJson.devDependencies ??= {};
73
- // Pin neutrinos-cli to the running CLI version
74
- const cliVersion = JSON.parse(readFileSync(getCliPackagePath(), 'utf-8')).version;
75
- const allDevDeps = { 'neutrinos-cli': cliVersion, ...TARGET_DEV_DEPS };
76
- for (const [dep, version] of Object.entries(allDevDeps)) {
73
+ for (const [dep, version] of Object.entries(TARGET_DEV_DEPS)) {
77
74
  const current = pkgJson.devDependencies[dep];
78
75
  if (!current) {
79
76
  pkgJson.devDependencies[dep] = version;
@@ -27,6 +27,7 @@ export const getGeneratedComponentName = (packageName) => kebabCase(packageName)
27
27
  export const getGeneratedComponentClassName = (packageName) => pascalCase(packageName);
28
28
  export const getDefaultIconPath = () => join(templatesPath(), 'assets/default-icon.png');
29
29
  export const getCliPackagePath = () => join(PACKAGE_ROOT, 'package.json');
30
+ export const wsPackageJsonPath = (wsPath) => join(wsPath, 'package.json');
30
31
  /**
31
32
  * Resolves the CLI binary entry point from a neutrinos-cli package directory.
32
33
  * Reads the bin.neutrinos or main field from the package's package.json.
@@ -0,0 +1,28 @@
1
+ import { execSync } from 'node:child_process';
2
+ export function isGitRepo(wsPath) {
3
+ try {
4
+ execSync('git rev-parse --is-inside-work-tree', { cwd: wsPath, stdio: 'pipe' });
5
+ return true;
6
+ }
7
+ catch {
8
+ return false;
9
+ }
10
+ }
11
+ export function isGitDirty(wsPath) {
12
+ const output = execSync('git status --porcelain', { cwd: wsPath, encoding: 'utf-8' });
13
+ return output.trim().length > 0;
14
+ }
15
+ export function gitInit(wsPath) {
16
+ execSync('git init', { cwd: wsPath, stdio: 'pipe' });
17
+ }
18
+ export function gitSnapshot(wsPath) {
19
+ gitInit(wsPath);
20
+ gitAddAll(wsPath);
21
+ gitCommit(wsPath, 'chore: snapshot before migration');
22
+ }
23
+ export function gitAddAll(wsPath) {
24
+ execSync('git add -A', { cwd: wsPath, stdio: 'pipe' });
25
+ }
26
+ export function gitCommit(wsPath, message) {
27
+ execSync(`git commit -m "${message}"`, { cwd: wsPath, stdio: 'pipe' });
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutrinos-cli",
3
- "version": "2.0.0-beta.17",
3
+ "version": "2.0.0-beta.19",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "neutrinos": "./dist/bin/cli.js"