inngest-cli
Advanced tools
Comparing version 0.16.3 to 0.16.4-next.1
{ | ||
"name": "inngest-cli", | ||
"version": "0.16.3", | ||
"version": "0.16.4-next.1", | ||
"description": "The event-driven queue for any language.", | ||
"license": "SEE LICENSE IN LICENSE.md", | ||
"scripts": { | ||
"prepublishOnly": "mkdir bin && touch bin/inngest && cp ../README.md .", | ||
"prepublishOnly": "touch bin/inngest && cp ../README.md .", | ||
"postinstall": "node postinstall.js", | ||
@@ -29,13 +29,15 @@ "build": "tsc" | ||
"dependencies": { | ||
"adm-zip": "^0.5.10", | ||
"debug": "^4.3.4", | ||
"node-fetch": "2.6.7", | ||
"tar": "6.1.11", | ||
"unzipper": "0.10.11" | ||
"tar": "6.1.11" | ||
}, | ||
"devDependencies": { | ||
"@types/adm-zip": "^0.5.0", | ||
"@types/debug": "^4.1.8", | ||
"@types/node-fetch": "2.6.2", | ||
"@types/request": "2.48.8", | ||
"@types/tar": "6.1.1", | ||
"@types/unzipper": "0.10.5", | ||
"typescript": "4.7.4" | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
@@ -15,7 +16,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const adm_zip_1 = __importDefault(require("adm-zip")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const path_1 = __importDefault(require("path")); | ||
const tar_1 = __importDefault(require("tar")); | ||
const unzipper_1 = __importDefault(require("unzipper")); | ||
const url_1 = require("url"); | ||
const rootDebug = (0, debug_1.default)("inngest:cli"); | ||
const archMap = { | ||
@@ -38,8 +41,17 @@ arm64: "arm64", | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const version = (_a = process.env.npm_package_version) === null || _a === void 0 ? void 0 : _a.trim(); | ||
const debug = rootDebug.extend("getBinaryUrl"); | ||
const { arch, platform } = getArchPlatform(); | ||
debug({ arch, platform }); | ||
let version = (_a = process.env.npm_package_version) === null || _a === void 0 ? void 0 : _a.trim(); | ||
debug("npm_package_version:", version); | ||
if (platform.platform === "windows") { | ||
debug("Windows detected; pinning to v0.14.6"); | ||
console.warn("Windows detected; pinning to last known working version 0.14.6"); | ||
version = "0.14.6"; | ||
} | ||
if (!version) { | ||
throw new Error("Could not find package version to install binary"); | ||
} | ||
const { arch, platform } = getArchPlatform(); | ||
const targetUrl = new url_1.URL(`https://cli.inngest.com/artifact/v${version}/inngest_${version}_${platform.platform}_${arch}${platform.extension}`); | ||
debug("targetUrl:", targetUrl.href); | ||
return targetUrl; | ||
@@ -49,4 +61,11 @@ }); | ||
function getArchPlatform() { | ||
const debug = rootDebug.extend("getArchPlatform"); | ||
const arch = archMap[process.arch]; | ||
const platform = platformMap[process.platform]; | ||
debug({ | ||
arch, | ||
platform, | ||
"process.arch": process.arch, | ||
"process.platform": process.platform, | ||
}); | ||
if (!arch) { | ||
@@ -58,6 +77,12 @@ throw new Error(`Unsupported architecture: ${process.arch}`); | ||
} | ||
if (platform.platform === "windows" && arch === "amd64") { | ||
debug("Old Windows x64 build; using 'x86_64' to access binary"); | ||
return { arch: "x86_64", platform }; | ||
} | ||
return { arch, platform }; | ||
} | ||
function downloadBinary(url) { | ||
const debug = rootDebug.extend("downloadBinary"); | ||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
debug("downloading binary from:", url.href); | ||
(0, node_fetch_1.default)(url.href, { | ||
@@ -76,2 +101,3 @@ redirect: "follow", | ||
function pipeBinaryToInstallLocation(res, originalUrl) { | ||
const debug = rootDebug.extend("pipeBinaryToInstallLocation"); | ||
return new Promise((resolve, reject) => { | ||
@@ -82,5 +108,7 @@ if (!res.body) { | ||
const targetPath = path_1.default.resolve("./bin"); | ||
debug("targetPath:", targetPath); | ||
const strategies = { | ||
[KnownExtension.Tar]: () => { | ||
var _a; | ||
debug("unpacking using tar strategy"); | ||
const untar = tar_1.default.extract({ cwd: targetPath }); | ||
@@ -92,7 +120,11 @@ untar.on("error", reject); | ||
[KnownExtension.Zip]: () => { | ||
var _a; | ||
const unzip = unzipper_1.default.Extract({ path: targetPath }); | ||
unzip.on("error", reject); | ||
unzip.on("close", () => resolve()); | ||
(_a = res.body) === null || _a === void 0 ? void 0 : _a.pipe(unzip); | ||
debug("unpacking using zip strategy"); | ||
res | ||
.buffer() | ||
.then((buffer) => { | ||
const zip = new adm_zip_1.default(buffer); | ||
zip.extractAllTo(targetPath, true); | ||
resolve(); | ||
}) | ||
.catch(reject); | ||
}, | ||
@@ -110,3 +142,5 @@ }; | ||
(() => __awaiter(void 0, void 0, void 0, function* () { | ||
rootDebug("postinstall started"); | ||
if (process.env.SKIP_POSTINSTALL) { | ||
rootDebug("SKIP_POSTINSTALL was defined; skipping postinstall"); | ||
process.exit(0); | ||
@@ -118,2 +152,3 @@ } | ||
yield pipeBinaryToInstallLocation(req, binaryUrl); | ||
rootDebug("postinstall complete"); | ||
} | ||
@@ -120,0 +155,0 @@ catch (err) { |
15886
5
150
4
6
+ Addedadm-zip@^0.5.10
+ Addeddebug@^4.3.4
+ Addedadm-zip@0.5.16(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedms@2.1.3(transitive)
- Removedunzipper@0.10.11
- Removedbalanced-match@1.0.2(transitive)
- Removedbig-integer@1.6.52(transitive)
- Removedbinary@0.3.0(transitive)
- Removedbluebird@3.4.7(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbuffer-indexof-polyfill@1.0.2(transitive)
- Removedbuffers@0.1.1(transitive)
- Removedchainsaw@0.1.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfstream@1.0.12(transitive)
- Removedglob@7.2.3(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlistenercount@1.0.1(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtraverse@0.3.9(transitive)
- Removedunzipper@0.10.11(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwrappy@1.0.2(transitive)