From f8ab6e9eb3edfa821052cc7e558c8c4f6241a086 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 29 Oct 2021 14:17:11 +0300 Subject: [PATCH] refactor(docs-infra): move `deploy-to-firebase.js` into a dedicated directory (#43963) This commit moves the `aio/scripts/deploy-to-firebase.js` script into a new directory, `aio/scripts/deploy-to-firebase/`. This will make it easier to break it up into multiple smaller files to better organize the code (without polluting the `aio/scripts/` directory). PR Close #43963 --- aio/aio-builds-setup/docs/misc--integrate-with-ci.md | 2 +- aio/package.json | 2 +- .../index.js} | 2 +- .../index.spec.js} | 6 +++--- aio/src/extra-files/README.md | 9 +++------ 5 files changed, 9 insertions(+), 12 deletions(-) rename aio/scripts/{deploy-to-firebase.js => deploy-to-firebase/index.js} (99%) rename aio/scripts/{deploy-to-firebase.spec.js => deploy-to-firebase/index.spec.js} (98%) diff --git a/aio/aio-builds-setup/docs/misc--integrate-with-ci.md b/aio/aio-builds-setup/docs/misc--integrate-with-ci.md index 149a429fbc9..c1d986de779 100644 --- a/aio/aio-builds-setup/docs/misc--integrate-with-ci.md +++ b/aio/aio-builds-setup/docs/misc--integrate-with-ci.md @@ -6,4 +6,4 @@ TODO (gkalpak): Add docs. Mention: Relevant files: `aio/aio-builds-setup/scripts/test.sh` - Deploying from CI. Relevant files: `.circleci/config.yml`, `scripts/ci/deploy.sh`, `aio/scripts/build-artifacts.sh`, - `aio/scripts/deploy-to-firebase.js` + `aio/scripts/deploy-to-firebase/index.js` diff --git a/aio/package.json b/aio/package.json index 053f543a68d..0bb4e90207b 100644 --- a/aio/package.json +++ b/aio/package.json @@ -57,7 +57,7 @@ "redirects-test": "node tests/deployment/unit/test", "firebase-utils-test": "node tools/firebase-test-utils/test", "tools-lint": "eslint tools/firebase-test-utils && eslint tools/ng-packages-installer", - "tools-test": "yarn docs-test && yarn boilerplate:test && jasmine tools/ng-packages-installer/index.spec.js && jasmine scripts/deploy-to-firebase.spec.js && yarn firebase-utils-test", + "tools-test": "yarn docs-test && yarn boilerplate:test && jasmine tools/ng-packages-installer/index.spec.js && jasmine scripts/deploy-to-firebase/**/*.spec.js && yarn firebase-utils-test", "preserve-and-sync": "yarn docs", "serve-and-sync": "run-p \"docs-watch --watch-only\" \"start {@}\" --", "boilerplate:add": "node ./tools/examples/example-boilerplate add", diff --git a/aio/scripts/deploy-to-firebase.js b/aio/scripts/deploy-to-firebase/index.js similarity index 99% rename from aio/scripts/deploy-to-firebase.js rename to aio/scripts/deploy-to-firebase/index.js index e5c5f460ee6..440f2883895 100644 --- a/aio/scripts/deploy-to-firebase.js +++ b/aio/scripts/deploy-to-firebase/index.js @@ -244,7 +244,7 @@ function deploy(data) { siteId, } = data; - cd(`${__dirname}/..`); + cd(`${__dirname}/../..`); console.log('\n\n\n==== Run pre-deploy actions. ====\n'); preDeployActions.forEach(fn => fn(data)); diff --git a/aio/scripts/deploy-to-firebase.spec.js b/aio/scripts/deploy-to-firebase/index.spec.js similarity index 98% rename from aio/scripts/deploy-to-firebase.spec.js rename to aio/scripts/deploy-to-firebase/index.spec.js index c701977cd36..36b62b7c50d 100644 --- a/aio/scripts/deploy-to-firebase.spec.js +++ b/aio/scripts/deploy-to-firebase/index.spec.js @@ -8,7 +8,7 @@ const { computeMajorVersion, getLatestCommit, getMostRecentMinorBranch, -} = require('./deploy-to-firebase'); +} = require('./index'); describe('deploy-to-firebase:', () => { @@ -389,11 +389,11 @@ describe('deploy-to-firebase:', () => { it('integration - should run the main script without error', () => { // NOTE: - // This test executes a new instance of the `deploy-to-firebase.js` script on a separate process + // This test executes a new instance of the `deploy-to-firebase` script on a separate process // and thus does not share the `getRemoteRefs()` cache. To improve stability, we retrieve the // latest commit from master ignoring any cached entries. const latestCommitOnMaster = getLatestCommit('master', {retrieveFromCache: false}); - const cmd = `"${process.execPath}" "${__dirname}/deploy-to-firebase" --dry-run`; + const cmd = `"${process.execPath}" "${__dirname}" --dry-run`; const env = { CI_REPO_OWNER: 'angular', CI_REPO_NAME: 'angular', diff --git a/aio/src/extra-files/README.md b/aio/src/extra-files/README.md index 55e0ac8feac..a61c5ec205a 100644 --- a/aio/src/extra-files/README.md +++ b/aio/src/extra-files/README.md @@ -2,12 +2,9 @@ This folder is used for extra files that should be included in deployments to firebase. -After the AIO application had been built and before it is deployed all files and folders -inside the folder with the same name as the current deployment mode (next, stable, archive) -will be copied to the `dist` folder. +After the AIO application had been built and before it is deployed all files and folders inside the folder with the same name as the current deployment mode (next, stable, archive) will be copied to the `dist` folder. -See the `scripts/deploy-to-firebase.js` script for more details. +See the `scripts/deploy-to-firebase/index.js` script for more details. **Note:** -The `deploy-to-firebase.js` script always expects there to be a folder for the current deployment -mode (even if it is empty). +The script always expects there to be a folder for the current deployment mode (even if it is empty).