From 982521f284373e855f186985f1e46ad221a5b6fe Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 18 Jun 2021 00:10:39 +0300 Subject: [PATCH] build(docs-infra): align `navigationUrls` in `ngsw-config.json` with Firebase redirects (#42452) The ServiceWorker `navigationUrls` globs defined in `ngsw-config.json` are supposed to exclude any URLs that are redirected on the server (as configured in `firebase.json`). However, the list of redirected URLs/globs in `firebase.json` and `ngsw-config.json` have gotten out of sync. This commit updates the globs in `ngsw-config.json` to match the ones in `firebase.json`. This is in preparation of automatically generating the ServiceWorker `navigationUrls` based on `firebase.json`. PR Close #42452 --- aio/ngsw-config.json | 48 ++++++++++++------- .../unit/testServiceWorkerRoutes.spec.ts | 10 +++- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/aio/ngsw-config.json b/aio/ngsw-config.json index b72479a3df..10555ab0ca 100644 --- a/aio/ngsw-config.json +++ b/aio/ngsw-config.json @@ -79,33 +79,46 @@ "!/**/*__*", "!/**/*__*/**", "!/**/stackblitz/{0,1}", - "!/api/**/AnimationStateDeclarationMetadata*", - "!/api/**/CORE_DIRECTIVES*", - "!/api/**/DirectiveMetadata*", - "!/api/**/HTTP_PROVIDERS*", - "!/api/**/NgFor-*", - "!/api/**/PLATFORM_PIPES*", - "!/api/*/**/*-(class|directive|var|interface|function|pipe|let|type-alias|decorator)", + "!/**/AnimationStateDeclarationMetadata*", + "!/**/CORE_DIRECTIVES*", + "!/**/DirectiveMetadata-*", + "!/**/HTTP_PROVIDERS*", + "!/**/NgFor-*", + "!/**/OptionalMetadata-*", + "!/**/PLATFORM_PIPES*", + "!/**/api/common/Control*", + "!/**/api/common/ControlGroup*", + "!/**/api/common/NgModel/{0,1}", + "!/**/api/common/SelectControlValueAccessor-*", + "!/**/api/common/index/MaxLengthValidator-*", + "!/**/cookbook/ts-to-js*", + "!/api/*/*-(class|decorator|directive|function|interface|let|pipe|type|type-alias|var)", + "!/api/*/testing/*-(class|decorator|directive|function|interface|let|pipe|type|type-alias|var)", + "!/api/*/testing/index/*", "!/api/animate/**", "!/api/api/**", - "!/api/common/Control*", - "!/api/common/MaxLengthValidator*", - "!/api/common/NgModel*", "!/api/http/**", "!/api/http/{0,1}", - "!/api/platform-browser/AnimationDriver*", - "!/api/testing/**", - "!/config/**", + "!/api/platform-browser/AnimationDriver/{0,1}", + "!/api/testing/*-*", + "!/api/upgrade/*/*-(class|decorator|directive|function|interface|let|pipe|type|type-alias|var)", + "!/api/upgrade/*/index/*", + "!/config/app-package-json/{0,1}", + "!/config/solution-tsconfig/{0,1}", + "!/config/tsconfig/{0,1}", "!/devtools/{0,1}", - "!/docs/*/**", - "!/docs/?*", + "!/docs/*/latest/**", + "!/docs/*/latest/{0,1}", + "!/docs/latest/**", + "!/docs/styleguide*", + "!/docs/styleguide/{0,1}", "!/getting-started/**", "!/getting-started/{0,1}", "!/guide/bazel/{0,1}", "!/guide/change-log/{0,1}", "!/guide/cli-quickstart/{0,1}", "!/guide/displaying-data/{0,1}", - "!/guide/learning-angular/{0,1}", + "!/guide/learning-angular*", "!/guide/metadata/{0,1}", "!/guide/ngmodule/{0,1}", "!/guide/quickstart/{0,1}", @@ -117,13 +130,12 @@ "!/guide/updating-to-version-10/{0,1}", "!/guide/updating-to-version-11/{0,1}", "!/guide/webpack/{0,1}", - "!/news/{0,1}", + "!/news*", "!/start/data/{0,1}", "!/start/deployment/{0,1}", "!/start/forms/{0,1}", "!/start/routing/{0,1}", "!/strict/{0,1}", - "!/styleguide/**", "!/styleguide/{0,1}", "!/testing/**", "!/testing/{0,1}" diff --git a/aio/tests/deployment/unit/testServiceWorkerRoutes.spec.ts b/aio/tests/deployment/unit/testServiceWorkerRoutes.spec.ts index 98d37fb007..a56db2ea09 100644 --- a/aio/tests/deployment/unit/testServiceWorkerRoutes.spec.ts +++ b/aio/tests/deployment/unit/testServiceWorkerRoutes.spec.ts @@ -28,9 +28,15 @@ describe('ServiceWorker navigation URLs', () => { expect(isNavigationUrl('/generated/docs/guide/animations.json')).toBeFalsy(); }); - it('should treat `/docs*` URLs correctly', () => { + it('should treat `/docs/*` URLs correctly', () => { const navigationUrls = ['/docs', '/docs/']; - const nonNavigationUrls = ['/docs/foo', '/docs/foo/', '/docs/foo/bar']; + const nonNavigationUrls = [ + '/docs/js/latest', + '/docs/ts/latest/foo', + '/docs/latest/foo/bar', + '/docs/styleguide', + '/docs/styleguide/', + ]; navigationUrls.forEach(url => expect(isNavigationUrl(url)).toBeTruthy(url)); nonNavigationUrls.forEach(url => expect(isNavigationUrl(url)).toBeFalsy(url));