From acecc0ccd8d550b83ead1c8324ea1517ee963a91 Mon Sep 17 00:00:00 2001 From: damien Date: Fri, 22 May 2020 15:04:25 -0400 Subject: [PATCH 1/3] add local happ button --- views/main_window.html | 12 ++++++++++++ views/main_window.js | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/views/main_window.html b/views/main_window.html index e13e639..c3c1f0b 100644 --- a/views/main_window.html +++ b/views/main_window.html @@ -102,6 +102,18 @@ + + + + + Install hApp from local file + + + Click here to install local hApp + + + + { if(app.activeUI == uiName) { - return + return } app.activeUI = uiName holoscape.hideViews() happUiController.showHappUi(uiName) }, + showHappInstall: () => { + holoscape.showInstallFromFileWindow() + }, showHappStore: () => { if(app.activeUI == "happ-store") { return From 0e56db508c2e5c35614147351939838a093e8874 Mon Sep 17 00:00:00 2001 From: damien Date: Mon, 27 Jul 2020 22:19:04 -0400 Subject: [PATCH 2/3] trying to get windows build working with wsl2 --- cli.js | 43 ++++++++++++++++++++++----- conductor.js | 11 ++++--- package.json | 1 + views/install_bundle_view.js | 9 ++++-- views/legacy_install_bundle_view.html | 9 ++++-- 5 files changed, 57 insertions(+), 16 deletions(-) diff --git a/cli.js b/cli.js index 8bda2c4..6396d40 100644 --- a/cli.js +++ b/cli.js @@ -7,8 +7,9 @@ const rootConfigPath = global.rootConfigPath function executablePath() { let executable; if (process.platform === "win32") { - executable = "./hc.exe" - } else if (process.platform === "darwin") { + return process.env.comspec; + } + if (process.platform === "darwin") { executable = "./hc-darwin" } else if (process.platform === "linux") { executable = "./hc-linux" @@ -20,10 +21,36 @@ function executablePath() { return path.join(__dirname, executable) } +function win32Path(filePath) { + let fp = filePath.replace(/\\/g, "\\\\"); + let wslparams = ["/c", "wsl", "wslpath", "-a", fp] + let { stdout, stderr, error } = spawnSync( + process.env.comspec, + wslparams, + {cwd: __dirname} + ) + stderr = stderr? stderr.toString() : ""; + stdout = stdout? stdout.toString() : ""; + console.log("CLI wslpath: got results:") + console.log("stdout:", stdout) + console.log("stderr:", stderr) + fp = stdout.substring(0, stdout.length - 1); // remove 'return' char + return fp +} + module.exports = { + win32Path: (filePath) => { + return win32Path(filePath) + }, hash: (filePath, properties) => { console.log("CLI: hashing file", filePath) + if (process.platform === "win32") { + filePath = win32Path(filePath) + } let params = ["hash", "--path", filePath] + if (process.platform === "win32") { + params.unshift("/c", "wsl", "hc-linux") + } if(properties) { for(let name in properties) { params.push("--property") @@ -31,12 +58,12 @@ module.exports = { } } let { stdout, stderr, error } = spawnSync( - executablePath(), + executablePath(), params, {cwd: __dirname} ) - stderr = stderr.toString() - stdout = stdout.toString() + stderr = stderr? stderr.toString() : ""; + stdout = stdout? stdout.toString() : ""; console.log("CLI: got results:") console.log("stdout:", stdout) console.log("stderr:", stderr) @@ -47,13 +74,13 @@ module.exports = { console.log('Error executing hc:', error) return {error} } - + if(stderr.length > 0) { error = stderr - console.log('Error executing hc:', error) + console.log('Error executing hc (stderr):', error) return {error} } - + console.log(`hc stdout: ${JSON.stringify(stdout)}`) let lines = stdout.split('\n') let hash diff --git a/conductor.js b/conductor.js index 9efd152..6334350 100644 --- a/conductor.js +++ b/conductor.js @@ -59,7 +59,8 @@ module.exports = { } if (process.platform === "win32") { - run = spawn(path.join(__dirname, "./holochain.exe"), ["-c", "./conductor-config.toml"], {env:{...process.env, RUST_BACKTRACE: 1}}) + // TODO: dont hardcode conductor-config + run = spawn(process.env.comspec, ["/c", "wsl", "holochain-linux", "-c", "/mnt/c/github/conductor-config.toml"], {env:{...process.env, RUST_BACKTRACE: 1}}) } else if (process.platform === "darwin") { run = spawn(path.join(__dirname, "./holochain-darwin"), ["-c", configPath], {env:{...process.env, RUST_BACKTRACE: 'full'}}) } else if (process.platform === "linux") { @@ -71,7 +72,7 @@ module.exports = { { run = spawn(path.join(__dirname, "./holochain-linux"), ["-c", configPath], {env:{...process.env, RUST_BACKTRACE: 'full'}}) } - + } else { log('error', "unsupported platform: "+process.platform) @@ -99,8 +100,10 @@ module.exports = { let holochain, hc if (process.platform === "win32") { - holochain = "./holochain.exe" - hc = "./hc.exe" + // holochain = "./holochain.exe" + // hc = "./hc.exe" + // TODO: check binaries on windows + return true; } else if (process.platform === "darwin") { holochain = "./holochain-darwin" hc = "./hc-darwin" diff --git a/package.json b/package.json index 2ab2ab2..e30a631 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "start:dev": "DEV=true electron .", "build-mac": "electron-packager . Holoscape --platform=darwin --overwrite --icon=./images/HoloScape-hdpi.icns", "build-linux": "electron-packager . Holoscape --platform=linux --overwrite --icon=./images/HoloScape-hdpi.png", + "build-windows": "electron-packager C:\\github\\holoscape --platform=win32 --overwrite --icon=C:\\github\\holoscape\\images\\HoloScape-hdpi.png", "delete:app-support": "rm -rf '$HOME/Library/Application Support/holoscape' && rm -rf '$HOME/Library/Application Support/Holoscape-default'" }, "author": "Holochain Core Dev Team ", diff --git a/views/install_bundle_view.js b/views/install_bundle_view.js index 2f93ceb..95c1278 100644 --- a/views/install_bundle_view.js +++ b/views/install_bundle_view.js @@ -16,6 +16,7 @@ import Vuetify, { VProgressCircular, } from 'vuetify/lib' import { Ripple } from 'vuetify/lib/directives' +import {win32Path} from './../cli' Vue.use(Vuetify, { components: { @@ -464,10 +465,14 @@ ipcRenderer.on('conductor-call-set', () => { } const dna_id = `${instance.name}-dna` - const path = instance.tempPath - console.log('Installing DNA', dna_id) + let path = instance.tempPath; + if (process.platform === 'win32') { + path = win32Path(instance.tempPath) + } + console.log('Installing DNA :' + dna_id) let properties = undefined console.log('PROPERTIES:', instance.dna_properties) + console.log('PATH:', path) if(instance.dna_properties) { let variables = {agent_id: agent_address} properties = interpolateProperties(instance.dna_properties, variables) diff --git a/views/legacy_install_bundle_view.html b/views/legacy_install_bundle_view.html index ee843c2..70d0dad 100644 --- a/views/legacy_install_bundle_view.html +++ b/views/legacy_install_bundle_view.html @@ -266,6 +266,7 @@

Bundle successfully installed!