This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add applyPatches script and some basic patch documentation
- Loading branch information
Showing
5 changed files
with
113 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -47,3 +47,32 @@ This project deploys multiple defense measures to ensure that the safe binaries | |
- Only authorized Vercel employees can push new revisions to npm. | ||
|
||
Report to [[email protected]](mailto:[email protected]), if you noticed a disparity between (hashes of) binaries. | ||
|
||
## Contributing Updates to Patches | ||
|
||
The expectation is that a patch applies cleanly, with no delta or offsets from | ||
the source repo. | ||
|
||
When making a change to a patch file, it is possible to apply that patch without | ||
building by running | ||
|
||
`yarn applyPatches --node-range node18` | ||
|
||
where the `--node-range` can be specified to apply patches for the version of | ||
node for which you are updating patches. If unspecified, the latest node version | ||
in [patches.json](./patches/patches.json) will be used. | ||
|
||
Ultimately, the patch should result in fully functional node binary, but the | ||
`applyPatches` script can be used to quickly iterate just the application of | ||
the patches you are updating without needing to wait for the full build to | ||
complete. | ||
|
||
## Building a Binary Locally | ||
|
||
You can use the `yarn start` script to build the binary locally, which is helpful | ||
when updating patches to ensure functionality before pushing patch updates for | ||
review. | ||
|
||
For example: | ||
|
||
`yarn start --node-range node18 --arch x64 --output dist` |
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env node | ||
|
||
import yargs from 'yargs'; | ||
|
||
import { log } from './log'; | ||
import { getNodeVersion } from './index'; | ||
import { version } from '../package.json'; | ||
import { fetchExtractApply, prepBuildPath } from './build'; | ||
|
||
async function applyPatchesOnVersion(nodeRange: string, quietExtraction = false) { | ||
await prepBuildPath(); | ||
await fetchExtractApply(getNodeVersion(nodeRange), quietExtraction); | ||
} | ||
|
||
async function main() { | ||
const { argv } = yargs | ||
.option('node-range', { alias: 'n', default: 'latest', type: 'string' }) | ||
.option('quiet-extraction', { alias: 'q', type: 'boolean' }) | ||
.version(version) | ||
.alias('v', 'version') | ||
.help() | ||
.alias('h', 'help'); | ||
|
||
const { | ||
'node-range': nodeRange, | ||
'quiet-extraction': quietExtraction, | ||
} = argv; | ||
|
||
await applyPatchesOnVersion(nodeRange, quietExtraction); | ||
} | ||
|
||
main().catch((error) => { | ||
if (!error.wasReported) log.error(error); | ||
process.exit(2); | ||
}); |
This file contains 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 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 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