mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
client: replace deprecated vue-resource with axios, lint more file
This commit is contained in:
@@ -21,7 +21,3 @@ test/content/**/*
|
|||||||
Gruntfile.js
|
Gruntfile.js
|
||||||
gulpfile.js
|
gulpfile.js
|
||||||
gulp
|
gulp
|
||||||
webpack
|
|
||||||
test/client/e2e
|
|
||||||
test/client/unit/index.js
|
|
||||||
test/client/unit/karma.conf.js
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"async": "^1.5.0",
|
"async": "^1.5.0",
|
||||||
"autoprefixer": "^6.4.0",
|
"autoprefixer": "^6.4.0",
|
||||||
"aws-sdk": "^2.0.25",
|
"aws-sdk": "^2.0.25",
|
||||||
|
"axios": "^0.15.3",
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.0.0",
|
||||||
"babel-loader": "^6.0.0",
|
"babel-loader": "^6.0.0",
|
||||||
"babel-plugin-syntax-async-functions": "^6.13.0",
|
"babel-plugin-syntax-async-functions": "^6.13.0",
|
||||||
@@ -118,7 +119,6 @@
|
|||||||
"vue": "^2.1.0",
|
"vue": "^2.1.0",
|
||||||
"vue-hot-reload-api": "^1.2.0",
|
"vue-hot-reload-api": "^1.2.0",
|
||||||
"vue-loader": "^10.0.0",
|
"vue-loader": "^10.0.0",
|
||||||
"vue-resource": "^1.0.2",
|
|
||||||
"vue-router": "^2.0.0-rc.5",
|
"vue-router": "^2.0.0-rc.5",
|
||||||
"vue-template-compiler": "^2.1.0",
|
"vue-template-compiler": "^2.1.0",
|
||||||
"webpack": "^1.12.2",
|
"webpack": "^1.12.2",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// for how to write custom assertions see
|
// for how to write custom assertions see
|
||||||
// http://nightwatchjs.org/guide#writing-custom-assertions
|
// http://nightwatchjs.org/guide#writing-custom-assertions
|
||||||
exports.assertion = function (selector, count) {
|
exports.assertion = function (selector, count) {
|
||||||
this.message = 'Testing if element <' + selector + '> has count: ' + count;
|
this.message = `Testing if element <${selector}> has count: ${count}`;
|
||||||
this.expected = count;
|
this.expected = count;
|
||||||
this.pass = function (val) {
|
this.pass = function (val) {
|
||||||
return val === this.expected;
|
return val === this.expected;
|
||||||
@@ -16,11 +16,10 @@ exports.assertion = function (selector, count) {
|
|||||||
return res.value;
|
return res.value;
|
||||||
};
|
};
|
||||||
this.command = function (cb) {
|
this.command = function (cb) {
|
||||||
var self = this;
|
return this.api.execute((el) => {
|
||||||
return this.api.execute(function (selector) {
|
return document.querySelectorAll(el).length;
|
||||||
return document.querySelectorAll(selector).length;
|
}, [selector], (res) => {
|
||||||
}, [selector], function (res) {
|
cb.call(this, res);
|
||||||
cb.call(self, res);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,45 +1,48 @@
|
|||||||
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
require('babel-register');
|
require('babel-register');
|
||||||
var config = require('../../../webpack/config');
|
const config = require('../../../webpack/config');
|
||||||
|
const chromeDriverPath = require('chromedriver').path;
|
||||||
|
|
||||||
// http://nightwatchjs.org/guide#settings-file
|
// http://nightwatchjs.org/guide#settings-file
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'src_folders': ['test/client/e2e/specs'],
|
src_folders: ['test/client/e2e/specs'],
|
||||||
'output_folder': 'test/client/e2e/reports',
|
output_folder: 'test/client/e2e/reports',
|
||||||
'custom_assertions_path': ['test/client/e2e/custom-assertions'],
|
custom_assertions_path: ['test/client/e2e/custom-assertions'],
|
||||||
|
|
||||||
'selenium': {
|
selenium: {
|
||||||
'start_process': true,
|
start_process: true,
|
||||||
'server_path': 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.0.jar',
|
server_path: 'node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.0.jar',
|
||||||
'host': '127.0.0.1',
|
host: '127.0.0.1',
|
||||||
'port': 4444,
|
port: 4444,
|
||||||
'cli_args': {
|
cli_args: {
|
||||||
'webdriver.chrome.driver': require('chromedriver').path,
|
'webdriver.chrome.driver': chromeDriverPath,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'test_settings': {
|
test_settings: {
|
||||||
'default': {
|
default: {
|
||||||
'selenium_port': 4444,
|
selenium_port: 4444,
|
||||||
'selenium_host': 'localhost',
|
selenium_host: 'localhost',
|
||||||
'silent': true,
|
silent: true,
|
||||||
'globals': {
|
globals: {
|
||||||
'devServerURL': 'http://localhost:' + (process.env.PORT || config.dev.port),
|
devServerURL: `http://localhost:${process.env.PORT || config.dev.port}`, // eslint-disable-line no-process-env
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'chrome': {
|
chrome: {
|
||||||
'desiredCapabilities': {
|
desiredCapabilities: {
|
||||||
'browserName': 'chrome',
|
browserName: 'chrome',
|
||||||
'javascriptEnabled': true,
|
javascriptEnabled: true,
|
||||||
'acceptSslCerts': true,
|
acceptSslCerts: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'firefox': {
|
firefox: {
|
||||||
'desiredCapabilities': {
|
desiredCapabilities: {
|
||||||
'browserName': 'firefox',
|
browserName: 'firefox',
|
||||||
'javascriptEnabled': true,
|
javascriptEnabled: true,
|
||||||
'acceptSslCerts': true,
|
acceptSslCerts: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// 1. start the dev server using production config
|
// 1. start the dev server using production config
|
||||||
process.env.NODE_ENV = 'testing';
|
process.env.NODE_ENV = 'testing'; // eslint-disable-line no-process-env
|
||||||
var server = require('../../../webpack/dev-server.js');
|
const server = require('../../../webpack/dev-server.js');
|
||||||
|
|
||||||
// 2. run the nightwatch test suite against it
|
// 2. run the nightwatch test suite against it
|
||||||
// to run in additional browsers:
|
// to run in additional browsers:
|
||||||
@@ -9,7 +9,7 @@ var server = require('../../../webpack/dev-server.js');
|
|||||||
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
|
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
|
||||||
// For more information on Nightwatch's config file, see
|
// For more information on Nightwatch's config file, see
|
||||||
// http://nightwatchjs.org/guide#settings-file
|
// http://nightwatchjs.org/guide#settings-file
|
||||||
var opts = process.argv.slice(2);
|
let opts = process.argv.slice(2);
|
||||||
if (opts.indexOf('--config') === -1) {
|
if (opts.indexOf('--config') === -1) {
|
||||||
opts = opts.concat(['--config', 'test/client/e2e/nightwatch.conf.js']);
|
opts = opts.concat(['--config', 'test/client/e2e/nightwatch.conf.js']);
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,8 @@ if (opts.indexOf('--env') === -1) {
|
|||||||
opts = opts.concat(['--env', 'chrome']);
|
opts = opts.concat(['--env', 'chrome']);
|
||||||
}
|
}
|
||||||
|
|
||||||
var spawn = require('cross-spawn');
|
const spawn = require('cross-spawn');
|
||||||
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' });
|
const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' });
|
||||||
|
|
||||||
runner.on('exit', function (code) {
|
runner.on('exit', function (code) {
|
||||||
server.close();
|
server.close();
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
// http://nightwatchjs.org/guide#usage
|
// http://nightwatchjs.org/guide#usage
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'default e2e tests': function (browser) {
|
'default e2e tests' (browser) {
|
||||||
|
|
||||||
// automatically uses dev Server port from /config.index.js
|
// automatically uses dev Server port from /config.index.js
|
||||||
// default: http://localhost:8080
|
// default: http://localhost:8080
|
||||||
// see nightwatch.conf.js
|
// see nightwatch.conf.js
|
||||||
var devServer = browser.globals.devServerURL;
|
const devServer = browser.globals.devServerURL;
|
||||||
|
|
||||||
browser
|
browser
|
||||||
.url(devServer)
|
.url(devServer)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
// TODO verify if it's needed, added because Vuex require Promise in the global scope
|
// TODO verify if it's needed, added because Axios require Promise in the global scope
|
||||||
// and babel-runtime doesn't affect external libraries
|
// and babel-runtime doesn't affect external libraries
|
||||||
require('babel-polyfill');
|
require('babel-polyfill');
|
||||||
|
|
||||||
// require all test files (files that ends with .spec.js)
|
// require all test files (files that ends with .spec.js)
|
||||||
var testsContext = require.context('./specs', true, /\.spec$/);
|
let testsContext = require.context('./specs', true, /\.spec$/);
|
||||||
testsContext.keys().forEach(testsContext);
|
testsContext.keys().forEach(testsContext);
|
||||||
|
|
||||||
// require all .vue and .js files except main.js for coverage.
|
// require all .vue and .js files except main.js for coverage.
|
||||||
var srcContext = require.context('../../../website/client', true, /^\.\/(?=(?!main(\.js)?$))(?=(.*\.(vue|js)$))/);
|
let srcContext = require.context('../../../website/client', true, /^\.\/(?=(?!main(\.js)?$))(?=(.*\.(vue|js)$))/);
|
||||||
srcContext.keys().forEach(srcContext);
|
srcContext.keys().forEach(srcContext);
|
||||||
@@ -3,14 +3,15 @@
|
|||||||
// we are also using it with karma-webpack
|
// we are also using it with karma-webpack
|
||||||
// https://github.com/webpack/karma-webpack
|
// https://github.com/webpack/karma-webpack
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
var baseConfig = require('../../../webpack/webpack.base.conf');
|
const baseConfig = require('../../../webpack/webpack.base.conf');
|
||||||
var utils = require('../../../webpack/utils');
|
const utils = require('../../../webpack/utils');
|
||||||
var webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
var projectRoot = path.resolve(__dirname, '../../../');
|
const projectRoot = path.resolve(__dirname, '../../../');
|
||||||
|
const testEnv = require('../../../webpack/config/test.env');
|
||||||
|
|
||||||
var webpackConfig = merge(baseConfig, {
|
const webpackConfig = merge(baseConfig, {
|
||||||
// use inline sourcemap for karma-sourcemap-loader
|
// use inline sourcemap for karma-sourcemap-loader
|
||||||
module: {
|
module: {
|
||||||
loaders: utils.styleLoaders(),
|
loaders: utils.styleLoaders(),
|
||||||
@@ -23,7 +24,7 @@ var webpackConfig = merge(baseConfig, {
|
|||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': require('../../../webpack/config/test.env'),
|
'process.env': testEnv,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -43,7 +44,7 @@ webpackConfig.module.preLoaders.unshift({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// only apply babel for test files when using isparta
|
// only apply babel for test files when using isparta
|
||||||
webpackConfig.module.loaders.some(function (loader, i) {
|
webpackConfig.module.loaders.some((loader) => {
|
||||||
if (loader.loader === 'babel') {
|
if (loader.loader === 'babel') {
|
||||||
loader.include = path.resolve(projectRoot, 'test/client/unit');
|
loader.include = path.resolve(projectRoot, 'test/client/unit');
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,35 +1,37 @@
|
|||||||
|
/* global env:true, rm:true, mkdir:true, cp:true */
|
||||||
|
|
||||||
// https://github.com/shelljs/shelljs
|
// https://github.com/shelljs/shelljs
|
||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
env.NODE_ENV = 'production';
|
env.NODE_ENV = 'production';
|
||||||
|
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var config = require('./config');
|
const config = require('./config');
|
||||||
var ora = require('ora');
|
const ora = require('ora');
|
||||||
var webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
var webpackConfig = require('./webpack.prod.conf');
|
const webpackConfig = require('./webpack.prod.conf');
|
||||||
|
|
||||||
console.log(
|
console.log( // eslint-disable-line no-console
|
||||||
' Tip:\n' +
|
' Tip:\n' +
|
||||||
' Built files are meant to be served over an HTTP server.\n' +
|
' Built files are meant to be served over an HTTP server.\n' +
|
||||||
' Opening index.html over file:// won\'t work.\n'
|
' Opening index.html over file:// won\'t work.\n'
|
||||||
);
|
);
|
||||||
|
|
||||||
var spinner = ora('building for production...');
|
const spinner = ora('building for production...');
|
||||||
spinner.start();
|
spinner.start();
|
||||||
|
|
||||||
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
|
const assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory);
|
||||||
rm('-rf', assetsPath);
|
rm('-rf', assetsPath);
|
||||||
mkdir('-p', assetsPath);
|
mkdir('-p', assetsPath);
|
||||||
cp('-R', config.build.staticAssetsDirectory, assetsPath);
|
cp('-R', config.build.staticAssetsDirectory, assetsPath);
|
||||||
|
|
||||||
webpack(webpackConfig, function (err, stats) {
|
webpack(webpackConfig, (err, stats) => {
|
||||||
spinner.stop();
|
spinner.stop();
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
process.stdout.write(stats.toString({
|
process.stdout.write(`${stats.toString({
|
||||||
colors: true,
|
colors: true,
|
||||||
modules: false,
|
modules: false,
|
||||||
children: false,
|
children: false,
|
||||||
chunks: false,
|
chunks: false,
|
||||||
chunkModules: false,
|
chunkModules: false,
|
||||||
}) + '\n');
|
})}\n`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
var prodEnv = require('./prod.env');
|
const prodEnv = require('./prod.env');
|
||||||
|
|
||||||
module.exports = merge(prodEnv, {
|
module.exports = merge(prodEnv, {
|
||||||
NODE_ENV: '"development"',
|
NODE_ENV: '"development"',
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
// see http://vuejs-templates.github.io/webpack for documentation.
|
// see http://vuejs-templates.github.io/webpack for documentation.
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
|
const staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live
|
||||||
|
const prodEnv = require('./prod.env');
|
||||||
|
const devEnv = require('./dev.env');
|
||||||
|
|
||||||
var staticAssetsDirectory = './website/static/.'; // The folder where static files (not processed) live
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
build: {
|
build: {
|
||||||
env: require('./prod.env'),
|
env: prodEnv,
|
||||||
index: path.resolve(__dirname, '../../dist-client/index.html'),
|
index: path.resolve(__dirname, '../../dist-client/index.html'),
|
||||||
assetsRoot: path.resolve(__dirname, '../../dist-client'),
|
assetsRoot: path.resolve(__dirname, '../../dist-client'),
|
||||||
assetsSubDirectory: 'static',
|
assetsSubDirectory: 'static',
|
||||||
assetsPublicPath: '/new-app',
|
assetsPublicPath: '/new-app',
|
||||||
staticAssetsDirectory: staticAssetsDirectory,
|
staticAssetsDirectory,
|
||||||
productionSourceMap: true,
|
productionSourceMap: true,
|
||||||
// Gzip off by default as many popular static hosts such as
|
// Gzip off by default as many popular static hosts such as
|
||||||
// Surge or Netlify already gzip all static assets for you.
|
// Surge or Netlify already gzip all static assets for you.
|
||||||
@@ -19,11 +21,11 @@ module.exports = {
|
|||||||
productionGzipExtensions: ['js', 'css'],
|
productionGzipExtensions: ['js', 'css'],
|
||||||
},
|
},
|
||||||
dev: {
|
dev: {
|
||||||
env: require('./dev.env'),
|
env: devEnv,
|
||||||
port: 8080,
|
port: 8080,
|
||||||
assetsSubDirectory: 'static',
|
assetsSubDirectory: 'static',
|
||||||
assetsPublicPath: '/',
|
assetsPublicPath: '/',
|
||||||
staticAssetsDirectory: staticAssetsDirectory,
|
staticAssetsDirectory,
|
||||||
proxyTable: {
|
proxyTable: {
|
||||||
// proxy all requests starting with /api/v3 to localhost:3000
|
// proxy all requests starting with /api/v3 to localhost:3000
|
||||||
'/api/v3': {
|
'/api/v3': {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
var merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
var devEnv = require('./dev.env');
|
const devEnv = require('./dev.env');
|
||||||
|
|
||||||
module.exports = merge(devEnv, {
|
module.exports = merge(devEnv, {
|
||||||
NODE_ENV: '"testing"',
|
NODE_ENV: '"testing"',
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
/* eslint-disable */
|
/* global window:true */
|
||||||
require('eventsource-polyfill')
|
|
||||||
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true&overlay=false')
|
|
||||||
|
|
||||||
hotClient.subscribe(function (event) {
|
require('eventsource-polyfill');
|
||||||
|
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true&overlay=false');
|
||||||
|
|
||||||
|
hotClient.subscribe(event => {
|
||||||
if (event.action === 'reload') {
|
if (event.action === 'reload') {
|
||||||
window.location.reload()
|
window.location.reload();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
var path = require('path');
|
/* eslint-disable no-process-env, no-console */
|
||||||
var express = require('express');
|
|
||||||
var webpack = require('webpack');
|
const path = require('path');
|
||||||
var config = require('./config');
|
const express = require('express');
|
||||||
var proxyMiddleware = require('http-proxy-middleware');
|
const webpack = require('webpack');
|
||||||
var webpackConfig = process.env.NODE_ENV === 'testing'
|
const config = require('./config');
|
||||||
? require('./webpack.prod.conf')
|
const proxyMiddleware = require('http-proxy-middleware');
|
||||||
: require('./webpack.dev.conf');
|
const webpackConfig = process.env.NODE_ENV === 'testing' ?
|
||||||
|
require('./webpack.prod.conf') :
|
||||||
|
require('./webpack.dev.conf');
|
||||||
|
|
||||||
// default port where dev server listens for incoming traffic
|
// default port where dev server listens for incoming traffic
|
||||||
var port = process.env.PORT || config.dev.port;
|
const port = process.env.PORT || config.dev.port;
|
||||||
// Define HTTP proxies to your custom API backend
|
// Define HTTP proxies to your custom API backend
|
||||||
// https://github.com/chimurai/http-proxy-middleware
|
// https://github.com/chimurai/http-proxy-middleware
|
||||||
var proxyTable = config.dev.proxyTable;
|
const proxyTable = config.dev.proxyTable;
|
||||||
|
|
||||||
var app = express();
|
const app = express();
|
||||||
var compiler = webpack(webpackConfig);
|
const compiler = webpack(webpackConfig);
|
||||||
|
|
||||||
var devMiddleware = require('webpack-dev-middleware')(compiler, {
|
const devMiddleware = require('webpack-dev-middleware')(compiler, {
|
||||||
publicPath: webpackConfig.output.publicPath,
|
publicPath: webpackConfig.output.publicPath,
|
||||||
stats: {
|
stats: {
|
||||||
colors: true,
|
colors: true,
|
||||||
@@ -24,18 +26,18 @@ var devMiddleware = require('webpack-dev-middleware')(compiler, {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var hotMiddleware = require('webpack-hot-middleware')(compiler);
|
const hotMiddleware = require('webpack-hot-middleware')(compiler);
|
||||||
// force page reload when html-webpack-plugin template changes
|
// force page reload when html-webpack-plugin template changes
|
||||||
compiler.plugin('compilation', function (compilation) {
|
compiler.plugin('compilation', (compilation) => {
|
||||||
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
|
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
|
||||||
hotMiddleware.publish({ action: 'reload' });
|
hotMiddleware.publish({ action: 'reload' });
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// proxy api requests
|
// proxy api requests
|
||||||
Object.keys(proxyTable).forEach(function (context) {
|
Object.keys(proxyTable).forEach((context) => {
|
||||||
var options = proxyTable[context];
|
let options = proxyTable[context];
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = { target: options };
|
options = { target: options };
|
||||||
}
|
}
|
||||||
@@ -53,13 +55,13 @@ app.use(devMiddleware);
|
|||||||
app.use(hotMiddleware);
|
app.use(hotMiddleware);
|
||||||
|
|
||||||
// serve pure static assets
|
// serve pure static assets
|
||||||
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
|
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
|
||||||
app.use(staticPath, express.static(config.dev.staticAssetsDirectory));
|
app.use(staticPath, express.static(config.dev.staticAssetsDirectory));
|
||||||
|
|
||||||
module.exports = app.listen(port, function (err) {
|
module.exports = app.listen(port, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Listening at http://localhost:' + port + '\n');
|
console.log(`Listening at http://localhost:${port}\n`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
var path = require('path');
|
/* eslint-disable no-process-env, no-console */
|
||||||
var config = require('./config');
|
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
||||||
|
|
||||||
exports.assetsPath = function (_path) {
|
const path = require('path');
|
||||||
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
const config = require('./config');
|
||||||
? config.build.assetsSubDirectory
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
: config.dev.assetsSubDirectory;
|
|
||||||
|
exports.assetsPath = (_path) => {
|
||||||
|
const assetsSubDirectory = process.env.NODE_ENV === 'production' ?
|
||||||
|
config.build.assetsSubDirectory :
|
||||||
|
config.dev.assetsSubDirectory;
|
||||||
return path.posix.join(assetsSubDirectory, _path);
|
return path.posix.join(assetsSubDirectory, _path);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.cssLoaders = function (options) {
|
exports.cssLoaders = (options) => {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
// generate loader string to be used with extract text plugin
|
// generate loader string to be used with extract text plugin
|
||||||
function generateLoaders (loaders) {
|
function generateLoaders (loaders) {
|
||||||
var sourceLoader = loaders.map(function (loader) {
|
let sourceLoader = loaders.map((loader) => {
|
||||||
var extraParamChar;
|
let extraParamChar;
|
||||||
if (/\?/.test(loader)) {
|
if (/\?/.test(loader)) {
|
||||||
loader = loader.replace(/\?/, '-loader?');
|
loader = loader.replace(/\?/, '-loader?');
|
||||||
extraParamChar = '&';
|
extraParamChar = '&';
|
||||||
} else {
|
} else {
|
||||||
loader = loader + '-loader';
|
loader = `${loader}-loader`;
|
||||||
extraParamChar = '?';
|
extraParamChar = '?';
|
||||||
}
|
}
|
||||||
return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '');
|
return `${loader}${(options.sourceMap ? extraParamChar + 'sourceMap' : '')}`; // eslint-disable-line prefer-template
|
||||||
}).join('!');
|
}).join('!');
|
||||||
|
|
||||||
if (options.extract) {
|
if (options.extract) {
|
||||||
@@ -45,14 +47,14 @@ exports.cssLoaders = function (options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Generate loaders for standalone style files (outside of .vue)
|
// Generate loaders for standalone style files (outside of .vue)
|
||||||
exports.styleLoaders = function (options) {
|
exports.styleLoaders = (options) => {
|
||||||
var output = [];
|
const output = [];
|
||||||
var loaders = exports.cssLoaders(options);
|
const loaders = exports.cssLoaders(options);
|
||||||
for (var extension in loaders) {
|
for (let extension in loaders) {
|
||||||
var loader = loaders[extension];
|
const loader = loaders[extension];
|
||||||
output.push({
|
output.push({
|
||||||
test: new RegExp('\\.' + extension + '$'),
|
test: new RegExp(`\\.${extension}$`),
|
||||||
loader: loader,
|
loader,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
var path = require('path');
|
/* eslint-disable no-process-env, no-console */
|
||||||
var config = require('./config');
|
|
||||||
var utils = require('./utils');
|
|
||||||
var projectRoot = path.resolve(__dirname, '../');
|
|
||||||
var webpack = require('webpack');
|
|
||||||
|
|
||||||
var IS_PROD = process.env.NODE_ENV === 'production';
|
const path = require('path');
|
||||||
var baseConfig = {
|
const config = require('./config');
|
||||||
|
const utils = require('./utils');
|
||||||
|
const projectRoot = path.resolve(__dirname, '../');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const postcssEasyImport = require('postcss-easy-import');
|
||||||
|
const IS_PROD = process.env.NODE_ENV === 'production';
|
||||||
|
const eslintFriendlyFormatter = require('eslint-friendly-formatter');
|
||||||
|
|
||||||
|
const baseConfig = {
|
||||||
entry: {
|
entry: {
|
||||||
app: './website/client/main.js',
|
app: './website/client/main.js',
|
||||||
},
|
},
|
||||||
@@ -86,10 +91,10 @@ var baseConfig = {
|
|||||||
vue: {
|
vue: {
|
||||||
loaders: utils.cssLoaders(),
|
loaders: utils.cssLoaders(),
|
||||||
postcss: [
|
postcss: [
|
||||||
require('autoprefixer')({
|
autoprefixer({
|
||||||
browsers: ['last 2 versions'],
|
browsers: ['last 2 versions'],
|
||||||
}),
|
}),
|
||||||
require('postcss-easy-import')({
|
postcssEasyImport({
|
||||||
glob: true,
|
glob: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@@ -98,7 +103,7 @@ var baseConfig = {
|
|||||||
|
|
||||||
if (!IS_PROD) {
|
if (!IS_PROD) {
|
||||||
baseConfig.eslint = {
|
baseConfig.eslint = {
|
||||||
formatter: require('eslint-friendly-formatter'),
|
formatter: eslintFriendlyFormatter,
|
||||||
emitWarning: true,
|
emitWarning: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
var config = require('./config');
|
const config = require('./config');
|
||||||
var webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
var merge = require('webpack-merge');
|
const merge = require('webpack-merge');
|
||||||
var utils = require('./utils');
|
const utils = require('./utils');
|
||||||
var baseWebpackConfig = require('./webpack.base.conf');
|
const baseWebpackConfig = require('./webpack.base.conf');
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
// add hot-reload related code to entry chunks
|
// add hot-reload related code to entry chunks
|
||||||
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
|
Object.keys(baseWebpackConfig.entry).forEach((name) => {
|
||||||
baseWebpackConfig.entry[name] = ['./webpack/dev-client'].concat(baseWebpackConfig.entry[name]);
|
baseWebpackConfig.entry[name] = ['./webpack/dev-client'].concat(baseWebpackConfig.entry[name]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
var path = require('path');
|
/* eslint-disable no-process-env, no-console */
|
||||||
var config = require('./config');
|
|
||||||
var utils = require('./utils');
|
|
||||||
var webpack = require('webpack');
|
|
||||||
var merge = require('webpack-merge');
|
|
||||||
var baseWebpackConfig = require('./webpack.base.conf');
|
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
||||||
var env = process.env.NODE_ENV === 'testing'
|
|
||||||
? require('./config/test.env')
|
|
||||||
: config.build.env;
|
|
||||||
|
|
||||||
var webpackConfig = merge(baseWebpackConfig, {
|
const path = require('path');
|
||||||
|
const config = require('./config');
|
||||||
|
const utils = require('./utils');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const baseWebpackConfig = require('./webpack.base.conf');
|
||||||
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
||||||
|
const env = process.env.NODE_ENV === 'testing' ?
|
||||||
|
require('./config/test.env') :
|
||||||
|
config.build.env;
|
||||||
|
|
||||||
|
const webpackConfig = merge(baseWebpackConfig, {
|
||||||
module: {
|
module: {
|
||||||
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true }),
|
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true }),
|
||||||
},
|
},
|
||||||
@@ -43,9 +46,9 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||||||
// you can customize output by editing /index.html
|
// you can customize output by editing /index.html
|
||||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: process.env.NODE_ENV === 'testing'
|
filename: process.env.NODE_ENV === 'testing' ?
|
||||||
? 'index.html'
|
'index.html' :
|
||||||
: config.build.index,
|
config.build.index,
|
||||||
template: './website/client/index.html',
|
template: './website/client/index.html',
|
||||||
inject: true,
|
inject: true,
|
||||||
minify: {
|
minify: {
|
||||||
@@ -61,12 +64,12 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||||||
// split vendor js into its own file
|
// split vendor js into its own file
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: 'vendor',
|
name: 'vendor',
|
||||||
minChunks: function (module, count) {
|
minChunks (scriptModule) {
|
||||||
// any required modules inside node_modules are extracted to vendor
|
// any required modules inside node_modules are extracted to vendor
|
||||||
return (
|
return (
|
||||||
module.resource &&
|
scriptModule.resource &&
|
||||||
/\.js$/.test(module.resource) &&
|
/\.js$/.test(scriptModule.resource) &&
|
||||||
module.resource.indexOf(
|
scriptModule.resource.indexOf(
|
||||||
path.join(__dirname, '../node_modules')
|
path.join(__dirname, '../node_modules')
|
||||||
) === 0
|
) === 0
|
||||||
);
|
);
|
||||||
@@ -82,17 +85,11 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (config.build.productionGzip) {
|
if (config.build.productionGzip) {
|
||||||
var CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
||||||
|
|
||||||
webpackConfig.plugins.push(
|
webpackConfig.plugins.push(
|
||||||
new CompressionWebpackPlugin({
|
new CompressionWebpackPlugin({
|
||||||
asset: '[path].gz[query]',
|
asset: '[path].gz[query]',
|
||||||
algorithm: 'gzip',
|
algorithm: 'gzip',
|
||||||
test: new RegExp(
|
test: new RegExp(`\\.(${config.build.productionGzipExtensions.join('|')})$`),
|
||||||
'\\.(' +
|
|
||||||
config.build.productionGzipExtensions.join('|') +
|
|
||||||
')$'
|
|
||||||
),
|
|
||||||
threshold: 10240,
|
threshold: 10240,
|
||||||
minRatio: 0.8,
|
minRatio: 0.8,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
// TODO verify if it's needed, added because Vuex require Promise in the global scope
|
// TODO verify if it's needed, added because Axios require Promise in the global scope
|
||||||
// and babel-runtime doesn't affect external libraries
|
// and babel-runtime doesn't affect external libraries
|
||||||
require('babel-polyfill');
|
require('babel-polyfill');
|
||||||
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import VueResource from 'vue-resource';
|
import axios from 'axios';
|
||||||
import AppComponent from './app';
|
import AppComponent from './app';
|
||||||
import router from './router';
|
import router from './router';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
import './filters/registerGlobals';
|
import './filters/registerGlobals';
|
||||||
import i18n from './plugins/i18n';
|
import i18n from './plugins/i18n';
|
||||||
|
|
||||||
Vue.use(VueResource);
|
|
||||||
Vue.use(i18n);
|
Vue.use(i18n);
|
||||||
|
|
||||||
// TODO just for the beginning
|
// TODO just for the beginning
|
||||||
@@ -18,8 +17,8 @@ let authSettings = localStorage.getItem('habit-mobile-settings');
|
|||||||
|
|
||||||
if (authSettings) {
|
if (authSettings) {
|
||||||
authSettings = JSON.parse(authSettings);
|
authSettings = JSON.parse(authSettings);
|
||||||
Vue.http.headers.common['x-api-user'] = authSettings.auth.apiId;
|
axios.defaults.headers.common['x-api-user'] = authSettings.auth.apiId;
|
||||||
Vue.http.headers.common['x-api-key'] = authSettings.auth.apiToken;
|
axios.defaults.headers.common['x-api-key'] = authSettings.auth.apiToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Vue from 'vue';
|
import axios from 'axios';
|
||||||
|
|
||||||
export async function fetchUserTasks (store) {
|
export async function fetchUserTasks (store) {
|
||||||
let response = await Vue.http.get('/api/v3/tasks/user');
|
let response = await axios.get('/api/v3/tasks/user');
|
||||||
store.state.tasks = response.body.data;
|
store.state.tasks = response.data.data;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import Vue from 'vue';
|
import axios from 'axios';
|
||||||
|
|
||||||
export async function fetch (store) { // eslint-disable-line no-shadow
|
export async function fetch (store) { // eslint-disable-line no-shadow
|
||||||
let response = await Vue.http.get('/api/v3/user');
|
let response = await axios.get('/api/v3/user');
|
||||||
store.state.user = response.body.data;
|
store.state.user = response.data.data;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user