This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3deb57
commit 8a42efd
Showing
5 changed files
with
31 additions
and
288 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { Binary } = require("binary-install"); | ||
const os = require("os"); | ||
const { join } = require("path"); | ||
const platform = getPlatform(); | ||
const version = require("./package.json").version; | ||
const url = `https://workers.cloudflare.com/get-npm-wrangler-binary/${version}/${platform}`; | ||
const installDirectory = join(os.homedir(), ".wrangler"); | ||
|
||
function getPlatform() { | ||
const type = os.type(); | ||
const arch = os.arch(); | ||
|
||
if (type === "Windows_NT" && arch === "x64") { | ||
return "x86_64-pc-windows-msvc"; | ||
} | ||
if (type === "Linux" && arch === "x64") { | ||
return "x86_64-unknown-linux-musl"; | ||
} | ||
if (type === "Darwin" && arch === "x64") { | ||
return "x86_64-apple-darwin"; | ||
} | ||
|
||
throw new Error(`Unsupported platform: ${type} ${arch}`); | ||
} | ||
|
||
module.exports.binary = new Binary({ name: "wrangler", url, installDirectory }); |
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 |
---|---|---|
@@ -1,67 +1,2 @@ | ||
const axios = require("axios"); | ||
const os = require("os"); | ||
const { join, resolve } = require("path"); | ||
const { mkdirSync, existsSync } = require("fs"); | ||
const rimraf = require("rimraf"); | ||
const tar = require("tar"); | ||
const { get } = axios; | ||
const { homedir } = require('os'); | ||
|
||
const cwd = join(homedir(), ".wrangler"); | ||
|
||
const VERSION = require("./package.json").version; | ||
|
||
function getPlatform() { | ||
const type = os.type(); | ||
const arch = os.arch(); | ||
|
||
if (type === "Windows_NT" && arch === "x64") { | ||
return "x86_64-pc-windows-msvc"; | ||
} | ||
if (type === "Linux" && arch === "x64") { | ||
return "x86_64-unknown-linux-musl"; | ||
} | ||
if (type === "Darwin" && arch === "x64") { | ||
return "x86_64-apple-darwin"; | ||
} | ||
|
||
throw new Error(`Unsupported platform: ${type} ${arch}`); | ||
} | ||
|
||
function downloadAsset(version, platform) { | ||
const dest = join(cwd, "out"); | ||
|
||
if (existsSync(dest)) { | ||
rimraf.sync(dest); | ||
} | ||
mkdirSync(dest); | ||
|
||
const url = `https://workers.cloudflare.com/get-npm-wrangler-binary/${ version }/${ platform }` | ||
|
||
console.log("Downloading release", url); | ||
|
||
return axios({ | ||
url, | ||
responseType: "stream" | ||
}).then(res => { | ||
res.data.pipe( | ||
tar.x({ | ||
strip: 1, | ||
C: dest | ||
}) | ||
); | ||
}); | ||
} | ||
|
||
if (!existsSync(cwd)) { | ||
mkdirSync(cwd); | ||
} | ||
|
||
downloadAsset(VERSION, getPlatform()) | ||
.then(() => { | ||
console.log("Wrangler has been installed!"); | ||
}) | ||
.catch(e => { | ||
console.error("Error fetching release", e.message); | ||
throw e; | ||
}); | ||
const { binary } = require("./binary"); | ||
binary.install(); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,2 @@ | ||
#!/usr/bin/env node | ||
|
||
const { join } = require("path"); | ||
const { spawnSync } = require("child_process"); | ||
const { homedir } = require("os"); | ||
|
||
const cwd = join(homedir(), ".wrangler"); | ||
const bin = join(cwd, "out", "wrangler"); | ||
const [, , ...args] = process.argv; | ||
|
||
const opts = { | ||
cwd: process.cwd(), | ||
stdio: "inherit" | ||
}; | ||
|
||
const result = spawnSync(bin, args, opts); | ||
|
||
if (result.error) { | ||
console.error(result.error); | ||
process.exit(1); | ||
} | ||
|
||
process.exit(result.status); | ||
const { binary } = require("./binary"); | ||
binary.run(); |