@metamask-previews/local-node-utils 0.0.0-preview-55f166437 → 0.0.0-preview-3e8f1945e

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 (123) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +11 -1
  3. package/dist/archive.cjs +13 -0
  4. package/dist/archive.cjs.map +1 -0
  5. package/dist/archive.d.cts +3 -0
  6. package/dist/archive.d.cts.map +1 -0
  7. package/dist/archive.d.mts +3 -0
  8. package/dist/archive.d.mts.map +1 -0
  9. package/dist/archive.mjs +8 -0
  10. package/dist/archive.mjs.map +1 -0
  11. package/dist/artifact.cjs +40 -0
  12. package/dist/artifact.cjs.map +1 -0
  13. package/dist/artifact.d.cts +6 -0
  14. package/dist/artifact.d.cts.map +1 -0
  15. package/dist/artifact.d.mts +6 -0
  16. package/dist/artifact.d.mts.map +1 -0
  17. package/dist/artifact.mjs +33 -0
  18. package/dist/artifact.mjs.map +1 -0
  19. package/dist/cache-directory.cjs +28 -0
  20. package/dist/cache-directory.cjs.map +1 -0
  21. package/dist/cache-directory.d.cts +6 -0
  22. package/dist/cache-directory.d.cts.map +1 -0
  23. package/dist/cache-directory.d.mts +6 -0
  24. package/dist/cache-directory.d.mts.map +1 -0
  25. package/dist/cache-directory.mjs +24 -0
  26. package/dist/cache-directory.mjs.map +1 -0
  27. package/dist/cache.cjs +14 -0
  28. package/dist/cache.cjs.map +1 -0
  29. package/dist/cache.d.cts +5 -0
  30. package/dist/cache.d.cts.map +1 -0
  31. package/dist/cache.d.mts +5 -0
  32. package/dist/cache.d.mts.map +1 -0
  33. package/dist/cache.mjs +10 -0
  34. package/dist/cache.mjs.map +1 -0
  35. package/dist/checksum.cjs +17 -0
  36. package/dist/checksum.cjs.map +1 -0
  37. package/dist/checksum.d.cts +2 -0
  38. package/dist/checksum.d.cts.map +1 -0
  39. package/dist/checksum.d.mts +2 -0
  40. package/dist/checksum.d.mts.map +1 -0
  41. package/dist/checksum.mjs +13 -0
  42. package/dist/checksum.mjs.map +1 -0
  43. package/dist/cli.cjs +11 -0
  44. package/dist/cli.cjs.map +1 -0
  45. package/dist/cli.d.cts +2 -0
  46. package/dist/cli.d.cts.map +1 -0
  47. package/dist/cli.d.mts +2 -0
  48. package/dist/cli.d.mts.map +1 -0
  49. package/dist/cli.mjs +7 -0
  50. package/dist/cli.mjs.map +1 -0
  51. package/dist/command.cjs +28 -0
  52. package/dist/command.cjs.map +1 -0
  53. package/dist/command.d.cts +2 -0
  54. package/dist/command.d.cts.map +1 -0
  55. package/dist/command.d.mts +2 -0
  56. package/dist/command.d.mts.map +1 -0
  57. package/dist/command.mjs +24 -0
  58. package/dist/command.mjs.map +1 -0
  59. package/dist/download.cjs +47 -0
  60. package/dist/download.cjs.map +1 -0
  61. package/dist/download.d.cts +4 -0
  62. package/dist/download.d.cts.map +1 -0
  63. package/dist/download.d.mts +4 -0
  64. package/dist/download.d.mts.map +1 -0
  65. package/dist/download.mjs +42 -0
  66. package/dist/download.mjs.map +1 -0
  67. package/dist/errors.cjs +11 -0
  68. package/dist/errors.cjs.map +1 -0
  69. package/dist/errors.d.cts +2 -0
  70. package/dist/errors.d.cts.map +1 -0
  71. package/dist/errors.d.mts +2 -0
  72. package/dist/errors.d.mts.map +1 -0
  73. package/dist/errors.mjs +7 -0
  74. package/dist/errors.mjs.map +1 -0
  75. package/dist/executable-wrapper.cjs +76 -0
  76. package/dist/executable-wrapper.cjs.map +1 -0
  77. package/dist/executable-wrapper.d.cts +9 -0
  78. package/dist/executable-wrapper.d.cts.map +1 -0
  79. package/dist/executable-wrapper.d.mts +9 -0
  80. package/dist/executable-wrapper.d.mts.map +1 -0
  81. package/dist/executable-wrapper.mjs +72 -0
  82. package/dist/executable-wrapper.mjs.map +1 -0
  83. package/dist/filesystem.cjs +45 -0
  84. package/dist/filesystem.cjs.map +1 -0
  85. package/dist/filesystem.d.cts +4 -0
  86. package/dist/filesystem.d.cts.map +1 -0
  87. package/dist/filesystem.d.mts +4 -0
  88. package/dist/filesystem.d.mts.map +1 -0
  89. package/dist/filesystem.mjs +39 -0
  90. package/dist/filesystem.mjs.map +1 -0
  91. package/dist/index.cjs +34 -10
  92. package/dist/index.cjs.map +1 -1
  93. package/dist/index.d.cts +15 -7
  94. package/dist/index.d.cts.map +1 -1
  95. package/dist/index.d.mts +15 -7
  96. package/dist/index.d.mts.map +1 -1
  97. package/dist/index.mjs +13 -9
  98. package/dist/index.mjs.map +1 -1
  99. package/dist/package-json.cjs +29 -0
  100. package/dist/package-json.cjs.map +1 -0
  101. package/dist/package-json.d.cts +6 -0
  102. package/dist/package-json.d.cts.map +1 -0
  103. package/dist/package-json.d.mts +6 -0
  104. package/dist/package-json.d.mts.map +1 -0
  105. package/dist/package-json.mjs +25 -0
  106. package/dist/package-json.mjs.map +1 -0
  107. package/dist/platform.cjs +25 -0
  108. package/dist/platform.cjs.map +1 -0
  109. package/dist/platform.d.cts +3 -0
  110. package/dist/platform.d.cts.map +1 -0
  111. package/dist/platform.d.mts +3 -0
  112. package/dist/platform.d.mts.map +1 -0
  113. package/dist/platform.mjs +20 -0
  114. package/dist/platform.mjs.map +1 -0
  115. package/dist/types.cjs +3 -0
  116. package/dist/types.cjs.map +1 -0
  117. package/dist/types.d.cts +14 -0
  118. package/dist/types.d.cts.map +1 -0
  119. package/dist/types.d.mts +14 -0
  120. package/dist/types.d.mts.map +1 -0
  121. package/dist/types.mjs +2 -0
  122. package/dist/types.mjs.map +1 -0
  123. package/package.json +5 -1
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ export declare function downloadFileFromUrl(url: string, destination: string): Promise<void>;
3
+ export declare function openDownloadStream(url: URL, redirectsRemaining?: number): Promise<NodeJS.ReadableStream>;
4
+ //# sourceMappingURL=download.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.cts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":";AAQA,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,GAAG,EACR,kBAAkB,SAAI,GACrB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CA8ChC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ export declare function downloadFileFromUrl(url: string, destination: string): Promise<void>;
3
+ export declare function openDownloadStream(url: URL, redirectsRemaining?: number): Promise<NodeJS.ReadableStream>;
4
+ //# sourceMappingURL=download.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.mts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":";AAQA,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,GAAG,EACR,kBAAkB,SAAI,GACrB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CA8ChC"}
@@ -0,0 +1,42 @@
1
+ /* eslint-disable import-x/no-nodejs-modules */
2
+ import { createWriteStream } from "node:fs";
3
+ import { mkdir } from "node:fs/promises";
4
+ import { request as requestHttp } from "node:http";
5
+ import { request as requestHttps } from "node:https";
6
+ import { dirname } from "node:path";
7
+ import { pipeline } from "node:stream/promises";
8
+ export async function downloadFileFromUrl(url, destination) {
9
+ await mkdir(dirname(destination), { recursive: true });
10
+ await pipeline(await openDownloadStream(new URL(url)), createWriteStream(destination));
11
+ }
12
+ export async function openDownloadStream(url, redirectsRemaining = 5) {
13
+ const request = url.protocol === 'http:' ? requestHttp : requestHttps;
14
+ return await new Promise((resolvePromise, rejectPromise) => {
15
+ const req = request(url, (response) => {
16
+ const { headers, statusCode, statusMessage } = response;
17
+ if (statusCode &&
18
+ statusCode >= 300 &&
19
+ statusCode < 400 &&
20
+ headers.location) {
21
+ response.resume();
22
+ if (redirectsRemaining <= 0) {
23
+ rejectPromise(new Error(`Too many redirects downloading ${url}`));
24
+ return;
25
+ }
26
+ openDownloadStream(new URL(headers.location, url), redirectsRemaining - 1)
27
+ .then(resolvePromise)
28
+ .catch(rejectPromise);
29
+ return;
30
+ }
31
+ if (!statusCode || statusCode < 200 || statusCode >= 300) {
32
+ response.resume();
33
+ rejectPromise(new Error(`Request to ${url} failed with ${statusCode ?? 'unknown'} ${statusMessage ?? ''}`.trim()));
34
+ return;
35
+ }
36
+ resolvePromise(response);
37
+ });
38
+ req.on('error', rejectPromise);
39
+ req.end();
40
+ });
41
+ }
42
+ //# sourceMappingURL=download.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.mjs","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB;AAC5C,OAAO,EAAE,KAAK,EAAE,yBAAyB;AACzC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,kBAAkB;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,mBAAmB;AACrD,OAAO,EAAE,OAAO,EAAE,kBAAkB;AACpC,OAAO,EAAE,QAAQ,EAAE,6BAA6B;AAEhD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAW,EACX,WAAmB;IAEnB,MAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,QAAQ,CACZ,MAAM,kBAAkB,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,EACtC,iBAAiB,CAAC,WAAW,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,GAAQ,EACR,kBAAkB,GAAG,CAAC;IAEtB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IAEtE,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACzD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE;YACpC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;YAExD,IACE,UAAU;gBACV,UAAU,IAAI,GAAG;gBACjB,UAAU,GAAG,GAAG;gBAChB,OAAO,CAAC,QAAQ,EAChB,CAAC;gBACD,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAClB,IAAI,kBAAkB,IAAI,CAAC,EAAE,CAAC;oBAC5B,aAAa,CAAC,IAAI,KAAK,CAAC,kCAAkC,GAAG,EAAE,CAAC,CAAC,CAAC;oBAClE,OAAO;gBACT,CAAC;gBAED,kBAAkB,CAChB,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,EAC9B,kBAAkB,GAAG,CAAC,CACvB;qBACE,IAAI,CAAC,cAAc,CAAC;qBACpB,KAAK,CAAC,aAAa,CAAC,CAAC;gBACxB,OAAO;YACT,CAAC;YAED,IAAI,CAAC,UAAU,IAAI,UAAU,GAAG,GAAG,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;gBACzD,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAClB,aAAa,CACX,IAAI,KAAK,CACP,cAAc,GAAG,gBAAgB,UAAU,IAAI,SAAS,IACtD,aAAa,IAAI,EACnB,EAAE,CAAC,IAAI,EAAE,CACV,CACF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC/B,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { createWriteStream } from 'node:fs';\nimport { mkdir } from 'node:fs/promises';\nimport { request as requestHttp } from 'node:http';\nimport { request as requestHttps } from 'node:https';\nimport { dirname } from 'node:path';\nimport { pipeline } from 'node:stream/promises';\n\nexport async function downloadFileFromUrl(\n url: string,\n destination: string,\n): Promise<void> {\n await mkdir(dirname(destination), { recursive: true });\n await pipeline(\n await openDownloadStream(new URL(url)),\n createWriteStream(destination),\n );\n}\n\nexport async function openDownloadStream(\n url: URL,\n redirectsRemaining = 5,\n): Promise<NodeJS.ReadableStream> {\n const request = url.protocol === 'http:' ? requestHttp : requestHttps;\n\n return await new Promise((resolvePromise, rejectPromise) => {\n const req = request(url, (response) => {\n const { headers, statusCode, statusMessage } = response;\n\n if (\n statusCode &&\n statusCode >= 300 &&\n statusCode < 400 &&\n headers.location\n ) {\n response.resume();\n if (redirectsRemaining <= 0) {\n rejectPromise(new Error(`Too many redirects downloading ${url}`));\n return;\n }\n\n openDownloadStream(\n new URL(headers.location, url),\n redirectsRemaining - 1,\n )\n .then(resolvePromise)\n .catch(rejectPromise);\n return;\n }\n\n if (!statusCode || statusCode < 200 || statusCode >= 300) {\n response.resume();\n rejectPromise(\n new Error(\n `Request to ${url} failed with ${statusCode ?? 'unknown'} ${\n statusMessage ?? ''\n }`.trim(),\n ),\n );\n return;\n }\n\n resolvePromise(response);\n });\n\n req.on('error', rejectPromise);\n req.end();\n });\n}\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFileMissingError = void 0;
4
+ function isFileMissingError(error) {
5
+ return (typeof error === 'object' &&
6
+ error !== null &&
7
+ Object.prototype.hasOwnProperty.call(error, 'code') &&
8
+ error.code === 'ENOENT');
9
+ }
10
+ exports.isFileMissingError = isFileMissingError;
11
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;QAClD,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC;AAPD,gDAOC","sourcesContent":["export function isFileMissingError(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n Object.prototype.hasOwnProperty.call(error, 'code') &&\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function isFileMissingError(error: unknown): boolean;
2
+ //# sourceMappingURL=errors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.cts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D"}
@@ -0,0 +1,2 @@
1
+ export declare function isFileMissingError(error: unknown): boolean;
2
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D"}
@@ -0,0 +1,7 @@
1
+ export function isFileMissingError(error) {
2
+ return (typeof error === 'object' &&
3
+ error !== null &&
4
+ Object.prototype.hasOwnProperty.call(error, 'code') &&
5
+ error.code === 'ENOENT');
6
+ }
7
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;QAClD,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC","sourcesContent":["export function isFileMissingError(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n Object.prototype.hasOwnProperty.call(error, 'code') &&\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n );\n}\n"]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installExecutableWrapper = void 0;
4
+ /* eslint-disable import-x/no-nodejs-modules */
5
+ const promises_1 = require("node:fs/promises");
6
+ const node_path_1 = require("node:path");
7
+ const errors_1 = require("./errors.cjs");
8
+ async function installExecutableWrapper({ binDirectory, commandName, executableArgs = [], executablePath, pathResolution = 'absolute', }) {
9
+ const binaryPath = (0, node_path_1.join)(binDirectory, commandName);
10
+ const wrapperSource = buildExecutableWrapperSource({
11
+ binDirectory,
12
+ executableArgs,
13
+ executablePath,
14
+ pathResolution,
15
+ });
16
+ await (0, promises_1.mkdir)(binDirectory, { recursive: true });
17
+ await (0, promises_1.unlink)(binaryPath).catch((error) => {
18
+ if (!(0, errors_1.isFileMissingError)(error)) {
19
+ throw error;
20
+ }
21
+ });
22
+ await (0, promises_1.writeFile)(binaryPath, wrapperSource);
23
+ await (0, promises_1.chmod)(binaryPath, 0o755);
24
+ return binaryPath;
25
+ }
26
+ exports.installExecutableWrapper = installExecutableWrapper;
27
+ function buildExecutableWrapperSource({ binDirectory, executableArgs, executablePath, pathResolution, }) {
28
+ if (pathResolution === 'relative') {
29
+ const relativeExecutablePath = (0, node_path_1.relative)(binDirectory, executablePath);
30
+ return `#!/usr/bin/env node
31
+ const { spawnSync } = require('node:child_process');
32
+ const path = require('node:path');
33
+
34
+ const executablePath = path.resolve(__dirname, ${JSON.stringify(relativeExecutablePath)});
35
+ const executableArgs = ${JSON.stringify(executableArgs)};
36
+ const result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {
37
+ stdio: 'inherit',
38
+ });
39
+
40
+ if (result.error) {
41
+ console.error(result.error.message);
42
+ process.exit(1);
43
+ }
44
+
45
+ if (result.signal) {
46
+ process.kill(process.pid, result.signal);
47
+ process.exit(1);
48
+ }
49
+
50
+ process.exit(result.status ?? 0);
51
+ `;
52
+ }
53
+ const resolvedExecutablePath = (0, node_path_1.resolve)(executablePath);
54
+ return `#!/usr/bin/env node
55
+ const { spawnSync } = require('node:child_process');
56
+
57
+ const executablePath = ${JSON.stringify(resolvedExecutablePath)};
58
+ const executableArgs = ${JSON.stringify(executableArgs)};
59
+ const result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {
60
+ stdio: 'inherit',
61
+ });
62
+
63
+ if (result.error) {
64
+ console.error(result.error.message);
65
+ process.exit(1);
66
+ }
67
+
68
+ if (result.signal) {
69
+ process.kill(process.pid, result.signal);
70
+ process.exit(1);
71
+ }
72
+
73
+ process.exit(result.status ?? 0);
74
+ `;
75
+ }
76
+ //# sourceMappingURL=executable-wrapper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-wrapper.cjs","sourceRoot":"","sources":["../src/executable-wrapper.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,+CAAmE;AACnE,yCAAoD;AAEpD,yCAA8C;AAIvC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,YAAY,EACZ,WAAW,EACX,cAAc,GAAG,EAAE,EACnB,cAAc,EACd,cAAc,GAAG,UAAU,GAO5B;IACC,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,4BAA4B,CAAC;QACjD,YAAY;QACZ,cAAc;QACd,cAAc;QACd,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,IAAA,gBAAK,EAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,IAAA,iBAAM,EAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,IAAI,CAAC,IAAA,2BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3C,MAAM,IAAA,gBAAK,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAE/B,OAAO,UAAU,CAAC;AACpB,CAAC;AA/BD,4DA+BC;AAED,SAAS,4BAA4B,CAAC,EACpC,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,GAMf;IACC,IAAI,cAAc,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,sBAAsB,GAAG,IAAA,oBAAQ,EAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAEtE,OAAO;;;;iDAIsC,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;yBAC9D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;CAgBtD,CAAC;IACA,CAAC;IAED,MAAM,sBAAsB,GAAG,IAAA,mBAAO,EAAC,cAAc,CAAC,CAAC;IAEvD,OAAO;;;yBAGgB,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;yBACtC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;CAgBtD,CAAC;AACF,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { chmod, mkdir, unlink, writeFile } from 'node:fs/promises';\nimport { join, relative, resolve } from 'node:path';\n\nimport { isFileMissingError } from './errors';\n\nexport type ExecutableWrapperPathResolution = 'absolute' | 'relative';\n\nexport async function installExecutableWrapper({\n binDirectory,\n commandName,\n executableArgs = [],\n executablePath,\n pathResolution = 'absolute',\n}: {\n binDirectory: string;\n commandName: string;\n executableArgs?: string[];\n executablePath: string;\n pathResolution?: ExecutableWrapperPathResolution;\n}): Promise<string> {\n const binaryPath = join(binDirectory, commandName);\n const wrapperSource = buildExecutableWrapperSource({\n binDirectory,\n executableArgs,\n executablePath,\n pathResolution,\n });\n\n await mkdir(binDirectory, { recursive: true });\n await unlink(binaryPath).catch((error) => {\n if (!isFileMissingError(error)) {\n throw error;\n }\n });\n await writeFile(binaryPath, wrapperSource);\n await chmod(binaryPath, 0o755);\n\n return binaryPath;\n}\n\nfunction buildExecutableWrapperSource({\n binDirectory,\n executableArgs,\n executablePath,\n pathResolution,\n}: {\n binDirectory: string;\n executableArgs: string[];\n executablePath: string;\n pathResolution: ExecutableWrapperPathResolution;\n}): string {\n if (pathResolution === 'relative') {\n const relativeExecutablePath = relative(binDirectory, executablePath);\n\n return `#!/usr/bin/env node\nconst { spawnSync } = require('node:child_process');\nconst path = require('node:path');\n\nconst executablePath = path.resolve(__dirname, ${JSON.stringify(relativeExecutablePath)});\nconst executableArgs = ${JSON.stringify(executableArgs)};\nconst result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {\n stdio: 'inherit',\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nif (result.signal) {\n process.kill(process.pid, result.signal);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 0);\n`;\n }\n\n const resolvedExecutablePath = resolve(executablePath);\n\n return `#!/usr/bin/env node\nconst { spawnSync } = require('node:child_process');\n\nconst executablePath = ${JSON.stringify(resolvedExecutablePath)};\nconst executableArgs = ${JSON.stringify(executableArgs)};\nconst result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {\n stdio: 'inherit',\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nif (result.signal) {\n process.kill(process.pid, result.signal);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 0);\n`;\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export type ExecutableWrapperPathResolution = 'absolute' | 'relative';
2
+ export declare function installExecutableWrapper({ binDirectory, commandName, executableArgs, executablePath, pathResolution, }: {
3
+ binDirectory: string;
4
+ commandName: string;
5
+ executableArgs?: string[];
6
+ executablePath: string;
7
+ pathResolution?: ExecutableWrapperPathResolution;
8
+ }): Promise<string>;
9
+ //# sourceMappingURL=executable-wrapper.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-wrapper.d.cts","sourceRoot":"","sources":["../src/executable-wrapper.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,+BAA+B,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtE,wBAAsB,wBAAwB,CAAC,EAC7C,YAAY,EACZ,WAAW,EACX,cAAmB,EACnB,cAAc,EACd,cAA2B,GAC5B,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,+BAA+B,CAAC;CAClD,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB"}
@@ -0,0 +1,9 @@
1
+ export type ExecutableWrapperPathResolution = 'absolute' | 'relative';
2
+ export declare function installExecutableWrapper({ binDirectory, commandName, executableArgs, executablePath, pathResolution, }: {
3
+ binDirectory: string;
4
+ commandName: string;
5
+ executableArgs?: string[];
6
+ executablePath: string;
7
+ pathResolution?: ExecutableWrapperPathResolution;
8
+ }): Promise<string>;
9
+ //# sourceMappingURL=executable-wrapper.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-wrapper.d.mts","sourceRoot":"","sources":["../src/executable-wrapper.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,+BAA+B,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtE,wBAAsB,wBAAwB,CAAC,EAC7C,YAAY,EACZ,WAAW,EACX,cAAmB,EACnB,cAAc,EACd,cAA2B,GAC5B,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,+BAA+B,CAAC;CAClD,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBlB"}
@@ -0,0 +1,72 @@
1
+ /* eslint-disable import-x/no-nodejs-modules */
2
+ import { chmod, mkdir, unlink, writeFile } from "node:fs/promises";
3
+ import { join, relative, resolve } from "node:path";
4
+ import { isFileMissingError } from "./errors.mjs";
5
+ export async function installExecutableWrapper({ binDirectory, commandName, executableArgs = [], executablePath, pathResolution = 'absolute', }) {
6
+ const binaryPath = join(binDirectory, commandName);
7
+ const wrapperSource = buildExecutableWrapperSource({
8
+ binDirectory,
9
+ executableArgs,
10
+ executablePath,
11
+ pathResolution,
12
+ });
13
+ await mkdir(binDirectory, { recursive: true });
14
+ await unlink(binaryPath).catch((error) => {
15
+ if (!isFileMissingError(error)) {
16
+ throw error;
17
+ }
18
+ });
19
+ await writeFile(binaryPath, wrapperSource);
20
+ await chmod(binaryPath, 0o755);
21
+ return binaryPath;
22
+ }
23
+ function buildExecutableWrapperSource({ binDirectory, executableArgs, executablePath, pathResolution, }) {
24
+ if (pathResolution === 'relative') {
25
+ const relativeExecutablePath = relative(binDirectory, executablePath);
26
+ return `#!/usr/bin/env node
27
+ const { spawnSync } = require('node:child_process');
28
+ const path = require('node:path');
29
+
30
+ const executablePath = path.resolve(__dirname, ${JSON.stringify(relativeExecutablePath)});
31
+ const executableArgs = ${JSON.stringify(executableArgs)};
32
+ const result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {
33
+ stdio: 'inherit',
34
+ });
35
+
36
+ if (result.error) {
37
+ console.error(result.error.message);
38
+ process.exit(1);
39
+ }
40
+
41
+ if (result.signal) {
42
+ process.kill(process.pid, result.signal);
43
+ process.exit(1);
44
+ }
45
+
46
+ process.exit(result.status ?? 0);
47
+ `;
48
+ }
49
+ const resolvedExecutablePath = resolve(executablePath);
50
+ return `#!/usr/bin/env node
51
+ const { spawnSync } = require('node:child_process');
52
+
53
+ const executablePath = ${JSON.stringify(resolvedExecutablePath)};
54
+ const executableArgs = ${JSON.stringify(executableArgs)};
55
+ const result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {
56
+ stdio: 'inherit',
57
+ });
58
+
59
+ if (result.error) {
60
+ console.error(result.error.message);
61
+ process.exit(1);
62
+ }
63
+
64
+ if (result.signal) {
65
+ process.kill(process.pid, result.signal);
66
+ process.exit(1);
67
+ }
68
+
69
+ process.exit(result.status ?? 0);
70
+ `;
71
+ }
72
+ //# sourceMappingURL=executable-wrapper.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executable-wrapper.mjs","sourceRoot":"","sources":["../src/executable-wrapper.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,yBAAyB;AACnE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB;AAEpD,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAI9C,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,YAAY,EACZ,WAAW,EACX,cAAc,GAAG,EAAE,EACnB,cAAc,EACd,cAAc,GAAG,UAAU,GAO5B;IACC,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,4BAA4B,CAAC;QACjD,YAAY;QACZ,cAAc;QACd,cAAc;QACd,cAAc;KACf,CAAC,CAAC;IAEH,MAAM,KAAK,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACvC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3C,MAAM,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAE/B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,4BAA4B,CAAC,EACpC,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,GAMf;IACC,IAAI,cAAc,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAEtE,OAAO;;;;iDAIsC,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;yBAC9D,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;CAgBtD,CAAC;IACA,CAAC;IAED,MAAM,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEvD,OAAO;;;yBAGgB,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;yBACtC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;CAgBtD,CAAC;AACF,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { chmod, mkdir, unlink, writeFile } from 'node:fs/promises';\nimport { join, relative, resolve } from 'node:path';\n\nimport { isFileMissingError } from './errors';\n\nexport type ExecutableWrapperPathResolution = 'absolute' | 'relative';\n\nexport async function installExecutableWrapper({\n binDirectory,\n commandName,\n executableArgs = [],\n executablePath,\n pathResolution = 'absolute',\n}: {\n binDirectory: string;\n commandName: string;\n executableArgs?: string[];\n executablePath: string;\n pathResolution?: ExecutableWrapperPathResolution;\n}): Promise<string> {\n const binaryPath = join(binDirectory, commandName);\n const wrapperSource = buildExecutableWrapperSource({\n binDirectory,\n executableArgs,\n executablePath,\n pathResolution,\n });\n\n await mkdir(binDirectory, { recursive: true });\n await unlink(binaryPath).catch((error) => {\n if (!isFileMissingError(error)) {\n throw error;\n }\n });\n await writeFile(binaryPath, wrapperSource);\n await chmod(binaryPath, 0o755);\n\n return binaryPath;\n}\n\nfunction buildExecutableWrapperSource({\n binDirectory,\n executableArgs,\n executablePath,\n pathResolution,\n}: {\n binDirectory: string;\n executableArgs: string[];\n executablePath: string;\n pathResolution: ExecutableWrapperPathResolution;\n}): string {\n if (pathResolution === 'relative') {\n const relativeExecutablePath = relative(binDirectory, executablePath);\n\n return `#!/usr/bin/env node\nconst { spawnSync } = require('node:child_process');\nconst path = require('node:path');\n\nconst executablePath = path.resolve(__dirname, ${JSON.stringify(relativeExecutablePath)});\nconst executableArgs = ${JSON.stringify(executableArgs)};\nconst result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {\n stdio: 'inherit',\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nif (result.signal) {\n process.kill(process.pid, result.signal);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 0);\n`;\n }\n\n const resolvedExecutablePath = resolve(executablePath);\n\n return `#!/usr/bin/env node\nconst { spawnSync } = require('node:child_process');\n\nconst executablePath = ${JSON.stringify(resolvedExecutablePath)};\nconst executableArgs = ${JSON.stringify(executableArgs)};\nconst result = spawnSync(executablePath, executableArgs.concat(process.argv.slice(2)), {\n stdio: 'inherit',\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nif (result.signal) {\n process.kill(process.pid, result.signal);\n process.exit(1);\n}\n\nprocess.exit(result.status ?? 0);\n`;\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFile = exports.isDirectory = exports.findExecutable = void 0;
4
+ /* eslint-disable import-x/no-nodejs-modules */
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ function findExecutable(root, name) {
8
+ if (!(0, node_fs_1.existsSync)(root)) {
9
+ return undefined;
10
+ }
11
+ for (const entry of (0, node_fs_1.readdirSync)(root)) {
12
+ const entryPath = (0, node_path_1.join)(root, entry);
13
+ const stat = (0, node_fs_1.statSync)(entryPath);
14
+ if (stat.isDirectory()) {
15
+ const found = findExecutable(entryPath, name);
16
+ if (found) {
17
+ return found;
18
+ }
19
+ }
20
+ else if (entry === name) {
21
+ return entryPath;
22
+ }
23
+ }
24
+ return undefined;
25
+ }
26
+ exports.findExecutable = findExecutable;
27
+ function isDirectory(path) {
28
+ try {
29
+ return (0, node_fs_1.statSync)(path).isDirectory();
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
35
+ exports.isDirectory = isDirectory;
36
+ function isFile(path) {
37
+ try {
38
+ return (0, node_fs_1.statSync)(path).isFile();
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ exports.isFile = isFile;
45
+ //# sourceMappingURL=filesystem.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.cjs","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,qCAA4D;AAC5D,yCAAiC;AAEjC,SAAgB,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,CAAC,IAAA,oBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,IAAA,qBAAW,EAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,IAAA,gBAAI,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,IAAA,kBAAQ,EAAC,SAAS,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC9C,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAnBD,wCAmBC;AAED,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,OAAO,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAND,kCAMC;AAED,SAAgB,MAAM,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,OAAO,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAND,wBAMC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport function findExecutable(root: string, name: string): string | undefined {\n if (!existsSync(root)) {\n return undefined;\n }\n\n for (const entry of readdirSync(root)) {\n const entryPath = join(root, entry);\n const stat = statSync(entryPath);\n if (stat.isDirectory()) {\n const found = findExecutable(entryPath, name);\n if (found) {\n return found;\n }\n } else if (entry === name) {\n return entryPath;\n }\n }\n\n return undefined;\n}\n\nexport function isDirectory(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\nexport function isFile(path: string): boolean {\n try {\n return statSync(path).isFile();\n } catch {\n return false;\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function findExecutable(root: string, name: string): string | undefined;
2
+ export declare function isDirectory(path: string): boolean;
3
+ export declare function isFile(path: string): boolean;
4
+ //# sourceMappingURL=filesystem.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.cts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmB7E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMjD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5C"}
@@ -0,0 +1,4 @@
1
+ export declare function findExecutable(root: string, name: string): string | undefined;
2
+ export declare function isDirectory(path: string): boolean;
3
+ export declare function isFile(path: string): boolean;
4
+ //# sourceMappingURL=filesystem.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.d.mts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmB7E;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMjD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM5C"}
@@ -0,0 +1,39 @@
1
+ /* eslint-disable import-x/no-nodejs-modules */
2
+ import { existsSync, readdirSync, statSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ export function findExecutable(root, name) {
5
+ if (!existsSync(root)) {
6
+ return undefined;
7
+ }
8
+ for (const entry of readdirSync(root)) {
9
+ const entryPath = join(root, entry);
10
+ const stat = statSync(entryPath);
11
+ if (stat.isDirectory()) {
12
+ const found = findExecutable(entryPath, name);
13
+ if (found) {
14
+ return found;
15
+ }
16
+ }
17
+ else if (entry === name) {
18
+ return entryPath;
19
+ }
20
+ }
21
+ return undefined;
22
+ }
23
+ export function isDirectory(path) {
24
+ try {
25
+ return statSync(path).isDirectory();
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ export function isFile(path) {
32
+ try {
33
+ return statSync(path).isFile();
34
+ }
35
+ catch {
36
+ return false;
37
+ }
38
+ }
39
+ //# sourceMappingURL=filesystem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.mjs","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,gBAAgB;AAC5D,OAAO,EAAE,IAAI,EAAE,kBAAkB;AAEjC,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC9C,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport function findExecutable(root: string, name: string): string | undefined {\n if (!existsSync(root)) {\n return undefined;\n }\n\n for (const entry of readdirSync(root)) {\n const entryPath = join(root, entry);\n const stat = statSync(entryPath);\n if (stat.isDirectory()) {\n const found = findExecutable(entryPath, name);\n if (found) {\n return found;\n }\n } else if (entry === name) {\n return entryPath;\n }\n }\n\n return undefined;\n}\n\nexport function isDirectory(path: string): boolean {\n try {\n return statSync(path).isDirectory();\n } catch {\n return false;\n }\n}\n\nexport function isFile(path: string): boolean {\n try {\n return statSync(path).isFile();\n } catch {\n return false;\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,13 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Example function that returns a greeting for the given name.
5
- *
6
- * @param name - The name to greet.
7
- * @returns The greeting.
8
- */
9
- function greeter(name) {
10
- return `Hello, ${name}!`;
11
- }
12
- exports.default = greeter;
3
+ exports.readPackageJsonToolConfig = exports.normalizeSystemArchitecture = exports.getPlatformKey = exports.isFile = exports.isDirectory = exports.findExecutable = exports.installExecutableWrapper = exports.downloadFileFromUrl = exports.extractTarGzArchive = exports.extractTarBz2Archive = exports.isFileMissingError = exports.runCommand = exports.readCliValue = exports.verifyFileChecksum = exports.getMetamaskCacheDirectory = exports.cleanInstallerCache = exports.resolvePlatformConfig = exports.requireCompletePlatformConfig = exports.mergeArtifactConfig = exports.getCacheKey = void 0;
4
+ var artifact_1 = require("./artifact.cjs");
5
+ Object.defineProperty(exports, "getCacheKey", { enumerable: true, get: function () { return artifact_1.getCacheKey; } });
6
+ Object.defineProperty(exports, "mergeArtifactConfig", { enumerable: true, get: function () { return artifact_1.mergeArtifactConfig; } });
7
+ Object.defineProperty(exports, "requireCompletePlatformConfig", { enumerable: true, get: function () { return artifact_1.requireCompletePlatformConfig; } });
8
+ Object.defineProperty(exports, "resolvePlatformConfig", { enumerable: true, get: function () { return artifact_1.resolvePlatformConfig; } });
9
+ var cache_1 = require("./cache.cjs");
10
+ Object.defineProperty(exports, "cleanInstallerCache", { enumerable: true, get: function () { return cache_1.cleanInstallerCache; } });
11
+ var cache_directory_1 = require("./cache-directory.cjs");
12
+ Object.defineProperty(exports, "getMetamaskCacheDirectory", { enumerable: true, get: function () { return cache_directory_1.getMetamaskCacheDirectory; } });
13
+ var checksum_1 = require("./checksum.cjs");
14
+ Object.defineProperty(exports, "verifyFileChecksum", { enumerable: true, get: function () { return checksum_1.verifyFileChecksum; } });
15
+ var cli_1 = require("./cli.cjs");
16
+ Object.defineProperty(exports, "readCliValue", { enumerable: true, get: function () { return cli_1.readCliValue; } });
17
+ var command_1 = require("./command.cjs");
18
+ Object.defineProperty(exports, "runCommand", { enumerable: true, get: function () { return command_1.runCommand; } });
19
+ var errors_1 = require("./errors.cjs");
20
+ Object.defineProperty(exports, "isFileMissingError", { enumerable: true, get: function () { return errors_1.isFileMissingError; } });
21
+ var archive_1 = require("./archive.cjs");
22
+ Object.defineProperty(exports, "extractTarBz2Archive", { enumerable: true, get: function () { return archive_1.extractTarBz2Archive; } });
23
+ Object.defineProperty(exports, "extractTarGzArchive", { enumerable: true, get: function () { return archive_1.extractTarGzArchive; } });
24
+ var download_1 = require("./download.cjs");
25
+ Object.defineProperty(exports, "downloadFileFromUrl", { enumerable: true, get: function () { return download_1.downloadFileFromUrl; } });
26
+ var executable_wrapper_1 = require("./executable-wrapper.cjs");
27
+ Object.defineProperty(exports, "installExecutableWrapper", { enumerable: true, get: function () { return executable_wrapper_1.installExecutableWrapper; } });
28
+ var filesystem_1 = require("./filesystem.cjs");
29
+ Object.defineProperty(exports, "findExecutable", { enumerable: true, get: function () { return filesystem_1.findExecutable; } });
30
+ Object.defineProperty(exports, "isDirectory", { enumerable: true, get: function () { return filesystem_1.isDirectory; } });
31
+ Object.defineProperty(exports, "isFile", { enumerable: true, get: function () { return filesystem_1.isFile; } });
32
+ var platform_1 = require("./platform.cjs");
33
+ Object.defineProperty(exports, "getPlatformKey", { enumerable: true, get: function () { return platform_1.getPlatformKey; } });
34
+ Object.defineProperty(exports, "normalizeSystemArchitecture", { enumerable: true, get: function () { return platform_1.normalizeSystemArchitecture; } });
35
+ var package_json_1 = require("./package-json.cjs");
36
+ Object.defineProperty(exports, "readPackageJsonToolConfig", { enumerable: true, get: function () { return package_json_1.readPackageJsonToolConfig; } });
13
37
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,OAAO,CAAC,IAAY;IAC1C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC;AAFD,0BAEC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport default function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAKA,2CAKoB;AAJlB,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,yHAAA,6BAA6B,OAAA;AAC7B,iHAAA,qBAAqB,OAAA;AAEvB,qCAA8C;AAArC,4GAAA,mBAAmB,OAAA;AAC5B,yDAA8D;AAArD,4HAAA,yBAAyB,OAAA;AAClC,2CAAgD;AAAvC,8GAAA,kBAAkB,OAAA;AAC3B,iCAAqC;AAA5B,mGAAA,YAAY,OAAA;AACrB,yCAAuC;AAA9B,qGAAA,UAAU,OAAA;AACnB,uCAA8C;AAArC,4GAAA,kBAAkB,OAAA;AAC3B,yCAAsE;AAA7D,+GAAA,oBAAoB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAClD,2CAAiD;AAAxC,+GAAA,mBAAmB,OAAA;AAC5B,+DAAgE;AAAvD,8HAAA,wBAAwB,OAAA;AAEjC,+CAAmE;AAA1D,4GAAA,cAAc,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,oGAAA,MAAM,OAAA;AAC5C,2CAAyE;AAAhE,0GAAA,cAAc,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AACpD,mDAA2D;AAAlD,yHAAA,yBAAyB,OAAA","sourcesContent":["export type {\n ArtifactConfig,\n ArtifactPlatformConfig,\n InstallDependencies,\n} from './types';\nexport {\n getCacheKey,\n mergeArtifactConfig,\n requireCompletePlatformConfig,\n resolvePlatformConfig,\n} from './artifact';\nexport { cleanInstallerCache } from './cache';\nexport { getMetamaskCacheDirectory } from './cache-directory';\nexport { verifyFileChecksum } from './checksum';\nexport { readCliValue } from './cli';\nexport { runCommand } from './command';\nexport { isFileMissingError } from './errors';\nexport { extractTarBz2Archive, extractTarGzArchive } from './archive';\nexport { downloadFileFromUrl } from './download';\nexport { installExecutableWrapper } from './executable-wrapper';\nexport type { ExecutableWrapperPathResolution } from './executable-wrapper';\nexport { findExecutable, isDirectory, isFile } from './filesystem';\nexport { getPlatformKey, normalizeSystemArchitecture } from './platform';\nexport { readPackageJsonToolConfig } from './package-json';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,16 @@
1
- /**
2
- * Example function that returns a greeting for the given name.
3
- *
4
- * @param name - The name to greet.
5
- * @returns The greeting.
6
- */
7
- export default function greeter(name: string): string;
1
+ export type { ArtifactConfig, ArtifactPlatformConfig, InstallDependencies, } from "./types.cjs";
2
+ export { getCacheKey, mergeArtifactConfig, requireCompletePlatformConfig, resolvePlatformConfig, } from "./artifact.cjs";
3
+ export { cleanInstallerCache } from "./cache.cjs";
4
+ export { getMetamaskCacheDirectory } from "./cache-directory.cjs";
5
+ export { verifyFileChecksum } from "./checksum.cjs";
6
+ export { readCliValue } from "./cli.cjs";
7
+ export { runCommand } from "./command.cjs";
8
+ export { isFileMissingError } from "./errors.cjs";
9
+ export { extractTarBz2Archive, extractTarGzArchive } from "./archive.cjs";
10
+ export { downloadFileFromUrl } from "./download.cjs";
11
+ export { installExecutableWrapper } from "./executable-wrapper.cjs";
12
+ export type { ExecutableWrapperPathResolution } from "./executable-wrapper.cjs";
13
+ export { findExecutable, isDirectory, isFile } from "./filesystem.cjs";
14
+ export { getPlatformKey, normalizeSystemArchitecture } from "./platform.cjs";
15
+ export { readPackageJsonToolConfig } from "./package-json.cjs";
8
16
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,GACpB,oBAAgB;AACjB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,6BAA6B,EAC7B,qBAAqB,GACtB,uBAAmB;AACpB,OAAO,EAAE,mBAAmB,EAAE,oBAAgB;AAC9C,OAAO,EAAE,yBAAyB,EAAE,8BAA0B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,uBAAmB;AAChD,OAAO,EAAE,YAAY,EAAE,kBAAc;AACrC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAC9C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAkB;AACtE,OAAO,EAAE,mBAAmB,EAAE,uBAAmB;AACjD,OAAO,EAAE,wBAAwB,EAAE,iCAA6B;AAChE,YAAY,EAAE,+BAA+B,EAAE,iCAA6B;AAC5E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,yBAAqB;AACnE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,uBAAmB;AACzE,OAAO,EAAE,yBAAyB,EAAE,2BAAuB"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,16 @@
1
- /**
2
- * Example function that returns a greeting for the given name.
3
- *
4
- * @param name - The name to greet.
5
- * @returns The greeting.
6
- */
7
- export default function greeter(name: string): string;
1
+ export type { ArtifactConfig, ArtifactPlatformConfig, InstallDependencies, } from "./types.mjs";
2
+ export { getCacheKey, mergeArtifactConfig, requireCompletePlatformConfig, resolvePlatformConfig, } from "./artifact.mjs";
3
+ export { cleanInstallerCache } from "./cache.mjs";
4
+ export { getMetamaskCacheDirectory } from "./cache-directory.mjs";
5
+ export { verifyFileChecksum } from "./checksum.mjs";
6
+ export { readCliValue } from "./cli.mjs";
7
+ export { runCommand } from "./command.mjs";
8
+ export { isFileMissingError } from "./errors.mjs";
9
+ export { extractTarBz2Archive, extractTarGzArchive } from "./archive.mjs";
10
+ export { downloadFileFromUrl } from "./download.mjs";
11
+ export { installExecutableWrapper } from "./executable-wrapper.mjs";
12
+ export type { ExecutableWrapperPathResolution } from "./executable-wrapper.mjs";
13
+ export { findExecutable, isDirectory, isFile } from "./filesystem.mjs";
14
+ export { getPlatformKey, normalizeSystemArchitecture } from "./platform.mjs";
15
+ export { readPackageJsonToolConfig } from "./package-json.mjs";
8
16
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,mBAAmB,GACpB,oBAAgB;AACjB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,6BAA6B,EAC7B,qBAAqB,GACtB,uBAAmB;AACpB,OAAO,EAAE,mBAAmB,EAAE,oBAAgB;AAC9C,OAAO,EAAE,yBAAyB,EAAE,8BAA0B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,uBAAmB;AAChD,OAAO,EAAE,YAAY,EAAE,kBAAc;AACrC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAC9C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAkB;AACtE,OAAO,EAAE,mBAAmB,EAAE,uBAAmB;AACjD,OAAO,EAAE,wBAAwB,EAAE,iCAA6B;AAChE,YAAY,EAAE,+BAA+B,EAAE,iCAA6B;AAC5E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,yBAAqB;AACnE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,uBAAmB;AACzE,OAAO,EAAE,yBAAyB,EAAE,2BAAuB"}
package/dist/index.mjs CHANGED
@@ -1,10 +1,14 @@
1
- /**
2
- * Example function that returns a greeting for the given name.
3
- *
4
- * @param name - The name to greet.
5
- * @returns The greeting.
6
- */
7
- export default function greeter(name) {
8
- return `Hello, ${name}!`;
9
- }
1
+ export { getCacheKey, mergeArtifactConfig, requireCompletePlatformConfig, resolvePlatformConfig } from "./artifact.mjs";
2
+ export { cleanInstallerCache } from "./cache.mjs";
3
+ export { getMetamaskCacheDirectory } from "./cache-directory.mjs";
4
+ export { verifyFileChecksum } from "./checksum.mjs";
5
+ export { readCliValue } from "./cli.mjs";
6
+ export { runCommand } from "./command.mjs";
7
+ export { isFileMissingError } from "./errors.mjs";
8
+ export { extractTarBz2Archive, extractTarGzArchive } from "./archive.mjs";
9
+ export { downloadFileFromUrl } from "./download.mjs";
10
+ export { installExecutableWrapper } from "./executable-wrapper.mjs";
11
+ export { findExecutable, isDirectory, isFile } from "./filesystem.mjs";
12
+ export { getPlatformKey, normalizeSystemArchitecture } from "./platform.mjs";
13
+ export { readPackageJsonToolConfig } from "./package-json.mjs";
10
14
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAY;IAC1C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport default function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,6BAA6B,EAC7B,qBAAqB,EACtB,uBAAmB;AACpB,OAAO,EAAE,mBAAmB,EAAE,oBAAgB;AAC9C,OAAO,EAAE,yBAAyB,EAAE,8BAA0B;AAC9D,OAAO,EAAE,kBAAkB,EAAE,uBAAmB;AAChD,OAAO,EAAE,YAAY,EAAE,kBAAc;AACrC,OAAO,EAAE,UAAU,EAAE,sBAAkB;AACvC,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAC9C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAkB;AACtE,OAAO,EAAE,mBAAmB,EAAE,uBAAmB;AACjD,OAAO,EAAE,wBAAwB,EAAE,iCAA6B;AAEhE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,yBAAqB;AACnE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,uBAAmB;AACzE,OAAO,EAAE,yBAAyB,EAAE,2BAAuB","sourcesContent":["export type {\n ArtifactConfig,\n ArtifactPlatformConfig,\n InstallDependencies,\n} from './types';\nexport {\n getCacheKey,\n mergeArtifactConfig,\n requireCompletePlatformConfig,\n resolvePlatformConfig,\n} from './artifact';\nexport { cleanInstallerCache } from './cache';\nexport { getMetamaskCacheDirectory } from './cache-directory';\nexport { verifyFileChecksum } from './checksum';\nexport { readCliValue } from './cli';\nexport { runCommand } from './command';\nexport { isFileMissingError } from './errors';\nexport { extractTarBz2Archive, extractTarGzArchive } from './archive';\nexport { downloadFileFromUrl } from './download';\nexport { installExecutableWrapper } from './executable-wrapper';\nexport type { ExecutableWrapperPathResolution } from './executable-wrapper';\nexport { findExecutable, isDirectory, isFile } from './filesystem';\nexport { getPlatformKey, normalizeSystemArchitecture } from './platform';\nexport { readPackageJsonToolConfig } from './package-json';\n"]}