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

Commit 271c0cd

Browse files
committed
Merge branch 'develop' of github.com:DivanteLtd/vue-storefront-api into feature/add-usergroupid-for-product-tax-calculation
# Conflicts: # CHANGELOG.md # config/default.json # src/api/catalog.js # src/api/user.js # src/platform/magento1/tax.js # src/platform/magento2/tax.js
2 parents d946f4f + 27552d0 commit 271c0cd

Some content is hidden

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

95 files changed

+4803
-1966
lines changed

.eslintrc.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module.exports = {
2+
root: true,
3+
env: { jest: true, node: true, es6: true},
4+
parserOptions: {
5+
parser: '@typescript-eslint/parser',
6+
ecmaVersion: 2018,
7+
sourceType: 'module'
8+
},
9+
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
10+
extends: [
11+
'standard',
12+
'plugin:@typescript-eslint/recommended'
13+
],
14+
plugins: ['vue-storefront', '@typescript-eslint'],
15+
// add your custom rules here
16+
rules: {
17+
'@typescript-eslint/no-var-requires': 1,
18+
'@typescript-eslint/indent': ['error', 2],
19+
'@typescript-eslint/camelcase': 0,
20+
semi: 'off',
21+
'@typescript-eslint/semi': 0,
22+
'@typescript-eslint/member-delimiter-style': ['error', { 'multiline': { 'delimiter': 'comma', 'requireLast': false }, 'singleline': { 'delimiter': 'comma' } }],
23+
'@typescript-eslint/no-empty-interface': 1,
24+
'@typescript-eslint/no-use-before-define': 1,
25+
'@typescript-eslint/no-explicit-any': 0,
26+
'@typescript-eslint/class-name-casing': 1,
27+
'@typescript-eslint/no-unused-vars': 0,
28+
'@typescript-eslint/explicit-function-return-type': 0,
29+
'@typescript-eslint/no-var-requires': 0,
30+
'handle-callback-err': 1,
31+
'prefer-promise-reject-errors': 0,
32+
'import/no-duplicates': ['warning'],
33+
// allow paren-less arrow functions
34+
'arrow-parens': 0,
35+
'prefer-arrow-callback': 1,
36+
// allow async-await
37+
'generator-star-spacing': 0,
38+
// allow debugger during development
39+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
40+
'no-restricted-imports': [2, { paths: ['lodash-es'] }],
41+
'vue-storefront/no-corecomponent-import': 'error',
42+
'vue-storefront/no-corecomponent': 'error',
43+
'vue-storefront/no-corepage-import': 'error',
44+
'vue-storefront/no-corepage': 'error',
45+
'no-console': 0,
46+
'no-unused-vars': 1
47+
},
48+
overrides: [
49+
{
50+
// @todo check if this is closed https://github.com/typescript-eslint/typescript-eslint/issues/342
51+
// This is an issue with interfaces so we need to wait until it fixed.
52+
files: ['core/**/*.ts'],
53+
rules: {
54+
'no-undef': 1
55+
}
56+
}
57+
]
58+
};

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ jobs:
2121
- <<: *build
2222
node_js: '8'
2323

