1 | const path = require('path')
|
2 | const fs = require('fs-extra')
|
3 | const init = require('./init')
|
4 | const components = require('./components')
|
5 | const pkg = require('../package.json')
|
6 | const fixturesPath = path.join(__dirname, '../fixtures')
|
7 | const starterKitPath = path.join(fixturesPath, 'spr')
|
8 | const starterKitDistPath = path.join(starterKitPath, 'dist')
|
9 | const blinkComponentsPath1 = path.join(fixturesPath, 'HTMLComponents/blink-components-release')
|
10 | const blinkComponentsPath2 = path.join(fixturesPath, 'HTMLComponents/blink-components')
|
11 |
|
12 | const cmd = process.argv[process.argv.length - 1]
|
13 | if (cmd === 'generate') {
|
14 | fs.ensureDir(starterKitDistPath)
|
15 | fs.ensureDir(blinkComponentsPath1)
|
16 | fs.ensureDir(blinkComponentsPath2)
|
17 | Promise.all([
|
18 | init({ program: { cwd: starterKitPath, silent: true }, pkg, env: { }, starterKit: 'spr' }),
|
19 | components({ pkg, env: { dest: blinkComponentsPath1, force: true }, program: { silent: true } }),
|
20 | components({ pkg, env: { dest: blinkComponentsPath2, force: true }, program: { silent: true } })
|
21 | ]).then(() => {
|
22 | fs.copyFile(path.join(fixturesPath, 'animate-cc-output/spr_creative.html'), path.join(starterKitPath, 'src/spr_creative.html'))
|
23 | fs.copyFile(path.join(fixturesPath, 'animate-cc-output/spr_creative.js'), path.join(starterKitPath, 'src/spr_creative.js'))
|
24 | fs.copyFile(path.join(fixturesPath, 'animate-cc-output/dist/manifest.json'), path.join(starterKitDistPath, 'manifest.json'))
|
25 | })
|
26 | setTimeout(() => {}, 4000)
|
27 | } else if (cmd === 'clean') {
|
28 | fs.remove(starterKitPath)
|
29 | fs.remove(blinkComponentsPath1)
|
30 | fs.remove(blinkComponentsPath2)
|
31 | } else {
|
32 | console.error('Use `clean` or `generate` commands.')
|
33 | }
|