install-module-linked-compat 0.1.0 → 0.2.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 (98) hide show
  1. package/README.md +2 -0
  2. package/bin/cli.js +2 -2
  3. package/dist/cjs/cli.js +7 -7
  4. package/dist/cjs/cli.js.map +1 -1
  5. package/dist/cjs/compat.d.cts +15 -1
  6. package/dist/cjs/compat.d.ts +15 -1
  7. package/dist/cjs/compat.js +141 -6
  8. package/dist/cjs/compat.js.map +1 -1
  9. package/dist/cjs/index.d.cts +5 -5
  10. package/dist/cjs/index.d.ts +5 -5
  11. package/dist/cjs/index.js +70 -17
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/workers/spawn.d.cts +3 -0
  14. package/dist/cjs/workers/spawn.d.ts +3 -0
  15. package/dist/cjs/workers/spawn.js +24 -0
  16. package/dist/cjs/workers/spawn.js.map +1 -0
  17. package/dist/esm/cli.js +6 -6
  18. package/dist/esm/cli.js.map +1 -1
  19. package/dist/esm/compat.d.ts +15 -1
  20. package/dist/esm/compat.js +66 -2
  21. package/dist/esm/compat.js.map +1 -1
  22. package/dist/esm/index.d.ts +5 -5
  23. package/dist/esm/index.js +21 -10
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/workers/spawn.d.ts +3 -0
  26. package/dist/esm/workers/spawn.js +6 -0
  27. package/dist/esm/workers/spawn.js.map +1 -0
  28. package/package.json +5 -6
  29. package/dist/cjs/constants.d.cts +0 -1
  30. package/dist/cjs/constants.d.ts +0 -1
  31. package/dist/cjs/constants.js +0 -19
  32. package/dist/cjs/constants.js.map +0 -1
  33. package/dist/cjs/lib/cache.d.cts +0 -2
  34. package/dist/cjs/lib/cache.d.ts +0 -2
  35. package/dist/cjs/lib/cache.js +0 -182
  36. package/dist/cjs/lib/cache.js.map +0 -1
  37. package/dist/cjs/lib/clear.d.cts +0 -2
  38. package/dist/cjs/lib/clear.d.ts +0 -2
  39. package/dist/cjs/lib/clear.js +0 -17
  40. package/dist/cjs/lib/clear.js.map +0 -1
  41. package/dist/cjs/lib/getSpecifier.d.cts +0 -2
  42. package/dist/cjs/lib/getSpecifier.d.ts +0 -2
  43. package/dist/cjs/lib/getSpecifier.js +0 -34
  44. package/dist/cjs/lib/getSpecifier.js.map +0 -1
  45. package/dist/cjs/lib/install.d.cts +0 -2
  46. package/dist/cjs/lib/install.d.ts +0 -2
  47. package/dist/cjs/lib/install.js +0 -69
  48. package/dist/cjs/lib/install.js.map +0 -1
  49. package/dist/cjs/lib/parseInstallString.d.cts +0 -4
  50. package/dist/cjs/lib/parseInstallString.d.ts +0 -4
  51. package/dist/cjs/lib/parseInstallString.js +0 -51
  52. package/dist/cjs/lib/parseInstallString.js.map +0 -1
  53. package/dist/cjs/lib/renameWithFallback.d.cts +0 -1
  54. package/dist/cjs/lib/renameWithFallback.d.ts +0 -1
  55. package/dist/cjs/lib/renameWithFallback.js +0 -32
  56. package/dist/cjs/lib/renameWithFallback.js.map +0 -1
  57. package/dist/cjs/types.d.cts +0 -9
  58. package/dist/cjs/types.d.ts +0 -9
  59. package/dist/cjs/types.js +0 -5
  60. package/dist/cjs/types.js.map +0 -1
  61. package/dist/cjs/workers/async.d.cts +0 -2
  62. package/dist/cjs/workers/async.d.ts +0 -2
  63. package/dist/cjs/workers/async.js +0 -108
  64. package/dist/cjs/workers/async.js.map +0 -1
  65. package/dist/cjs/workers/sync.d.cts +0 -1
  66. package/dist/cjs/workers/sync.d.ts +0 -1
  67. package/dist/cjs/workers/sync.js +0 -30
  68. package/dist/cjs/workers/sync.js.map +0 -1
  69. package/dist/esm/constants.d.ts +0 -1
  70. package/dist/esm/constants.js +0 -3
  71. package/dist/esm/constants.js.map +0 -1
  72. package/dist/esm/lib/cache.d.ts +0 -2
  73. package/dist/esm/lib/cache.js +0 -93
  74. package/dist/esm/lib/cache.js.map +0 -1
  75. package/dist/esm/lib/clear.d.ts +0 -2
  76. package/dist/esm/lib/clear.js +0 -6
  77. package/dist/esm/lib/clear.js.map +0 -1
  78. package/dist/esm/lib/getSpecifier.d.ts +0 -2
  79. package/dist/esm/lib/getSpecifier.js +0 -18
  80. package/dist/esm/lib/getSpecifier.js.map +0 -1
  81. package/dist/esm/lib/install.d.ts +0 -2
  82. package/dist/esm/lib/install.js +0 -23
  83. package/dist/esm/lib/install.js.map +0 -1
  84. package/dist/esm/lib/parseInstallString.d.ts +0 -4
  85. package/dist/esm/lib/parseInstallString.js +0 -14
  86. package/dist/esm/lib/parseInstallString.js.map +0 -1
  87. package/dist/esm/lib/renameWithFallback.d.ts +0 -1
  88. package/dist/esm/lib/renameWithFallback.js +0 -16
  89. package/dist/esm/lib/renameWithFallback.js.map +0 -1
  90. package/dist/esm/types.d.ts +0 -9
  91. package/dist/esm/types.js +0 -1
  92. package/dist/esm/types.js.map +0 -1
  93. package/dist/esm/workers/async.d.ts +0 -2
  94. package/dist/esm/workers/async.js +0 -50
  95. package/dist/esm/workers/async.js.map +0 -1
  96. package/dist/esm/workers/sync.d.ts +0 -1
  97. package/dist/esm/workers/sync.js +0 -14
  98. package/dist/esm/workers/sync.js.map +0 -1
@@ -1,4 +1,68 @@
1
+ import childProcess from 'child_process';
2
+ import fs from 'fs';
3
+ import { safeRm, safeRmSync } from 'fs-remove-compat';
4
+ import { getContent } from 'get-file-compat';
5
+ import mkdirp from 'mkdirp-classic';
6
+ import Module from 'module';
7
+ import { bind } from 'node-version-call-local';
1
8
  import os from 'os';
