clean.js 1.46 KB
Newer Older
Julien Benchetrit's avatar
Julien Benchetrit committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
const shell = require('shelljs');
const addCheckMark = require('./helpers/checkmark.js');

if (!shell.which('git')) {
  shell.echo('Sorry, this script requires git');
  shell.exit(1);
}

if (!shell.test('-e', 'internals/templates')) {
  shell.echo('The example is deleted already.');
  shell.exit(1);
}

process.stdout.write('Cleanup started...');


// Cleanup components/
dengxiaofeng's avatar
dengxiaofeng committed
18
// shell.rm('-rf', 'src/components/*');
Julien Benchetrit's avatar
Julien Benchetrit committed
19 20

// Handle containers/
dengxiaofeng's avatar
dengxiaofeng committed
21
shell.rm('-rf', 'src/containers');
Julien Benchetrit's avatar
Julien Benchetrit committed
22 23 24 25 26 27
shell.mv('internals/templates/containers', 'app');

// Handle tests/
shell.mv('internals/templates/tests', 'app');

// Handle translations/
dengxiaofeng's avatar
dengxiaofeng committed
28
shell.rm('-rf', 'src/translations');
Julien Benchetrit's avatar
Julien Benchetrit committed
29 30 31
shell.mv('internals/templates/translations', 'app');

// Handle utils/
dengxiaofeng's avatar
dengxiaofeng committed
32
shell.rm('-rf', 'src/utils');
Julien Benchetrit's avatar
Julien Benchetrit committed
33 34 35
shell.mv('internals/templates/utils', 'app');

// Replace the files in the root app/ folder
dengxiaofeng's avatar
dengxiaofeng committed
36 37
shell.cp('internals/templates/app.js', 'src/app.js');
shell.cp('internals/templates/global-styles.js', 'src/global-styles.js');
dengxiaofeng's avatar
dengxiaofeng committed
38
// shell.cp('internals/templates/i18n.js', 'src/i18n.js');
dengxiaofeng's avatar
dengxiaofeng committed
39 40 41 42
shell.cp('internals/templates/index.html', 'src/index.html');
shell.cp('internals/templates/reducers.js', 'src/reducers.js');
shell.cp('internals/templates/configureStore.js', 'src/configureStore.js');

Julien Benchetrit's avatar
Julien Benchetrit committed
43 44 45 46 47 48 49 50 51 52 53 54 55
shell.rm('-rf', 'internals/templates');

addCheckMark();

if (
  shell.exec('git add . --all && git commit -qm "Remove default example"')
    .code !== 0
) {
  shell.echo('\nError: Git commit failed');
  shell.exit(1);
}

shell.echo('\nCleanup done. Happy Coding!!!');