@neo4j-labs/cli 1.2.0 → 1.4.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.
Files changed (2) hide show
  1. package/bin/postinstall.js +58 -0
  2. package/package.json +13 -9
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ // Copyright (c) "Neo4j"
3
+ // Neo4j Sweden AB [https://neo4j.com]
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ // postinstall.js — optional auto-skill-install hook for @neo4j-labs/cli.
7
+ //
8
+ // Runs `neo4j-cli skill install --rw` after `npm install` when the environment
9
+ // variable NEO4J_CLI_AUTO_INSTALL_SKILL is set to exactly "1".
10
+ // Any failure (including no agents detected) is caught and suppressed so that
11
+ // the npm install itself is never aborted by this hook.
12
+
13
+ 'use strict';
14
+
15
+ const path = require('path');
16
+ const { spawnSync } = require('child_process');
17
+
18
+ /**
19
+ * Run the postinstall skill-install hook.
20
+ *
21
+ * Exported so tests can call it directly without relying on process.exit for
22
+ * flow control. Returns immediately (no-op) unless NEO4J_CLI_AUTO_INSTALL_SKILL
23
+ * is exactly "1".
24
+ */
25
+ function run() {
26
+ if (process.env.NEO4J_CLI_AUTO_INSTALL_SKILL !== '1') {
27
+ return;
28
+ }
29
+
30
+ const shimPath = path.join(__dirname, 'neo4j-cli.js');
31
+
32
+ try {
33
+ const result = spawnSync(
34
+ process.execPath,
35
+ [shimPath, 'skill', 'install', '--rw'],
36
+ { stdio: 'inherit' },
37
+ );
38
+ if (result.error) {
39
+ // spawn-level error (e.g. ENOENT) — warn but don't fail
40
+ process.stderr.write(
41
+ 'neo4j-cli postinstall: skill install failed: ' + result.error.message + '\n',
42
+ );
43
+ }
44
+ } catch (err) {
45
+ // Catch any unexpected synchronous throw — must not abort npm install
46
+ process.stderr.write(
47
+ 'neo4j-cli postinstall: unexpected error: ' + (err && err.message ? err.message : String(err)) + '\n',
48
+ );
49
+ }
50
+ }
51
+
52
+ module.exports = { run };
53
+
54
+ // When executed as a script (not required as a module), run and always exit 0.
55
+ if (require.main === module) {
56
+ run();
57
+ process.exit(0);
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-labs/cli",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Neo4j command-line tool (super-CLI). Installs the right prebuilt binary for your platform.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/neo4j-labs/neo4j-cli",
@@ -14,21 +14,25 @@
14
14
  "bin": {
15
15
  "neo4j-cli": "bin/neo4j-cli.js"
16
16
  },
17
+ "scripts": {
18
+ "postinstall": "node bin/postinstall.js"
19
+ },
17
20
  "files": [
18
21
  "bin/neo4j-cli.js",
22
+ "bin/postinstall.js",
19
23
  "README.md"
20
24
  ],
21
25
  "engines": {
22
26
  "node": ">=18"
23
27
  },
24
28
  "optionalDependencies": {
25
- "@neo4j-labs/cli-darwin-arm64": "1.2.0",
26
- "@neo4j-labs/cli-darwin-x64": "1.2.0",
27
- "@neo4j-labs/cli-linux-arm64": "1.2.0",
28
- "@neo4j-labs/cli-linux-ia32": "1.2.0",
29
- "@neo4j-labs/cli-linux-x64": "1.2.0",
30
- "@neo4j-labs/cli-win32-arm64": "1.2.0",
31
- "@neo4j-labs/cli-win32-ia32": "1.2.0",
32
- "@neo4j-labs/cli-win32-x64": "1.2.0"
29
+ "@neo4j-labs/cli-darwin-arm64": "1.4.0",
30
+ "@neo4j-labs/cli-darwin-x64": "1.4.0",
31
+ "@neo4j-labs/cli-linux-arm64": "1.4.0",
32
+ "@neo4j-labs/cli-linux-ia32": "1.4.0",
33
+ "@neo4j-labs/cli-linux-x64": "1.4.0",
34
+ "@neo4j-labs/cli-win32-arm64": "1.4.0",
35
+ "@neo4j-labs/cli-win32-ia32": "1.4.0",
36
+ "@neo4j-labs/cli-win32-x64": "1.4.0"
33
37
  }
34
38
  }