inngest-cli 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/inngest +0 -0
- package/package.json +39 -0
- package/postinstall.js +115 -0
package/bin/inngest
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "inngest-cli",
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "The event-driven queue for any language.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepublishOnly": "mkdir bin && touch bin/inngest",
|
|
8
|
+
"postinstall": "node postinstall.js",
|
|
9
|
+
"build": "tsc"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"inngest": "./bin/inngest"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/inngest/inngest.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/inngest/inngest",
|
|
19
|
+
"files": [
|
|
20
|
+
"bin",
|
|
21
|
+
"LICENSE.md",
|
|
22
|
+
"postinstall.js"
|
|
23
|
+
],
|
|
24
|
+
"volta": {
|
|
25
|
+
"node": "16.16.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"node-fetch": "2.6.7",
|
|
29
|
+
"tar": "6.1.11",
|
|
30
|
+
"unzipper": "0.10.11"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node-fetch": "2.6.2",
|
|
34
|
+
"@types/request": "2.48.8",
|
|
35
|
+
"@types/tar": "6.1.1",
|
|
36
|
+
"@types/unzipper": "0.10.5",
|
|
37
|
+
"typescript": "4.7.4"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const tar_1 = __importDefault(require("tar"));
|
|
18
|
+
const unzipper_1 = __importDefault(require("unzipper"));
|
|
19
|
+
const url_1 = require("url");
|
|
20
|
+
const archMap = {
|
|
21
|
+
arm64: "arm64",
|
|
22
|
+
x64: "x86_64",
|
|
23
|
+
};
|
|
24
|
+
var KnownExtension;
|
|
25
|
+
(function (KnownExtension) {
|
|
26
|
+
KnownExtension["Tar"] = ".tar.gz";
|
|
27
|
+
KnownExtension["Zip"] = ".zip";
|
|
28
|
+
})(KnownExtension || (KnownExtension = {}));
|
|
29
|
+
const platformMap = {
|
|
30
|
+
linux: { platform: "linux", extension: KnownExtension.Tar },
|
|
31
|
+
darwin: { platform: "darwin", extension: KnownExtension.Tar },
|
|
32
|
+
win32: { platform: "windows", extension: KnownExtension.Zip },
|
|
33
|
+
};
|
|
34
|
+
function getBinaryUrl() {
|
|
35
|
+
var _a;
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const version = (_a = process.env.npm_package_version) === null || _a === void 0 ? void 0 : _a.trim();
|
|
38
|
+
if (!version) {
|
|
39
|
+
throw new Error("Could not find package version to install binary");
|
|
40
|
+
}
|
|
41
|
+
const { arch, platform } = getArchPlatform();
|
|
42
|
+
const targetUrl = new url_1.URL(`https://cli.inngest.com/artifact/v${version}/inngest_${version}_${platform.platform}_${arch}${platform.extension}`);
|
|
43
|
+
return targetUrl;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function getArchPlatform() {
|
|
47
|
+
const arch = archMap[process.arch];
|
|
48
|
+
const platform = platformMap[process.platform];
|
|
49
|
+
if (!arch) {
|
|
50
|
+
throw new Error(`Unsupported architecture: ${process.arch}`);
|
|
51
|
+
}
|
|
52
|
+
if (!platform) {
|
|
53
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
54
|
+
}
|
|
55
|
+
return { arch, platform };
|
|
56
|
+
}
|
|
57
|
+
function downloadBinary(url) {
|
|
58
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
(0, node_fetch_1.default)(url.href, {
|
|
60
|
+
redirect: "follow",
|
|
61
|
+
})
|
|
62
|
+
.then((res) => {
|
|
63
|
+
if (res.status !== 200) {
|
|
64
|
+
throw new Error(`Error downloading binary; invalid response status code: ${res.status}`);
|
|
65
|
+
}
|
|
66
|
+
resolve(res);
|
|
67
|
+
})
|
|
68
|
+
.catch(reject);
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
function pipeBinaryToInstallLocation(res, originalUrl) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
if (!res.body) {
|
|
74
|
+
return reject(new Error("No body to pipe"));
|
|
75
|
+
}
|
|
76
|
+
const targetPath = path_1.default.resolve("./bin");
|
|
77
|
+
const strategies = {
|
|
78
|
+
[KnownExtension.Tar]: () => {
|
|
79
|
+
var _a;
|
|
80
|
+
const untar = tar_1.default.extract({ cwd: targetPath });
|
|
81
|
+
untar.on("error", reject);
|
|
82
|
+
untar.on("end", () => resolve());
|
|
83
|
+
(_a = res.body) === null || _a === void 0 ? void 0 : _a.pipe(untar);
|
|
84
|
+
},
|
|
85
|
+
[KnownExtension.Zip]: () => {
|
|
86
|
+
var _a;
|
|
87
|
+
const unzip = unzipper_1.default.Extract({ path: targetPath });
|
|
88
|
+
unzip.on("error", reject);
|
|
89
|
+
unzip.on("close", () => resolve());
|
|
90
|
+
(_a = res.body) === null || _a === void 0 ? void 0 : _a.pipe(unzip);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
const [, strategy] = Object.entries(strategies).find(([knownExt]) => {
|
|
94
|
+
return originalUrl.pathname.endsWith(knownExt);
|
|
95
|
+
}) || [, null];
|
|
96
|
+
if (!strategy) {
|
|
97
|
+
return reject(new Error("Unsupported extension"));
|
|
98
|
+
}
|
|
99
|
+
strategy();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
if (process.env.SKIP_POSTINSTALL) {
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const binaryUrl = yield getBinaryUrl();
|
|
108
|
+
const req = yield downloadBinary(binaryUrl);
|
|
109
|
+
yield pipeBinaryToInstallLocation(req, binaryUrl);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
console.error(err);
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
}))();
|