certctl-cli 1.0.0
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/README.md +31 -0
- package/bin/certctl-darwin-amd64 +0 -0
- package/bin/certctl-darwin-arm64 +0 -0
- package/bin/certctl-linux-amd64 +0 -0
- package/bin/certctl-linux-arm64 +0 -0
- package/bin/certctl-windows-amd64.exe +0 -0
- package/bin/run.js +50 -0
- package/package.json +34 -0
- package/scripts/install.js +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @z_ai/certctl
|
|
2
|
+
|
|
3
|
+
轻量级 SSL 证书申请工具,支持通配符证书 & 阿里云 DNS 自动验证。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @z_ai/certctl
|
|
9
|
+
# 或
|
|
10
|
+
npx @z_ai/certctl apply -d example.com
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 使用
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 手动 DNS 验证
|
|
17
|
+
certctl apply -d example.com
|
|
18
|
+
|
|
19
|
+
# 阿里云 DNS 自动验证
|
|
20
|
+
certctl apply -d example.com --dns aliyun
|
|
21
|
+
|
|
22
|
+
# 查看证书
|
|
23
|
+
certctl list
|
|
24
|
+
|
|
25
|
+
# 续期证书
|
|
26
|
+
certctl renew -d example.com
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
MIT
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
function getBinaryName() {
|
|
9
|
+
const platform = os.platform();
|
|
10
|
+
const arch = os.arch();
|
|
11
|
+
|
|
12
|
+
let name = 'certctl';
|
|
13
|
+
|
|
14
|
+
if (platform === 'win32') {
|
|
15
|
+
name += '-windows';
|
|
16
|
+
} else if (platform === 'darwin') {
|
|
17
|
+
name += '-darwin';
|
|
18
|
+
} else {
|
|
19
|
+
name += '-linux';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (arch === 'arm64') {
|
|
23
|
+
name += '-arm64';
|
|
24
|
+
} else {
|
|
25
|
+
name += '-amd64';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (platform === 'win32') {
|
|
29
|
+
name += '.exe';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return name;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const binaryPath = path.join(__dirname, getBinaryName());
|
|
36
|
+
|
|
37
|
+
if (!fs.existsSync(binaryPath)) {
|
|
38
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
39
|
+
console.error('Please run: npm run postinstall');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
44
|
+
stdio: 'inherit',
|
|
45
|
+
env: process.env
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
child.on('exit', (code) => {
|
|
49
|
+
process.exit(code || 0);
|
|
50
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "certctl-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "轻量级 SSL 证书申请工具 / Lightweight SSL Certificate CLI Tool",
|
|
5
|
+
"bin": {
|
|
6
|
+
"certctl": "./bin/run.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/install.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"ssl",
|
|
13
|
+
"certificate",
|
|
14
|
+
"letsencrypt",
|
|
15
|
+
"acme",
|
|
16
|
+
"dns",
|
|
17
|
+
"cli"
|
|
18
|
+
],
|
|
19
|
+
"author": "cuijianzhong",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/cuijianzhong/certctl"
|
|
24
|
+
},
|
|
25
|
+
"os": [
|
|
26
|
+
"darwin",
|
|
27
|
+
"linux",
|
|
28
|
+
"win32"
|
|
29
|
+
],
|
|
30
|
+
"cpu": [
|
|
31
|
+
"x64",
|
|
32
|
+
"arm64"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const VERSION = '1.0.0';
|
|
7
|
+
const REPO = 'z_ai/certctl';
|
|
8
|
+
const BASE_URL = `https://github.com/${REPO}/releases/download/v${VERSION}`;
|
|
9
|
+
|
|
10
|
+
function getBinaryName() {
|
|
11
|
+
const platform = os.platform();
|
|
12
|
+
const arch = os.arch();
|
|
13
|
+
|
|
14
|
+
let name = 'certctl';
|
|
15
|
+
|
|
16
|
+
if (platform === 'win32') {
|
|
17
|
+
name += '-windows';
|
|
18
|
+
} else if (platform === 'darwin') {
|
|
19
|
+
name += '-darwin';
|
|
20
|
+
} else {
|
|
21
|
+
name += '-linux';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (arch === 'arm64') {
|
|
25
|
+
name += '-arm64';
|
|
26
|
+
} else {
|
|
27
|
+
name += '-amd64';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (platform === 'win32') {
|
|
31
|
+
name += '.exe';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return name;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function download(url, dest) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const file = fs.createWriteStream(dest);
|
|
40
|
+
|
|
41
|
+
https.get(url, (response) => {
|
|
42
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
43
|
+
download(response.headers.location, dest).then(resolve).catch(reject);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (response.statusCode !== 200) {
|
|
48
|
+
reject(new Error(`Download failed: ${response.statusCode}`));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
response.pipe(file);
|
|
53
|
+
file.on('finish', () => {
|
|
54
|
+
file.close();
|
|
55
|
+
fs.chmodSync(dest, 0o755);
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
}).on('error', reject);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function main() {
|
|
63
|
+
const binaryName = getBinaryName();
|
|
64
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
65
|
+
const dest = path.join(binDir, binaryName);
|
|
66
|
+
|
|
67
|
+
if (fs.existsSync(dest)) {
|
|
68
|
+
console.log('Binary already exists');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const url = `${BASE_URL}/${binaryName}`;
|
|
73
|
+
console.log(`Downloading ${binaryName}...`);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await download(url, dest);
|
|
77
|
+
console.log('Download complete!');
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(`Download failed: ${err.message}`);
|
|
80
|
+
console.log('\nYou can manually build the binary:');
|
|
81
|
+
console.log(' cd certctl && go build -o npm-package/bin/' + binaryName);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
main();
|