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

Commit b3cd25b

Browse files
committed
Merge branch 'develop' of https://github.com/DivanteLtd/vue-storefront-api into develop
# Conflicts: # package.json
2 parents 239c3c4 + d2bb206 commit b3cd25b

File tree

4 files changed

+126
-9
lines changed

4 files changed

+126
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The **legacy** (A) mode - starting just the Elastic and Redis containers:
3131
`docker-compose up -d`
3232

3333
The **standard** (B) mode - starting Elastic, Redis + Vue Storefront API containers:
34-
`docker-compose -f docker-compose.yml -f docker-compose.all.yml up -d`
34+
`docker-compose -f docker-compose.yml -f docker-compose.nodejs.yml up -d`
3535

3636
As a result, all necessary services will be launched:
3737
- Vue Storefront API runtime environment (Node.js with dependencies from `package.json`)

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
"start": "node dist",
1111
"db": "babel-node --plugins transform-es2015-modules-commonjs scripts/db.js",
1212
"seo": "babel-node --plugins transform-es2015-modules-commonjs scripts/seo.js",
13-
"restore": "node node_modules/elasticdump/bin/elasticdump --input=var/catalog.json --output=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog_temp",
14-
"restore_it": "node node_modules/elasticdump/bin/elasticdump --input=var/catalog_it.json --output=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog_it && npm run db rebuild -- --indexName=vue_storefront_catalog_it",
15-
"restore_de": "node node_modules/elasticdump/bin/elasticdump --input=var/catalog_de.json --output=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog_de && npm run db rebuild -- --indexName=vue_storefront_catalog_de",
16-
"restore2main": "node node_modules/elasticdump/bin/elasticdump --input=var/catalog.json --output=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog",
17-
"dump": "node node_modules/elasticdump/bin/elasticdump --output=var/catalog.json --input=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog",
18-
"dump_it": "node node_modules/elasticdump/bin/elasticdump --output=var/catalog_it.json --input=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog_it",
19-
"dump_de": "node node_modules/elasticdump/bin/elasticdump --output=var/catalog_de.json --input=http://$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/vue_storefront_catalog_de",
20-
"kue-dashboard": "node node_modules/kue/bin/kue-dashboard -p 3050 -r redis://$REDIS_HOST:$REDIS_PORT",
13+
"restore": "babel-node --plugins transform-es2015-modules-commonjs scripts/elastic.js restore",
14+
"restore_it": "npm run restore -- --input-file=var/catalog_it.json --output-index=vue_storefront_catalog_it && npm run db rebuild -- --indexName=vue_storefront_catalog_it",
15+
"restore_de": "npm run restore -- --input-file=var/catalog_de.json --output-index=vue_storefront_catalog_de && npm run db rebuild -- --indexName=vue_storefront_catalog_de",
16+
"restore2main": "npm run restore -- --output-index=vue_storefront_catalog",
17+
"dump": "babel-node --plugins transform-es2015-modules-commonjs scripts/elastic.js dump",
18+
"dump_it": "npm run dump -- --input-index=vue_storefront_catalog_it --output-file=var/catalog_it.json",
19+
"dump_de": "npm run dump -- --input-index=vue_storefront_catalog_de --output-file=var/catalog_de.json",
20+
"kue": "babel-node --plugins transform-es2015-modules-commonjs scripts/kue.js",
21+
"kue-dashboard": "npm run kue dashboard -- --port=3050",
2122
"o2m": "babel src -s -D -d dist --presets es2015,stage-0; node dist/worker/order_to_magento2.js start",
2223
"o2m-anon": "babel src -s -D -d dist --presets es2015,stage-0; node dist/worker/order_to_magento2.js testAnon",
2324
"o2m-auth": "babel src -s -D -d dist --presets es2015,stage-0; node dist/worker/order_to_magento2.js testAuth",

scripts/elastic.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
'use harmony'
2+
3+
const CommandRouter = require('command-router')
4+
const cli = CommandRouter()
5+
6+
const util = require('util');
7+
const config = require('config').elasticsearch
8+
const spawnSync = require('child_process').spawnSync
9+
10+
cli.option({
11+
name: 'input-file',
12+
default: 'var/catalog.json',
13+
type: String
14+
})
15+
16+
cli.option({
17+
name: 'input-index',
18+
default: 'vue_storefront_catalog',
19+
type: String
20+
})
21+
22+
cli.option({
23+
name: 'output-file',
24+
default: 'var/catalog.json',
25+
type: String
26+
})
27+
28+
cli.option({
29+
name: 'output-index',
30+
default: 'vue_storefront_catalog_temp',
31+
type: String
32+
})
33+
34+
function stdOutErr(stdout, stderr) {
35+
if (stdout.length > 0)
36+
console.log(stdout.toString('utf8'));
37+
if (stderr.length > 0)
38+
console.error(stderr.toString('utf8'));
39+
}
40+
41+
cli.command('dump', () => {
42+
var input = util.format('http://%s:%d/%s', config.host, config.port, cli.options['input-index']);
43+
44+
var child = spawnSync('node', ['node_modules/elasticdump/bin/elasticdump', '--input=' + input, '--output=' + cli.options['output-file']]);
45+
stdOutErr(child.stdout, child.stderr);
46+
})
47+
48+
cli.command('restore', () => {
49+
var output = util.format('http://%s:%d/%s', config.host, config.port, cli.options['output-index']);
50+
51+
var child = spawnSync('node', ['node_modules/elasticdump/bin/elasticdump', '--input=' + cli.options['input-file'], '--output=' + output]);
52+
stdOutErr(child.stdout, child.stderr);
53+
})
54+
55+
cli.on('notfound', (action) => {
56+
console.error('I don\'t know how to: ' + action)
57+
process.exit(1)
58+
})
59+
60+
process.on('unhandledRejection', (reason, p) => {
61+
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);
62+
});
63+
64+
process.on('uncaughtException', function(exception) {
65+
console.log(exception);
66+
});
67+
68+
cli.parse(process.argv);

scripts/kue.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use harmony'
2+
3+
const CommandRouter = require('command-router')
4+
const cli = CommandRouter()
5+
6+
const util = require('util');
7+
const config = require('config').redis
8+
const kue = require('kue');
9+
10+
cli.option({
11+
name: 'port',
12+
alias: 'p',
13+
default: 3000,
14+
type: Number
15+
})
16+
17+
cli.option({
18+
name: 'prefix',
19+
alias: 'q',
20+
default: 'q',
21+
type: String
22+
})
23+
24+
cli.command('dashboard', () => {
25+
var redis = util.format('redis://%s:%d', config.host, config.port);
26+
27+
kue.createQueue({
28+
redis: redis,
29+
prefix: cli.options.prefix
30+
});
31+
32+
kue.app.listen(cli.options.port);
33+
})
34+
35+
cli.on('notfound', (action) => {
36+
console.error('I don\'t know how to: ' + action)
37+
process.exit(1)
38+
})
39+
40+
process.on('unhandledRejection', (reason, p) => {
41+
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);
42+
});
43+
44+
process.on('uncaughtException', function(exception) {
45+
console.log(exception);
46+
});
47+
48+
cli.parse(process.argv);

0 commit comments

Comments
 (0)