2017-03-14 12:25:39 +01:00
|
|
|
const shell = require('shelljs');
|
|
|
|
|
2017-08-09 22:21:08 +02:00
|
|
|
// Store installation start date.
|
|
|
|
const installationStartDate = new Date();
|
2018-01-09 17:09:54 +01:00
|
|
|
const watcher = (label, cmd, withSuccess = true) => {
|
|
|
|
if (label.length > 0) {
|
|
|
|
shell.echo(`📦 ${label}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = shell.exec(cmd, {
|
2018-01-12 16:41:59 +01:00
|
|
|
silent: true
|
2018-01-09 17:09:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if (data.stderr && data.code !== 0) {
|
|
|
|
console.error(data.stderr);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (label.length > 0 && withSuccess) {
|
|
|
|
shell.echo('✅ Success');
|
|
|
|
shell.echo('');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
shell.echo('');
|
|
|
|
shell.echo('🕓 The setup process can take few minutes.');
|
|
|
|
shell.echo('');
|
2017-08-09 22:21:08 +02:00
|
|
|
|
2017-03-14 12:25:39 +01:00
|
|
|
// Remove existing binary.
|
|
|
|
shell.rm('-f', '/usr/local/bin/strapi.js');
|
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('packages/strapi-utils');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Linking strapi-utils...', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi-generate');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('', 'npm install ../strapi-utils');
|
|
|
|
watcher('Linking strapi-generate...', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-09-30 19:30:06 +02:00
|
|
|
shell.cd('../strapi-generate-api');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Linking strapi-generate-api...', 'npm link');
|
2017-09-30 19:30:06 +02:00
|
|
|
|
2017-08-22 18:29:02 +02:00
|
|
|
shell.cd('../strapi-helper-plugin');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Linking strapi-helper-plugin...', 'npm link');
|
2017-08-22 18:29:02 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi-admin');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
|
|
|
watcher('', 'npm install ../strapi-utils --no-optional');
|
2017-08-22 18:29:02 +02:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-admin', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi-generate-admin');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('', 'npm install ../strapi-admin');
|
|
|
|
watcher('Linking strapi-generate-admin...', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi-generate-new');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('', 'npm install ../strapi-utils');
|
|
|
|
watcher('Linking strapi-generate-new', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi-mongoose');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('', 'npm install ../strapi-utils');
|
|
|
|
watcher('Linking strapi-mongoose...', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-07-17 16:48:09 +02:00
|
|
|
shell.cd('../strapi');
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('', 'npm install ../strapi-generate ../strapi-generate-admin ../strapi-generate-api ../strapi-generate-new ../strapi-generate-plugin ../strapi-generate-policy ../strapi-generate-service ../strapi-utils');
|
|
|
|
watcher('Linking strapi...', 'npm link');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
2017-11-20 15:10:40 +01:00
|
|
|
shell.cd('../strapi-plugin-email');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
2017-11-20 15:10:40 +01:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-plugin-email...', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-11-20 15:10:40 +01:00
|
|
|
|
2017-11-14 10:11:16 +01:00
|
|
|
shell.cd('../strapi-plugin-users-permissions');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
2017-11-14 10:11:16 +01:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-plugin-users-permissions...', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-11-14 10:11:16 +01:00
|
|
|
|
2017-08-09 22:09:41 +02:00
|
|
|
shell.cd('../strapi-plugin-content-manager');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
2017-08-09 22:09:41 +02:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-plugin-content-manager...', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-08-09 22:09:41 +02:00
|
|
|
|
|
|
|
shell.cd('../strapi-plugin-settings-manager');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
2017-08-09 22:09:41 +02:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-plugin-settings-manager...', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-08-09 22:21:08 +02:00
|
|
|
|
2017-09-08 13:48:22 +02:00
|
|
|
shell.cd('../strapi-plugin-content-type-builder');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
|
|
|
|
watcher('', 'npm install ../strapi-generate --no-optional');
|
|
|
|
watcher('', 'npm install ../strapi-generate-api --no-optional');
|
2017-09-08 13:48:22 +02:00
|
|
|
shell.rm('-f', 'package-lock.json');
|
2018-01-10 15:38:28 +01:00
|
|
|
watcher('Linking strapi-plugin-content-type-builder...', 'npm link --no-optional', false);
|
2018-01-09 17:09:54 +01:00
|
|
|
watcher('Building...', 'npm run build');
|
2017-09-08 13:48:22 +02:00
|
|
|
|
2017-08-09 22:21:08 +02:00
|
|
|
// Log installation duration.
|
|
|
|
const installationEndDate = new Date();
|
|
|
|
const duration = (installationEndDate.getTime() - installationStartDate.getTime()) / 1000;
|
|
|
|
shell.echo('Strapi has been succesfully installed.');
|
2017-08-22 18:29:02 +02:00
|
|
|
shell.echo(`Installation took ${Math.floor(duration / 60) > 0 ? `${Math.floor(duration / 60)} minutes and ` : ''}${Math.floor(duration % 60)} seconds.`);
|