2016-12-01 16:44:03 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module dependencies
|
|
|
|
*/
|
|
|
|
|
2017-08-24 13:48:19 +02:00
|
|
|
const { exec } = require('child_process');
|
|
|
|
const path = require('path');
|
2017-11-03 17:15:53 +01:00
|
|
|
const fs = require('fs-extra');
|
2018-07-10 11:08:58 +02:00
|
|
|
const { packageManager } = require('strapi-utils'); // eslint-disable-line import/no-unresolved
|
2017-08-24 13:48:19 +02:00
|
|
|
|
2016-12-01 16:44:03 +01:00
|
|
|
/**
|
|
|
|
* Runs after this generator has finished
|
|
|
|
*
|
|
|
|
* @param {Object} scope
|
|
|
|
* @param {Function} cb
|
|
|
|
*/
|
|
|
|
|
2017-08-24 13:48:19 +02:00
|
|
|
module.exports = (scope, cb) => {
|
2017-11-03 17:15:53 +01:00
|
|
|
// Copy the admin files.
|
|
|
|
fs.copySync(path.resolve(__dirname, '..', 'files'), path.resolve(scope.rootPath, 'admin'));
|
|
|
|
|
2017-09-27 17:55:51 +02:00
|
|
|
if (scope.developerMode) {
|
|
|
|
return cb();
|
|
|
|
}
|
2017-11-03 17:15:53 +01:00
|
|
|
|
2017-09-08 17:14:11 +02:00
|
|
|
// Install back-end admin `node_modules`.
|
2018-06-22 16:46:48 +02:00
|
|
|
const cmd = packageManager.isStrapiInstalledWithNPM() ? 'npm install --production --ignore-scripts' : 'yarn install --production --ignore-scripts';
|
2018-06-21 15:07:50 +02:00
|
|
|
exec(cmd, {
|
2017-08-24 13:48:19 +02:00
|
|
|
cwd: path.resolve(scope.rootPath, 'admin')
|
2017-09-08 17:14:11 +02:00
|
|
|
}, (err) => {
|
2017-08-24 13:48:19 +02:00
|
|
|
if (err) {
|
|
|
|
return cb(err);
|
|
|
|
}
|
2016-12-01 16:44:03 +01:00
|
|
|
|
2017-08-24 13:48:19 +02:00
|
|
|
cb();
|
|
|
|
});
|
2016-12-01 16:44:03 +01:00
|
|
|
};
|