2
- export function homedir() {
3
- return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();
9
+ import path from 'path';
10
+ import url from 'url';
11
+ // Tier 2 deferral: these load only on the sync and pre-Node 4 paths.
12
+ const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
13
+ // Workers MUST always load from dist/cjs/ for old Node compatibility (works from both cjs and esm).
14
+ const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
15
+ const cjsDir = typeof require === 'undefined' ? path.join(__dirname, '..', 'cjs') : __dirname;
16
+ export function detect() {
17
+ const [major, minor] = process.versions.node.split('.').map(Number);
18
+ return {
19
+ major,
20
+ minor,
21
+ hasFetch: typeof fetch === 'function',
22
+ hasRm: typeof fs.rm === 'function' && typeof fs.rmSync === 'function',
23
+ hasMkdir: major > 10 || major === 10 && minor >= 12,
24
+ hasHomedir: typeof os.homedir === 'function',
25
+ hasExecFileSync: typeof childProcess.execFileSync === 'function'
26
+ };
4
27
  }
28
+ export function overlayFor(detection) {
29
+ const overlay = {};
30
+ if (detection.major === 0) {
31
+ // 0.x npm cannot install modern packages: delegate the spawn to a newer
32
+ // local node, which runs the worker (the proven 1.6.5 mechanism).
33
+ overlay.spawn = bind('>0.12', path.join(cjsDir, 'workers', 'spawn.js'), {
34
+ callbacks: true
35
+ });
36
+ }
37
+ if (!detection.hasFetch) {
38
+ overlay.fetchText = (u, callback)=>getContent(u, 'utf8', (err, res)=>err ? callback(err) : callback(null, res === null || res === void 0 ? void 0 : res.content));
39
+ }
40
+ if (!detection.hasRm) {
41
+ overlay.rm = (p, callback)=>safeRm(p, (err)=>callback(err !== null && err !== void 0 ? err : null));
42
+ overlay.rmSync = (p)=>safeRmSync(p);
43
+ }
44
+ if (!detection.hasMkdir) {
45
+ overlay.mkdir = (p, callback)=>mkdirp(p, callback);
46
+ }
47
+ if (!detection.hasHomedir) {
48
+ overlay.homedir = ()=>_require('homedir-polyfill')();
49
+ }
50
+ if (!detection.hasExecFileSync) {
51
+ overlay.syncExec = (workerPath, data)=>{
52
+ const payload = JSON.parse(data);
53
+ return _require('function-exec-sync')({
54
+ callbacks: true
55
+ }, workerPath, payload.installString, payload.nodeModulesPath, {
56
+ cachePath: payload.cachePath,
57
+ workerModule: payload.workerModule
58
+ });
59
+ };
60
+ }
61
+ // The sync child is a fresh process on this same node: it needs every shim
62
+ // this node lacks, resolved from this module in its own process.
63
+ if (detection.major === 0 || !detection.hasFetch || !detection.hasRm || !detection.hasMkdir || !detection.hasHomedir) {
64
+ overlay.workerModule = path.join(cjsDir, 'compat.js');
65
+ }
66
+ return overlay;
67
+ }
68
+ export default overlayFor(detect());
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/compat.ts"],"sourcesContent":["import os from 'os';\n\nexport function homedir(): string {\n return typeof os.homedir === 'function' ? os.homedir() : require('homedir-polyfill')();\n}\n"],"names":["os","homedir","require"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AAEpB,OAAO,SAASC;IACd,OAAO,OAAOD,GAAGC,OAAO,KAAK,aAAaD,GAAGC,OAAO,KAAKC,QAAQ;AACnE"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/compat.ts"],"sourcesContent":["import childProcess from 'child_process';\nimport fs from 'fs';\nimport { safeRm, safeRmSync } from 'fs-remove-compat';\nimport { getContent } from 'get-file-compat';\nimport type { InstallOptions } from 'install-module-linked';\nimport mkdirp from 'mkdirp-classic';\nimport Module from 'module';\nimport { bind } from 'node-version-call-local';\nimport os from 'os';\nimport path from 'path';\nimport url from 'url';\n\n// Tier 2 deferral: these load only on the sync and pre-Node 4 paths.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n// Workers MUST always load from dist/cjs/ for old Node compatibility (works from both cjs and esm).\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst cjsDir = typeof require === 'undefined' ? path.join(__dirname, '..', 'cjs') : __dirname;\n\nexport interface OverlayDetection {\n major: number;\n minor: number;\n hasFetch: boolean;\n hasRm: boolean;\n hasMkdir: boolean;\n hasHomedir: boolean;\n hasExecFileSync: boolean;\n}\n\nexport function detect(): OverlayDetection {\n const [major, minor] = process.versions.node.split('.').map(Number) as [number, number];\n return {\n major,\n minor,\n hasFetch: typeof fetch === 'function',\n hasRm: typeof fs.rm === 'function' && typeof fs.rmSync === 'function',\n hasMkdir: major > 10 || (major === 10 && minor >= 12),\n hasHomedir: typeof os.homedir === 'function',\n hasExecFileSync: typeof childProcess.execFileSync === 'function',\n };\n}\n\n// The shims the running node lacks, keyed by the core's InstallOptions names;\n// empty on Node >= 18.\nexport type Overlay = Partial<Pick<InstallOptions, 'spawn' | 'fetchText' | 'rm' | 'rmSync' | 'mkdir' | 'homedir' | 'syncExec' | 'workerModule'>>;\n\nexport function overlayFor(detection: OverlayDetection): Overlay {\n const overlay: Overlay = {};\n if (detection.major === 0) {\n // 0.x npm cannot install modern packages: delegate the spawn to a newer\n // local node, which runs the worker (the proven 1.6.5 mechanism).\n overlay.spawn = bind('>0.12', path.join(cjsDir, 'workers', 'spawn.js'), { callbacks: true });\n }\n if (!detection.hasFetch) {\n overlay.fetchText = (u, callback) => getContent(u, 'utf8', (err, res) => (err ? callback(err) : callback(null, res?.content)));\n }\n if (!detection.hasRm) {\n overlay.rm = (p, callback) => safeRm(p, (err) => callback(err ?? null));\n overlay.rmSync = (p) => safeRmSync(p);\n }\n if (!detection.hasMkdir) {\n overlay.mkdir = (p, callback) => mkdirp(p, callback);\n }\n if (!detection.hasHomedir) {\n overlay.homedir = () => _require('homedir-polyfill')();\n }\n if (!detection.hasExecFileSync) {\n overlay.syncExec = (workerPath, data) => {\n const payload = JSON.parse(data) as { installString: string; nodeModulesPath: string; cachePath?: string; workerModule?: string };\n return _require('function-exec-sync')({ callbacks: true }, workerPath, payload.installString, payload.nodeModulesPath, { cachePath: payload.cachePath, workerModule: payload.workerModule }) as string | undefined;\n };\n }\n // The sync child is a fresh process on this same node: it needs every shim\n // this node lacks, resolved from this module in its own process.\n if (detection.major === 0 || !detection.hasFetch || !detection.hasRm || !detection.hasMkdir || !detection.hasHomedir) {\n overlay.workerModule = path.join(cjsDir, 'compat.js');\n }\n return overlay;\n}\n\nexport default overlayFor(detect());\n"],"names":["childProcess","fs","safeRm","safeRmSync","getContent","mkdirp","Module","bind","os","path","url","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","cjsDir","join","detect","major","minor","process","versions","node","split","map","Number","hasFetch","fetch","hasRm","rm","rmSync","hasMkdir","hasHomedir","homedir","hasExecFileSync","execFileSync","overlayFor","detection","overlay","spawn","callbacks","fetchText","u","callback","err","res","content","p","mkdir","syncExec","workerPath","data","payload","JSON","parse","installString","nodeModulesPath","cachePath","workerModule"],"mappings":"AAAA,OAAOA,kBAAkB,gBAAgB;AACzC,OAAOC,QAAQ,KAAK;AACpB,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAmB;AACtD,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,YAAY,SAAS;AAC5B,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,OAAOC,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,qEAAqE;AACrE,MAAMC,WAAW,OAAOC,YAAY,cAAcN,OAAOO,aAAa,CAAC,YAAYH,GAAG,IAAIE;AAE1F,oGAAoG;AACpG,MAAME,YAAYL,KAAKM,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaN,IAAIO,aAAa,CAAC,YAAYP,GAAG;AACjH,MAAMQ,SAAS,OAAON,YAAY,cAAcH,KAAKU,IAAI,CAACL,WAAW,MAAM,SAASA;AAYpF,OAAO,SAASM;IACd,MAAM,CAACC,OAAOC,MAAM,GAAGC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,KAAKC,GAAG,CAACC;IAC5D,OAAO;QACLP;QACAC;QACAO,UAAU,OAAOC,UAAU;QAC3BC,OAAO,OAAO9B,GAAG+B,EAAE,KAAK,cAAc,OAAO/B,GAAGgC,MAAM,KAAK;QAC3DC,UAAUb,QAAQ,MAAOA,UAAU,MAAMC,SAAS;QAClDa,YAAY,OAAO3B,GAAG4B,OAAO,KAAK;QAClCC,iBAAiB,OAAOrC,aAAasC,YAAY,KAAK;IACxD;AACF;AAMA,OAAO,SAASC,WAAWC,SAA2B;IACpD,M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AAI,CAACM,UAAUL,UAAU,EAAE;QACpHM,QAAQoB,YAAY,GAAGpD,KAAKU,IAAI,CAACD,QAAQ;IAC3C;IACA,OAAOuB;AACT;AAEA,eAAeF,WAAWnB,UAAU"}
@@ -1,9 +1,9 @@
1
- import type { InstallCallback, InstallOptions } from './types.js';
2
- export { default as clear } from './lib/clear.js';
3
- export { default as install } from './lib/install.js';
4
- export { default as parseInstallString } from './lib/parseInstallString.js';
5
- export type * from './types.js';
1
+ import type { CleanOptions, InstallCallback, InstallOptions } from 'install-module-linked';
2
+ import { install, parseInstallString } from 'install-module-linked';
3
+ export type * from 'install-module-linked';
6
4
  export default function installModule(installString: string, nodeModulesPath: string, callback: InstallCallback): void;
7
5
  export default function installModule(installString: string, nodeModulesPath: string, options: InstallOptions, callback: InstallCallback): void;
8
6
  export default function installModule(installString: string, nodeModulesPath: string, options?: InstallOptions): Promise<string>;
9
7
  export declare function sync(installString: string, nodeModulesPath: string, options?: InstallOptions): string | undefined;
8
+ export declare function clear(options?: CleanOptions): void;
9
+ export { install, parseInstallString };
package/dist/esm/index.js CHANGED
@@ -1,14 +1,25 @@
1
- import worker from './workers/async.js';
2
- import workerSync from './workers/sync.js';
3
- export { default as clear } from './lib/clear.js';
4
- export { default as install } from './lib/install.js';
5
- export { default as parseInstallString } from './lib/parseInstallString.js';
1
+ import installModuleCore, { clear as clearCore, install, parseInstallString, sync as syncCore } from 'install-module-linked';
2
+ import overlay from './compat.js';
6
3
  export default function installModule(installString, nodeModulesPath, options, callback) {
7
- callback = typeof options === 'function' ? options : callback;
8
- options = typeof options === 'function' ? {} : options || {};
9
- if (typeof callback === 'function') return worker(installString, nodeModulesPath, options, callback);
10
- return new Promise((resolve, reject)=>worker(installString, nodeModulesPath, options, (err, dest)=>err ? reject(err) : resolve(dest)));
4
+ const userOptions = typeof options === 'function' ? {} : options || {};
5
+ const userCallback = typeof options === 'function' ? options : callback;
6
+ const merged = {
7
+ ...overlay,
8
+ ...userOptions
9
+ };
10
+ if (typeof userCallback === 'function') return installModuleCore(installString, nodeModulesPath, merged, userCallback);
11
+ return installModuleCore(installString, nodeModulesPath, merged);
11
12
  }
12
13
  export function sync(installString, nodeModulesPath, options) {
13
- return workerSync(installString, nodeModulesPath, options || {});
14
+ return syncCore(installString, nodeModulesPath, {
15
+ ...overlay,
16
+ ...options
17
+ });
14
18
  }
19
+ export function clear(options) {
20
+ clearCore({
21
+ ...overlay,
22
+ ...options
23
+ });
24
+ }
25
+ export { install, parseInstallString };
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/index.ts"],"sourcesContent":["import type { InstallCallback, InstallOptions } from './types.ts';\nimport worker from './workers/async.ts';\nimport workerSync from './workers/sync.ts';\n\nexport { default as clear } from './lib/clear.ts';\nexport { default as install } from './lib/install.ts';\nexport { default as parseInstallString } from './lib/parseInstallString.ts';\nexport type * from './types.ts';\n\nexport default function installModule(installString: string, nodeModulesPath: string, callback: InstallCallback): void;\nexport default function installModule(installString: string, nodeModulesPath: string, options: InstallOptions, callback: InstallCallback): void;\nexport default function installModule(installString: string, nodeModulesPath: string, options?: InstallOptions): Promise<string>;\nexport default function installModule(installString: string, nodeModulesPath: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): void | Promise<string> {\n callback = typeof options === 'function' ? options : callback;\n options = typeof options === 'function' ? {} : ((options || {}) as InstallOptions);\n\n if (typeof callback === 'function') return worker(installString, nodeModulesPath, options, callback);\n return new Promise((resolve, reject) => worker(installString, nodeModulesPath, options, (err, dest) => (err ? reject(err) : resolve(dest as string))));\n}\n\nexport function sync(installString: string, nodeModulesPath: string, options?: InstallOptions): string | undefined {\n return workerSync(installString, nodeModulesPath, options || {});\n}\n"],"names":["worker","workerSync","default","clear","install","parseInstallString","installModule","installString","nodeModulesPath","options","callback","Promise","resolve","reject","err","dest","sync"],"mappings":"AACA,OAAOA,YAAY,qBAAqB;AACxC,OAAOC,gBAAgB,oBAAoB;AAE3C,SAASC,WAAWC,KAAK,QAAQ,iBAAiB;AAClD,SAASD,WAAWE,OAAO,QAAQ,mBAAmB;AACtD,SAASF,WAAWG,kBAAkB,QAAQ,8BAA8B;AAM5E,eAAe,SAASC,cAAcC,aAAqB,EAAEC,eAAuB,EAAEC,OAA0C,EAAEC,QAA0B;IAC1JA,WAAW,OAAOD,YAAY,aAAaA,UAAUC;IACrDD,UAAU,OAAOA,YAAY,aAAa,CAAC,IAAMA,WAAW,CAAC;IAE7D,IAAI,OAAOC,aAAa,YAAY,OAAOV,OAAOO,eAAeC,iBAAiBC,SAASC;IAC3F,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWb,OAAOO,eAAeC,iBAAiBC,SAAS,CAACK,KAAKC,OAAUD,MAAMD,OAAOC,OAAOF,QAAQG;AACtI;AAEA,OAAO,SAASC,KAAKT,aAAqB,EAAEC,eAAuB,EAAEC,OAAwB;IAC3F,OAAOR,WAAWM,eAAeC,iBAAiBC,WAAW,CAAC;AAChE"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/index.ts"],"sourcesContent":["import type { CleanOptions, InstallCallback, InstallOptions } from 'install-module-linked';\nimport installModuleCore, { clear as clearCore, install, parseInstallString, sync as syncCore } from 'install-module-linked';\nimport overlay from './compat.ts';\n\nexport type * from 'install-module-linked';\n\n// Identical API to install-module-linked; the overlay supplies the shims the\n// running node lacks (empty on Node >= 18), and user options always win.\n\nexport default function installModule(installString: string, nodeModulesPath: string, callback: InstallCallback): void;\nexport default function installModule(installString: string, nodeModulesPath: string, options: InstallOptions, callback: InstallCallback): void;\nexport default function installModule(installString: string, nodeModulesPath: string, options?: InstallOptions): Promise<string>;\nexport default function installModule(installString: string, nodeModulesPath: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): void | Promise<string> {\n const userOptions = typeof options === 'function' ? {} : options || {};\n const userCallback = typeof options === 'function' ? options : callback;\n const merged = { ...overlay, ...userOptions };\n if (typeof userCallback === 'function') return installModuleCore(installString, nodeModulesPath, merged, userCallback);\n return installModuleCore(installString, nodeModulesPath, merged);\n}\n\nexport function sync(installString: string, nodeModulesPath: string, options?: InstallOptions): string | undefined {\n return syncCore(installString, nodeModulesPath, { ...overlay, ...options });\n}\n\nexport function clear(options?: CleanOptions): void {\n clearCore({ ...overlay, ...options });\n}\n\nexport { install, parseInstallString };\n"],"names":["installModuleCore","clear","clearCore","install","parseInstallString","sync","syncCore","overlay","installModule","installString","nodeModulesPath","options","callback","userOptions","userCallback","merged"],"mappings":"AACA,OAAOA,qBAAqBC,SAASC,SAAS,EAAEC,OAAO,EAAEC,kBAAkB,EAAEC,QAAQC,QAAQ,QAAQ,wBAAwB;AAC7H,OAAOC,aAAa,cAAc;AAUlC,eAAe,SAASC,cAAcC,aAAqB,EAAEC,eAAuB,EAAEC,OAA0C,EAAEC,QAA0B;IAC1J,MAAMC,cAAc,OAAOF,YAAY,aAAa,CAAC,IAAIA,WAAW,CAAC;IACrE,MAAMG,eAAe,OAAOH,YAAY,aAAaA,UAAUC;IAC/D,MAAMG,SAAS;QAAE,GAAGR,OAAO;QAAE,GAAGM,WAAW;IAAC;IAC5C,IAAI,OAAOC,iBAAiB,YAAY,OAAOd,kBAAkBS,eAAeC,iBAAiBK,QAAQD;IACzG,OAAOd,kBAAkBS,eAAeC,iBAAiBK;AAC3D;AAEA,OAAO,SAASV,KAAKI,aAAqB,EAAEC,eAAuB,EAAEC,OAAwB;IAC3F,OAAOL,SAASG,eAAeC,iBAAiB;QAAE,GAAGH,OAAO;QAAE,GAAGI,OAAO;IAAC;AAC3E;AAEA,OAAO,SAASV,MAAMU,OAAsB;IAC1CT,UAAU;QAAE,GAAGK,OAAO;QAAE,GAAGI,OAAO;IAAC;AACrC;AAEA,SAASR,OAAO,EAAEC,kBAAkB,GAAG"}
@@ -0,0 +1,3 @@
1
+ export default function spawnRemote(command: string, args: string[], options: {
2
+ cwd: string;
3
+ }, callback: (err: Error | null) => void): void;
@@ -0,0 +1,6 @@
1
+ import spawn from 'cross-spawn-cb';
2
+ // 0.x delegation child: node-version-call-local runs this in a newer local
3
+ // node, where npm can install modern packages (the proven 1.6.5 mechanism).
4
+ export default function spawnRemote(command, args, options, callback) {
5
+ spawn(command, args, options, (err)=>callback(err !== null && err !== void 0 ? err : null));
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/workers/spawn.ts"],"sourcesContent":["import spawn from 'cross-spawn-cb';\n\n// 0.x delegation child: node-version-call-local runs this in a newer local\n// node, where npm can install modern packages (the proven 1.6.5 mechanism).\nexport default function spawnRemote(command: string, args: string[], options: { cwd: string }, callback: (err: Error | null) => void): void {\n spawn(command, args, options, (err) => callback(err ?? null));\n}\n"],"names":["spawn","spawnRemote","command","args","options","callback","err"],"mappings":"AAAA,OAAOA,WAAW,iBAAiB;AAEnC,2EAA2E;AAC3E,4EAA4E;AAC5E,eAAe,SAASC,YAAYC,OAAe,EAAEC,IAAc,EAAEC,OAAwB,EAAEC,QAAqC;IAClIL,MAAME,SAASC,MAAMC,SAAS,CAACE,MAAQD,SAASC,gBAAAA,iBAAAA,MAAO;AACzD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "install-module-linked-compat",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Installs and symlinks a module into node_modules",
5
5
  "keywords": [
6
6
  "npm",
@@ -53,21 +53,20 @@
53
53
  "cross-spawn-cb": "^3.0.0",
54
54
  "exit-compat": "^1.0.0",
55
55
  "fs-remove-compat": "^1.0.0",
56
+ "function-exec-sync": "^2.1.2",
56
57
  "get-file-compat": "^2.0.0",
57
58
  "getopts-compat": "^2.2.5",
58
59
  "homedir-polyfill": "^1.0.3",
59
- "lockfile": "^1.0.4",
60
+ "install-module-linked": "^2.0.1",
60
61
  "mkdirp-classic": "^0.5.2",
61
- "node-version-call-local": "^1.0.0",
62
- "queue-cb": "^1.0.0",
63
- "temp-suffix": "^1.0.10"
62
+ "node-version-call-local": "^1.0.0"
64
63
  },
65
64
  "devDependencies": {
66
- "@types/lockfile": "^1.0.4",
67
65
  "@types/mocha": "*",
68
66
  "@types/node": "*",
69
67
  "node-version-use": "*",
70
68
  "pinkie-promise": "*",
69
+ "queue-cb": "^1.0.0",
71
70
  "ts-dev-stack": "*",
72
71
  "tsds-config": "*"
73
72
  },
@@ -1 +0,0 @@
1
- export declare const DEFAULT_CACHE_PATH: string;
@@ -1 +0,0 @@
1
- export declare const DEFAULT_CACHE_PATH: string;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "DEFAULT_CACHE_PATH", {
6
- enumerable: true,
7
- get: function() {
8
- return DEFAULT_CACHE_PATH;
9
- }
10
- });
11
- var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
- var _compatts = require("./compat.js");
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- var DEFAULT_CACHE_PATH = _path.default.join((0, _compatts.homedir)(), '.iml');
19
- /* 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; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/constants.ts"],"sourcesContent":["import path from 'path';\n\nimport { homedir } from './compat.ts';\n\nexport const DEFAULT_CACHE_PATH = path.join(homedir(), '.iml') as string;\n"],"names":["DEFAULT_CACHE_PATH","path","join","homedir"],"mappings":";;;;+BAIaA;;;eAAAA;;;2DAJI;wBAEO;;;;;;AAEjB,IAAMA,qBAAqBC,aAAI,CAACC,IAAI,CAACC,IAAAA,iBAAO,KAAI"}
@@ -1,2 +0,0 @@
1
- import type { EnsureCachedCallback } from '../types.js';
2
- export default function ensureCached(installString: string, cachePath: string, callback: EnsureCachedCallback): void;
@@ -1,2 +0,0 @@
1
- import type { EnsureCachedCallback } from '../types.js';
2
- export default function ensureCached(installString: string, cachePath: string, callback: EnsureCachedCallback): void;
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return ensureCached;
9
- }
10
- });
11
- var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- var _fsremovecompat = require("fs-remove-compat");
13
- var _lockfile = /*#__PURE__*/ _interop_require_default(require("lockfile"));
14
- var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
15
- var _path = /*#__PURE__*/ _interop_require_default(require("path"));
16
- var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
17
- var _tempsuffix = /*#__PURE__*/ _interop_require_default(require("temp-suffix"));
18
- var _getSpecifierts = /*#__PURE__*/ _interop_require_default(require("./getSpecifier.js"));
19
- var _installts = /*#__PURE__*/ _interop_require_default(require("./install.js"));
20
- var _parseInstallStringts = /*#__PURE__*/ _interop_require_default(require("./parseInstallString.js"));
21
- var _renameWithFallbackts = /*#__PURE__*/ _interop_require_default(require("./renameWithFallback.js"));
22
- function _array_like_to_array(arr, len) {
23
- if (len == null || len > arr.length) len = arr.length;
24
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25
- return arr2;
26
- }
27
- function _array_without_holes(arr) {
28
- if (Array.isArray(arr)) return _array_like_to_array(arr);
29
- }
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else obj[key] = value;
39
- return obj;
40
- }
41
- function _interop_require_default(obj) {
42
- return obj && obj.__esModule ? obj : {
43
- default: obj
44
- };
45
- }
46
- function _iterable_to_array(iter) {
47
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
48
- return Array.from(iter);
49
- }
50
- }
51
- function _non_iterable_spread() {
52
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53
- }
54
- function _object_spread(target) {
55
- for(var i = 1; i < arguments.length; i++){
56
- var source = arguments[i] != null ? arguments[i] : {};
57
- var ownKeys = Object.keys(source);
58
- if (typeof Object.getOwnPropertySymbols === "function") {
59
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
60
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
61
- }));
62
- }
63
- ownKeys.forEach(function(key) {
64
- _define_property(target, key, source[key]);
65
- });
66
- }
67
- return target;
68
- }
69
- function _to_consumable_array(arr) {
70
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
71
- }
72
- function _unsupported_iterable_to_array(o, minLen) {
73
- if (!o) return;
74
- if (typeof o === "string") return _array_like_to_array(o, minLen);
75
- var n = Object.prototype.toString.call(o).slice(8, -1);
76
- if (n === "Object" && o.constructor) n = o.constructor.name;
77
- if (n === "Map" || n === "Set") return Array.from(n);
78
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
79
- }
80
- var LOCK_OPTIONS = {
81
- wait: 600000,
82
- pollPeriod: 100,
83
- stale: 660000,
84
- retries: 3
85
- };
86
- function ensureCached(installString, cachePath, callback) {
87
- (0, _getSpecifierts.default)(installString, function(err, specifier) {
88
- if (err) return callback(err);
89
- // biome-ignore lint/style/noNonNullAssertion: getSpecifier always sets the specifier when err is null
90
- var cachedAt = _path.default.join(cachePath, specifier);
91
- var lockPath = "".concat(cachedAt, ".lock");
92
- var readyPath = _path.default.join(cachedAt, '.ready');
93
- var name = (0, _parseInstallStringts.default)(installString).name;
94
- // Check if already cached AND complete (fast path, no lock needed)
95
- _fs.default.stat(readyPath, function(readyErr) {
96
- if (!readyErr) return callback(undefined, cachedAt); // Valid cache
97
- // Not cached or incomplete - acquire lock and install
98
- doLockedInstall();
99
- });
100
- function doLockedInstall() {
101
- // Ensure lock file's parent directory exists (handles scoped packages like @scope/pkg)
102
- (0, _mkdirpclassic.default)(_path.default.dirname(lockPath), function(mkdirErr) {
103
- if (mkdirErr) return callback(mkdirErr);
104
- var startTime = Date.now();
105
- // Retry loop for Windows EPERM - treat it like EEXIST (lock held by another process)
106
- function tryLock(cb) {
107
- _lockfile.default.lock(lockPath, _object_spread({}, LOCK_OPTIONS), function(lockErr) {
108
- if (lockErr && lockErr.code === 'EPERM' && Date.now() - startTime < LOCK_OPTIONS.wait) {
109
- setTimeout(function() {
110
- return tryLock(cb);
111
- }, LOCK_OPTIONS.pollPeriod);
112
- return;
113
- }
114
- cb(lockErr);
115
- });
116
- }
117
- tryLock(function(lockErr) {
118
- if (lockErr) return callback(lockErr);
119
- // Single exit point - always unlock before calling back
120
- function done(err) {
121
- _lockfile.default.unlock(lockPath, function() {
122
- return callback(err, err ? undefined : cachedAt);
123
- });
124
- }
125
- // Re-check cache (another process may have completed while we waited for lock)
126
- _fs.default.stat(readyPath, function(readyErr) {
127
- if (!readyErr) return done(); // Cache appeared while we waited
128
- // Clean up any incomplete cache before installing
129
- (0, _fsremovecompat.safeRm)(cachedAt, function(rmErr) {
130
- if (rmErr) return done(rmErr);
131
- doInstall(done);
132
- });
133
- });
134
- });
135
- });
136
- }
137
- function doInstall(cb) {
138
- var _path1;
139
- var tmp = "".concat(cachedAt, "-").concat((0, _tempsuffix.default)());
140
- var tmpModulePath = (_path1 = _path.default).join.apply(_path1, [
141
- tmp,
142
- 'node_modules'
143
- ].concat(_to_consumable_array(name.split('/'))));
144
- var queue = new _queuecb.default(1);
145
- queue.defer(function(cb) {
146
- return (0, _mkdirpclassic.default)(tmp, function(err) {
147
- return cb(err);
148
- });
149
- });
150
- queue.defer(function(cb) {
151
- return _fs.default.writeFile(_path.default.join(tmp, 'package.json'), '{}', 'utf8', function(err) {
152
- return cb(err);
153
- });
154
- });
155
- // biome-ignore lint/style/noNonNullAssertion: getSpecifier always sets the specifier when err is null
156
- queue.defer(_installts.default.bind(null, specifier, tmp));
157
- queue.defer(function(qcb) {
158
- // Verify npm actually created the package directory - npm may silently skip
159
- // installation (exit 0) when platform doesn't match (os/cpu/libc fields)
160
- _fs.default.stat(tmpModulePath, function(statErr) {
161
- if (statErr) return qcb(new Error("Package directory not created by npm. This may happen when the package has platform restrictions (os/cpu/libc) that don't match the current system: ".concat(tmpModulePath)));
162
- qcb();
163
- });
164
- });
165
- queue.defer(_renameWithFallbackts.default.bind(null, tmpModulePath, cachedAt));
166
- queue.defer(_renameWithFallbackts.default.bind(null, _path.default.join(tmp, 'node_modules'), _path.default.join(cachedAt, 'node_modules')));
167
- // Write .ready marker after both renames succeed
168
- queue.defer(function(cb) {
169
- return _fs.default.writeFile(readyPath, '', 'utf8', function(err) {
170
- return cb(err);
171
- });
172
- });
173
- queue.await(function(queueErr) {
174
- // Clean up temp directory whether installed or not
175
- (0, _fsremovecompat.safeRm)(tmp, function() {
176
- return cb(queueErr);
177
- });
178
- });
179
- }
180
- });
181
- }
182
- /* 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; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/lib/cache.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport lockfile from 'lockfile';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\nimport type { EnsureCachedCallback } from '../types.ts';\nimport getSpecifier from './getSpecifier.ts';\nimport install from './install.ts';\nimport parse from './parseInstallString.ts';\nimport renameWithFallback from './renameWithFallback.ts';\n\nconst LOCK_OPTIONS = {\n wait: 600000, // Wait up to 10 minutes for lock (npm installs can be slow)\n pollPeriod: 100, // Check every 100ms\n stale: 660000, // Consider locks stale after 11 minutes (must be > wait)\n retries: 3, // Retry 3 times on transient errors\n};\n\nexport default function ensureCached(installString: string, cachePath: string, callback: EnsureCachedCallback) {\n getSpecifier(installString, (err, specifier) => {\n if (err) return callback(err);\n // biome-ignore lint/style/noNonNullAssertion: getSpecifier always sets the specifier when err is null\n const cachedAt = path.join(cachePath, specifier!);\n const lockPath = `${cachedAt}.lock`;\n const readyPath = path.join(cachedAt, '.ready');\n const { name } = parse(installString);\n\n // Check if already cached AND complete (fast path, no lock needed)\n fs.stat(readyPath, (readyErr: NodeJS.ErrnoException | null) => {\n if (!readyErr) return callback(undefined, cachedAt); // Valid cache\n\n // Not cached or incomplete - acquire lock and install\n doLockedInstall();\n });\n\n function doLockedInstall() {\n // Ensure lock file's parent directory exists (handles scoped packages like @scope/pkg)\n mkdirp(path.dirname(lockPath), (mkdirErr: Error | null) => {\n if (mkdirErr) return callback(mkdirErr);\n\n const startTime = Date.now();\n\n // Retry loop for Windows EPERM - treat it like EEXIST (lock held by another process)\n function tryLock(cb: (err?: Error | null) => void) {\n lockfile.lock(lockPath, { ...LOCK_OPTIONS }, (lockErr: Error | null) => {\n if (lockErr && (lockErr as NodeJS.ErrnoException).code === 'EPERM' && Date.now() - startTime < LOCK_OPTIONS.wait) {\n setTimeout(() => tryLock(cb), LOCK_OPTIONS.pollPeriod);\n return;\n }\n cb(lockErr);\n });\n }\n\n tryLock((lockErr) => {\n if (lockErr) return callback(lockErr);\n\n // Single exit point - always unlock before calling back\n function done(err?: Error | null) {\n lockfile.unlock(lockPath, () => callback(err, err ? undefined : cachedAt));\n }\n\n // Re-check cache (another process may have completed while we waited for lock)\n fs.stat(readyPath, (readyErr: NodeJS.ErrnoException | null) => {\n if (!readyErr) return done(); // Cache appeared while we waited\n\n // Clean up any incomplete cache before installing\n safeRm(cachedAt, (rmErr) => {\n if (rmErr) return done(rmErr);\n doInstall(done);\n });\n });\n });\n });\n }\n\n function doInstall(cb: (err?: Error | null) => void) {\n const tmp = `${cachedAt}-${tempSuffix()}`;\n const tmpModulePath = path.join(tmp, 'node_modules', ...name.split('/'));\n\n const queue = new Queue(1);\n queue.defer((cb) => mkdirp(tmp, (err) => cb(err)));\n queue.defer((cb) => fs.writeFile(path.join(tmp, 'package.json'), '{}', 'utf8', (err) => cb(err)));\n // biome-ignore lint/style/noNonNullAssertion: getSpecifier always sets the specifier when err is null\n queue.defer(install.bind(null, specifier!, tmp));\n queue.defer((qcb) => {\n // Verify npm actually created the package directory - npm may silently skip\n // installation (exit 0) when platform doesn't match (os/cpu/libc fields)\n fs.stat(tmpModulePath, (statErr) => {\n if (statErr) return qcb(new Error(`Package directory not created by npm. This may happen when the package has platform restrictions (os/cpu/libc) that don't match the current system: ${tmpModulePath}`));\n qcb();\n });\n });\n queue.defer(renameWithFallback.bind(null, tmpModulePath, cachedAt));\n queue.defer(renameWithFallback.bind(null, path.join(tmp, 'node_modules'), path.join(cachedAt, 'node_modules')));\n // Write .ready marker after both renames succeed\n queue.defer((cb) => fs.writeFile(readyPath, '', 'utf8', (err) => cb(err)));\n queue.await((queueErr) => {\n // Clean up temp directory whether installed or not\n safeRm(tmp, () => cb(queueErr));\n });\n }\n });\n}\n"],"names":["ensureCached","LOCK_OPTIONS","wait","pollPeriod","stale","retries","installString","cachePath","callback","getSpecifier","err","specifier","cachedAt","path","join","lockPath","readyPath","name","parse","fs","stat","readyErr","undefined","doLockedInstall","mkdirp","dirname","mkdirErr","startTime","Date","now","tryLock","cb","lockfile","lock","lockErr","code","setTimeout","done","unlock","safeRm","rmErr","doInstall","tmp","tempSuffix","tmpModulePath","split","queue","Queue","defer","writeFile","install","bind","qcb","statErr","Error","renameWithFallback","await","queueErr"],"mappings":";;;;+BAoBA;;;eAAwBA;;;yDApBT;8BACQ;+DACF;oEACF;2DACF;8DACC;iEACK;qEAEE;gEACL;2EACF;2EAC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,MAAME,KAAK,CAACO,6BAAkB,CAACJ,IAAI,CAAC,MAAMtC,aAAI,CAACC,IAAI,CAAC4B,KAAK,iBAAiB7B,aAAI,CAACC,IAAI,CAACF,UAAU;YAC9F,iDAAiD;YACjDkC,MAAME,KAAK,CAAC,SAACjB;uBAAOZ,WAAE,CAAC8B,SAAS,CAACjC,WAAW,IAAI,QAAQ,SAACN;2BAAQqB,GAAGrB;;;YACpEoC,MAAMU,KAAK,CAAC,SAACC;gBACX,mDAAmD;gBACnDlB,IAAAA,sBAAM,EAACG,KAAK;2BAAMX,GAAG0B;;YACvB;QACF;IACF;AACF"}
@@ -1,2 +0,0 @@
1
- import type { CleanOptions } from '../types.js';
2
- export default function clear(_options?: CleanOptions): void;
@@ -1,2 +0,0 @@
1
- import type { CleanOptions } from '../types.js';
2
- export default function clear(_options?: CleanOptions): void;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return clear;
9
- }
10
- });
11
- var _fsremovecompat = require("fs-remove-compat");
12
- var _constantsts = require("../constants.js");
13
- function clear(_options) {
14
- (0, _fsremovecompat.safeRmSync)(_constantsts.DEFAULT_CACHE_PATH);
15
- console.log("Cleaned ".concat(_constantsts.DEFAULT_CACHE_PATH));
16
- }
17
- /* 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; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/lib/clear.ts"],"sourcesContent":["import { safeRmSync } from 'fs-remove-compat';\nimport { DEFAULT_CACHE_PATH } from '../constants.ts';\n\nimport type { CleanOptions } from '../types.ts';\n\nexport default function clear(_options?: CleanOptions) {\n safeRmSync(DEFAULT_CACHE_PATH);\n console.log(`Cleaned ${DEFAULT_CACHE_PATH}`);\n}\n"],"names":["clear","_options","safeRmSync","DEFAULT_CACHE_PATH","console","log"],"mappings":";;;;+BAKA;;;eAAwBA;;;8BALG;2BACQ;AAIpB,SAASA,MAAMC,QAAuB;IACnDC,IAAAA,0BAAU,EAACC,+BAAkB;IAC7BC,QAAQC,GAAG,CAAC,AAAC,WAA6B,OAAnBF,+BAAkB;AAC3C"}
@@ -1,2 +0,0 @@
1
- import type { GetScopedSpecifiedCallback } from '../types.js';
2
- export default function getSpecifier(installString: string, callback: GetScopedSpecifiedCallback): void;
@@ -1,2 +0,0 @@
1
- import type { GetScopedSpecifiedCallback } from '../types.js';
2
- export default function getSpecifier(installString: string, callback: GetScopedSpecifiedCallback): void;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return getSpecifier;
9
- }
10
- });
11
- var _getfilecompat = require("get-file-compat");
12
- var _parseInstallStringts = /*#__PURE__*/ _interop_require_default(require("./parseInstallString.js"));
13
- function _interop_require_default(obj) {
14
- return obj && obj.__esModule ? obj : {
15
- default: obj
16
- };
17
- }
18
- function getSpecifier(installString, callback) {
19
- var _parseInstallString = (0, _parseInstallStringts.default)(installString), name = _parseInstallString.name, version = _parseInstallString.version;
20
- if (version) return callback(undefined, installString);
21
- // URL-encode the package name (handles scoped packages: @scope/pkg -> @scope%2Fpkg)
22
- var encodedName = encodeURIComponent(name).replace(/%40/g, '@');
23
- (0, _getfilecompat.getContent)("https://registry.npmjs.org/".concat(encodedName, "/latest"), 'utf8', function(err, res) {
24
- if (err) return callback(err);
25
- try {
26
- var _ref;
27
- var json = JSON.parse((_ref = res === null || res === void 0 ? void 0 : res.content) !== null && _ref !== void 0 ? _ref : 'null');
28
- callback(undefined, "".concat(name, "@").concat(json.version));
29
- } catch (err) {
30
- callback(err);
31
- }
32
- });
33
- }
34
- /* 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; }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node/install-module-linked-compat/src/lib/getSpecifier.ts"],"sourcesContent":["import { getContent } from 'get-file-compat';\nimport type { GetScopedSpecifiedCallback } from '../types.ts';\nimport parseInstallString from './parseInstallString.ts';\n\ninterface JSONPackage {\n version: string;\n}\n\nexport default function getSpecifier(installString: string, callback: GetScopedSpecifiedCallback) {\n const { name, version } = parseInstallString(installString);\n if (version) return callback(undefined, installString);\n\n // URL-encode the package name (handles scoped packages: @scope/pkg -> @scope%2Fpkg)\n const encodedName = encodeURIComponent(name).replace(/%40/g, '@');\n getContent(`https://registry.npmjs.org/${encodedName}/latest`, 'utf8', (err, res) => {\n if (err) return callback(err);\n try {\n const json = JSON.parse(res?.content ?? 'null');\n callback(undefined, `${name}@${(json as JSONPackage).version}`);\n } catch (err) {\n callback(err as Error);\n }\n });\n}\n"],"names":["getSpecifier","installString","callback","parseInstallString","name","version","undefined","encodedName","encodeURIComponent","replace","getContent","err","res","json","JSON","parse","content"],"mappings":";;;;+BAQA;;;eAAwBA;;;6BARG;2EAEI;;;;;;AAMhB,SAASA,aAAaC,aAAqB,EAAEC,QAAoC;IAC9F,IAA0BC,sBAAAA,IAAAA,6BAAkB,EAACF,gBAArCG,OAAkBD,oBAAlBC,MAAMC,UAAYF,oBAAZE;IACd,IAAIA,SAAS,OAAOH,SAASI,WAAWL;IAExC,oFAAoF;IACpF,IAAMM,cAAcC,mBAAmBJ,MAAMK,OAAO,CAAC,QAAQ;IAC7DC,IAAAA,yBAAU,EAAC,AAAC,8BAAyC,OAAZH,aAAY,YAAU,QAAQ,SAACI,KAAKC;QAC3E,IAAID,KAAK,OAAOT,SAASS;QACzB,IAAI;;YACF,IAAME,OAAOC,KAAKC,KAAK,SAACH,gBAAAA,0BAAAA,IAAKI,OAAO,uCAAI;YACxCd,SAASI,WAAW,AAAC,GAAU,OAARF,MAAK,KAAiC,OAA9B,AAACS,KAAqBR,OAAO;QAC9D,EAAE,OAAOM,KAAK;YACZT,SAASS;QACX;IACF;AACF"}
@@ -1,2 +0,0 @@
1
- import type { InstallCallback } from '../types.js';
2
- export default function install(specifier: string, dest: string, callback: InstallCallback): void;
@@ -1,2 +0,0 @@
1
- import type { InstallCallback } from '../types.js';
2
- export default function install(specifier: string, dest: string, callback: InstallCallback): void;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return install;
9
- }
10
- });
11
- var _crossspawncb = /*#__PURE__*/ _interop_require_default(require("cross-spawn-cb"));
12
- var _nodeversioncalllocal = require("node-version-call-local");
13
- var _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
- var _url = /*#__PURE__*/ _interop_require_default(require("url"));
15
- function _array_like_to_array(arr, len) {
16
- if (len == null || len > arr.length) len = arr.length;
17
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
18
- return arr2;
19
- }
20
- function _array_without_holes(arr) {
21
- if (Array.isArray(arr)) return _array_like_to_array(arr);
22
- }
23
- function _interop_require_default(obj) {
24
- return obj && obj.__esModule ? obj : {
25
- default: obj
26
- };
27
- }
28
- function _iterable_to_array(iter) {
29
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
30
- return Array.from(iter);
31
- }
32
- }
33
- function _non_iterable_spread() {
34
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
- }
36
- function _to_consumable_array(arr) {
37
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
38
- }
39
- function _unsupported_iterable_to_array(o, minLen) {
40
- if (!o) return;
41
- if (typeof o === "string") return _array_like_to_array(o, minLen);
42
- var n = Object.prototype.toString.call(o).slice(8, -1);
43
- if (n === "Object" && o.constructor) n = o.constructor.name;
44
- if (n === "Map" || n === "Set") return Array.from(n);
45
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
- }
47
- var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
48
- var major = +process.versions.node.split('.')[0];
49
- var workerPath = _path.default.join(__dirname, '..', '..', 'cjs', 'lib', 'install.js');
50
- function run(specifier, dest, callback) {
51
- (0, _crossspawncb.default)('npm', [
52
- 'install',
53
- specifier
54
- ], {
55
- cwd: dest
56
- }, function(err) {
57
- var _path1;
58
- err ? callback(err) : callback(undefined, (_path1 = _path.default).join.apply(_path1, [
59
- dest
60
- ].concat(_to_consumable_array(specifier.split('/')))));
61
- });
62
- }
63
- var worker = major > 0 ? run : (0, _nodeversioncalllocal.bind)('>0.12', workerPath, {
64
- callbacks: true
65
- });
66
- function install(specifier, dest, callback) {
67
- worker(specifier, dest, callback);
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; }