1 | const path = require('path')
|
2 | const shelljs = require('shelljs')
|
3 |
|
4 | const { version } = require('../package.json')
|
5 | const { shouldUseYarn } = require('../dist/util')
|
6 | const Project = require('../dist/create/project').default
|
7 |
|
8 | class GenerateLockfile extends Project {
|
9 | copy () {
|
10 | const cwd = process.cwd()
|
11 | const {projectName, template} = this.conf
|
12 | const lockfileDir = path.join(this.templatePath(), template, 'yarn-lockfiles')
|
13 | shelljs.cd(cwd)
|
14 | shelljs.rm('-rf', lockfileDir)
|
15 | shelljs.mkdir('-p', lockfileDir)
|
16 | shelljs.cp('-r', `${projectName}/yarn.lock`, `${lockfileDir}/${version}-yarn.lock`)
|
17 | shelljs.rm('-rf', projectName)
|
18 | }
|
19 |
|
20 | start () {
|
21 | this.write(this.copy.bind(this))
|
22 | }
|
23 | }
|
24 |
|
25 | if (shouldUseYarn) {
|
26 | const generateLockfile = new GenerateLockfile({
|
27 | projectName: 'temp',
|
28 | template: 'default',
|
29 | typescript: false,
|
30 | env: 'test'
|
31 | })
|
32 | generateLockfile.start()
|
33 | }
|