From 35d422e8e39a36c04f120d8a2f30d161fbcd4afa Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 24 Nov 2019 09:00:00 -0300 Subject: [PATCH 1/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7872d33..033c3b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aragon/aragen", - "version": "5.3.6", + "version": "5.4.1", "description": "Generate Aragon local dev environment snapshots", "main": "index.js", "bin": { From b06cae08e2a4f955dcfeb068e335d74ded13fbe2 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sun, 24 Nov 2019 09:00:12 -0300 Subject: [PATCH 2/4] 5.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 033c3b3..5eda29f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aragon/aragen", - "version": "5.4.1", + "version": "5.4.2", "description": "Generate Aragon local dev environment snapshots", "main": "index.js", "bin": { From 4a44b9a1c02e2bb272022bbd30795033a1de6348 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 16 Dec 2019 05:52:33 -0300 Subject: [PATCH 3/4] Move commands logic to aragon-cli --- .travis.yml | 50 ++--- index.js | 12 +- lib.js | 6 - package.json | 35 +--- readme.md | 14 +- {src => scripts}/helpers/ganache-vars.js | 0 scripts/start-ganache | 2 +- src/cli.js | 51 ----- src/commands/start.js | 239 ----------------------- src/commands/status.js | 71 ------- webpack/plugins.js | 22 --- webpack/webpack.node.config.js | 37 ---- 12 files changed, 43 insertions(+), 496 deletions(-) delete mode 100644 lib.js rename {src => scripts}/helpers/ganache-vars.js (100%) delete mode 100755 src/cli.js delete mode 100644 src/commands/start.js delete mode 100644 src/commands/status.js delete mode 100644 webpack/plugins.js delete mode 100644 webpack/webpack.node.config.js diff --git a/.travis.yml b/.travis.yml index 70328a9..fe25b31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,25 @@ -language: node_js -notifications: - email: true -node_js: - - '8' -install: - - travis_wait 60 npm install - - travis_wait 60 npm run get-client - - travis_wait 60 npm run get-core-apps - - travis_wait 60 npm run get-dao-templates - - travis_wait 60 npm run get-fundraising - - travis_wait 60 npm run get-open-enterprise - - npm run start -before_script: - - npm prune -before_deploy: echo 'Starting publish to NPM' -deploy: - skip_cleanup: true - provider: npm - email: jorge+npmci@aragon.one - api_key: - secure: UO/9KUzMStVfgR+pOjURKK+mCrjVsP2a9GhrbpclL9yCGyylHe0uyGX5/pF+crMHoSjgYoew00UZgKEfzSIdYiR7h2hs5J+wcTOnSjapevL4/NA0C608fQOilb7Fj5vmxSuYTjZHCUvEcmTVmGU+zpw+YHYtyl5rmONwWZXHKQzKSPflzl0rJL+HMTgJYjbOB3RqxwK7kcW58wWkJl+x1aFxK1KMTnqUHS8FOITo1c7Gn0wPEPSPogzkXh8RVOpA4xkNbOP2gqqfpfuzBuDhULK1MBxvnSnuvaXBHAFaF1a++wj65+f3mo8zpHOIm6n/rcAbQC5siRHZph83K4oszdPf+oxRXneuezFogdoHlUdKUFy7Kdmca/HYYZDlstH3ERrC/apKyh4+5MG7ElCf1V8xItG1XySbLpMnCs0EYsxnoo1XtLeIBJop2nPbsrpBQULkq6Z7zn+tIU8SSAd5hqnfsa+pkvMKbPirzhy7xdyhK2iV97P+y0EkEEI4MOhjGRbyHOyS5ATeXbKb+l3ZcooJ6+rJz9YvjVsF4Ivy0RDfdADKKR1RLQ3Pw1/MBooTGBAUuw4/RopO5h4h2ivyNpfxkWikS86fn8nyZrGZGQe1lJOIgZ8GEtUppYhmd70jilaY5VGRelXQGYrFt+eBAiDcqYGeMDmOa8ZaTjFSS9k= - on: - branch: master - repo: aragon/aragen +# language: node_js +# notifications: +# email: true +# node_js: +# - '8' +# install: +# - travis_wait 60 npm install +# - travis_wait 60 npm run get-client +# - travis_wait 60 npm run get-core-apps +# - travis_wait 60 npm run get-dao-templates +# - travis_wait 60 npm run get-fundraising +# - travis_wait 60 npm run get-open-enterprise +# - npm run start +# before_script: +# - npm prune +# before_deploy: echo 'Starting publish to NPM' +# deploy: +# skip_cleanup: true +# provider: npm +# email: jorge+npmci@aragon.one +# api_key: +# secure: UO/9KUzMStVfgR+pOjURKK+mCrjVsP2a9GhrbpclL9yCGyylHe0uyGX5/pF+crMHoSjgYoew00UZgKEfzSIdYiR7h2hs5J+wcTOnSjapevL4/NA0C608fQOilb7Fj5vmxSuYTjZHCUvEcmTVmGU+zpw+YHYtyl5rmONwWZXHKQzKSPflzl0rJL+HMTgJYjbOB3RqxwK7kcW58wWkJl+x1aFxK1KMTnqUHS8FOITo1c7Gn0wPEPSPogzkXh8RVOpA4xkNbOP2gqqfpfuzBuDhULK1MBxvnSnuvaXBHAFaF1a++wj65+f3mo8zpHOIm6n/rcAbQC5siRHZph83K4oszdPf+oxRXneuezFogdoHlUdKUFy7Kdmca/HYYZDlstH3ERrC/apKyh4+5MG7ElCf1V8xItG1XySbLpMnCs0EYsxnoo1XtLeIBJop2nPbsrpBQULkq6Z7zn+tIU8SSAd5hqnfsa+pkvMKbPirzhy7xdyhK2iV97P+y0EkEEI4MOhjGRbyHOyS5ATeXbKb+l3ZcooJ6+rJz9YvjVsF4Ivy0RDfdADKKR1RLQ3Pw1/MBooTGBAUuw4/RopO5h4h2ivyNpfxkWikS86fn8nyZrGZGQe1lJOIgZ8GEtUppYhmd70jilaY5VGRelXQGYrFt+eBAiDcqYGeMDmOa8ZaTjFSS9k= +# on: +# branch: master +# repo: aragon/aragen diff --git a/index.js b/index.js index 11585be..eadb630 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ module.exports = { - // ENS is deterministically deployed to this address + // Addresses deterministically deployed ens: '0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1', - commands: { - start: require('./src/commands/start'), - status: require('./src/commands/status'), - }, + daoFacotry: '0x5d94e3e7aec542ab0f9129b9a7badeb5b3ca0f77', + minimeFactory: '0xd526b7aba39cccf76422835e7fd5327b98ad73c9', + fifsResolvingRegistrar: '0xf1f8aac64036cdd399886b1c157b7e3b361093f3', + apmRegistry: '0x32296d9f8fed89658668875dc73cacf87e8888b2', + openRegistry: '0x983f1d68a781abbc3a49676a6399dd173de25105', + hatchRegistry: '0xd4592f8b2116d00fc4ce183773eb24c584060cfc', } diff --git a/lib.js b/lib.js deleted file mode 100644 index 7329b20..0000000 --- a/lib.js +++ /dev/null @@ -1,6 +0,0 @@ -// make sourcemaps work! -require('source-map-support').install(); - -module.exports = require("ganache-core/public-exports.js"); -module.exports.version = require("ganache-core/package.json").version; -module.exports.to = require("ganache-core/lib/utils/to"); diff --git a/package.json b/package.json index 5eda29f..cac8e4f 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,9 @@ { "name": "@aragon/aragen", - "version": "5.4.2", + "version": "6.0.0-beta.1", "description": "Generate Aragon local dev environment snapshots", "main": "index.js", - "bin": { - "aragen": "./src/cli.js" - }, "scripts": { - "prepublishOnly": "npm run build", - "build": "webpack-cli --config ./src/webpack/webpack.node.config.js", "start": "npm run start-ganache-bg && npm run deploy", "start:local": "npm run start-ganache-bg && npm run link-repos && npm run deploy", "link-repos": "scripts/link-repos", @@ -31,8 +26,7 @@ "files": [ "index.js", "aragon-ganache", - "ipfs-cache", - "src" + "ipfs-cache" ], "repository": { "type": "git", @@ -47,20 +41,7 @@ "url": "https://github.com/aragon/aragen/issues" }, "homepage": "https://github.com/aragon/aragen#readme", - "dependencies": { - "@aragon/cli-utils": "^0.0.8", - "@babel/polyfill": "^7.0.0", - "chalk": "^2.1.0", - "ethers": "^4.0.0", - "execa": "^2.0.3", - "find-process": "^1.4.2", - "listr": "^0.14.3", - "mkdirp": "^0.5.1", - "ncp": "^2.0.0", - "rimraf": "^2.6.2", - "source-map-support": "0.5.12", - "yargs": "^13.2.4" - }, + "dependencies": {}, "devDependencies": { "@aragon/cli": "^6.0.0", "@aragon/id": "^2.0.0", @@ -69,15 +50,7 @@ "eth-ens-namehash": "^2.0.8", "ganache-cli": "^6.7.0", "ganache-core": "^2.8.0", - "js-scrypt": "0.2.0", - "node-loader": "^0.6.0", - "on-build-webpack": "^0.1.0", - "prepend-file": "^1.3.1", - "scrypt": "6.0.3", - "shebang-loader": "0.0.1", - "truffle": "4.1.14", - "webpack": "^4.18.0", - "webpack-cli": "3.1.0" + "truffle": "4.1.14" }, "publishConfig": { "access": "public" diff --git a/readme.md b/readme.md index 48f0ed1..3e73d5b 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,7 @@ Generate an Aragon environment ``` npm i +npm run gen npm start ``` @@ -29,17 +30,14 @@ The Aragen package published to NPM contains a ganache snapshot that can be used By default it has set up: - ENS: `0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1` +- DAO_FACTORY: `0x5d94e3e7aec542ab0f9129b9a7badeb5b3ca0f77` +- MINIME_FACTORY: `0xd526b7aba39cccf76422835e7fd5327b98ad73c9` +- FIFResolvingRegistrar: `0xf1f8aac64036cdd399886b1c157b7e3b361093f3` + - APM: `ens.addr('aragonpm.eth')` - AragonID: `ens.owner('aragonid.eth')` - Aragon apps: As APM repos, e.g. `apm.getLatest('voting.aragonpm.eth')` -- Beta templates: As APM repos, e.g. `apm.getLatest('democracy-template.aragonpm.eth')` - -To use directly with ganache-cli: - -``` -npm install @aragon/aragen -npx aragen start -``` +- Templates: As APM repos, e.g. `apm.getLatest('democracy-template.aragonpm.eth')` If you wish to access from code, for example to run ganache-core directly: diff --git a/src/helpers/ganache-vars.js b/scripts/helpers/ganache-vars.js similarity index 100% rename from src/helpers/ganache-vars.js rename to scripts/helpers/ganache-vars.js diff --git a/scripts/start-ganache b/scripts/start-ganache index 1048729..f3ae40a 100755 --- a/scripts/start-ganache +++ b/scripts/start-ganache @@ -2,7 +2,7 @@ cd $(dirname $0)/.. BASEPATH=$(pwd) -mnemonic=$(node -p "require(require('path').join(\"${BASEPATH}\", 'src/helpers/ganache-vars')).MNEMONIC") +mnemonic=$(node -p "require(require('path').join(\"${BASEPATH}\", 'scripts/helpers/ganache-vars')).MNEMONIC") rm -rf aragon-ganache mkdir aragon-ganache diff --git a/src/cli.js b/src/cli.js deleted file mode 100755 index 8a60350..0000000 --- a/src/cli.js +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node - -// make sourcemaps work! -require('source-map-support').install() - -require('@babel/polyfill') -const ConsoleReporter = require('@aragon/cli-utils/src/reporters/ConsoleReporter') - -// Set up commands -const cmd = require('yargs') - .strict() - .parserConfiguration({ - 'parse-numbers': false, - }) - .usage(`Usage: aragen [options]`) - .commandDir('./commands') - -cmd.alias('h', 'help') - -// Configure CLI behavior -cmd.demandCommand(1, 'You need to specify a command') - -// Set global options -cmd.option('silent', { - description: 'Silence output to terminal', - default: false, -}) - -cmd.option('debug', { - description: 'Show more output to terminal', - default: false, - coerce: debug => { - if (debug || process.env.DEBUG) { - global.DEBUG_MODE = true - return true - } - }, -}) - -// Run -const reporter = new ConsoleReporter() -// reporter.debug(JSON.stringify(process.argv)) -cmd - .fail((msg, err, yargs) => { - if (!err) yargs.showHelp() - reporter.error(msg || err.message || 'An error occurred') - reporter.debug(err && err.stack) - }) - .parse(process.argv.slice(2), { - reporter, - }) diff --git a/src/commands/start.js b/src/commands/start.js deleted file mode 100644 index 0f542c0..0000000 --- a/src/commands/start.js +++ /dev/null @@ -1,239 +0,0 @@ -const TaskList = require('listr') -const ncp = require('ncp') -const ganache = require('../build/ganache-core.node.cli.js') -const ethers = require('ethers') -const { promisify } = require('util') -const os = require('os') -const path = require('path') -const rimraf = require('rimraf') -const mkdirp = require('mkdirp') -const chalk = require('chalk') -const fs = require('fs') -const listrOpts = require('@aragon/cli-utils/src/helpers/listr-options') -const pjson = require('../../package.json') -const devchainStatus = require('./status') - -const { BLOCK_GAS_LIMIT, MNEMONIC } = require('../helpers/ganache-vars') - -exports.command = 'start' - -exports.describe = - 'Open a test chain for development and pass arguments to ganache' - -exports.builder = yargs => { - return yargs - .option('port', { - description: 'The port to run the local chain on', - default: 8545, - alias: 'p', - }) - .option('network-id', { - description: 'Network id to connect with', - alias: 'i', - }) - .option('block-time', { - description: 'Specify blockTime in seconds for automatic mining', - alias: 'b', - }) - .option('gas-limit', { - default: BLOCK_GAS_LIMIT, - description: 'Block gas limit. Must be specified as a hex string', - alias: 'l', - }) - .option('reset', { - type: 'boolean', - default: false, - description: 'Reset devchain to snapshot', - alias: 'r', - }) - .option('accounts', { - default: 2, - description: 'Number of accounts to print', - alias: 'a', - }) - .option('verbose', { - default: false, - type: 'boolean', - description: 'Enable verbose devchain output', - alias: 'v', - }) -} - -exports.task = async function({ - port = 8545, - networkId, - blockTime, - gasLimit = BLOCK_GAS_LIMIT, - verbose = false, - reset = false, - showAccounts = 2, - reporter, - silent, - debug, -}) { - const removeDir = promisify(rimraf) - const mkDir = promisify(mkdirp) - const recursiveCopy = promisify(ncp) - - const snapshotPath = path.join( - os.homedir(), - `.aragon/aragen-db-${pjson.version}` - ) - - const tasks = new TaskList( - [ - { - title: 'Check devchain status', - task: async ctx => { - const task = await devchainStatus.task({ - port, - reset, - silent, - debug, - }) - - const { portTaken, processID } = await task.run() - - if (portTaken && !reset) { - throw new Error( - `Process with ID ${chalk.red( - processID - )} already running at port ${chalk.blue(port)}` - ) - } - }, - }, - { - title: 'Setting up a new chain from latest Aragon snapshot', - task: async (ctx, task) => { - await removeDir(snapshotPath) - await mkDir(path.resolve(snapshotPath, '..')) - const snapshot = path.join(__dirname, '../../aragon-ganache') - await recursiveCopy(snapshot, snapshotPath) - }, - enabled: () => !fs.existsSync(snapshotPath) || reset, - }, - { - title: 'Starting a local chain from snapshot', - task: async (ctx, task) => { - ctx.id = parseInt(networkId) || parseInt(1e8 * Math.random()) - - const options = { - network_id: ctx.id, - blockTime, - gasLimit, - mnemonic: MNEMONIC, - db_path: snapshotPath, - logger: verbose ? { log: reporter.info.bind(reporter) } : undefined, - debug, - } - - const server = ganache.server(options) - - const listen = () => - new Promise((resolve, reject) => { - server.listen(port, err => { - if (err) return reject(err) - - task.title = `Local chain started at port ${chalk.blue(port)}\n` - resolve() - }) - }) - await listen() - - ctx.mnemonic = MNEMONIC - - ctx.wallets = [] - - for (i = 1; i <= showAccounts; i++) { - let path = `m/44'/60'/0'/0/${i - 1}` - ctx.wallets.push(ethers.Wallet.fromMnemonic(MNEMONIC, path)) - } - }, - }, - ], - listrOpts(silent, debug) - ) - - return tasks -} - -exports.printAccounts = (reporter, wallets) => { - const firstAccountComment = - '(account used to deploy DAOs, has more permissions)' - - const formattedAccounts = wallets.map( - ({ address, privateKey }, i) => - `Address #${i + 1}: ${chalk.green(address)} ${ - i === 0 ? firstAccountComment : '' - }\nPrivate key: ` + - chalk.blue(privateKey) + - '\n' - ) - - reporter.info(`Here are some Ethereum accounts you can use. - The first one will be used for all the actions the aragonCLI performs. - You can use your favorite Ethereum provider or wallet to import their private keys. - \n${formattedAccounts.join('\n')}`) -} - -exports.printMnemonic = (reporter, mnemonic) => { - reporter.info( - `The accounts were generated from the following mnemonic phrase:\n${chalk.blue( - mnemonic - )}\n` - ) -} - -exports.printResetNotice = (reporter, reset) => { - if (reset) { - reporter.warning(`${chalk.yellow( - 'The devchain was reset, some steps need to be done to prevent issues:' - )} - - Reset the application cache in Aragon Client by going to Settings -> Troubleshooting. - - If using Metamask: switch to a different network, and then switch back to the 'Private Network' (this will clear the nonce cache and prevent errors when sending transactions) - `) - } -} - -exports.handler = async ({ - reporter, - port, - networkId, - blockTime, - gasLimit, - reset, - verbose, - accounts, - silent, - debug, -}) => { - const task = await exports.task({ - port, - networkId, - blockTime, - gasLimit, - reset, - verbose, - reporter, - showAccounts: accounts, - silent, - debug, - }) - const { wallets, id, mnemonic } = await task.run() - exports.printAccounts(reporter, wallets) - exports.printMnemonic(reporter, mnemonic) - exports.printResetNotice(reporter, reset) - - reporter.info( - 'ENS instance deployed at:', - chalk.green('0x5f6f7e8cc7346a11ca2def8f827b7a0b612c56a1'), - '\n' - ) - - reporter.info(`Network Id: ${chalk.blue(id)}`, '\n') - - reporter.info( - `Devchain running at: ${chalk.blue('http://localhost:' + port)}.` - ) -} diff --git a/src/commands/status.js b/src/commands/status.js deleted file mode 100644 index 8ac4fed..0000000 --- a/src/commands/status.js +++ /dev/null @@ -1,71 +0,0 @@ -const TaskList = require('listr') -const chalk = require('chalk') -const listrOpts = require('@aragon/cli-utils/src/helpers/listr-options') -const { isPortTaken } = require('@aragon/cli-utils/src/util') -const execa = require('execa') -const find = require('find-process') - -exports.command = 'status' -exports.describe = 'Status of the local devchain.' - -exports.builder = yargs => { - return yargs.option('port', { - description: 'The port to check', - default: 8545, - }) -} - -exports.task = async ({ port, reset, silent, debug }) => { - return new TaskList( - [ - { - title: 'Check port', - task: async ctx => { - ctx.portTaken = await isPortTaken(port) - if (ctx.portTaken) { - const processData = await find('port', port) - ctx.processID = processData[0].pid - } - }, - }, - { - title: 'Kill running process', - enabled: ctx => ctx.portTaken && reset, - task: async ctx => { - await execa('kill', [ctx.processID]) - return `Process running at port ${chalk.blue(port)} was killed.` - }, - }, - ], - listrOpts(silent, debug) - ) -} - -exports.handler = async function({ - port, - reset = false, - reporter, - debug, - silent, -}) { - const task = await exports.task({ - port, - reset, - reporter, - debug, - silent, - }) - - const { portTaken, processID } = await task.run() - - reporter.newLine() - - if (portTaken && !reset) { - reporter.info(`Devchain running at port: ${chalk.blue(port)}`) - reporter.info(`Process ID: ${chalk.blue(processID)}`) - } else if (!reset) { - reporter.info(`Devchain is not running at port: ${chalk.blue(port)}`) - } - - reporter.newLine() -} diff --git a/webpack/plugins.js b/webpack/plugins.js deleted file mode 100644 index bfe1024..0000000 --- a/webpack/plugins.js +++ /dev/null @@ -1,22 +0,0 @@ -const { IgnorePlugin } = require("webpack"); -const WebpackOnBuildPlugin = require("on-build-webpack"); -const { EOL } = require("os"); -const { chmodSync, existsSync } = require("fs"); -const { join } = require("path"); - -const prependFile = require("prepend-file"); -module.exports = (outputDir, outputFilename) => { - return [ - // ignore these plugins completely - new IgnorePlugin(/^(?:electron|ws)$/), - - // Put the shebang back on and make sure it's executable. - new WebpackOnBuildPlugin(function () { - const outputFile = join(outputDir, outputFilename); - if (existsSync(outputFile)) { - prependFile.sync(outputFile, "#!/usr/bin/env node" + EOL); - chmodSync(outputFile, "755"); - } - }) - ]; -}; \ No newline at end of file diff --git a/webpack/webpack.node.config.js b/webpack/webpack.node.config.js deleted file mode 100644 index ed27754..0000000 --- a/webpack/webpack.node.config.js +++ /dev/null @@ -1,37 +0,0 @@ -const { resolve } = require('path') -const plugins = require('./plugins') - -const outputDir = resolve(__dirname, '../src/build') -const outputFilename = 'ganache-core.node.cli.js' -module.exports = { - entry: ['../lib.js'], - target: 'node', - output: { - path: outputDir, - filename: outputFilename, - library: 'Aragen', - libraryTarget: 'umd', - umdNamedDefine: true, - }, - devtool: 'source-map', - module: { - rules: [ - { - test: /\.js$/, - use: 'shebang-loader', - }, - ], - }, - externals: /^(source-map-support|yargs|bn.js)$/, - resolve: { - alias: { - // eth-block-tracker is es6 but automatically builds an es5 version for us on install. - 'eth-block-tracker': 'eth-block-tracker/dist/es5/index.js', - - // replace native `scrypt` module with pure js `js-scrypt` - scrypt: 'js-scrypt', - }, - }, - plugins: plugins(outputDir, outputFilename), - mode: 'production', -} From ce9fac8b434cf79b89944d5303973464864c20d1 Mon Sep 17 00:00:00 2001 From: Gabriel Garcia Date: Mon, 16 Dec 2019 05:56:09 -0300 Subject: [PATCH 4/4] Update readme.md --- readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.md b/readme.md index 3e73d5b..4840302 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,6 @@ Generate an Aragon environment ``` npm i -npm run gen npm start ```