NPM@5 (2nd try) (#9013)

* second try at using npm5

* use npm 5 in travis

* build client only in production
This commit is contained in:
Matteo Pagliazzi
2017-09-01 20:21:40 +02:00
committed by GitHub
parent 3d9738ac2f
commit 2e4f665fa5
9 changed files with 21167 additions and 13881 deletions

View File

@@ -14,7 +14,7 @@ files:
owner: root
group: users
content: |
$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin/npm install -g npm@4
$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin/npm install -g npm@5
container_commands:
01_makeBabel:
command: "touch /tmp/.babel.json"

View File

@@ -13,7 +13,7 @@ addons:
- g++-4.8
before_install:
- $CXX --version
- npm install -g npm@4
- npm install -g npm@5
- if [ $REQUIRES_SERVER ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10; echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list; sudo apt-get update; sudo apt-get install mongodb-org-server; fi
install:
- npm install &> npm.install.log || (cat npm.install.log; false)

View File

@@ -1,5 +1,7 @@
FROM node:boron
# Upgrade NPM to v5
RUN npm install -g npm@5
# Install global packages
RUN npm install -g gulp grunt-cli bower mocha

View File

@@ -1,5 +1,7 @@
FROM node:boron
# Upgrade NPM to v5
RUN npm install -g npm@5
# Install global packages
RUN npm install -g gulp grunt-cli bower mocha

View File

@@ -1,6 +1,7 @@
import gulp from 'gulp';
import runSequence from 'run-sequence';
import babel from 'gulp-babel';
import webpackProductionBuild from '../webpack/build';
require('gulp-grunt')(gulp);
gulp.task('build', () => {
@@ -25,6 +26,14 @@ gulp.task('build:common', () => {
gulp.task('build:server', ['build:src', 'build:common']);
// Client Production Build
gulp.task('build:client', ['bootstrap'], (done) => {
webpackProductionBuild((err, output) => {
if (err) return done(err);
console.log(output);
});
});
gulp.task('build:dev', ['browserify', 'prepare:staticNewStuff'], (done) => {
gulp.start('grunt-build:dev', done);
});
@@ -33,7 +42,12 @@ gulp.task('build:dev:watch', ['build:dev'], () => {
gulp.watch(['website/client-old/**/*.styl', 'website/common/script/*']);
});
gulp.task('build:prod', ['browserify', 'build:server', 'prepare:staticNewStuff'], (done) => {
gulp.task('build:prod', [
'browserify',
'build:server',
'prepare:staticNewStuff',
'build:client',
], (done) => {
runSequence(
'grunt-build:prod',
'apidoc',

13852
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

21110
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -141,7 +141,7 @@
"private": true,
"engines": {
"node": "^6.9.1",
"npm": "^4.0.2"
"npm": "^5.0.0"
},
"scripts": {
"lint": "eslint --ext .js,.vue .",
@@ -163,13 +163,13 @@
"coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html",
"sprites": "gulp sprites:compile",
"client:dev": "gulp bootstrap && node webpack/dev-server.js",
"client:build": "gulp bootstrap && node webpack/build.js",
"client:build": "gulp build:client",
"client:unit": "cross-env NODE_ENV=test karma start test/client/unit/karma.conf.js --single-run",
"client:unit:watch": "cross-env NODE_ENV=test karma start test/client/unit/karma.conf.js",
"client:e2e": "node test/client/e2e/runner.js",
"client:test": "npm run client:unit && npm run client:e2e",
"start": "gulp run:dev",
"postinstall": "gulp build && npm run client:build",
"postinstall": "gulp build",
"apidoc": "gulp apidoc"
},
"devDependencies": {

View File

@@ -2,7 +2,6 @@
// https://github.com/shelljs/shelljs
require('shelljs/global');
env.NODE_ENV = 'production';
const path = require('path');
const config = require('./config');
@@ -10,28 +9,39 @@ const ora = require('ora');
const webpack = require('webpack');
const webpackConfig = require('./webpack.prod.conf');
console.log( // eslint-disable-line no-console
' Tip:\n' +
' Built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
);
module.exports = function webpackProductionBuild (callback) {
env.NODE_ENV = 'production';
const spinner = ora('building for production...');
spinner.start();
console.log( // eslint-disable-line no-console
' Tip:\n' +
' Built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
);
const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
rm('-rf', assetsPath);
mkdir('-p', assetsPath);
cp('-R', config.build.staticAssetsDirectory, assetsPath);
const spinner = ora('building for production...');
spinner.start();
webpack(webpackConfig, (err, stats) => {
spinner.stop();
if (err) throw err;
process.stdout.write(`${stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
})}\n`);
});
const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
rm('-rf', assetsPath);
mkdir('-p', assetsPath);
cp('-R', config.build.staticAssetsDirectory, assetsPath);
webpack(webpackConfig, (err, stats) => {
spinner.stop();
const output = `${stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
})}\n`;
if (callback) {
return err ? callback(err) : callback(null, output);
} else {
if (err) throw err;
process.stdout.write(output);
}
});
};