toss-openapi-cli 0.1.2
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/tosscli.js +68 -0
- package/package.json +20 -0
package/bin/tosscli.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync, spawnSync } = require("node:child_process");
|
|
5
|
+
const { globalPaths } = require("node:module");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
|
|
8
|
+
const packages = {
|
|
9
|
+
"darwin arm64": "@finetension/tosscli-darwin-arm64",
|
|
10
|
+
"darwin x64": "@finetension/tosscli-darwin-x64",
|
|
11
|
+
"linux arm64": "@finetension/tosscli-linux-arm64",
|
|
12
|
+
"linux x64": "@finetension/tosscli-linux-x64",
|
|
13
|
+
"win32 x64": "@finetension/tosscli-win32-x64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const key = `${process.platform} ${process.arch}`;
|
|
17
|
+
const packageName = packages[key];
|
|
18
|
+
|
|
19
|
+
if (!packageName) {
|
|
20
|
+
console.error(`tosscli: unsupported platform: ${key}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binaryName = process.platform === "win32" ? "tosscli.exe" : "tosscli";
|
|
25
|
+
let binaryPath;
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
binaryPath = require.resolve(`${packageName}/bin/${binaryName}`);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
const paths = [
|
|
31
|
+
path.join(__dirname, "node_modules"),
|
|
32
|
+
path.join(__dirname, ".."),
|
|
33
|
+
...globalPaths,
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const npmRoot = execFileSync("npm", ["root", "-g"], {
|
|
38
|
+
encoding: "utf8",
|
|
39
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
40
|
+
}).trim();
|
|
41
|
+
if (npmRoot) {
|
|
42
|
+
paths.unshift(npmRoot);
|
|
43
|
+
}
|
|
44
|
+
} catch (_) {
|
|
45
|
+
// npm may not be available when this shim is invoked from a bundled context.
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
binaryPath = require.resolve(`${packageName}/bin/${binaryName}`, { paths });
|
|
50
|
+
} catch (_) {
|
|
51
|
+
console.error(`tosscli: platform package is missing: ${packageName}`);
|
|
52
|
+
console.error("Reinstall with optional dependencies enabled:");
|
|
53
|
+
console.error(" npm install -g toss-openapi-cli");
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
windowsHide: false,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (result.error) {
|
|
64
|
+
console.error(`tosscli: failed to execute ${binaryPath}: ${result.error.message}`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "toss-openapi-cli",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Unofficial CLI for public Toss Open APIs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tosscli": "bin/tosscli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": ["bin"],
|
|
10
|
+
"optionalDependencies": {
|
|
11
|
+
"@finetension/tosscli-darwin-arm64": "0.1.2",
|
|
12
|
+
"@finetension/tosscli-darwin-x64": "0.1.2",
|
|
13
|
+
"@finetension/tosscli-linux-arm64": "0.1.2",
|
|
14
|
+
"@finetension/tosscli-linux-x64": "0.1.2",
|
|
15
|
+
"@finetension/tosscli-win32-x64": "0.1.2"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
}
|
|
20
|
+
}
|