@holochain/hc-spin 0.300.2 → 0.300.4

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 CHANGED
@@ -4,31 +4,23 @@ CLI to run Holochain apps in development mode.
4
4
 
5
5
  ## Installation
6
6
 
7
- To install the latest version compatible with **holochain 0.1.x**:
8
-
9
- ⚠️ Requires `@holochain/client 0.12.6` or newer ⚠️
10
-
11
- ```
12
- npm install --save-dev @holochain/hc-spin@">=0.100.0 <0.200.0"
13
- ```
14
-
15
- To install the latest version compatible with **holochain 0.2.x**:
7
+ To install the latest version compatible with **holochain 0.3.x**:
16
8
 
17
- ⚠️ Requires `@holochain/client 0.16.2` or newer ⚠️
9
+ ⚠️ Requires `@holochain/client 0.17.0-dev.5` or newer ⚠️
18
10
 
19
11
  ```
20
- npm install --save-dev @holochain/hc-spin@">=0.200.0 <0.300.0"
12
+ npm install --save-dev @holochain/hc-spin@">=0.300.0 <0.400.0"
21
13
  ```
22
14
 
23
- To install the latest version compatible with **holochain 0.3.x**:
15
+ To install the latest version compatible with **holochain 0.4.x**:
24
16
 
25
- ⚠️ Requires `@holochain/client 0.17.0-dev.5` or newer ⚠️
17
+ ⚠️ Requires `@holochain/client 0.18.0-rc.1` or newer ⚠️
26
18
 
27
19
  ```
28
- npm install --save-dev @holochain/hc-spin@">=0.300.0 <0.400.0"
20
+ npm install --save-dev @holochain/hc-spin@">=0.400.0 <0.500.0"
29
21
  ```
30
22
 
31
- ## Usage (holochain 0.2)
23
+ ## Usage (holochain 0.4)
32
24
 
33
25
  ```
34
26
  Usage: hc-spin [options] <path>
@@ -52,6 +44,7 @@ Options:
52
44
  --ui-port <number> Port pointing to a localhost dev server that serves your UI assets.
53
45
  --signaling-url <url> Url of the signaling server to use. By default, hc spin spins up a local development signaling server for you
54
46
  but this argument allows you to specify a custom one.
47
+ --open-devtools Automatically open the devtools on startup.
55
48
  -h, --help display help for command
56
49
  ```
57
50
 
package/cli/cli.js CHANGED
@@ -1,18 +1,40 @@
1
1
  #!/usr/bin/env node
2
- const { spawn } = require('child_process');
2
+ const { spawn, spawnSync } = require('child_process');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
 
6
- let electronBinary;
7
- let pathStr = '../node_modules/.bin/electron';
8
- // recursively look for electron binary in node_modules folder
9
- for (let i = 0; i < 7; i++) {
10
- const maybeElectronBinary = path.resolve(__dirname, pathStr);
11
- if (fs.existsSync(maybeElectronBinary)) {
12
- electronBinary = maybeElectronBinary;
13
- break;
14
- } else {
15
- pathStr = '../' + pathStr;
6
+ let electronBinary = process.env.ELECTRON_BINARY;
7
+
8
+ if (!electronBinary) {
9
+ // Check whether electron is installed globally and compare with the expected version
10
+ const electronHandleTemp = spawnSync('electron', ['--version']);
11
+
12
+ if (electronHandleTemp.stdout) {
13
+ if (!electronHandleTemp.stdout.toString().startsWith('v###REPLACE_AT_BUILD_TIME###')) {
14
+ console.warn(
15
+ 'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
16
+ );
17
+ } else {
18
+ electronBinary = 'electron';
19
+ }
20
+ }
21
+
22
+ if (!electronBinary) {
23
+ let pathStr =
24
+ process.platform === 'win32'
25
+ ? '../node_modules/electron/dist/electron.exe'
26
+ : '../node_modules/.bin/electron';
27
+
28
+ // recursively look for electron binary in node_modules folder
29
+ for (let i = 0; i < 7; i++) {
30
+ const maybeElectronBinary = path.resolve(__dirname, pathStr);
31
+ if (fs.existsSync(maybeElectronBinary)) {
32
+ electronBinary = maybeElectronBinary;
33
+ break;
34
+ } else {
35
+ pathStr = '../' + pathStr;
36
+ }
37
+ }
16
38
  }
17
39
  }
18
40
 
package/dist/cli.js CHANGED
@@ -1,18 +1,40 @@
1
1
  #!/usr/bin/env node
2
- const { spawn } = require('child_process');
2
+ const { spawn, spawnSync } = require('child_process');
3
3
  const path = require('path');
4
4
  const fs = require('fs');
5
5
 
6
- let electronBinary;
7
- let pathStr = '../node_modules/.bin/electron';
8
- // recursively look for electron binary in node_modules folder
9
- for (let i = 0; i < 7; i++) {
10
- const maybeElectronBinary = path.resolve(__dirname, pathStr);
11
- if (fs.existsSync(maybeElectronBinary)) {
12
- electronBinary = maybeElectronBinary;
13
- break;
14
- } else {
15
- pathStr = '../' + pathStr;
6
+ let electronBinary = process.env.ELECTRON_BINARY;
7
+
8
+ if (!electronBinary) {
9
+ // Check whether electron is installed globally and compare with the expected version
10
+ const electronHandleTemp = spawnSync('electron', ['--version']);
11
+
12
+ if (electronHandleTemp.stdout) {
13
+ if (!electronHandleTemp.stdout.toString().startsWith('v29.')) {
14
+ console.warn(
15
+ 'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
16
+ );
17
+ } else {
18
+ electronBinary = 'electron';
19
+ }
20
+ }
21
+
22
+ if (!electronBinary) {
23
+ let pathStr =
24
+ process.platform === 'win32'
25
+ ? '../node_modules/electron/dist/electron.exe'
26
+ : '../node_modules/.bin/electron';
27
+
28
+ // recursively look for electron binary in node_modules folder
29
+ for (let i = 0; i < 7; i++) {
30
+ const maybeElectronBinary = path.resolve(__dirname, pathStr);
31
+ if (fs.existsSync(maybeElectronBinary)) {
32
+ electronBinary = maybeElectronBinary;
33
+ break;
34
+ } else {
35
+ pathStr = '../' + pathStr;
36
+ }
37
+ }
16
38
  }
17
39
  }
18
40