@holochain/hc-spin 0.200.14 → 0.200.15
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/cli/cli.js +33 -15
- package/dist/cli.js +33 -15
- package/dist/main/index.js +7 -1
- package/package.json +3 -3
- package/scripts/replace-electron-version.js +11 -0
- package/src/main/index.ts +7 -1
package/cli/cli.js
CHANGED
|
@@ -1,22 +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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
|
package/dist/cli.js
CHANGED
|
@@ -1,22 +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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
|
package/dist/main/index.js
CHANGED
|
@@ -11861,7 +11861,13 @@ electron.protocol.registerSchemesAsPrivileged([
|
|
|
11861
11861
|
contextMenu({
|
|
11862
11862
|
showSaveImageAs: true,
|
|
11863
11863
|
showSearchWithGoogle: false,
|
|
11864
|
-
showInspectElement: true
|
|
11864
|
+
showInspectElement: true,
|
|
11865
|
+
append: (_defaultActions, _parameters, browserWindow) => [
|
|
11866
|
+
{
|
|
11867
|
+
label: "Reload",
|
|
11868
|
+
click: () => browserWindow.reload()
|
|
11869
|
+
}
|
|
11870
|
+
]
|
|
11865
11871
|
});
|
|
11866
11872
|
const handleSignZomeCall = async (e, request) => {
|
|
11867
11873
|
const windowInfo = WINDOW_INFO_MAP[e.sender.id];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/hc-spin",
|
|
3
|
-
"version": "0.200.
|
|
3
|
+
"version": "0.200.15",
|
|
4
4
|
"holochainVersion": "0.2.x",
|
|
5
5
|
"description": "CLI to run Holochain aps during development.",
|
|
6
6
|
"author": "matthme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
|
31
31
|
"start": "electron-vite preview",
|
|
32
32
|
"dev": "electron-vite dev",
|
|
33
|
-
"build": "rimraf dist && npm run typecheck && electron-vite build && mv ./out ./dist && cp ./cli/cli.js ./dist/cli.js"
|
|
33
|
+
"build": "rimraf dist && npm run typecheck && electron-vite build && mv ./out ./dist && cp ./cli/cli.js ./dist/cli.js && node ./scripts/replace-electron-version.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@electron-toolkit/preload": "^3.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@holochain/hc-spin-rust-utils": "^0.200.3",
|
|
40
40
|
"@msgpack/msgpack": "^2.8.0",
|
|
41
41
|
"commander": "11.1.0",
|
|
42
|
-
"electron": "^
|
|
42
|
+
"electron": "^29.3.1",
|
|
43
43
|
"electron-context-menu": "3.6.1",
|
|
44
44
|
"get-port": "7.0.0",
|
|
45
45
|
"nanoid": "5.0.4",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
const packageJsonString = fs.readFileSync('package.json');
|
|
4
|
+
const packageJson = JSON.parse(packageJsonString);
|
|
5
|
+
const electronVersion = packageJson.dependencies.electron;
|
|
6
|
+
const majorElectronVersion = electronVersion.replace('^', '').slice(0, 3);
|
|
7
|
+
console.log('electron version: ', majorElectronVersion);
|
|
8
|
+
|
|
9
|
+
const cliJs = fs.readFileSync('./dist/cli.js', 'utf-8');
|
|
10
|
+
const modifiedCliJs = cliJs.replace('###REPLACE_AT_BUILD_TIME###', majorElectronVersion);
|
|
11
|
+
fs.writeFileSync('./dist/cli.js', modifiedCliJs);
|
package/src/main/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { app, IpcMainInvokeEvent, ipcMain, protocol, Menu } from 'electron';
|
|
1
|
+
import { app, IpcMainInvokeEvent, ipcMain, protocol, Menu, BrowserWindow } from 'electron';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { nanoid } from 'nanoid';
|
|
@@ -119,6 +119,12 @@ contextMenu({
|
|
|
119
119
|
showSaveImageAs: true,
|
|
120
120
|
showSearchWithGoogle: false,
|
|
121
121
|
showInspectElement: true,
|
|
122
|
+
append: (_defaultActions, _parameters, browserWindow) => [
|
|
123
|
+
{
|
|
124
|
+
label: 'Reload',
|
|
125
|
+
click: () => (browserWindow as BrowserWindow).reload(),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
122
128
|
});
|
|
123
129
|
|
|
124
130
|
const handleSignZomeCall = async (e: IpcMainInvokeEvent, request: CallZomeRequest) => {
|