1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | 'use strict';
|
13 |
|
14 | const path = require( 'path' );
|
15 | const fs = require( 'fs-extra' );
|
16 | const execa = require( 'execa' );
|
17 | const shell = require( 'shelljs' );
|
18 |
|
19 | module.exports = ( blockName, blockDir ) => {
|
20 | shell.cd( blockDir );
|
21 | shell.touch( 'package.json' );
|
22 |
|
23 |
|
24 | const appPackage = {
|
25 | name: `${ blockName }-cgb-guten-block`,
|
26 | version: '1.0.0',
|
27 | private: true,
|
28 | scripts: {
|
29 | start: 'cgb-scripts start',
|
30 | build: 'cgb-scripts build',
|
31 | eject: 'cgb-scripts eject',
|
32 | },
|
33 | };
|
34 |
|
35 |
|
36 | fs.writeFileSync(
|
37 | path.join( process.cwd(), 'package.json' ),
|
38 | JSON.stringify( appPackage, null, 2 ) + '\n'
|
39 | );
|
40 |
|
41 |
|
42 | return new Promise( async resolve => {
|
43 | await execa( 'npm', [
|
44 | 'install',
|
45 | 'cgb-scripts',
|
46 | '--save',
|
47 | '--save-exact',
|
48 | '--slient',
|
49 | ] );
|
50 | resolve( true );
|
51 | } );
|
52 | };
|