UNPKG

1.7 kBJavaScriptView Raw
1const path = require('path')
2const fs = require('fs-extra')
3const init = require('./init')
4const components = require('./components')
5const pkg = require('../package.json')
6const fixturesPath = path.join(__dirname, '../fixtures')
7const starterKitPath = path.join(fixturesPath, 'spr')
8const starterKitDistPath = path.join(starterKitPath, 'dist')
9const blinkComponentsPath1 = path.join(fixturesPath, 'HTMLComponents/blink-components-release')
10const blinkComponentsPath2 = path.join(fixturesPath, 'HTMLComponents/blink-components')
11
12const cmd = process.argv[process.argv.length - 1] // could be `generate` or `clean`
13if (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}