Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit daac835

Browse files
authored
Merge pull request #12 from algolia/chore/update-everything
Chore/update everything
2 parents 628157f + c0828d4 commit daac835

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6081
-16081
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.nuxt

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['algolia/vue'],
3+
};

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9.4.0

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5"
4+
}

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
cache:
3+
yarn: true

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Vue InstantSearch examples
2+
3+
Some examples for [Vue InstantSearch](https://community.algolia.com/vue-instantsearch) by Algolia.
4+
5+
To start, you need to run `yarn` to install all of the dependencies, then go to a subdirectory, and run the script you want, like `yarn start`.
6+
7+
## Included examples
8+
9+
* e-commerce
10+
* multi-index
11+
* nuxt
12+
* quick-start
13+
* ssr
14+
* vue-router (need to run separately in directory)

examples/e-commerce/build/build.js

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
1-
require('./check-versions')()
1+
/* eslint-disable import/no-commonjs, no-console */
2+
require('./check-versions')();
23

3-
process.env.NODE_ENV = 'production'
4+
process.env.NODE_ENV = 'production';
45

5-
var ora = require('ora')
6-
var rm = require('rimraf')
7-
var path = require('path')
8-
var chalk = require('chalk')
9-
var webpack = require('webpack')
10-
var config = require('../config')
11-
var webpackConfig = require('./webpack.prod.conf')
6+
const ora = require('ora');
7+
const rm = require('rimraf');
8+
const path = require('path');
9+
const chalk = require('chalk');
10+
const webpack = require('webpack');
11+
const config = require('../config');
12+
const webpackConfig = require('./webpack.prod.conf');
1213

13-
var spinner = ora('building for production...')
14-
spinner.start()
14+
const spinner = ora('building for production...');
15+
spinner.start();
1516

1617
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17-
if (err) throw err
18-
webpack(webpackConfig, function (err, stats) {
19-
spinner.stop()
20-
if (err) throw err
21-
process.stdout.write(stats.toString({
22-
colors: true,
23-
modules: false,
24-
children: false,
25-
chunks: false,
26-
chunkModules: false
27-
}) + '\n\n')
18+
if (err) throw err;
19+
webpack(webpackConfig, (_err, stats) => {
20+
spinner.stop();
21+
if (_err) throw _err;
22+
process.stdout.write(
23+
`${stats.toString({
24+
colors: true,
25+
modules: false,
26+
children: false,
27+
chunks: false,
28+
chunkModules: false,
29+
})}\n\n`
30+
);
2831

29-
console.log(chalk.cyan(' Build complete.\n'))
30-
console.log(chalk.yellow(
31-
' Tip: built files are meant to be served over an HTTP server.\n' +
32-
' Opening index.html over file:// won\'t work.\n'
33-
))
34-
})
35-
})
32+
console.log(chalk.cyan(' Build complete.\n'));
33+
console.log(
34+
chalk.yellow(
35+
' Tip: built files are meant to be served over an HTTP server.\n' +
36+
" Opening index.html over file:// won't work.\n"
37+
)
38+
);
39+
});
40+
});
Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,55 @@
1-
var chalk = require('chalk')
2-
var semver = require('semver')
3-
var packageConfig = require('../package.json')
1+
/* eslint-disable import/no-commonjs, no-process-exit, no-console */
42

5-
function exec (cmd) {
6-
return require('child_process').execSync(cmd).toString().trim()
3+
const chalk = require('chalk');
4+
const semver = require('semver');
5+
const packageConfig = require('../package.json');
6+
7+
function exec(cmd) {
8+
return require('child_process')
9+
.execSync(cmd)
10+
.toString()
11+
.trim();
712
}
813

9-
var versionRequirements = [
14+
const versionRequirements = [
1015
{
1116
name: 'node',
1217
currentVersion: semver.clean(process.version),
13-
versionRequirement: packageConfig.engines.node
18+
versionRequirement: packageConfig.engines.node,
1419
},
1520
{
1621
name: 'npm',
1722
currentVersion: exec('npm --version'),
18-
versionRequirement: packageConfig.engines.npm
19-
}
20-
]
23+
versionRequirement: packageConfig.engines.npm,
24+
},
25+
];
2126

