Skip to content

Commit

Permalink
feat(commands/run): introduce --client-version and --client-port
Browse files Browse the repository at this point in the history
This commit introduces a new option `--client-version` that can be used to
specify the Aragon client version to be used as discussed in aragon#182. A version
can be any commit-ish values (hashes, branches, tags).

Example:

```
$ aragon run --client-version=fa2025232330bc3e4d3b792cab4bf44d754d33e6
```
Or

```
$ aragon run --client-version=dev
```

It also offers a new option `--client-port` to configure the port on which
the client is being served from.

Notice that this option is being ignored at the moment, which will be addressed
in a future commit. For more info: aragon#198

Closes aragon#182
  • Loading branch information
0x-r4bbit committed Sep 11, 2018
1 parent 6b92a70 commit 2ed542c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
]
},
"aragon": {
"clientVersion": "fa2025232330bc3e4d3b792cab4bf44d754d33e6"
"clientVersion": "fa2025232330bc3e4d3b792cab4bf44d754d33e6",
"clientPort": "3000"
}
}
38 changes: 25 additions & 13 deletions src/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const { Writable } = require('stream')
const url = require('url')

const TX_MIN_GAS = 10e6
const CLIENT_PORT = 3000

const aragonClientVersion = pkg.aragon.clientVersion;
const DEFAULT_CLIENT_VERSION = pkg.aragon.clientVersion;
const DEFAULT_CLIENT_PORT = pkg.aragon.clientPort

exports.command = 'run'

Expand Down Expand Up @@ -86,6 +86,12 @@ exports.builder = function (yargs) {
description: 'Arguments for calling the app init function',
array: true,
default: [],
}).option('client-version', {
description: 'Version of Aragon client used to run your sandboxed app',
default: DEFAULT_CLIENT_VERSION
}).option('client-port', {
description: 'Port being used by Aragon client',
default: DEFAULT_CLIENT_PORT
})
}

Expand Down Expand Up @@ -124,9 +130,16 @@ exports.handler = function ({
httpServedFrom,
appInit,
appInitArgs,
clientVersion,
clientPort
}) {

apmOptions.ensRegistryAddress = apmOptions['ens-registry']

clientPort = clientPort || DEFAULT_CLIENT_PORT

const showAccounts = accounts

const tasks = new TaskList([
{
title: 'Start a local Ethereum network',
Expand Down Expand Up @@ -232,7 +245,8 @@ exports.handler = function ({
{
title: 'Download wrapper',
task: (ctx, task) => {
const CLIENT_PATH = `${os.homedir()}/.aragon/wrapper-${aragonClientVersion}`
clientVersion = clientVersion || DEFAULT_CLIENT_VERSION
const CLIENT_PATH = `${os.homedir()}/.aragon/wrapper-${clientVersion}`
ctx.wrapperPath = CLIENT_PATH

// Make sure we haven't already downloaded the wrapper
Expand All @@ -246,12 +260,10 @@ exports.handler = function ({
fs.ensureDirSync(CLIENT_PATH)

// Clone wrapper
return clone(
'https://github.com/aragon/aragon',
CLIENT_PATH,
{ checkout: aragonClientVersion }
)
},
return clone('https://github.com/aragon/aragon', CLIENT_PATH, {
checkout: clientVersion
})
}
},
{
title: 'Install wrapper dependencies',
Expand All @@ -261,7 +273,7 @@ exports.handler = function ({
{
title: 'Start Aragon client',
task: async (ctx, task) => {
if (await isPortTaken(CLIENT_PORT)) {
if (await isPortTaken(clientPort)) {
ctx.portOpen = true
return
}
Expand All @@ -282,9 +294,9 @@ exports.handler = function ({
// Check until the wrapper is served
const checkWrapperReady = () => {
setTimeout(async () => {
const portTaken = await isPortTaken(CLIENT_PORT)
const portTaken = await isPortTaken(clientPort)
if (portTaken) {
opn(`http://localhost:${CLIENT_PORT}/#/${ctx.daoAddress}`)
opn(`http://localhost:${clientPort}/#/${ctx.daoAddress}`)
} else {
checkWrapperReady()
}
Expand All @@ -306,7 +318,7 @@ exports.handler = function ({

return tasks.run({ ens: apmOptions['ens-registry'] }).then(async (ctx) => {
if (ctx.portOpen) {
reporter.warning(`Server already listening at port ${CLIENT_PORT}, skipped starting Aragon`)
reporter.warning(`Server already listening at port ${clientPort}, skipped starting Aragon`)
}

if (ctx.notInitialized) {
Expand Down

0 comments on commit 2ed542c

Please sign in to comment.