@metamask-previews/foundryup 1.0.1-preview-8bfa290fb → 2.0.0-preview-0a30e47
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 +12 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/{cli.mjs → cli.js} +2 -2
- package/dist/cli.js.map +1 -0
- package/dist/{download.d.cts → download.d.ts} +4 -9
- package/dist/download.d.ts.map +1 -0
- package/dist/{download.mjs → download.js} +5 -5
- package/dist/download.js.map +1 -0
- package/dist/{extract.d.cts → extract.d.ts} +2 -2
- package/dist/extract.d.ts.map +1 -0
- package/dist/{extract.mjs → extract.js} +15 -15
- package/dist/extract.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +4 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.mjs → index.js} +12 -12
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +71 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/{options.mjs → options.js} +6 -6
- package/dist/options.js.map +1 -0
- package/dist/{types.d.mts → types.d.ts} +4 -10
- package/dist/types.d.ts.map +1 -0
- package/dist/{types.mjs → types.js} +1 -1
- package/dist/types.js.map +1 -0
- package/dist/{utils.d.cts → utils.d.ts} +3 -3
- package/dist/utils.d.ts.map +1 -0
- package/dist/{utils.mjs → utils.js} +4 -4
- package/dist/utils.js.map +1 -0
- package/package.json +11 -9
- package/dist/cli.cjs +0 -23
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -3
- package/dist/cli.d.cts.map +0 -1
- package/dist/cli.d.mts +0 -3
- package/dist/cli.d.mts.map +0 -1
- package/dist/cli.mjs.map +0 -1
- package/dist/download.cjs +0 -76
- package/dist/download.cjs.map +0 -1
- package/dist/download.d.cts.map +0 -1
- package/dist/download.d.mts +0 -30
- package/dist/download.d.mts.map +0 -1
- package/dist/download.mjs.map +0 -1
- package/dist/extract.cjs +0 -205
- package/dist/extract.cjs.map +0 -1
- package/dist/extract.d.cts.map +0 -1
- package/dist/extract.d.mts +0 -24
- package/dist/extract.d.mts.map +0 -1
- package/dist/extract.mjs.map +0 -1
- package/dist/index.cjs +0 -163
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -56
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/options.cjs +0 -157
- package/dist/options.cjs.map +0 -1
- package/dist/options.d.cts +0 -62
- package/dist/options.d.cts.map +0 -1
- package/dist/options.d.mts +0 -62
- package/dist/options.d.mts.map +0 -1
- package/dist/options.mjs.map +0 -1
- package/dist/types.cjs +0 -30
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.cts +0 -78
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.mjs.map +0 -1
- package/dist/utils.cjs +0 -110
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts.map +0 -1
- package/dist/utils.d.mts +0 -50
- package/dist/utils.d.mts.map +0 -1
- package/dist/utils.mjs.map +0 -1
package/dist/utils.cjs
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformChecksums = exports.isCodedError = exports.getVersion = exports.say = exports.normalizeSystemArchitecture = exports.noop = void 0;
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
const node_os_1 = require("node:os");
|
|
6
|
-
const types_js_1 = require("./types.cjs");
|
|
7
|
-
/**
|
|
8
|
-
* No Operation. A function that does nothing and returns nothing.
|
|
9
|
-
*
|
|
10
|
-
* @returns `undefined`
|
|
11
|
-
*/
|
|
12
|
-
const noop = () => undefined;
|
|
13
|
-
exports.noop = noop;
|
|
14
|
-
/**
|
|
15
|
-
* Returns the system architecture, normalized to one of the supported
|
|
16
|
-
* {@link Architecture} values.
|
|
17
|
-
*
|
|
18
|
-
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
19
|
-
* @returns The normalized architecture value
|
|
20
|
-
*/
|
|
21
|
-
function normalizeSystemArchitecture(architecture = (0, node_os_1.arch)()) {
|
|
22
|
-
if (architecture.startsWith('arm')) {
|
|
23
|
-
// if `arm*`, use `arm64`
|
|
24
|
-
return types_js_1.Architecture.Arm64;
|
|
25
|
-
}
|
|
26
|
-
else if (architecture === 'x64') {
|
|
27
|
-
// if `x64`, it _might_ be amd64 running via Rosetta on Apple Silicon
|
|
28
|
-
// (arm64). we can check this by running `sysctl.proc_translated` and
|
|
29
|
-
// checking the output; `1` === `arm64`. This can happen if the user is
|
|
30
|
-
// running an amd64 version of Node on Apple Silicon. We want to use the
|
|
31
|
-
// binaries native to the system for better performance.
|
|
32
|
-
try {
|
|
33
|
-
if ((0, node_child_process_1.execSync)('sysctl -n sysctl.proc_translated 2>/dev/null')[0] === 1) {
|
|
34
|
-
return types_js_1.Architecture.Arm64;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
// Ignore error: if sysctl check fails, we assume native amd64
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return types_js_1.Architecture.Amd64; // Default for all other architectures
|
|
42
|
-
}
|
|
43
|
-
exports.normalizeSystemArchitecture = normalizeSystemArchitecture;
|
|
44
|
-
/**
|
|
45
|
-
* Log a message to the console.
|
|
46
|
-
*
|
|
47
|
-
* @param message - The message to log
|
|
48
|
-
*/
|
|
49
|
-
function say(message) {
|
|
50
|
-
console.log(`[foundryup] ${message}`);
|
|
51
|
-
}
|
|
52
|
-
exports.say = say;
|
|
53
|
-
/**
|
|
54
|
-
* Get the version of the binary at the given path.
|
|
55
|
-
*
|
|
56
|
-
* @param binPath - Path to the binary executable
|
|
57
|
-
* @returns The `--version` reported by the binary
|
|
58
|
-
* @throws If the binary fails to report its version
|
|
59
|
-
*/
|
|
60
|
-
function getVersion(binPath) {
|
|
61
|
-
try {
|
|
62
|
-
return (0, node_child_process_1.execFileSync)(binPath, ['--version']).subarray(0, -1); // ignore newline
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
const msg = `Failed to get version for ${binPath}
|
|
66
|
-
|
|
67
|
-
Your selected platform or architecture may be incorrect, or the binary may not
|
|
68
|
-
support your system. If you believe this is an error, please report it.`;
|
|
69
|
-
if (error instanceof Error) {
|
|
70
|
-
error.message = `${msg}\n\n${error.message}`;
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
throw new AggregateError([new Error(msg), error]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.getVersion = getVersion;
|
|
77
|
-
/**
|
|
78
|
-
* Type guard to check if an error has a code property.
|
|
79
|
-
*
|
|
80
|
-
* @param error - The error to check
|
|
81
|
-
* @returns True if the error has a code property
|
|
82
|
-
*/
|
|
83
|
-
function isCodedError(error) {
|
|
84
|
-
return (error instanceof Error && 'code' in error && typeof error.code === 'string');
|
|
85
|
-
}
|
|
86
|
-
exports.isCodedError = isCodedError;
|
|
87
|
-
/**
|
|
88
|
-
* Transforms the CLI checksum object into a platform+arch-specific checksum
|
|
89
|
-
* object.
|
|
90
|
-
*
|
|
91
|
-
* @param checksums - The CLI checksum object
|
|
92
|
-
* @param targetPlatform - The build platform
|
|
93
|
-
* @param targetArch - The build architecture
|
|
94
|
-
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
95
|
-
*/
|
|
96
|
-
function transformChecksums(checksums, targetPlatform, targetArch) {
|
|
97
|
-
if (!checksums) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
const key = `${targetPlatform}-${targetArch}`;
|
|
101
|
-
return {
|
|
102
|
-
algorithm: checksums.algorithm,
|
|
103
|
-
binaries: Object.entries(checksums.binaries).reduce((acc, [name, record]) => {
|
|
104
|
-
acc[name] = record[key];
|
|
105
|
-
return acc;
|
|
106
|
-
}, {}),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
exports.transformChecksums = transformChecksums;
|
|
110
|
-
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,2DAA4D;AAC5D,qCAA+B;AAE/B,0CAA0C;AAQ1C;;;;GAIG;AACI,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAAvB,QAAA,IAAI,QAAmB;AAEpC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,eAAuB,IAAA,cAAI,GAAE;IAE7B,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,yBAAyB;QACzB,OAAO,uBAAY,CAAC,KAAK,CAAC;IAC5B,CAAC;SAAM,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;QAClC,qEAAqE;QACrE,qEAAqE;QACrE,uEAAuE;QACvE,wEAAwE;QACxE,wDAAwD;QACxD,IAAI,CAAC;YACH,IAAI,IAAA,6BAAQ,EAAC,8CAA8C,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtE,OAAO,uBAAY,CAAC,KAAK,CAAC;YAC5B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8DAA8D;QAChE,CAAC;IACH,CAAC;IAED,OAAO,uBAAY,CAAC,KAAK,CAAC,CAAC,sCAAsC;AACnE,CAAC;AAtBD,kEAsBC;AAED;;;;GAIG;AACH,SAAgB,GAAG,CAAC,OAAe;IACjC,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC;AAFD,kBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,OAAO,IAAA,iCAAY,EAAC,OAAO,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,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n\nimport { Architecture } from './types.js';\nimport type {\n Checksums,\n PlatformArchChecksums,\n Binary,\n Platform,\n} from './types.js';\n\n/**\n * No Operation. A function that does nothing and returns nothing.\n *\n * @returns `undefined`\n */\nexport const noop = () => undefined;\n\n/**\n * Returns the system architecture, normalized to one of the supported\n * {@link Architecture} values.\n *\n * @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')\n * @returns The normalized architecture value\n */\nexport function normalizeSystemArchitecture(\n architecture: string = arch(),\n): Architecture {\n if (architecture.startsWith('arm')) {\n // if `arm*`, use `arm64`\n return Architecture.Arm64;\n } else if (architecture === 'x64') {\n // if `x64`, it _might_ be amd64 running via Rosetta on Apple Silicon\n // (arm64). we can check this by running `sysctl.proc_translated` and\n // checking the output; `1` === `arm64`. This can happen if the user is\n // running an amd64 version of Node on Apple Silicon. We want to use the\n // binaries native to the system for better performance.\n try {\n if (execSync('sysctl -n sysctl.proc_translated 2>/dev/null')[0] === 1) {\n return Architecture.Arm64;\n }\n } catch {\n // Ignore error: if sysctl check fails, we assume native amd64\n }\n }\n\n return Architecture.Amd64; // Default for all other architectures\n}\n\n/**\n * Log a message to the console.\n *\n * @param message - The message to log\n */\nexport function say(message: string) {\n console.log(`[foundryup] ${message}`);\n}\n\n/**\n * Get the version of the binary at the given path.\n *\n * @param binPath - Path to the binary executable\n * @returns The `--version` reported by the binary\n * @throws If the binary fails to report its version\n */\nexport function getVersion(binPath: string): Buffer {\n try {\n return execFileSync(binPath, ['--version']).subarray(0, -1); // ignore newline\n } catch (error: unknown) {\n const msg = `Failed to get version for ${binPath}\n\nYour selected platform or architecture may be incorrect, or the binary may not\nsupport your system. If you believe this is an error, please report it.`;\n if (error instanceof Error) {\n error.message = `${msg}\\n\\n${error.message}`;\n throw error;\n }\n throw new AggregateError([new Error(msg), error]);\n }\n}\n\n/**\n * Type guard to check if an error has a code property.\n *\n * @param error - The error to check\n * @returns True if the error has a code property\n */\nexport function isCodedError(\n error: unknown,\n): error is Error & { code: string } {\n return (\n error instanceof Error && 'code' in error && typeof error.code === 'string'\n );\n}\n\n/**\n * Transforms the CLI checksum object into a platform+arch-specific checksum\n * object.\n *\n * @param checksums - The CLI checksum object\n * @param targetPlatform - The build platform\n * @param targetArch - The build architecture\n * @returns Platform and architecture specific checksums or null if no checksums provided\n */\nexport function transformChecksums(\n checksums: Checksums | undefined,\n targetPlatform: Platform,\n targetArch: Architecture,\n): PlatformArchChecksums | null {\n if (!checksums) {\n return null;\n }\n\n const key = `${targetPlatform}-${targetArch}` as const;\n return {\n algorithm: checksums.algorithm,\n binaries: Object.entries(checksums.binaries).reduce(\n (acc, [name, record]) => {\n acc[name as Binary] = record[key];\n return acc;\n },\n {} as Record<Binary, string>,\n ),\n };\n}\n"]}
|
package/dist/utils.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,oBAAmB;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EAErB,QAAQ,EACT,oBAAmB;AAEpB;;;;GAIG;AACH,eAAO,MAAM,IAAI,iBAAkB,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,GAAE,MAAe,GAC5B,YAAY,CAoBd;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,QAElC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAclD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAInC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,cAAc,EAAE,QAAQ,EACxB,UAAU,EAAE,YAAY,GACvB,qBAAqB,GAAG,IAAI,CAgB9B"}
|
package/dist/utils.d.mts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Architecture } from "./types.mjs";
|
|
2
|
-
import type { Checksums, PlatformArchChecksums, Platform } from "./types.mjs";
|
|
3
|
-
/**
|
|
4
|
-
* No Operation. A function that does nothing and returns nothing.
|
|
5
|
-
*
|
|
6
|
-
* @returns `undefined`
|
|
7
|
-
*/
|
|
8
|
-
export declare const noop: () => undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the system architecture, normalized to one of the supported
|
|
11
|
-
* {@link Architecture} values.
|
|
12
|
-
*
|
|
13
|
-
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
14
|
-
* @returns The normalized architecture value
|
|
15
|
-
*/
|
|
16
|
-
export declare function normalizeSystemArchitecture(architecture?: string): Architecture;
|
|
17
|
-
/**
|
|
18
|
-
* Log a message to the console.
|
|
19
|
-
*
|
|
20
|
-
* @param message - The message to log
|
|
21
|
-
*/
|
|
22
|
-
export declare function say(message: string): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get the version of the binary at the given path.
|
|
25
|
-
*
|
|
26
|
-
* @param binPath - Path to the binary executable
|
|
27
|
-
* @returns The `--version` reported by the binary
|
|
28
|
-
* @throws If the binary fails to report its version
|
|
29
|
-
*/
|
|
30
|
-
export declare function getVersion(binPath: string): Buffer;
|
|
31
|
-
/**
|
|
32
|
-
* Type guard to check if an error has a code property.
|
|
33
|
-
*
|
|
34
|
-
* @param error - The error to check
|
|
35
|
-
* @returns True if the error has a code property
|
|
36
|
-
*/
|
|
37
|
-
export declare function isCodedError(error: unknown): error is Error & {
|
|
38
|
-
code: string;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Transforms the CLI checksum object into a platform+arch-specific checksum
|
|
42
|
-
* object.
|
|
43
|
-
*
|
|
44
|
-
* @param checksums - The CLI checksum object
|
|
45
|
-
* @param targetPlatform - The build platform
|
|
46
|
-
* @param targetArch - The build architecture
|
|
47
|
-
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
48
|
-
*/
|
|
49
|
-
export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
|
|
50
|
-
//# sourceMappingURL=utils.d.mts.map
|
package/dist/utils.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,oBAAmB;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EAErB,QAAQ,EACT,oBAAmB;AAEpB;;;;GAIG;AACH,eAAO,MAAM,IAAI,iBAAkB,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,GAAE,MAAe,GAC5B,YAAY,CAoBd;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,QAElC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAclD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAInC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,cAAc,EAAE,QAAQ,EACxB,UAAU,EAAE,YAAY,GACvB,qBAAqB,GAAG,IAAI,CAgB9B"}
|
package/dist/utils.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,2BAA2B;AAC5D,OAAO,EAAE,IAAI,EAAE,gBAAgB;AAE/B,OAAO,EAAE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7C,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,IAAI,cAAc,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAc;IAEd,OAAO,CACL,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAgC,EAChC,cAAwB,EACxB,UAAwB;IAExB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,cAAc,IAAI,UAAU,EAAW,CAAC;IACvD,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CACjD,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;YACtB,GAAG,CAAC,IAAc,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAA4B,CAC7B;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { execFileSync, execSync } from 'node:child_process';\nimport { arch } from 'node:os';\n\nimport { Architecture } from './types.js';\nimport type {\n Checksums,\n PlatformArchChecksums,\n Binary,\n Platform,\n} from './types.js';\n\n/**\n * No Operation. A function that does nothing and returns nothing.\n *\n * @returns `undefined`\n */\nexport const noop = () => undefined;\n\n/**\n * Returns the system architecture, normalized to one of the supported\n * {@link Architecture} values.\n *\n * @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')\n * @returns The normalized architecture value\n */\nexport function normalizeSystemArchitecture(\n architecture: string = arch(),\n): Architecture {\n if (architecture.startsWith('arm')) {\n // if `arm*`, use `arm64`\n return Architecture.Arm64;\n } else if (architecture === 'x64') {\n // if `x64`, it _might_ be amd64 running via Rosetta on Apple Silicon\n // (arm64). we can check this by running `sysctl.proc_translated` and\n // checking the output; `1` === `arm64`. This can happen if the user is\n // running an amd64 version of Node on Apple Silicon. We want to use the\n // binaries native to the system for better performance.\n try {\n if (execSync('sysctl -n sysctl.proc_translated 2>/dev/null')[0] === 1) {\n return Architecture.Arm64;\n }\n } catch {\n // Ignore error: if sysctl check fails, we assume native amd64\n }\n }\n\n return Architecture.Amd64; // Default for all other architectures\n}\n\n/**\n * Log a message to the console.\n *\n * @param message - The message to log\n */\nexport function say(message: string) {\n console.log(`[foundryup] ${message}`);\n}\n\n/**\n * Get the version of the binary at the given path.\n *\n * @param binPath - Path to the binary executable\n * @returns The `--version` reported by the binary\n * @throws If the binary fails to report its version\n */\nexport function getVersion(binPath: string): Buffer {\n try {\n return execFileSync(binPath, ['--version']).subarray(0, -1); // ignore newline\n } catch (error: unknown) {\n const msg = `Failed to get version for ${binPath}\n\nYour selected platform or architecture may be incorrect, or the binary may not\nsupport your system. If you believe this is an error, please report it.`;\n if (error instanceof Error) {\n error.message = `${msg}\\n\\n${error.message}`;\n throw error;\n }\n throw new AggregateError([new Error(msg), error]);\n }\n}\n\n/**\n * Type guard to check if an error has a code property.\n *\n * @param error - The error to check\n * @returns True if the error has a code property\n */\nexport function isCodedError(\n error: unknown,\n): error is Error & { code: string } {\n return (\n error instanceof Error && 'code' in error && typeof error.code === 'string'\n );\n}\n\n/**\n * Transforms the CLI checksum object into a platform+arch-specific checksum\n * object.\n *\n * @param checksums - The CLI checksum object\n * @param targetPlatform - The build platform\n * @param targetArch - The build architecture\n * @returns Platform and architecture specific checksums or null if no checksums provided\n */\nexport function transformChecksums(\n checksums: Checksums | undefined,\n targetPlatform: Platform,\n targetArch: Architecture,\n): PlatformArchChecksums | null {\n if (!checksums) {\n return null;\n }\n\n const key = `${targetPlatform}-${targetArch}` as const;\n return {\n algorithm: checksums.algorithm,\n binaries: Object.entries(checksums.binaries).reduce(\n (acc, [name, record]) => {\n acc[name as Binary] = record[key];\n return acc;\n },\n {} as Record<Binary, string>,\n ),\n };\n}\n"]}
|