novac 2.2.2 → 2.3.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.
package/bin/novac CHANGED
@@ -676,16 +676,16 @@ program
676
676
  process.exit(1);
677
677
  }
678
678
  const config = JSON.parse(fs.readFileSync(configFile, 'utf8'));
679
- const name = config.name || path.basename(process.cwd());
679
+ const name = config.name || path.basename(process.cwd());
680
680
  const version = config.version || '1.0.0';
681
- const main = config.main || 'src/main.nova';
682
- const srcDir = config.srcDir || 'src';
681
+ const main = config.main || 'src/main.nova';
682
+ const srcDir = config.srcDir || 'src';
683
683
 
684
684
  function collectNova(dir, base = dir) {
685
685
  const results = {};
686
686
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
687
687
  const full = path.join(dir, entry.name);
688
- const rel = path.relative(base, full);
688
+ const rel = path.relative(base, full);
689
689
  if (entry.isDirectory()) Object.assign(results, collectNova(full, base));
690
690
  else if (entry.name.endsWith('.nova') || entry.name.endsWith('.nv')) {
691
691
  results[rel] = fs.readFileSync(full, 'utf8');
@@ -730,14 +730,51 @@ program
730
730
  console.log(chalk.blue(` Install in another project: novac module install ./${name}.novamod`));
731
731
  } else if (option.toUpperCase() === 'PATH') {
732
732
  const platform = os.platform();
733
- const npmPrefix = execSync('npm config get prefix', { encoding: 'utf8' }).trim();
734
- const binPath = path.join(npmPrefix, 'bin');
733
+ const binPath = __dirname;
735
734
  console.log(chalk.blue(`Adding ${binPath} to PATH for ${platform}...`));
736
735
  try {
736
+ // FIXED — reads/writes registry directly via PowerShell, no length limit
737
737
  if (platform === 'win32') {
738
- execSync(`setx PATH "%PATH%;${binPath}"`, { stdio: 'inherit' });
739
- console.log(chalk.green('PATH updated on Windows. Restart your terminal.'));
740
- } else if (['darwin','linux','freebsd','openbsd','sunos','aix','android'].includes(platform)) {
738
+ // ── 1. Create .cmd shims for every non-shim file in the bin directory ──
739
+ const binFiles = fs.readdirSync(binPath).filter(f => {
740
+ const full = path.join(binPath, f);
741
+ if (!fs.statSync(full).isFile()) return false;
742
+ if (f.endsWith('.cmd') || f.endsWith('.bat')) return false;
743
+ if (fs.existsSync(path.join(binPath, f + '.cmd'))) return false;
744
+ return true;
745
+ });
746
+
747
+ for (const f of binFiles) {
748
+ const shimPath = path.join(binPath, f + '.cmd');
749
+ fs.writeFileSync(shimPath, `@echo off\nnode "%~dp0${f}" %*\n`, 'utf8');
750
+ console.log(chalk.green(` created shim: ${f}.cmd`));
751
+ }
752
+
753
+ if (binFiles.length === 0) {
754
+ console.log(chalk.gray(' shims already up to date'));
755
+ }
756
+
757
+ // ── 2. Add bin dir to user PATH via registry (no setx, no length limit) ──
758
+ const psScript = [
759
+ `$regPath = 'HKCU:\\Environment'`,
760
+ `$current = (Get-ItemProperty -Path $regPath -Name PATH -ErrorAction SilentlyContinue).PATH`,
761
+ `if (-not $current) { $current = '' }`,
762
+ `$add = '${binPath.replace(/\\/g, '\\\\').replace(/'/g, "''")}'`,
763
+ `$parts = $current -split ';' | Where-Object { $_ -ne '' }`,
764
+ `if ($parts -contains $add) {`,
765
+ ` Write-Host 'Already in PATH — nothing changed.'`,
766
+ `} else {`,
767
+ ` $newPath = ($parts + $add) -join ';'`,
768
+ ` [Environment]::SetEnvironmentVariable('PATH', $newPath, 'User')`,
769
+ ` Write-Host 'PATH updated successfully.'`,
770
+ `}`,
771
+ ].join('; ');
772
+
773
+ execSync(`powershell -NoProfile -Command "${psScript}"`, { stdio: 'inherit' });
774
+ console.log(chalk.green('Done. Open a NEW terminal for the PATH change to take effect.'));
775
+ console.log(chalk.yellow('To apply in the current session run:'));
776
+ console.log(chalk.white(` $env:PATH += ';${binPath}'`));
777
+ } else if (['darwin', 'linux', 'freebsd', 'openbsd', 'sunos', 'aix', 'android'].includes(platform)) {
741
778
  const shellRc = platform === 'darwin'
742
779
  ? path.join(process.env.HOME, '.zshrc')
743
780
  : path.join(process.env.HOME, '.bashrc');
@@ -875,13 +912,13 @@ moduleCmd
875
912
  }
876
913
  console.log(chalk.blue(`Installed ${scope} modules${pattern ? ` matching "${pattern}"` : ''}:`));
877
914
  for (const e of entries) {
878
- const manifestPath = path.join(novaModulesDir, e.name, 'nova.kit.json');
915
+ const manifestPath = path.join(novaModulesDir, e.name, 'nova.kit.json');
879
916
  const bundleManifest = path.join(novaModulesDir, e.name, 'nova.mod.json');
880
917
  let version = '?';
881
918
  if (fs.existsSync(manifestPath)) {
882
- try { version = JSON.parse(fs.readFileSync(manifestPath, 'utf8')).version || '?'; } catch {}
919
+ try { version = JSON.parse(fs.readFileSync(manifestPath, 'utf8')).version || '?'; } catch { }
883
920
  } else if (fs.existsSync(bundleManifest)) {
884
- try { version = JSON.parse(fs.readFileSync(bundleManifest, 'utf8')).version || '?'; } catch {}
921
+ try { version = JSON.parse(fs.readFileSync(bundleManifest, 'utf8')).version || '?'; } catch { }
885
922
  }
886
923
  console.log(` ${chalk.green(e.name)} ${chalk.gray(version)}`);
887
924
  }
package/bin/novac.cmd ADDED
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ node "%~dp0novac" %*
package/bin/nvc.cmd ADDED
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ node "%~dp0nvc" %*