-
Notifications
You must be signed in to change notification settings - Fork 79
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
aragon init prepare template for environments #371
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,18 @@ export async function prepareTemplate(basename, appName) { | |
const arappPath = path.resolve(basename, 'arapp.json') | ||
const arapp = await fs.readJson(arappPath) | ||
|
||
// TODO remove once the old arapp.json is no longer supported | ||
if (!arapp.environments) { | ||
arapp.environments = {} | ||
} | ||
|
||
const props = { | ||
network: 'development', | ||
appName: appName, | ||
} | ||
|
||
if (arapp.environments.default) { | ||
Object.assign(arapp.environments.default, props) | ||
} else { | ||
arapp.environments.default = props | ||
} | ||
|
||
// remove old arapp.json props | ||
delete arapp.appName | ||
delete arapp.version | ||
const defaultEnv = arapp.environments.default | ||
const stagingEnv = arapp.environments.staging | ||
const productionEnv = arapp.environments.production | ||
|
||
defaultEnv.appName = appName | ||
Object.assign(arapp.environments.default, defaultEnv) | ||
|
||
stagingEnv.appName = stagingEnv.appName.replace(/^app/, appName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid we could have: - stagingEnv.appName = stagingEnv.appName.replace(/^app/, appName)
+ stagingEnv.appName = stagingEnv.appName.replace(/^app/, basename) this will work for the CLI, but break the test, because in the test we are passing a path: I think what we can do instead is some parsing in function prepareTemplate(path, appName) {
const basename = name.split('.')[0]
//...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right. This is better |
||
productionEnv.appName = productionEnv.appName.replace(/^app/, appName) | ||
|
||
Object.assign(arapp.environments.staging, stagingEnv) | ||
Object.assign(arapp.environments.production, productionEnv) | ||
|
||
const gitFolderPath = path.resolve(basename, '.git') | ||
const licensePath = path.resolve(basename, 'LICENSE') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,14 +27,24 @@ test('prepare project template', async t => { | |
const arappPath = `${projectPath}/arapp.json` | ||
const packageJsonPath = `${projectPath}/package.json` | ||
const licensePath = `${projectPath}/LICENSE` | ||
const appName = 'TestApp' | ||
const appName = 'aragon-app.aragonpm.eth' | ||
|
||
await fs.ensureDir(repoPath) | ||
await fs.ensureFile(arappPath) | ||
await fs.ensureFile(packageJsonPath) | ||
await fs.ensureFile(licensePath) | ||
await fs.writeJson(arappPath, { | ||
appName: 'boilerplate-placeholder', | ||
environments: { | ||
default: { | ||
appName: 'app.aragonpm.eth', | ||
}, | ||
staging: { | ||
appName: 'app.open.aragonpm.eth', | ||
}, | ||
production: { | ||
appName: 'app.open.aragonpm.eth', | ||
}, | ||
}, | ||
}) | ||
await fs.writeJson(packageJsonPath, { | ||
license: 'MIT', | ||
|
@@ -48,5 +58,7 @@ test('prepare project template', async t => { | |
t.falsy(await fs.pathExists(repoPath)) | ||
t.is(undefined, packageJson.license) | ||
t.falsy(fs.pathExistsSync(licensePath)) | ||
t.is(appName, project.environments.default.appName) | ||
t.is(`${appName}`, project.environments.default.appName) | ||
t.is(`${appName}.open.aragonpm.eth`, project.environments.staging.appName) | ||
t.is(`${appName}.open.aragonpm.eth`, project.environments.production.appName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like |
||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this, but it seems unnecessary to run
documentation lint
on the tests 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll include this change in #359