@metamask-previews/foundryup 1.0.1-preview-b13d916 → 1.0.1-preview-4f4c98e

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 (74) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/{cli.mjs → cli.js} +2 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/{download.d.cts → download.d.ts} +4 -9
  7. package/dist/download.d.ts.map +1 -0
  8. package/dist/{download.mjs → download.js} +5 -5
  9. package/dist/download.js.map +1 -0
  10. package/dist/{extract.d.cts → extract.d.ts} +2 -2
  11. package/dist/extract.d.ts.map +1 -0
  12. package/dist/{extract.mjs → extract.js} +15 -15
  13. package/dist/extract.js.map +1 -0
  14. package/dist/{index.d.cts → index.d.ts} +4 -7
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/{index.mjs → index.js} +12 -12
  17. package/dist/index.js.map +1 -0
  18. package/dist/options.d.ts +71 -0
  19. package/dist/options.d.ts.map +1 -0
  20. package/dist/{options.mjs → options.js} +6 -6
  21. package/dist/options.js.map +1 -0
  22. package/dist/{types.d.mts → types.d.ts} +4 -10
  23. package/dist/types.d.ts.map +1 -0
  24. package/dist/{types.mjs → types.js} +1 -1
  25. package/dist/types.js.map +1 -0
  26. package/dist/{utils.d.cts → utils.d.ts} +3 -3
  27. package/dist/utils.d.ts.map +1 -0
  28. package/dist/{utils.mjs → utils.js} +4 -4
  29. package/dist/utils.js.map +1 -0
  30. package/package.json +11 -9
  31. package/dist/cli.cjs +0 -23
  32. package/dist/cli.cjs.map +0 -1
  33. package/dist/cli.d.cts +0 -3
  34. package/dist/cli.d.cts.map +0 -1
  35. package/dist/cli.d.mts +0 -3
  36. package/dist/cli.d.mts.map +0 -1
  37. package/dist/cli.mjs.map +0 -1
  38. package/dist/download.cjs +0 -76
  39. package/dist/download.cjs.map +0 -1
  40. package/dist/download.d.cts.map +0 -1
  41. package/dist/download.d.mts +0 -30
  42. package/dist/download.d.mts.map +0 -1
  43. package/dist/download.mjs.map +0 -1
  44. package/dist/extract.cjs +0 -205
  45. package/dist/extract.cjs.map +0 -1
  46. package/dist/extract.d.cts.map +0 -1
  47. package/dist/extract.d.mts +0 -24
  48. package/dist/extract.d.mts.map +0 -1
  49. package/dist/extract.mjs.map +0 -1
  50. package/dist/index.cjs +0 -163
  51. package/dist/index.cjs.map +0 -1
  52. package/dist/index.d.cts.map +0 -1
  53. package/dist/index.d.mts +0 -56
  54. package/dist/index.d.mts.map +0 -1
  55. package/dist/index.mjs.map +0 -1
  56. package/dist/options.cjs +0 -157
  57. package/dist/options.cjs.map +0 -1
  58. package/dist/options.d.cts +0 -62
  59. package/dist/options.d.cts.map +0 -1
  60. package/dist/options.d.mts +0 -62
  61. package/dist/options.d.mts.map +0 -1
  62. package/dist/options.mjs.map +0 -1
  63. package/dist/types.cjs +0 -30
  64. package/dist/types.cjs.map +0 -1
  65. package/dist/types.d.cts +0 -78
  66. package/dist/types.d.cts.map +0 -1
  67. package/dist/types.d.mts.map +0 -1
  68. package/dist/types.mjs.map +0 -1
  69. package/dist/utils.cjs +0 -110
  70. package/dist/utils.cjs.map +0 -1
  71. package/dist/utils.d.cts.map +0 -1
  72. package/dist/utils.d.mts +0 -50
  73. package/dist/utils.d.mts.map +0 -1
  74. package/dist/utils.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ 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
+
10
14
  ## [1.0.1]
11
15
 
12
16
  ### Fixed
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
@@ -5,7 +5,7 @@
5
5
  * This script downloads and installs Foundry binaries.
6
6
  * If an error occurs, it logs the error and exits with code 1.
7
7
  */
8
- import { downloadAndInstallFoundryBinaries } from "./index.mjs";
8
+ import { downloadAndInstallFoundryBinaries } from './index.js';
9
9
  /**
10
10
  * Run the main installation process and handle errors.
11
11
  */
@@ -18,4 +18,4 @@ downloadAndInstallFoundryBinaries().catch((error) => {
18
18
  console.error('Error:', error);
19
19
  process.exit(1);
20
20
  });
21
- //# sourceMappingURL=cli.mjs.map
21
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AACH,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAE/D;;GAEG;AACH,iCAAiC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAClD;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point for Foundryup.\n *\n * This script downloads and installs Foundry binaries.\n * If an error occurs, it logs the error and exits with code 1.\n */\nimport { downloadAndInstallFoundryBinaries } from './index.js';\n\n/**\n * Run the main installation process and handle errors.\n */\ndownloadAndInstallFoundryBinaries().catch((error) => {\n /**\n * Log any error that occurs during installation and exit with code 1.\n *\n * @param error - The error thrown during installation.\n */\n console.error('Error:', error);\n process.exit(1);\n});\n"]}
@@ -1,11 +1,6 @@
1
- /// <reference types="node" />
2
- /// <reference types="node/http.js" />
3
- /// <reference types="npm-which/node_modules/@types/node/http.js" />
4
- /// <reference types="node/stream.js" />
5
- /// <reference types="npm-which/node_modules/@types/node/stream.js" />
6
- import type { IncomingMessage } from "node:http";
7
- import { Stream } from "node:stream";
8
- import type { DownloadOptions } from "./types.cjs";
1
+ import type { IncomingMessage } from 'node:http';
2
+ import { Stream } from 'node:stream';
3
+ import type { DownloadOptions } from './types.js';
9
4
  /**
10
5
  * A PassThrough stream that emits a 'response' event when the HTTP(S) response is available.
11
6
  */
