fix: esacpe mappin template filename

This commit is contained in:
Rainer Killinger
2019-10-15 10:42:22 +02:00
committed by Rainer Killinger
parent 4ac6987813
commit 496e6c5bd0
3 changed files with 35 additions and 12 deletions

27
package-lock.json generated
View File

@@ -219,9 +219,9 @@
} }
}, },
"@openstapps/core": { "@openstapps/core": {
"version": "0.28.0", "version": "0.29.0",
"resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.28.0.tgz", "resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.29.0.tgz",
"integrity": "sha512-VwL0ngs2o1xEsgNdne/XipYQimidrtfxT/DemVf28SMbGGjXDDS6NO8er4nMVV9C1uKm6SnKwWlzhKQF2OJjYg==", "integrity": "sha512-xXfBIYWQlnYiRSURxNBs1nmd38EcgAZGXoHRBaT4Cv/E5bt2ciMOo+MqPVLtKaAf1YPHB419FbxxDjxTkccL2g==",
"requires": { "requires": {
"@types/geojson": "1.0.6", "@types/geojson": "1.0.6",
"@types/json-patch": "0.0.30", "@types/json-patch": "0.0.30",
@@ -4151,6 +4151,14 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
}, },
"sanitize-filename": {
"version": "1.6.3",
"resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz",
"integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==",
"requires": {
"truncate-utf8-bytes": "^1.0.0"
}
},
"semver": { "semver": {
"version": "6.1.1", "version": "6.1.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz",
@@ -4688,6 +4696,14 @@
"integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
"dev": true "dev": true
}, },
"truncate-utf8-bytes": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz",
"integrity": "sha1-QFkjkJWS1W94pYGENLC3hInKXys=",
"requires": {
"utf8-byte-length": "^1.0.1"
}
},
"ts-json-schema-generator": { "ts-json-schema-generator": {
"version": "0.42.0", "version": "0.42.0",
"resolved": "https://registry.npmjs.org/ts-json-schema-generator/-/ts-json-schema-generator-0.42.0.tgz", "resolved": "https://registry.npmjs.org/ts-json-schema-generator/-/ts-json-schema-generator-0.42.0.tgz",
@@ -4930,6 +4946,11 @@
"prepend-http": "^2.0.0" "prepend-http": "^2.0.0"
} }
}, },
"utf8-byte-length": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
"integrity": "sha1-9F8VDExm7uloGGUFq5P8u4rWv2E="
},
"utf8-bytes": { "utf8-bytes": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/utf8-bytes/-/utf8-bytes-0.0.1.tgz", "resolved": "https://registry.npmjs.org/utf8-bytes/-/utf8-bytes-0.0.1.tgz",

View File

@@ -10,7 +10,7 @@
"Jovan Krunić <jovan.krunic@gmail.com>", "Jovan Krunić <jovan.krunic@gmail.com>",
"Karl-Philipp Wulfert <krlwlfrt@gmail.com>", "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
"Michel Jonathan Schmitz", "Michel Jonathan Schmitz",
"Rainer Killinger", "Rainer Killinger <git@killinger.co>",
"Sebastian Lange", "Sebastian Lange",
"Wieland Schöbl" "Wieland Schöbl"
], ],
@@ -37,8 +37,8 @@
"config": "3.1.0", "config": "3.1.0",
"cors": "2.8.5", "cors": "2.8.5",
"elasticsearch": "16.1.1", "elasticsearch": "16.1.1",
"express-promise-router": "3.0.3",
"express": "4.17.1", "express": "4.17.1",
"express-promise-router": "3.0.3",
"fs-extra": "8.0.1", "fs-extra": "8.0.1",
"got": "9.6.0", "got": "9.6.0",
"jsonschema": "1.2.4", "jsonschema": "1.2.4",
@@ -49,13 +49,14 @@
"node-cron": "2.0.3", "node-cron": "2.0.3",
"nodemailer": "6.2.1", "nodemailer": "6.2.1",
"promise-queue": "2.2.5", "promise-queue": "2.2.5",
"sanitize-filename": "1.6.3",
"ts-node": "8.2.0", "ts-node": "8.2.0",
"uuid": "3.3.2" "uuid": "3.3.2"
}, },
"devDependencies": { "devDependencies": {
"@openstapps/configuration": "0.21.0", "@openstapps/configuration": "0.21.0",
"@types/chai-as-promised": "7.1.0",
"@types/chai": "4.1.7", "@types/chai": "4.1.7",
"@types/chai-as-promised": "7.1.0",
"@types/config": "0.0.34", "@types/config": "0.0.34",
"@types/cors": "2.8.5", "@types/cors": "2.8.5",
"@types/elasticsearch": "5.0.34", "@types/elasticsearch": "5.0.34",
@@ -71,16 +72,16 @@
"@types/sinon-express-mock": "1.3.7", "@types/sinon-express-mock": "1.3.7",
"@types/supertest": "2.0.7", "@types/supertest": "2.0.7",
"@types/uuid": "3.4.5", "@types/uuid": "3.4.5",
"chai-as-promised": "7.1.1",
"chai": "4.2.0", "chai": "4.2.0",
"chai-as-promised": "7.1.1",
"conventional-changelog-cli": "2.0.21", "conventional-changelog-cli": "2.0.21",
"mocha-typescript": "1.1.17",
"mocha": "6.1.4", "mocha": "6.1.4",
"mocha-typescript": "1.1.17",
"nyc": "14.1.1", "nyc": "14.1.1",
"prepend-file-cli": "1.0.6", "prepend-file-cli": "1.0.6",
"rimraf": "2.6.3", "rimraf": "2.6.3",
"sinon-express-mock": "2.2.0",
"sinon": "7.3.2", "sinon": "7.3.2",
"sinon-express-mock": "2.2.0",
"supertest": "4.0.2", "supertest": "4.0.2",
"tslint": "5.18.0", "tslint": "5.18.0",
"typedoc": "0.14.2", "typedoc": "0.14.2",

View File

@@ -20,12 +20,13 @@ import {Client} from 'elasticsearch';
import {existsSync, writeFileSync} from 'fs'; import {existsSync, writeFileSync} from 'fs';
import {readFile} from 'fs-extra'; import {readFile} from 'fs-extra';
import {resolve} from 'path'; import {resolve} from 'path';
import sanitize = require('sanitize-filename');
import {configFile, coreVersion} from '../../common'; import {configFile, coreVersion} from '../../common';
const dirPath = resolve('src', 'storage', 'elasticsearch', 'templates'); const dirPath = resolve('src', 'storage', 'elasticsearch', 'templates');
const templatePath = resolve(dirPath, `template_${coreVersion}.json`); const templatePath = resolve(dirPath, sanitize(`template_${coreVersion}.json`, {replacement: '-'}));
const errorPath = resolve(dirPath, `failed_template_${coreVersion}.json`); const errorPath = resolve(dirPath, sanitize(`failed_template_${coreVersion}.json`, {replacement: '-'}));
const errorReportPath = resolve(dirPath, `error_report_${coreVersion}.txt`); const errorReportPath = resolve(dirPath, sanitize(`error_report_${coreVersion}.txt`, {replacement: '-'}));
/** /**
* Check if the correct template exists * Check if the correct template exists