From 4f93dd0f048838f3b9975aad9085720b300e74c0 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 3 Nov 2023 15:57:05 +0000 Subject: [PATCH] move files in install to js --- .../{MergeEnvTemplate.ts => MergeEnvTemplate.js} | 12 ++++++------ ...eValueInConfig.ts => ReplaceValueInConfig.js} | 16 ++++++++-------- configure.sh | 2 +- package.json | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) rename Scripts/Install/{MergeEnvTemplate.ts => MergeEnvTemplate.js} (72%) rename Scripts/Install/{ReplaceValueInConfig.ts => ReplaceValueInConfig.js} (72%) diff --git a/Scripts/Install/MergeEnvTemplate.ts b/Scripts/Install/MergeEnvTemplate.js similarity index 72% rename from Scripts/Install/MergeEnvTemplate.ts rename to Scripts/Install/MergeEnvTemplate.js index e81b7fee2d..b03ef656d7 100644 --- a/Scripts/Install/MergeEnvTemplate.ts +++ b/Scripts/Install/MergeEnvTemplate.js @@ -2,12 +2,12 @@ import fs from 'fs'; -const init: Function = (): void => { - const tempate: string = fs.readFileSync('./config.example.env', 'utf8'); - const env: string = fs.readFileSync('./config.env', 'utf8'); +const init = () => { + const tempate = fs.readFileSync('./config.example.env', 'utf8'); + const env = fs.readFileSync('./config.env', 'utf8'); - const linesInTemplate: Array = tempate.split('\n'); - const linesInEnv: Array = env.split('\n'); + const linesInTemplate = tempate.split('\n'); + const linesInEnv= env.split('\n'); for (const line of linesInTemplate) { // this is a comment, ignore. @@ -23,7 +23,7 @@ const init: Function = (): void => { // if the line is present in template but is not present in env file then add it to the env file. We assume, values in template file are default values. if (line.split('=').length > 0) { if ( - linesInEnv.filter((envLine: string) => { + linesInEnv.filter((envLine) => { return ( envLine.split('=').length > 0 && envLine.split('=')[0] === line.split('=')[0] diff --git a/Scripts/Install/ReplaceValueInConfig.ts b/Scripts/Install/ReplaceValueInConfig.js similarity index 72% rename from Scripts/Install/ReplaceValueInConfig.ts rename to Scripts/Install/ReplaceValueInConfig.js index 11bd0df1ce..4256ad6a09 100644 --- a/Scripts/Install/ReplaceValueInConfig.ts +++ b/Scripts/Install/ReplaceValueInConfig.js @@ -2,14 +2,14 @@ import fs from 'fs'; -const init: Function = (): void => { - let env: string = ''; +const init = () => { + let env = ''; try { env = fs.readFileSync('./config.env', 'utf8'); } catch (err) { // do nothing. } - const envValToReplace: string | undefined = process.argv[2]; + const envValToReplace = process.argv[2]; if (!envValToReplace) { // eslint-disable-next-line @@ -17,7 +17,7 @@ const init: Function = (): void => { return; } - const envValToReplaceWith: string | undefined = process.argv[3]; + const envValToReplaceWith= process.argv[3]; if (!envValToReplaceWith) { // eslint-disable-next-line @@ -25,9 +25,9 @@ const init: Function = (): void => { return; } - const linesInEnv: Array = env.split('\n'); - const linesToRender: Array = []; - let found: boolean = false; + const linesInEnv = env.split('\n'); + const linesToRender = []; + let found = false; for (let line of linesInEnv) { // this is a comment, ignore. @@ -35,7 +35,7 @@ const init: Function = (): void => { linesToRender.push(line); } else { found = true; - const items: Array = line.split('='); + const items = line.split('='); items[1] = envValToReplaceWith; line = items.join('='); linesToRender.push(line); diff --git a/configure.sh b/configure.sh index e7bdc61a5d..edf4237cc2 100644 --- a/configure.sh +++ b/configure.sh @@ -170,7 +170,7 @@ touch config.env source ~/.bashrc #Run a scirpt to merge config.env.tpl to config.env -ts-node-esm ./Scripts/Install/MergeEnvTemplate.ts +node ./Scripts/Install/MergeEnvTemplate.js # Load env values from config.env diff --git a/package.json b/package.json index 2ad1a507a0..36d7956863 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,10 @@ "prettier": "^2.6.0" }, "scripts": { - "config-to-dev": "ts-node-esm ./Scripts/Install/ReplaceValueInConfig.ts ENVIRONMENT development", - "config-to-ci": "ts-node-esm ./Scripts/Install/ReplaceValueInConfig.ts ENVIRONMENT ci", - "config-to-test": "ts-node-esm ./Scripts/Install/ReplaceValueInConfig.ts ENVIRONMENT test && ts-node-esm ./Scripts/Install/ReplaceValueInConfig.ts APP_TAG test", - "config-to-production": "ts-node-esm ./Scripts/Install/ReplaceValueInConfig.ts ENVIRONMENT production", + "config-to-dev": "node ./Scripts/Install/ReplaceValueInConfig.js ENVIRONMENT development", + "config-to-ci": "node ./Scripts/Install/ReplaceValueInConfig.js ENVIRONMENT ci", + "config-to-test": "node ./Scripts/Install/ReplaceValueInConfig.js ENVIRONMENT test && node ./Scripts/Install/ReplaceValueInConfig.js APP_TAG test", + "config-to-production": "node ./Scripts/Install/ReplaceValueInConfig.js ENVIRONMENT production", "prerun": "bash configure.sh", "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js", "uninstall": "bash uninstall.sh",