Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scaffolding #20

Merged
merged 5 commits into from Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/cli.js
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 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 package.json
Expand Up @@ -28,6 +28,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
26 changes: 18 additions & 8 deletions src/handle.js
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,27 @@ 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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should show an error (or at least warn the user) if an unknown template name is provided, instead of defaulting to the react boilerplate by default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 8f68ca5 suffice for that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah


// Clone the template into the directory
// TODO: Somehow write name to `manifest.json` in template?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to appName on module.json also

const basename = name.split('.')[0]
clone(`https://github.com/${template}`, basename, { shallow: true }, () => {
reporter.info(`Created new module ${name} in ${basename}`)
})
},
versions (_, flags) {
Expand Down