node-version-use 1.9.8 → 2.0.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.
Files changed (92) hide show
  1. package/README.md +121 -23
  2. package/dist/cjs/cli.js +25 -6
  3. package/dist/cjs/cli.js.map +1 -1
  4. package/dist/cjs/commands/default.d.cts +7 -0
  5. package/dist/cjs/commands/default.d.ts +7 -0
  6. package/dist/cjs/commands/default.js +57 -0
  7. package/dist/cjs/commands/default.js.map +1 -0
  8. package/dist/cjs/commands/index.d.cts +3 -0
  9. package/dist/cjs/commands/index.d.ts +3 -0
  10. package/dist/cjs/commands/index.js +54 -0
  11. package/dist/cjs/commands/index.js.map +1 -0
  12. package/dist/cjs/commands/install.d.cts +6 -0
  13. package/dist/cjs/commands/install.d.ts +6 -0
  14. package/dist/cjs/commands/install.js +69 -0
  15. package/dist/cjs/commands/install.js.map +1 -0
  16. package/dist/cjs/commands/list.d.cts +6 -0
  17. package/dist/cjs/commands/list.d.ts +6 -0
  18. package/dist/cjs/commands/list.js +93 -0
  19. package/dist/cjs/commands/list.js.map +1 -0
  20. package/dist/cjs/commands/local.d.cts +7 -0
  21. package/dist/cjs/commands/local.d.ts +7 -0
  22. package/dist/cjs/commands/local.js +69 -0
  23. package/dist/cjs/commands/local.js.map +1 -0
  24. package/dist/cjs/commands/setup.d.cts +7 -0
  25. package/dist/cjs/commands/setup.d.ts +7 -0
  26. package/dist/cjs/commands/setup.js +55 -0
  27. package/dist/cjs/commands/setup.js.map +1 -0
  28. package/dist/cjs/commands/teardown.d.cts +6 -0
  29. package/dist/cjs/commands/teardown.d.ts +6 -0
  30. package/dist/cjs/commands/teardown.js +66 -0
  31. package/dist/cjs/commands/teardown.js.map +1 -0
  32. package/dist/cjs/commands/uninstall.d.cts +6 -0
  33. package/dist/cjs/commands/uninstall.d.ts +6 -0
  34. package/dist/cjs/commands/uninstall.js +148 -0
  35. package/dist/cjs/commands/uninstall.js.map +1 -0
  36. package/dist/cjs/commands/which.d.cts +7 -0
  37. package/dist/cjs/commands/which.d.ts +7 -0
  38. package/dist/cjs/commands/which.js +117 -0
  39. package/dist/cjs/commands/which.js.map +1 -0
  40. package/dist/cjs/compat.d.cts +17 -0
  41. package/dist/cjs/compat.d.ts +17 -0
  42. package/dist/cjs/compat.js +47 -1
  43. package/dist/cjs/compat.js.map +1 -1
  44. package/dist/cjs/constants.js +1 -1
  45. package/dist/cjs/constants.js.map +1 -1
  46. package/dist/cjs/types.d.cts +1 -0
  47. package/dist/cjs/types.d.ts +1 -0
  48. package/dist/cjs/worker.js +2 -2
  49. package/dist/cjs/worker.js.map +1 -1
  50. package/dist/esm/cli.js +23 -4
  51. package/dist/esm/cli.js.map +1 -1
  52. package/dist/esm/commands/default.d.ts +7 -0
  53. package/dist/esm/commands/default.js +41 -0
  54. package/dist/esm/commands/default.js.map +1 -0
  55. package/dist/esm/commands/index.d.ts +3 -0
  56. package/dist/esm/commands/index.js +27 -0
  57. package/dist/esm/commands/index.js.map +1 -0
  58. package/dist/esm/commands/install.d.ts +6 -0
  59. package/dist/esm/commands/install.js +53 -0
  60. package/dist/esm/commands/install.js.map +1 -0
  61. package/dist/esm/commands/list.d.ts +6 -0
  62. package/dist/esm/commands/list.js +52 -0
  63. package/dist/esm/commands/list.js.map +1 -0
  64. package/dist/esm/commands/local.d.ts +7 -0
  65. package/dist/esm/commands/local.js +51 -0
  66. package/dist/esm/commands/local.js.map +1 -0
  67. package/dist/esm/commands/setup.d.ts +7 -0
  68. package/dist/esm/commands/setup.js +39 -0
  69. package/dist/esm/commands/setup.js.map +1 -0
  70. package/dist/esm/commands/teardown.d.ts +6 -0
  71. package/dist/esm/commands/teardown.js +33 -0
  72. package/dist/esm/commands/teardown.js.map +1 -0
  73. package/dist/esm/commands/uninstall.d.ts +6 -0
  74. package/dist/esm/commands/uninstall.js +132 -0
  75. package/dist/esm/commands/uninstall.js.map +1 -0
  76. package/dist/esm/commands/which.d.ts +7 -0
  77. package/dist/esm/commands/which.js +101 -0
  78. package/dist/esm/commands/which.js.map +1 -0
  79. package/dist/esm/compat.d.ts +17 -0
  80. package/dist/esm/compat.js +39 -2
  81. package/dist/esm/compat.js.map +1 -1
  82. package/dist/esm/constants.js +2 -1
  83. package/dist/esm/constants.js.map +1 -1
  84. package/dist/esm/types.d.ts +1 -0
  85. package/dist/esm/types.js.map +1 -1
  86. package/dist/esm/worker.js +2 -2
  87. package/dist/esm/worker.js.map +1 -1
  88. package/package.json +11 -4
  89. package/scripts/postinstall.cjs +273 -0
  90. package/shim/Makefile +58 -0
  91. package/shim/go.mod +3 -0
  92. package/shim/main.go +302 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/list.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu list\n *\n * List all installed Node versions.\n */\nexport default function listCmd(_args: string[]): void {\n var versionsPath = path.join(storagePath, 'versions');\n\n // Check if versions directory exists\n if (!fs.existsSync(versionsPath)) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Read all directories in versions folder\n var entries = readdirWithTypes(versionsPath);\n var versions = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);\n\n if (versions.length === 0) {\n console.log('No Node versions installed.');\n console.log('Install a version: nvu install <version>');\n exit(0);\n return;\n }\n\n // Get the current default\n const defaultFilePath = path.join(storagePath, 'default');\n let defaultVersion = '';\n if (fs.existsSync(defaultFilePath)) {\n defaultVersion = fs.readFileSync(defaultFilePath, 'utf8').trim();\n }\n\n // Sort versions (simple string sort, could be improved with semver)\n versions.sort((a, b) => {\n const aParts = a.split('.').map((n) => parseInt(n, 10) || 0);\n const bParts = b.split('.').map((n) => parseInt(n, 10) || 0);\n for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {\n const aVal = aParts[i] || 0;\n const bVal = bParts[i] || 0;\n if (aVal !== bVal) return bVal - aVal; // Descending order\n }\n return 0;\n });\n\n console.log('Installed Node versions:');\n for (const version of versions) {\n const isDefault = version === defaultVersion || `v${version}` === defaultVersion || version === `v${defaultVersion}`;\n const marker = isDefault ? ' (default)' : '';\n console.log(` ${version}${marker}`);\n }\n exit(0);\n}\n"],"names":["listCmd","_args","versionsPath","path","join","storagePath","fs","existsSync","console","log","exit","entries","readdirWithTypes","versions","filter","entry","isDirectory","map","name","length","defaultFilePath","defaultVersion","readFileSync","trim","sort","a","b","aParts","split","n","parseInt","bParts","i","Math","max","aVal","bVal","version","isDefault","marker"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;wBACgB;2BACL;;;;;;AAOb,SAASA,QAAQC,KAAe;IAC7C,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,qCAAqC;IACrC,IAAI,CAACC,WAAE,CAACC,UAAU,CAACL,eAAe;QAChCM,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,0CAA0C;IAC1C,IAAIC,UAAUC,IAAAA,0BAAgB,EAACV;IAC/B,IAAIW,WAAWF,QAAQG,MAAM,CAAC,SAACC;eAAUA,MAAMC,WAAW;OAAIC,GAAG,CAAC,SAACF;eAAUA,MAAMG,IAAI;;IAEvF,IAAIL,SAASM,MAAM,KAAK,GAAG;QACzBX,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,0BAA0B;IAC1B,IAAMU,kBAAkBjB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC/C,IAAIgB,iBAAiB;IACrB,IAAIf,WAAE,CAACC,UAAU,CAACa,kBAAkB;QAClCC,iBAAiBf,WAAE,CAACgB,YAAY,CAACF,iBAAiB,QAAQG,IAAI;IAChE;IAEA,oEAAoE;IACpEV,SAASW,IAAI,CAAC,SAACC,GAAGC;QAChB,IAAMC,SAASF,EAAEG,KAAK,CAAC,KAAKX,GAAG,CAAC,SAACY;mBAAMC,SAASD,GAAG,OAAO;;QAC1D,IAAME,SAASL,EAAEE,KAAK,CAAC,KAAKX,GAAG,CAAC,SAACY;mBAAMC,SAASD,GAAG,OAAO;;QAC1D,IAAK,IAAIG,IAAI,GAAGA,IAAIC,KAAKC,GAAG,CAACP,OAAOR,MAAM,EAAEY,OAAOZ,MAAM,GAAGa,IAAK;YAC/D,IAAMG,OAAOR,MAAM,CAACK,EAAE,IAAI;YAC1B,IAAMI,OAAOL,MAAM,CAACC,EAAE,IAAI;YAC1B,IAAIG,SAASC,MAAM,OAAOA,OAAOD,MAAM,mBAAmB;QAC5D;QACA,OAAO;IACT;IAEA3B,QAAQC,GAAG,CAAC;QACP,kCAAA,2BAAA;;QAAL,QAAK,YAAiBI,6BAAjB,SAAA,6BAAA,QAAA,yBAAA,iCAA2B;YAA3B,IAAMwB,UAAN;YACH,IAAMC,YAAYD,YAAYhB,kBAAkB,AAAC,IAAW,OAARgB,aAAchB,kBAAkBgB,YAAY,AAAC,IAAkB,OAAfhB;YACpG,IAAMkB,SAASD,YAAY,eAAe;YAC1C9B,QAAQC,GAAG,CAAC,AAAC,KAAc8B,OAAVF,SAAiB,OAAPE;QAC7B;;QAJK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAKL7B,IAAAA,aAAI,EAAC;AACP"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu local [version] [--nvurc]
3
+ *
4
+ * Write .nvmrc (or .nvurc) to the current directory.
5
+ * This pins the Node version for the current project.
6
+ */
7
+ export default function localCmd(args: string[]): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu local [version] [--nvurc]
3
+ *
4
+ * Write .nvmrc (or .nvurc) to the current directory.
5
+ * This pins the Node version for the current project.
6
+ */
7
+ export default function localCmd(args: string[]): void;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * nvu local [version] [--nvurc]
7
+ *
8
+ * Write .nvmrc (or .nvurc) to the current directory.
9
+ * This pins the Node version for the current project.
10
+ */ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return localCmd;
14
+ }
15
+ });
16
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
17
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
18
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
19
+ function _interop_require_default(obj) {
20
+ return obj && obj.__esModule ? obj : {
21
+ default: obj
22
+ };
23
+ }
24
+ function localCmd(args) {
25
+ var cwd = process.cwd();
26
+ // Check for --nvurc flag
27
+ var useNvurc = args.includes('--nvurc');
28
+ var filteredArgs = args.filter(function(arg) {
29
+ return arg !== '--nvurc';
30
+ });
31
+ var fileName = useNvurc ? '.nvurc' : '.nvmrc';
32
+ var filePath = _path.default.join(cwd, fileName);
33
+ // If no version provided, display current local version
34
+ if (filteredArgs.length === 0) {
35
+ // Check for existing version files
36
+ var nvurcPath = _path.default.join(cwd, '.nvurc');
37
+ var nvmrcPath = _path.default.join(cwd, '.nvmrc');
38
+ if (_fs.default.existsSync(nvurcPath)) {
39
+ var version = _fs.default.readFileSync(nvurcPath, 'utf8').trim();
40
+ console.log("Current local version (.nvurc): ".concat(version));
41
+ (0, _exit.default)(0);
42
+ return;
43
+ }
44
+ if (_fs.default.existsSync(nvmrcPath)) {
45
+ var version1 = _fs.default.readFileSync(nvmrcPath, 'utf8').trim();
46
+ console.log("Current local version (.nvmrc): ".concat(version1));
47
+ (0, _exit.default)(0);
48
+ return;
49
+ }
50
+ console.log('No local version set in this directory.');
51
+ console.log('Usage: nvu local <version>');
52
+ console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');
53
+ (0, _exit.default)(0);
54
+ return;
55
+ }
56
+ var version2 = filteredArgs[0].trim();
57
+ // Validate version format (basic check)
58
+ if (!version2 || version2.startsWith('-')) {
59
+ console.log('Usage: nvu local <version>');
60
+ console.log('Example: nvu local 20');
61
+ (0, _exit.default)(1);
62
+ return;
63
+ }
64
+ // Write the version file
65
+ _fs.default.writeFileSync(filePath, "".concat(version2, "\n"), 'utf8');
66
+ console.log("Created ".concat(fileName, " with version: ").concat(version2));
67
+ (0, _exit.default)(0);
68
+ }
69
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/local.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * nvu local [version] [--nvurc]\n *\n * Write .nvmrc (or .nvurc) to the current directory.\n * This pins the Node version for the current project.\n */\nexport default function localCmd(args: string[]): void {\n const cwd = process.cwd();\n\n // Check for --nvurc flag\n const useNvurc = args.includes('--nvurc');\n const filteredArgs = args.filter((arg) => arg !== '--nvurc');\n\n const fileName = useNvurc ? '.nvurc' : '.nvmrc';\n const filePath = path.join(cwd, fileName);\n\n // If no version provided, display current local version\n if (filteredArgs.length === 0) {\n // Check for existing version files\n const nvurcPath = path.join(cwd, '.nvurc');\n const nvmrcPath = path.join(cwd, '.nvmrc');\n\n if (fs.existsSync(nvurcPath)) {\n const version = fs.readFileSync(nvurcPath, 'utf8').trim();\n console.log(`Current local version (.nvurc): ${version}`);\n exit(0);\n return;\n }\n if (fs.existsSync(nvmrcPath)) {\n const version = fs.readFileSync(nvmrcPath, 'utf8').trim();\n console.log(`Current local version (.nvmrc): ${version}`);\n exit(0);\n return;\n }\n\n console.log('No local version set in this directory.');\n console.log('Usage: nvu local <version>');\n console.log(' nvu local <version> --nvurc (use .nvurc instead of .nvmrc)');\n exit(0);\n return;\n }\n\n const version = filteredArgs[0].trim();\n\n // Validate version format (basic check)\n if (!version || version.startsWith('-')) {\n console.log('Usage: nvu local <version>');\n console.log('Example: nvu local 20');\n exit(1);\n return;\n }\n\n // Write the version file\n fs.writeFileSync(filePath, `${version}\\n`, 'utf8');\n console.log(`Created ${fileName} with version: ${version}`);\n exit(0);\n}\n"],"names":["localCmd","args","cwd","process","useNvurc","includes","filteredArgs","filter","arg","fileName","filePath","path","join","length","nvurcPath","nvmrcPath","fs","existsSync","version","readFileSync","trim","console","log","exit","startsWith","writeFileSync"],"mappings":";;;;+BAIA;;;;;CAKC,GACD;;;eAAwBA;;;2DAVP;yDACF;2DACE;;;;;;AAQF,SAASA,SAASC,IAAc;IAC7C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,yBAAyB;IACzB,IAAME,WAAWH,KAAKI,QAAQ,CAAC;IAC/B,IAAMC,eAAeL,KAAKM,MAAM,CAAC,SAACC;eAAQA,QAAQ;;IAElD,IAAMC,WAAWL,WAAW,WAAW;IACvC,IAAMM,WAAWC,aAAI,CAACC,IAAI,CAACV,KAAKO;IAEhC,wDAAwD;IACxD,IAAIH,aAAaO,MAAM,KAAK,GAAG;QAC7B,mCAAmC;QACnC,IAAMC,YAAYH,aAAI,CAACC,IAAI,CAACV,KAAK;QACjC,IAAMa,YAAYJ,aAAI,CAACC,IAAI,CAACV,KAAK;QAEjC,IAAIc,WAAE,CAACC,UAAU,CAACH,YAAY;YAC5B,IAAMI,UAAUF,WAAE,CAACG,YAAY,CAACL,WAAW,QAAQM,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,aAAI,EAAC;YACL;QACF;QACA,IAAIP,WAAE,CAACC,UAAU,CAACF,YAAY;YAC5B,IAAMG,WAAUF,WAAE,CAACG,YAAY,CAACJ,WAAW,QAAQK,IAAI;YACvDC,QAAQC,GAAG,CAAC,AAAC,mCAA0C,OAARJ;YAC/CK,IAAAA,aAAI,EAAC;YACL;QACF;QAEAF,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAML,WAAUZ,YAAY,CAAC,EAAE,CAACc,IAAI;IAEpC,wCAAwC;IACxC,IAAI,CAACF,YAAWA,SAAQM,UAAU,CAAC,MAAM;QACvCH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,yBAAyB;IACzBP,WAAE,CAACS,aAAa,CAACf,UAAU,AAAC,GAAU,OAARQ,UAAQ,OAAK;IAC3CG,QAAQC,GAAG,CAAC,AAAC,WAAoCJ,OAA1BT,UAAS,mBAAyB,OAARS;IACjDK,IAAAA,aAAI,EAAC;AACP"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu setup
3
+ *
4
+ * Install/reinstall nvu shims to ~/.nvu/bin
5
+ * This runs the same logic as the postinstall script.
6
+ */
7
+ export default function setupCmd(_args: string[]): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu setup
3
+ *
4
+ * Install/reinstall nvu shims to ~/.nvu/bin
5
+ * This runs the same logic as the postinstall script.
6
+ */
7
+ export default function setupCmd(_args: string[]): void;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * nvu setup
7
+ *
8
+ * Install/reinstall nvu shims to ~/.nvu/bin
9
+ * This runs the same logic as the postinstall script.
10
+ */ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return setupCmd;
14
+ }
15
+ });
16
+ var _child_process = require("child_process");
17
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
18
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
19
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
20
+ var _url = /*#__PURE__*/ _interop_require_default(require("url"));
21
+ var _compatts = require("../compat.js");
22
+ var _constantsts = require("../constants.js");
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
28
+ var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
29
+ function setupCmd(_args) {
30
+ var binDir = _path.default.join(_constantsts.storagePath, 'bin');
31
+ // Create directories
32
+ if (!_fs.default.existsSync(_constantsts.storagePath)) {
33
+ (0, _compatts.mkdirpSync)(_constantsts.storagePath);
34
+ }
35
+ if (!_fs.default.existsSync(binDir)) {
36
+ (0, _compatts.mkdirpSync)(binDir);
37
+ }
38
+ // Find the postinstall script relative to this module
39
+ var postinstallPath = _path.default.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');
40
+ if (_fs.default.existsSync(postinstallPath)) {
41
+ // Run the postinstall script
42
+ try {
43
+ (0, _child_process.execSync)('node "'.concat(postinstallPath, '"'), {
44
+ stdio: 'inherit'
45
+ });
46
+ } catch (_err) {
47
+ // postinstall handles its own errors gracefully
48
+ }
49
+ } else {
50
+ console.log('Setup script not found.');
51
+ console.log('Try reinstalling: npm install -g node-version-use');
52
+ (0, _exit.default)(1);
53
+ }
54
+ }
55
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/setup.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport url from 'url';\nimport { mkdirpSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\nvar __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n/**\n * nvu setup\n *\n * Install/reinstall nvu shims to ~/.nvu/bin\n * This runs the same logic as the postinstall script.\n */\nexport default function setupCmd(_args: string[]): void {\n var binDir = path.join(storagePath, 'bin');\n\n // Create directories\n if (!fs.existsSync(storagePath)) {\n mkdirpSync(storagePath);\n }\n if (!fs.existsSync(binDir)) {\n mkdirpSync(binDir);\n }\n\n // Find the postinstall script relative to this module\n var postinstallPath = path.join(__dirname, '..', '..', '..', 'scripts', 'postinstall.cjs');\n\n if (fs.existsSync(postinstallPath)) {\n // Run the postinstall script\n try {\n execSync(`node \"${postinstallPath}\"`, { stdio: 'inherit' });\n } catch (_err) {\n // postinstall handles its own errors gracefully\n }\n } else {\n console.log('Setup script not found.');\n console.log('Try reinstalling: npm install -g node-version-use');\n exit(1);\n }\n}\n"],"names":["setupCmd","__dirname","path","dirname","__filename","url","fileURLToPath","_args","binDir","join","storagePath","fs","existsSync","mkdirpSync","postinstallPath","execSync","stdio","_err","console","log","exit"],"mappings":";;;;+BAUA;;;;;CAKC,GACD;;;eAAwBA;;;6BAhBC;2DACR;yDACF;2DACE;0DACD;wBACW;2BACC;;;;;;AAE5B,IAAIC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAQjF,SAASN,SAASO,KAAe;IAC9C,IAAIC,SAASN,aAAI,CAACO,IAAI,CAACC,wBAAW,EAAE;IAEpC,qBAAqB;IACrB,IAAI,CAACC,WAAE,CAACC,UAAU,CAACF,wBAAW,GAAG;QAC/BG,IAAAA,oBAAU,EAACH,wBAAW;IACxB;IACA,IAAI,CAACC,WAAE,CAACC,UAAU,CAACJ,SAAS;QAC1BK,IAAAA,oBAAU,EAACL;IACb;IAEA,sDAAsD;IACtD,IAAIM,kBAAkBZ,aAAI,CAACO,IAAI,CAACR,WAAW,MAAM,MAAM,MAAM,WAAW;IAExE,IAAIU,WAAE,CAACC,UAAU,CAACE,kBAAkB;QAClC,6BAA6B;QAC7B,IAAI;YACFC,IAAAA,uBAAQ,EAAC,AAAC,SAAwB,OAAhBD,iBAAgB,MAAI;gBAAEE,OAAO;YAAU;QAC3D,EAAE,OAAOC,MAAM;QACb,gDAAgD;QAClD;IACF,OAAO;QACLC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;IACP;AACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * nvu teardown
3
+ *
4
+ * Remove nvu shims from ~/.nvu/bin
5
+ */
6
+ export default function teardownCmd(_args: string[]): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * nvu teardown
3
+ *
4
+ * Remove nvu shims from ~/.nvu/bin
5
+ */
6
+ export default function teardownCmd(_args: string[]): void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * nvu teardown
7
+ *
8
+ * Remove nvu shims from ~/.nvu/bin
9
+ */ "default", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return teardownCmd;
13
+ }
14
+ });
15
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
16
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
+ var _constantsts = require("../constants.js");
19
+ function _interop_require_default(obj) {
20
+ return obj && obj.__esModule ? obj : {
21
+ default: obj
22
+ };
23
+ }
24
+ function teardownCmd(_args) {
25
+ var binDir = _path.default.join(_constantsts.storagePath, 'bin');
26
+ var shims = [
27
+ 'node',
28
+ 'npm',
29
+ 'npx'
30
+ ];
31
+ var ext = process.platform === 'win32' ? '.exe' : '';
32
+ var removed = 0;
33
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
34
+ try {
35
+ for(var _iterator = shims[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
36
+ var shim = _step.value;
37
+ var shimPath = _path.default.join(binDir, shim + ext);
38
+ if (_fs.default.existsSync(shimPath)) {
39
+ _fs.default.unlinkSync(shimPath);
40
+ removed++;
41
+ }
42
+ }
43
+ } catch (err) {
44
+ _didIteratorError = true;
45
+ _iteratorError = err;
46
+ } finally{
47
+ try {
48
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
49
+ _iterator.return();
50
+ }
51
+ } finally{
52
+ if (_didIteratorError) {
53
+ throw _iteratorError;
54
+ }
55
+ }
56
+ }
57
+ if (removed > 0) {
58
+ console.log("Removed ".concat(removed, " shim(s) from ").concat(binDir));
59
+ console.log('');
60
+ console.log('You may also want to remove ~/.nvu/bin from your PATH.');
61
+ } else {
62
+ console.log('No shims found to remove.');
63
+ }
64
+ (0, _exit.default)(0);
65
+ }
66
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/teardown.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu teardown\n *\n * Remove nvu shims from ~/.nvu/bin\n */\nexport default function teardownCmd(_args: string[]): void {\n const binDir = path.join(storagePath, 'bin');\n\n const shims = ['node', 'npm', 'npx'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n\n let removed = 0;\n for (const shim of shims) {\n const shimPath = path.join(binDir, shim + ext);\n if (fs.existsSync(shimPath)) {\n fs.unlinkSync(shimPath);\n removed++;\n }\n }\n\n if (removed > 0) {\n console.log(`Removed ${removed} shim(s) from ${binDir}`);\n console.log('');\n console.log('You may also want to remove ~/.nvu/bin from your PATH.');\n } else {\n console.log('No shims found to remove.');\n }\n\n exit(0);\n}\n"],"names":["teardownCmd","_args","binDir","path","join","storagePath","shims","ext","process","platform","removed","shim","shimPath","fs","existsSync","unlinkSync","console","log","exit"],"mappings":";;;;+BAKA;;;;CAIC,GACD;;;eAAwBA;;;2DAVP;yDACF;2DACE;2BACW;;;;;;AAOb,SAASA,YAAYC,KAAe;IACjD,IAAMC,SAASC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAEtC,IAAMC,QAAQ;QAAC;QAAQ;QAAO;KAAM;IACpC,IAAMC,MAAMC,QAAQC,QAAQ,KAAK,UAAU,SAAS;IAEpD,IAAIC,UAAU;QACT,kCAAA,2BAAA;;QAAL,QAAK,YAAcJ,0BAAd,SAAA,6BAAA,QAAA,yBAAA,iCAAqB;YAArB,IAAMK,OAAN;YACH,IAAMC,WAAWT,aAAI,CAACC,IAAI,CAACF,QAAQS,OAAOJ;YAC1C,IAAIM,WAAE,CAACC,UAAU,CAACF,WAAW;gBAC3BC,WAAE,CAACE,UAAU,CAACH;gBACdF;YACF;QACF;;QANK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAQL,IAAIA,UAAU,GAAG;QACfM,QAAQC,GAAG,CAAC,AAAC,WAAkCf,OAAxBQ,SAAQ,kBAAuB,OAAPR;QAC/Cc,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;IACd,OAAO;QACLD,QAAQC,GAAG,CAAC;IACd;IAEAC,IAAAA,aAAI,EAAC;AACP"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * nvu uninstall <version>
3
+ *
4
+ * Remove an installed Node version.
5
+ */
6
+ export default function uninstallCmd(args: string[]): void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * nvu uninstall <version>
3
+ *
4
+ * Remove an installed Node version.
5
+ */
6
+ export default function uninstallCmd(args: string[]): void;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * nvu uninstall <version>
7
+ *
8
+ * Remove an installed Node version.
9
+ */ "default", {
10
+ enumerable: true,
11
+ get: function() {
12
+ return uninstallCmd;
13
+ }
14
+ });
15
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
16
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
17
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
18
+ var _compatts = require("../compat.js");
19
+ var _constantsts = require("../constants.js");
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ function uninstallCmd(args) {
26
+ if (args.length === 0) {
27
+ console.log('Usage: nvu uninstall <version>');
28
+ console.log('Example: nvu uninstall 20');
29
+ console.log(' nvu uninstall v20.19.6');
30
+ (0, _exit.default)(1);
31
+ return;
32
+ }
33
+ var version = args[0].trim();
34
+ var versionsPath = _path.default.join(_constantsts.storagePath, 'versions');
35
+ // Find all matching installed versions
36
+ var matches = findInstalledVersions(versionsPath, version);
37
+ if (matches.length === 0) {
38
+ console.log("Node ".concat(version, " is not installed."));
39
+ console.log('');
40
+ console.log('Installed versions:');
41
+ listInstalledVersions(versionsPath);
42
+ (0, _exit.default)(1);
43
+ return;
44
+ }
45
+ if (matches.length > 1) {
46
+ console.log('Multiple versions match "'.concat(version, '":'));
47
+ for(var i = 0; i < matches.length; i++){
48
+ console.log(" ".concat(matches[i]));
49
+ }
50
+ console.log('');
51
+ console.log('Please specify the exact version to uninstall.');
52
+ (0, _exit.default)(1);
53
+ return;
54
+ }
55
+ var installedVersion = matches[0];
56
+ var versionPath = _path.default.join(versionsPath, installedVersion);
57
+ // Check if this is the current default
58
+ var defaultPath = _path.default.join(_constantsts.storagePath, 'default');
59
+ var isDefault = false;
60
+ if (_fs.default.existsSync(defaultPath)) {
61
+ var defaultVersion = _fs.default.readFileSync(defaultPath, 'utf8').trim();
62
+ var normalizedDefault = defaultVersion.replace(/^v/, '');
63
+ var normalizedInstalled = installedVersion.replace(/^v/, '');
64
+ // Check if default matches this version
65
+ if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf("".concat(normalizedDefault, ".")) === 0) {
66
+ isDefault = true;
67
+ }
68
+ }
69
+ // Remove the version directory
70
+ try {
71
+ (0, _compatts.rmSync)(versionPath);
72
+ console.log("Removed Node ".concat(installedVersion));
73
+ if (isDefault) {
74
+ // Clear the default since it's no longer installed
75
+ _fs.default.unlinkSync(defaultPath);
76
+ console.log('');
77
+ console.log('Note: This was your default version. Set a new default with:');
78
+ console.log(' nvu default <version>');
79
+ }
80
+ } catch (err) {
81
+ console.error("Failed to remove Node ".concat(installedVersion, ":"), err.message);
82
+ (0, _exit.default)(1);
83
+ return;
84
+ }
85
+ (0, _exit.default)(0);
86
+ }
87
+ /**
88
+ * Find all installed versions matching the given version string
89
+ */ function findInstalledVersions(versionsPath, version) {
90
+ if (!_fs.default.existsSync(versionsPath)) {
91
+ return [];
92
+ }
93
+ var normalizedVersion = version.replace(/^v/, '');
94
+ var matches = [];
95
+ // Try exact matches first
96
+ var exactMatches = [
97
+ version,
98
+ "v".concat(normalizedVersion),
99
+ normalizedVersion
100
+ ];
101
+ for(var i = 0; i < exactMatches.length; i++){
102
+ var v = exactMatches[i];
103
+ var versionPath = _path.default.join(versionsPath, v);
104
+ if (_fs.default.existsSync(versionPath) && _fs.default.statSync(versionPath).isDirectory()) {
105
+ if (matches.indexOf(v) === -1) {
106
+ matches.push(v);
107
+ }
108
+ }
109
+ }
110
+ // If we have an exact match, return just that
111
+ if (matches.length > 0) {
112
+ return matches;
113
+ }
114
+ // Try partial match (e.g., "20" matches "v20.19.6")
115
+ var entries = (0, _compatts.readdirWithTypes)(versionsPath);
116
+ for(var j = 0; j < entries.length; j++){
117
+ var entry = entries[j];
118
+ if (!entry.isDirectory()) continue;
119
+ var dirVersion = entry.name.replace(/^v/, '');
120
+ if (dirVersion.indexOf("".concat(normalizedVersion, ".")) === 0) {
121
+ matches.push(entry.name);
122
+ }
123
+ }
124
+ return matches;
125
+ }
126
+ /**
127
+ * List installed versions for user reference
128
+ */ function listInstalledVersions(versionsPath) {
129
+ if (!_fs.default.existsSync(versionsPath)) {
130
+ console.log(' (none)');
131
+ return;
132
+ }
133
+ var entries = (0, _compatts.readdirWithTypes)(versionsPath);
134
+ var versions = [];
135
+ for(var i = 0; i < entries.length; i++){
136
+ if (entries[i].isDirectory()) {
137
+ versions.push(entries[i].name);
138
+ }
139
+ }
140
+ if (versions.length === 0) {
141
+ console.log(' (none)');
142
+ } else {
143
+ for(var j = 0; j < versions.length; j++){
144
+ console.log(" ".concat(versions[j]));
145
+ }
146
+ }
147
+ }
148
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/uninstall.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { readdirWithTypes, rmSync } from '../compat.ts';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu uninstall <version>\n *\n * Remove an installed Node version.\n */\nexport default function uninstallCmd(args: string[]): void {\n if (args.length === 0) {\n console.log('Usage: nvu uninstall <version>');\n console.log('Example: nvu uninstall 20');\n console.log(' nvu uninstall v20.19.6');\n exit(1);\n return;\n }\n\n var version = args[0].trim();\n var versionsPath = path.join(storagePath, 'versions');\n\n // Find all matching installed versions\n var matches = findInstalledVersions(versionsPath, version);\n\n if (matches.length === 0) {\n console.log(`Node ${version} is not installed.`);\n console.log('');\n console.log('Installed versions:');\n listInstalledVersions(versionsPath);\n exit(1);\n return;\n }\n\n if (matches.length > 1) {\n console.log(`Multiple versions match \"${version}\":`);\n for (var i = 0; i < matches.length; i++) {\n console.log(` ${matches[i]}`);\n }\n console.log('');\n console.log('Please specify the exact version to uninstall.');\n exit(1);\n return;\n }\n\n var installedVersion = matches[0];\n var versionPath = path.join(versionsPath, installedVersion);\n\n // Check if this is the current default\n var defaultPath = path.join(storagePath, 'default');\n var isDefault = false;\n if (fs.existsSync(defaultPath)) {\n var defaultVersion = fs.readFileSync(defaultPath, 'utf8').trim();\n var normalizedDefault = defaultVersion.replace(/^v/, '');\n var normalizedInstalled = installedVersion.replace(/^v/, '');\n\n // Check if default matches this version\n if (normalizedInstalled === normalizedDefault || normalizedInstalled.indexOf(`${normalizedDefault}.`) === 0) {\n isDefault = true;\n }\n }\n\n // Remove the version directory\n try {\n rmSync(versionPath);\n console.log(`Removed Node ${installedVersion}`);\n\n if (isDefault) {\n // Clear the default since it's no longer installed\n fs.unlinkSync(defaultPath);\n console.log('');\n console.log('Note: This was your default version. Set a new default with:');\n console.log(' nvu default <version>');\n }\n } catch (err) {\n console.error(`Failed to remove Node ${installedVersion}:`, (err as Error).message);\n exit(1);\n return;\n }\n\n exit(0);\n}\n\n/**\n * Find all installed versions matching the given version string\n */\nfunction findInstalledVersions(versionsPath: string, version: string): string[] {\n if (!fs.existsSync(versionsPath)) {\n return [];\n }\n\n var normalizedVersion = version.replace(/^v/, '');\n var matches: string[] = [];\n\n // Try exact matches first\n var exactMatches = [version, `v${normalizedVersion}`, normalizedVersion];\n for (var i = 0; i < exactMatches.length; i++) {\n var v = exactMatches[i];\n var versionPath = path.join(versionsPath, v);\n if (fs.existsSync(versionPath) && fs.statSync(versionPath).isDirectory()) {\n if (matches.indexOf(v) === -1) {\n matches.push(v);\n }\n }\n }\n\n // If we have an exact match, return just that\n if (matches.length > 0) {\n return matches;\n }\n\n // Try partial match (e.g., \"20\" matches \"v20.19.6\")\n var entries = readdirWithTypes(versionsPath);\n for (var j = 0; j < entries.length; j++) {\n var entry = entries[j];\n if (!entry.isDirectory()) continue;\n var dirVersion = entry.name.replace(/^v/, '');\n if (dirVersion.indexOf(`${normalizedVersion}.`) === 0) {\n matches.push(entry.name);\n }\n }\n\n return matches;\n}\n\n/**\n * List installed versions for user reference\n */\nfunction listInstalledVersions(versionsPath: string): void {\n if (!fs.existsSync(versionsPath)) {\n console.log(' (none)');\n return;\n }\n\n var entries = readdirWithTypes(versionsPath);\n var versions: string[] = [];\n for (var i = 0; i < entries.length; i++) {\n if (entries[i].isDirectory()) {\n versions.push(entries[i].name);\n }\n }\n\n if (versions.length === 0) {\n console.log(' (none)');\n } else {\n for (var j = 0; j < versions.length; j++) {\n console.log(` ${versions[j]}`);\n }\n }\n}\n"],"names":["uninstallCmd","args","length","console","log","exit","version","trim","versionsPath","path","join","storagePath","matches","findInstalledVersions","listInstalledVersions","i","installedVersion","versionPath","defaultPath","isDefault","fs","existsSync","defaultVersion","readFileSync","normalizedDefault","replace","normalizedInstalled","indexOf","rmSync","unlinkSync","err","error","message","normalizedVersion","exactMatches","v","statSync","isDirectory","push","entries","readdirWithTypes","j","entry","dirVersion","name","versions"],"mappings":";;;;+BAMA;;;;CAIC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;wBACwB;2BACb;;;;;;AAOb,SAASA,aAAaC,IAAc;IACjD,IAAIA,KAAKC,MAAM,KAAK,GAAG;QACrBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAIC,UAAUL,IAAI,CAAC,EAAE,CAACM,IAAI;IAC1B,IAAIC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAE1C,uCAAuC;IACvC,IAAIC,UAAUC,sBAAsBL,cAAcF;IAElD,IAAIM,QAAQV,MAAM,KAAK,GAAG;QACxBC,QAAQC,GAAG,CAAC,AAAC,QAAe,OAARE,SAAQ;QAC5BH,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZU,sBAAsBN;QACtBH,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,IAAIO,QAAQV,MAAM,GAAG,GAAG;QACtBC,QAAQC,GAAG,CAAC,AAAC,4BAAmC,OAARE,SAAQ;QAChD,IAAK,IAAIS,IAAI,GAAGA,IA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AC/B,IAAIqC,WAAqB,EAAE;IAC3B,IAAK,IAAI9B,IAAI,GAAGA,IAAIwB,QAAQrC,MAAM,EAAEa,IAAK;QACvC,IAAIwB,OAAO,CAACxB,EAAE,CAACsB,WAAW,IAAI;YAC5BQ,SAASP,IAAI,CAACC,OAAO,CAACxB,EAAE,CAAC6B,IAAI;QAC/B;IACF;IAEA,IAAIC,SAAS3C,MAAM,KAAK,GAAG;QACzBC,QAAQC,GAAG,CAAC;IACd,OAAO;QACL,IAAK,IAAIqC,IAAI,GAAGA,IAAII,SAAS3C,MAAM,EAAEuC,IAAK;YACxCtC,QAAQC,GAAG,CAAC,AAAC,KAAgB,OAAZyC,QAAQ,CAACJ,EAAE;QAC9B;IACF;AACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu which
3
+ *
4
+ * Show which Node binary would be used based on current directory.
5
+ * This simulates what the shim would do.
6
+ */
7
+ export default function whichCmd(_args: string[]): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * nvu which
3
+ *
4
+ * Show which Node binary would be used based on current directory.
5
+ * This simulates what the shim would do.
6
+ */
7
+ export default function whichCmd(_args: string[]): void;
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * nvu which
7
+ *
8
+ * Show which Node binary would be used based on current directory.
9
+ * This simulates what the shim would do.
10
+ */ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return whichCmd;
14
+ }
15
+ });
16
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
17
+ var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
18
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
19
+ var _constantsts = require("../constants.js");
20
+ function _interop_require_default(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+ function whichCmd(_args) {
26
+ var cwd = process.cwd();
27
+ // Resolve version using the same logic as the shim
28
+ var version = resolveVersion(cwd);
29
+ if (!version) {
30
+ console.log('No Node version configured for this directory.');
31
+ console.log('');
32
+ console.log('To configure a version:');
33
+ console.log(' nvu local <version> - Set version for this project');
34
+ console.log(' nvu default <version> - Set global default');
35
+ (0, _exit.default)(1);
36
+ return;
37
+ }
38
+ // Check if the version is installed
39
+ var versionsPath = _path.default.join(_constantsts.storagePath, 'versions');
40
+ var versionPath = _path.default.join(versionsPath, version);
41
+ var versionPathWithV = _path.default.join(versionsPath, "v".concat(version));
42
+ var versionPathWithoutV = _path.default.join(versionsPath, version.replace(/^v/, ''));
43
+ var actualVersionPath = '';
44
+ if (_fs.default.existsSync(versionPath)) {
45
+ actualVersionPath = versionPath;
46
+ } else if (_fs.default.existsSync(versionPathWithV)) {
47
+ actualVersionPath = versionPathWithV;
48
+ } else if (_fs.default.existsSync(versionPathWithoutV)) {
49
+ actualVersionPath = versionPathWithoutV;
50
+ }
51
+ console.log("Version: ".concat(version));
52
+ console.log("Source: ".concat(getVersionSource(cwd)));
53
+ if (actualVersionPath) {
54
+ var nodePath = _path.default.join(actualVersionPath, 'bin', 'node');
55
+ console.log("Binary: ".concat(nodePath));
56
+ if (_fs.default.existsSync(nodePath)) {
57
+ console.log('Status: Installed');
58
+ } else {
59
+ console.log('Status: Directory exists but binary not found');
60
+ }
61
+ } else {
62
+ console.log("Status: Not installed (run: nvu install ".concat(version, ")"));
63
+ }
64
+ (0, _exit.default)(0);
65
+ }
66
+ /**
67
+ * Resolve version from config files (mirrors shim logic)
68
+ */ function resolveVersion(cwd) {
69
+ // Walk up directories looking for .nvurc or .nvmrc
70
+ var dir = cwd;
71
+ while(true){
72
+ // Check .nvurc first
73
+ var nvurcPath = _path.default.join(dir, '.nvurc');
74
+ if (_fs.default.existsSync(nvurcPath)) {
75
+ return _fs.default.readFileSync(nvurcPath, 'utf8').trim();
76
+ }
77
+ // Check .nvmrc
78
+ var nvmrcPath = _path.default.join(dir, '.nvmrc');
79
+ if (_fs.default.existsSync(nvmrcPath)) {
80
+ return _fs.default.readFileSync(nvmrcPath, 'utf8').trim();
81
+ }
82
+ // Move to parent
83
+ var parent = _path.default.dirname(dir);
84
+ if (parent === dir) break;
85
+ dir = parent;
86
+ }
87
+ // Check global default
88
+ var defaultPath = _path.default.join(_constantsts.storagePath, 'default');
89
+ if (_fs.default.existsSync(defaultPath)) {
90
+ return _fs.default.readFileSync(defaultPath, 'utf8').trim();
91
+ }
92
+ return null;
93
+ }
94
+ /**
95
+ * Determine the source of the version (for display)
96
+ */ function getVersionSource(cwd) {
97
+ var dir = cwd;
98
+ while(true){
99
+ var nvurcPath = _path.default.join(dir, '.nvurc');
100
+ if (_fs.default.existsSync(nvurcPath)) {
101
+ return nvurcPath;
102
+ }
103
+ var nvmrcPath = _path.default.join(dir, '.nvmrc');
104
+ if (_fs.default.existsSync(nvmrcPath)) {
105
+ return nvmrcPath;
106
+ }
107
+ var parent = _path.default.dirname(dir);
108
+ if (parent === dir) break;
109
+ dir = parent;
110
+ }
111
+ var defaultPath = _path.default.join(_constantsts.storagePath, 'default');
112
+ if (_fs.default.existsSync(defaultPath)) {
113
+ return "".concat(defaultPath, " (global default)");
114
+ }
115
+ return 'none';
116
+ }
117
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-version-use/src/commands/which.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport path from 'path';\nimport { storagePath } from '../constants.ts';\n\n/**\n * nvu which\n *\n * Show which Node binary would be used based on current directory.\n * This simulates what the shim would do.\n */\nexport default function whichCmd(_args: string[]): void {\n const cwd = process.cwd();\n\n // Resolve version using the same logic as the shim\n const version = resolveVersion(cwd);\n\n if (!version) {\n console.log('No Node version configured for this directory.');\n console.log('');\n console.log('To configure a version:');\n console.log(' nvu local <version> - Set version for this project');\n console.log(' nvu default <version> - Set global default');\n exit(1);\n return;\n }\n\n // Check if the version is installed\n const versionsPath = path.join(storagePath, 'versions');\n const versionPath = path.join(versionsPath, version);\n const versionPathWithV = path.join(versionsPath, `v${version}`);\n const versionPathWithoutV = path.join(versionsPath, version.replace(/^v/, ''));\n\n let actualVersionPath = '';\n if (fs.existsSync(versionPath)) {\n actualVersionPath = versionPath;\n } else if (fs.existsSync(versionPathWithV)) {\n actualVersionPath = versionPathWithV;\n } else if (fs.existsSync(versionPathWithoutV)) {\n actualVersionPath = versionPathWithoutV;\n }\n\n console.log(`Version: ${version}`);\n console.log(`Source: ${getVersionSource(cwd)}`);\n\n if (actualVersionPath) {\n const nodePath = path.join(actualVersionPath, 'bin', 'node');\n console.log(`Binary: ${nodePath}`);\n if (fs.existsSync(nodePath)) {\n console.log('Status: Installed');\n } else {\n console.log('Status: Directory exists but binary not found');\n }\n } else {\n console.log(`Status: Not installed (run: nvu install ${version})`);\n }\n\n exit(0);\n}\n\n/**\n * Resolve version from config files (mirrors shim logic)\n */\nfunction resolveVersion(cwd: string): string | null {\n // Walk up directories looking for .nvurc or .nvmrc\n let dir = cwd;\n while (true) {\n // Check .nvurc first\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return fs.readFileSync(nvurcPath, 'utf8').trim();\n }\n\n // Check .nvmrc\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return fs.readFileSync(nvmrcPath, 'utf8').trim();\n }\n\n // Move to parent\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n // Check global default\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return fs.readFileSync(defaultPath, 'utf8').trim();\n }\n\n return null;\n}\n\n/**\n * Determine the source of the version (for display)\n */\nfunction getVersionSource(cwd: string): string {\n let dir = cwd;\n while (true) {\n const nvurcPath = path.join(dir, '.nvurc');\n if (fs.existsSync(nvurcPath)) {\n return nvurcPath;\n }\n\n const nvmrcPath = path.join(dir, '.nvmrc');\n if (fs.existsSync(nvmrcPath)) {\n return nvmrcPath;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n const defaultPath = path.join(storagePath, 'default');\n if (fs.existsSync(defaultPath)) {\n return `${defaultPath} (global default)`;\n }\n\n return 'none';\n}\n"],"names":["whichCmd","_args","cwd","process","version","resolveVersion","console","log","exit","versionsPath","path","join","storagePath","versionPath","versionPathWithV","versionPathWithoutV","replace","actualVersionPath","fs","existsSync","getVersionSource","nodePath","dir","nvurcPath","readFileSync","trim","nvmrcPath","parent","dirname","defaultPath"],"mappings":";;;;+BAKA;;;;;CAKC,GACD;;;eAAwBA;;;2DAXP;yDACF;2DACE;2BACW;;;;;;AAQb,SAASA,SAASC,KAAe;IAC9C,IAAMC,MAAMC,QAAQD,GAAG;IAEvB,mDAAmD;IACnD,IAAME,UAAUC,eAAeH;IAE/B,IAAI,CAACE,SAAS;QACZE,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZC,IAAAA,aAAI,EAAC;QACL;IACF;IAEA,oCAAoC;IACpC,IAAMC,eAAeC,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC5C,IAAMC,cAAcH,aAAI,CAACC,IAAI,CAACF,cAAcL;IAC5C,IAAMU,mBAAmBJ,aAAI,CAACC,IAAI,CAACF,cAAc,AAAC,IAAW,OAARL;IACrD,IAAMW,sBAAsBL,aAAI,CAACC,IAAI,CAACF,cAAcL,QAAQY,OAAO,CAAC,MAAM;IAE1E,IAAIC,oBAAoB;IACxB,IAAIC,WAAE,CAACC,UAAU,CAACN,cAAc;QAC9BI,oBAAoBJ;IACtB,OAAO,IAAIK,WAAE,CAACC,UAAU,CAACL,mBAAmB;QAC1CG,oBA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AQJ,IAAI;IAClD;IAEA,OAAO;AACT;AAEA;;CAEC,GACD,SAASL,iBAAiBlB,GAAW;IACnC,IAAIoB,MAAMpB;IACV,MAAO,KAAM;QACX,IAAMqB,YAAYb,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACI,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMG,YAAYhB,aAAI,CAACC,IAAI,CAACW,KAAK;QACjC,IAAIJ,WAAE,CAACC,UAAU,CAACO,YAAY;YAC5B,OAAOA;QACT;QAEA,IAAMC,SAASjB,aAAI,CAACkB,OAAO,CAACN;QAC5B,IAAIK,WAAWL,KAAK;QACpBA,MAAMK;IACR;IAEA,IAAME,cAAcnB,aAAI,CAACC,IAAI,CAACC,wBAAW,EAAE;IAC3C,IAAIM,WAAE,CAACC,UAAU,CAACU,cAAc;QAC9B,OAAO,AAAC,GAAc,OAAZA,aAAY;IACxB;IAEA,OAAO;AACT"}
@@ -1,2 +1,19 @@
1
1
  export declare function homedir(): string;
2
2
  export declare function stringEndsWith(str: string, search: string, position?: number): boolean;
3
+ /**
4
+ * Recursive mkdir for Node.js 0.8+
5
+ */
6
+ export declare function mkdirpSync(dir: string): void;
7
+ /**
8
+ * Recursive rm for Node.js 0.8+
9
+ */
10
+ export declare function rmSync(dir: string): void;
11
+ /**
12
+ * Read directory entries with types for Node.js 0.8+
13
+ * Returns array of {name, isDirectory()}
14
+ */
15
+ export interface DirEntry {
16
+ name: string;
17
+ isDirectory(): boolean;
18
+ }
19
+ export declare function readdirWithTypes(dir: string): DirEntry[];