From bf1866b2570654a0d3720e7363727d071e8f4264 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 13 Feb 2021 18:35:03 +0100 Subject: [PATCH] Make the build app self contained. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .cfignore | 5 + .vscode/launch.json | 3 +- .vscode/tasks.json | 10 ++ Gruntfile.js | 29 +++- docker/Dockerfile | 3 +- docker/autoconfig.sh | 2 +- package-lock.json | 137 +++++++++++++++--- package.json | 29 ++-- src/assets/config-template.json | 10 +- src/assets/configs-aws | 2 +- .../abb-atg.station-template.json | 2 +- .../abb.station-template.json | 2 +- .../evlink.station-template.json | 2 +- .../keba.station-template.json | 2 +- .../schneider-imredd.station-template.json | 2 +- .../schneider.station-template.json | 2 +- .../siemens.station-template.json | 2 +- .../virtual-simple-atg.station-template.json | 2 +- .../virtual-simple.station-template.json | 2 +- .../virtual.station-template.json | 2 +- src/charging-station/Bootstrap.ts | 5 +- src/charging-station/ChargingStation.ts | 3 +- src/utils/Configuration.ts | 3 +- 23 files changed, 201 insertions(+), 60 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.cfignore b/.cfignore index b4688e92..878b6bc3 100644 --- a/.cfignore +++ b/.cfignore @@ -2,6 +2,7 @@ .gitignore .gitattributes .gitmodules +.github .jshintrc .eslintrc .vscode @@ -9,6 +10,8 @@ .tscache # Logs *.log +# Winston +*-audit.json # Vim # Persistent undo [._]*.un~ @@ -16,8 +19,10 @@ .netrwhist *~ *.orig +src ev-simulator-start.sh ev-simulator-start.bat README.md node_modules manifest-cf-template.yml +mta.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json index 046c8246..8c879c6e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,10 +9,11 @@ "request": "launch", "name": "Debug Program via npm", "cwd": "${workspaceFolder}", + "preLaunchTask": "Build", "runtimeExecutable": "npm", "runtimeArgs": [ "run-script", - "start:dev:debug" + "start:debug" ], "skipFiles": [ "/**" diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..343bcdc2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,10 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build", + "type": "npm", + "script": "build" + } + ] +} diff --git a/Gruntfile.js b/Gruntfile.js index cc434c17..eeaeb558 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,12 +3,35 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), ts: { tsconfig: './tsconfig.json', - dev: { - watch: './src' + buildWatch: { + watch: './src', }, prod: {} + }, + mkdir: { + assets: { + options: { + create: ['dist/assets'], + } + } + }, + copy: { + assets: { + files: [{ + expand: true, + cwd: 'src/assets', + src: '**', + dest: 'dist/assets', + }] + }, + }, + clean: { + build: ['dist'], } }); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-mkdir'); + grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-ts'); - grunt.registerTask('default', ['ts:prod']); + grunt.registerTask('default', ['clean:build', 'ts:prod', 'mkdir:assets', 'copy:assets']); }; diff --git a/docker/Dockerfile b/docker/Dockerfile index f8812848..059ced11 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,10 +14,9 @@ WORKDIR /usr/app COPY --from=builder /usr/builder/node_modules ./node_modules COPY NOTICE LICENSE ./ -COPY src ./src COPY dist ./dist COPY *.json ./ -COPY docker/config.json ./src/assets/config.json +COPY docker/config.json ./dist/assets/config.json COPY docker/autoconfig.sh /autoconfig.sh RUN chmod +x /autoconfig.sh diff --git a/docker/autoconfig.sh b/docker/autoconfig.sh index b39dd3f0..4d188219 100644 --- a/docker/autoconfig.sh +++ b/docker/autoconfig.sh @@ -7,7 +7,7 @@ then [ -z $emobility_server_type ] && { echo "emobility env server type variable not found, exiting"; exit 1; } [ -z $emobility_service_type ] && { echo "emobility env service type variable not found, exiting"; exit 1; } - cp $emobility_install_dir/src/assets/configs-aws/$emobility_server_type-$emobility_service_type-$emobility_landscape.json $emobility_install_dir/src/assets/config.json + cp $emobility_install_dir/src/assets/configs-aws/$emobility_server_type-$emobility_service_type-$emobility_landscape.json $emobility_install_dir/dist/assets/config.json else echo "no emobility env defined, start with default configuration" fi diff --git a/package-lock.json b/package-lock.json index f9f9dc5a..3c273600 100644 --- a/package-lock.json +++ b/package-lock.json @@ -653,9 +653,9 @@ } }, "@types/estree": { - "version": "0.0.45", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz", - "integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==", + "version": "0.0.46", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.46.tgz", + "integrity": "sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==", "dev": true }, "@types/json-schema": { @@ -665,9 +665,9 @@ "dev": true }, "@types/node": { - "version": "14.14.25", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.25.tgz", - "integrity": "sha512-EPpXLOVqDvisVxtlbvzfyqSsFeQxltFbluZNRndIb8tr9KiBnYNLzrc1N3pyKUCww2RNrfHDViqDWWE1LCJQtQ==", + "version": "14.14.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.27.tgz", + "integrity": "sha512-Ecfmo4YDQPwuqTCl1yBxLV5ihKfRlkBmzUEDcfIRvDxOTGQEeikr317Ln7Gcv0tjA8dVgKI3rniqW2G1OyKDng==", "dev": true }, "@types/offscreencanvas": { @@ -4124,12 +4124,12 @@ } }, "eslint": { - "version": "7.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.19.0.tgz", - "integrity": "sha512-CGlMgJY56JZ9ZSYhJuhow61lMPPjUzWmChFya71Z/jilVos7mR/jPgaEfVGgMBY5DshbKdG8Ezb8FDCHcoMEMg==", + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.20.0.tgz", + "integrity": "sha512-qGi0CTcOGP2OtCQBgWZlQjcTuP0XkIpYFj25XtRTQSHC+umNnp7UMshr2G8SLsRFYDdAPFeHOsiteadmMH02Yw==", "dev": true, "requires": { - "@babel/code-frame": "^7.0.0", + "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.3.0", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -4141,7 +4141,7 @@ "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^2.0.0", "espree": "^7.3.1", - "esquery": "^1.2.0", + "esquery": "^1.4.0", "esutils": "^2.0.2", "file-entry-cache": "^6.0.0", "functional-red-black-tree": "^1.0.1", @@ -4168,6 +4168,15 @@ "v8-compile-cache": "^2.0.3" }, "dependencies": { + "@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.4" + } + }, "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", @@ -4424,9 +4433,9 @@ "dev": true }, "esquery": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", - "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" @@ -4824,6 +4833,12 @@ "moment": "^2.11.2" } }, + "file-sync-cmp": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/file-sync-cmp/-/file-sync-cmp-0.1.1.tgz", + "integrity": "sha1-peeo/7+kk7Q7kju9TKiaU7Y7YSs=", + "dev": true + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -5301,6 +5316,88 @@ } } }, + "grunt-contrib-clean": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-clean/-/grunt-contrib-clean-2.0.0.tgz", + "integrity": "sha512-g5ZD3ORk6gMa5ugZosLDQl3dZO7cI3R14U75hTM+dVLVxdMNJCPVmwf9OUt4v4eWgpKKWWoVK9DZc1amJp4nQw==", + "dev": true, + "requires": { + "async": "^2.6.1", + "rimraf": "^2.6.2" + }, + "dependencies": { + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "grunt-contrib-copy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-copy/-/grunt-contrib-copy-1.0.0.tgz", + "integrity": "sha1-cGDGWB6QS4qw0A8HbgqPbj58NXM=", + "dev": true, + "requires": { + "chalk": "^1.1.1", + "file-sync-cmp": "^0.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, "grunt-known-options": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-1.1.1.tgz", @@ -5417,6 +5514,12 @@ } } }, + "grunt-mkdir": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/grunt-mkdir/-/grunt-mkdir-1.1.0.tgz", + "integrity": "sha512-FRE17OYVveNbVJFX8GPGa5bzH2ZiAdBx3q0Kwk2Dg6l+TzLGaTdufUxiUWUbS2MERFacnmXZwDDOR5ZbYW0o+Q==", + "dev": true + }, "grunt-ts": { "version": "6.0.0-beta.22", "resolved": "https://registry.npmjs.org/grunt-ts/-/grunt-ts-6.0.0-beta.22.tgz", @@ -10464,9 +10567,9 @@ }, "dependencies": { "ajv": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz", - "integrity": "sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.0.tgz", + "integrity": "sha512-svS9uILze/cXbH0z2myCK2Brqprx/+JJYK5pHicT/GQiBfzzhUVAIT6MwqJg8y4xV/zoGsUeuPuwtoiKSGE15g==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", diff --git a/package.json b/package.json index 5812d74a..b4fe270f 100644 --- a/package.json +++ b/package.json @@ -21,20 +21,16 @@ "main": "dist/start.js", "scripts": { "prestart": "npm run build", - "start": "node -r source-map-support/register dist/start.js", - "start:dev": "ts-node-dev -- src/start.ts", - "start:dev:debug": "ts-node-dev --inspect -- src/start.ts", - "start:debug": "node -r source-map-support/register --inspect dist/start.js", - "start:prof": "node -r source-map-support/register --prof dist/start.js", - "start:doctorprof": "clinic doctor -- node -r source-map-support/register dist/start.js", - "start:flameprof": "clinic flame -- node -r source-map-support/register dist/start.js", - "start:bubbleprof": "clinic bubbleprof -- node -r source-map-support/register dist/start.js", + "start": "cross-env NODE_ENV=production node -r source-map-support/register dist/start.js", + "start:debug": "cross-env NODE_ENV=production node -r source-map-support/register --inspect dist/start.js", + "start:prof": "cross-env NODE_ENV=production node -r source-map-support/register --prof dist/start.js", + "start:doctorprof": "cross-env NODE_ENV=production clinic doctor -- node -r source-map-support/register dist/start.js", + "start:flameprof": "cross-env NODE_ENV=production clinic flame -- node -r source-map-support/register dist/start.js", + "start:bubbleprof": "cross-env NODE_ENV=production clinic bubbleprof -- node -r source-map-support/register dist/start.js", "grunt": "grunt", - "build": "npm run build:prod", + "build": "npm run grunt", "build:mta": "mbt build", - "build:prod": "npm run grunt", - "build:dev": "npm run grunt -- ts:dev", - "build:clean": "rimraf ./dist", + "build:watch": "npm run grunt -- ts:buildWatch", "lint": "cross-env TIMING=1 eslint --ext .js,.ts src", "lint:fix": "cross-env TIMING=1 eslint --fix --ext .js,.ts src", "import-sort": "npx import-sort-cli --write 'src/**/*.ts{,x}'", @@ -62,20 +58,21 @@ "utf-8-validate": "^5.0.4" }, "devDependencies": { - "@types/node": "^14.14.25", + "@types/node": "^14.14.27", "@types/uuid": "^8.3.0", "@types/ws": "^7.4.0", "@typescript-eslint/eslint-plugin": "^4.15.0", "@typescript-eslint/parser": "^4.15.0", "clinic": "^8.0.1", "cross-env": "^7.0.3", - "eslint": "^7.19.0", + "eslint": "^7.20.0", "grunt": "^1.3.0", + "grunt-contrib-clean": "^2.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-mkdir": "^1.1.0", "grunt-ts": "^6.0.0-beta.22", "mbt": "^1.1.0", "npm-check": "^5.9.2", - "rimraf": "^3.0.2", - "ts-node-dev": "^1.1.1", "typescript": "^4.1.5" } } diff --git a/src/assets/config-template.json b/src/assets/config-template.json index a7eef490..0bc2c309 100644 --- a/src/assets/config-template.json +++ b/src/assets/config-template.json @@ -10,23 +10,23 @@ "workerPoolMaxSize": 16, "stationTemplateURLs": [ { - "file": "./src/assets/station-templates/siemens.station-template.json", + "file": "siemens.station-template.json", "numberOfStations": 1 }, { - "file": "./src/assets/station-templates/keba.station-template.json", + "file": "keba.station-template.json", "numberOfStations": 2 }, { - "file": "./src/assets/station-templates/abb.station-template.json", + "file": "abb.station-template.json", "numberOfStations": 2 }, { - "file": "./src/assets/station-templates/evlink.station-template.json", + "file": "evlink.station-template.json", "numberOfStations": 4 }, { - "file": "./src/assets/station-templates/schneider.station-template.json", + "file": "schneider.station-template.json", "numberOfStations": 1 } ], diff --git a/src/assets/configs-aws b/src/assets/configs-aws index 51d08d86..e72cca60 160000 --- a/src/assets/configs-aws +++ b/src/assets/configs-aws @@ -1 +1 @@ -Subproject commit 51d08d86d46e58e739deb9a75f9044f78b3c96fe +Subproject commit e72cca60a40fc383ff1c4f35aa93fff7fc169968 diff --git a/src/assets/station-templates/abb-atg.station-template.json b/src/assets/station-templates/abb-atg.station-template.json index 875eed45..316f8b3e 100644 --- a/src/assets/station-templates/abb-atg.station-template.json +++ b/src/assets/station-templates/abb-atg.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-ABB", "nameSuffix": "-Roaming", "chargePointModel": "MD_TERRA_53", diff --git a/src/assets/station-templates/abb.station-template.json b/src/assets/station-templates/abb.station-template.json index ce2025c9..3f743f96 100644 --- a/src/assets/station-templates/abb.station-template.json +++ b/src/assets/station-templates/abb.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-ABB", "chargePointModel": "MD_TERRA_53", "chargePointVendor": "ABB", diff --git a/src/assets/station-templates/evlink.station-template.json b/src/assets/station-templates/evlink.station-template.json index aebc3d05..74436fc3 100644 --- a/src/assets/station-templates/evlink.station-template.json +++ b/src/assets/station-templates/evlink.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-EVLINK", "chargePointModel": "MONOBLOCK", "chargePointVendor": "Schneider Electric", diff --git a/src/assets/station-templates/keba.station-template.json b/src/assets/station-templates/keba.station-template.json index b1337fc7..236f0ce5 100644 --- a/src/assets/station-templates/keba.station-template.json +++ b/src/assets/station-templates/keba.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-KEBA", "chargePointModel": "KC-P30-ESS400C2-E0R", "chargePointVendor": "Keba AG", diff --git a/src/assets/station-templates/schneider-imredd.station-template.json b/src/assets/station-templates/schneider-imredd.station-template.json index e82998e1..6daad3a7 100644 --- a/src/assets/station-templates/schneider-imredd.station-template.json +++ b/src/assets/station-templates/schneider-imredd.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-SCHNEIDER", "chargePointModel": "MONOBLOCK", "chargePointVendor": "Schneider Electric", diff --git a/src/assets/station-templates/schneider.station-template.json b/src/assets/station-templates/schneider.station-template.json index 1502c595..353ad567 100644 --- a/src/assets/station-templates/schneider.station-template.json +++ b/src/assets/station-templates/schneider.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-SCHNEIDER", "chargePointModel": "MONOBLOCK", "chargePointVendor": "Schneider Electric", diff --git a/src/assets/station-templates/siemens.station-template.json b/src/assets/station-templates/siemens.station-template.json index 0f48b404..fa05caf0 100644 --- a/src/assets/station-templates/siemens.station-template.json +++ b/src/assets/station-templates/siemens.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-SIEMENS", "fixedName": true, "chargePointModel": "SIEMENSXX213", diff --git a/src/assets/station-templates/virtual-simple-atg.station-template.json b/src/assets/station-templates/virtual-simple-atg.station-template.json index 6b9df513..0da43ac6 100644 --- a/src/assets/station-templates/virtual-simple-atg.station-template.json +++ b/src/assets/station-templates/virtual-simple-atg.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-BASIC", "chargePointModel": "Simulator simple", "chargePointVendor": "Ovomaltin", diff --git a/src/assets/station-templates/virtual-simple.station-template.json b/src/assets/station-templates/virtual-simple.station-template.json index 63e4c143..f251d2c4 100644 --- a/src/assets/station-templates/virtual-simple.station-template.json +++ b/src/assets/station-templates/virtual-simple.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-BASIC", "chargePointModel": "Simulator simple", "chargePointVendor": "Ovomaltin", diff --git a/src/assets/station-templates/virtual.station-template.json b/src/assets/station-templates/virtual.station-template.json index a28fccf5..8cb63eb6 100644 --- a/src/assets/station-templates/virtual.station-template.json +++ b/src/assets/station-templates/virtual.station-template.json @@ -1,5 +1,5 @@ { - "authorizationFile": "./src/assets/authorization-tags.json", + "authorizationFile": "authorization-tags.json", "baseName": "CS-SIMU", "chargePointModel": "Simulator connectors", "chargePointVendor": "Ovomaltin", diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 8c6d415a..486b4fcd 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -4,6 +4,7 @@ import Utils from '../utils/Utils'; import WorkerFactory from '../worker/WorkerFactory'; import Wrk from '../worker/Wrk'; import { isMainThread } from 'worker_threads'; +import path from 'path'; export default class Bootstrap { private static instance: Bootstrap; @@ -13,7 +14,7 @@ export default class Bootstrap { private constructor() { this.started = false; - this.workerScript = './dist/charging-station/StationWorker.js'; + this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'StationWorker.js'); } public static getInstance(): Bootstrap { @@ -36,7 +37,7 @@ export default class Bootstrap { for (let index = 1; index <= nbStations; index++) { const workerData: StationWorkerData = { index, - templateFile: stationURL.file + templateFile: path.join(path.resolve(__dirname, '../'), 'assets', 'station-templates', path.basename(stationURL.file)) }; await this.getWorkerImplementationInstance().addElement(workerData); numStationsTotal++; diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 0c39613b..411c4522 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -29,6 +29,7 @@ import { WebSocketCloseEventStatusCode } from '../types/WebSocket'; import crypto from 'crypto'; import fs from 'fs'; import logger from '../utils/Logger'; +import path from 'path'; export default class ChargingStation { public stationTemplateFile: string; @@ -598,7 +599,7 @@ export default class ChargingStation { } private getAuthorizationFile(): string { - return this.stationInfo.authorizationFile && this.stationInfo.authorizationFile; + return this.stationInfo.authorizationFile && path.join(path.resolve(__dirname, '../'), 'assets', path.basename(this.stationInfo.authorizationFile)); } private getAuthorizedTags(): string[] { diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 6d1f7ccf..99519b7d 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -3,9 +3,10 @@ import ConfigurationData, { StationTemplateURL } from '../types/ConfigurationDat import Bootstrap from '../charging-station/Bootstrap'; import { WorkerProcessType } from '../types/Worker'; import fs from 'fs'; +import path from 'path'; export default class Configuration { - private static configurationFilePath = './src/assets/config.json'; + private static configurationFilePath = path.join(path.resolve(__dirname, '../'), 'assets', 'config.json'); private static configurationFileWatcher: fs.FSWatcher; private static configuration: ConfigurationData; -- 2.34.1