@blazium-games/cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +9 -2
- package/bin/chauffeur.js +153 -0
- package/package.json +34 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Blazium Games
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @blazium-games/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`chauffeur` uploads builds, debug symbols, and store images to Blazium Games.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g @blazium-games/cli
|
|
7
|
+
chauffeur --version
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Platform packages ship the binary. If one is missing, this wrapper downloads the public CDN archive for that OS.
|
package/bin/chauffeur.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync, spawnSync } = require("child_process");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
|
|
10
|
+
function fail(message) {
|
|
11
|
+
console.error(message);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function platformTarget(platform, arch) {
|
|
16
|
+
const table = {
|
|
17
|
+
"linux:x64": { cdn: "linux-amd64", exe: "chauffeur" },
|
|
18
|
+
"linux:arm64": { cdn: "linux-arm64", exe: "chauffeur" },
|
|
19
|
+
"win32:x64": { cdn: "windows-amd64", exe: "chauffeur.exe" },
|
|
20
|
+
"darwin:x64": { cdn: "darwin-amd64", exe: "chauffeur" },
|
|
21
|
+
"darwin:arm64": { cdn: "darwin-arm64", exe: "chauffeur" },
|
|
22
|
+
};
|
|
23
|
+
return table[`${platform}:${arch}`] || null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function optionalBin(pkgName, exe) {
|
|
27
|
+
let pkgJson;
|
|
28
|
+
try {
|
|
29
|
+
pkgJson = require.resolve(`${pkgName}/package.json`);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err && (err.code === "MODULE_NOT_FOUND" || /Cannot find module/.test(String(err.message)))) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
const bin = path.join(path.dirname(pkgJson), "bin", exe);
|
|
37
|
+
if (!fs.existsSync(bin)) {
|
|
38
|
+
fail(`Optional package ${pkgName} is installed but ${bin} is missing.`);
|
|
39
|
+
}
|
|
40
|
+
return bin;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function cacheFile(exe) {
|
|
44
|
+
const base =
|
|
45
|
+
process.platform === "win32"
|
|
46
|
+
? process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local")
|
|
47
|
+
: path.join(os.homedir(), ".cache");
|
|
48
|
+
return path.join(base, "blazium-games", "npm-cli", "latest", exe);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function fetchBuffer(url, redirectsLeft) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
if (!url.startsWith("https:")) {
|
|
54
|
+
reject(new Error(`Refusing non-https URL`));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const req = https.get(url, (res) => {
|
|
58
|
+
const code = res.statusCode || 0;
|
|
59
|
+
if (code >= 300 && code < 400 && res.headers.location) {
|
|
60
|
+
res.resume();
|
|
61
|
+
if (redirectsLeft <= 0) {
|
|
62
|
+
reject(new Error("Too many redirects"));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const next = new URL(res.headers.location, url).href;
|
|
66
|
+
resolve(fetchBuffer(next, redirectsLeft - 1));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (code !== 200) {
|
|
70
|
+
res.resume();
|
|
71
|
+
reject(new Error(`HTTP ${code}`));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const chunks = [];
|
|
75
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
76
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
77
|
+
});
|
|
78
|
+
req.on("error", reject);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function unpack(zipPath, dest, exe) {
|
|
83
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
84
|
+
if (process.platform === "win32") {
|
|
85
|
+
const named = `${zipPath}.zip`;
|
|
86
|
+
fs.copyFileSync(zipPath, named);
|
|
87
|
+
execFileSync("powershell.exe", [
|
|
88
|
+
"-NoProfile",
|
|
89
|
+
"-NonInteractive",
|
|
90
|
+
"-Command",
|
|
91
|
+
`Expand-Archive -Force -LiteralPath '${named.replace(/'/g, "''")}' -DestinationPath '${dest.replace(/'/g, "''")}'`,
|
|
92
|
+
]);
|
|
93
|
+
} else {
|
|
94
|
+
execFileSync("unzip", ["-o", zipPath, "-d", dest]);
|
|
95
|
+
}
|
|
96
|
+
const bin = path.join(dest, exe);
|
|
97
|
+
if (!fs.existsSync(bin)) {
|
|
98
|
+
fail(`CDN archive did not contain ${exe}`);
|
|
99
|
+
}
|
|
100
|
+
if (process.platform !== "win32") {
|
|
101
|
+
fs.chmodSync(bin, 0o755);
|
|
102
|
+
}
|
|
103
|
+
return bin;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function downloadBinary(spec, dest) {
|
|
107
|
+
const url = `https://cdn.blazium.online/tools/chauffeur/${spec.cdn}/latest/archive/default`;
|
|
108
|
+
const body = await fetchBuffer(url, 5);
|
|
109
|
+
const zip = `${dest}.zip`;
|
|
110
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
111
|
+
fs.writeFileSync(zip, body);
|
|
112
|
+
return unpack(zip, path.dirname(dest), spec.exe);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function run(bin) {
|
|
116
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
117
|
+
if (result.error) {
|
|
118
|
+
fail(result.error.message);
|
|
119
|
+
}
|
|
120
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function main() {
|
|
124
|
+
const spec = platformTarget(process.platform, process.arch);
|
|
125
|
+
if (!spec) {
|
|
126
|
+
fail(
|
|
127
|
+
`No @blazium-games/cli binary for ${process.platform}/${process.arch}. ` +
|
|
128
|
+
"Supported: linux x64/arm64, darwin x64/arm64, win32 x64."
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const pkgName = `@blazium-games/cli-${process.platform}-${process.arch}`;
|
|
133
|
+
const installed = optionalBin(pkgName, spec.exe);
|
|
134
|
+
if (installed) {
|
|
135
|
+
run(installed);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const cached = cacheFile(spec.exe);
|
|
140
|
+
if (fs.existsSync(cached)) {
|
|
141
|
+
run(cached);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
console.error(`Optional package ${pkgName} is not installed. Downloading chauffeur from the CDN.`);
|
|
146
|
+
run(await downloadBinary(spec, cached));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (require.main === module) {
|
|
150
|
+
main().catch((err) => fail(err && err.message ? err.message : String(err)));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = { platformTarget, cacheFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazium-games/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "chauffeur, the Blazium Games upload tool for builds, symbols, and store images.",
|
|
5
|
+
"repository": "https://github.com/blazium-games/games_cli",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"chauffeur": "bin/chauffeur.js"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/chauffeur.js",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@blazium-games/cli-linux-x64": "0.1.1",
|
|
20
|
+
"@blazium-games/cli-linux-arm64": "0.1.1",
|
|
21
|
+
"@blazium-games/cli-win32-x64": "0.1.1",
|
|
22
|
+
"@blazium-games/cli-darwin-x64": "0.1.1",
|
|
23
|
+
"@blazium-games/cli-darwin-arm64": "0.1.1"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://blazium.games",
|
|
29
|
+
"bugs": "https://github.com/blazium-games/support/issues",
|
|
30
|
+
"author": "Blazium Games",
|
|
31
|
+
"keywords": [
|
|
32
|
+
"blazium",
|
|
33
|
+
"chauffeur",
|
|
34
|
+
"cli"
|
|
35
|
+
]
|
|
36
|
+
}
|