@metamask-previews/local-node-utils 1.0.0-preview-4f4c98e → 1.0.0-preview-eb263b0ee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -4
- package/dist/archive.cjs +13 -0
- package/dist/archive.cjs.map +1 -0
- package/dist/{archive.d.ts → archive.d.cts} +1 -1
- package/dist/archive.d.cts.map +1 -0
- package/dist/archive.d.mts +3 -0
- package/dist/archive.d.mts.map +1 -0
- package/dist/{archive.js → archive.mjs} +2 -2
- package/dist/archive.mjs.map +1 -0
- package/dist/artifact.cjs +40 -0
- package/dist/artifact.cjs.map +1 -0
- package/dist/{artifact.d.ts → artifact.d.cts} +2 -2
- package/dist/artifact.d.cts.map +1 -0
- package/dist/artifact.d.mts +6 -0
- package/dist/artifact.d.mts.map +1 -0
- package/dist/{artifact.js → artifact.mjs} +2 -2
- package/dist/artifact.mjs.map +1 -0
- package/dist/cache-directory.cjs +28 -0
- package/dist/cache-directory.cjs.map +1 -0
- package/dist/{cache-directory.d.ts → cache-directory.d.cts} +1 -1
- package/dist/cache-directory.d.cts.map +1 -0
- package/dist/cache-directory.d.mts +6 -0
- package/dist/cache-directory.d.mts.map +1 -0
- package/dist/{cache-directory.js → cache-directory.mjs} +6 -6
- package/dist/cache-directory.mjs.map +1 -0
- package/dist/cache.cjs +14 -0
- package/dist/cache.cjs.map +1 -0
- package/dist/{cache.d.ts → cache.d.cts} +1 -1
- package/dist/cache.d.cts.map +1 -0
- package/dist/cache.d.mts +5 -0
- package/dist/cache.d.mts.map +1 -0
- package/dist/{cache.js → cache.mjs} +3 -3
- package/dist/cache.mjs.map +1 -0
- package/dist/checksum.cjs +17 -0
- package/dist/checksum.cjs.map +1 -0
- package/dist/{checksum.d.ts → checksum.d.cts} +1 -1
- package/dist/checksum.d.cts.map +1 -0
- package/dist/checksum.d.mts +2 -0
- package/dist/checksum.d.mts.map +1 -0
- package/dist/{checksum.js → checksum.mjs} +4 -4
- package/dist/checksum.mjs.map +1 -0
- package/dist/cli.cjs +11 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/{cli.d.ts → cli.d.cts} +1 -1
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/{cli.js → cli.mjs} +1 -1
- package/dist/cli.mjs.map +1 -0
- package/dist/command.cjs +28 -0
- package/dist/command.cjs.map +1 -0
- package/dist/{command.d.ts → command.d.cts} +1 -1
- package/dist/command.d.cts.map +1 -0
- package/dist/command.d.mts +2 -0
- package/dist/command.d.mts.map +1 -0
- package/dist/{command.js → command.mjs} +2 -2
- package/dist/command.mjs.map +1 -0
- package/dist/download.cjs +47 -0
- package/dist/download.cjs.map +1 -0
- package/dist/{download.d.ts → download.d.cts} +1 -1
- package/dist/download.d.cts.map +1 -0
- package/dist/download.d.mts +3 -0
- package/dist/download.d.mts.map +1 -0
- package/dist/{download.js → download.mjs} +7 -7
- package/dist/download.mjs.map +1 -0
- package/dist/errors.cjs +11 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/{errors.d.ts → errors.d.cts} +1 -1
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +2 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/{errors.js → errors.mjs} +1 -1
- package/dist/errors.mjs.map +1 -0
- package/dist/executable-wrapper.cjs +76 -0
- package/dist/executable-wrapper.cjs.map +1 -0
- package/dist/{executable-wrapper.d.ts → executable-wrapper.d.cts} +1 -1
- package/dist/executable-wrapper.d.cts.map +1 -0
- package/dist/executable-wrapper.d.mts +9 -0
- package/dist/executable-wrapper.d.mts.map +1 -0
- package/dist/{executable-wrapper.js → executable-wrapper.mjs} +4 -4
- package/dist/executable-wrapper.mjs.map +1 -0
- package/dist/filesystem.cjs +45 -0
- package/dist/filesystem.cjs.map +1 -0
- package/dist/{filesystem.d.ts → filesystem.d.cts} +1 -1
- package/dist/filesystem.d.cts.map +1 -0
- package/dist/filesystem.d.mts +4 -0
- package/dist/filesystem.d.mts.map +1 -0
- package/dist/{filesystem.js → filesystem.mjs} +3 -3
- package/dist/filesystem.mjs.map +1 -0
- package/dist/index.cjs +37 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -0
- package/dist/package-json.cjs +29 -0
- package/dist/package-json.cjs.map +1 -0
- package/dist/{package-json.d.ts → package-json.d.cts} +1 -1
- package/dist/package-json.d.cts.map +1 -0
- package/dist/package-json.d.mts +6 -0
- package/dist/package-json.d.mts.map +1 -0
- package/dist/{package-json.js → package-json.mjs} +4 -4
- package/dist/package-json.mjs.map +1 -0
- package/dist/platform.cjs +25 -0
- package/dist/platform.cjs.map +1 -0
- package/dist/{platform.d.ts → platform.d.cts} +1 -1
- package/dist/platform.d.cts.map +1 -0
- package/dist/platform.d.mts +3 -0
- package/dist/platform.d.mts.map +1 -0
- package/dist/{platform.js → platform.mjs} +3 -3
- package/dist/platform.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +1 -1
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +14 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +16 -12
- package/dist/archive.d.ts.map +0 -1
- package/dist/archive.js.map +0 -1
- package/dist/artifact.d.ts.map +0 -1
- package/dist/artifact.js.map +0 -1
- package/dist/cache-directory.d.ts.map +0 -1
- package/dist/cache-directory.js.map +0 -1
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js.map +0 -1
- package/dist/checksum.d.ts.map +0 -1
- package/dist/checksum.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/command.d.ts.map +0 -1
- package/dist/command.js.map +0 -1
- package/dist/download.d.ts.map +0 -1
- package/dist/download.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/executable-wrapper.d.ts.map +0 -1
- package/dist/executable-wrapper.js.map +0 -1
- package/dist/filesystem.d.ts.map +0 -1
- package/dist/filesystem.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/package-json.d.ts.map +0 -1
- package/dist/package-json.js.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
|
|
13
|
-
|
|
14
10
|
## [1.0.0]
|
|
15
11
|
|
|
16
12
|
### Added
|
package/dist/archive.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractTarBz2Archive = exports.extractTarGzArchive = void 0;
|
|
4
|
+
const command_js_1 = require("./command.cjs");
|
|
5
|
+
async function extractTarGzArchive(archivePath, destination) {
|
|
6
|
+
await (0, command_js_1.runCommand)('tar', ['-xzf', archivePath, '-C', destination]);
|
|
7
|
+
}
|
|
8
|
+
exports.extractTarGzArchive = extractTarGzArchive;
|
|
9
|
+
async function extractTarBz2Archive(archivePath, destination) {
|
|
10
|
+
await (0, command_js_1.runCommand)('tar', ['-xjf', archivePath, '-C', destination]);
|
|
11
|
+
}
|
|
12
|
+
exports.extractTarBz2Archive = extractTarBz2Archive;
|
|
13
|
+
//# sourceMappingURL=archive.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.cjs","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":";;;AAAA,8CAA0C;AAEnC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,WAAmB;IAEnB,MAAM,IAAA,uBAAU,EAAC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACpE,CAAC;AALD,kDAKC;AAEM,KAAK,UAAU,oBAAoB,CACxC,WAAmB,EACnB,WAAmB;IAEnB,MAAM,IAAA,uBAAU,EAAC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACpE,CAAC;AALD,oDAKC","sourcesContent":["import { runCommand } from './command.js';\n\nexport async function extractTarGzArchive(\n archivePath: string,\n destination: string,\n): Promise<void> {\n await runCommand('tar', ['-xzf', archivePath, '-C', destination]);\n}\n\nexport async function extractTarBz2Archive(\n archivePath: string,\n destination: string,\n): Promise<void> {\n await runCommand('tar', ['-xjf', archivePath, '-C', destination]);\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function extractTarGzArchive(archivePath: string, destination: string): Promise<void>;
|
|
2
2
|
export declare function extractTarBz2Archive(archivePath: string, destination: string): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=archive.d.
|
|
3
|
+
//# sourceMappingURL=archive.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.d.cts","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAEA,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.d.mts","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAEA,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { runCommand } from
|
|
1
|
+
import { runCommand } from "./command.mjs";
|
|
2
2
|
export async function extractTarGzArchive(archivePath, destination) {
|
|
3
3
|
await runCommand('tar', ['-xzf', archivePath, '-C', destination]);
|
|
4
4
|
}
|
|
5
5
|
export async function extractTarBz2Archive(archivePath, destination) {
|
|
6
6
|
await runCommand('tar', ['-xjf', archivePath, '-C', destination]);
|
|
7
7
|
}
|
|
8
|
-
//# sourceMappingURL=archive.
|
|
8
|
+
//# sourceMappingURL=archive.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive.mjs","sourceRoot":"","sources":["../src/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAqB;AAE1C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,WAAmB;IAEnB,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,WAAmB,EACnB,WAAmB;IAEnB,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { runCommand } from './command.js';\n\nexport async function extractTarGzArchive(\n archivePath: string,\n destination: string,\n): Promise<void> {\n await runCommand('tar', ['-xzf', archivePath, '-C', destination]);\n}\n\nexport async function extractTarBz2Archive(\n archivePath: string,\n destination: string,\n): Promise<void> {\n await runCommand('tar', ['-xjf', archivePath, '-C', destination]);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCacheKey = exports.requireCompletePlatformConfig = exports.resolvePlatformConfig = exports.mergeArtifactConfig = void 0;
|
|
4
|
+
/* eslint-disable import-x/no-nodejs-modules */
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
function mergeArtifactConfig(defaults, override) {
|
|
7
|
+
if (!override) {
|
|
8
|
+
return defaults;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
version: override.version ?? defaults.version,
|
|
12
|
+
platforms: { ...defaults.platforms, ...override.platforms },
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.mergeArtifactConfig = mergeArtifactConfig;
|
|
16
|
+
function resolvePlatformConfig(config, platform, label) {
|
|
17
|
+
const platformConfig = config.platforms.current ?? config.platforms[platform];
|
|
18
|
+
if (!platformConfig) {
|
|
19
|
+
throw new Error(`No ${label} is configured for ${platform}.`);
|
|
20
|
+
}
|
|
21
|
+
return platformConfig;
|
|
22
|
+
}
|
|
23
|
+
exports.resolvePlatformConfig = resolvePlatformConfig;
|
|
24
|
+
function requireCompletePlatformConfig(config, label) {
|
|
25
|
+
if (!config.url || !config.checksum) {
|
|
26
|
+
throw new Error(`${label} require both a URL and a checksum.`);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
checksum: config.checksum,
|
|
30
|
+
url: config.url,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.requireCompletePlatformConfig = requireCompletePlatformConfig;
|
|
34
|
+
function getCacheKey(config) {
|
|
35
|
+
return (0, node_crypto_1.createHash)('sha256')
|
|
36
|
+
.update(`${config.url}:${config.checksum}`)
|
|
37
|
+
.digest('hex');
|
|
38
|
+
}
|
|
39
|
+
exports.getCacheKey = getCacheKey;
|
|
40
|
+
//# sourceMappingURL=artifact.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.cjs","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,6CAAyC;AAIzC,SAAgB,mBAAmB,CACjC,QAAwB,EACxB,QAAoC;IAEpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO;QAC7C,SAAS,EAAE,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE;KAC5D,CAAC;AACJ,CAAC;AAZD,kDAYC;AAED,SAAgB,qBAAqB,CACnC,MAAsB,EACtB,QAAgB,EAChB,KAAa;IAEb,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE9E,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,sBAAsB,QAAQ,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAZD,sDAYC;AAED,SAAgB,6BAA6B,CAC3C,MAAuC,EACvC,KAAa;IAEb,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAC;IACjE,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAC;AACJ,CAAC;AAZD,sEAYC;AAED,SAAgB,WAAW,CAAC,MAA8B;IACxD,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;SAC1C,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAJD,kCAIC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { createHash } from 'node:crypto';\n\nimport type { ArtifactConfig, ArtifactPlatformConfig } from './types.js';\n\nexport function mergeArtifactConfig(\n defaults: ArtifactConfig,\n override: ArtifactConfig | undefined,\n): ArtifactConfig {\n if (!override) {\n return defaults;\n }\n\n return {\n version: override.version ?? defaults.version,\n platforms: { ...defaults.platforms, ...override.platforms },\n };\n}\n\nexport function resolvePlatformConfig(\n config: ArtifactConfig,\n platform: string,\n label: string,\n): ArtifactPlatformConfig {\n const platformConfig = config.platforms.current ?? config.platforms[platform];\n\n if (!platformConfig) {\n throw new Error(`No ${label} is configured for ${platform}.`);\n }\n\n return platformConfig;\n}\n\nexport function requireCompletePlatformConfig(\n config: Partial<ArtifactPlatformConfig>,\n label: string,\n): ArtifactPlatformConfig {\n if (!config.url || !config.checksum) {\n throw new Error(`${label} require both a URL and a checksum.`);\n }\n\n return {\n checksum: config.checksum,\n url: config.url,\n };\n}\n\nexport function getCacheKey(config: ArtifactPlatformConfig): string {\n return createHash('sha256')\n .update(`${config.url}:${config.checksum}`)\n .digest('hex');\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ArtifactConfig, ArtifactPlatformConfig } from
|
|
1
|
+
import type { ArtifactConfig, ArtifactPlatformConfig } from "./types.cjs";
|
|
2
2
|
export declare function mergeArtifactConfig(defaults: ArtifactConfig, override: ArtifactConfig | undefined): ArtifactConfig;
|
|
3
3
|
export declare function resolvePlatformConfig(config: ArtifactConfig, platform: string, label: string): ArtifactPlatformConfig;
|
|
4
4
|
export declare function requireCompletePlatformConfig(config: Partial<ArtifactPlatformConfig>, label: string): ArtifactPlatformConfig;
|
|
5
5
|
export declare function getCacheKey(config: ArtifactPlatformConfig): string;
|
|
6
|
-
//# sourceMappingURL=artifact.d.
|
|
6
|
+
//# sourceMappingURL=artifact.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.d.cts","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAmB;AAEzE,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc,GAAG,SAAS,GACnC,cAAc,CAShB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,sBAAsB,CAQxB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,OAAO,CAAC,sBAAsB,CAAC,EACvC,KAAK,EAAE,MAAM,GACZ,sBAAsB,CASxB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAIlE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ArtifactConfig, ArtifactPlatformConfig } from "./types.mjs";
|
|
2
|
+
export declare function mergeArtifactConfig(defaults: ArtifactConfig, override: ArtifactConfig | undefined): ArtifactConfig;
|
|
3
|
+
export declare function resolvePlatformConfig(config: ArtifactConfig, platform: string, label: string): ArtifactPlatformConfig;
|
|
4
|
+
export declare function requireCompletePlatformConfig(config: Partial<ArtifactPlatformConfig>, label: string): ArtifactPlatformConfig;
|
|
5
|
+
export declare function getCacheKey(config: ArtifactPlatformConfig): string;
|
|
6
|
+
//# sourceMappingURL=artifact.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.d.mts","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAmB;AAEzE,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc,GAAG,SAAS,GACnC,cAAc,CAShB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,sBAAsB,CAQxB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,OAAO,CAAC,sBAAsB,CAAC,EACvC,KAAK,EAAE,MAAM,GACZ,sBAAsB,CASxB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAIlE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-nodejs-modules */
|
|
2
|
-
import { createHash } from
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
3
|
export function mergeArtifactConfig(defaults, override) {
|
|
4
4
|
if (!override) {
|
|
5
5
|
return defaults;
|
|
@@ -30,4 +30,4 @@ export function getCacheKey(config) {
|
|
|
30
30
|
.update(`${config.url}:${config.checksum}`)
|
|
31
31
|
.digest('hex');
|
|
32
32
|
}
|
|
33
|
-
//# sourceMappingURL=artifact.
|
|
33
|
+
//# sourceMappingURL=artifact.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.mjs","sourceRoot":"","sources":["../src/artifact.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,oBAAoB;AAIzC,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,QAAoC;IAEpC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO;QAC7C,SAAS,EAAE,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE;KAC5D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAAsB,EACtB,QAAgB,EAChB,KAAa;IAEb,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAE9E,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,sBAAsB,QAAQ,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,MAAuC,EACvC,KAAa;IAEb,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAC;IACjE,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;SAC1C,MAAM,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { createHash } from 'node:crypto';\n\nimport type { ArtifactConfig, ArtifactPlatformConfig } from './types.js';\n\nexport function mergeArtifactConfig(\n defaults: ArtifactConfig,\n override: ArtifactConfig | undefined,\n): ArtifactConfig {\n if (!override) {\n return defaults;\n }\n\n return {\n version: override.version ?? defaults.version,\n platforms: { ...defaults.platforms, ...override.platforms },\n };\n}\n\nexport function resolvePlatformConfig(\n config: ArtifactConfig,\n platform: string,\n label: string,\n): ArtifactPlatformConfig {\n const platformConfig = config.platforms.current ?? config.platforms[platform];\n\n if (!platformConfig) {\n throw new Error(`No ${label} is configured for ${platform}.`);\n }\n\n return platformConfig;\n}\n\nexport function requireCompletePlatformConfig(\n config: Partial<ArtifactPlatformConfig>,\n label: string,\n): ArtifactPlatformConfig {\n if (!config.url || !config.checksum) {\n throw new Error(`${label} require both a URL and a checksum.`);\n }\n\n return {\n checksum: config.checksum,\n url: config.url,\n };\n}\n\nexport function getCacheKey(config: ArtifactPlatformConfig): string {\n return createHash('sha256')\n .update(`${config.url}:${config.checksum}`)\n .digest('hex');\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetamaskCacheDirectory = void 0;
|
|
4
|
+
/* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const yaml_1 = require("yaml");
|
|
9
|
+
const errors_js_1 = require("./errors.cjs");
|
|
10
|
+
function getMetamaskCacheDirectory({ cwd = process.cwd(), homeDirectory = (0, node_os_1.homedir)(), toolName = 'local-node-utils', } = {}) {
|
|
11
|
+
const yarnRcPath = (0, node_path_1.join)(cwd, '.yarnrc.yml');
|
|
12
|
+
let enableGlobalCache = false;
|
|
13
|
+
try {
|
|
14
|
+
const parsedConfig = (0, yaml_1.parse)((0, node_fs_1.readFileSync)(yarnRcPath, 'utf8'));
|
|
15
|
+
enableGlobalCache = parsedConfig?.enableGlobalCache ?? false;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if ((0, errors_js_1.isFileMissingError)(error)) {
|
|
19
|
+
return (0, node_path_1.join)(cwd, '.metamask', 'cache');
|
|
20
|
+
}
|
|
21
|
+
console.warn(`Warning: Error reading ${yarnRcPath}, using local ${toolName} cache:`, error);
|
|
22
|
+
}
|
|
23
|
+
return enableGlobalCache
|
|
24
|
+
? (0, node_path_1.join)(homeDirectory, '.cache', 'metamask')
|
|
25
|
+
: (0, node_path_1.join)(cwd, '.metamask', 'cache');
|
|
26
|
+
}
|
|
27
|
+
exports.getMetamaskCacheDirectory = getMetamaskCacheDirectory;
|
|
28
|
+
//# sourceMappingURL=cache-directory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-directory.cjs","sourceRoot":"","sources":["../src/cache-directory.ts"],"names":[],"mappings":";;;AAAA,sEAAsE;AACtE,qCAAuC;AACvC,qCAAkC;AAClC,yCAAiC;AACjC,+BAA0C;AAE1C,4CAAiD;AAEjD,SAAgB,yBAAyB,CAAC,EACxC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,aAAa,GAAG,IAAA,iBAAO,GAAE,EACzB,QAAQ,GAAG,kBAAkB,MAK3B,EAAE;IACJ,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAC5C,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAA,YAAS,EAAC,IAAA,sBAAY,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,iBAAiB,GAAG,YAAY,EAAE,iBAAiB,IAAI,KAAK,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,IAAA,8BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAA,gBAAI,EAAC,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,IAAI,CACV,0BAA0B,UAAU,iBAAiB,QAAQ,SAAS,EACtE,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB;QACtB,CAAC,CAAC,IAAA,gBAAI,EAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC3C,CAAC,CAAC,IAAA,gBAAI,EAAC,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AA5BD,8DA4BC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */\nimport { readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\n\nimport { isFileMissingError } from './errors.js';\n\nexport function getMetamaskCacheDirectory({\n cwd = process.cwd(),\n homeDirectory = homedir(),\n toolName = 'local-node-utils',\n}: {\n cwd?: string;\n homeDirectory?: string;\n toolName?: string;\n} = {}): string {\n const yarnRcPath = join(cwd, '.yarnrc.yml');\n let enableGlobalCache = false;\n\n try {\n const parsedConfig = parseYaml(readFileSync(yarnRcPath, 'utf8'));\n enableGlobalCache = parsedConfig?.enableGlobalCache ?? false;\n } catch (error) {\n if (isFileMissingError(error)) {\n return join(cwd, '.metamask', 'cache');\n }\n console.warn(\n `Warning: Error reading ${yarnRcPath}, using local ${toolName} cache:`,\n error,\n );\n }\n\n return enableGlobalCache\n ? join(homeDirectory, '.cache', 'metamask')\n : join(cwd, '.metamask', 'cache');\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-directory.d.cts","sourceRoot":"","sources":["../src/cache-directory.ts"],"names":[],"mappings":"AAQA,wBAAgB,yBAAyB,CAAC,EACxC,GAAmB,EACnB,aAAyB,EACzB,QAA6B,GAC9B,GAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAoBd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-directory.d.mts","sourceRoot":"","sources":["../src/cache-directory.ts"],"names":[],"mappings":"AAQA,wBAAgB,yBAAyB,CAAC,EACxC,GAAmB,EACnB,aAAyB,EACzB,QAA6B,GAC9B,GAAE;IACD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAoBd"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */
|
|
2
|
-
import { readFileSync } from
|
|
3
|
-
import { homedir } from
|
|
4
|
-
import { join } from
|
|
5
|
-
import { parse as parseYaml } from
|
|
6
|
-
import { isFileMissingError } from
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { parse as parseYaml } from "yaml";
|
|
6
|
+
import { isFileMissingError } from "./errors.mjs";
|
|
7
7
|
export function getMetamaskCacheDirectory({ cwd = process.cwd(), homeDirectory = homedir(), toolName = 'local-node-utils', } = {}) {
|
|
8
8
|
const yarnRcPath = join(cwd, '.yarnrc.yml');
|
|
9
9
|
let enableGlobalCache = false;
|
|
@@ -21,4 +21,4 @@ export function getMetamaskCacheDirectory({ cwd = process.cwd(), homeDirectory =
|
|
|
21
21
|
? join(homeDirectory, '.cache', 'metamask')
|
|
22
22
|
: join(cwd, '.metamask', 'cache');
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=cache-directory.
|
|
24
|
+
//# sourceMappingURL=cache-directory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-directory.mjs","sourceRoot":"","sources":["../src/cache-directory.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB;AACvC,OAAO,EAAE,OAAO,EAAE,gBAAgB;AAClC,OAAO,EAAE,IAAI,EAAE,kBAAkB;AACjC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,aAAa;AAE1C,OAAO,EAAE,kBAAkB,EAAE,qBAAoB;AAEjD,MAAM,UAAU,yBAAyB,CAAC,EACxC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,aAAa,GAAG,OAAO,EAAE,EACzB,QAAQ,GAAG,kBAAkB,MAK3B,EAAE;IACJ,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAC5C,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,iBAAiB,GAAG,YAAY,EAAE,iBAAiB,IAAI,KAAK,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,IAAI,CACV,0BAA0B,UAAU,iBAAiB,QAAQ,SAAS,EACtE,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO,iBAAiB;QACtB,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC3C,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */\nimport { readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\n\nimport { isFileMissingError } from './errors.js';\n\nexport function getMetamaskCacheDirectory({\n cwd = process.cwd(),\n homeDirectory = homedir(),\n toolName = 'local-node-utils',\n}: {\n cwd?: string;\n homeDirectory?: string;\n toolName?: string;\n} = {}): string {\n const yarnRcPath = join(cwd, '.yarnrc.yml');\n let enableGlobalCache = false;\n\n try {\n const parsedConfig = parseYaml(readFileSync(yarnRcPath, 'utf8'));\n enableGlobalCache = parsedConfig?.enableGlobalCache ?? false;\n } catch (error) {\n if (isFileMissingError(error)) {\n return join(cwd, '.metamask', 'cache');\n }\n console.warn(\n `Warning: Error reading ${yarnRcPath}, using local ${toolName} cache:`,\n error,\n );\n }\n\n return enableGlobalCache\n ? join(homeDirectory, '.cache', 'metamask')\n : join(cwd, '.metamask', 'cache');\n}\n"]}
|
package/dist/cache.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanInstallerCache = 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
|
+
async function cleanInstallerCache({ cacheDirectory, namespace, }) {
|
|
8
|
+
await (0, promises_1.rm)((0, node_path_1.join)(cacheDirectory, namespace), {
|
|
9
|
+
force: true,
|
|
10
|
+
recursive: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.cleanInstallerCache = cleanInstallerCache;
|
|
14
|
+
//# sourceMappingURL=cache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.cjs","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,+CAAsC;AACtC,yCAAiC;AAE1B,KAAK,UAAU,mBAAmB,CAAC,EACxC,cAAc,EACd,SAAS,GAIV;IACC,MAAM,IAAA,aAAE,EAAC,IAAA,gBAAI,EAAC,cAAc,EAAE,SAAS,CAAC,EAAE;QACxC,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAXD,kDAWC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { rm } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport async function cleanInstallerCache({\n cacheDirectory,\n namespace,\n}: {\n cacheDirectory: string;\n namespace: string;\n}): Promise<void> {\n await rm(join(cacheDirectory, namespace), {\n force: true,\n recursive: true,\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.cts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAIA,wBAAsB,mBAAmB,CAAC,EACxC,cAAc,EACd,SAAS,GACV,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhB"}
|
package/dist/cache.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.mts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAIA,wBAAsB,mBAAmB,CAAC,EACxC,cAAc,EACd,SAAS,GACV,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-nodejs-modules */
|
|
2
|
-
import { rm } from
|
|
3
|
-
import { join } from
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
export async function cleanInstallerCache({ cacheDirectory, namespace, }) {
|
|
5
5
|
await rm(join(cacheDirectory, namespace), {
|
|
6
6
|
force: true,
|
|
7
7
|
recursive: true,
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=cache.
|
|
10
|
+
//# sourceMappingURL=cache.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.mjs","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,EAAE,EAAE,yBAAyB;AACtC,OAAO,EAAE,IAAI,EAAE,kBAAkB;AAEjC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EACxC,cAAc,EACd,SAAS,GAIV;IACC,MAAM,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,EAAE;QACxC,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { rm } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport async function cleanInstallerCache({\n cacheDirectory,\n namespace,\n}: {\n cacheDirectory: string;\n namespace: string;\n}): Promise<void> {\n await rm(join(cacheDirectory, namespace), {\n force: true,\n recursive: true,\n });\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyFileChecksum = void 0;
|
|
4
|
+
/* eslint-disable import-x/no-nodejs-modules */
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const promises_1 = require("node:stream/promises");
|
|
8
|
+
async function verifyFileChecksum(filePath, expectedChecksum, label) {
|
|
9
|
+
const hash = (0, node_crypto_1.createHash)('sha256');
|
|
10
|
+
await (0, promises_1.pipeline)((0, node_fs_1.createReadStream)(filePath), hash);
|
|
11
|
+
const checksum = hash.digest('hex');
|
|
12
|
+
if (checksum !== expectedChecksum) {
|
|
13
|
+
throw new Error(`${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.verifyFileChecksum = verifyFileChecksum;
|
|
17
|
+
//# sourceMappingURL=checksum.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum.cjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,6CAAyC;AACzC,qCAA2C;AAC3C,mDAAgD;AAEzC,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,gBAAwB,EACxB,KAAa;IAEb,MAAM,IAAI,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,IAAA,mBAAQ,EAAC,IAAA,0BAAgB,EAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,QAAQ,KAAK,gBAAgB,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,gCAAgC,gBAAgB,SAAS,QAAQ,GAAG,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC;AAdD,gDAcC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { createHash } from 'node:crypto';\nimport { createReadStream } from 'node:fs';\nimport { pipeline } from 'node:stream/promises';\n\nexport async function verifyFileChecksum(\n filePath: string,\n expectedChecksum: string,\n label: string,\n): Promise<void> {\n const hash = createHash('sha256');\n await pipeline(createReadStream(filePath), hash);\n const checksum = hash.digest('hex');\n\n if (checksum !== expectedChecksum) {\n throw new Error(\n `${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function verifyFileChecksum(filePath: string, expectedChecksum: string, label: string): Promise<void>;
|
|
2
|
-
//# sourceMappingURL=checksum.d.
|
|
2
|
+
//# sourceMappingURL=checksum.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum.d.cts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAKA,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum.d.mts","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAKA,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-nodejs-modules */
|
|
2
|
-
import { createHash } from
|
|
3
|
-
import { createReadStream } from
|
|
4
|
-
import { pipeline } from
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { createReadStream } from "node:fs";
|
|
4
|
+
import { pipeline } from "node:stream/promises";
|
|
5
5
|
export async function verifyFileChecksum(filePath, expectedChecksum, label) {
|
|
6
6
|
const hash = createHash('sha256');
|
|
7
7
|
await pipeline(createReadStream(filePath), hash);
|
|
@@ -10,4 +10,4 @@ export async function verifyFileChecksum(filePath, expectedChecksum, label) {
|
|
|
10
10
|
throw new Error(`${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=checksum.
|
|
13
|
+
//# sourceMappingURL=checksum.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum.mjs","sourceRoot":"","sources":["../src/checksum.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,oBAAoB;AACzC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB;AAC3C,OAAO,EAAE,QAAQ,EAAE,6BAA6B;AAEhD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,QAAgB,EAChB,gBAAwB,EACxB,KAAa;IAEb,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,QAAQ,KAAK,gBAAgB,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,gCAAgC,gBAAgB,SAAS,QAAQ,GAAG,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { createHash } from 'node:crypto';\nimport { createReadStream } from 'node:fs';\nimport { pipeline } from 'node:stream/promises';\n\nexport async function verifyFileChecksum(\n filePath: string,\n expectedChecksum: string,\n label: string,\n): Promise<void> {\n const hash = createHash('sha256');\n await pipeline(createReadStream(filePath), hash);\n const checksum = hash.digest('hex');\n\n if (checksum !== expectedChecksum) {\n throw new Error(\n `${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n}\n"]}
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readCliValue = void 0;
|
|
4
|
+
function readCliValue(option, value) {
|
|
5
|
+
if (!value || value.startsWith('--')) {
|
|
6
|
+
throw new Error(`${option} requires a value.`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
exports.readCliValue = readCliValue;
|
|
11
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.cjs","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAC1B,MAAc,EACd,KAAyB;IAEzB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,oBAAoB,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AATD,oCASC","sourcesContent":["export function readCliValue(\n option: string,\n value: string | undefined,\n): string {\n if (!value || value.startsWith('--')) {\n throw new Error(`${option} requires a value.`);\n }\n\n return value;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function readCliValue(option: string, value: string | undefined): string;
|
|
2
|
-
//# sourceMappingURL=cli.d.
|
|
2
|
+
//# sourceMappingURL=cli.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.cts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAMR"}
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.mts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAMR"}
|
package/dist/{cli.js → cli.mjs}
RENAMED
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,KAAyB;IAEzB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,oBAAoB,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["export function readCliValue(\n option: string,\n value: string | undefined,\n): string {\n if (!value || value.startsWith('--')) {\n throw new Error(`${option} requires a value.`);\n }\n\n return value;\n}\n"]}
|
package/dist/command.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommand = void 0;
|
|
4
|
+
/* eslint-disable import-x/no-nodejs-modules */
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
async function runCommand(command, args) {
|
|
7
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
8
|
+
const child = (0, node_child_process_1.spawn)(command, args, {
|
|
9
|
+
shell: false,
|
|
10
|
+
stdio: ['ignore', 'ignore', 'pipe'],
|
|
11
|
+
});
|
|
12
|
+
let stderr = '';
|
|
13
|
+
child.stderr.on('data', (chunk) => {
|
|
14
|
+
stderr += chunk.toString();
|
|
15
|
+
});
|
|
16
|
+
child.on('error', rejectPromise);
|
|
17
|
+
child.on('close', (code, signal) => {
|
|
18
|
+
if (code === 0) {
|
|
19
|
+
resolvePromise();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const exitStatus = signal ? `signal ${signal}` : `code ${code ?? 'null'}`;
|
|
23
|
+
rejectPromise(new Error(`${command} ${args.join(' ')} failed with ${exitStatus}: ${stderr}`));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.runCommand = runCommand;
|
|
28
|
+
//# sourceMappingURL=command.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.cjs","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,2DAA2C;AAEpC,KAAK,UAAU,UAAU,CAC9B,OAAe,EACf,IAAc;IAEd,MAAM,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACxD,MAAM,KAAK,GAAG,IAAA,0BAAK,EAAC,OAAO,EAAE,IAAI,EAAE;YACjC,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;SACpC,CAAC,CAAC;QACH,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACjC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACjC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,cAAc,EAAE,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1E,aAAa,CACX,IAAI,KAAK,CACP,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,UAAU,KAAK,MAAM,EAAE,CACpE,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA7BD,gCA6BC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { spawn } from 'node:child_process';\n\nexport async function runCommand(\n command: string,\n args: string[],\n): Promise<void> {\n await new Promise<void>((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n shell: false,\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n let stderr = '';\n\n child.stderr.on('data', (chunk) => {\n stderr += chunk.toString();\n });\n child.on('error', rejectPromise);\n child.on('close', (code, signal) => {\n if (code === 0) {\n resolvePromise();\n return;\n }\n\n const exitStatus = signal ? `signal ${signal}` : `code ${code ?? 'null'}`;\n rejectPromise(\n new Error(\n `${command} ${args.join(' ')} failed with ${exitStatus}: ${stderr}`,\n ),\n );\n });\n });\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function runCommand(command: string, args: string[]): Promise<void>;
|
|
2
|
-
//# sourceMappingURL=command.d.
|
|
2
|
+
//# sourceMappingURL=command.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.cts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.mts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-nodejs-modules */
|
|
2
|
-
import { spawn } from
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
3
|
export async function runCommand(command, args) {
|
|
4
4
|
await new Promise((resolvePromise, rejectPromise) => {
|
|
5
5
|
const child = spawn(command, args, {
|
|
@@ -21,4 +21,4 @@ export async function runCommand(command, args) {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=command.
|
|
24
|
+
//# sourceMappingURL=command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.mjs","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,KAAK,EAAE,2BAA2B;AAE3C,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAe,EACf,IAAc;IAEd,MAAM,IAAI,OAAO,CAAO,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE;QACxD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;YACjC,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC;SACpC,CAAC,CAAC;QACH,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACjC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YACjC,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,cAAc,EAAE,CAAC;gBACjB,OAAO;YACT,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1E,aAAa,CACX,IAAI,KAAK,CACP,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,UAAU,KAAK,MAAM,EAAE,CACpE,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules */\nimport { spawn } from 'node:child_process';\n\nexport async function runCommand(\n command: string,\n args: string[],\n): Promise<void> {\n await new Promise<void>((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n shell: false,\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n let stderr = '';\n\n child.stderr.on('data', (chunk) => {\n stderr += chunk.toString();\n });\n child.on('error', rejectPromise);\n child.on('close', (code, signal) => {\n if (code === 0) {\n resolvePromise();\n return;\n }\n\n const exitStatus = signal ? `signal ${signal}` : `code ${code ?? 'null'}`;\n rejectPromise(\n new Error(\n `${command} ${args.join(' ')} failed with ${exitStatus}: ${stderr}`,\n ),\n );\n });\n });\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openDownloadStream = exports.downloadFileFromUrl = void 0;
|
|
4
|
+
/* eslint-disable import-x/no-nodejs-modules */
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
const node_http_1 = require("node:http");
|
|
8
|
+
const node_https_1 = require("node:https");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const promises_2 = require("node:stream/promises");
|
|
11
|
+
async function downloadFileFromUrl(url, destination) {
|
|
12
|
+
await (0, promises_1.mkdir)((0, node_path_1.dirname)(destination), { recursive: true });
|
|
13
|
+
await (0, promises_2.pipeline)(await openDownloadStream(new URL(url)), (0, node_fs_1.createWriteStream)(destination));
|
|
14
|
+
}
|
|
15
|
+
exports.downloadFileFromUrl = downloadFileFromUrl;
|
|
16
|
+
async function openDownloadStream(url, redirectsRemaining = 5) {
|
|
17
|
+
const request = url.protocol === 'http:' ? node_http_1.request : node_https_1.request;
|
|
18
|
+
return await new Promise((resolvePromise, rejectPromise) => {
|
|
19
|
+
const req = request(url, (response) => {
|
|
20
|
+
const { headers, statusCode, statusMessage } = response;
|
|
21
|
+
if (statusCode &&
|
|
22
|
+
statusCode >= 300 &&
|
|
23
|
+
statusCode < 400 &&
|
|
24
|
+
headers.location) {
|
|
25
|
+
response.resume();
|
|
26
|
+
if (redirectsRemaining <= 0) {
|
|
27
|
+
rejectPromise(new Error(`Too many redirects downloading ${url}`));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
openDownloadStream(new URL(headers.location, url), redirectsRemaining - 1)
|
|
31
|
+
.then(resolvePromise)
|
|
32
|
+
.catch(rejectPromise);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!statusCode || statusCode < 200 || statusCode >= 300) {
|
|
36
|
+
response.resume();
|
|
37
|
+
rejectPromise(new Error(`Request to ${url} failed with ${statusCode ?? 'unknown'} ${statusMessage ?? ''}`.trim()));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
resolvePromise(response);
|
|
41
|
+
});
|
|
42
|
+
req.on('error', rejectPromise);
|
|
43
|
+
req.end();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.openDownloadStream = openDownloadStream;
|
|
47
|
+
//# sourceMappingURL=download.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.cjs","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAC/C,qCAA4C;AAC5C,+CAAyC;AACzC,yCAAmD;AACnD,2CAAqD;AACrD,yCAAoC;AACpC,mDAAgD;AAEzC,KAAK,UAAU,mBAAmB,CACvC,GAAW,EACX,WAAmB;IAEnB,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,IAAA,mBAAQ,EACZ,MAAM,kBAAkB,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,EACtC,IAAA,2BAAiB,EAAC,WAAW,CAAC,CAC/B,CAAC;AACJ,CAAC;AATD,kDASC;AAEM,KAAK,UAAU,kBAAkB,CACtC,GAAQ,EACR,kBAAkB,GAAG,CAAC;IAEtB,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAW,CAAC,CAAC,CAAC,oBAAY,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;AAjDD,gDAiDC","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"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function downloadFileFromUrl(url: string, destination: string): Promise<void>;
|
|
2
2
|
export declare function openDownloadStream(url: URL, redirectsRemaining?: number): Promise<NodeJS.ReadableStream>;
|
|
3
|
-
//# sourceMappingURL=download.d.
|
|
3
|
+
//# 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 @@
|
|
|
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"}
|