Skip to content

Commit

Permalink
Merge pull request aragon#20 from aragon/scaffolding
Browse files Browse the repository at this point in the history
Support scaffolding
  • Loading branch information
onbjerg authored and 0xGabi committed Jan 5, 2019
1 parent 094fdfb commit 74a46c7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/aragon-cli/bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const cli = meow(`
$ aragon-dev-cli <subcommand>
Commands
init <name> Initialize a new Aragon module (e.g. test.aragonpm.eth)
init <name> [template] Initialize a new Aragon module from a template (default template: react). The name must be a valid ENS name.
version <major|minor|patch> Bump the module version
versions List the published versions of this module
publish Publish a new version of the module
Expand Down
5 changes: 5 additions & 0 deletions packages/aragon-cli/package-lock.json

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

1 change: 1 addition & 0 deletions packages/aragon-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"chalk": "^2.1.0",
"decamelize": "^1.2.0",
"eth-ens-namehash": "^2.0.0",
"git-clone": "^0.1.0",
"ipfs-api": "^14.3.5",
"meow": "^3.7.0",
"npm-run": "^4.1.2",
Expand Down
29 changes: 21 additions & 8 deletions packages/aragon-cli/src/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const namehash = require('eth-ens-namehash')
const inspector = require('solidity-inspector')
const config = require('./config')()
const pkgDir = require('pkg-dir')
const clone = require('git-clone')

const prettyKey = (key) => {
let str = decamelize(key, ' ')
Expand All @@ -21,18 +22,30 @@ const prettyKey = (key) => {
}

const handlers = {
init ([name], flags) {
init ([name, template], flags) {
if (!name) {
reporter.fatal('No name specified')
}

pkg.write({
appName: name,
version: '1.0.0',
roles: [],
path: 'src/App.sol'
}).then(({ appName }) => {
reporter.info(`Created new module ${appName}`)
if (!template) {
template = 'react'
}

// Determine template repository name
const aliasedTemplates = {
bare: 'aragon/aragon-bare-boilerplate',
react: 'aragon/aragon-react-boilerplate'
}
if (aliasedTemplates[template]) template = aliasedTemplates[template]


// Clone the template into the directory
// TODO: Somehow write name to `manifest.json` in template?
// TODO: Write human-readable app name to `module.json`
const basename = name.split('.')[0]
reporter.info(`Cloning ${template} into ${basename}...`)
clone(`https://github.com/${template}`, basename, { shallow: true }, () => {
reporter.info(`Created new module ${name} in ${basename}`)
})
},
versions (_, flags) {
Expand Down

0 comments on commit 74a46c7

Please sign in to comment.