Skip to content

Commit

Permalink
refactor: improvements to install script
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Jul 29, 2019
1 parent 4951099 commit 04ed9eb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
9 changes: 9 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

import { ensureDirSync } from 'fs-extra'
import { bgRed, red } from 'kleur'
import { isAbsolute, join, basename } from 'path'
import { Application } from '@poppinss/application'
Expand All @@ -26,6 +27,14 @@ export async function runTasks (projectRoot: string) {
const application = new Application(projectRoot, {} as any, {}, {})
const absPath = isAbsolute(projectRoot) ? projectRoot : join(process.cwd(), projectRoot)

/**
* Create directory if missing
*/
ensureDirSync(absPath)

/**
* Ensure that directory is empty
*/
const isEmpty = isEmptyDir(absPath)
if (!isEmpty) {
console.log(bgRed(`Error`))
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@
},
"dependencies": {
"@adonisjs/fold": "^6.1.2",
"@adonisjs/sink": "^2.0.9",
"@adonisjs/sink": "^2.0.11",
"@poppinss/application": "^1.0.7",
"fs-extra": "^8.1.0",
"kleur": "^3.0.3",
"randomstring": "^1.1.5"
},
Expand Down
33 changes: 20 additions & 13 deletions tasks/createPackageFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,32 @@ export default function createPackageFile (basePath: string, appName: string) {
pkg.setScript('build', 'adonis build')
pkg.setScript('start', 'adonis serve --dev')

/**
* Use yarn when executed as `yarn create`
*/
if (process.env.npm_execpath && process.env.npm_execpath.includes('yarn')) {
pkg.yarn(true)
}

/**
* Prod dependencies
*/
pkg.install({
'@adonisjs/core': 'latest',
'@adonisjs/fold': 'next',
'reflect-metadata': 'latest',
}, false)
pkg.install('@adonisjs/core', 'latest', false)
pkg.install('@adonisjs/fold', '6', false)
pkg.install('reflect-metadata', 'latest', false)

/**
* Dev dependencies
*/
pkg.install([
'typescript',
'youch',
'youch-terminal',
'pino-pretty',
'tslint',
'adonis-preset-ts',
])
pkg.install('typescript')
pkg.install('youch')
pkg.install('youch-terminal')
pkg.install('pino-pretty')
pkg.install('tslint')
pkg.install('adonis-preset-ts')

/**
* Commit mutations
*/
pkg.commit()
}

0 comments on commit 04ed9eb

Please sign in to comment.