-
Notifications
You must be signed in to change notification settings - Fork 1
/
remove-universal.js
52 lines (42 loc) · 1.91 KB
/
remove-universal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { spawn } = require('child_process');
const fs = require('fs');
function runCliCommand(command, args) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { stdio: 'inherit' });
child.on('close', code => {
if (code !== 0) {
reject(new Error(`${ command } ${ args.join(' ') }`));
return;
}
resolve();
});
});
}
function uninstallPackages(dependencies) {
// Dependencies
const args = ['uninstall', '--save', ...dependencies];
console.log('\n★★ Removing server rendering dependencies\n'); // eslint-disable-line no-console
runCliCommand('npm', args).then(() => {
console.log('\n★★ Removing files:\n'); // eslint-disable-line no-console
fs.unlinkSync('webpack.config.server.js');
console.log('- webpack.config.server.js'); // eslint-disable-line no-console
fs.unlinkSync('source/js/server.js');
console.log('- server.js'); // eslint-disable-line no-console
fs.unlinkSync('source/js/components/server/ServerHTML.jsx');
console.log('- ServerHTML.jsx'); // eslint-disable-line no-console
fs.rmdirSync('source/js/components/server/');
console.log('- components/server\n'); // eslint-disable-line no-console
console.log('★★ Removing self:\n'); // eslint-disable-line no-console
fs.unlinkSync('remove-universal.js');
console.log('- remove-universal.js\n'); // eslint-disable-line no-console
console.log( // eslint-disable-line no-console
'★★ Removed server rendering dependencies and files.\n\n' +
' But you have to manually remove unused code from\n' +
' "source/js/config/store.js" which is marked with:\n' +
' // Remove if you are not using server rendering.\n\n' +
' You should remove "server" and "universal" tasks.\n' +
' from "package.json" too.\n'
);
});
}
uninstallPackages(['concurrently', 'nodemon', 'express', 'remotedev-serialize']);