From d8fa123a60493d79d7c7f35a6056a8c82d28ab02 Mon Sep 17 00:00:00 2001 From: "malonso@cloudflare.com" Date: Wed, 24 Feb 2021 11:09:09 -0600 Subject: [PATCH 1/3] use @cloudflare/binary-install@0.2.0 (same as binary-install@0.1.0 with updated deps), more detail in release checklist --- RELEASE_CHECKLIST.md | 4 ++-- npm/binary.js | 2 +- npm/npm-shrinkwrap.json | 20 ++++++++++---------- npm/package.json | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index 7d07855a6..bd219f392 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -12,7 +12,7 @@ This is a list of the things that need to happen during a release. 1. Go through the commit history since the last release. Ensure that all PRs that have landed are marked with the milestone. You can use this to show all the PRs that are merged on or after YYY-MM-DD: - `https://github.com/issues?utf8=%E2%9C%93&q=repo%3Acloudflare%2Fwrangler+merged%3A%3E%3DYYYY-MM-DD` + `https://github.com/issues?q=repo%3Acloudflare%2Fwrangler+base%3Amaster+merged%3A%3E%3DYYYY-MM-DD` 1. Go through the closed PRs in the milestone. Each should have a changelog label indicating if the change is docs, fix, feature, or maintenance. If there is a missing label, please add one. @@ -31,7 +31,7 @@ This is a list of the things that need to happen during a release. 1. Copy `README.md` to `npm/README.md` 1. Bump the version number in `npm/package.json` -1. `cd npm && npm install` _Note: This step will appear to fail, however its utility is re-building npm-shrinkwrap.json_ +1. `cd npm && npm install` _Note: This step will appear to fail due to the new version not existing yet, however its utility is re-building npm-shrinkwrap.json_ ### Start a release PR diff --git a/npm/binary.js b/npm/binary.js index c67f036ba..4ebfef91e 100644 --- a/npm/binary.js +++ b/npm/binary.js @@ -1,4 +1,4 @@ -const { Binary } = require("binary-install"); +const { Binary } = require("@cloudflare/binary-install"); const os = require("os"); const { join } = require("path"); diff --git a/npm/npm-shrinkwrap.json b/npm/npm-shrinkwrap.json index 2125f67c9..edc1e76b8 100644 --- a/npm/npm-shrinkwrap.json +++ b/npm/npm-shrinkwrap.json @@ -4,6 +4,16 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@cloudflare/binary-install": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@cloudflare/binary-install/-/binary-install-0.2.0.tgz", + "integrity": "sha512-54n9ILgln+qUJc0BtbetEIEi1GrIL88p7ZDJy+BV8EsUqA7pMCMHAUOHjDq+YrIoqJHGJktlQJxBYB+4Umf3ww==", + "requires": { + "axios": "^0.21.1", + "rimraf": "^3.0.2", + "tar": "^6.0.2" + } + }, "axios": { "version": "0.21.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", @@ -17,16 +27,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "binary-install": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-0.1.1.tgz", - "integrity": "sha512-DqED0D/6LrS+BHDkKn34vhRqOGjy5gTMgvYZsGK2TpNbdPuz4h+MRlNgGv5QBRd7pWq/jylM4eKNCizgAq3kNQ==", - "requires": { - "axios": "^0.21.1", - "rimraf": "^3.0.2", - "tar": "^6.1.0" - } - }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", diff --git a/npm/package.json b/npm/package.json index 359ed9283..fa3528025 100644 --- a/npm/package.json +++ b/npm/package.json @@ -42,6 +42,6 @@ "cli" ], "dependencies": { - "binary-install": "0.1.1" + "@cloudflare/binary-install": "0.2.0" } } From 87327726a90128a6efecc787f9bc51555e4a10ea Mon Sep 17 00:00:00 2001 From: bpofficial <43508501+bpofficial@users.noreply.github.com> Date: Thu, 25 Feb 2021 03:30:14 +1000 Subject: [PATCH 2/3] added alternative binary install path options (#1555) Co-authored-by: Brayden Phillips Co-authored-by: Ashcon Partovi Co-authored-by: Natalie Davidson Co-authored-by: Sven Sauleau --- npm/binary.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/npm/binary.js b/npm/binary.js index 4ebfef91e..576ed87fa 100644 --- a/npm/binary.js +++ b/npm/binary.js @@ -20,9 +20,10 @@ const getPlatform = () => { }; const getBinaryURL = (version, platform) => { - const site = process.env.WRANGLER_BINARY_HOST || - process.env.npm_config_wrangler_binary_host || - 'https://workers.cloudflare.com/get-npm-wrangler-binary'; + const site = + process.env.WRANGLER_BINARY_HOST || + process.env.npm_config_wrangler_binary_host || + "https://workers.cloudflare.com/get-npm-wrangler-binary"; return `${site}/${version}/${platform}`; }; @@ -30,7 +31,11 @@ const getBinary = () => { const platform = getPlatform(); const version = require("./package.json").version; const url = getBinaryURL(version, platform); - const installDirectory = join(os.homedir(), ".wrangler"); + + const useCwd = !!process.env.WRANGLER_USE_CWD; + const customPath = process.env.WRANGLER_INSTALL_PATH; + const altPath = useCwd ? process.cwd() : !!customPath ? customPath : false; + const installDirectory = join(altPath || os.homedir(), ".wrangler"); return new Binary(url, { name: "wrangler", installDirectory }); }; @@ -47,10 +52,10 @@ const install = () => { const uninstall = () => { const binary = getBinary(); binary.uninstall(); -} +}; module.exports = { install, run, - uninstall + uninstall, }; From d7d257886f893349ec5b1113e4544022fef8cccc Mon Sep 17 00:00:00 2001 From: "malonso@cloudflare.com" Date: Thu, 25 Feb 2021 08:46:03 -0600 Subject: [PATCH 3/3] use node_modules by default, clarify README --- README.md | 13 +++++++++++-- npm/binary.js | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e675b52d..13c465acb 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,24 @@ You have many options to install wrangler! ### Install with `npm` -We strongly recommend you install `npm` with a Node version manager like [`nvm`](https://github.com/nvm-sh/nvm#installing-and-updating), which will allow `wrangler` to install configuration data in a global `node_modules` directory in your user's home directory, without requiring that you run as `root`. +We strongly recommend you install `npm` with a Node version manager like [`nvm`](https://github.com/nvm-sh/nvm#installing-and-updating), which puts the global `node_modules` in your home directory to eliminate permissions issues with `npm install -g`. Distribution-packaged `npm` installs often use `/usr/lib/node_modules` (which is root) for globally installed `npm` packages, and running `npm install -g` as `root` prevents `wrangler` from installing properly. -Once you've installed `nvm`, run: + +Once you've installed `nvm` and configured your system to use the `nvm` managed node install, run: ```bash npm i @cloudflare/wrangler -g ``` + If you are running an ARM based system (eg Raspberry Pi, Pinebook) you'll need to use the `cargo` installation method listed below to build wrangler from source. +#### Specify binary location + +In case you need `wrangler`'s npm installer to place the binary in a non-default location (such as when using `wrangler` in CI), you can use the following configuration options to specify an install location: + +- Environment variable: `WRANGLER_INSTALL_PATH` +- NPM configuration: `wrangler_install_path` + #### Specify binary site URL In case you need to store/mirror binaries on premise you will need to specify where wrangler should search for them by providing any of the following: diff --git a/npm/binary.js b/npm/binary.js index 576ed87fa..ce86f5c15 100644 --- a/npm/binary.js +++ b/npm/binary.js @@ -32,10 +32,10 @@ const getBinary = () => { const version = require("./package.json").version; const url = getBinaryURL(version, platform); - const useCwd = !!process.env.WRANGLER_USE_CWD; - const customPath = process.env.WRANGLER_INSTALL_PATH; - const altPath = useCwd ? process.cwd() : !!customPath ? customPath : false; - const installDirectory = join(altPath || os.homedir(), ".wrangler"); + const customPath = + process.env.WRANGLER_INSTALL_PATH || + process.env.npm_config_wrangler_install_path; + const installDirectory = join(customPath || __dirname, "wrangler"); return new Binary(url, { name: "wrangler", installDirectory }); };