Merge pull request #953 from strapi/reduce-setup-monorepo

Reduce setup monorepo
This commit is contained in:
Jim LAURIE 2018-04-23 12:43:55 +02:00 committed by GitHub
commit 0cdcc02c05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 102 additions and 48 deletions

View File

@ -10,6 +10,8 @@ To setup the development environment please **follow the instructions below:**
2. Clone it to your computer `git clone git@github.com:strapi/strapi.git`.
3. Run `npm run setup` at the root of the directory.
> You can run `npm run setup:build` to build the plugins' admin (the setup time will be longer)
> Note: If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
## Plugin development Setup
@ -26,4 +28,4 @@ To generate a new plugin **run the following commands:**
4. In a new terminal window open at the root of your project launch your Strapi server `strapi start`.
Your are now ready to develop your own plugin and live-test your updates!
Your are now ready to develop your own plugin and live-test your updates!

View File

@ -24,6 +24,7 @@
"release": "npm run clean:all && npm install && npm run createsymlinkdependencies && lerna exec --concurrency 1 -- npm install && npm run removesymlinkdependencies && node ./scripts/publish.js $TAG",
"createsymlinkdependencies": "node ./scripts/createSymlinkDependencies.js",
"removesymlinkdependencies": "node ./scripts/removeSymlinkDependencies.js",
"setup:build": "npm run setup --build",
"setup": "npm run clean:all && npm install && node ./scripts/setup.js && npm run clean",
"test": "make test"
},

View File