@@ -27,4 +22,4 @@ declare class DownloadStream extends Stream.PassThrough {
27
22
  */
28
23
  export declare function startDownload(url: URL, options?: DownloadOptions, redirects?: number): DownloadStream;
29
24
  export {};
30
- //# sourceMappingURL=download.d.cts.map
25
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,cAAM,cAAe,SAAQ,MAAM,CAAC,WAAW;IAC7C;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,eAAe,CAAC,CAKzC;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,eAAoB,EAC7B,SAAS,GAAE,MAAU,kBAsDtB"}
@@ -1,7 +1,7 @@
1
- import { request as httpRequest } from "node:http";
2
- import { request as httpsRequest } from "node:https";
3
- import { Stream } from "node:stream";
4
- import { pipeline } from "node:stream/promises";
1
+ import { request as httpRequest } from 'node:http';
2
+ import { request as httpsRequest } from 'node:https';
3
+ import { Stream } from 'node:stream';
4
+ import { pipeline } from 'node:stream/promises';
5
5
  /**
6
6
  * A PassThrough stream that emits a 'response' event when the HTTP(S) response is available.
7
7
  */
@@ -69,4 +69,4 @@ export function startDownload(url, options = {}, redirects = 0) {
69
69
  .end();
70
70
  return stream;
71
71
  }
72
- //# sourceMappingURL=download.mjs.map
72
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD;;GAEG;AACH,MAAM,cAAe,SAAQ,MAAM,CAAC,WAAW;IAC7C;;;;OAIG;IACH,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAQ,EACR,OAAO,GAAoB,EAAE,EAC7B,SAAS,GAAW,CAAC;IAErB,MAAM,aAAa,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;IACtE,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;QACjC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACxB,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;QAEH,MAAM,EAAE,UAA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AAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC,CAAC;SACC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SAChD,GAAG,EAAE,CAAC;IACT,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { request as httpRequest } from 'node:http';\nimport type { IncomingMessage } from 'node:http';\nimport { request as httpsRequest } from 'node:https';\nimport { Stream } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\n\nimport type { DownloadOptions } from './types.js';\n\n/**\n * A PassThrough stream that emits a 'response' event when the HTTP(S) response is available.\n */\nclass DownloadStream extends Stream.PassThrough {\n /**\n * Returns a promise that resolves with the HTTP(S) IncomingMessage response.\n *\n * @returns The HTTP(S) response stream.\n */\n async response(): Promise<IncomingMessage> {\n return new Promise((resolve, reject) => {\n this.once('response', resolve);\n this.once('error', reject);\n });\n }\n}\n\n/**\n * Starts a download from the given URL.\n *\n * @param url - The URL to download from\n * @param options - The download options\n * @param redirects - The number of redirects that have occurred\n * @returns A stream of the download\n */\nexport function startDownload(\n url: URL,\n options: DownloadOptions = {},\n redirects: number = 0,\n) {\n const MAX_REDIRECTS = options.maxRedirects ?? 5;\n const request = url.protocol === 'http:' ? httpRequest : httpsRequest;\n const stream = new DownloadStream();\n request(url, options, (response) => {\n stream.once('close', () => {\n response.destroy();\n });\n\n const { statusCode, statusMessage, headers } = response;\n // handle redirects\n if (\n statusCode &&\n statusCode >= 300 &&\n statusCode < 400 &&\n headers.location\n ) {\n if (redirects >= MAX_REDIRECTS) {\n stream.emit('error', new Error('Too many redirects'));\n response.destroy();\n } else {\n // note: we don't emit a response until we're done redirecting, because\n // handlers only expect it to be emitted once.\n pipeline(\n startDownload(new URL(headers.location, url), options, redirects + 1)\n // emit the response event to the stream\n .once('response', stream.emit.bind(stream, 'response')),\n stream,\n ).catch(stream.emit.bind(stream, 'error'));\n response.destroy();\n }\n }\n\n // check for HTTP errors\n else if (!statusCode || statusCode < 200 || statusCode >= 300) {\n stream.emit(\n 'error',\n new Error(\n `Request to ${url} failed. Status Code: ${statusCode} - ${statusMessage}`,\n ),\n );\n response.destroy();\n } else {\n // resolve with response stream\n stream.emit('response', response);\n\n response.once('error', stream.emit.bind(stream, 'error'));\n pipeline(response, stream).catch(stream.emit.bind(stream, 'error'));\n }\n })\n .once('error', stream.emit.bind(stream, 'error'))\n .end();\n return stream;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Binary } from "./types.cjs";
1
+ import type { Binary } from './types.js';
2
2
  /**
3
3
  * Extracts the binaries from the given URL and writes them to the destination.
4
4
  *
@@ -21,4 +21,4 @@ export declare function extractFrom(url: URL, binaries: Binary[], dir: string, c
21
21
  algorithm: string;
22
22
  binaries: Record<Binary, string>;
23
23
  } | null): Promise<string[]>;
24
- //# sourceMappingURL=extract.d.cts.map
24
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGzC;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,EAAE,EAClB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,qBAoE1E"}
@@ -1,17 +1,17 @@
1
- import { Minipass } from "minipass";
2
- import { ok } from "node:assert/strict";
3
- import { createHash } from "node:crypto";
4
- import { createWriteStream } from "node:fs";
5
- import { rename, mkdir, rm } from "node:fs/promises";
6
- import { Agent as HttpAgent } from "node:http";
7
- import { Agent as HttpsAgent } from "node:https";
8
- import { join, basename, extname, relative } from "node:path";
9
- import { pipeline } from "node:stream/promises";
10
- import { extract as extractTar } from "tar";
11
- import { Open } from "unzipper";
12
- import { startDownload } from "./download.mjs";
13
- import { Extension } from "./types.mjs";
14
- import { say } from "./utils.mjs";
1
+ import { Minipass } from 'minipass';
2
+ import { ok } from 'node:assert/strict';
3
+ import { createHash } from 'node:crypto';
4
+ import { createWriteStream } from 'node:fs';
5
+ import { rename, mkdir, rm } from 'node:fs/promises';
6
+ import { Agent as HttpAgent } from 'node:http';
7
+ import { Agent as HttpsAgent } from 'node:https';
8
+ import { join, basename, extname, relative } from 'node:path';
9
+ import { pipeline } from 'node:stream/promises';
10
+ import { extract as extractTar } from 'tar';
11
+ import { Open } from 'unzipper';
12
+ import { startDownload } from './download.js';
13
+ import { Extension } from './types.js';
14
+ import { say } from './utils.js';
15
15
  /**
16
16
  * Extracts the binaries from the given URL and writes them to the destination.
17
17
  *
@@ -198,4 +198,4 @@ async function extractFromZip(url, binaries, dir, checksumAlgorithm) {
198
198
  };
199
199
  }));
200
200
  }
201
- //# sourceMappingURL=extract.mjs.map
201
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,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AC7B,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClC,OAAO;YACL,IAAI,EAAE,IAAI;YACV,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { Minipass } from 'minipass';\nimport { ok } from 'node:assert/strict';\nimport { createHash } from 'node:crypto';\nimport { createWriteStream } from 'node:fs';\nimport { rename, mkdir, rm } from 'node:fs/promises';\nimport { Agent as HttpAgent } from 'node:http';\nimport { Agent as HttpsAgent } from 'node:https';\nimport { join, basename, extname, relative } from 'node:path';\nimport { pipeline } from 'node:stream/promises';\nimport { extract as extractTar } from 'tar';\nimport { Open } from 'unzipper';\nimport type { Source, Entry } from 'unzipper';\n\nimport { startDownload } from './download.js';\nimport { Extension } from './types.js';\nimport type { Binary } from './types.js';\nimport { say } from './utils.js';\n\n/**\n * Extracts the binaries from the given URL and writes them to the destination.\n *\n * @param url - The URL of the archive to extract the binaries from\n * @param binaries - The list of binaries to extract\n * @param dir - The destination directory\n * @param checksums - The checksums to verify the binaries against\n * @returns The list of binaries extracted\n */\n\n/**\n * Extracts the binaries from the given URL and writes them to the destination.\n *\n * @param url - The URL of the archive to extract the binaries from\n * @param binaries - The list of binaries to extract\n * @param dir - The destination directory\n * @param checksums - The checksums to verify the binaries against\n * @returns The list of binaries extracted\n */\nexport async function extractFrom(\n url: URL,\n binaries: Binary[],\n dir: string,\n checksums: { algorithm: string; binaries: Record<Binary, string> } | null,\n) {\n const extract = url.pathname.toLowerCase().endsWith(Extension.Tar)\n ? extractFromTar\n : extractFromZip;\n // write all files to a temporary directory first, then rename to the final\n // destination to avoid accidental partial extraction. We don't use\n // `os.tmpdir` for this because `rename` will fail if the directories are on\n // different file systems.\n const tempDir = `${dir}.downloading`;\n const rmOpts = { recursive: true, maxRetries: 3, force: true };\n try {\n // clean up any previous in-progress downloads\n await rm(tempDir, rmOpts);\n // make the temporary directory to extract the binaries to\n await mkdir(tempDir, { recursive: true });\n const downloads = await extract(\n url,\n binaries,\n tempDir,\n checksums?.algorithm,\n );\n ok(downloads.length === binaries.length, 'Failed to extract all binaries');\n\n const paths: string[] = [];\n for (const { path, binary, checksum } of downloads) {\n if (checksums) {\n say(`verifying checksum for ${binary}`);\n const expected = checksums.binaries[binary];\n if (checksum === expected) {\n say(`checksum verified for ${binary}`);\n } else {\n throw new Error(\n `checksum mismatch for ${binary}, expected ${expected}, got ${checksum}`,\n );\n }\n }\n // add the *final* path to the list of binaries\n paths.push(join(dir, relative(tempDir, path)));\n }\n\n // this directory shouldn't exist, but if two simultaneous `yarn foundryup`\n // processes are running, it might. Last process wins, so we remove other\n // `dir`s just in case.\n await rm(dir, rmOpts);\n // everything has been extracted; move the files to their final destination\n await rename(tempDir, dir);\n // return the list of extracted binaries\n return paths;\n } catch (error) {\n // if things fail for any reason try to clean up a bit. it is very important\n // to not leave `dir` behind, as its existence is a signal that the binaries\n // are installed.\n const rmErrors = (\n await Promise.allSettled([rm(tempDir, rmOpts), rm(dir, rmOpts)])\n )\n .filter((r) => r.status === 'rejected')\n .map((r) => r.reason);\n\n // if we failed to clean up, create an aggregate error message\n if (rmErrors.length) {\n throw new AggregateError(\n [error, ...rmErrors],\n 'This is a bug; you should report it.',\n );\n }\n throw error;\n }\n}\n/**\n * Extracts the binaries from a tar archive.\n *\n * @param url - The URL of the archive to extract the binaries from\n * @param binaries - The list of binaries to extract\n * @param dir - The destination directory\n * @param checksumAlgorithm - The checksum algorithm to use\n * @returns The list of binaries extracted\n */\n\n/**\n * Extracts the binaries from a tar archive.\n *\n * @param url - The URL of the archive to extract the binaries from\n * @param binaries - The list of binaries to extract\n * @param dir - The destination directory\n * @param checksumAlgorithm - The checksum algorithm to use\n * @returns The list of binaries extracted\n */\nasync function extractFromTar(\n url: URL,\n binaries: Binary[],\n dir: string,\n checksumAlgorithm?: string,\n) {\n const downloads: {\n path: string;\n binary: Binary;\n checksum?: string;\n }[] = [];\n await pipeline(\n startDownload(url),\n extractTar(\n {\n cwd: dir,\n // @ts-expect-error: Types here broke in `tar@7.5.12`, but it appears to\n // work fine as-is.\n // See: https://github.com/isaacs/node-tar/issues/459\n transform: (entry) => {\n const absolutePath = entry.absolute;\n if (!absolutePath) {\n throw new Error('Missing absolute path for entry');\n }\n\n if (checksumAlgorithm) {\n const hash = createHash(checksumAlgorithm);\n const passThrough = new Minipass({ async: true });\n passThrough.pipe(hash);\n passThrough.on('end', () => {\n downloads.push({\n path: absolutePath,\n binary: entry.path as Binary,\n checksum: hash.digest('hex'),\n });\n });\n return passThrough;\n }\n\n // When no checksum is needed, record the entry and return undefined\n // to use the original stream without transformation\n downloads.push({\n path: absolutePath,\n binary: entry.path as Binary,\n });\n return undefined;\n },\n },\n binaries,\n ),\n );\n return downloads;\n}\n/**\n * Extracts the binaries from a zip archive.\n *\n * @param url - The URL of the archive to extract the binaries from\n * @param binaries - The list of binaries to extract\n * @param dir - The destination directory\n * @param checksumAlgorithm - The checksum algorithm to use\n * @returns The list of binaries extracted\n */\nasync function extractFromZip(\n url: URL,\n binaries: Binary[],\n dir: string,\n checksumAlgorithm?: string,\n) {\n const agent = new (url.protocol === 'http:' ? HttpAgent : HttpsAgent)({\n keepAlive: true,\n });\n const source: Source = {\n async size() {\n const download = startDownload(url, { agent, method: 'HEAD' });\n const response = await download.response();\n const contentLength = response.headers['content-length'];\n return contentLength ? parseInt(contentLength, 10) : 0;\n },\n stream(offset: number, bytes: number) {\n const options = {\n agent,\n headers: {\n range: `bytes=${offset}-${bytes ? offset + bytes : ''}`,\n },\n };\n return startDownload(url, options);\n },\n };\n\n const { files } = await Open.custom(source, {});\n const filtered = files.filter(({ path }) =>\n binaries.includes(basename(path, extname(path)) as Binary),\n );\n return await Promise.all(\n filtered.map(async ({ path, stream }) => {\n const dest = join(dir, path);\n const entry = stream();\n const destStream = createWriteStream(dest);\n const binary = basename(path, extname(path)) as Binary;\n if (checksumAlgorithm) {\n const hash = createHash(checksumAlgorithm);\n const hashStream = async function* (entryStream: Entry) {\n for await (const chunk of entryStream) {\n hash.update(chunk);\n yield chunk;\n }\n };\n await pipeline(entry, hashStream, destStream);\n return {\n path: dest,\n binary,\n checksum: hash.digest('hex'),\n };\n }\n await pipeline(entry, destStream);\n return {\n path: dest,\n binary,\n };\n }),\n );\n}\n"]}
@@ -1,10 +1,7 @@
1
1
  #!/usr/bin/env -S node --require "./node_modules/tsx/dist/preflight.cjs" --import "./node_modules/tsx/dist/loader.mjs"
2
- /// <reference types="node" />
3
- /// <reference types="node/fs.js" />
4
- /// <reference types="npm-which/node_modules/@types/node/fs.js" />
5
- import type { Dir } from "node:fs";
6
- import type { Checksums, Architecture, Binary } from "./types.cjs";
7
- import { Platform } from "./types.cjs";
2
+ import type { Dir } from 'node:fs';
3
+ import type { Checksums, Architecture, Binary } from './types.js';
4
+ import { Platform } from './types.js';
8
5
  /**
9
6
  * Determines the cache directory based on the .yarnrc.yml configuration.
10
7
  * If global cache is enabled, returns a path in the user's home directory.
@@ -53,4 +50,4 @@ export declare function installBinaries(downloadedBinaries: Dir, BIN_DIR: string
53
50
  * @returns A promise that resolves when the operation is complete
54
51
  */
55
52
  export declare function downloadAndInstallFoundryBinaries(): Promise<void>;
56
- //# sourceMappingURL=index.d.cts.map
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAgBnC,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAa,QAAQ,EAAE,MAAM,YAAY,CAAC;AASjD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAoB1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,GACX,MAAM,CAGR;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,EAAE,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,YAAY,EAClB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,GAAG,CAAC,CAmBd;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,kBAAkB,EAAE,GAAG,EACvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;;;;;GAMG;AACH,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC,CAmDvE"}
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env -S node --require "./node_modules/tsx/dist/preflight.cjs" --import "./node_modules/tsx/dist/loader.mjs"
2
- import { createHash } from "node:crypto";
3
- import { readFileSync } from "node:fs";
4
- import { copyFile, mkdir, opendir, rm, symlink, unlink } from "node:fs/promises";
5
- import { homedir } from "node:os";
6
- import { dirname, join, relative } from "node:path";
7
- import { cwd, exit } from "node:process";
8
- import { parse as parseYaml } from "yaml";
9
- import { extractFrom } from "./extract.mjs";
10
- import { parseArgs, printBanner } from "./options.mjs";
11
- import { Extension, Platform } from "./types.mjs";
12
- import { getVersion, isCodedError, noop, say, transformChecksums } from "./utils.mjs";
2
+ import { createHash } from 'node:crypto';
3
+ import { readFileSync } from 'node:fs';
4
+ import { copyFile, mkdir, opendir, rm, symlink, unlink, } from 'node:fs/promises';
5
+ import { homedir } from 'node:os';
6
+ import { dirname, join, relative } from 'node:path';
7
+ import { cwd, exit } from 'node:process';
8
+ import { parse as parseYaml } from 'yaml';
9
+ import { extractFrom } from './extract.js';
10
+ import { parseArgs, printBanner } from './options.js';
11
+ import { Extension, Platform } from './types.js';
12
+ import { getVersion, isCodedError, noop, say, transformChecksums, } from './utils.js';
13
13
  /**
14
14
  * Determines the cache directory based on the .yarnrc.yml configuration.
15
15
  * If global cache is enabled, returns a path in the user's home directory.
@@ -152,4 +152,4 @@ export async function downloadAndInstallFoundryBinaries() {
152
152
  await installBinaries(downloadedBinaries, BIN_DIR, cachePath);
153
153
  say('done!');
154
154
  }
155
- //# sourceMappingURL=index.mjs.map
155
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,EAAE,EACF,OAAO,EACP,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,GAAG,EACH,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,YAA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AAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,GAAG,CAAC,YAAY,IAAI,IAAI,OAAO,QAAQ,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;IAE3D,MAAM,eAAe,GAAG,mBAAmB,CACzC,IAAI,EACJ,GAAG,EACH,OAAO,EACP,QAAQ,EACR,IAAI,CACL,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAEpD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;SAClC,MAAM,CAAC,GAAG,eAAe,IAAI,IAAI,EAAE,CAAC;SACpC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAE5C,MAAM,kBAAkB,GAAG,MAAM,wBAAwB,CACvD,GAAG,EACH,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,SAAS,CACV,CAAC;IAEF,MAAM,eAAe,CAAC,kBAAkB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAE9D,GAAG,CAAC,OAAO,CAAC,CAAC;AACf,CAAC","sourcesContent":["#!/usr/bin/env -S node --require \"./node_modules/tsx/dist/preflight.cjs\" --import \"./node_modules/tsx/dist/loader.mjs\"\n\nimport { createHash } from 'node:crypto';\nimport { readFileSync } from 'node:fs';\nimport type { Dir } from 'node:fs';\nimport {\n copyFile,\n mkdir,\n opendir,\n rm,\n symlink,\n unlink,\n} from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join, relative } from 'node:path';\nimport { cwd, exit } from 'node:process';\nimport { parse as parseYaml } from 'yaml';\n\nimport { extractFrom } from './extract.js';\nimport { parseArgs, printBanner } from './options.js';\nimport type { Checksums, Architecture, Binary } from './types.js';\nimport { Extension, Platform } from './types.js';\nimport {\n getVersion,\n isCodedError,\n noop,\n say,\n transformChecksums,\n} from './utils.js';\n\n/**\n * Determines the cache directory based on the .yarnrc.yml configuration.\n * If global cache is enabled, returns a path in the user's home directory.\n * Otherwise, returns a local cache path in the current working directory.\n *\n * @returns The path to the cache directory\n */\nexport function getCacheDirectory(): string {\n let enableGlobalCache = false;\n try {\n const configFileContent = readFileSync('.yarnrc.yml', 'utf8');\n const parsedConfig = parseYaml(configFileContent);\n enableGlobalCache = parsedConfig?.enableGlobalCache ?? false;\n } catch (error) {\n // If file doesn't exist or can't be read, default to local cache\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n return join(cwd(), '.metamask', 'cache');\n }\n // For other errors, log but continue with default\n console.warn(\n 'Warning: Error reading .yarnrc.yml, using local cache:',\n error,\n );\n }\n return enableGlobalCache\n ? join(homedir(), '.cache', 'metamask')\n : join(cwd(), '.metamask', 'cache');\n}\n\n/**\n * Generates the URL for downloading the Foundry binary archive.\n *\n * @param repo - The GitHub repository (e.g., 'foundry-rs/foundry')\n * @param tag - The release tag (e.g., 'v1.0.0')\n * @param version - The version string\n * @param platform - The target platform (e.g., Platform.Linux)\n * @param arch - The target architecture (e.g., 'amd64')\n * @returns The URL for the binary archive\n */\nexport function getBinaryArchiveUrl(\n repo: string,\n tag: string,\n version: string,\n platform: Platform,\n arch: string,\n): string {\n const ext = platform === Platform.Windows ? Extension.Zip : Extension.Tar;\n return `https://github.com/${repo}/releases/download/${tag}/foundry_${version}_${platform}_${arch}.${ext}`;\n}\n\n/**\n * Checks if binaries are already in the cache. If not, downloads and extracts them.\n *\n * @param url - The URL to download the binaries from\n * @param binaries - The list of binaries to download\n * @param cachePath - The path to the cache directory\n * @param platform - The target platform\n * @param arch - The target architecture\n * @param checksums - Optional checksums for verification\n * @returns A promise that resolves to the directory containing the downloaded binaries\n */\nexport async function checkAndDownloadBinaries(\n url: URL,\n binaries: Binary[],\n cachePath: string,\n platform: Platform,\n arch: Architecture,\n checksums?: Checksums,\n): Promise<Dir> {\n let downloadedBinaries: Dir;\n try {\n say(`checking cache`);\n downloadedBinaries = await opendir(cachePath);\n say(`found binaries in cache`);\n } catch (e: unknown) {\n say(`binaries not in cache`);\n if ((e as NodeJS.ErrnoException).code === 'ENOENT') {\n say(`installing from ${url.toString()}`);\n // directory doesn't exist, download and extract\n const platformChecksums = transformChecksums(checksums, platform, arch);\n await extractFrom(url, binaries, cachePath, platformChecksums);\n downloadedBinaries = await opendir(cachePath);\n } else {\n throw e;\n }\n }\n return downloadedBinaries;\n}\n\n/**\n * Installs the downloaded binaries by creating symlinks or copying files.\n *\n * @param downloadedBinaries - The directory containing the downloaded binaries\n * @param BIN_DIR - The target directory for installation\n * @param cachePath - The path to the cache directory\n * @returns A promise that resolves when installation is complete\n */\nexport async function installBinaries(\n downloadedBinaries: Dir,\n BIN_DIR: string,\n cachePath: string,\n): Promise<void> {\n for await (const file of downloadedBinaries) {\n if (!file.isFile()) {\n continue;\n }\n const target = join(file.parentPath, file.name);\n const path = join(BIN_DIR, relative(cachePath, target));\n\n // compute the relative path from where the symlink will be created\n // to the target file, so that it works even if the project is moved\n // (like in some CI environments)\n const relativeTarget = relative(dirname(path), target);\n\n // create the BIN_DIR paths if they don't exists already\n await mkdir(BIN_DIR, { recursive: true });\n\n // clean up any existing files or symlinks\n await unlink(path).catch(noop);\n try {\n // create new symlink\n await symlink(relativeTarget, path);\n } catch (e) {\n if (!(isCodedError(e) && ['EPERM', 'EXDEV'].includes(e.code))) {\n throw e;\n }\n // symlinking can fail if it's a cross-device/filesystem link, or for\n // permissions reasons, so we'll just copy the file instead\n await copyFile(target, path);\n }\n // check that it works by logging the version\n say(`installed - ${getVersion(path).toString()}`);\n }\n}\n\n/**\n * Downloads and installs Foundry binaries based on command-line arguments.\n * If the command is 'cache clean', it removes the cache directory.\n * Otherwise, it downloads and installs the specified binaries.\n *\n * @returns A promise that resolves when the operation is complete\n */\nexport async function downloadAndInstallFoundryBinaries(): Promise<void> {\n const parsedArgs = parseArgs();\n\n const CACHE_DIR = getCacheDirectory();\n\n if (parsedArgs.command === 'cache clean') {\n await rm(CACHE_DIR, { recursive: true, force: true });\n say('done!');\n exit(0);\n }\n\n const {\n repo,\n version: { version, tag },\n arch,\n platform,\n binaries,\n checksums,\n } = parsedArgs.options;\n\n printBanner();\n const bins = binaries.join(', ');\n say(`fetching ${bins} ${version} for ${platform} ${arch}`);\n\n const BIN_ARCHIVE_URL = getBinaryArchiveUrl(\n repo,\n tag,\n version,\n platform,\n arch,\n );\n const BIN_DIR = join(cwd(), 'node_modules', '.bin');\n\n const url = new URL(BIN_ARCHIVE_URL);\n const cacheKey = createHash('sha256')\n .update(`${BIN_ARCHIVE_URL}-${bins}`)\n .digest('hex');\n const cachePath = join(CACHE_DIR, cacheKey);\n\n const downloadedBinaries = await checkAndDownloadBinaries(\n url,\n binaries,\n cachePath,\n platform,\n arch,\n checksums,\n );\n\n await installBinaries(downloadedBinaries, BIN_DIR, cachePath);\n\n say('done!');\n}\n"]}
@@ -0,0 +1,71 @@
1
+ import { Architecture, Binary, Platform } from './types.js';
2
+ import type { Checksums, ParsedOptions, ArchitecturesTuple, PlatformsTuple } from './types.js';
3
+ /**
4
+ * Prints the Foundry banner to the console.
5
+ */
6
+ export declare function printBanner(): void;
7
+ /**
8
+ * Parses command line arguments and returns the parsed options.
9
+ *
10
+ * @param args - Command line arguments to parse
11
+ * @returns Parsed command line arguments
12
+ */
13
+ export declare function parseArgs(args?: string[]): {
14
+ readonly command: "cache clean";
15
+ readonly options?: undefined;
16
+ } | {
17
+ readonly command: 'install';
18
+ readonly options: ParsedOptions<ReturnType<typeof getOptions>>;
19
+ };
20
+ /**
21
+ * Returns the command line options configuration.
22
+ *
23
+ * @param defaultPlatform - Default platform to use
24
+ * @param defaultArch - Default architecture to use
25
+ * @returns Command line options configuration
26
+ */
27
+ declare function getOptions(defaultPlatform?: NodeJS.Platform, defaultArch?: Architecture): {
28
+ binaries: {
29
+ alias: string;
30
+ type: 'array';
31
+ multiple: boolean;
32
+ description: string;
33
+ default: [Binary];
34
+ choices: [Binary];
35
+ coerce: (values: Binary[]) => Binary[];
36
+ };
37
+ checksums: {
38
+ alias: string;
39
+ description: string;
40
+ coerce: (rawChecksums: string | Checksums) => Checksums;
41
+ optional: boolean;
42
+ };
43
+ repo: {
44
+ alias: string;
45
+ description: string;
46
+ default: string;
47
+ };
48
+ version: {
49
+ alias: string;
50
+ description: string;
51
+ default: string;
52
+ coerce: (rawVersion: string) => {
53
+ version: 'nightly' | `v${string}`;
54
+ tag: string;
55
+ };
56
+ };
57
+ arch: {
58
+ alias: string;
59
+ description: string;
60
+ default: Architecture;
61
+ choices: ArchitecturesTuple;
62
+ };
63
+ platform: {
64
+ alias: string;
65
+ description: string;
66
+ default: Platform;
67
+ choices: PlatformsTuple;
68
+ };
69
+ };
70
+ export {};
71
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,kBAAkB,EAElB,cAAc,EACf,MAAM,YAAY,CAAC;AAapB;;GAEG;AACH,wBAAgB,WAAW,SAkB1B;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAM,EAAkB;;;;sBAkC3C,SAAS;sBACC,aAAa,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;EAElE;AAID;;;;;;GAMG;AACH,iBAAS,UAAU,CACjB,eAAe,kBAAa,EAC5B,WAAW,eAAgC;IAGzC,QAAQ;QACN,KAAK;QACL,IAAI,EAAE,OAAO;QACb,QAAQ;QACR,WAAW;QACX,OAAO;QACP,OAAO;QACP,MAAM,WAAW,MAAM,EAAE,KAAG,MAAM,EAAE;;IAEtC,SAAS;QACP,KAAK;QACL,WAAW;QACX,MAAM,iBAAiB,MAAM,GAAG,SAAS,KAAG,SAAS;QASrD,QAAQ;;IAEV,IAAI;QACF,KAAK;QACL,WAAW;QACX,OAAO;;IAET,OAAO;QACL,KAAK;QACL,WAAW;QAEX,OAAO;QACP,MAAM,eACQ,MAAM,KACjB;YAAE,OAAO,EAAE,SAAS,GAAG,IAAI,MAAM,EAAE,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE;;IAUvD,IAAI;QACF,KAAK;QACL,WAAW;QAEX,OAAO;QACP,OAAO,EAAiC,kBAAkB;;IAE5D,QAAQ;QACN,KAAK;QACL,WAAW;QAEX,OAAO,EAAqB,QAAQ;QACpC,OAAO,EAA6B,cAAc;;EAGvD"}
@@ -1,8 +1,8 @@
1
- import { platform } from "node:os";
2
- import { argv, stdout } from "node:process";
3
- import yargs from "yargs/yargs";
4
- import { Architecture, Binary, Platform } from "./types.mjs";
5
- import { normalizeSystemArchitecture } from "./utils.mjs";
1
+ import { platform } from 'node:os';
2
+ import { argv, stdout } from 'node:process';
3
+ import yargs from 'yargs/yargs';
4
+ import { Architecture, Binary, Platform } from './types.js';
5
+ import { normalizeSystemArchitecture } from './utils.js';
6
6
  /**
7
7
  * Type guard to check if a string is a valid version string starting with 'v'.
8
8
  *
@@ -146,4 +146,4 @@ function getOptions(defaultPlatform = platform(), defaultArch = normalizeSystemA
146
146
  },
147
147
  };
148
148
  }
149
- //# sourceMappingURL=options.mjs.map
149
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;A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ACT,uEAAuE;YACzE,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,CACN,UAAkB,EACkC,EAAE;gBACtD,IAAI,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;oBACrC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;oBAC/C,6DAA6D;gBAC/D,CAAC;qBAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;oBACvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;gBAClD,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACrC,CAAC;SACF;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,0BAA0B;YACvC,6EAA6E;YAC7E,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAuB;SAC3D;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,sBAAsB;YACnC,6EAA6E;YAC7E,OAAO,EAAE,eAA2B;YACpC,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 { Architecture, Binary, Platform } from './types.js';\nimport type {\n Checksums,\n ParsedOptions,\n ArchitecturesTuple,\n BinariesTuple,\n PlatformsTuple,\n} from './types.js';\nimport { normalizeSystemArchitecture } from './utils.js';\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,\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"]}
@@ -1,12 +1,6 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node/http" />
4
- /// <reference types="npm-which/node_modules/@types/node/http" />
5
- /// <reference types="node/https" />
6
- /// <reference types="npm-which/node_modules/@types/node/https" />
7
- import type { Agent as HttpAgent } from "node:http";
8
- import type { Agent as HttpsAgent } from "node:https";
9
- import type { InferredOptionTypes, Options } from "yargs";
1
+ import type { Agent as HttpAgent } from 'node:http';
2
+ import type { Agent as HttpsAgent } from 'node:https';
3
+ import type { InferredOptionTypes, Options } from 'yargs';
10
4
  type UnionToIntersection<U> = ((k: U) => void) extends (k: infer I) => void ? I : never;
11
5
  type LastInUnion<U extends PropertyKey> = UnionToIntersection<U extends PropertyKey ? () => U : never> extends () => infer Last ? Last : never;
12
6
  type UnionToTuple<U extends PropertyKey, Last = LastInUnion<U>> = [U] extends [
@@ -75,4 +69,4 @@ export type DownloadOptions = {
75
69
  maxRedirects?: number;
76
70
  };
77
71
  export {};
78
- //# sourceMappingURL=types.d.mts.map
72
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,OAAO,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,CAA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G,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"}
@@ -24,4 +24,4 @@ export var Binary;
24
24
  Binary["Chisel"] = "chisel";
25
25
  })(Binary || (Binary = {}));
26
26
  // #endregion helpers
27
- //# sourceMappingURL=types.mjs.map
27
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","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"]}
@@ -1,5 +1,5 @@
1
- import { Architecture } from "./types.cjs";
2
- import type { Checksums, PlatformArchChecksums, Platform } from "./types.cjs";
1
+ import { Architecture } from './types.js';
2
+ import type { Checksums, PlatformArchChecksums, Platform } from './types.js';
3
3
  /**
4
4
  * No Operation. A function that does nothing and returns nothing.
5
5
  *
@@ -47,4 +47,4 @@ export declare function isCodedError(error: unknown): error is Error & {
47
47
  * @returns Platform and architecture specific checksums or null if no checksums provided
48
48
  */
49
49
  export declare function transformChecksums(checksums: Checksums | undefined, targetPlatform: Platform, targetArch: Architecture): PlatformArchChecksums | null;
50
- //# sourceMappingURL=utils.d.cts.map
50
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EAErB,QAAQ,EACT,MAAM,YAAY,CAAC;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"}
@@ -1,6 +1,6 @@
1
- import { execFileSync, execSync } from "node:child_process";
2
- import { arch } from "node:os";
3
- import { Architecture } from "./types.mjs";
1
+ import { execFileSync, execSync } from 'node:child_process';
2
+ import { arch } from 'node:os';
3
+ import { Architecture } from './types.js';
4
4
  /**
5
5
  * No Operation. A function that does nothing and returns nothing.
6
6
  *
@@ -98,4 +98,4 @@ export function transformChecksums(checksums, targetPlatform, targetArch) {
98
98
  }, {}),
99
99
  };
100
100
  }
101
- //# sourceMappingURL=utils.mjs.map
101
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAY,GAAW,IAAI,EAAE;IAE7B,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,yBAAyB;QACzB,OAAO,YAAY,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,QAAQ,CAAC,8CAA8C,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtE,OAAO,YAAY,CAAC,KAAK,CAAC;YAC5B,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,8DAA8D;QAChE,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC,KAAK,CAAC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AC,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/foundryup",
3
- "version": "1.0.1-preview-b13d916",
3
+ "version": "1.0.1-preview-4f4c98e",
4
4
  "description": "foundryup",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -16,14 +16,13 @@
16
16
  "url": "https://github.com/MetaMask/core.git"
17
17
  },
18
18
  "bin": {
19
- "mm-foundryup": "./dist/cli.mjs"
19
+ "mm-foundryup": "./dist/cli.js"
20
20
  },
21
21
  "files": [
22
22
  "dist/"
23
23
  ],
24
+ "type": "module",
24
25
  "sideEffects": false,
25
- "main": "./dist/index.cjs",
26
- "types": "./dist/index.d.cts",
27
26
  "exports": {
28
27
  "./package.json": "./package.json"
29
28
  },
@@ -33,9 +32,11 @@
33
32
  },
34
33
  "scripts": {
35
34
  "anvil": "node_modules/.bin/anvil",
36
- "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
37
- "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
35
+ "build": "tsc --project tsconfig.build.json",
36
+ "build:all": "tsc --build tsconfig.build.json --verbose",
37
+ "build:clean": "yarn build:only-clean && yarn build",
38
38
  "build:docs": "typedoc",
39
+ "build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
39
40
  "changelog:update": "../../scripts/update-changelog.sh @metamask/foundryup",
40
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/foundryup",
41
42
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
@@ -55,22 +56,23 @@
55
56
  },
56
57
  "devDependencies": {
57
58
  "@metamask/auto-changelog": "^6.1.0",
58
- "@ts-bridge/cli": "^0.6.4",
59
59
  "@types/jest": "^30.0.0",
60
60
  "@types/unzipper": "^0.10.10",
61
61
  "@types/yargs": "^17.0.32",
62
62
  "@types/yargs-parser": "^21.0.3",
63
+ "@typescript/native": "npm:typescript@^7.0.2",
63
64
  "deepmerge": "^4.2.2",
64
65
  "jest": "^30.4.2",
65
66
  "nock": "^13.3.1",
67
+ "rimraf": "^5.0.5",
66
68
  "ts-jest": "^29.4.11",
67
69
  "tsx": "^4.20.5",
68
70
  "typedoc": "^0.25.13",
69
71
  "typedoc-plugin-missing-exports": "^2.0.0",
70
- "typescript": "~5.3.3",
72
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
71
73
  "yaml": "^2.3.4"
72
74
  },
73
75
  "engines": {
74
- "node": "^18.18 || >=20"
76
+ "node": "^22.14.0 || ^24"
75
77
  }
76
78
  }
package/dist/cli.cjs DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- /**
5
- * CLI entry point for Foundryup.
6
- *
7
- * This script downloads and installs Foundry binaries.
8
- * If an error occurs, it logs the error and exits with code 1.
9
- */
10
- const index_js_1 = require("./index.cjs");
11
- /**
12
- * Run the main installation process and handle errors.
13
- */
14
- (0, index_js_1.downloadAndInstallFoundryBinaries)().catch((error) => {
15
- /**
16
- * Log any error that occurs during installation and exit with code 1.
17
- *
18
- * @param error - The error thrown during installation.
19
- */
20
- console.error('Error:', error);
21
- process.exit(1);
22
- });
23
- //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.cjs","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,0CAA+D;AAE/D;;GAEG;AACH,IAAA,4CAAiC,GAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAClD;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n/**\n * CLI entry point for Foundryup.\n *\n * This script downloads and installs Foundry binaries.\n * If an error occurs, it logs the error and exits with code 1.\n */\nimport { downloadAndInstallFoundryBinaries } from './index.js';\n\n/**\n * Run the main installation process and handle errors.\n */\ndownloadAndInstallFoundryBinaries().catch((error) => {\n /**\n * Log any error that occurs during installation and exit with code 1.\n *\n * @param error - The error thrown during installation.\n */\n console.error('Error:', error);\n process.exit(1);\n});\n"]}
package/dist/cli.d.cts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.cts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.d.mts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.mts.map