2017-12-19 21:23:20 +01:00
|
|
|
const shell = require('shelljs');
|
|
|
|
const path = require('path');
|
2017-12-20 12:20:22 +01:00
|
|
|
const _ = require('lodash');
|
2017-12-19 21:23:20 +01:00
|
|
|
|
2017-12-20 12:20:22 +01:00
|
|
|
shell.echo('');
|
|
|
|
shell.echo('🕓 The setup process can take few minutes.');
|
2018-01-09 17:09:54 +01:00
|
|
|
shell.echo('');
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.echo('🔸 Administration Panel');
|
2018-01-09 17:09:54 +01:00
|
|
|
shell.echo('📦 Installing packages...');
|
2017-12-19 21:23:20 +01:00
|
|
|
|
2017-12-20 12:20:22 +01:00
|
|
|
const pwd = shell.pwd();
|
2017-12-19 21:23:20 +01:00
|
|
|
|
2018-01-16 16:33:05 +01:00
|
|
|
const silent = process.env.npm_config_debug !== 'true';
|
2018-01-08 16:34:41 +01:00
|
|
|
const isDevelopmentMode = path.resolve(pwd.stdout).indexOf('strapi-admin') !== -1;
|
|
|
|
const appPath = isDevelopmentMode ? path.resolve(process.env.PWD, '..') : path.resolve(pwd.stdout, '..');
|
|
|
|
|
2018-01-09 17:09:54 +01:00
|
|
|
// Remove package-lock.json.
|
|
|
|
shell.rm('-rf', path.resolve(appPath, 'package-lock.json'));
|
|
|
|
shell.rm('-rf', path.resolve(appPath, 'admin', 'package-lock.json'));
|
2018-01-08 16:34:41 +01:00
|
|
|
|
2018-01-09 17:09:54 +01:00
|
|
|
// Install the project dependencies.
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${appPath}" && npm install --ignore-scripts`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2018-01-09 17:09:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Install the administration dependencies.
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(appPath, 'admin')}" && npm install`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2017-12-20 12:20:22 +01:00
|
|
|
});
|
2017-12-19 21:23:20 +01:00
|
|
|
|
2018-01-08 16:34:41 +01:00
|
|
|
if (isDevelopmentMode) {
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(appPath, 'admin')}" && npm link strapi-helper-plugin && npm link strapi-utils`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2018-01-08 16:34:41 +01:00
|
|
|
});
|
|
|
|
} else {
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(appPath, 'admin', 'node_modules', 'strapi-helper-plugin')}" && npm install`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2018-01-08 16:34:41 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-20 18:34:33 +01:00
|
|
|
shell.echo('🏗 Building...');
|
|
|
|
|
2018-03-18 13:11:11 +01:00
|
|
|
const build = shell.exec(`cd "${path.resolve(appPath, 'admin')}" && APP_PATH="${appPath}" npm run build`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2017-12-20 18:34:33 +01:00
|
|
|
});
|
|
|
|
|
2018-01-08 16:34:41 +01:00
|
|
|
if (build.stderr && build.code !== 0) {
|
2017-12-20 18:34:33 +01:00
|
|
|
console.error(build.stderr);
|
2018-01-09 17:09:54 +01:00
|
|
|
process.exit(1);
|
2017-12-20 18:34:33 +01:00
|
|
|
}
|
|
|
|
|
2018-01-08 16:34:41 +01:00
|
|
|
shell.echo('✅ Success');
|
|
|
|
shell.echo('');
|
|
|
|
|
2018-01-09 18:39:50 +01:00
|
|
|
if (process.env.npm_config_plugins === 'true') {
|
|
|
|
const plugins = path.resolve(appPath, 'plugins');
|
|
|
|
|
|
|
|
shell.ls('* -d', plugins).forEach(function (plugin) {
|
|
|
|
shell.echo(`🔸 Plugin - ${_.upperFirst(plugin)}`);
|
|
|
|
shell.echo('📦 Installing packages...');
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(plugins, plugin)}" && npm install`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2018-01-09 18:39:50 +01:00
|
|
|
});
|
2018-01-19 14:50:34 +01:00
|
|
|
|
|
|
|
if (isDevelopmentMode) {
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(plugins, plugin)}" && npm link strapi-helper-plugin`, {
|
2018-01-19 14:50:34 +01:00
|
|
|
silent
|
|
|
|
});
|
|
|
|
} else {
|
2018-03-18 13:11:11 +01:00
|
|
|
shell.exec(`cd "${path.resolve(plugins, plugin, 'node_modules', 'strapi-helper-plugin')}" && npm install`, {
|
2018-01-19 14:50:34 +01:00
|
|
|
silent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-01-09 18:39:50 +01:00
|
|
|
shell.echo('🏗 Building...');
|
|
|
|
|
2018-03-18 13:11:11 +01:00
|
|
|
const build = shell.exec(`cd "${path.resolve(plugins, plugin)}" && APP_PATH="${appPath}" npm run build`, {
|
2018-01-16 16:18:33 +01:00
|
|
|
silent
|
2018-01-09 18:39:50 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if (build.stderr && build.code !== 0) {
|
|
|
|
console.error(build.stderr);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
shell.echo('✅ Success');
|
|
|
|
shell.echo('');
|
2017-12-20 12:20:22 +01:00
|
|
|
});
|
2018-01-09 18:39:50 +01:00
|
|
|
}
|