-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: harden npm
publish & make installer leaner
#11600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+245
−291
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
NODE_ENV="development" | ||
|
||
NPM_TOKEN="" | ||
NPM_REGISTRY_URL="" | ||
NPM_USERNAME="foundry-rs" | ||
|
||
PLATFORM_NAME="" | ||
ARCH="" | ||
ARCH="" | ||
|
||
# for testing purposes | ||
NPM_EMAIL="" | ||
NPM_PASSWORD="" | ||
NPM_REGISTRY_URL="" | ||
NPM_USER="foundry-rs" | ||
ALLOW_NO_INTEGRITY=false | ||
ALLOW_INSECURE_REGISTRY=false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# forge | ||
# Forge | ||
|
||
A CLI tool for testing, building, and deploying your smart contracts. | ||
See <https://getfoundry.sh/forge/overview> for details. | ||
Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys your smart contracts. | ||
Forge is part of the Foundry suite and is installed alongside `cast`, `chisel`, and `anvil`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,5 @@ | ||
# @foundry-rs npm Packages | ||
|
||
This folder contains the npm packages for the Foundry CLI. | ||
The npm folder contains the meta packages for `forge` (`@foundry-rs/forge`) and per-arch packages (e.g. `@foundry-rs/forge-darwin-arm64`). | ||
|
||
- `@foundry-rs/forge`, | ||
- `@foundry-rs/anvil` (soon), | ||
|
||
## Local publish & Test | ||
|
||
The npm folder contains the meta package `@foundry-rs/forge` and per-arch packages (e.g. `@foundry-rs/forge-darwin-arm64`). This guide shows how to publish them to a local registry and test via npx/bunx. | ||
|
||
### Prerequisites | ||
|
||
- Node.js LTS, npm, and Bun installed (`bun -v`). | ||
- Docker (recommended) or a local [Verdaccio](https://verdaccio.org) install. | ||
- Optional: Rust toolchain if you want to build a fresh `forge` binary (`cargo build --release -p forge`). | ||
|
||
Start a local npm registry (Verdaccio) with Docker: | ||
|
||
- Docker: `docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio` | ||
- Verify: open `http://localhost:4873` in a browser | ||
- Note: you might need to bump `max_body_size` in [Verdaccio `config.yaml`](https://verdaccio.org/docs/configuration#max-body-size): | ||
|
||
```yaml | ||
max_body_size: 300mb # default is 10mb | ||
``` | ||
|
||
I enter the docker image then `echo 'max_body_size: 300mb' >> /verdaccio/conf/config.yaml` | ||
|
||
Authenticate npm to Verdaccio | ||
|
||
- Create a user/token: `npm adduser --registry http://localhost:4873 --scope=@foundry-rs` | ||
- Ensure your auth token is present (either in `~/.npmrc` or a project `.npmrc`): | ||
- `registry=http://localhost:4873` | ||
- `//localhost:4873/:_authToken=YOUR_TOKEN` | ||
|
||
#### Quick publish (macOS arm64) | ||
|
||
- From `npm/` in this repo: | ||
- `export NPM_REGISTRY_URL=http://localhost:4873` | ||
- `export NPM_TOKEN=localtesttoken` # required by scripts; any non-empty value works | ||
- `bun install` | ||
- `./scripts/setup-local.sh` | ||
- This publishes `@foundry-rs/forge-darwin-arm64` and then `@foundry-rs/forge` to your local registry. | ||
|
||
### Manual publish (any platform) | ||
|
||
- Build wrappers: `cd npm && bun install && npm run build` | ||
- If you have a local `forge` binary, stage it for your platform: | ||
- Example (macOS arm64): | ||
- `cargo build --release -p forge` | ||
- `cd npm` | ||
- `ARCH=arm64 PLATFORM_NAME=darwin FORGE_BIN_PATH=../target/release/forge bun ./scripts/prepublish.ts` | ||
- Publish the platform package, then the meta package (versions auto-synced from Cargo.toml unless overridden by `VERSION_NAME`): | ||
- `export NPM_REGISTRY_URL=http://localhost:4873` | ||
- `export NPM_TOKEN=localtesttoken` | ||
- `bun run ./scripts/publish.ts ./@foundry-rs/forge-<platform>-<arch>` | ||
- `bun run ./scripts/publish.ts ./@foundry-rs/forge` | ||
|
||
#### Run from a test workspace | ||
|
||
- Use the provided workspace: `cd npm/test/workspace` | ||
- Registry config is already set (`.npmrc` and `bunfig.toml` point to `http://localhost:4873`). | ||
- With npm: `npx @foundry-rs/forge --version` | ||
- With Bun: `bunx @foundry-rs/forge --version` | ||
- Alternatively from anywhere, force the local registry: | ||
- `npm_config_registry=http://localhost:4873 npx @foundry-rs/forge --version` | ||
- `REGISTRY_URL=http://localhost:4873 bunx @foundry-rs/forge --version` | ||
|
||
#### Notes | ||
|
||
- The meta package’s `postinstall` either installs the platform-specific optionalDependency or downloads its tarball from the configured registry. | ||
- Publish arch packages first, then the meta package; the publish script auto-updates `optionalDependencies` to the same version. | ||
- If `npm publish` returns 401, ensure you ran `npm adduser` against `http://localhost:4873` and that your token is present in `.npmrc` or provided via `NODE_AUTH_TOKEN`. | ||
A guide on how to publish to a local registry and test via `npx`/`bunx` is available in [./test/README.md](./test/README.md). |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.