@foundry-rs/forge 1.4.4-nightly.20251027.9c0737c → 1.4.4-nightly.20251028.9273fd8
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/README.md +1 -1
- package/package.json +7 -7
- package/bin/forge.mjs +0 -54
- package/dist/install.mjs +0 -171
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
# Forge
|
|
2
2
|
|
|
3
3
|
Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts.
|
|
4
|
-
|
|
4
|
+
The forge binary can be used both within and outside of a Foundry project.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundry-rs/forge",
|
|
3
|
-
"version": "1.4.4-nightly.
|
|
3
|
+
"version": "1.4.4-nightly.20251028.9273fd8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://getfoundry.sh/forge",
|
|
6
6
|
"description": "Fast and flexible Ethereum testing framework",
|
|
7
7
|
"bin": {
|
|
8
|
-
"forge": "./bin
|
|
8
|
+
"forge": "./bin.mjs"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"postinstall": "node ./dist/install.mjs"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@foundry-rs/forge-darwin-arm64": "1.4.4-nightly.
|
|
19
|
-
"@foundry-rs/forge-darwin-amd64": "1.4.4-nightly.
|
|
20
|
-
"@foundry-rs/forge-linux-arm64": "1.4.4-nightly.
|
|
21
|
-
"@foundry-rs/forge-linux-amd64": "1.4.4-nightly.
|
|
22
|
-
"@foundry-rs/forge-win32-amd64": "1.4.4-nightly.
|
|
18
|
+
"@foundry-rs/forge-darwin-arm64": "1.4.4-nightly.20251028.9273fd8",
|
|
19
|
+
"@foundry-rs/forge-darwin-amd64": "1.4.4-nightly.20251028.9273fd8",
|
|
20
|
+
"@foundry-rs/forge-linux-arm64": "1.4.4-nightly.20251028.9273fd8",
|
|
21
|
+
"@foundry-rs/forge-linux-amd64": "1.4.4-nightly.20251028.9273fd8",
|
|
22
|
+
"@foundry-rs/forge-win32-amd64": "1.4.4-nightly.20251028.9273fd8"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public",
|
package/bin/forge.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as NodeModule from "node:module";
|
|
3
|
-
import * as NodeChildProcess from "node:child_process";
|
|
4
|
-
import * as NodeFS from "node:fs";
|
|
5
|
-
import * as NodePath from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
8
|
-
//#region src/const.ts
|
|
9
|
-
const BINARY_DISTRIBUTION_PACKAGES = {
|
|
10
|
-
darwin: {
|
|
11
|
-
x64: "@foundry-rs/forge-darwin-amd64",
|
|
12
|
-
arm64: "@foundry-rs/forge-darwin-arm64"
|
|
13
|
-
},
|
|
14
|
-
linux: {
|
|
15
|
-
x64: "@foundry-rs/forge-linux-amd64",
|
|
16
|
-
arm64: "@foundry-rs/forge-linux-arm64"
|
|
17
|
-
},
|
|
18
|
-
win32: { x64: "@foundry-rs/forge-win32-amd64" }
|
|
19
|
-
};
|
|
20
|
-
const BINARY_NAME = process.platform === "win32" ? "forge.exe" : "forge";
|
|
21
|
-
const PLATFORM_SPECIFIC_PACKAGE_NAME = BINARY_DISTRIBUTION_PACKAGES[process.platform][process.arch];
|
|
22
|
-
const colors = {
|
|
23
|
-
red: "\x1B[31m",
|
|
24
|
-
green: "\x1B[32m",
|
|
25
|
-
yellow: "\x1B[33m",
|
|
26
|
-
blue: "\x1B[34m",
|
|
27
|
-
magenta: "\x1B[35m",
|
|
28
|
-
cyan: "\x1B[36m",
|
|
29
|
-
white: "\x1B[37m",
|
|
30
|
-
reset: "\x1B[0m"
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/forge.ts
|
|
35
|
-
const require = NodeModule.createRequire(import.meta.url);
|
|
36
|
-
const __dirname = NodePath.dirname(fileURLToPath(import.meta.url));
|
|
37
|
-
function getBinaryPath() {
|
|
38
|
-
try {
|
|
39
|
-
const binaryPath = require.resolve(`${PLATFORM_SPECIFIC_PACKAGE_NAME}/bin/${BINARY_NAME}`);
|
|
40
|
-
if (NodeFS.existsSync(binaryPath)) return binaryPath;
|
|
41
|
-
} catch {
|
|
42
|
-
return NodePath.join(__dirname, "..", "dist", BINARY_NAME);
|
|
43
|
-
}
|
|
44
|
-
console.error(colors.red, `Platform-specific package ${PLATFORM_SPECIFIC_PACKAGE_NAME} not found.`);
|
|
45
|
-
console.error(colors.yellow, "This usually means the installation failed or your platform is not supported.");
|
|
46
|
-
console.error(colors.reset);
|
|
47
|
-
console.error(colors.yellow, `Platform: ${process.platform}, Architecture: ${process.arch}`);
|
|
48
|
-
console.error(colors.reset);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
NodeChildProcess.spawn(getBinaryPath(), process.argv.slice(2), { stdio: "inherit" });
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
export { };
|
package/dist/install.mjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as NodeModule from "node:module";
|
|
3
|
-
import * as NodeCrypto from "node:crypto";
|
|
4
|
-
import * as NodeFS from "node:fs";
|
|
5
|
-
import * as NodeHttp from "node:http";
|
|
6
|
-
import * as NodeHttps from "node:https";
|
|
7
|
-
import * as NodePath from "node:path";
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
9
|
-
import * as NodeZlib from "node:zlib";
|
|
10
|
-
|
|
11
|
-
//#region src/const.ts
|
|
12
|
-
function getRegistryUrl() {
|
|
13
|
-
return process.env.npm_config_registry || process.env.REGISTRY_URL || "https://registry.npmjs.org";
|
|
14
|
-
}
|
|
15
|
-
const BINARY_DISTRIBUTION_PACKAGES = {
|
|
16
|
-
darwin: {
|
|
17
|
-
x64: "@foundry-rs/forge-darwin-amd64",
|
|
18
|
-
arm64: "@foundry-rs/forge-darwin-arm64"
|
|
19
|
-
},
|
|
20
|
-
linux: {
|
|
21
|
-
x64: "@foundry-rs/forge-linux-amd64",
|
|
22
|
-
arm64: "@foundry-rs/forge-linux-arm64"
|
|
23
|
-
},
|
|
24
|
-
win32: { x64: "@foundry-rs/forge-win32-amd64" }
|
|
25
|
-
};
|
|
26
|
-
const BINARY_NAME = process.platform === "win32" ? "forge.exe" : "forge";
|
|
27
|
-
const PLATFORM_SPECIFIC_PACKAGE_NAME = BINARY_DISTRIBUTION_PACKAGES[process.platform][process.arch];
|
|
28
|
-
const colors = {
|
|
29
|
-
red: "\x1B[31m",
|
|
30
|
-
green: "\x1B[32m",
|
|
31
|
-
yellow: "\x1B[33m",
|
|
32
|
-
blue: "\x1B[34m",
|
|
33
|
-
magenta: "\x1B[35m",
|
|
34
|
-
cyan: "\x1B[36m",
|
|
35
|
-
white: "\x1B[37m",
|
|
36
|
-
reset: "\x1B[0m"
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/install.ts
|
|
41
|
-
const __dirname = NodePath.dirname(fileURLToPath(import.meta.url));
|
|
42
|
-
const fallbackBinaryPath = NodePath.join(__dirname, BINARY_NAME);
|
|
43
|
-
const require = NodeModule.createRequire(import.meta.url);
|
|
44
|
-
const isLocalhostHost = (hostname) => hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
|
|
45
|
-
function ensureSecureUrl(urlString, purpose) {
|
|
46
|
-
try {
|
|
47
|
-
const url = new URL(urlString);
|
|
48
|
-
if (url.protocol === "http:") {
|
|
49
|
-
const allowInsecure = process.env.ALLOW_INSECURE_REGISTRY === "true";
|
|
50
|
-
if (!isLocalhostHost(url.hostname) && !allowInsecure) throw new Error(`Refusing to use insecure HTTP for ${purpose}: ${urlString}. Set ALLOW_INSECURE_REGISTRY=true to override (not recommended).`);
|
|
51
|
-
}
|
|
52
|
-
} catch {}
|
|
53
|
-
}
|
|
54
|
-
function makeRequest(url) {
|
|
55
|
-
return new Promise((resolve, reject) => {
|
|
56
|
-
ensureSecureUrl(url, "HTTP request");
|
|
57
|
-
(url.startsWith("https:") ? NodeHttps : NodeHttp).get(url, (response) => {
|
|
58
|
-
if (response?.statusCode && response.statusCode >= 200 && response.statusCode < 300) {
|
|
59
|
-
const chunks = [];
|
|
60
|
-
response.on("data", (chunk) => chunks.push(chunk));
|
|
61
|
-
response.on("end", () => resolve(Buffer.concat(chunks)));
|
|
62
|
-
} else if (response?.statusCode && response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
63
|
-
const redirected = (() => {
|
|
64
|
-
try {
|
|
65
|
-
return new URL(response.headers.location, url).href;
|
|
66
|
-
} catch {
|
|
67
|
-
return response.headers.location;
|
|
68
|
-
}
|
|
69
|
-
})();
|
|
70
|
-
makeRequest(redirected).then(resolve, reject);
|
|
71
|
-
} else reject(/* @__PURE__ */ new Error(`Package registry responded with status code ${response.statusCode} when downloading the package.`));
|
|
72
|
-
}).on("error", (error) => reject(error));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Scoped package names should be percent-encoded
|
|
77
|
-
* e.g. @scope/pkg -> %40scope%2Fpkg
|
|
78
|
-
*/
|
|
79
|
-
const encodePackageNameForRegistry = (name) => name.startsWith("@") ? encodeURIComponent(name) : name;
|
|
80
|
-
/**
|
|
81
|
-
* Tar archives are organized in 512 byte blocks.
|
|
82
|
-
* Blocks can either be header blocks or data blocks.
|
|
83
|
-
* Header blocks contain file names of the archive in the first 100 bytes, terminated by a null byte.
|
|
84
|
-
* The size of a file is contained in bytes 124-135 of a header block and in octal format.
|
|
85
|
-
* The following blocks will be data blocks containing the file.
|
|
86
|
-
*/
|
|
87
|
-
function extractFileFromTarball(tarballBuffer, filepath) {
|
|
88
|
-
let offset = 0;
|
|
89
|
-
while (offset < tarballBuffer.length) {
|
|
90
|
-
const header = tarballBuffer.subarray(offset, offset + 512);
|
|
91
|
-
offset += 512;
|
|
92
|
-
const fileName = header.toString("utf-8", 0, 100).replace(/\0.*/g, "");
|
|
93
|
-
const fileSize = Number.parseInt(header.toString("utf-8", 124, 136).replace(/\0.*/g, ""), 8);
|
|
94
|
-
if (fileName === filepath) return tarballBuffer.subarray(offset, offset + fileSize);
|
|
95
|
-
offset = offset + fileSize + 511 & -512;
|
|
96
|
-
}
|
|
97
|
-
throw new Error(`File ${filepath} not found in tarball`);
|
|
98
|
-
}
|
|
99
|
-
async function downloadBinaryFromRegistry() {
|
|
100
|
-
const registryUrl = getRegistryUrl().replace(/\/$/, "");
|
|
101
|
-
ensureSecureUrl(registryUrl, "registry URL");
|
|
102
|
-
const encodedName = encodePackageNameForRegistry(PLATFORM_SPECIFIC_PACKAGE_NAME);
|
|
103
|
-
let desiredVersion;
|
|
104
|
-
try {
|
|
105
|
-
const pkgJsonPath = NodePath.join(__dirname, "..", "package.json");
|
|
106
|
-
const pkgJson = JSON.parse(NodeFS.readFileSync(pkgJsonPath, "utf8"));
|
|
107
|
-
desiredVersion = pkgJson?.optionalDependencies?.[PLATFORM_SPECIFIC_PACKAGE_NAME] || pkgJson?.version;
|
|
108
|
-
} catch {}
|
|
109
|
-
const metaUrl = `${registryUrl}/${encodedName}`;
|
|
110
|
-
const metaBuffer = await makeRequest(metaUrl);
|
|
111
|
-
const metadata = JSON.parse(metaBuffer.toString("utf8"));
|
|
112
|
-
const version = desiredVersion || metadata?.["dist-tags"]?.latest;
|
|
113
|
-
const dist = (metadata?.versions?.[version])?.dist;
|
|
114
|
-
if (!dist?.tarball) throw new Error(`Could not find tarball for ${PLATFORM_SPECIFIC_PACKAGE_NAME}@${version} from ${metaUrl}`);
|
|
115
|
-
ensureSecureUrl(dist.tarball, "tarball URL");
|
|
116
|
-
console.info(colors.green, "Downloading binary from:\n", dist.tarball, "\n", colors.reset);
|
|
117
|
-
/**
|
|
118
|
-
* Download the tarball of the right binary distribution package
|
|
119
|
-
* Verify integrity: prefer SRI integrity (sha512/sha256/sha1),
|
|
120
|
-
* fallback to legacy dist.shasum (sha1 hex). Fail if neither unless explicitly allowed.
|
|
121
|
-
*/
|
|
122
|
-
const tarballDownloadBuffer = await makeRequest(dist.tarball);
|
|
123
|
-
(() => {
|
|
124
|
-
let verified = false;
|
|
125
|
-
const sriMatch = (typeof dist.integrity === "string" ? dist.integrity : "").match(/^([a-z0-9]+)-([A-Za-z0-9+/=]+)$/i);
|
|
126
|
-
if (sriMatch) {
|
|
127
|
-
const algo = sriMatch[1].toLowerCase();
|
|
128
|
-
const expected = sriMatch[2];
|
|
129
|
-
if (new Set([
|
|
130
|
-
"sha512",
|
|
131
|
-
"sha256",
|
|
132
|
-
"sha1"
|
|
133
|
-
]).has(algo)) {
|
|
134
|
-
const actual = NodeCrypto.createHash(algo).update(tarballDownloadBuffer).digest("base64");
|
|
135
|
-
if (expected !== actual) throw new Error(`Downloaded tarball failed integrity check (${algo} mismatch)`);
|
|
136
|
-
verified = true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (!verified && typeof dist.shasum === "string" && dist.shasum.length === 40) {
|
|
140
|
-
const expectedSha1Hex = dist.shasum.toLowerCase();
|
|
141
|
-
const actualSha1Hex = NodeCrypto.createHash("sha1").update(tarballDownloadBuffer).digest("hex");
|
|
142
|
-
if (expectedSha1Hex !== actualSha1Hex) throw new Error("Downloaded tarball failed integrity check (sha1 shasum mismatch)");
|
|
143
|
-
verified = true;
|
|
144
|
-
}
|
|
145
|
-
if (!verified) {
|
|
146
|
-
if (!(process.env.ALLOW_NO_INTEGRITY === "true" || process.env.ALLOW_UNVERIFIED_TARBALL === "true")) throw new Error("No integrity metadata found for downloaded tarball. Set ALLOW_NO_INTEGRITY=true to bypass (not recommended).");
|
|
147
|
-
console.warn(colors.yellow, "Warning: proceeding without integrity verification (explicitly allowed).", colors.reset);
|
|
148
|
-
}
|
|
149
|
-
})();
|
|
150
|
-
const tarballBuffer = NodeZlib.gunzipSync(tarballDownloadBuffer);
|
|
151
|
-
NodeFS.writeFileSync(fallbackBinaryPath, extractFileFromTarball(tarballBuffer, `package/bin/${BINARY_NAME}`), { mode: 493 });
|
|
152
|
-
}
|
|
153
|
-
function isPlatformSpecificPackageInstalled() {
|
|
154
|
-
try {
|
|
155
|
-
require.resolve(`${PLATFORM_SPECIFIC_PACKAGE_NAME}/bin/${BINARY_NAME}`);
|
|
156
|
-
return true;
|
|
157
|
-
} catch (_error) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (!PLATFORM_SPECIFIC_PACKAGE_NAME) throw new Error("Platform not supported!");
|
|
162
|
-
if (!isPlatformSpecificPackageInstalled()) {
|
|
163
|
-
console.log("Platform specific package not found. Will manually download binary.");
|
|
164
|
-
downloadBinaryFromRegistry().catch((error) => {
|
|
165
|
-
console.error(colors.red, "Failed to download binary:", error, colors.reset);
|
|
166
|
-
process.exitCode = 1;
|
|
167
|
-
});
|
|
168
|
-
} else console.log("Platform specific package already installed. Skipping manual download.");
|
|
169
|
-
|
|
170
|
-
//#endregion
|
|
171
|
-
export { };
|