certctl-cli 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -4
  2. package/scripts/install.js +3 -86
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "certctl-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "轻量级 SSL 证书申请工具 / Lightweight SSL Certificate CLI Tool",
5
5
  "bin": {
6
6
  "certctl": "./bin/run.js"
7
7
  },
8
- "scripts": {
9
- "postinstall": "node scripts/install.js"
10
- },
11
8
  "keywords": [
12
9
  "ssl",
13
10
  "certificate",
@@ -1,86 +1,3 @@
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();
1
+ #!/usr/bin/env node
2
+ // 二进制文件已包含在包中,无需下载
3
+ console.log('certctl installed successfully!');