Skip to content

Commit

Permalink
Merge pull request h-be#34 from h-be/upcoming-release
Browse files Browse the repository at this point in the history
update holochain conductor api, and switch to yml config
  • Loading branch information
Connoropolous authored Dec 24, 2020
2 parents fd6849a + 2eb7e6c commit 490f0e8
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 40 deletions.
50 changes: 37 additions & 13 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, Menu, shell } = require('electron')
const spawn = require('child_process').spawn
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
} = require('electron-devtools-installer')
const fs = require('fs')
const path = require('path')
const kill = require('tree-kill')
const { log, logger } = require('./logger')
require('electron-context-menu')()
require('fix-path')()
// enables the devtools window automatically
// require('electron-debug')({ isEnabled: true })
require('electron-debug')({ isEnabled: true, showDevTools: false })

const { AdminWebsocket } = require('@holochain/conductor-api')

Expand All @@ -34,22 +38,34 @@ const HOLOCHAIN_BIN = './holochain'
const LAIR_KEYSTORE_BIN = './lair-keystore'

// TODO: make this based on version number?
const CONFIG_PATH = path.join(app.getPath('appData'), 'AcornNew')
const CONFIG_PATH = path.join(app.getPath('appData'), 'HcAcorn')
const STORAGE_PATH = path.join(CONFIG_PATH, 'database')
const CONDUCTOR_CONFIG_PATH = path.join(CONFIG_PATH, 'conductor-config.toml')
const CONDUCTOR_CONFIG_PATH = path.join(CONFIG_PATH, 'conductor-config.yml')

if (!fs.existsSync(CONFIG_PATH)) {
fs.mkdirSync(CONFIG_PATH)
fs.mkdirSync(STORAGE_PATH)
fs.writeFileSync(
CONDUCTOR_CONFIG_PATH,
`
environment_path = "${STORAGE_PATH}"
use_dangerous_test_keystore = false
[[admin_interfaces]]
driver.type = "websocket"
driver.port = ${ADMIN_PORT}`
environment_path: ${STORAGE_PATH}
use_dangerous_test_keystore: false
passphrase_service:
type: cmd
admin_interfaces:
- driver:
type: websocket
port: ${ADMIN_PORT}
network:
bootstrap_service: https://bootstrap.holo.host
transport_pool:
- type: proxy
sub_transport:
type: quic
bind_to: kitsune-quic://0.0.0.0:0
proxy_config:
type: remote_proxy_client
proxy_url: kitsune-proxy://VYgwCrh2ZCKL1lpnMM1VVUee7ks-9BkmW47C_ys4nqg/kitsune-quic/h/kitsune-proxy.harris-braun.com/p/4010/--`
)
}

Expand Down Expand Up @@ -113,6 +129,9 @@ async function startConductor() {

holochain_handle = spawn(HOLOCHAIN_BIN, ['-c', CONDUCTOR_CONFIG_PATH], {
cwd: __dirname,
env: {
RUST_BACKTRACE: 1,
},
})
holochain_handle.stderr.on('data', (data) => {
log('error', 'holochain> ' + data.toString())
Expand Down Expand Up @@ -140,27 +159,32 @@ async function startConductor() {

async function installIfFirstLaunch(adminWs) {
const dnas = await adminWs.listDnas()
// const activeAppIds = await adminWs.listActiveApps()
if (dnas.length === 0) {
let myPubKey = await adminWs.generateAgentPubKey()
await adminWs.installApp({
agent_key: myPubKey,
app_id: PROFILES_APP_ID,
installed_app_id: PROFILES_APP_ID,
dnas: [
{
nick: MATCH_ACORN_UI_PROFILES_DNA_NICK,
path: './dna/profiles.dna.gz',
},
],
})
await adminWs.activateApp({ app_id: PROFILES_APP_ID })
await adminWs.activateApp({ installed_app_id: PROFILES_APP_ID })
await adminWs.attachAppInterface({ port: APP_PORT })
}
await adminWs.attachAppInterface({ port: APP_PORT })
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async function () {
installExtension(REDUX_DEVTOOLS)
.then(() => installExtension(REACT_DEVELOPER_TOOLS))
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err))
createWindow()
await startConductor()
const adminWs = await AdminWebsocket.connect(`ws://localhost:${ADMIN_PORT}`)
Expand Down
18 changes: 9 additions & 9 deletions nix/acorn/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ let
bundle-dna = (pkgs.writeShellScriptBin "acorn-bundle-dna" ''
rm -rf dna
# an optional first argument should be the version number you want
# default to 0.4.0
echo "fetching DNA from https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.0}/profiles.dna.gz"
echo "fetching DNA from https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.0}/projects.dna.gz"
curl -O -L https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.0}/profiles.dna.gz
curl -O -L https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.0}/projects.dna.gz
# default to 0.4.1
echo "fetching DNA from https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.2}/profiles.dna.gz"
echo "fetching DNA from https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.2}/projects.dna.gz"
curl -O -L https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.2}/profiles.dna.gz
curl -O -L https://github.com/h-be/acorn-hc/releases/download/v''${1:-0.4.2}/projects.dna.gz
mkdir dna
mv profiles.dna.gz dna/profiles.dna.gz
mv projects.dna.gz dna/projects.dna.gz
Expand All @@ -17,8 +17,8 @@ let
rm -rf ui
mkdir ui
# an optional first argument should be the version number you want
# default to 0.4.1
curl -O -L https://github.com/h-be/acorn-ui/releases/download/v''${1:-0.4.1}/acorn-ui.zip
# default to 0.4.3
curl -O -L https://github.com/h-be/acorn-ui/releases/download/v''${1:-0.4.3}/acorn-ui.zip
# unzip into the ./ui folder
unzip acorn-ui.zip -d ui
rm acorn-ui.zip
Expand All @@ -29,8 +29,8 @@ let
rm -rf ./ui
rm -rf ./dna
rm -rf ./Acorn-*
rm -rf $HOME/.config/Acorn
rm -rf $HOME/Library/Application\ Support/Acorn
rm -rf $HOME/.config/HcAcorn
rm -rf $HOME/Library/Application\ Support/HcAcorn
rm -rf ./node_modules
'');

Expand Down
114 changes: 99 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 490f0e8

Please sign in to comment.