@aionui/officecli 1.0.122 → 1.0.124
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 +2 -2
- package/lib/install-binary.js +8 -3
- package/officecli.js +39 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ CLI for reading and writing Office documents (`.docx`, `.xlsx`, `.pptx`) via a
|
|
|
4
4
|
document DOM API.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install -g @
|
|
7
|
+
npm install -g @aionui/officecli
|
|
8
8
|
# or run without installing:
|
|
9
|
-
npx @
|
|
9
|
+
npx @aionui/officecli --help
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
On install, the native binary for your platform (macOS / Linux / Windows,
|
package/lib/install-binary.js
CHANGED
|
@@ -19,12 +19,17 @@ const MIRROR_BASE = 'https://d.officecli.ai';
|
|
|
19
19
|
const GITHUB_BASE = 'https://github.com/' + REPO;
|
|
20
20
|
|
|
21
21
|
// The package version is set to the release version at publish time, so the
|
|
22
|
-
// tag we download from is derived directly from it (immutable, never
|
|
22
|
+
// release tag we download from is derived directly from it (immutable, never
|
|
23
|
+
// stale). A prerelease/build suffix (e.g. 1.0.122-test.1) maps to the same
|
|
24
|
+
// binary release v1.0.122 — strip everything after the first '-' or '+'.
|
|
23
25
|
const VERSION = require('../package.json').version;
|
|
24
|
-
const TAG = 'v' + VERSION;
|
|
26
|
+
const TAG = 'v' + VERSION.split('+')[0].split('-')[0];
|
|
25
27
|
|
|
26
28
|
const PKG_ROOT = path.join(__dirname, '..');
|
|
27
|
-
|
|
29
|
+
// Native binary lives under vendor/, NOT bin/: the repo's root .gitignore
|
|
30
|
+
// ignores `bin/`, and keeping the download target out of bin/ avoids any
|
|
31
|
+
// collision with the launcher shim.
|
|
32
|
+
const BIN_DIR = path.join(PKG_ROOT, 'vendor');
|
|
28
33
|
|
|
29
34
|
function log(msg) {
|
|
30
35
|
// postinstall output goes to stderr so it never pollutes a command's stdout.
|
package/officecli.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// Launcher shim. npm links this as the `officecli` command. It execs the native
|
|
5
|
+
// binary fetched by postinstall, forwarding argv, stdio and the exit code. If
|
|
6
|
+
// the binary is missing (postinstall was skipped or failed offline), it is
|
|
7
|
+
// downloaded lazily on this first run.
|
|
8
|
+
//
|
|
9
|
+
// This lives at the package root, NOT under bin/, on purpose: the repo's root
|
|
10
|
+
// .gitignore ignores `bin/`, which would silently drop a bin/ shim from the
|
|
11
|
+
// published tarball.
|
|
12
|
+
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const { spawnSync } = require('child_process');
|
|
15
|
+
const installer = require('./lib/install-binary');
|
|
16
|
+
|
|
17
|
+
async function main() {
|
|
18
|
+
let bin = installer.binaryPath();
|
|
19
|
+
if (!fs.existsSync(bin)) {
|
|
20
|
+
try {
|
|
21
|
+
bin = await installer.ensureBinary();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
process.stderr.write('[officecli] ' + err.message + '\n');
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const res = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
28
|
+
if (res.error) {
|
|
29
|
+
process.stderr.write('[officecli] failed to launch binary: ' + res.error.message + '\n');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
// Signal-terminated child: surface a non-zero exit rather than a null status.
|
|
33
|
+
if (res.signal) {
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
process.exit(res.status === null ? 1 : res.status);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aionui/officecli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.124",
|
|
4
4
|
"description": "OfficeCli — CLI for reading and writing Office documents (.docx, .xlsx, .pptx) via a document DOM API. The native binary is fetched on install for your platform.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "goworm",
|
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
"cli"
|
|
25
25
|
],
|
|
26
26
|
"bin": {
|
|
27
|
-
"officecli": "
|
|
27
|
+
"officecli": "officecli.js"
|
|
28
|
+
},
|
|
29
|
+
"main": "lib/install-binary.js",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": "./lib/install-binary.js"
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
|
30
34
|
"postinstall": "node install.js"
|
|
31
35
|
},
|
|
32
36
|
"files": [
|
|
33
|
-
"
|
|
37
|
+
"officecli.js",
|
|
34
38
|
"lib/install-binary.js",
|
|
35
39
|
"install.js",
|
|
36
40
|
"README.md"
|