@metamask-previews/foundryup 0.0.0-preview-c1fef6e5 → 1.0.0-preview-d2bf8ff
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 +17 -1
- package/README.md +0 -4
- package/dist/cli.cjs +16 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +16 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/download.cjs +11 -3
- package/dist/download.cjs.map +1 -1
- package/dist/download.d.cts +8 -0
- package/dist/download.d.cts.map +1 -1
- package/dist/download.d.mts +8 -0
- package/dist/download.d.mts.map +1 -1
- package/dist/download.mjs +11 -3
- package/dist/download.mjs.map +1 -1
- package/dist/extract.cjs +20 -2
- package/dist/extract.cjs.map +1 -1
- package/dist/extract.d.cts +10 -1
- package/dist/extract.d.cts.map +1 -1
- package/dist/extract.d.mts +10 -1
- package/dist/extract.d.mts.map +1 -1
- package/dist/extract.mjs +21 -3
- package/dist/extract.mjs.map +1 -1
- package/dist/index.cjs +48 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +46 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +51 -9
- package/dist/index.mjs.map +1 -1
- package/dist/options.cjs +24 -2
- package/dist/options.cjs.map +1 -1
- package/dist/options.d.cts +9 -0
- package/dist/options.d.cts.map +1 -1
- package/dist/options.d.mts +9 -0
- package/dist/options.d.mts.map +1 -1
- package/dist/options.mjs +24 -2
- package/dist/options.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +4 -2
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +4 -2
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.cjs +9 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +10 -4
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +10 -4
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +10 -4
- package/dist/utils.mjs.map +1 -1
- package/package.json +15 -9
package/dist/options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB;AAC5C,OAAO,KAAK,oBAAoB;
|
|
1
|
+
{"version":3,"file":"options.mjs","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB;AAC5C,OAAO,KAAK,oBAAoB;AAEhC,OAAO,EAML,YAAY,EACZ,MAAM,EACN,QAAQ,EACT,oBAAgB;AACjB,OAAO,EAAE,2BAA2B,EAAE,oBAAgB;AAEtD;;;;;GAKG;AACH,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;CAgBb,CAAC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,OAAiB,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE;QAClC,+DAA+D;SAC9D,MAAM,EAAE;QACT,yDAAyD;SACxD,OAAO,CAAC,KAAK,CAAC;QACf,wCAAwC;SACvC,UAAU,CAAC,gBAAgB,CAAC;QAC7B,iEAAiE;SAChE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,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ACpC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAmB;SACnD;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { platform } from 'node:os';\nimport { argv, stdout } from 'node:process';\nimport yargs from 'yargs/yargs';\n\nimport {\n type Checksums,\n type ParsedOptions,\n type ArchitecturesTuple,\n type BinariesTuple,\n type PlatformsTuple,\n Architecture,\n Binary,\n Platform,\n} from './types';\nimport { normalizeSystemArchitecture } from './utils';\n\n/**\n * Type guard to check if a string is a valid version string starting with 'v'.\n *\n * @param value - The string to check\n * @returns True if the string is a valid version string\n */\nfunction isVersionString(value: string): value is `v${string}` {\n return /^v\\d/u.test(value);\n}\n\n/**\n * Prints the Foundry banner to the console.\n */\nexport function printBanner() {\n console.log(`\n.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx\n\n ╔═╗ ╔═╗ ╦ ╦ ╔╗╔ ╔╦╗ ╦═╗ ╦ ╦ Portable and modular toolkit\n ╠╣ ║ ║ ║ ║ ║║║ ║║ ╠╦╝ ╚╦╝ for Ethereum Application Development\n ╚ ╚═╝ ╚═╝ ╝╚╝ ═╩╝ ╩╚═ ╩ written in Rust.\n\n.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx\n\nRepo : https://github.com/foundry-rs/\nBook : https://book.getfoundry.sh/\nChat : https://t.me/foundry_rs/\nSupport : https://t.me/foundry_support/\nContribute : https://github.com/orgs/foundry-rs/projects/2/\n\n.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx.xOx\n`);\n}\n\n/**\n * Parses command line arguments and returns the parsed options.\n *\n * @param args - Command line arguments to parse\n * @returns Parsed command line arguments\n */\nexport function parseArgs(args: string[] = argv.slice(2)) {\n const { $0, _, ...parsed } = yargs()\n // Ensure unrecognized commands/options are reported as errors.\n .strict()\n // disable yargs's version, as it doesn't make sense here\n .version(false)\n // use the scriptName in `--help` output\n .scriptName('yarn foundryup')\n // wrap output at a maximum of 120 characters or `stdout.columns`\n .wrap(Math.min(120, stdout.columns))\n .parserConfiguration({\n 'strip-aliased': true,\n 'strip-dashed': true,\n })\n // enable ENV parsing, which allows the user to specify foundryup options\n // via environment variables prefixed with `FOUNDRYUP_`\n .env('FOUNDRYUP')\n .command(['$0', 'install'], 'Install foundry binaries', (builder) => {\n builder.options(getOptions()).pkgConf('foundryup');\n })\n .command('cache', '', (builder) => {\n builder.command('clean', 'Remove the shared cache files').demandCommand();\n })\n .parseSync(args);\n\n const command = _.join(' ');\n if (command === 'cache clean') {\n return {\n command,\n } as const;\n }\n\n // if we get here `command` is always 'install' or '' (yargs checks it)\n return {\n command: 'install',\n options: parsed as ParsedOptions<ReturnType<typeof getOptions>>,\n } as const;\n}\n\nconst Binaries = Object.values(Binary) as BinariesTuple;\n\n/**\n * Returns the command line options configuration.\n *\n * @param defaultPlatform - Default platform to use\n * @param defaultArch - Default architecture to use\n * @returns Command line options configuration\n */\nfunction getOptions(\n defaultPlatform = platform(),\n defaultArch = normalizeSystemArchitecture(),\n) {\n return {\n binaries: {\n alias: 'b',\n type: 'array' as const,\n multiple: true,\n description: 'Specify the binaries to install',\n default: Binaries,\n choices: Binaries,\n coerce: (values: Binary[]): Binary[] => [...new Set(values)], // Remove duplicates\n },\n checksums: {\n alias: 'c',\n description: 'JSON object containing checksums for the binaries.',\n coerce: (rawChecksums: string | Checksums): Checksums => {\n try {\n return typeof rawChecksums === 'string'\n ? JSON.parse(rawChecksums)\n : rawChecksums;\n } catch {\n throw new Error('Invalid checksums');\n }\n },\n optional: true,\n },\n repo: {\n alias: 'r',\n description: 'Specify the repository',\n default: 'foundry-rs/foundry',\n },\n version: {\n alias: 'v',\n description:\n 'Specify the version (see: https://github.com/foundry-rs/foundry/tags)',\n default: 'nightly',\n coerce: (\n rawVersion: string,\n ): { version: 'nightly' | `v${string}`; tag: string } => {\n if (rawVersion.startsWith('nightly')) {\n return { version: 'nightly', tag: rawVersion };\n // we don't validate the version much, we just trust the user\n } else if (isVersionString(rawVersion)) {\n return { version: rawVersion, tag: rawVersion };\n }\n throw new Error('Invalid version');\n },\n },\n arch: {\n alias: 'a',\n description: 'Specify the architecture',\n // if `defaultArch` is not a supported Architecture yargs will throw an error\n default: defaultArch as Architecture,\n choices: Object.values(Architecture) as ArchitecturesTuple,\n },\n platform: {\n alias: 'p',\n description: 'Specify the platform',\n // if `defaultPlatform` is not a supported Platform yargs will throw an error\n default: defaultPlatform as Platform,\n choices: Object.values(Platform) as PlatformsTuple,\n },\n };\n}\n"]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuBA,mBAAmB;AAEnB,gBAAgB;AAEhB,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,2BAAc,CAAA;AAChB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAED,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,2BAAe,CAAA;IACf,0BAAc,CAAA;AAChB,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,yBAAe,CAAA;IACf,yBAAe,CAAA;IACf,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACnB,CAAC,EALW,MAAM,sBAAN,MAAM,QAKjB;AAsDD,qBAAqB","sourcesContent":["import type { Agent as HttpAgent } from 'node:http';\nimport type { Agent as HttpsAgent } from 'node:https';\nimport type { InferredOptionTypes, Options } from 'yargs';\n\n// #region utils\n\ntype UnionToIntersection<U> = ((k: U) => void) extends (k: infer I) => void\n ? I\n : never;\n\ntype LastInUnion<U extends PropertyKey> =\n UnionToIntersection<\n U extends PropertyKey ? () => U : never\n > extends () => infer Last\n ? Last\n : never;\n\ntype UnionToTuple<U extends PropertyKey, Last = LastInUnion<U>> = [U] extends [\n never,\n]\n ? []\n : [...UnionToTuple<Exclude<U, Last>>, Last];\n\n// #endregion utils\n\n// #region enums\n\nexport enum Architecture {\n Amd64 = 'amd64',\n Arm64 = 'arm64',\n}\n\nexport enum Extension {\n Zip = 'zip',\n Tar = 'tar.gz',\n}\n\nexport enum Platform {\n Windows = 'win32',\n Linux = 'linux',\n Mac = 'darwin',\n}\n\nexport enum Binary {\n Anvil = 'anvil',\n Forge = 'forge',\n Cast = 'cast',\n Chisel = 'chisel',\n}\n\n// #endregion enums\n\n// #region helpers\n\n/**\n * Tuple representing all members of the {@link Binary} enum.\n */\nexport type BinariesTuple = UnionToTuple<Binary>;\n\n/**\n * Tuple representing all members of the {@link Architecture} enum.\n */\nexport type ArchitecturesTuple = UnionToTuple<Architecture>;\n\n/**\n * Tuple representing all members of the {@link Platform} enum.\n */\nexport type PlatformsTuple = UnionToTuple<Platform>;\n\n/**\n * Checksum types expected by the CLI.\n */\nexport type Checksums = {\n algorithm: string;\n binaries: Record<Binary, Record<`${Platform}-${Architecture}`, string>>;\n};\n\n/**\n * Checksum type expected by application code, specific to the selected\n * {@link Platform} and {@link Architecture}.\n *\n * See also: {@link Checksums}.\n */\nexport type PlatformArchChecksums = {\n algorithm: string;\n binaries: Record<Binary, string>;\n};\n\n/**\n * Given a map of raw yargs options config, returns a map of inferred types.\n */\nexport type ParsedOptions<O extends { [key: string]: Options }> = {\n [key in keyof O]: InferredOptionTypes<O>[key];\n};\n\nexport type DownloadOptions = {\n method?: 'GET' | 'HEAD';\n headers?: Record<string, string>;\n agent?: HttpsAgent | HttpAgent;\n maxRedirects?: number;\n};\n\n// #endregion helpers\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { Agent as HttpsAgent } from "node:https";
|
|
4
3
|
import type { Agent as HttpAgent } from "node:http";
|
|
4
|
+
import type { Agent as HttpsAgent } from "node:https";
|
|
5
5
|
import type { InferredOptionTypes, Options } from "yargs";
|
|
6
6
|
type UnionToIntersection<U> = ((k: U) => void) extends (k: infer I) => void ? I : never;
|
|
7
7
|
type LastInUnion<U extends PropertyKey> = UnionToIntersection<U extends PropertyKey ? () => U : never> extends () => infer Last ? Last : never;
|
|
@@ -48,7 +48,9 @@ export type Checksums = {
|
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* Checksum type expected by application code, specific to the selected
|
|
51
|
-
* {@link Platform} and {@link Architecture}.
|
|
51
|
+
* {@link Platform} and {@link Architecture}.
|
|
52
|
+
*
|
|
53
|
+
* See also: {@link Checksums}.
|
|
52
54
|
*/
|
|
53
55
|
export type PlatformArchChecksums = {
|
|
54
56
|
algorithm: string;
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,kBAAkB;AACpD,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,mBAAmB;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,cAAc;AAI1D,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,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AM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,IAAI;KAC/D,GAAG,IAAI,MAAM,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { Agent as HttpsAgent } from "node:https";
|
|
4
3
|
import type { Agent as HttpAgent } from "node:http";
|
|
4
|
+
import type { Agent as HttpsAgent } from "node:https";
|
|
5
5
|
import type { InferredOptionTypes, Options } from "yargs";
|
|
6
6
|
type UnionToIntersection<U> = ((k: U) => void) extends (k: infer I) => void ? I : never;
|
|
7
7
|
type LastInUnion<U extends PropertyKey> = UnionToIntersection<U extends PropertyKey ? () => U : never> extends () => infer Last ? Last : never;
|
|
@@ -48,7 +48,9 @@ export type Checksums = {
|
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
50
|
* Checksum type expected by application code, specific to the selected
|
|
51
|
-
* {@link Platform} and {@link Architecture}.
|
|
51
|
+
* {@link Platform} and {@link Architecture}.
|
|
52
|
+
*
|
|
53
|
+
* See also: {@link Checksums}.
|
|
52
54
|
*/
|
|
53
55
|
export type PlatformArchChecksums = {
|
|
54
56
|
algorithm: string;
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,kBAAkB;AACpD,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,mBAAmB;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,cAAc;AAI1D,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,IAAI,GACvE,CAAC,GACD,KAAK,CAAC;AAEV,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IACpC,mBAAmB,CACjB,CAAC,SAAS,WAAW,GAAG,MAAM,CAAC,GAAG,KAAK,CACxC,SAAS,MAAM,MAAM,IAAI,GACtB,IAAI,GACJ,KAAK,CAAC;AAEZ,KAAK,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;IAC5E,KAAK;CACN,GACG,EAAE,GACF,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAM9C,oBAAY,YAAY;IACtB,KAAK,UAAU;IACf,KAAK,UAAU;CAChB;AAED,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,GAAG,WAAW;CACf;AAED,oBAAY,QAAQ;IAClB,OAAO,UAAU;IACjB,KAAK,UAAU;IACf,GAAG,WAAW;CACf;AAED,oBAAY,MAAM;IAChB,KAAK,UAAU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mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA,mBAAmB;AAEnB,gBAAgB;AAEhB,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,+BAAe,CAAA;AACjB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,2BAAc,CAAA;AAChB,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,2BAAe,CAAA;IACf,0BAAc,CAAA;AAChB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAED,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,yBAAe,CAAA;IACf,yBAAe,CAAA;IACf,uBAAa,CAAA;IACb,2BAAiB,CAAA;AACnB,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AAsDD,qBAAqB","sourcesContent":["import type { Agent as HttpAgent } from 'node:http';\nimport type { Agent as HttpsAgent } from 'node:https';\nimport type { InferredOptionTypes, Options } from 'yargs';\n\n// #region utils\n\ntype UnionToIntersection<U> = ((k: U) => void) extends (k: infer I) => void\n ? I\n : never;\n\ntype LastInUnion<U extends PropertyKey> =\n UnionToIntersection<\n U extends PropertyKey ? () => U : never\n > extends () => infer Last\n ? Last\n : never;\n\ntype UnionToTuple<U extends PropertyKey, Last = LastInUnion<U>> = [U] extends [\n never,\n]\n ? []\n : [...UnionToTuple<Exclude<U, Last>>, Last];\n\n// #endregion utils\n\n// #region enums\n\nexport enum Architecture {\n Amd64 = 'amd64',\n Arm64 = 'arm64',\n}\n\nexport enum Extension {\n Zip = 'zip',\n Tar = 'tar.gz',\n}\n\nexport enum Platform {\n Windows = 'win32',\n Linux = 'linux',\n Mac = 'darwin',\n}\n\nexport enum Binary {\n Anvil = 'anvil',\n Forge = 'forge',\n Cast = 'cast',\n Chisel = 'chisel',\n}\n\n// #endregion enums\n\n// #region helpers\n\n/**\n * Tuple representing all members of the {@link Binary} enum.\n */\nexport type BinariesTuple = UnionToTuple<Binary>;\n\n/**\n * Tuple representing all members of the {@link Architecture} enum.\n */\nexport type ArchitecturesTuple = UnionToTuple<Architecture>;\n\n/**\n * Tuple representing all members of the {@link Platform} enum.\n */\nexport type PlatformsTuple = UnionToTuple<Platform>;\n\n/**\n * Checksum types expected by the CLI.\n */\nexport type Checksums = {\n algorithm: string;\n binaries: Record<Binary, Record<`${Platform}-${Architecture}`, string>>;\n};\n\n/**\n * Checksum type expected by application code, specific to the selected\n * {@link Platform} and {@link Architecture}.\n *\n * See also: {@link Checksums}.\n */\nexport type PlatformArchChecksums = {\n algorithm: string;\n binaries: Record<Binary, string>;\n};\n\n/**\n * Given a map of raw yargs options config, returns a map of inferred types.\n */\nexport type ParsedOptions<O extends { [key: string]: Options }> = {\n [key in keyof O]: InferredOptionTypes<O>[key];\n};\n\nexport type DownloadOptions = {\n method?: 'GET' | 'HEAD';\n headers?: Record<string, string>;\n agent?: HttpsAgent | HttpAgent;\n maxRedirects?: number;\n};\n\n// #endregion helpers\n"]}
|
package/dist/utils.cjs
CHANGED
|
@@ -16,7 +16,7 @@ exports.noop = noop;
|
|
|
16
16
|
* {@link Architecture} values.
|
|
17
17
|
*
|
|
18
18
|
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns The normalized architecture value
|
|
20
20
|
*/
|
|
21
21
|
function normalizeSystemArchitecture(architecture = (0, node_os_1.arch)()) {
|
|
22
22
|
if (architecture.startsWith('arm')) {
|
|
@@ -53,7 +53,7 @@ exports.say = say;
|
|
|
53
53
|
/**
|
|
54
54
|
* Get the version of the binary at the given path.
|
|
55
55
|
*
|
|
56
|
-
* @param binPath
|
|
56
|
+
* @param binPath - Path to the binary executable
|
|
57
57
|
* @returns The `--version` reported by the binary
|
|
58
58
|
* @throws If the binary fails to report its version
|
|
59
59
|
*/
|
|
@@ -74,6 +74,12 @@ support your system. If you believe this is an error, please report it.`;
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
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
|
+
*/
|
|
77
83
|
function isCodedError(error) {
|
|
78
84
|
return (error instanceof Error && 'code' in error && typeof error.code === 'string');
|
|
79
85
|
}
|
|
@@ -85,7 +91,7 @@ exports.isCodedError = isCodedError;
|
|
|
85
91
|
* @param checksums - The CLI checksum object
|
|
86
92
|
* @param targetPlatform - The build platform
|
|
87
93
|
* @param targetArch - The build architecture
|
|
88
|
-
* @returns
|
|
94
|
+
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
89
95
|
*/
|
|
90
96
|
function transformChecksums(checksums, targetPlatform, targetArch) {
|
|
91
97
|
if (!checksums) {
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,2DAA4D;AAC5D,qCAA+B;
|
|
1
|
+
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,2DAA4D;AAC5D,qCAA+B;AAE/B,uCAMiB;AAEjB;;;;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;QAClC,yBAAyB;QACzB,OAAO,oBAAY,CAAC,KAAK,CAAC;KAC3B;SAAM,IAAI,YAAY,KAAK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;AACH,SAAgB,kBAAkB,CAChC,SAAgC,EAChC,cAAwB,EACxB,UAAwB;IAExB,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;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;AApBD,gDAoBC","sourcesContent":["import { execFileSync, execSync } from 'node:child_process';\nimport { arch } from 'node:os';\n\nimport {\n type Checksums,\n type PlatformArchChecksums,\n Architecture,\n type Binary,\n type Platform,\n} from './types';\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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { type Checksums, type PlatformArchChecksums, Architecture, Platform } from "./types.cjs";
|
|
2
|
+
import { type Checksums, type PlatformArchChecksums, Architecture, type Platform } from "./types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* No Operation. A function that does nothing and returns nothing.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@ export declare const noop: () => undefined;
|
|
|
11
11
|
* {@link Architecture} values.
|
|
12
12
|
*
|
|
13
13
|
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns The normalized architecture value
|
|
15
15
|
*/
|
|
16
16
|
export declare function normalizeSystemArchitecture(architecture?: string): Architecture;
|
|
17
17
|
/**
|
|
@@ -23,11 +23,17 @@ export declare function say(message: string): void;
|
|
|
23
23
|
/**
|
|
24
24
|
* Get the version of the binary at the given path.
|
|
25
25
|
*
|
|
26
|
-
* @param binPath
|
|
26
|
+
* @param binPath - Path to the binary executable
|
|
27
27
|
* @returns The `--version` reported by the binary
|
|
28
28
|
* @throws If the binary fails to report its version
|
|
29
29
|
*/
|
|
30
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
|
+
*/
|
|
31
37
|
export declare function isCodedError(error: unknown): error is Error & {
|
|
32
38
|
code: string;
|
|
33
39
|
};
|
|
@@ -38,7 +44,7 @@ export declare function isCodedError(error: unknown): error is Error & {
|
|
|
38
44
|
* @param checksums - The CLI checksum object
|
|
39
45
|
* @param targetPlatform - The build platform
|
|
40
46
|
* @param targetArch - The build architecture
|
|
41
|
-
* @returns
|
|
47
|
+
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
42
48
|
*/
|
|
43
49
|
export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
|
|
44
50
|
//# sourceMappingURL=utils.d.cts.map
|
package/dist/utils.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,YAAY,EAEZ,KAAK,QAAQ,EACd,oBAAgB;AAEjB;;;;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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { type Checksums, type PlatformArchChecksums, Architecture, Platform } from "./types.mjs";
|
|
2
|
+
import { type Checksums, type PlatformArchChecksums, Architecture, type Platform } from "./types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* No Operation. A function that does nothing and returns nothing.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@ export declare const noop: () => undefined;
|
|
|
11
11
|
* {@link Architecture} values.
|
|
12
12
|
*
|
|
13
13
|
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns The normalized architecture value
|
|
15
15
|
*/
|
|
16
16
|
export declare function normalizeSystemArchitecture(architecture?: string): Architecture;
|
|
17
17
|
/**
|
|
@@ -23,11 +23,17 @@ export declare function say(message: string): void;
|
|
|
23
23
|
/**
|
|
24
24
|
* Get the version of the binary at the given path.
|
|
25
25
|
*
|
|
26
|
-
* @param binPath
|
|
26
|
+
* @param binPath - Path to the binary executable
|
|
27
27
|
* @returns The `--version` reported by the binary
|
|
28
28
|
* @throws If the binary fails to report its version
|
|
29
29
|
*/
|
|
30
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
|
+
*/
|
|
31
37
|
export declare function isCodedError(error: unknown): error is Error & {
|
|
32
38
|
code: string;
|
|
33
39
|
};
|
|
@@ -38,7 +44,7 @@ export declare function isCodedError(error: unknown): error is Error & {
|
|
|
38
44
|
* @param checksums - The CLI checksum object
|
|
39
45
|
* @param targetPlatform - The build platform
|
|
40
46
|
* @param targetArch - The build architecture
|
|
41
|
-
* @returns
|
|
47
|
+
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
42
48
|
*/
|
|
43
49
|
export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
|
|
44
50
|
//# sourceMappingURL=utils.d.mts.map
|
package/dist/utils.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,YAAY,EAEZ,KAAK,QAAQ,EACd,oBAAgB;AAEjB;;;;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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFileSync, execSync } from "node:child_process";
|
|
2
2
|
import { arch } from "node:os";
|
|
3
|
-
import { Architecture
|
|
3
|
+
import { Architecture } from "./types.mjs";
|
|
4
4
|
/**
|
|
5
5
|
* No Operation. A function that does nothing and returns nothing.
|
|
6
6
|
*
|
|
@@ -12,7 +12,7 @@ export const noop = () => undefined;
|
|
|
12
12
|
* {@link Architecture} values.
|
|
13
13
|
*
|
|
14
14
|
* @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns The normalized architecture value
|
|
16
16
|
*/
|
|
17
17
|
export function normalizeSystemArchitecture(architecture = arch()) {
|
|
18
18
|
if (architecture.startsWith('arm')) {
|
|
@@ -47,7 +47,7 @@ export function say(message) {
|
|
|
47
47
|
/**
|
|
48
48
|
* Get the version of the binary at the given path.
|
|
49
49
|
*
|
|
50
|
-
* @param binPath
|
|
50
|
+
* @param binPath - Path to the binary executable
|
|
51
51
|
* @returns The `--version` reported by the binary
|
|
52
52
|
* @throws If the binary fails to report its version
|
|
53
53
|
*/
|
|
@@ -67,6 +67,12 @@ support your system. If you believe this is an error, please report it.`;
|
|
|
67
67
|
throw new AggregateError([new Error(msg), error]);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Type guard to check if an error has a code property.
|
|
72
|
+
*
|
|
73
|
+
* @param error - The error to check
|
|
74
|
+
* @returns True if the error has a code property
|
|
75
|
+
*/
|
|
70
76
|
export function isCodedError(error) {
|
|
71
77
|
return (error instanceof Error && 'code' in error && typeof error.code === 'string');
|
|
72
78
|
}
|
|
@@ -77,7 +83,7 @@ export function isCodedError(error) {
|
|
|
77
83
|
* @param checksums - The CLI checksum object
|
|
78
84
|
* @param targetPlatform - The build platform
|
|
79
85
|
* @param targetArch - The build architecture
|
|
80
|
-
* @returns
|
|
86
|
+
* @returns Platform and architecture specific checksums or null if no checksums provided
|
|
81
87
|
*/
|
|
82
88
|
export function transformChecksums(checksums, targetPlatform, targetArch) {
|
|
83
89
|
if (!checksums) {
|
package/dist/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,EAGL,YAAY,EAGb,oBAAgB;AAEjB;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,eAAuB,IAAI,EAAE;IAE7B,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAA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,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAgC,EAChC,cAAwB,EACxB,UAAwB;IAExB,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;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 {\n type Checksums,\n type PlatformArchChecksums,\n Architecture,\n type Binary,\n type Platform,\n} from './types';\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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/foundryup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-preview-d2bf8ff",
|
|
4
4
|
"description": "foundryup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -27,14 +27,16 @@
|
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
29
|
"anvil": "node_modules/.bin/anvil",
|
|
30
|
-
"build": "
|
|
30
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
31
31
|
"build:docs": "typedoc",
|
|
32
|
+
"changelog:update": "../../scripts/update-changelog.sh @metamask/foundryup",
|
|
32
33
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/foundryup",
|
|
33
34
|
"publish:preview": "yarn npm publish --tag preview",
|
|
34
|
-
"test": "jest --reporters=jest-silent-reporter",
|
|
35
|
-
"test:clean": "jest --clearCache",
|
|
36
|
-
"test:verbose": "jest --verbose",
|
|
37
|
-
"test:watch": "jest --watch"
|
|
35
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
36
|
+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
37
|
+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
38
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
|
|
39
|
+
"since-latest-release": "../../scripts/since-latest-release.sh"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@metamask/auto-changelog": "^3.4.4",
|
|
@@ -44,10 +46,12 @@
|
|
|
44
46
|
"@types/yargs-parser": "^21.0.3",
|
|
45
47
|
"deepmerge": "^4.2.2",
|
|
46
48
|
"jest": "^27.5.1",
|
|
49
|
+
"nock": "^13.3.1",
|
|
47
50
|
"ts-jest": "^27.1.4",
|
|
48
51
|
"typedoc": "^0.24.8",
|
|
49
52
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
50
|
-
"typescript": "~5.2.2"
|
|
53
|
+
"typescript": "~5.2.2",
|
|
54
|
+
"yaml": "^2.3.4"
|
|
51
55
|
},
|
|
52
56
|
"engines": {
|
|
53
57
|
"node": "^18.18 || >=20"
|
|
@@ -60,7 +64,9 @@
|
|
|
60
64
|
"minipass": "^7.1.2",
|
|
61
65
|
"tar": "^7.4.3",
|
|
62
66
|
"unzipper": "^0.12.3",
|
|
63
|
-
"yargs": "17.7.2",
|
|
67
|
+
"yargs": "^17.7.2",
|
|
64
68
|
"yargs-parser": "^21.1.1"
|
|
65
|
-
}
|
|
69
|
+
},
|
|
70
|
+
"main": "./dist/index.cjs",
|
|
71
|
+
"types": "./dist/index.d.cts"
|
|
66
72
|
}
|