@ -55,16 +55,6 @@ const FIRST_BLOCK = [
},
];
const WELCOME_AGAIN_BLOCK = [
{
title: {
id: 'app.components.HomePage.welcome.again',
},
name: upperFirst(`${get(auth.getUserInfo(), 'username')}!`),
content: () => <WelcomeContent hasContent />,
},
];
const FIRST_BLOCK_LINKS = [
{
link: 'https://strapi.io/documentation/',
@ -169,6 +159,15 @@ export class HomePage extends React.PureComponent {
render() {
const { homePage: { articles, body } } = this.props;
const WELCOME_AGAIN_BLOCK = [
{
title: {
id: 'app.components.HomePage.welcome.again',
},
name: upperFirst(`${get(auth.getUserInfo(), 'username')}!`),
content: () => <WelcomeContent hasContent />,
},
];
return (
<div className={cn('container-fluid', styles.containerFluid)}>

View File

@ -46,7 +46,7 @@
],
"engines": {
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -71,8 +71,8 @@ module.exports = scope => {
'uuid': uuid()
},
'engines': {
'node': '>= 7.0.0',
'npm': '>= 3.0.0'
'node': '>= 9.0.0',
'npm': '>= 5.0.0'
},
'license': scope.license || 'MIT'
});

View File

@ -29,7 +29,7 @@ module.exports = scope => {
'analyze:clean': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json',
'preanalyze': 'npm run analyze:clean',
'analyze': 'node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js',
'prebuild': 'npm run build:clean && npm run test',
'prebuild': 'npm run build:clean',
'build:dev': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress',
'build': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress',
'build:clean': 'node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build',

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
@ -44,7 +44,7 @@
},
"engines": {
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
@ -48,7 +48,7 @@
},
"engines": {
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
@ -45,8 +45,8 @@
"url": "git://github.com/strapi/strapi.git"
},
"engines": {
"node": ">= 7.0.0",
"npm": ">= 3.0.0"
"node": ">= 9.0.0",
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
@ -45,7 +45,7 @@
},
"engines": {
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",

View File

@ -11,7 +11,7 @@
"analyze:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf stats.json",
"preanalyze": "npm run analyze:clean",
"analyze": "node ./node_modules/strapi-helper-plugin/lib/internals/scripts/analyze.js",
"prebuild": "npm run build:clean && npm run test",
"prebuild": "npm run build:clean",
"build:dev": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=development node ./node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/cross-env NODE_ENV=production node node_modules/strapi-helper-plugin/node_modules/.bin/webpack --config node_modules/strapi-helper-plugin/lib/internals/webpack/webpack.prod.babel.js --color -p --progress",
"build:clean": "node ./node_modules/strapi-helper-plugin/node_modules/.bin/rimraf admin/build",
@ -51,8 +51,8 @@
"url": "git://github.com/strapi/strapi.git"
},
"engines": {
"node": ">= 7.0.0",
"npm": ">= 3.0.0"
"node": ">= 9.0.0",
"npm": ">= 5.0.0"
},
"license": "MIT"
}

View File

@ -1,8 +1,21 @@
const shell = require('shelljs');
// Check npm version
const npm = shell.exec('npm -v').stdout;
if (parseFloat(npm) < 5) {
throw new Error('[ERROR: Strapi] You need npm version @>=5');
}
const nodeVersion = shell.exec('node -v').stdout.replace('v', '');
if (parseFloat(nodeVersion) < 8.6) {
throw new Error('[ERROR: Strapi] You need to use node version @>=9');
}
// Store installation start date.
const silent = process.env.npm_config_debug !== 'true';
const installationStartDate = new Date();
const watcher = (label, cmd, withSuccess = true) => {
if (label.length > 0) {
shell.echo(label);
@ -21,6 +34,22 @@ const watcher = (label, cmd, withSuccess = true) => {
shell.echo('✅ Success');
shell.echo('');
}
};
const asyncWatcher = (label, cmd, withSuccess = true, resolve) => {
if (label.length > 0) {
shell.echo(label);
}
return shell.exec(cmd, { silent, async: true }, (code, stdout, stderr) => {
if (stderr && code !== 0) {
console.error(stderr);
process.exit(1);
}
return resolve();
});
};
shell.echo('');
@ -57,7 +86,6 @@ if (shell.test('-e', 'admin/src/config/plugins.json') === false) {
}
watcher('📦 Linking strapi-admin', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-generate-admin');
watcher('', 'npm install ../strapi-admin');
@ -83,6 +111,14 @@ shell.cd('../strapi');
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');
// Upload plugins
shell.cd('../strapi-upload-local');
watcher('📦 Linking strapi-upload-local...', 'npm link --no-optional', false);
shell.cd('../strapi-upload-aws-s3');
watcher('📦 Linking strapi-upload-aws-s3...', 'npm link --no-optional', false);
// Plugins with admin
shell.cd('../strapi-plugin-email');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-email...', 'npm link --no-optional', false);
@ -91,32 +127,24 @@ shell.cd('../strapi-plugin-users-permissions');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-users-permissions...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-content-manager');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-content-manager...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-settings-manager');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-settings-manager...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-upload-local');
watcher('📦 Linking strapi-upload-local...', 'npm link --no-optional', false);
shell.cd('../strapi-upload-aws-s3');
watcher('📦 Linking strapi-upload-aws-s3...', 'npm link --no-optional', false);
// Plugins with admin and other plugin's dependencies
shell.cd('../strapi-plugin-upload');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
watcher('', 'npm install ../strapi-upload-local --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-upload...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-content-type-builder');
watcher('', 'npm install ../strapi-helper-plugin --no-optional');
@ -124,15 +152,39 @@ watcher('', 'npm install ../strapi-generate --no-optional');
watcher('', 'npm install ../strapi-generate-api --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-content-type-builder...', 'npm link --no-optional', false);
watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-plugin-graphql');
watcher('', 'npm install ../strapi-utils --no-optional');
shell.rm('-f', 'package-lock.json');
watcher('📦 Linking strapi-plugin-graphql...', 'npm link --no-optional', false);
const pluginsToBuild = ['admin', 'content-manager', 'content-type-builder', 'upload', 'users-permissions', 'settings-manager'];
// Log installation duration.
const installationEndDate = new Date();
const duration = (installationEndDate.getTime() - installationStartDate.getTime()) / 1000;
shell.echo('✅ Strapi has been succesfully installed.');
shell.echo(`⏳ The installation took ${Math.floor(duration / 60) > 0 ? `${Math.floor(duration / 60)} minutes and ` : ''}${Math.floor(duration % 60)} seconds.`);
const buildPlugins = async () => {
const build = (pckgName) => {
return new Promise(resolve => {
const name = pckgName === 'admin' ? pckgName: `plugin-${pckgName}`;
asyncWatcher(`🏗 Building ${name}...`, `cd ../strapi-${name} && npm run build`, false, resolve);
});
};
return Promise.all(pluginsToBuild.map(plugin => build(plugin)));
};
const setup = async () => {
if (process.env.npm_config_build) {
if (process.platform === 'darwin') { // Allow async build for darwin platform
await buildPlugins();
} else {
pluginsToBuild.map(name => {
const pluginName = name === 'admin' ? name : `plugin-${name}`;
shell.cd(`../strapi-${pluginName}`);
return watcher(`🏗 Building ${pluginName}...`, 'npm run build');
});
}
}
// Log installation duration.
const installationEndDate = new Date();
const duration = (installationEndDate.getTime() - installationStartDate.getTime()) / 1000;
shell.echo('✅ Strapi has been succesfully installed.');
shell.echo(`⏳ The installation took ${Math.floor(duration / 60) > 0 ? `${Math.floor(duration / 60)} minutes and ` : ''}${Math.floor(duration % 60)} seconds.`);
};
setup();