From f3805cc6694cde211867d412abea6f68aa92cd53 Mon Sep 17 00:00:00 2001 From: MarcoAguirre <42116904+MarcoAguirre@users.noreply.github.com> Date: Wed, 11 May 2022 12:22:57 -0500 Subject: [PATCH 01/12] Added a task file to setup frontend (#857) --- tasks.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tasks.py diff --git a/tasks.py b/tasks.py new file mode 100644 index 000000000..0e07c3134 --- /dev/null +++ b/tasks.py @@ -0,0 +1,11 @@ +from invoke import task + +@task +def set_environment(c, command): + try: + c.run('npm install') + c.run('make build') + c.run('make run') + c.run('make logs') + except: + print('\n Something went wrong') From b46f511db79d7c07829c02b77a6f5573e275c263 Mon Sep 17 00:00:00 2001 From: almeida-erick <102696058+almeida-erick@users.noreply.github.com> Date: Thu, 12 May 2022 12:23:19 -0500 Subject: [PATCH 02/12] fix: TT-653 Add conditions when an user is currently working on a task (#860) --- .../time-entries-table/time-entries-table.component.spec.ts | 4 ++-- .../components/details-fields/details-fields.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts index 559a13b93..1f6da7c5d 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.spec.ts @@ -190,7 +190,7 @@ describe('Reports Page', () => { it('Should populate the users with the payload from the action executed', () => { const actionSubject = TestBed.inject(ActionsSubject) as ActionsSubject; - const usersArray = [] + const usersArray = []; const action = { type: UserActionTypes.LOAD_USERS_SUCCESS, payload: usersArray @@ -201,7 +201,7 @@ describe('Reports Page', () => { expect(component.users).toEqual(usersArray); }); - + it('The sum of the data dates is equal to {"hours": 3, "minutes":20,"seconds":0}', () => { let {hours,minutes,seconds}: TotalHours = component.sumDates(timeEntryList); expect({hours, minutes, seconds}).toEqual({hours:3,minutes:20,seconds:0}); diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 1afceb347..32b8c408b 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -361,7 +361,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { const isStartDateInTheFuture = moment(startDateToSubmit).isAfter(moment()); const isEndDateInTheFuture = moment(endDateToSubmit).isAfter(moment()); - const timeEntryIsInTheFuture = isStartDateInTheFuture || isEndDateInTheFuture; + const timeEntryIsInTheFuture = isStartDateInTheFuture || (isEndDateInTheFuture && !this.goingToWorkOnThis); if (timeEntryIsInTheFuture) { this.toastrService.error('You cannot start a time-entry in the future'); From 39d9f0aac5fd07646c4b108510df9e125a6bbd3c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 12 May 2022 17:25:14 +0000 Subject: [PATCH 03/12] chore(release): 1.72.6 [skip ci]nn --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c5ecac923..383abf90a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.5", + "version": "1.72.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c0661d64e..31ab9b582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.5", + "version": "1.72.6", "scripts": { "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", From c9d830a7edf51ba5283fcfd18f196348c27c7ddd Mon Sep 17 00:00:00 2001 From: MarcoAguirre <42116904+MarcoAguirre@users.noreply.github.com> Date: Thu, 12 May 2022 14:29:03 -0500 Subject: [PATCH 04/12] Now supports TLS and DNS (#862) * Now supports TLS and DNS * Solved version issue --- infrastructure/main.tf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infrastructure/main.tf b/infrastructure/main.tf index d7b433273..c87877d5f 100644 --- a/infrastructure/main.tf +++ b/infrastructure/main.tf @@ -42,7 +42,8 @@ locals { } module "ui" { - source = "git@github.com:ioet/infra-terraform-modules.git//azure-app-service?ref=tags/v0.0.5" + #source = "../../infra-terraform-modules/azure-app-service" + source = "git@github.com:ioet/infra-terraform-modules.git//azure-app-service?ref=tags/v0.0.13" app_service_name = local.service_name create_app_service_plan = local.create_app_service_plan docker_image_name = "${local.image_name}:${var.image_tag}" @@ -52,8 +53,9 @@ module "ui" { docker_registry_username = data.terraform_remote_state.service.outputs.container_registry_admin_username location = data.terraform_remote_state.service.outputs.container_registry_location resource_group_name = data.terraform_remote_state.service.outputs.resource_group_name - service_plan_kind = local.service_plan_kind service_plan_name = local.service_name service_plan_size = var.service_plan_size service_plan_tier = var.service_plan_tier + hostname = "ui" + dns_zone_name = data.terraform_remote_state.service.outputs.subdomain } From e4e4838e3a642d814232b628a4d163d930f5d1a7 Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 11:11:06 -0500 Subject: [PATCH 05/12] TT-630 Removing use of keys.ts to store evironment variables (#859) --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++++--- Dockerfile | 4 +-- package.json | 1 - scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 ------- scripts/setenv.ts | 33 ------------------------ src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++++++++++--- 9 files changed, 41 insertions(+), 67 deletions(-) delete mode 100644 scripts/populate-var-file.sh delete mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index 5934939b6..db0ed3d19 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index f63625e00..bfa81fde6 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,11 +48,16 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: Running tests - run: npm run ci-test --if-present + run: | + set -a + source .env + set +a + npm run ci-test --if-present + rm .env - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index e1e08bc62..aa7f1e0ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run config && npm run build +RUN npm run build diff --git a/package.json b/package.json index 31ab9b582..24a0e8687 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "time-tracker", "version": "1.72.6", "scripts": { - "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 6ab4a5cd4..504fa13d7 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo 'AUTHORITY = '$AUTHORITY'' >> .env -echo 'CLIENT_ID = '$CLIENT_ID'' >> .env -echo 'SCOPES = '$SCOPES'' >> .env -echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env -echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env -echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env +echo "AUTHORITY='$AUTHORITY'" >> .env +echo "CLIENT_ID='$CLIENT_ID'" >> .env +echo "SCOPES='$SCOPES'" >> .env +echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env +echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env +echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh deleted file mode 100644 index f395689af..000000000 --- a/scripts/populate-var-file.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -> src/environments/keys.ts -echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts -echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts -echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts -echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts -cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts deleted file mode 100644 index 659a587b2..000000000 --- a/scripts/setenv.ts +++ /dev/null @@ -1,33 +0,0 @@ -const { writeFile } = require('fs'); - -const pathJs = `./src/environments/keys.ts` -const contentKeys = -`export const AUTHORITY = '${process.env["AUTHORITY"]}'; -export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; -export const SCOPES = ['${process.env["SCOPES"]}']; -export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; -export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; -`; - -writeFile(pathJs, contentKeys, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJs}`); -}); - -const pathJson = `./src/environments/.keys.json` -const contentKeysJson = -`{ - "authority": "${process.env.AUTHORITY_JSON}", - "client_id": "${process.env.CLIENT_ID_JSON}", - "scopes": ["${process.env.SCOPES_JSON}"] -}`; - -writeFile(pathJson, contentKeysJson, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJson}`); -}); diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 6846b4ca6..d54957afd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,7 +1,6 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. -import * as keys from './keys'; export const environment = { production: false, @@ -9,13 +8,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = keys.AUTHORITY; -export const CLIENT_ID = keys.CLIENT_ID; -export const SCOPES = keys.SCOPES; +export const AUTHORITY = process.env["AUTHORITY"]; +export const CLIENT_ID = process.env["CLIENT_ID"]; +export const SCOPES = process.env["SCOPES"].split(","); export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; -export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; +export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 1a85a6c20..717582daa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,25 @@ +const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); - module.exports = (config) => { + const config_ = { + ...config, + plugins : [ + ...config.plugins, + new webpack.DefinePlugin({ + 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), + 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), + 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), + 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), + 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), + 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) + }) + ] + } addTailwindPlugin({ - webpackConfig: config, + webpackConfig: config_, tailwindConfig, patchComponentsStyles: true }); - return config; + return config_; }; From 67e3d46649b56c72fb5b76880c80be51b78a6868 Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 11:58:57 -0500 Subject: [PATCH 06/12] Revert "TT-630 Removing use of keys.ts to store evironment variables (#859)" (#865) This reverts commit e4e4838e3a642d814232b628a4d163d930f5d1a7. --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++----- Dockerfile | 4 +-- package.json | 1 + scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 +++++++ scripts/setenv.ts | 33 ++++++++++++++++++++++++ src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++----------- 9 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 scripts/populate-var-file.sh create mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index db0ed3d19..5934939b6 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index bfa81fde6..f63625e00 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,16 +48,11 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: Running tests - run: | - set -a - source .env - set +a - npm run ci-test --if-present - rm .env + run: npm run ci-test --if-present - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index aa7f1e0ae..e1e08bc62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run build +RUN npm run config && npm run build diff --git a/package.json b/package.json index 24a0e8687..31ab9b582 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "time-tracker", "version": "1.72.6", "scripts": { + "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 504fa13d7..6ab4a5cd4 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo "AUTHORITY='$AUTHORITY'" >> .env -echo "CLIENT_ID='$CLIENT_ID'" >> .env -echo "SCOPES='$SCOPES'" >> .env -echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env -echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env -echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env +echo 'AUTHORITY = '$AUTHORITY'' >> .env +echo 'CLIENT_ID = '$CLIENT_ID'' >> .env +echo 'SCOPES = '$SCOPES'' >> .env +echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env +echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env +echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh new file mode 100644 index 000000000..f395689af --- /dev/null +++ b/scripts/populate-var-file.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +> src/environments/keys.ts +echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts +echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts +echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts +echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts +cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts new file mode 100644 index 000000000..659a587b2 --- /dev/null +++ b/scripts/setenv.ts @@ -0,0 +1,33 @@ +const { writeFile } = require('fs'); + +const pathJs = `./src/environments/keys.ts` +const contentKeys = +`export const AUTHORITY = '${process.env["AUTHORITY"]}'; +export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; +export const SCOPES = ['${process.env["SCOPES"]}']; +export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; +export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; +`; + +writeFile(pathJs, contentKeys, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJs}`); +}); + +const pathJson = `./src/environments/.keys.json` +const contentKeysJson = +`{ + "authority": "${process.env.AUTHORITY_JSON}", + "client_id": "${process.env.CLIENT_ID_JSON}", + "scopes": ["${process.env.SCOPES_JSON}"] +}`; + +writeFile(pathJson, contentKeysJson, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJson}`); +}); diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d54957afd..6846b4ca6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,6 +1,7 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. +import * as keys from './keys'; export const environment = { production: false, @@ -8,13 +9,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = process.env["AUTHORITY"]; -export const CLIENT_ID = process.env["CLIENT_ID"]; -export const SCOPES = process.env["SCOPES"].split(","); +export const AUTHORITY = keys.AUTHORITY; +export const CLIENT_ID = keys.CLIENT_ID; +export const SCOPES = keys.SCOPES; export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; -export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; +export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; +export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 717582daa..1a85a6c20 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,25 +1,11 @@ -const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); + module.exports = (config) => { - const config_ = { - ...config, - plugins : [ - ...config.plugins, - new webpack.DefinePlugin({ - 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), - 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), - 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), - 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), - 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), - 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) - }) - ] - } addTailwindPlugin({ - webpackConfig: config_, + webpackConfig: config, tailwindConfig, patchComponentsStyles: true }); - return config_; + return config; }; From 4a6f51372c4860534dfb0dd4e63c519e8ab2b922 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 17 May 2022 17:01:02 +0000 Subject: [PATCH 07/12] chore(release): 1.72.7 [skip ci]nn --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 383abf90a..4d55900f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.6", + "version": "1.72.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 31ab9b582..4482ba5be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.6", + "version": "1.72.7", "scripts": { "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", From 74b556a649f91a7aba7f86a640ca8aebca1e817e Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 12:19:12 -0500 Subject: [PATCH 08/12] TT 630 Remove keys.ts to set env variables (#864) * Removing use of keys.ts to store evironment variables * fix: update prod environment --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++++--- Dockerfile | 4 +-- package.json | 1 - scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 ------- scripts/setenv.ts | 33 ------------------------ src/environments/environment.prod.ts | 13 +++++----- src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++++++++++--- 10 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 scripts/populate-var-file.sh delete mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index 5934939b6..db0ed3d19 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index f63625e00..bfa81fde6 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,11 +48,16 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: Running tests - run: npm run ci-test --if-present + run: | + set -a + source .env + set +a + npm run ci-test --if-present + rm .env - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index e1e08bc62..aa7f1e0ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run config && npm run build +RUN npm run build diff --git a/package.json b/package.json index 4482ba5be..2f6425131 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "time-tracker", "version": "1.72.7", "scripts": { - "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 6ab4a5cd4..504fa13d7 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo 'AUTHORITY = '$AUTHORITY'' >> .env -echo 'CLIENT_ID = '$CLIENT_ID'' >> .env -echo 'SCOPES = '$SCOPES'' >> .env -echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env -echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env -echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env +echo "AUTHORITY='$AUTHORITY'" >> .env +echo "CLIENT_ID='$CLIENT_ID'" >> .env +echo "SCOPES='$SCOPES'" >> .env +echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env +echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env +echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh deleted file mode 100644 index f395689af..000000000 --- a/scripts/populate-var-file.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -> src/environments/keys.ts -echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts -echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts -echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts -echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts -cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts deleted file mode 100644 index 659a587b2..000000000 --- a/scripts/setenv.ts +++ /dev/null @@ -1,33 +0,0 @@ -const { writeFile } = require('fs'); - -const pathJs = `./src/environments/keys.ts` -const contentKeys = -`export const AUTHORITY = '${process.env["AUTHORITY"]}'; -export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; -export const SCOPES = ['${process.env["SCOPES"]}']; -export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; -export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; -`; - -writeFile(pathJs, contentKeys, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJs}`); -}); - -const pathJson = `./src/environments/.keys.json` -const contentKeysJson = -`{ - "authority": "${process.env.AUTHORITY_JSON}", - "client_id": "${process.env.CLIENT_ID_JSON}", - "scopes": ["${process.env.SCOPES_JSON}"] -}`; - -writeFile(pathJson, contentKeysJson, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJson}`); -}); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 7beadeb31..75dcb96e4 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,3 @@ -import * as keys from './keys'; export const environment = { production: true, @@ -6,13 +5,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = keys.AUTHORITY; -export const CLIENT_ID = keys.CLIENT_ID; -export const SCOPES = keys.SCOPES; +export const AUTHORITY = process.env["AUTHORITY"]; +export const CLIENT_ID = process.env["CLIENT_ID"]; +export const SCOPES = process.env["SCOPES"].split(","); export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; -export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; +export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 6846b4ca6..d54957afd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,7 +1,6 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. -import * as keys from './keys'; export const environment = { production: false, @@ -9,13 +8,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = keys.AUTHORITY; -export const CLIENT_ID = keys.CLIENT_ID; -export const SCOPES = keys.SCOPES; +export const AUTHORITY = process.env["AUTHORITY"]; +export const CLIENT_ID = process.env["CLIENT_ID"]; +export const SCOPES = process.env["SCOPES"].split(","); export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; -export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; +export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 1a85a6c20..717582daa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,25 @@ +const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); - module.exports = (config) => { + const config_ = { + ...config, + plugins : [ + ...config.plugins, + new webpack.DefinePlugin({ + 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), + 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), + 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), + 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), + 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), + 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) + }) + ] + } addTailwindPlugin({ - webpackConfig: config, + webpackConfig: config_, tailwindConfig, patchComponentsStyles: true }); - return config; + return config_; }; From 7b179d8cf6bb6b5b956e704fab898bf89c2d1543 Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 13:01:05 -0500 Subject: [PATCH 09/12] Revert "TT 630 Remove keys.ts to set env variables (#864)" (#866) This reverts commit 74b556a649f91a7aba7f86a640ca8aebca1e817e. --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++----- Dockerfile | 4 +-- package.json | 1 + scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 +++++++ scripts/setenv.ts | 33 ++++++++++++++++++++++++ src/environments/environment.prod.ts | 13 +++++----- src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++----------- 10 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 scripts/populate-var-file.sh create mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index db0ed3d19..5934939b6 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index bfa81fde6..f63625e00 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,16 +48,11 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: Running tests - run: | - set -a - source .env - set +a - npm run ci-test --if-present - rm .env + run: npm run ci-test --if-present - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index aa7f1e0ae..e1e08bc62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run build +RUN npm run config && npm run build diff --git a/package.json b/package.json index 2f6425131..4482ba5be 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "time-tracker", "version": "1.72.7", "scripts": { + "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 504fa13d7..6ab4a5cd4 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo "AUTHORITY='$AUTHORITY'" >> .env -echo "CLIENT_ID='$CLIENT_ID'" >> .env -echo "SCOPES='$SCOPES'" >> .env -echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env -echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env -echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env +echo 'AUTHORITY = '$AUTHORITY'' >> .env +echo 'CLIENT_ID = '$CLIENT_ID'' >> .env +echo 'SCOPES = '$SCOPES'' >> .env +echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env +echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env +echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh new file mode 100644 index 000000000..f395689af --- /dev/null +++ b/scripts/populate-var-file.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +> src/environments/keys.ts +echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts +echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts +echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts +echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts +cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts new file mode 100644 index 000000000..659a587b2 --- /dev/null +++ b/scripts/setenv.ts @@ -0,0 +1,33 @@ +const { writeFile } = require('fs'); + +const pathJs = `./src/environments/keys.ts` +const contentKeys = +`export const AUTHORITY = '${process.env["AUTHORITY"]}'; +export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; +export const SCOPES = ['${process.env["SCOPES"]}']; +export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; +export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; +`; + +writeFile(pathJs, contentKeys, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJs}`); +}); + +const pathJson = `./src/environments/.keys.json` +const contentKeysJson = +`{ + "authority": "${process.env.AUTHORITY_JSON}", + "client_id": "${process.env.CLIENT_ID_JSON}", + "scopes": ["${process.env.SCOPES_JSON}"] +}`; + +writeFile(pathJson, contentKeysJson, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJson}`); +}); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 75dcb96e4..7beadeb31 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,4 @@ +import * as keys from './keys'; export const environment = { production: true, @@ -5,13 +6,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = process.env["AUTHORITY"]; -export const CLIENT_ID = process.env["CLIENT_ID"]; -export const SCOPES = process.env["SCOPES"].split(","); +export const AUTHORITY = keys.AUTHORITY; +export const CLIENT_ID = keys.CLIENT_ID; +export const SCOPES = keys.SCOPES; export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; -export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; +export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; +export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d54957afd..6846b4ca6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,6 +1,7 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. +import * as keys from './keys'; export const environment = { production: false, @@ -8,13 +9,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = process.env["AUTHORITY"]; -export const CLIENT_ID = process.env["CLIENT_ID"]; -export const SCOPES = process.env["SCOPES"].split(","); +export const AUTHORITY = keys.AUTHORITY; +export const CLIENT_ID = keys.CLIENT_ID; +export const SCOPES = keys.SCOPES; export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; -export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; +export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; +export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 717582daa..1a85a6c20 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,25 +1,11 @@ -const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); + module.exports = (config) => { - const config_ = { - ...config, - plugins : [ - ...config.plugins, - new webpack.DefinePlugin({ - 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), - 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), - 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), - 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), - 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), - 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) - }) - ] - } addTailwindPlugin({ - webpackConfig: config_, + webpackConfig: config, tailwindConfig, patchComponentsStyles: true }); - return config_; + return config; }; From 78578be50a6beefa0557b4c60069f7df18be6ac2 Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 15:28:56 -0500 Subject: [PATCH 10/12] TT-630 enviroment variables (#867) --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++++--- Dockerfile | 4 +-- package.json | 1 - scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 ------- scripts/setenv.ts | 33 ------------------------ src/environments/environment.prod.ts | 13 +++++----- src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++++++++++--- 10 files changed, 47 insertions(+), 74 deletions(-) delete mode 100644 scripts/populate-var-file.sh delete mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index 5934939b6..db0ed3d19 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index f63625e00..bfa81fde6 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,11 +48,16 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-var-file.sh - sh ./scripts/populate-var-file.sh + chmod +x ./scripts/populate-keys.sh + sh ./scripts/populate-keys.sh - name: Running tests - run: npm run ci-test --if-present + run: | + set -a + source .env + set +a + npm run ci-test --if-present + rm .env - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index e1e08bc62..aa7f1e0ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run config && npm run build +RUN npm run build diff --git a/package.json b/package.json index 4482ba5be..2f6425131 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "time-tracker", "version": "1.72.7", "scripts": { - "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 6ab4a5cd4..504fa13d7 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo 'AUTHORITY = '$AUTHORITY'' >> .env -echo 'CLIENT_ID = '$CLIENT_ID'' >> .env -echo 'SCOPES = '$SCOPES'' >> .env -echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env -echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env -echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env +echo "AUTHORITY='$AUTHORITY'" >> .env +echo "CLIENT_ID='$CLIENT_ID'" >> .env +echo "SCOPES='$SCOPES'" >> .env +echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env +echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env +echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh deleted file mode 100644 index f395689af..000000000 --- a/scripts/populate-var-file.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -> src/environments/keys.ts -echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts -echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts -echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts -echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts -echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts -cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts deleted file mode 100644 index 659a587b2..000000000 --- a/scripts/setenv.ts +++ /dev/null @@ -1,33 +0,0 @@ -const { writeFile } = require('fs'); - -const pathJs = `./src/environments/keys.ts` -const contentKeys = -`export const AUTHORITY = '${process.env["AUTHORITY"]}'; -export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; -export const SCOPES = ['${process.env["SCOPES"]}']; -export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; -export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; -`; - -writeFile(pathJs, contentKeys, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJs}`); -}); - -const pathJson = `./src/environments/.keys.json` -const contentKeysJson = -`{ - "authority": "${process.env.AUTHORITY_JSON}", - "client_id": "${process.env.CLIENT_ID_JSON}", - "scopes": ["${process.env.SCOPES_JSON}"] -}`; - -writeFile(pathJson, contentKeysJson, function (err) { - if (err) { - console.log(err); - } - console.log(`Wrote variables to ${pathJson}`); -}); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 7beadeb31..75dcb96e4 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,3 @@ -import * as keys from './keys'; export const environment = { production: true, @@ -6,13 +5,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = keys.AUTHORITY; -export const CLIENT_ID = keys.CLIENT_ID; -export const SCOPES = keys.SCOPES; +export const AUTHORITY = process.env["AUTHORITY"]; +export const CLIENT_ID = process.env["CLIENT_ID"]; +export const SCOPES = process.env["SCOPES"].split(","); export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; -export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; +export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 6846b4ca6..d54957afd 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,7 +1,6 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. -import * as keys from './keys'; export const environment = { production: false, @@ -9,13 +8,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = keys.AUTHORITY; -export const CLIENT_ID = keys.CLIENT_ID; -export const SCOPES = keys.SCOPES; +export const AUTHORITY = process.env["AUTHORITY"]; +export const CLIENT_ID = process.env["CLIENT_ID"]; +export const SCOPES = process.env["SCOPES"].split(","); export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; -export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; +export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; +export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 1a85a6c20..717582daa 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,11 +1,25 @@ +const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); - module.exports = (config) => { + const config_ = { + ...config, + plugins : [ + ...config.plugins, + new webpack.DefinePlugin({ + 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), + 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), + 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), + 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), + 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), + 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) + }) + ] + } addTailwindPlugin({ - webpackConfig: config, + webpackConfig: config_, tailwindConfig, patchComponentsStyles: true }); - return config; + return config_; }; From 693291210b2c457805dbcb8064a99a91ec426277 Mon Sep 17 00:00:00 2001 From: nicolsss <56645701+nicolsss@users.noreply.github.com> Date: Tue, 17 May 2022 16:09:34 -0500 Subject: [PATCH 11/12] Revert "TT-630 enviroment variables (#867)" (#868) This reverts commit 78578be50a6beefa0557b4c60069f7df18be6ac2. --- .github/workflows/CD-time-tracker-ui.yml | 4 +-- .github/workflows/CI-time-tracker-ui.yml | 11 +++----- Dockerfile | 4 +-- package.json | 1 + scripts/populate-keys.sh | 12 ++++----- scripts/populate-var-file.sh | 10 +++++++ scripts/setenv.ts | 33 ++++++++++++++++++++++++ src/environments/environment.prod.ts | 13 +++++----- src/environments/environment.ts | 13 +++++----- webpack.config.js | 20 +++----------- 10 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 scripts/populate-var-file.sh create mode 100644 scripts/setenv.ts diff --git a/.github/workflows/CD-time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml index db0ed3d19..5934939b6 100644 --- a/.github/workflows/CD-time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -35,8 +35,8 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: 'run: npm install and build' run: | diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml index bfa81fde6..f63625e00 100644 --- a/.github/workflows/CI-time-tracker-ui.yml +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -48,16 +48,11 @@ jobs: STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }} AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }} run: | - chmod +x ./scripts/populate-keys.sh - sh ./scripts/populate-keys.sh + chmod +x ./scripts/populate-var-file.sh + sh ./scripts/populate-var-file.sh - name: Running tests - run: | - set -a - source .env - set +a - npm run ci-test --if-present - rm .env + run: npm run ci-test --if-present - name: Generate coverage report env: diff --git a/Dockerfile b/Dockerfile index aa7f1e0ae..e1e08bc62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,13 +43,13 @@ USER ${USERNAME} RUN npm cache clean --force && npm install EXPOSE 4200 EXPOSE 9876 -CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck +CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck FROM development as build COPY .env . -RUN npm run build +RUN npm run config && npm run build diff --git a/package.json b/package.json index 2f6425131..4482ba5be 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "time-tracker", "version": "1.72.7", "scripts": { + "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions", "ng": "ng", "start": "ng serve", diff --git a/scripts/populate-keys.sh b/scripts/populate-keys.sh index 504fa13d7..6ab4a5cd4 100644 --- a/scripts/populate-keys.sh +++ b/scripts/populate-keys.sh @@ -1,10 +1,10 @@ #!/bin/bash > .env -echo "AUTHORITY='$AUTHORITY'" >> .env -echo "CLIENT_ID='$CLIENT_ID'" >> .env -echo "SCOPES='$SCOPES'" >> .env -echo "STACK_EXCHANGE_ID='$STACK_EXCHANGE_ID'" >> .env -echo "STACK_EXCHANGE_ACCESS_TOKEN='$STACK_EXCHANGE_ACCESS_TOKEN'" >> .env -echo "AZURE_APP_CONFIGURATION_CONNECTION_STRING='$AZURE_APP_CONFIGURATION_CONNECTION_STRING'" >> .env +echo 'AUTHORITY = '$AUTHORITY'' >> .env +echo 'CLIENT_ID = '$CLIENT_ID'' >> .env +echo 'SCOPES = '$SCOPES'' >> .env +echo 'STACK_EXCHANGE_ID = '$STACK_EXCHANGE_ID'' >> .env +echo 'STACK_EXCHANGE_ACCESS_TOKEN = '$STACK_EXCHANGE_ACCESS_TOKEN'' >> .env +echo 'AZURE_APP_CONFIGURATION_CONNECTION_STRING = '$AZURE_APP_CONFIGURATION_CONNECTION_STRING'' >> .env cat .env diff --git a/scripts/populate-var-file.sh b/scripts/populate-var-file.sh new file mode 100644 index 000000000..f395689af --- /dev/null +++ b/scripts/populate-var-file.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +> src/environments/keys.ts +echo 'export const AUTHORITY = "'$AUTHORITY'";' >> src/environments/keys.ts +echo 'export const CLIENT_ID = "'$CLIENT_ID'";' >> src/environments/keys.ts +echo 'export const SCOPES = ["'$SCOPES'"];' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ID = "'$STACK_EXCHANGE_ID'";' >> src/environments/keys.ts +echo 'export const STACK_EXCHANGE_ACCESS_TOKEN = "'$STACK_EXCHANGE_ACCESS_TOKEN'";' >> src/environments/keys.ts +echo 'export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = "'$AZURE_APP_CONFIGURATION_CONNECTION_STRING'";' >> src/environments/keys.ts +cat src/environments/keys.ts diff --git a/scripts/setenv.ts b/scripts/setenv.ts new file mode 100644 index 000000000..659a587b2 --- /dev/null +++ b/scripts/setenv.ts @@ -0,0 +1,33 @@ +const { writeFile } = require('fs'); + +const pathJs = `./src/environments/keys.ts` +const contentKeys = +`export const AUTHORITY = '${process.env["AUTHORITY"]}'; +export const CLIENT_ID = '${process.env["CLIENT_ID"]}'; +export const SCOPES = ['${process.env["SCOPES"]}']; +export const STACK_EXCHANGE_ID = '${process.env["STACK_EXCHANGE_ID"]}'; +export const STACK_EXCHANGE_ACCESS_TOKEN = '${process.env["STACK_EXCHANGE_ACCESS_TOKEN"]}'; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = '${process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]}'; +`; + +writeFile(pathJs, contentKeys, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJs}`); +}); + +const pathJson = `./src/environments/.keys.json` +const contentKeysJson = +`{ + "authority": "${process.env.AUTHORITY_JSON}", + "client_id": "${process.env.CLIENT_ID_JSON}", + "scopes": ["${process.env.SCOPES_JSON}"] +}`; + +writeFile(pathJson, contentKeysJson, function (err) { + if (err) { + console.log(err); + } + console.log(`Wrote variables to ${pathJson}`); +}); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 75dcb96e4..7beadeb31 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,4 @@ +import * as keys from './keys'; export const environment = { production: true, @@ -5,13 +6,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = process.env["AUTHORITY"]; -export const CLIENT_ID = process.env["CLIENT_ID"]; -export const SCOPES = process.env["SCOPES"].split(","); +export const AUTHORITY = keys.AUTHORITY; +export const CLIENT_ID = keys.CLIENT_ID; +export const SCOPES = keys.SCOPES; export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; -export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; +export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; +export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index d54957afd..6846b4ca6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,6 +1,7 @@ // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. +import * as keys from './keys'; export const environment = { production: false, @@ -8,13 +9,13 @@ export const environment = { stackexchangeApiUrl: 'https://api.stackexchange.com', }; -export const AUTHORITY = process.env["AUTHORITY"]; -export const CLIENT_ID = process.env["CLIENT_ID"]; -export const SCOPES = process.env["SCOPES"].split(","); +export const AUTHORITY = keys.AUTHORITY; +export const CLIENT_ID = keys.CLIENT_ID; +export const SCOPES = keys.SCOPES; export const ITEMS_PER_PAGE = 5; -export const STACK_EXCHANGE_ID = process.env["STACK_EXCHANGE_ID"]; -export const STACK_EXCHANGE_ACCESS_TOKEN = process.env["STACK_EXCHANGE_ACCESS_TOKEN"]; -export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]; +export const STACK_EXCHANGE_ID = keys.STACK_EXCHANGE_ID; +export const STACK_EXCHANGE_ACCESS_TOKEN = keys.STACK_EXCHANGE_ACCESS_TOKEN; +export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = keys.AZURE_APP_CONFIGURATION_CONNECTION_STRING; export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = { diff --git a/webpack.config.js b/webpack.config.js index 717582daa..1a85a6c20 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,25 +1,11 @@ -const webpack = require('webpack') const { addTailwindPlugin } = require("@ngneat/tailwind"); const tailwindConfig = require("./tailwind.config.js"); + module.exports = (config) => { - const config_ = { - ...config, - plugins : [ - ...config.plugins, - new webpack.DefinePlugin({ - 'process.env.AUTHORITY': JSON.stringify(process.env["AUTHORITY"]), - 'process.env.CLIENT_ID':JSON.stringify(process.env["CLIENT_ID"]), - 'process.env.SCOPES':JSON.stringify(process.env["SCOPES"]), - 'process.env.STACK_EXCHANGE_ID':JSON.stringify(process.env["STACK_EXCHANGE_ID"]), - 'process.env.STACK_EXCHANGE_ACCESS_TOKEN':JSON.stringify(process.env["STACK_EXCHANGE_ACCESS_TOKEN"]), - 'process.env.AZURE_APP_CONFIGURATION_CONNECTION_STRING':JSON.stringify(process.env["AZURE_APP_CONFIGURATION_CONNECTION_STRING"]) - }) - ] - } addTailwindPlugin({ - webpackConfig: config_, + webpackConfig: config, tailwindConfig, patchComponentsStyles: true }); - return config_; + return config; }; From 1735c6a9522052f0f9925aaac02abc18ddbfeedc Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 17 May 2022 21:11:33 +0000 Subject: [PATCH 12/12] chore(release): 1.72.9 [skip ci]nn --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d55900f9..723e7deea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.7", + "version": "1.72.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4482ba5be..0bca8a4de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "time-tracker", - "version": "1.72.7", + "version": "1.72.9", "scripts": { "config": "ts-node ./scripts/setenv.ts", "preinstall": "npx npm-force-resolutions",