forked from adonisjs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstructions.ts
More file actions
48 lines (43 loc) · 1.41 KB
/
instructions.ts
File metadata and controls
48 lines (43 loc) · 1.41 KB
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
/*
* @adonisjs/core
*
* (c) Harminder Virk <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { join } from 'path'
import * as sinkStatic from '@adonisjs/sink'
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
const APP_TEMPLATE_STUB = join(__dirname, './templates', 'config', 'app.txt')
const STATIC_TEMPLATE_STUB = join(__dirname, './templates', 'config', 'static.txt')
export default async function instructions (
projectRoot: string,
_: ApplicationContract,
{ logger, files }: typeof sinkStatic,
) {
const isApiBoilerplate = process.env['ADONIS_CREATE_APP_BOILERPLATE'] === 'api'
/**
* Create app config file
*/
const appConfig = new files.MustacheFile(projectRoot, 'config/app.ts', APP_TEMPLATE_STUB)
if (appConfig.exists()) {
logger.skip('config/app.ts')
} else {
appConfig.apply({ forceContentNegotiationToJSON: isApiBoilerplate }).commit()
logger.create('config/app.ts')
}
/**
* Create static config file when boilerplate
* is not for the api
*/
if (!isApiBoilerplate) {
const staticConfig = new files.MustacheFile(projectRoot, 'config/static.ts', STATIC_TEMPLATE_STUB)
if (staticConfig.exists()) {
logger.skip('config/static.ts')
} else {
staticConfig.apply({}).commit()
logger.create('config/static.ts')
}
}
}