Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -20,23 +21,49 @@ 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")
params.push(`${name}=${properties[name]}`)
}
}
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)
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions conductor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 . 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 <devcore@holochain.org>",
Expand Down
9 changes: 7 additions & 2 deletions views/install_bundle_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Vuetify, {
VProgressCircular,
} from 'vuetify/lib'
import { Ripple } from 'vuetify/lib/directives'
import {win32Path} from './../cli'

Vue.use(Vuetify, {
components: {
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions views/legacy_install_bundle_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ <h2 class="alert alert-success">Bundle successfully installed!</h2>

<script>
const { ipcRenderer, shell } = require('electron')
const { win32Path } = require('./../cli')
const toml = require('toml')
const fs = require('fs')
const getUri = require('get-uri')
Expand Down Expand Up @@ -586,8 +587,12 @@ <h2 class="alert alert-success">Bundle successfully installed!</h2>
}

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('PATH: "' + path + '"')
console.log('Installing DNA | ', dna_id)
let properties = undefined
console.log('PROPERTIES:', instance.dna_properties)
if(instance.dna_properties) {
Expand Down
12 changes: 12 additions & 0 deletions views/main_window.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@
</v-list-item-content>
</v-list-item>

<v-list-item key="'happ-install'" v-on:click="showHappInstall()">
<v-icon v-text="'mdi-plus'" large color="deep-orange" dark></v-icon>
<v-list-item-content>
<v-list-item-title class="title">
Install hApp from local file
</v-list-item-title>
<v-list-item-subtitle>
Click here to install local hApp
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>

<v-divider></v-divider>

<v-list-item
Expand Down
5 changes: 4 additions & 1 deletion views/main_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ let app = new Vue({
methods: {
showHappUi: (uiName) => {
if(app.activeUI == uiName) {
return
return
}
app.activeUI = uiName
holoscape.hideViews()
happUiController.showHappUi(uiName)
},
showHappInstall: () => {
holoscape.showInstallFromFileWindow()
},
showHappStore: () => {
if(app.activeUI == "happ-store") {
return
Expand Down