1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const { json, install, uninstall } = require('mrm-core')
|
11 | const debug = require('debug')('adonis:mrm-package')
|
12 |
|
13 | class TsPreset {
|
14 | constructor () {
|
15 | this.dependencies = [
|
16 | '@adonisjs/require-ts',
|
17 | 'typescript',
|
18 | '@types/node',
|
19 | 'del-cli'
|
20 | ]
|
21 | }
|
22 |
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | install (baseDependencies) {
|
33 | const dependencies = baseDependencies.concat(this.dependencies)
|
34 |
|
35 | debug('installing dependencies %o', dependencies)
|
36 | install(dependencies)
|
37 | }
|
38 |
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | uninstall () {
|
47 | debug('removing dependencies %o', this.dependencies)
|
48 | uninstall(this.dependencies)
|
49 | }
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | up (pkgFile) {
|
61 | pkgFile.setScript('clean', 'del build')
|
62 | pkgFile.setScript('compile', 'npm run lint && npm run clean && tsc')
|
63 | pkgFile.setScript('build', 'npm run compile')
|
64 | pkgFile.setScript('prepublishOnly', 'npm run build')
|
65 |
|
66 | |
67 |
|
68 |
|
69 | if (!pkgFile.get('main')) {
|
70 | pkgFile.set('main', 'build/index.js')
|
71 | }
|
72 |
|
73 | if (!pkgFile.get('files')) {
|
74 | pkgFile.set('files', [
|
75 | 'build/src',
|
76 | 'build/index.d.ts',
|
77 | 'build/index.js'
|
78 | ])
|
79 | }
|
80 |
|
81 | debug('creating files %o', ['tsconfig.json'])
|
82 | json('tsconfig.json').merge({ extends: './node_modules/@adonisjs/mrm-preset/_tsconfig' }).save()
|
83 | }
|
84 | }
|
85 |
|
86 | module.exports = new TsPreset()
|