@gadmin2n/cli 0.0.116 → 0.0.118

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.
@@ -302,15 +302,43 @@ function detectInstallCommand(dir) {
302
302
  }
303
303
  return { cmd: 'npm install', manager: 'npm' };
304
304
  }
305
+ /**
306
+ * Detect whether `package.json` content contains unresolved 3-way merge
307
+ * conflict markers. When present, the file is not valid JSON and we cannot
308
+ * meaningfully compare its deps — the user must resolve the conflicts before
309
+ * running an installer.
310
+ */
311
+ function hasConflictMarkers(content) {
312
+ return content.includes('<<<<<<<') || content.includes('>>>>>>>');
313
+ }
314
+ /**
315
+ * Surface dependency changes to the user as a manual checklist. We
316
+ * intentionally do NOT run the installer ourselves anymore: after a 3-way
317
+ * merge, `package.json` may carry conflict markers and not be valid JSON,
318
+ * which would cause `yarn install` to fail mid-flight and leave the project
319
+ * in a half-broken state. Instead we print exactly which directories need
320
+ * attention and which command to run there.
321
+ *
322
+ * Three buckets per snapshot:
323
+ * 1. Conflict markers present → resolve first, then install
324
+ * 2. Deps actually changed → run install
325
+ * 3. Bytes changed but deps unchanged (e.g. scripts/formatting only)
326
+ * → no install needed, just FYI
327
+ */
305
328
  function maybeInstallChangedDeps(snapshots, dryRun) {
306
329
  return __awaiter(this, void 0, void 0, function* () {
307
330
  const changed = [];
308
331
  const skippedNoDepChange = [];
332
+ const conflictMarkers = [];
309
333
  for (const snap of snapshots) {
310
334
  const pkgPath = path.join(snap.dir, 'package.json');
311
335
  if (!fs.existsSync(pkgPath))
312
336
  continue;
313
337
  const after = fs.readFileSync(pkgPath, 'utf-8');
338
+ if (hasConflictMarkers(after)) {
339
+ conflictMarkers.push(snap);
340
+ continue;
341
+ }
314
342
  if (depsChanged(snap.before, after)) {
315
343
  changed.push(snap);
316
344
  }
@@ -319,29 +347,34 @@ function maybeInstallChangedDeps(snapshots, dryRun) {
319
347
  skippedNoDepChange.push(snap.label);
320
348
  }
321
349
  }
322
- if (changed.length === 0 && skippedNoDepChange.length === 0)
350
+ if (changed.length === 0 &&
351
+ skippedNoDepChange.length === 0 &&
352
+ conflictMarkers.length === 0) {
323
353
  return;
354
+ }
324
355
  console.info(chalk.bold('\n═══════════════════════════════════════════════════'));
325
- console.info(chalk.bold(' Install dependencies for changed package.json'));
356
+ console.info(chalk.bold(' Dependency changes manual action required'));
326
357
  console.info(chalk.bold('═══════════════════════════════════════════════════\n'));
327
- for (const label of skippedNoDepChange) {
328
- console.info(` ${chalk.cyan(label + '/')} package.json changed but deps unchanged ${chalk.gray('skip install')}`);
358
+ if (dryRun) {
359
+ console.info(chalk.gray('(dry-run nothing was actually written; the listing below is informational only)\n'));
329
360
  }
361
+ // 1. Files with unresolved conflict markers — highest priority.
362
+ for (const snap of conflictMarkers) {
363
+ const { cmd } = detectInstallCommand(snap.dir);
364
+ console.info(` ${chalk.red(snap.label + '/')} package.json has unresolved 3-way merge markers (<<<<<<<). ` +
365
+ `Resolve them first, then run ${chalk.bold(cmd)} in this directory.`);
366
+ }
367
+ // 2. Deps actually changed — recommend install command.
330
368
  for (const snap of changed) {
331
369
  const { cmd, manager } = detectInstallCommand(snap.dir);
332
- console.info(` ${chalk.cyan(snap.label + '/')} deps changed using ${chalk.bold(manager)}: ${chalk.gray(cmd)}`);
333
- if (dryRun) {
334
- console.info(chalk.gray(` (dry-run: skip running)\n`));
335
- continue;
336
- }
337
- try {
338
- (0, child_process_1.execSync)(cmd, { cwd: snap.dir, stdio: 'inherit' });
339
- console.info(chalk.green(` ✓ ${snap.label}/ install done\n`));
340
- }
341
- catch (err) {
342
- console.warn(chalk.yellow(` ⚠️ ${snap.label}/ install failed: ${(err === null || err === void 0 ? void 0 : err.message) || err}\n`));
343
- }
370
+ console.info(` ${chalk.yellow(snap.label + '/')} dependencies changed run ${chalk.bold(cmd)} ` +
371
+ chalk.gray(`(${manager} detected)`));
344
372
  }
373
+ // 3. Bytes changed but deps unchanged — purely informational.
374
+ for (const label of skippedNoDepChange) {
375
+ console.info(` ${chalk.cyan(label + '/')} package.json changed but dependencies are identical — ${chalk.gray('no install needed')}`);
376
+ }
377
+ console.info();
345
378
  });
346
379
  }
347
380
  function assertGitAvailable() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadmin2n/cli",
3
- "version": "0.0.116",
3
+ "version": "0.0.118",
4
4
  "description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -47,7 +47,7 @@
47
47
  "@angular-devkit/core": "13.3.2",
48
48
  "@angular-devkit/schematics": "13.3.2",
49
49
  "@angular-devkit/schematics-cli": "13.3.2",
50
- "@gadmin2n/schematics": "^0.0.91",
50
+ "@gadmin2n/schematics": "^0.0.92",
51
51
  "abc": "^0.6.1",
52
52
  "chalk": "3.0.0",
53
53
  "chokidar": "3.5.3",