@ihr360cli/ihr-cli 1.0.36-beta.4 → 1.0.36-beta.41

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/bin/ihr-cli.js CHANGED
@@ -5,6 +5,8 @@ const { spawnSync } = require("child_process");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
 
8
+ const ROOT_PACKAGE_NAME = "@ihr360cli/ihr-cli";
9
+
8
10
  const PACKAGE_MAP = {
9
11
  "linux-x64": "@ihr360cli/ihr-cli-linux-x64",
10
12
  "linux-arm64": "@ihr360cli/ihr-cli-linux-arm64",
@@ -31,6 +33,26 @@ function binaryName(platform = process.platform) {
31
33
  return platform === "win32" ? "ihr-cli.exe" : "ihr-cli";
32
34
  }
33
35
 
36
+ function packageVersion() {
37
+ try {
38
+ const manifest = require("../package.json");
39
+ return String(manifest.version || "").trim();
40
+ } catch (error) {
41
+ return "";
42
+ }
43
+ }
44
+
45
+ function missingNativeMessage(name) {
46
+ const version = packageVersion();
47
+ const spec = version ? `${ROOT_PACKAGE_NAME}@${version}` : ROOT_PACKAGE_NAME;
48
+ const pkg = version ? `${name}@${version}` : name;
49
+ return (
50
+ `Missing native package ${pkg}. ` +
51
+ "npm skipped this optional package, leaving a broken install that will not self-heal. " +
52
+ `Reinstall the same version: npm install -g ${spec}`
53
+ );
54
+ }
55
+
34
56
  function nativePackageCandidates(name, baseDir) {
35
57
  const packageRoot = baseDir || path.join(__dirname, "..");
36
58
  const scopeDir = path.dirname(packageRoot);
@@ -60,9 +82,7 @@ function resolveBinary(opts = {}) {
60
82
  return bin;
61
83
  }
62
84
  }
63
- throw new Error(
64
- `Missing native package ${name}. Reinstall with: npm install -g @ihr360cli/ihr-cli@beta`
65
- );
85
+ throw new Error(missingNativeMessage(name));
66
86
  }
67
87
 
68
88
  function run(argv = process.argv.slice(2), opts = {}) {
@@ -88,8 +108,11 @@ function run(argv = process.argv.slice(2), opts = {}) {
88
108
 
89
109
  module.exports = {
90
110
  PACKAGE_MAP,
111
+ ROOT_PACKAGE_NAME,
91
112
  platformPackageName,
92
113
  binaryName,
114
+ packageVersion,
115
+ missingNativeMessage,
93
116
  resolveBinary,
94
117
  run,
95
118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihr360cli/ihr-cli",
3
- "version": "1.0.36-beta.4",
3
+ "version": "1.0.36-beta.41",
4
4
  "description": "iHR360 command-line interface",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -8,6 +8,7 @@
8
8
  },
9
9
  "files": [
10
10
  "bin/",
11
+ "scripts/",
11
12
  "README.md"
12
13
  ],
13
14
  "engines": {
@@ -23,11 +24,11 @@
23
24
  "arm64"
24
25
  ],
25
26
  "optionalDependencies": {
26
- "@ihr360cli/ihr-cli-linux-x64": "1.0.36-beta.4",
27
- "@ihr360cli/ihr-cli-linux-arm64": "1.0.36-beta.4",
28
- "@ihr360cli/ihr-cli-darwin-x64": "1.0.36-beta.4",
29
- "@ihr360cli/ihr-cli-darwin-arm64": "1.0.36-beta.4",
30
- "@ihr360cli/ihr-cli-win32-x64": "1.0.36-beta.4"
27
+ "@ihr360cli/ihr-cli-linux-x64": "1.0.36-beta.41",
28
+ "@ihr360cli/ihr-cli-linux-arm64": "1.0.36-beta.41",
29
+ "@ihr360cli/ihr-cli-darwin-x64": "1.0.36-beta.41",
30
+ "@ihr360cli/ihr-cli-darwin-arm64": "1.0.36-beta.41",
31
+ "@ihr360cli/ihr-cli-win32-x64": "1.0.36-beta.41"
31
32
  },
32
33
  "publishConfig": {
33
34
  "access": "public"
@@ -40,5 +41,8 @@
40
41
  "ihr360",
41
42
  "ihr-cli",
42
43
  "cli"
43
- ]
44
+ ],
45
+ "scripts": {
46
+ "postinstall": "node scripts/postinstall.js"
47
+ }
44
48
  }
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { resolveBinary } = require("../bin/ihr-cli.js");
5
+
6
+ try {
7
+ resolveBinary();
8
+ } catch (error) {
9
+ console.error(error.message);
10
+ process.exit(1);
11
+ }