This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
New.ts
56 lines (46 loc) · 1.59 KB
/
New.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* @adonisjs/cli
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BaseCommand, flags, args } from '@adonisjs/ace'
import { Installer } from '../Services/Installer'
import { satisfiesNodeVersion, dumpAsciiLogo } from '../helpers'
/**
* Build the AdonisJs typescript project for production.
*/
export default class NewApp extends BaseCommand {
public static commandName = 'new'
public static description = 'Scaffold a new application'
@flags.boolean({ description: 'Use yarn instead of npm for installing dependencies' })
public yarn: boolean
@args.string({ description: 'The name/path of the project directory' })
public name: string
@flags.boolean({ description: 'Create project for REST API server' })
public apiOnly: boolean
/**
* Reference to the project root. It always has to be
* the current working directory
*/
public projectRoot = process.cwd()
/**
* Called by ace automatically, when this command is invoked
*/
public async handle () {
if (!satisfiesNodeVersion()) {
const message = [
`Unsatisfied Node.js version ${process.version}`,
'Please update Node.js to {10.15.3} before you continue',
]
this.logger.error(message.join(' '))
return
}
dumpAsciiLogo()
const installer = new Installer(this.projectRoot, this.yarn ? 'yarn' : 'npm', false)
const flags = this.apiOnly ? ['--boilerplate', 'api'] : ['--boilerplate', 'web']
installer.createApp(this.name, flags)
}
}