22-
module.exports = function () {
23-
var warnings = []
24-
for (var i = 0; i < versionRequirements.length; i++) {
25-
var mod = versionRequirements[i]
27+
module.exports = function() {
28+
const warnings = [];
29+
for (let i = 0; i < versionRequirements.length; i++) {
30+
const mod = versionRequirements[i];
2631
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27-
warnings.push(mod.name + ': ' +
28-
chalk.red(mod.currentVersion) + ' should be ' +
29-
chalk.green(mod.versionRequirement)
30-
)
32+
warnings.push(
33+
`${mod.name}: ${chalk.red(mod.currentVersion)} should be ${chalk.green(
34+
mod.versionRequirement
35+
)}`
36+
);
3137
}
3238
}
3339

3440
if (warnings.length) {
35-
console.log('')
36-
console.log(chalk.yellow('To use this template, you must update following to modules:'))
37-
console.log()
38-
for (var i = 0; i < warnings.length; i++) {
39-
var warning = warnings[i]
40-
console.log(' ' + warning)
41+
console.log('');
42+
console.log(
43+
chalk.yellow(
44+
'To use this template, you must update following to modules:'
45+
)
46+
);
47+
console.log();
48+
for (let i = 0; i < warnings.length; i++) {
49+
const warning = warnings[i];
50+
console.log(` ${warning}`);
4151
}
42-
console.log()
43-
process.exit(1)
52+
console.log();
53+
process.exit(1);
4454
}
45-
}
55+
};
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
/* eslint-disable */
2-
require('eventsource-polyfill')
3-
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
1+
/* eslint-disable import/no-commonjs */
42

5-
hotClient.subscribe(function (event) {
3+
require('eventsource-polyfill');
4+
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true');
5+
6+
hotClient.subscribe(event => {
67
if (event.action === 'reload') {
7-
window.location.reload()
8+
window.location.reload();
89
}
9-
})
10+
});
Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,86 @@
1-
require('./check-versions')()
1+
/* eslint-disable import/no-commonjs, no-console */
22

3-
var config = require('../config')
3+
require('./check-versions')();
4+
5+
const config = require('../config');
46
if (!process.env.NODE_ENV) {
5-
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
7+
process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV);
68
}
79

8-
var opn = require('opn')
9-
var path = require('path')
10-
var express = require('express')
11-
var webpack = require('webpack')
12-
var proxyMiddleware = require('http-proxy-middleware')
13-
var webpackConfig = require('./webpack.dev.conf')
10+
const opn = require('opn');
11+
const path = require('path');
12+
const express = require('express');
13+
const webpack = require('webpack');
14+
const proxyMiddleware = require('http-proxy-middleware');
15+
const webpackConfig = require('./webpack.dev.conf');
1416

1517
// default port where dev server listens for incoming traffic
16-
var port = process.env.PORT || config.dev.port
18+
const port = process.env.PORT || config.dev.port;
1719
// automatically open browser, if not set will be false
18-
var autoOpenBrowser = !!config.dev.autoOpenBrowser
20+
const autoOpenBrowser = Boolean(config.dev.autoOpenBrowser);
1921
// Define HTTP proxies to your custom API backend
2022
// https://github.com/chimurai/http-proxy-middleware
21-
var proxyTable = config.dev.proxyTable
23+
const proxyTable = config.dev.proxyTable;
2224

23-
var app = express()
24-
var compiler = webpack(webpackConfig)
25+
const app = express();
26+
const compiler = webpack(webpackConfig);
2527

26-
var devMiddleware = require('webpack-dev-middleware')(compiler, {
28+
const devMiddleware = require('webpack-dev-middleware')(compiler, {
2729
publicPath: webpackConfig.output.publicPath,
28-
quiet: true
29-
})
30+
quiet: true,
31+
});
3032

31-
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32-
log: () => {}
33-
})
33+
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
34+
log: () => {},
35+
});
3436
// force page reload when html-webpack-plugin template changes
35-
compiler.plugin('compilation', function (compilation) {
36-
compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
37-
hotMiddleware.publish({ action: 'reload' })
38-
cb()
39-
})
40-
})
37+
compiler.plugin('compilation', compilation => {
38+
compilation.plugin('html-webpack-plugin-after-emit', (data, cb) => {
39+
hotMiddleware.publish({ action: 'reload' });
40+
cb();
41+
});
42+
});
4143

4244
// proxy api requests
43-
Object.keys(proxyTable).forEach(function (context) {
44-
var options = proxyTable[context]
45+
Object.keys(proxyTable).forEach(context => {
46+
let options = proxyTable[context];
4547
if (typeof options === 'string') {
46-
options = { target: options }
48+
options = { target: options };
4749
}
48-
app.use(proxyMiddleware(options.filter || context, options))
49-
})
50+
app.use(proxyMiddleware(options.filter || context, options));
51+
});
5052

5153
// handle fallback for HTML5 history API
52-
app.use(require('connect-history-api-fallback')())
54+
app.use(require('connect-history-api-fallback')());
5355

5456
// serve webpack bundle output
55-
app.use(devMiddleware)
57+
app.use(devMiddleware);
5658

5759
// enable hot-reload and state-preserving
5860
// compilation error display
59-
app.use(hotMiddleware)
61+
app.use(hotMiddleware);
6062

6163
// serve pure static assets
62-
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
63-
app.use(staticPath, express.static('./static'))
64+
const staticPath = path.posix.join(
65+
config.dev.assetsPublicPath,
66+
config.dev.assetsSubDirectory
67+
);
68+
app.use(staticPath, express.static('./static'));
6469

65-
var uri = 'http://localhost:' + port
70+
const uri = `http://localhost:${port}`;
6671

67-
devMiddleware.waitUntilValid(function () {
68-
console.log('> Listening at ' + uri + '\n')
69-
})
72+
devMiddleware.waitUntilValid(() => {
73+
console.log(`> Listening at ${uri}\n`);
74+
});
7075

71-
module.exports = app.listen(port, function (err) {
76+
module.exports = app.listen(port, err => {
7277
if (err) {
73-
console.log(err)
74-
return
78+
console.log(err);
79+
return;
7580
}
7681

7782
// when env is testing, don't need open it
7883
if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
79-
opn(uri)
84+
opn(uri);
8085
}
81-
})
86+
});

0 commit comments

Comments
 (0)