@fulgur-rs/cli 0.5.13 → 0.5.14
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 +5 -4
- package/bin/fulgur +51 -0
- package/package.json +8 -12
- package/install.js +0 -89
package/README.md
CHANGED
|
@@ -177,10 +177,11 @@ of the `@fulgur-rs/cli-<platform>` packages above, all declared as
|
|
|
177
177
|
npm only installs the one that matches the current `os` / `cpu` / libc, so
|
|
178
178
|
there is no per-platform bloat and no cross-compilation at install time.
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
The `bin/fulgur` entry is a small JavaScript shim that, at run time, resolves
|
|
181
|
+
the platform package via `require.resolve` and execs its native binary. There
|
|
182
|
+
is no `postinstall` step, so `npx @fulgur-rs/cli` works on the very first run.
|
|
183
|
+
If you install with `--ignore-optional` or on an unsupported platform, the
|
|
184
|
+
shim exits with a clear error message.
|
|
184
185
|
|
|
185
186
|
## Links
|
|
186
187
|
|
package/bin/fulgur
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
|
|
8
|
+
const PLATFORMS = {
|
|
9
|
+
'linux-x64': { pkg: '@fulgur-rs/cli-linux-x64', bin: 'fulgur' },
|
|
10
|
+
'linux-x64-musl': { pkg: '@fulgur-rs/cli-linux-x64-musl', bin: 'fulgur' },
|
|
11
|
+
'linux-arm64': { pkg: '@fulgur-rs/cli-linux-arm64', bin: 'fulgur' },
|
|
12
|
+
'darwin-arm64': { pkg: '@fulgur-rs/cli-darwin-arm64', bin: 'fulgur' },
|
|
13
|
+
'darwin-x64': { pkg: '@fulgur-rs/cli-darwin-x64', bin: 'fulgur' },
|
|
14
|
+
'win32-x64': { pkg: '@fulgur-rs/cli-win32-x64', bin: 'fulgur.exe' },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function isMusl() {
|
|
18
|
+
try { return fs.readFileSync('/proc/self/maps', 'utf8').includes('musl'); }
|
|
19
|
+
catch { return false; }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function detectPlatformKey() {
|
|
23
|
+
const { platform, arch } = process;
|
|
24
|
+
if (platform === 'linux' && arch === 'x64') return isMusl() ? 'linux-x64-musl' : 'linux-x64';
|
|
25
|
+
if (platform === 'linux' && arch === 'arm64') return 'linux-arm64';
|
|
26
|
+
if (platform === 'darwin' && arch === 'arm64') return 'darwin-arm64';
|
|
27
|
+
if (platform === 'darwin' && arch === 'x64') return 'darwin-x64';
|
|
28
|
+
if (platform === 'win32' && arch === 'x64') return 'win32-x64';
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const key = detectPlatformKey();
|
|
33
|
+
if (!key) {
|
|
34
|
+
process.stderr.write(`@fulgur-rs/cli: unsupported platform ${process.platform}/${process.arch}\n`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { pkg, bin } = PLATFORMS[key];
|
|
39
|
+
let pkgDir;
|
|
40
|
+
try {
|
|
41
|
+
pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
|
|
42
|
+
} catch {
|
|
43
|
+
process.stderr.write(
|
|
44
|
+
`@fulgur-rs/cli: platform package ${pkg} not found.\n` +
|
|
45
|
+
`This usually means it was not installed (e.g. --ignore-optional was used).\n`
|
|
46
|
+
);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const r = spawnSync(path.join(pkgDir, 'bin', bin), process.argv.slice(2), { stdio: 'inherit' });
|
|
51
|
+
process.exit(r.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fulgur-rs/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"description": "HTML to PDF conversion CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"html",
|
|
@@ -17,18 +17,14 @@
|
|
|
17
17
|
"fulgur": "bin/fulgur"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"bin/"
|
|
21
|
-
"install.js"
|
|
20
|
+
"bin/"
|
|
22
21
|
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"postinstall": "node install.js"
|
|
25
|
-
},
|
|
26
22
|
"optionalDependencies": {
|
|
27
|
-
"@fulgur-rs/cli-linux-x64": "0.5.
|
|
28
|
-
"@fulgur-rs/cli-linux-x64-musl": "0.5.
|
|
29
|
-
"@fulgur-rs/cli-linux-arm64": "0.5.
|
|
30
|
-
"@fulgur-rs/cli-darwin-arm64": "0.5.
|
|
31
|
-
"@fulgur-rs/cli-darwin-x64": "0.5.
|
|
32
|
-
"@fulgur-rs/cli-win32-x64": "0.5.
|
|
23
|
+
"@fulgur-rs/cli-linux-x64": "0.5.14",
|
|
24
|
+
"@fulgur-rs/cli-linux-x64-musl": "0.5.14",
|
|
25
|
+
"@fulgur-rs/cli-linux-arm64": "0.5.14",
|
|
26
|
+
"@fulgur-rs/cli-darwin-arm64": "0.5.14",
|
|
27
|
+
"@fulgur-rs/cli-darwin-x64": "0.5.14",
|
|
28
|
+
"@fulgur-rs/cli-win32-x64": "0.5.14"
|
|
33
29
|
}
|
|
34
30
|
}
|
package/install.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
const PLATFORMS = {
|
|
8
|
-
'linux-x64': { os: 'linux', cpu: 'x64', pkg: '@fulgur-rs/cli-linux-x64', bin: 'fulgur' },
|
|
9
|
-
'linux-x64-musl': { os: 'linux', cpu: 'x64', pkg: '@fulgur-rs/cli-linux-x64-musl', bin: 'fulgur' },
|
|
10
|
-
'linux-arm64': { os: 'linux', cpu: 'arm64', pkg: '@fulgur-rs/cli-linux-arm64', bin: 'fulgur' },
|
|
11
|
-
'darwin-arm64': { os: 'darwin', cpu: 'arm64', pkg: '@fulgur-rs/cli-darwin-arm64', bin: 'fulgur' },
|
|
12
|
-
'darwin-x64': { os: 'darwin', cpu: 'x64', pkg: '@fulgur-rs/cli-darwin-x64', bin: 'fulgur' },
|
|
13
|
-
'win32-x64': { os: 'win32', cpu: 'x64', pkg: '@fulgur-rs/cli-win32-x64', bin: 'fulgur.exe' },
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function isMusl() {
|
|
17
|
-
try {
|
|
18
|
-
const maps = fs.readFileSync('/proc/self/maps', 'utf8');
|
|
19
|
-
return maps.includes('musl');
|
|
20
|
-
} catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function detectPlatformKey() {
|
|
26
|
-
const os = process.platform;
|
|
27
|
-
const cpu = process.arch;
|
|
28
|
-
|
|
29
|
-
if (os === 'linux' && cpu === 'x64') {
|
|
30
|
-
return isMusl() ? 'linux-x64-musl' : 'linux-x64';
|
|
31
|
-
}
|
|
32
|
-
if (os === 'linux' && cpu === 'arm64') return 'linux-arm64';
|
|
33
|
-
if (os === 'darwin' && cpu === 'arm64') return 'darwin-arm64';
|
|
34
|
-
if (os === 'darwin' && cpu === 'x64') return 'darwin-x64';
|
|
35
|
-
if (os === 'win32' && cpu === 'x64') return 'win32-x64';
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const platformKey = detectPlatformKey();
|
|
40
|
-
if (!platformKey) {
|
|
41
|
-
process.stderr.write(
|
|
42
|
-
`@fulgur-rs/cli: unsupported platform ${process.platform}/${process.arch}\n`
|
|
43
|
-
);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const platform = PLATFORMS[platformKey];
|
|
48
|
-
let pkgDir;
|
|
49
|
-
try {
|
|
50
|
-
pkgDir = path.dirname(require.resolve(`${platform.pkg}/package.json`));
|
|
51
|
-
} catch {
|
|
52
|
-
process.stderr.write(
|
|
53
|
-
`@fulgur-rs/cli: platform package ${platform.pkg} not found.\n` +
|
|
54
|
-
`This usually means it was not installed (e.g., --ignore-optional was used).\n`
|
|
55
|
-
);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const src = path.join(pkgDir, 'bin', platform.bin);
|
|
60
|
-
const destDir = path.join(__dirname, 'bin');
|
|
61
|
-
const dest = path.join(destDir, platform.bin);
|
|
62
|
-
|
|
63
|
-
if (!fs.existsSync(src)) {
|
|
64
|
-
process.stderr.write(
|
|
65
|
-
`@fulgur-rs/cli: binary not found at ${src}\n` +
|
|
66
|
-
`The platform package ${platform.pkg} may be corrupted or incomplete.\n`
|
|
67
|
-
);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
72
|
-
fs.copyFileSync(src, dest);
|
|
73
|
-
if (process.platform !== 'win32') {
|
|
74
|
-
fs.chmodSync(dest, 0o755);
|
|
75
|
-
} else {
|
|
76
|
-
// Windows: npm の bin フィールドは拡張子なし "bin/fulgur" を参照するため、
|
|
77
|
-
// .exe を起動する JS シムを書き込む
|
|
78
|
-
const shimPath = path.join(destDir, 'fulgur');
|
|
79
|
-
const shimContent = [
|
|
80
|
-
'#!/usr/bin/env node',
|
|
81
|
-
"'use strict';",
|
|
82
|
-
"const { spawnSync } = require('child_process');",
|
|
83
|
-
"const path = require('path');",
|
|
84
|
-
"const r = spawnSync(path.join(__dirname, 'fulgur.exe'), process.argv.slice(2), { stdio: 'inherit' });",
|
|
85
|
-
'process.exit(r.status ?? 1);',
|
|
86
|
-
'',
|
|
87
|
-
].join('\n');
|
|
88
|
-
fs.writeFileSync(shimPath, shimContent, { encoding: 'utf8' });
|
|
89
|
-
}
|