Merge pull request #281 from coralproject/add-yarn

Add yarn + Upgrade Webpack
This commit is contained in:
David Erwin
2017-02-02 10:14:07 -05:00
committed by GitHub
13 changed files with 8125 additions and 187 deletions
+1
View File
@@ -1,2 +1,3 @@
node_modules
test
.git
-1
View File
@@ -12,4 +12,3 @@ dump.rdb
*.cfg
.idea/
coverage/
yarn.lock
+5 -2
View File
@@ -1,5 +1,8 @@
FROM node:7
# Install yarn
RUN npm install -g yarn
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
@@ -12,9 +15,9 @@ EXPOSE 5000
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install --production
RUN yarn install --production
# Bundle app source
COPY . /usr/src/app
CMD [ "npm", "start" ]
CMD [ "yarn", "start" ]
+6 -6
View File
@@ -27,7 +27,7 @@ Navigate to a directory.
```
git clone https://github.com/coralproject/talk
cd talk
npm install
yarn install
```
### Environmental Variables
@@ -42,7 +42,7 @@ Talk uses environmental variables for configuration. You can learn about them in
Starting the server:
```
npm start
yarn start
```
Browse to `http://localhost:3000` (or your custom port.)
@@ -54,13 +54,13 @@ Our build process will build all front end components registered [here](https://
One time build:
```
npm build
yarn build
```
Build, then rebuild when a file is updated (development build):
```
npm build-watch
yarn build-watch
```
@@ -69,13 +69,13 @@ npm build-watch
Run all tests once:
`
npm test
yarn test
`
Run our end to end tests (will install Selenium and nightwatch):
`
npm run e2e
yarn e2e
`
_Please ensure all tests are passing before submitting a PR!_
+12 -3
View File
@@ -4,11 +4,20 @@ machine:
services:
- docker
- redis
environment:
PATH: "${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
NODE_ENV: "test"
dependencies:
override:
- yarn
cache_directories:
- ~/.cache/yarn
post:
# Build the static assets
- yarn build
# Lint the project here, before tests are ran.
- npm run lint
- yarn lint
database:
post:
@@ -20,9 +29,9 @@ database:
test:
override:
# Run the tests using the junit reporter.
- MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml NPM_PACKAGE_CONFIG_MOCHA_REPORTER=mocha-junit-reporter npm run test
- MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml MOCHA_REPORTER=mocha-junit-reporter yarn test
# Run the e2e test suite
- E2E_REPORT_PATH=$CIRCLE_TEST_REPORTS/e2e npm run e2e
- E2E_REPORT_PATH=$CIRCLE_TEST_REPORTS/e2e yarn e2e
deployment:
release:
+3 -3
View File
@@ -5,19 +5,19 @@ This app handles moderation for Talk (and maybe more later on)
## Installation
$ npm install
$ yarn install
$ cp config.sample.json config.json
Then change `config.json` to adjust it to your project
## Building for production
$ npm run build
$ yarn build
The public folder has everything you need for deployment. You can just copy that folder to your favorite static web server
## Development
$ npm start
$ yarn start
A development server will be running at http://localhost:4132
-35
View File
@@ -1,35 +0,0 @@
version: '2'
services:
talk:
image: coralproject/talk:latest
build: .
restart: always
ports:
- "5000:5000"
- "2525:2525"
environment:
- "TALK_PORT=5000"
- "TALK_MONGO_URL=mongodb://mongo"
- "TALK_REDIS_URL=redis://redis"
depends_on:
- mongo
- redis
mongo:
image: mongo:3.2
restart: always
volumes:
- mongo:/data/db
redis:
image: redis:3.2-alpine
restart: always
volumes:
- redis:/data
volumes:
mongo:
external: false
redis:
external: false
+1 -1
View File
@@ -112,7 +112,7 @@ http://eslint.org/docs/rules/#best-practices
## Lint the code
```js
npm run lint
yarn lint
```
+2 -2
View File
@@ -71,10 +71,10 @@ The `pree2e` script will create 3 users: a Commenter, a Moderator, and an Admin
## Run the tests
Run Talk
`dotenv npm run start`
`dotenv yarn start`
Run e2e tests
`npm run e2e`
`yarn e2e`
## Advanced Nightwatch and Selenium Settings
+9 -9
View File
@@ -6,27 +6,27 @@
"scripts": {
"start": "./bin/cli serve --jobs",
"dev-start": "nodemon --config .nodemon.json --exec \"./bin/cli -c .env serve --jobs\"",
"build": "NODE_ENV=production webpack --config webpack.config.js --bail",
"build-watch": "NODE_ENV=development webpack --config webpack.config.dev.js --watch",
"build": "NODE_ENV=production webpack -p --config webpack.config.js --bail",
"build-watch": "NODE_ENV=development webpack --config webpack.config.js --watch",
"lint": "eslint bin/* .",
"lint-fix": "eslint bin/* . --fix",
"test": "TEST_MODE=unit NODE_ENV=test mocha -R ${NPM_PACKAGE_CONFIG_MOCHA_REPORTER:-spec}",
"test": "TEST_MODE=unit NODE_ENV=test mocha -R ${MOCHA_REPORTER:-spec}",
"test-cover": "TEST_MODE=unit NODE_ENV=test istanbul cover _mocha --report text --check-coverage -- -R spec",
"pree2e": "NODE_ENV=test TALK_PORT=3011 scripts/pree2e.sh",
"e2e": "NODE_ENV=test nightwatch",
"poste2e": "NODE_ENV=test scripts/poste2e.sh",
"embed-start": "NODE_ENV=development npm run build && ./bin/cli serve --jobs",
"postinstall": "npm run build"
"embed-start": "NODE_ENV=development yarn build && ./bin/cli serve --jobs",
"heroku-postbuild": "yarn build"
},
"config": {
"pre-git": {
"commit-msg": [],
"pre-commit": [
"npm run lint",
"npm test"
"yarn lint",
"yarn test"
],
"pre-push": [
"npm test"
"yarn test"
],
"post-commit": [],
"post-merge": []
@@ -159,7 +159,7 @@
"style-loader": "^0.13.1",
"supertest": "^2.0.1",
"timeago.js": "^2.0.3",
"webpack": "^1.13.3"
"webpack": "^2.2.1"
},
"engines": {
"node": ">=7.0.0"
-112
View File
@@ -1,112 +0,0 @@
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const Copy = require('copy-webpack-plugin');
const webpack = require('webpack');
// Edit the build targets and embeds below.
const buildTargets = [
'coral-admin'
];
const buildEmbeds = [
'stream'
];
module.exports = {
devtool: 'inline-source-map',
entry: buildTargets.reduce((entry, target) => {
// Add the entry for the bundle.
entry[`${target}/bundle`] = [
'babel-polyfill',
path.join(__dirname, 'client/', target, '/src/index')
];
return entry;
}, buildEmbeds.reduce((entry, embed) => {
// Add the entry for the bundle.
entry[`embed/${embed}/bundle`] = [
'babel-polyfill',
path.join(__dirname, 'client/', `coral-embed-${embed}`, '/src/index')
];
return entry;
}, {})),
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
loaders: [
{
loader: 'babel',
exclude: /node_modules/,
test: /\.js$/
},
{
loader: 'json',
test: /\.json$/,
exclude: /node_modules/
},
{
loaders: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
'postcss-loader'
],
test: /.css$/,
},
{
loader: 'url-loader?limit=100000',
test: /\.png$/
},
{
loader: 'file-loader',
test: /\.(jpg|png|gif|svg)$/
},
{
loader: 'url?limit=100000',
test: /\.woff$/
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
}
]
},
plugins: [
new Copy([
...buildEmbeds.map(embed => ({
from: path.join(__dirname, 'client', `coral-embed-${embed}`, 'style'),
to: path.join(__dirname, 'dist', 'embed', embed)
})),
{
from: path.join(__dirname, 'client', 'lib'),
to: path.join(__dirname, 'dist', 'embed', 'stream')
}
]),
autoprefixer,
precss,
new webpack.ProvidePlugin({
'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': `"${process.env.NODE_ENV}"`,
'VERSION': `"${require('./package.json').version}"`
}
})
],
resolve: {
root: [
path.join(__dirname, 'client'),
...buildTargets.map(target => path.join(__dirname, 'client', target, 'src')),
...buildEmbeds.map(embed => path.join(__dirname, 'client', `coral-embed-${embed}`, 'src'))
]
},
postcss: require('./postcss.config.js')
};
+107 -13
View File
@@ -1,17 +1,111 @@
const path = require('path');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const Copy = require('copy-webpack-plugin');
const webpack = require('webpack');
const devConfig = require('./webpack.config.dev');
// Disable source maps.
devConfig.devtool = null;
// Edit the build targets and embeds below.
devConfig.plugins = devConfig.plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin()
]);
const buildTargets = [
'coral-admin'
];
module.exports = devConfig;
const buildEmbeds = [
'stream'
];
module.exports = {
devtool: 'cheap-source-map',
entry: buildTargets.reduce((entry, target) => {
// Add the entry for the bundle.
entry[`${target}/bundle`] = [
'babel-polyfill',
path.join(__dirname, 'client/', target, '/src/index')
];
return entry;
}, buildEmbeds.reduce((entry, embed) => {
// Add the entry for the bundle.
entry[`embed/${embed}/bundle`] = [
'babel-polyfill',
path.join(__dirname, 'client/', `coral-embed-${embed}`, '/src/index')
];
return entry;
}, {})),
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [
{
loader: 'babel-loader',
exclude: /node_modules/,
test: /\.js$/
},
{
loader: 'json-loader',
test: /\.json$/,
exclude: /node_modules/
},
{
loaders: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]',
'postcss-loader'
],
test: /.css$/,
},
{
loader: 'url-loader?limit=100000',
test: /\.png$/
},
{
loader: 'file-loader',
test: /\.(jpg|png|gif|svg)$/
},
{
loader: 'url-loader?limit=100000',
test: /\.woff$/
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
}
]
},
plugins: [
new Copy([
...buildEmbeds.map(embed => ({
from: path.join(__dirname, 'client', `coral-embed-${embed}`, 'style'),
to: path.join(__dirname, 'dist', 'embed', embed)
})),
{
from: path.join(__dirname, 'client', 'lib'),
to: path.join(__dirname, 'dist', 'embed', 'stream')
}
]),
autoprefixer,
precss,
new webpack.ProvidePlugin({
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
new webpack.DefinePlugin({
'process.env': {
'VERSION': `"${require('./package.json').version}"`
}
})
],
resolve: {
modules: [
path.resolve(__dirname, 'client'),
...buildTargets.map(target => path.join(__dirname, 'client', target, 'src')),
...buildEmbeds.map(embed => path.join(__dirname, 'client', `coral-embed-${embed}`, 'src')),
'node_modules'
]
}
};
+7979
View File
File diff suppressed because it is too large Load Diff