Skip to content

Commit

Permalink
update for iamp2p
Browse files Browse the repository at this point in the history
  • Loading branch information
Connoropolous committed Jan 19, 2021
1 parent 490f0e8 commit 95eead2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ storage

# electron-packager folders
Acorn-*
iamp2p-*

# copied binaries
lair-keystore
Expand Down
Binary file added images/iamp2p-app-icon-1024px-green.icns
Binary file not shown.
42 changes: 8 additions & 34 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ require('electron-context-menu')()
require('fix-path')()
require('electron-debug')({ isEnabled: true, showDevTools: false })

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

// ELECTRON
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand All @@ -26,8 +24,6 @@ let quit = false
// veresions of these same ports
const APP_PORT = 8889 // MUST MATCH ACORN_UI config
const ADMIN_PORT = 1235 // MUST MATCH ACORN_UI config
const PROFILES_APP_ID = 'profiles-app' // MUST MATCH ACORN_UI config
const MATCH_ACORN_UI_PROFILES_DNA_NICK = 'profiles.dna.gz'

// a special log from the conductor, specifying
// that the interfaces are ready to receive incoming
Expand All @@ -38,14 +34,15 @@ 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'), 'HcAcorn')
const STORAGE_PATH = path.join(CONFIG_PATH, 'database')
const CONDUCTOR_CONFIG_PATH = path.join(CONFIG_PATH, 'conductor-config.yml')
const CONFIG_PATH = path.join(app.getPath('appData'), 'iamp2p')
const INNER_CONFIG = path.join(CONFIG_PATH, 'holochain')
const STORAGE_PATH = path.join(INNER_CONFIG, 'database')
const CONDUCTOR_CONFIG_PATH = path.join(INNER_CONFIG, 'conductor-config.yml')

if (!fs.existsSync(CONFIG_PATH)) {
fs.mkdirSync(CONFIG_PATH)
fs.mkdirSync(STORAGE_PATH)
fs.writeFileSync(
if (!fs.existsSync(CONFIG_PATH)) fs.mkdirSync(CONFIG_PATH)
if (!fs.existsSync(INNER_CONFIG)) fs.mkdirSync(INNER_CONFIG)
if (!fs.existsSync(STORAGE_PATH)) fs.mkdirSync(STORAGE_PATH)
if (!fs.existsSync(CONDUCTOR_CONFIG_PATH)) fs.writeFileSync(
CONDUCTOR_CONFIG_PATH,
`
environment_path: ${STORAGE_PATH}
Expand All @@ -67,7 +64,6 @@ network:
type: remote_proxy_client
proxy_url: kitsune-proxy://VYgwCrh2ZCKL1lpnMM1VVUee7ks-9BkmW47C_ys4nqg/kitsune-quic/h/kitsune-proxy.harris-braun.com/p/4010/--`
)
}

function createWindow() {
// Create the browser window.
Expand Down Expand Up @@ -157,26 +153,6 @@ 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,
installed_app_id: PROFILES_APP_ID,
dnas: [
{
nick: MATCH_ACORN_UI_PROFILES_DNA_NICK,
path: './dna/profiles.dna.gz',
},
],
})
await adminWs.activateApp({ installed_app_id: PROFILES_APP_ID })
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.
Expand All @@ -187,8 +163,6 @@ app.on('ready', async function () {
.catch((err) => console.log('An error occurred: ', err))
createWindow()
await startConductor()
const adminWs = await AdminWebsocket.connect(`ws://localhost:${ADMIN_PORT}`)
await installIfFirstLaunch(adminWs)
// trigger refresh once we know
// interfaces have booted up
mainWindow.loadURL('file://' + __dirname + '/ui/index.html')
Expand Down
44 changes: 2 additions & 42 deletions package-lock.json

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

16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"name": "Acorn",
"version": "0.4.1",
"description": "A Holochain State of Affairs Tree application",
"name": "iamp2p",
"version": "1.0.0",
"description": "Your Guide To P2P",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"repository": "https://github.com/h-be/acorn-release",
"keywords": [
"Electron",
"Acorn",
"State of Affairs"
],
"author": "Harris-Braun Enterprises, LLC and contributors",
"repository": "https://github.com/sprillow/iamp2p-release",
"author": "Sprillow Limited",
"license": "CAL-1.0 Beta 4",
"dependencies": {
"@holochain/conductor-api": "0.0.1-dev.14",
"command-exists": "^1.2.8",
"electron-context-menu": "^0.12.1",
"electron-debug": "^3.0.1",
Expand Down

0 comments on commit 95eead2

Please sign in to comment.