24+
- &unit
25+
stage: Test
26+
script: yarn test:unit
27+
name: "NodeJS 10 unit tests"
28+
node_js: "10"
29+
30+
- <<: *unit
31+
name: "NodeJS 8 unit tests"
32+
node_js: "8"

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Constant for Mailchimp subscription status - @KonstantinSoelch (#294)
1111
- mage2vs import now has optional `--generate-unique-url-keys` parameter which defaults to `false` to enable/disable the url key generation with name and id for categories - @rain2o (#232)
12+
- Added eslint config from vue-storefront so we have the same config and in both repos typescript support - @resubaka (#320)
13+
- Added jest support - @resubaka (#321)
14+
- Added caching factory and action factory for the image endpoint. This gives the possibility to use other services for caching or image processing - @resubaka (#317, #315)
1215
- Added support for tax calculation where the values from customer_tax_class_ids is used - @resubaka (#307)
1316

1417
### Fixed

config/default.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,22 @@
229229
"process": 4
230230
},
231231
"simd": true,
232-
"keepDownloads": true
232+
"keepDownloads": true,
233+
"caching": {
234+
"active": false,
235+
"type": "file",
236+
"file": {
237+
"path": "/tmp/vue-storefront-api"
238+
},
239+
"google-cloud-storage": {
240+
"libraryOptions": {},
241+
"bucket": "",
242+
"prefix": "vue-storefront-api/image-cache"
243+
}
244+
},
245+
"action": {
246+
"type": "local"
247+
}
233248
},
234249
"entities": {
235250
"category": {

config/test.json

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

docker/vue-storefront-api/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ WORKDIR /var/www
77
RUN apk add --no-cache curl git
88

99
COPY package.json ./
10+
COPY yarn.lock ./
1011

1112
RUN apk add --no-cache --virtual .build-deps ca-certificates wget && \
1213
yarn install --no-cache && \

migrations/1530101328854-local_es_config_fix.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,31 @@ const path = require('path')
77

88
const configDir = path.resolve('./config')
99

10-
var files = fs.readdirSync(configDir).filter(function(file) {
10+
var files = fs.readdirSync(configDir).filter((file) => {
1111
if (file === 'default.json') return false
1212

1313
if (file.startsWith('elastic.schema.')) return false
1414

1515
return path.extname(file) === '.json'
1616
})
1717

18-
1918
module.exports.up = next => {
20-
files.forEach(function(file) {
19+
files.forEach((file) => {
2120
var filePath = path.join(configDir, file)
2221

2322
try {
2423
console.log(`Searching for deprecated parameters in file '${filePath}'...`)
2524
let config = JSON.parse(fs.readFileSync(filePath))
2625

27-
if ("esHost" in config) {
26+
if ('esHost' in config) {
2827
console.log("Parameter 'esHost' found - rewriting...", filePath)
2928
let esHostPort = config.esHost.split(':')
3029
_set(config, 'elasticsearch.host', esHostPort[0])
3130
_set(config, 'elasticsearch.port', esHostPort[1])
3231
delete config.esHost
3332
}
3433

35-
if ("esIndexes" in config) {
34+
if ('esIndexes' in config) {
3635
console.log("Parameter 'esIndexes' found - rewriting...")
3736
_set(config, 'elasticsearch.indices', config.esIndexes)
3837
delete config.esIndexes

package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,21 @@
3131
"migrate": "node node_modules/migrate/bin/migrate",
3232
"prestart": "npm run -s build",
3333
"test": "eslint src",
34+
"test:unit": "jest -c test/unit/jest.conf.js",
3435
"setup": "npm run restore; npm run migrate",
35-
"lint": "eslint --ext .js src migrations scripts"
36-
},
37-
"eslintConfig": {
38-
"extends": "eslint:recommended",
39-
"parserOptions": {
40-
"ecmaVersion": 2018,
41-
"sourceType": "module"
42-
},
43-
"env": {
44-
"node": true,
45-
"es6": true
46-
},
47-
"rules": {
48-
"no-console": 0,
49-
"no-unused-vars": 1
50-
}
36+
"lint": "eslint --ext .js,.ts src migrations scripts --fix"
5137
},
38+
"pre-commit": [
39+
"lint"
40+
],
5241
"repository": {
5342
"type": "git",
5443
"url": "git+https://github.com/DivanteLtd/vue-storefront-api.git"
5544
},
5645
"author": "Piotr Karwatka <pkarwatka@divante.pl>",
5746
"license": "MIT",
5847
"dependencies": {
48+
"@google-cloud/storage": "^3.0.3",
5949
"ajv": "^6.4.0",
6050
"ajv-keywords": "^3.4.0",
6151
"body-parser": "^1.18.2",
@@ -68,6 +58,7 @@
6858
"elasticsearch": "^15.2.0",
6959
"email-check": "^1.1.0",
7060
"express": "^4.16.3",
61+
"fs-extra": "^8.1.0",
7162
"graphql": "^0.10.1",
7263
"graphql-tools": "^1.2.1",
7364
"humps": "^1.1.0",
@@ -99,11 +90,23 @@
9990
"@types/body-parser": "^1.17.0",
10091
"@types/config": "^0.0.34",
10192
"@types/express": "^4.16.1",
93+
"@types/jest": "^24.0.11",
10294
"@types/node": "^11.13.4",
95+
"@typescript-eslint/eslint-plugin": "^1.7.1-alpha.17",
96+
"@typescript-eslint/parser": "^1.7.1-alpha.17",
10397
"apollo-server-express": "^1.3.6",
10498
"cpx": "^1.5.0",
105-
"eslint": "^4.16.0",
99+
"jest": "^24.8.0",
100+
"eslint": "^5.0.0",
101+
"eslint-config-standard": "^11.0.0",
102+
"eslint-plugin-import": "^2.13.0",
103+
"eslint-plugin-node": "^6.0.1",
104+
"eslint-plugin-promise": "^3.7.0",
105+
"eslint-plugin-standard": "^3.1.0",
106+
"eslint-plugin-vue-storefront": "^0.0.1",
106107
"nodemon": "^1.18.7",
108+
"ts-jest": "^24.0.2",
109+
"pre-commit": "^1.2.2",
107110
"ts-node": "^8.1.0",
108111
"tslib": "^1.9.3",
109112
"typescript": "3.3.*"

scripts/db.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,30 @@ program
1414

1515
console.log('** Hello! I am going to rebuild EXISTING ES index to fix the schema')
1616
const originalIndex = cmd.indexName
17-
const tempIndex = originalIndex + '_' + Math.round(+new Date()/1000)
18-
17+
const tempIndex = originalIndex + '_' + Math.round(+new Date() / 1000)
18+
1919
console.log(`** Creating temporary index ${tempIndex}`)
20-
es.createIndex(common.db, tempIndex, function(err) {
20+
es.createIndex(common.db, tempIndex, (err) => {
2121
if (err) {
2222
console.log(err)
2323
}
24-
24+
2525
console.log(`** Putting the mappings on top of ${tempIndex}`)
26-
es.putMappings(common.db, tempIndex, function(err) {
27-
26+
es.putMappings(common.db, tempIndex, (err) => {
2827
console.log(`** We will reindex ${originalIndex} with the current schema`)
29-
es.reIndex(common.db, originalIndex, tempIndex, function (err) {
28+
es.reIndex(common.db, originalIndex, tempIndex, (err) => {
3029
if (err) {
3130
console.log(err)
3231
}
33-
32+
3433
console.log('** Removing the original index')
35-
es.deleteIndex(common.db, originalIndex, function (err) {
34+
es.deleteIndex(common.db, originalIndex, (err) => {
3635
if (err) {
3736
console.log(err)
3837
}
39-
38+
4039
console.log('** Creating alias')
41-
es.putAlias(common.db, tempIndex, originalIndex, function (err) {
40+
es.putAlias(common.db, tempIndex, originalIndex, (err) => {
4241
console.log('Done! Bye!')
4342
process.exit(0)
4443
})
@@ -59,7 +58,7 @@ program
5958

6059
console.log('** Hello! I am going to create NEW ES index')
6160
const indexName = cmd.indexName
62-
es.createIndex(common.db, indexName, function (err) {
61+
es.createIndex(common.db, indexName, (err) => {
6362
if (err) {
6463
console.log(err)
6564
}
@@ -83,7 +82,7 @@ process.on('unhandledRejection', (reason, p) => {
8382
// application specific logging, throwing an error, or other logic here
8483
})
8584

86-
process.on('uncaughtException', function (exception) {
85+
process.on('uncaughtException', (exception) => {
8786
console.error(exception) // to see your exception details in the console
8887
// if you are on production, maybe you can send the exception details to your
8988
// email as well ?

scripts/elastic.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ const program = require('commander')
22
const config = require('config').elasticsearch
33
const spawnSync = require('child_process').spawnSync
44

5-
function stdOutErr(stdout, stderr) {
6-
if (stdout.length > 0)
7-
console.log(stdout.toString('utf8'))
8-
if (stderr.length > 0)
9-
console.error(stderr.toString('utf8'))
5+
function stdOutErr (stdout, stderr) {
6+
if (stdout.length > 0) { console.log(stdout.toString('utf8')) }
7+
if (stderr.length > 0) { console.error(stderr.toString('utf8')) }
108
}
119

1210
program
@@ -49,9 +47,9 @@ program
4947
.parse(process.argv)
5048

5149
process.on('unhandledRejection', (reason, p) => {
52-
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason)
50+
console.log('Unhandled Rejection at: Promise ', p, ' reason: ', reason)
5351
})
5452

55-
process.on('uncaughtException', function(exception) {
53+
process.on('uncaughtException', (exception) => {
5654
console.log(exception)
5755
})

0 commit comments

Comments
 (0)