diff --git a/finland/config.js b/finland/config.js index e183fa52..9d1e71ff 100644 --- a/finland/config.js +++ b/finland/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'finland', diff --git a/gulpfile.js b/gulpfile.js index 92d14fcb..6faf04e3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,7 +17,6 @@ const { buildOTPGraphTask } = require('./task/BuildOTPGraph') const { renameGTFSFile } = require('./task/GTFSRename') const { replaceGTFSFilesTask } = require('./task/GTFSReplace') const { extractFromZip, addToZip } = require('./task/ZipTask') -const patchDeploymentFiles = require('./task/PatchDeploymentFiles') const storageCleanup = require('./task/StorageCleanup') const seedSourceDir = `${config.dataDir}/router-${config.router.id}` // e.g. data/router-hsl @@ -182,6 +181,4 @@ gulp.task('router:store', () => gulp.src(`${config.dataDir}/build/${config.router.id}/**/*`, { buffer: false }).pipe(gulp.dest(`${config.storageDir}/${global.storageDirName}/`)) ) -gulp.task('deploy:prepare', () => patchDeploymentFiles()) - gulp.task('storage:cleanup', () => storageCleanup(config.storageDir, config.router.id, process.env.SEED_TAG)) diff --git a/hsl/config.js b/hsl/config.js index 25009aa6..da4bc812 100644 --- a/hsl/config.js +++ b/hsl/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'hsl', diff --git a/kela/config.js b/kela/config.js index 64613eb8..cf2c2fe7 100644 --- a/kela/config.js +++ b/kela/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'kela', diff --git a/opentripplanner/Dockerfile b/opentripplanner/Dockerfile index 4e4bdd3c..6c9696ac 100644 --- a/opentripplanner/Dockerfile +++ b/opentripplanner/Dockerfile @@ -4,8 +4,8 @@ FROM hsldevcom/opentripplanner:${OTP_TAG} ARG OTP_GRAPH_DIR ENV OTP_GRAPH_DIR=$OTP_GRAPH_DIR -ADD entrypoint.sh /var/otp/entrypoint.sh +ADD entrypoint.sh /var/entrypoint.sh WORKDIR /var/otp/${OTP_GRAPH_DIR} -ENTRYPOINT ["/var/otp/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/var/entrypoint.sh"] \ No newline at end of file diff --git a/task/Common.js b/task/Common.js deleted file mode 100644 index 829e29df..00000000 --- a/task/Common.js +++ /dev/null @@ -1,14 +0,0 @@ - -/* - * id = feedid (String) - * url = feed url (String) - * fit = mapfit shapes (true/falsy) - * rules = OBA Filter rules to apply (array of strings or undefined) - * replacements = replace or remove file from gtfs package (format: {'file_to_replace': 'file_to_replace_with' or null}) - * request options = optional special options for request - */ -const mapSrc = (id, url, fit, rules, replacements, request) => ({ id, url, fit, rules, replacements, request }) - -module.exports = { - mapSrc -} \ No newline at end of file diff --git a/task/PatchDeploymentFiles.js b/task/PatchDeploymentFiles.js deleted file mode 100644 index 4d2b3087..00000000 --- a/task/PatchDeploymentFiles.js +++ /dev/null @@ -1,28 +0,0 @@ -const fs = require('fs') - -const OTP_TAG = process.env.OTP_TAG || 'v2' - -function patchDockerfile (otpTag, graphDir) { - const dockerFile = 'opentripplanner/Dockerfile' - const data = fs.readFileSync(dockerFile, { encoding: 'utf8' }) - const patchedData = data - .replace(//g, otpTag) - .replace(//g, graphDir) - fs.writeFileSync(dockerFile, patchedData, { encoding: 'utf8' }) -} - -function patchLighttpdConf (graphDir) { - const confFile = 'otp-data-server/lighttpd.conf' - const data = fs.readFileSync(confFile, { encoding: 'utf8' }) - const patchedData = data - .replace(//g, graphDir) - fs.writeFileSync(confFile, patchedData, { encoding: 'utf8' }) -} - -module.exports = function () { - return new Promise((resolve) => { - patchDockerfile(OTP_TAG, global.storageDirName) - patchLighttpdConf(global.storageDirName) - resolve() - }) -} diff --git a/util.js b/util.js index 736fd78c..e7adefed 100644 --- a/util.js +++ b/util.js @@ -144,6 +144,16 @@ function dirNameToDate (dirName) { return date instanceof Date && !isNaN(date) ? date : null } +/* + * id = feedid (String) + * url = feed url (String) + * fit = mapfit shapes (true/falsy) + * rules = OBA Filter rules to apply (array of strings or undefined) + * replacements = replace or remove file from gtfs package (format: {'file_to_replace': 'file_to_replace_with' or null}) + * request options = optional special options for request + */ +const mapSrc = (id, url, fit, rules, replacements, request) => ({ id, url, fit, rules, replacements, request }) + module.exports = { zipDir: (zipFile, dir, cb) => { zipWithGlob(zipFile, [`${dir}/*`], undefined, cb) @@ -153,5 +163,6 @@ module.exports = { updateSlackMessage, otpMatching, parseId, - dirNameToDate + dirNameToDate, + mapSrc } diff --git a/varely/config.js b/varely/config.js index baac478b..ceb85412 100644 --- a/varely/config.js +++ b/varely/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'varely', diff --git a/waltti-alt/config.js b/waltti-alt/config.js index ae13b638..f7adb943 100644 --- a/waltti-alt/config.js +++ b/waltti-alt/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'waltti-alt', diff --git a/waltti/config.js b/waltti/config.js index 6d4d704d..3e743159 100644 --- a/waltti/config.js +++ b/waltti/config.js @@ -1,4 +1,4 @@ -const { mapSrc } = require('../task/Common') +const { mapSrc } = require('../util') module.exports = { id: 'waltti',