@raven.js/cli 1.0.0-alpha.14 → 1.0.0-alpha.16

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/raven +30 -23
  2. package/package.json +6 -6
package/bin/raven CHANGED
@@ -1,35 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
  const { spawn } = require('child_process');
3
3
  const path = require('path');
4
- const fs = require('fs');
4
+ const os = require('os');
5
5
 
6
- const targets = [
7
- 'linux-x64',
8
- 'linux-arm64',
9
- 'darwin-x64',
10
- 'darwin-arm64',
11
- 'windows-x64'
12
- ];
6
+ const knownWindowsPackages = {
7
+ 'win32 x64': '@raven.js/cli-windows-x64'
8
+ };
13
9
 
14
- let binaryPath = null;
15
- for (const target of targets) {
16
- try {
17
- const pkgPath = require.resolve(`@raven.js/cli-${target}`);
18
- const pkgDir = path.dirname(pkgPath);
19
- const candidate = path.join(pkgDir, process.platform === 'win32' ? 'raven.exe' : 'raven');
20
- if (fs.existsSync(candidate)) {
21
- binaryPath = candidate;
22
- break;
23
- }
24
- } catch (e) {
25
- continue;
10
+ const knownUnixlikePackages = {
11
+ 'linux x64': '@raven.js/cli-linux-x64',
12
+ 'linux arm64': '@raven.js/cli-linux-arm64',
13
+ 'darwin x64': '@raven.js/cli-darwin-x64',
14
+ 'darwin arm64': '@raven.js/cli-darwin-arm64'
15
+ };
16
+
17
+ function pkgAndSubpathForCurrentPlatform() {
18
+ let pkg;
19
+ let subpath;
20
+ const platformKey = `${process.platform} ${os.arch()}`;
21
+
22
+ if (platformKey in knownWindowsPackages) {
23
+ pkg = knownWindowsPackages[platformKey];
24
+ subpath = 'bin/raven.exe';
25
+ } else if (platformKey in knownUnixlikePackages) {
26
+ pkg = knownUnixlikePackages[platformKey];
27
+ subpath = 'bin/raven';
28
+ } else {
29
+ throw new Error(`Unsupported platform: ${platformKey}`);
26
30
  }
31
+
32
+ return { pkg, subpath };
27
33
  }
28
34
 
29
- if (!binaryPath) {
30
- console.error('No compatible binary found for your platform');
31
- process.exit(1);
35
+ function generateBinPath() {
36
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
37
+ return require.resolve(`${pkg}/${subpath}`);
32
38
  }
33
39
 
40
+ const binaryPath = generateBinPath();
34
41
  const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
35
42
  child.on('exit', (code) => process.exit(code || 0));
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@raven.js/cli",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.16",
4
4
  "description": "CLI tool for RavenJS framework",
5
5
  "bin": {
6
6
  "raven": "./bin/raven"
7
7
  },
8
8
  "optionalDependencies": {
9
- "@raven.js/cli-linux-x64": "1.0.0-alpha.14",
10
- "@raven.js/cli-linux-arm64": "1.0.0-alpha.14",
11
- "@raven.js/cli-darwin-x64": "1.0.0-alpha.14",
12
- "@raven.js/cli-darwin-arm64": "1.0.0-alpha.14",
13
- "@raven.js/cli-windows-x64": "1.0.0-alpha.14"
9
+ "@raven.js/cli-linux-x64": "1.0.0-alpha.16",
10
+ "@raven.js/cli-linux-arm64": "1.0.0-alpha.16",
11
+ "@raven.js/cli-darwin-x64": "1.0.0-alpha.16",
12
+ "@raven.js/cli-darwin-arm64": "1.0.0-alpha.16",
13
+ "@raven.js/cli-windows-x64": "1.0.0-alpha.16"
14
14
  },
15
15
  "keywords": [
16
16
  "ravenjs",