@eltonssouza/development-utility-kit 0.14.0 → 0.14.1

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.
Files changed (2) hide show
  1. package/bin/cli.js +32 -16
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -267,6 +267,31 @@ function harnessVersion() {
267
267
  }
268
268
  }
269
269
 
270
+ // ─── spawn helpers (DEP0190-safe) ─────────────────────────────────────────────
271
+
272
+ /**
273
+ * Whether a binary resolves on PATH — cross-platform, no shell (so no DEP0190).
274
+ * @param {string} bin
275
+ * @returns {boolean}
276
+ */
277
+ function isOnPath(bin) {
278
+ const probe = process.platform === 'win32' ? 'where' : 'which';
279
+ const r = spawnSync(probe, [bin], { stdio: 'ignore' });
280
+ return r.status === 0;
281
+ }
282
+
283
+ /**
284
+ * Run a TRUSTED, static command line. A shell is needed on Windows to resolve
285
+ * `.cmd`/`.bat` shims (npm, git, rtk). Passing the command as a SINGLE string
286
+ * (not args[] + shell:true) avoids Node's DEP0190 warning. Never pass untrusted
287
+ * input — quote path arguments at the call site.
288
+ * @param {string} cmd
289
+ * @param {object} [opts]
290
+ */
291
+ function runShell(cmd, opts = {}) {
292
+ return spawnSync(cmd, { shell: true, ...opts });
293
+ }
294
+
270
295
  // ─── adoptProject (install / update) ──────────────────────────────────────────
271
296
 
272
297
  /**
@@ -432,17 +457,11 @@ function adoptProject(opts) {
432
457
  process.stdout.write('Written : CLAUDE.md\n');
433
458
 
434
459
  // Auto-install duk globally when running via npx (duk not yet in PATH).
435
- const dukCheck = spawnSync('duk', ['--version'], {
436
- shell: process.platform === 'win32',
437
- stdio: 'ignore',
438
- });
439
- if (dukCheck.error) {
460
+ if (!isOnPath('duk')) {
440
461
  process.stdout.write('\nInstalling duk CLI globally...\n');
441
- const globalInstall = spawnSync(
442
- 'npm',
443
- ['install', '-g', '@eltonssouza/development-utility-kit'],
444
- { stdio: 'inherit', shell: process.platform === 'win32' }
445
- );
462
+ const globalInstall = runShell('npm install -g @eltonssouza/development-utility-kit', {
463
+ stdio: 'inherit',
464
+ });
446
465
  if (globalInstall.status === 0) {
447
466
  process.stdout.write('duk installed globally. Run: duk help\n');
448
467
  } else {
@@ -530,10 +549,9 @@ function newProject(name, options) {
530
549
  fs.mkdirSync(target, { recursive: true });
531
550
 
532
551
  // 2. git init (non-fatal if git not installed; warn and continue)
533
- const gitResult = spawnSync('git', ['init', '-q'], {
552
+ const gitResult = runShell('git init -q', {
534
553
  cwd: target,
535
554
  stdio: 'inherit',
536
- shell: process.platform === 'win32',
537
555
  });
538
556
  if (gitResult.status !== 0) {
539
557
  process.stdout.write('Warning: "git init" failed or git is not in PATH. Continuing without git repo.\n');
@@ -707,9 +725,8 @@ function dashboard(passthroughArgs) {
707
725
 
708
726
  if (!fs.existsSync(nodeModulesDir)) {
709
727
  process.stdout.write('Installing dashboard dependencies (first run)...\n');
710
- const result = spawnSync('npm', ['install', '--prefix', dashboardDir], {
728
+ const result = runShell(`npm install --prefix "${dashboardDir}"`, {
711
729
  stdio: 'inherit',
712
- shell: process.platform === 'win32',
713
730
  });
714
731
  if (result.status !== 0) {
715
732
  process.stderr.write('Error: npm install failed for dashboard dependencies.\n');
@@ -718,8 +735,7 @@ function dashboard(passthroughArgs) {
718
735
  }
719
736
 
720
737
  // FR-008: print rtk gain output before starting the server
721
- const rtkResult = spawnSync('rtk', ['gain'], {
722
- shell: process.platform === 'win32',
738
+ const rtkResult = runShell('rtk gain', {
723
739
  stdio: ['ignore', 'pipe', 'ignore'],
724
740
  });
725
741
  if (rtkResult.status === 0 && rtkResult.stdout && rtkResult.stdout.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eltonssouza/development-utility-kit",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "npx installer for the development-utility-kit harness",
5
5
  "bin": {
6
6
  "duk": "bin/cli.js"