From 7ab4cc5e5333398986dd5a89443690c15a7c9feb Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 11 Jul 2023 08:39:17 +0100 Subject: [PATCH] [ACA-4715] break dependency on envsubst (#3325) * remove BPM host * break dependency on envsubst * remove prebuild script * cleanup package.json --- .github/actions/before-e2e/action.yml | 14 +- .github/actions/run-e2e-playwright/action.yml | 6 - .github/actions/run-e2e/action.yml | 6 - .github/workflows/pull-request.yml | 2 +- .github/workflows/release.yml | 3 +- Dockerfile | 3 - README.md | 2 +- app/project.json | 6 +- app/proxy.conf.js | 6 +- .../{app.config.json.tpl => app.config.json} | 6 +- docker/run.sh | 4 - docs/getting-started/building-from-source.md | 2 +- package-lock.json | 174 ------------------ package.json | 8 +- .../src/api/api-client-factory.ts | 6 +- protractor.conf.js | 4 +- 16 files changed, 21 insertions(+), 231 deletions(-) rename app/src/{app.config.json.tpl => app.config.json} (99%) diff --git a/.github/actions/before-e2e/action.yml b/.github/actions/before-e2e/action.yml index e6a4edc188..aa5f87fab1 100644 --- a/.github/actions/before-e2e/action.yml +++ b/.github/actions/before-e2e/action.yml @@ -32,7 +32,7 @@ runs: steps: - name: Check content UP shell: bash - run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $APP_CONFIG_ECM_HOST -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1 + run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $BASE_URL -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1 - name: Download artifacts uses: ./.github/actions/download-job-artifact @@ -43,18 +43,6 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} - - name: Replace variables in app.config.json - shell: bash - run: | - APP_CONFIG_FILE_PATH="${{ inputs.to }}/app.config.json" - npx envsub --all $APP_CONFIG_FILE_PATH $APP_CONFIG_FILE_PATH || exit 1 - echo -n " \_ Validating replaced config file ... "; - npx ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d $APP_CONFIG_FILE_PATH --errors=text --verbose || exit 4 - if grep -E -q '\$\{[A-Z0-9_]*\}' $APP_CONFIG_FILE_PATH; then - echo -e "\e[31m \_ ERROR: Variables are still present in the app.config.json file. Some of them might not have default value set.\e[0m"; - exit 5; - fi - - name: Update webdriver-manager shell: bash run: | diff --git a/.github/actions/run-e2e-playwright/action.yml b/.github/actions/run-e2e-playwright/action.yml index 4706f315ec..30a5fd9473 100644 --- a/.github/actions/run-e2e-playwright/action.yml +++ b/.github/actions/run-e2e-playwright/action.yml @@ -22,12 +22,6 @@ runs: - name: Setup and run with options shell: bash run: | - # npx http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\ - - { - echo "APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port}" - } >> .env - npm start > /dev/null &\ echo "Running playwright tests with options ${{ inputs.options }}" diff --git a/.github/actions/run-e2e/action.yml b/.github/actions/run-e2e/action.yml index 91acd6c465..3684275bc9 100644 --- a/.github/actions/run-e2e/action.yml +++ b/.github/actions/run-e2e/action.yml @@ -23,12 +23,6 @@ runs: shell: bash run: | ./node_modules/.bin/tsc -p "./e2e/protractor/$E2E_TSCONFIG" || exit 1; - # npx http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\ - - { - echo "APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port}" - } >> .env - npm start > /dev/null &\ if [ ${{ inputs.test-runner }} == "playwright" ]; then diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 8e48464deb..9ed5968679 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ concurrency: cancel-in-progress: true env: - APP_CONFIG_ECM_HOST: ${{ secrets.PIPELINE_ENV_URL }} + BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} ADMIN_EMAIL: ${{ secrets.PIPELINE_ADMIN_USERNAME }} ADMIN_PASSWORD: ${{ secrets.PIPELINE_ADMIN_PASSWORD }} HR_USER: ${{ secrets.HR_USER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf9d39a9e1..565bdf73d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ on: - develop env: - APP_CONFIG_ECM_HOST: ${{ secrets.PIPELINE_ENV_URL }} + BASE_URL: ${{ secrets.PIPELINE_ENV_URL }} ADMIN_EMAIL: ${{ secrets.PIPELINE_ADMIN_USERNAME }} ADMIN_PASSWORD: ${{ secrets.PIPELINE_ADMIN_PASSWORD }} AWS_REGION: "eu-west-2" @@ -22,7 +22,6 @@ env: PLAYWRIGHT_E2E_HOST: ${{ secrets.PLAYWRIGHT_E2E_HOST }} NPM_REGISTRY_ADDRESS: ${{ secrets.NPM_REGISTRY_ADDRESS }} - jobs: publish-docker-registry: name: "Publish to Quay" diff --git a/Dockerfile b/Dockerfile index 3871207c26..63d033de38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,9 +18,6 @@ USER 101 ARG PROJECT_NAME -ENV APP_CONFIG_BPM_HOST="{protocol}//{hostname}{:port}" -ENV APP_CONFIG_ECM_HOST="{protocol}//{hostname}{:port}" - COPY docker/default.conf.template /etc/nginx/templates/ COPY dist/$PROJECT_NAME /usr/share/nginx/html/ diff --git a/README.md b/README.md index 36ae04780d..92ffaeab0f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Please refer to the public [documentation](https://alfresco-content-app.netlify. Create an `.env` file in the project root folder with the following content ```yml -APP_CONFIG_ECM_HOST="" +BASE_URL="" ``` Where `` is the address of the ACS. diff --git a/app/project.json b/app/project.json index e93f66818a..66f72c684c 100644 --- a/app/project.json +++ b/app/project.json @@ -33,9 +33,9 @@ "app/src/assets", "app/src/favicon-96x96.png", { - "input": "app/.tmp", - "output": "/", - "glob": "app.config.json" + "glob": "app.config.json", + "input": "app/src", + "output": "/" }, { "glob": "**/*", diff --git a/app/proxy.conf.js b/app/proxy.conf.js index be998bbbaf..cd22e0f55a 100644 --- a/app/proxy.conf.js +++ b/app/proxy.conf.js @@ -1,10 +1,10 @@ require('@alfresco/adf-cli/tooling').dotenvConfig({ path: process.env.ENV_FILE }); -const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST; +const { BASE_URL } = process.env; module.exports = { "/alfresco": { - "target": APP_CONFIG_ECM_HOST, + "target": BASE_URL, "secure": false, "pathRewrite": { "^/alfresco/alfresco": "" @@ -13,7 +13,7 @@ module.exports = { 'logLevel': 'debug', onProxyReq: function(request) { if(request["method"] !== "GET") - request.setHeader("origin", APP_CONFIG_ECM_HOST); + request.setHeader("origin", BASE_URL); }, // workaround for REPO-2260 onProxyRes: function (proxyRes) { diff --git a/app/src/app.config.json.tpl b/app/src/app.config.json similarity index 99% rename from app/src/app.config.json.tpl rename to app/src/app.config.json index 8a65d75fc4..49018c02ca 100644 --- a/app/src/app.config.json.tpl +++ b/app/src/app.config.json @@ -1,8 +1,8 @@ { "$schema": "../node_modules/@alfresco/adf-core/app.config.schema.json", - "ecmHost": "${APP_CONFIG_ECM_HOST}", - "aosHost": "${APP_CONFIG_ECM_HOST}/alfresco/aos", - "baseShareUrl": "${APP_CONFIG_ECM_HOST}/#/preview/s", + "ecmHost": "{protocol}//{hostname}{:port}", + "aosHost": "{protocol}//{hostname}{:port}/alfresco/aos", + "baseShareUrl": "{protocol}//{hostname}{:port}/#/preview/s", "providers": "ECM", "authType": "BASIC", "loginRoute": "login", diff --git a/docker/run.sh b/docker/run.sh index 2098ff9601..0f4de1c542 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -3,10 +3,6 @@ set -e eval ALL_ARGUMENTS=("BASE_PATH" - "APP_BASE_SHARE_URL" - "APP_CONFIG_IDENTITY_HOST" - "APP_CONFIG_BPM_HOST" - "APP_CONFIG_ECM_HOST" ) ALL_ARGUMENTS_LENGTH=${#ALL_ARGUMENTS[@]} DOCKER_ARGS="" diff --git a/docs/getting-started/building-from-source.md b/docs/getting-started/building-from-source.md index 7bd1f379f2..01dcd79024 100644 --- a/docs/getting-started/building-from-source.md +++ b/docs/getting-started/building-from-source.md @@ -34,7 +34,7 @@ You need to set some environment variables to be able to run the local dev serve ```yml # App config settings -APP_CONFIG_ECM_HOST="" +BASE_URL="" ``` ## Proxy settings diff --git a/package-lock.json b/package-lock.json index fc9790d8c3..db2bee3825 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,6 @@ "cypress": "^12.14.0", "dotenv": "8.2.0", "dotenv-expand": "^5.1.0", - "envsub": "^4.1.0", "eslint": "^8.42.0", "eslint-plugin-ban": "^1.6.0", "eslint-plugin-import": "2.27.5", @@ -13046,102 +13045,6 @@ "node": ">=6" } }, - "node_modules/envsub": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/envsub/-/envsub-4.1.0.tgz", - "integrity": "sha512-B44hta3xNFu6+zDhOha1TIrZkQHGDO3G5K8D2sJIkm/s3XyQjxWBGp1B+b/Y74Go1PqMP+cp8moPR4JullnD9Q==", - "dev": true, - "dependencies": { - "bluebird": "^3.7.2", - "chalk": "^3.0.0", - "commander": "^4.0.1", - "diff": "^4.0.1", - "handlebars": "^4.5.3", - "lodash": "^4.17.15", - "replace-last": "^1.2.6", - "string.prototype.matchall": "^4.0.8" - }, - "bin": { - "envsub": "bin/envsub.js", - "envsubh": "bin/envsubh.js" - } - }, - "node_modules/envsub/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/envsub/node_modules/chalk": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", - "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/envsub/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/envsub/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/envsub/node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, - "node_modules/envsub/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/envsub/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/errno": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz", @@ -15857,36 +15760,6 @@ "integrity": "sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==", "dev": true }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/handlebars/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -26754,15 +26627,6 @@ "node": ">=0.10" } }, - "node_modules/replace-last": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/replace-last/-/replace-last-1.2.6.tgz", - "integrity": "sha512-Cj+MK38VtNu1S5J73mEZY3ciQb9dJajNq1Q8inP4dn/MhJMjHwoAF3Z3FjspwAEV9pfABl565MQucmrjOkty4g==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -28201,25 +28065,6 @@ "node": ">=8" } }, - "node_modules/string.prototype.matchall": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz", - "integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "get-intrinsic": "^1.1.3", - "has-symbols": "^1.0.3", - "internal-slot": "^1.0.3", - "regexp.prototype.flags": "^1.4.3", - "side-channel": "^1.0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/string.prototype.trim": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", @@ -29669,19 +29514,6 @@ "node": "*" } }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -30628,12 +30460,6 @@ "node": ">=0.10.0" } }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 8959a3ad7f..40423c505e 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,12 @@ { "name": "alfresco-content-app", "version": "4.1.0", - "commit": "", "license": "LGPL-3.0", "scripts": { "postinstall": "ngcc", "ng": "ng", - "validate-app-config": "ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d ./app/.tmp/app.config.json --errors=text --verbose", - "assemble-app-config": "envsub --env-file ./.env --env APP_CONFIG_ECM_HOST={protocol}//{hostname}{:port} --all ./app/src/app.config.json.tpl ./app/.tmp/app.config.json", - "prestart": "mkdir -p ./app/.tmp && npm run assemble-app-config && npm run validate-app-config", "start": "nx serve content-ce", - "start:prod": "npm run validate-app-config && node --max-old-space-size=8192 nx serve content-ce --configuration production", - "prebuild": "mkdir -p ./app/.tmp && cp ./app/src/app.config.json.tpl ./app/.tmp/app.config.json", + "start:prod": "node --max-old-space-size=8192 nx serve content-ce --configuration production", "build": "nx build content-ce", "build.release": "npm run build -- --configuration=production,release", "test": "nx test", @@ -104,7 +99,6 @@ "cypress": "^12.14.0", "dotenv": "8.2.0", "dotenv-expand": "^5.1.0", - "envsub": "^4.1.0", "eslint": "^8.42.0", "eslint-plugin-ban": "^1.6.0", "eslint-plugin-import": "2.27.5", diff --git a/projects/aca-playwright-shared/src/api/api-client-factory.ts b/projects/aca-playwright-shared/src/api/api-client-factory.ts index a848a00eb0..6147a78759 100644 --- a/projects/aca-playwright-shared/src/api/api-client-factory.ts +++ b/projects/aca-playwright-shared/src/api/api-client-factory.ts @@ -49,10 +49,12 @@ export interface AcaBackend { tearDown(): Promise; } +const { BASE_URL } = process.env; + const config = { authType: 'BASIC', - hostBpm: process.env.APP_CONFIG_BPM_HOST, - hostEcm: process.env.APP_CONFIG_ECM_HOST, + hostBpm: BASE_URL, + hostEcm: BASE_URL, provider: 'ECM', contextRoot: 'alfresco' }; diff --git a/protractor.conf.js b/protractor.conf.js index 5186a89326..31e28b1a23 100755 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -19,15 +19,15 @@ const width = 1366; const height = 768; const SAVE_SCREENSHOT = process.env.SAVE_SCREENSHOT === 'true'; -const APP_CONFIG_ECM_HOST = process.env.APP_CONFIG_ECM_HOST || 'http://localhost:8080'; const MAXINSTANCES = process.env.MAXINSTANCES || 1; const E2E_LOG_LEVEL = process.env.E2E_LOG_LEVEL || 'ERROR'; const E2E_TS_CONFIG_FOR_ADF = 'tsconfig.e2e.adf.json'; const LOCAL_ADF_OPTION = '--with-local-adf'; +const { BASE_URL } = process.env; const appConfig = { - hostEcm: APP_CONFIG_ECM_HOST, + hostEcm: BASE_URL || 'http://localhost:8080', providers: 'ECM', authType: 'BASIC' };