@metamask-previews/foundryup 0.0.0-preview-c1fef6e5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +20 -0
  3. package/README.md +47 -0
  4. package/dist/cli.cjs +10 -0
  5. package/dist/cli.cjs.map +1 -0
  6. package/dist/cli.d.cts +3 -0
  7. package/dist/cli.d.cts.map +1 -0
  8. package/dist/cli.d.mts +3 -0
  9. package/dist/cli.d.mts.map +1 -0
  10. package/dist/cli.mjs +8 -0
  11. package/dist/cli.mjs.map +1 -0
  12. package/dist/download.cjs +68 -0
  13. package/dist/download.cjs.map +1 -0
  14. package/dist/download.d.cts +18 -0
  15. package/dist/download.d.cts.map +1 -0
  16. package/dist/download.d.mts +18 -0
  17. package/dist/download.d.mts.map +1 -0
  18. package/dist/download.mjs +64 -0
  19. package/dist/download.mjs.map +1 -0
  20. package/dist/extract.cjs +184 -0
  21. package/dist/extract.cjs.map +1 -0
  22. package/dist/extract.d.cts +15 -0
  23. package/dist/extract.d.cts.map +1 -0
  24. package/dist/extract.d.mts +15 -0
  25. package/dist/extract.d.mts.map +1 -0
  26. package/dist/extract.mjs +180 -0
  27. package/dist/extract.mjs.map +1 -0
  28. package/dist/index.cjs +116 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +11 -0
  31. package/dist/index.d.cts.map +1 -0
  32. package/dist/index.d.mts +11 -0
  33. package/dist/index.d.mts.map +1 -0
  34. package/dist/index.mjs +109 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/options.cjs +135 -0
  37. package/dist/options.cjs.map +1 -0
  38. package/dist/options.d.cts +52 -0
  39. package/dist/options.d.cts.map +1 -0
  40. package/dist/options.d.mts +52 -0
  41. package/dist/options.d.mts.map +1 -0
  42. package/dist/options.mjs +127 -0
  43. package/dist/options.mjs.map +1 -0
  44. package/dist/types.cjs +30 -0
  45. package/dist/types.cjs.map +1 -0
  46. package/dist/types.d.cts +72 -0
  47. package/dist/types.d.cts.map +1 -0
  48. package/dist/types.d.mts +72 -0
  49. package/dist/types.d.mts.map +1 -0
  50. package/dist/types.mjs +27 -0
  51. package/dist/types.mjs.map +1 -0
  52. package/dist/utils.cjs +104 -0
  53. package/dist/utils.cjs.map +1 -0
  54. package/dist/utils.d.cts +44 -0
  55. package/dist/utils.d.cts.map +1 -0
  56. package/dist/utils.d.mts +44 -0
  57. package/dist/utils.d.mts.map +1 -0
  58. package/dist/utils.mjs +95 -0
  59. package/dist/utils.mjs.map +1 -0
  60. package/package.json +66 -0
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import { type Checksums, type PlatformArchChecksums, Architecture, Platform } from "./types.cjs";
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
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
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
+ export declare function isCodedError(error: unknown): error is Error & {
32
+ code: string;
33
+ };
34
+ /**
35
+ * Transforms the CLI checksum object into a platform+arch-specific checksum
36
+ * object.
37
+ *
38
+ * @param checksums - The CLI checksum object
39
+ * @param targetPlatform - The build platform
40
+ * @param targetArch - The build architecture
41
+ * @returns
42
+ */
43
+ export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
44
+ //# sourceMappingURL=utils.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,YAAY,EAEZ,QAAQ,EACT,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,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"}
@@ -0,0 +1,44 @@
1
+ /// <reference types="node" />
2
+ import { type Checksums, type PlatformArchChecksums, Architecture, 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
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
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
+ export declare function isCodedError(error: unknown): error is Error & {
32
+ code: string;
33
+ };
34
+ /**
35
+ * Transforms the CLI checksum object into a platform+arch-specific checksum
36
+ * object.
37
+ *
38
+ * @param checksums - The CLI checksum object
39
+ * @param targetPlatform - The build platform
40
+ * @param targetArch - The build architecture
41
+ * @returns
42
+ */
43
+ export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
44
+ //# sourceMappingURL=utils.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAEA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,YAAY,EAEZ,QAAQ,EACT,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,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 ADDED
@@ -0,0 +1,95 @@
1
+ import { execFileSync, execSync } from "node:child_process";
2
+ import { arch } from "node:os";
3
+ import { Architecture, Binary, Platform } from "./types.mjs";
4
+ /**
5
+ * No Operation. A function that does nothing and returns nothing.
6
+ *
7
+ * @returns `undefined`
8
+ */
9
+ export const noop = () => undefined;
10
+ /**
11
+ * Returns the system architecture, normalized to one of the supported
12
+ * {@link Architecture} values.
13
+ *
14
+ * @param architecture - The architecture string to normalize (e.g., 'x64', 'arm64')
15
+ * @returns
16
+ */
17
+ export function normalizeSystemArchitecture(architecture = arch()) {
18
+ if (architecture.startsWith('arm')) {
19
+ // if `arm*`, use `arm64`
20
+ return Architecture.Arm64;
21
+ }
22
+ else if (architecture === 'x64') {
23
+ // if `x64`, it _might_ be amd64 running via Rosetta on Apple Silicon
24
+ // (arm64). we can check this by running `sysctl.proc_translated` and
25
+ // checking the output; `1` === `arm64`. This can happen if the user is
26
+ // running an amd64 version of Node on Apple Silicon. We want to use the
27
+ // binaries native to the system for better performance.
28
+ try {
29
+ if (execSync('sysctl -n sysctl.proc_translated 2>/dev/null')[0] === 1) {
30
+ return Architecture.Arm64;
31
+ }
32
+ }
33
+ catch {
34
+ // Ignore error: if sysctl check fails, we assume native amd64
35
+ }
36
+ }
37
+ return Architecture.Amd64; // Default for all other architectures
38
+ }
39
+ /**
40
+ * Log a message to the console.
41
+ *
42
+ * @param message - The message to log
43
+ */
44
+ export function say(message) {
45
+ console.log(`[foundryup] ${message}`);
46
+ }
47
+ /**
48
+ * Get the version of the binary at the given path.
49
+ *
50
+ * @param binPath
51
+ * @returns The `--version` reported by the binary
52
+ * @throws If the binary fails to report its version
53
+ */
54
+ export function getVersion(binPath) {
55
+ try {
56
+ return execFileSync(binPath, ['--version']).subarray(0, -1); // ignore newline
57
+ }
58
+ catch (error) {
59
+ const msg = `Failed to get version for ${binPath}
60
+
61
+ Your selected platform or architecture may be incorrect, or the binary may not
62
+ support your system. If you believe this is an error, please report it.`;
63
+ if (error instanceof Error) {
64
+ error.message = `${msg}\n\n${error.message}`;
65
+ throw error;
66
+ }
67
+ throw new AggregateError([new Error(msg), error]);
68
+ }
69
+ }
70
+ export function isCodedError(error) {
71
+ return (error instanceof Error && 'code' in error && typeof error.code === 'string');
72
+ }
73
+ /**
74
+ * Transforms the CLI checksum object into a platform+arch-specific checksum
75
+ * object.
76
+ *
77
+ * @param checksums - The CLI checksum object
78
+ * @param targetPlatform - The build platform
79
+ * @param targetArch - The build architecture
80
+ * @returns
81
+ */
82
+ export function transformChecksums(checksums, targetPlatform, targetArch) {
83
+ if (!checksums) {
84
+ return null;
85
+ }
86
+ const key = `${targetPlatform}-${targetArch}`;
87
+ return {
88
+ algorithm: checksums.algorithm,
89
+ binaries: Object.entries(checksums.binaries).reduce((acc, [name, record]) => {
90
+ acc[name] = record[key];
91
+ return acc;
92
+ }, {}),
93
+ };
94
+ }
95
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +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;AAC/B,OAAO,EAGL,YAAY,EACZ,MAAM,EACN,QAAQ,EACT,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,EAAE;QAClC,yBAAyB;QACzB,OAAO,YAAY,CAAC,KAAK,CAAC;KAC3B;SAAM,IAAI,YAAY,KAAK,KAAK,EAAE;QACjC,qEAAqE;QACrE,qEAAqE;QACrE,uEAAuE;QACvE,wEAAwE;QACxE,wDAAwD;QACxD,IAAI;YACF,IAAI,QAAQ,CAAC,8CAA8C,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBACrE,OAAO,YAAY,CAAC,KAAK,CAAC;aAC3B;SACF;QAAC,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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';\nimport {\n type Checksums,\n type PlatformArchChecksums,\n Architecture,\n Binary,\n 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\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\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\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\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 ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@metamask-previews/foundryup",
3
+ "version": "0.0.0-preview-c1fef6e5",
4
+ "description": "foundryup",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/foundryup#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ "./package.json": "./package.json"
21
+ },
22
+ "bin": {
23
+ "mm-foundryup": "./dist/cli.mjs"
24
+ },
25
+ "files": [
26
+ "dist/"
27
+ ],
28
+ "scripts": {
29
+ "anvil": "node_modules/.bin/anvil",
30
+ "build": "npx ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
31
+ "build:docs": "typedoc",
32
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/foundryup",
33
+ "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"
38
+ },
39
+ "devDependencies": {
40
+ "@metamask/auto-changelog": "^3.4.4",
41
+ "@types/jest": "^27.4.1",
42
+ "@types/unzipper": "^0.10.10",
43
+ "@types/yargs": "^17.0.32",
44
+ "@types/yargs-parser": "^21.0.3",
45
+ "deepmerge": "^4.2.2",
46
+ "jest": "^27.5.1",
47
+ "ts-jest": "^27.1.4",
48
+ "typedoc": "^0.24.8",
49
+ "typedoc-plugin-missing-exports": "^2.0.0",
50
+ "typescript": "~5.2.2"
51
+ },
52
+ "engines": {
53
+ "node": "^18.18 || >=20"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "registry": "https://registry.npmjs.org/"
58
+ },
59
+ "dependencies": {
60
+ "minipass": "^7.1.2",
61
+ "tar": "^7.4.3",
62
+ "unzipper": "^0.12.3",
63
+ "yargs": "17.7.2",
64
+ "yargs-parser": "^21.1.1"
65
+ }
66
+ }