diff --git a/docs/3.x.x/en/plugin-development/quick-start.md b/docs/3.x.x/en/plugin-development/quick-start.md index ba349b11e9..e90f5069cc 100644 --- a/docs/3.x.x/en/plugin-development/quick-start.md +++ b/docs/3.x.x/en/plugin-development/quick-start.md @@ -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! diff --git a/package.json b/package.json index e765323c4b..abeb87362f 100755 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/packages/strapi-admin/admin/src/containers/HomePage/index.js b/packages/strapi-admin/admin/src/containers/HomePage/index.js index 83906e6191..3ddc1ac242 100644 --- a/packages/strapi-admin/admin/src/containers/HomePage/index.js +++ b/packages/strapi-admin/admin/src/containers/HomePage/index.js @@ -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: () => , - }, -]; - 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: () => , + }, + ]; return (
diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index baa28cd0d2..5274288c5f 100755 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -46,7 +46,7 @@ ], "engines": { "node": ">= 9.0.0", - "npm": ">= 3.0.0" + "npm": ">= 5.0.0" }, "license": "MIT" } \ No newline at end of file diff --git a/packages/strapi-generate-new/json/package.json.js b/packages/strapi-generate-new/json/package.json.js index af2d6efb2b..ba14205b2f 100755 --- a/packages/strapi-generate-new/json/package.json.js +++ b/packages/strapi-generate-new/json/package.json.js @@ -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' }); diff --git a/packages/strapi-generate-plugin/json/package.json.js b/packages/strapi-generate-plugin/json/package.json.js index 81131821de..6e988da000 100755 --- a/packages/strapi-generate-plugin/json/package.json.js +++ b/packages/strapi-generate-plugin/json/package.json.js @@ -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', diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index bd28d1f609..ee4c444e68 100755 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -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" } \ No newline at end of file diff --git a/packages/strapi-plugin-content-type-builder/package.json b/packages/strapi-plugin-content-type-builder/package.json index c6cd9a4845..ca91fa6380 100755 --- a/packages/strapi-plugin-content-type-builder/package.json +++ b/packages/strapi-plugin-content-type-builder/package.json @@ -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" } \ No newline at end of file diff --git a/packages/strapi-plugin-email/package.json b/packages/strapi-plugin-email/package.json index f9e028f629..bf20fe5a03 100644 --- a/packages/strapi-plugin-email/package.json +++ b/packages/strapi-plugin-email/package.json @@ -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" } \ No newline at end of file diff --git a/packages/strapi-plugin-settings-manager/package.json b/packages/strapi-plugin-settings-manager/package.json index adc14c4689..fa6e21ccbd 100755 --- a/packages/strapi-plugin-settings-manager/package.json +++ b/packages/strapi-plugin-settings-manager/package.json @@ -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" } \ No newline at end of file diff --git a/packages/strapi-plugin-upload/package.json b/packages/strapi-plugin-upload/package.json index c180e40809..f6b2f97ced 100644 --- a/packages/strapi-plugin-upload/package.json +++ b/packages/strapi-plugin-upload/package.json @@ -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", diff --git a/packages/strapi-plugin-users-permissions/package.json b/packages/strapi-plugin-users-permissions/package.json index 034e3d64a4..62a426cc4d 100644 --- a/packages/strapi-plugin-users-permissions/package.json +++ b/packages/strapi-plugin-users-permissions/package.json @@ -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" } \ No newline at end of file diff --git a/scripts/setup.js b/scripts/setup.js index dc7d5c8c46..9de64e9311 100755 --- a/scripts/setup.js +++ b/scripts/setup.js @@ -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();