@guanzhu.me/usql 0.19.12-ipass.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 +15 -0
- package/bin/usql.mjs +120 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2025 Kenneth Shaw
|
|
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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @guanzhu.me/usql
|
|
2
|
+
|
|
3
|
+
通过影刀 iPaaS 执行数据库查询的 usql 定制发行包,基于 [xo/usql](https://github.com/xo/usql),源码位于 [wn0x00/usql](https://github.com/wn0x00/usql)。
|
|
4
|
+
|
|
5
|
+
需要 Node.js 20 或以上版本。支持 Linux 与 macOS 的 x64、arm64,以及 Windows x64。
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -g @guanzhu.me/usql@0.19.12-ipass.1
|
|
9
|
+
usql --version
|
|
10
|
+
usql --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
请保留 npm 可选依赖,它们包含对应平台的原生程序。启动器不下载程序、不执行安装脚本,并透传参数、环境变量、标准输入输出及退出状态。数据库网关配置请参阅源码仓库文档。
|
|
14
|
+
|
|
15
|
+
MIT 许可证见 LICENSE。
|
package/bin/usql.mjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { realpathSync, statSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { constants } from 'node:os';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const packageName = '@guanzhu.me/usql';
|
|
11
|
+
const platforms = new Set([
|
|
12
|
+
'linux-x64', 'linux-arm64', 'darwin-x64', 'darwin-arm64', 'win32-x64',
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
export function selectPlatform(platform = process.platform, arch = process.arch) {
|
|
16
|
+
const id = `${platform}-${arch}`;
|
|
17
|
+
if (!platforms.has(id)) {
|
|
18
|
+
throw new Error(`Unsupported platform: ${id}. Supported platforms: ${[...platforms].join(', ')}.`);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
id,
|
|
22
|
+
packageName: `${packageName}-${id}`,
|
|
23
|
+
binary: platform === 'win32' ? 'usql.exe' : 'usql',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resolveBinary({
|
|
28
|
+
platform = process.platform,
|
|
29
|
+
arch = process.arch,
|
|
30
|
+
resolveModule = require.resolve,
|
|
31
|
+
} = {}) {
|
|
32
|
+
const target = selectPlatform(platform, arch);
|
|
33
|
+
const modulePath = `${target.packageName}/bin/${target.binary}`;
|
|
34
|
+
try {
|
|
35
|
+
const binary = resolveModule(modulePath);
|
|
36
|
+
if (!statSync(binary).isFile()) throw new Error('The binary is not a regular file.');
|
|
37
|
+
return binary;
|
|
38
|
+
} catch (cause) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Cannot load ${target.packageName}. Reinstall ${packageName} with optional dependencies enabled (npm install -g ${packageName} --include=optional).`,
|
|
41
|
+
{ cause },
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Injectable process/spawn objects make signal and failure behavior testable on every OS.
|
|
47
|
+
export function launch(argv = process.argv.slice(2), {
|
|
48
|
+
runtime = process,
|
|
49
|
+
spawnProcess = spawn,
|
|
50
|
+
findBinary = resolveBinary,
|
|
51
|
+
} = {}) {
|
|
52
|
+
const binary = findBinary({ platform: runtime.platform, arch: runtime.arch });
|
|
53
|
+
return new Promise((accept, reject) => {
|
|
54
|
+
let child;
|
|
55
|
+
const signals = runtime.platform === 'win32'
|
|
56
|
+
? ['SIGINT', 'SIGTERM', 'SIGBREAK']
|
|
57
|
+
: ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
58
|
+
const listeners = new Map();
|
|
59
|
+
const cleanup = () => {
|
|
60
|
+
for (const [signal, listener] of listeners) runtime.removeListener(signal, listener);
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
child = spawnProcess(binary, argv, {
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
env: runtime.env,
|
|
66
|
+
shell: false,
|
|
67
|
+
});
|
|
68
|
+
for (const signal of signals) {
|
|
69
|
+
const listener = () => {
|
|
70
|
+
try {
|
|
71
|
+
child.kill(signal);
|
|
72
|
+
} catch (cause) {
|
|
73
|
+
cleanup();
|
|
74
|
+
reject(new Error(`Failed to forward ${signal} to usql.`, { cause }));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
listeners.set(signal, listener);
|
|
78
|
+
runtime.on(signal, listener);
|
|
79
|
+
}
|
|
80
|
+
child.once('error', (cause) => {
|
|
81
|
+
cleanup();
|
|
82
|
+
reject(new Error('Failed to start the usql native executable.', { cause }));
|
|
83
|
+
});
|
|
84
|
+
child.once('exit', (code, signal) => {
|
|
85
|
+
cleanup();
|
|
86
|
+
accept({ code: Number.isInteger(code) ? code : 1, signal });
|
|
87
|
+
});
|
|
88
|
+
} catch (cause) {
|
|
89
|
+
cleanup();
|
|
90
|
+
reject(new Error('Failed to start the usql native executable.', { cause }));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function applyExit({ code, signal }, runtime = process) {
|
|
96
|
+
if (!signal) {
|
|
97
|
+
runtime.exitCode = Number.isInteger(code) ? code : 1;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Re-raise the child's signal after removing the forwarding listeners. Windows
|
|
101
|
+
// does not implement every POSIX signal, so preserve a nonzero fallback there.
|
|
102
|
+
runtime.exitCode = 128 + (constants.signals[signal] || 1);
|
|
103
|
+
try {
|
|
104
|
+
runtime.kill(runtime.pid, signal);
|
|
105
|
+
} catch {
|
|
106
|
+
// The fallback exit code above also covers unsupported signal delivery.
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (process.argv[1] && realpathSync(resolve(process.argv[1])) === fileURLToPath(import.meta.url)) {
|
|
111
|
+
try {
|
|
112
|
+
if (Number(process.versions.node.split('.')[0]) < 20) {
|
|
113
|
+
throw new Error('usql requires Node.js 20 or newer.');
|
|
114
|
+
}
|
|
115
|
+
applyExit(await launch());
|
|
116
|
+
} catch (error) {
|
|
117
|
+
process.stderr.write(`usql: ${error.message}\n`);
|
|
118
|
+
process.exitCode = 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@guanzhu.me/usql",
|
|
3
|
+
"version": "0.19.12-ipass.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/wn0x00/usql.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/wn0x00/usql#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/wn0x00/usql/issues"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"description": "通过影刀 iPaaS 执行数据库查询的 usql 定制发行包",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"usql",
|
|
22
|
+
"sql",
|
|
23
|
+
"ipass",
|
|
24
|
+
"yingdao"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"usql": "bin/usql.mjs"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/usql.mjs",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"optionalDependencies": {
|
|
36
|
+
"@guanzhu.me/usql-linux-x64": "0.19.12-ipass.1",
|
|
37
|
+
"@guanzhu.me/usql-linux-arm64": "0.19.12-ipass.1",
|
|
38
|
+
"@guanzhu.me/usql-darwin-x64": "0.19.12-ipass.1",
|
|
39
|
+
"@guanzhu.me/usql-darwin-arm64": "0.19.12-ipass.1",
|
|
40
|
+
"@guanzhu.me/usql-win32-x64": "0.19.12-ipass.1"
|
|
41
|
+
}
|
|
42
|
+
}
|