-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.ts
38 lines (34 loc) · 1.17 KB
/
instructions.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
/*
* adonisjs-cloudinary
*
* (c) Liam Edwards <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
import * as sinkStatic from '@adonisjs/sink'
import { join } from 'path'
function getStub(...relativePaths: string[]) {
return join(__dirname, 'templates', ...relativePaths)
}
export default async function instructions(projectRoot: string, app: ApplicationContract, sink: typeof sinkStatic) {
// Config
const configPath = app.configPath('cloudinary.ts')
const cloudinaryConfig = new sink.files.TemplateLiteralFile(
projectRoot,
configPath,
getStub('cloudinary.txt')
)
cloudinaryConfig.apply().commit()
const configDir = app.directoriesMap.get('config') || 'config'
sink.logger.action('create').succeeded(`${configDir}/cloudinary.ts`)
// .env
const env = new sink.files.EnvFile(projectRoot)
env.set('CLOUDINARY_CLOUD_NAME', '')
env.set('CLOUDINARY_API_KEY', '')
env.set('CLOUDINARY_API_SECRET', '')
env.set('CLOUDINARY_SECURE', '')
env.commit()
sink.logger.action('update').succeeded('.env,.env.example')
}