diff --git a/package.json b/package.json index 94816c0..4ef32ee 100755 --- a/package.json +++ b/package.json @@ -10,11 +10,11 @@ "prepublishOnly": "npm run start", "start": "npm run start-ganache-bg && npm run get-repos && npm run gen", "start:local": "npm run start-ganache-bg && npm run link-repos && npm run gen", - "gen": "scripts/deploy-base && scripts/publish-apps && scripts/publish-kits", - "start-ganache": "scripts/start-ganache", - "start-ganache-bg": "scripts/start-ganache-bg", + "gen": "sh scripts/deploy-base && sh scripts/publish-apps && sh scripts/publish-kits", + "start-ganache": "node scripts/start-ganache", + "start-ganache-bg": "node scripts/start-ganache-bg", "get-repos": "scripts/get-repos", - "link-repos": "scripts/link-repos", + "link-repos": "node scripts/link-repos", "deploy-base": "scripts/deploy-base", "deploy-beta": "scripts/deploy-beta" }, @@ -41,10 +41,12 @@ "chalk": "^2.1.0", "figures": "^2.0.0", "ganache-core": "^2.2.1", + "kill-port-process": "0.0.6", "listr": "^0.13.0", "ncp": "^2.0.0", "mkdirp": "^0.5.1", "rimraf": "^2.6.2", + "shelljs": "^0.8.3", "web3": "^1.0.0-beta.34", "yargs": "^12.0.2" }, diff --git a/scripts/deploy-base b/scripts/deploy-base deleted file mode 100755 index f9f776d..0000000 --- a/scripts/deploy-base +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -e; -source scripts/set-env; - -echo "Make sure you are on an empty chain running with the default mnemonic" -sleep 2; # let the people read - -echo "Deploying ENS instance" -cd repos/aragonOS; -npx truffle compile; -DEPLOYED_ENS=$(npx truffle exec --network rpc scripts/deploy-test-ens.js | tail -n 1) -if [ "${ENS}" = "${DEPLOYED_ENS}" ]; then - echo "ENS deployed $DEPLOYED_ENS" -else - echo >&2 "ENS address missmatch. Please restart ganache by running:"; - echo "npm run start-ganache"; - rm -rf aragon-ganache; - exit 1; -fi - -echo "Deploying APM registry to aragonpm.eth" -npx truffle exec --network rpc scripts/deploy-apm.js - -cd ../aragon-id; -echo "Deploying aragonID registry to aragonpm.eth" -npx truffle compile; -npx truffle exec --network rpc scripts/deploy-beta-aragonid.js; diff --git a/scripts/deploy-base.js b/scripts/deploy-base.js new file mode 100644 index 0000000..7180729 --- /dev/null +++ b/scripts/deploy-base.js @@ -0,0 +1,29 @@ +const { echo, exec, cd, exit, rm } = require('shelljs') +require('./set-env') + +echo('Make sure you are on an empty chain running with the default mnemonic') +// sleep 2; # let the people read + +echo('Deploying ENS instance') +cd('repos/aragonOS') +// exec('npx truffle compile') +const DEPLOYED_ENS = exec('npx truffle exec --network rpc scripts/deploy-test-ens.js') //| tail -n 1 +console.log(DEPLOYED_ENS.stdout) + +if(process.env.ENS === DEPLOYED_ENS) { + echo('ENS deployed $DEPLOYED_ENS') +} else { + // echo >&2 "ENS address missmatch. Please restart ganache by running:"; + echo('ENS address missmatch. Please restart ganache by running:') + echo('npm run start-ganache') + rm('-rf', 'aragon-ganache') + exit(1) +} + +echo('Deploying APM registry to aragonpm.eth') +exec('npx truffle exec --network rpc scripts/deploy-apm.js') + +cd('../aragon-id') +echo('Deploying aragonID registry to aragonpm.eth') +exec('npx truffle compile') +exec('npx truffle exec --network rpc scripts/deploy-beta-aragonid.js') diff --git a/scripts/link-repos b/scripts/link-repos deleted file mode 100755 index 282dc74..0000000 --- a/scripts/link-repos +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -e; -echo "Cleaning and creating 'repos' dir" -rm -rf repos; -mkdir repos; - -cd repos - -echo "Linking to local repos" -ln -s ../../aragonOS aragonOS -ln -s ../../aragon-apps aragon-apps -ln -s ../../aragon-id aragon-id -ln -s ../../dao-kits dao-kits diff --git a/scripts/link-repos.js b/scripts/link-repos.js new file mode 100644 index 0000000..8c0521c --- /dev/null +++ b/scripts/link-repos.js @@ -0,0 +1,14 @@ +const { mkdir, echo, rm, cd, ln } = require('shelljs') + +// TODO set -e; +echo('Cleaning and creating "repos" dir') +rm('-rf', 'repos') +mkdir('repos') + +cd('repos') + +echo('Linking to local repos') +ln('-s', '../../aragonOS', 'aragonOS') +ln('-s', '../../aragon-apps', 'aragon-apps') +ln('-s', '../../aragon-id', 'aragon-id') +ln('-s', '../../dao-kits', 'dao-kits') diff --git a/scripts/set-env b/scripts/set-env deleted file mode 100755 index 60b9c02..0000000 --- a/scripts/set-env +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -export OWNER="0xb4124ceb3451635dacedd11767f004d8a28c6ee7" -export ENS="0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1" \ No newline at end of file diff --git a/scripts/set-env.js b/scripts/set-env.js new file mode 100644 index 0000000..b03e662 --- /dev/null +++ b/scripts/set-env.js @@ -0,0 +1,2 @@ +process.env.OWNER = "0xb4124ceb3451635dacedd11767f004d8a28c6ee7" +process.env.ENS = "0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1" diff --git a/scripts/start-ganache b/scripts/start-ganache deleted file mode 100755 index 8c98d43..0000000 --- a/scripts/start-ganache +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -cd $(dirname $0)/.. -BASEPATH=$(pwd) -mnemonic=$(node -p "require(require('path').join(\"${BASEPATH}\", 'src/helpers/ganache-vars')).MNEMONIC") - -rm -rf aragon-ganache -mkdir aragon-ganache -set -e; -npx ganache-cli -m "${mnemonic}" -i 15 -l 100000000 --db aragon-ganache diff --git a/scripts/start-ganache-bg b/scripts/start-ganache-bg deleted file mode 100755 index 4d33e18..0000000 --- a/scripts/start-ganache-bg +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set +e; -kill -9 $(lsof -t -i:8545); -set -e; - -echo "Starting ganache in the background"; - -nohup npm run start-ganache & diff --git a/scripts/start-ganache-bg.js b/scripts/start-ganache-bg.js new file mode 100644 index 0000000..227458c --- /dev/null +++ b/scripts/start-ganache-bg.js @@ -0,0 +1,20 @@ +const { echo, exec } = require('shelljs') +const kill = require('kill-port-process') + +async function execute () { + echo('Checking if the port 8545 is busy') + try { + await kill(8545) + } catch (e) { + echo('Nothing was running on port 8545') + } + + echo('Starting ganache in the background') + + // TODO nohup npm run start-ganache & + exec('npm run start-ganache', { + detached: true // is it working? + }) +} + +execute() diff --git a/scripts/start-ganache.js b/scripts/start-ganache.js new file mode 100644 index 0000000..e491afd --- /dev/null +++ b/scripts/start-ganache.js @@ -0,0 +1,13 @@ +const { echo, mkdir, pwd, rm, exec } = require('shelljs') + +const BASEPATH = pwd().toString() + +// TODO cd $(dirname $0) /.. + +const mnemonic = require(require('path').join(BASEPATH, 'src/helpers/ganache-vars')).MNEMONIC +echo(mnemonic) + +rm('-rf','aragon-ganache') +mkdir('aragon-ganache') +// TODO # set - e; +exec(`npx ganache-cli -m "${mnemonic}" -i 15 -l 100000000 --db aragon-ganache`)