mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs(docs-infra): remove service worker related code from the firebase deploy. (#56210)
PR Close #56210
This commit is contained in:
committed by
Andrew Kushnir
parent
182138e74b
commit
0ad308ef26
@@ -241,10 +241,9 @@ function computeDeploymentsInfo(
|
||||
projectId: 'angular-io',
|
||||
siteId: 'rc-angular-io-site',
|
||||
deployedUrl: 'https://rc.angular.io/',
|
||||
preDeployActions: [pre.disableServiceWorker, pre.redirectNonFilesToStable],
|
||||
preDeployActions: [pre.redirectNonFilesToStable],
|
||||
postDeployActions: [
|
||||
pre.undo.redirectNonFilesToStable,
|
||||
pre.undo.disableServiceWorker,
|
||||
post.testNoActiveRcDeployment,
|
||||
],
|
||||
},
|
||||
@@ -256,12 +255,10 @@ function computeDeploymentsInfo(
|
||||
siteId: 'stable-angular-io-site',
|
||||
deployedUrl: 'https://angular.io/',
|
||||
preDeployActions: [
|
||||
pre.disableServiceWorker,
|
||||
pre.redirectNonFilesToVersion17,
|
||||
],
|
||||
postDeployActions: [
|
||||
pre.undo.redirectNonFilesToVersion17,
|
||||
pre.undo.disableServiceWorker,
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
@@ -299,10 +299,9 @@ describe('deploy-to-firebase:', () => {
|
||||
projectId: 'angular-io',
|
||||
siteId: 'rc-angular-io-site',
|
||||
deployedUrl: 'https://rc.angular.io/',
|
||||
preDeployActions: ['function:disableServiceWorker', 'function:redirectNonFilesToStable'],
|
||||
preDeployActions: ['function:redirectNonFilesToStable'],
|
||||
postDeployActions: [
|
||||
'function:undoRedirectNonFilesToStable',
|
||||
'function:undoDisableServiceWorker',
|
||||
'function:testNoActiveRcDeployment',
|
||||
],
|
||||
},
|
||||
@@ -377,12 +376,10 @@ describe('deploy-to-firebase:', () => {
|
||||
siteId: 'stable-angular-io-site',
|
||||
deployedUrl: 'https://angular.io/',
|
||||
preDeployActions: [
|
||||
'function:disableServiceWorker',
|
||||
'function:redirectNonFilesToVersion17',
|
||||
],
|
||||
postDeployActions: [
|
||||
'function:undoRedirectNonFilesToVersion17',
|
||||
'function:undoDisableServiceWorker',
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -7,18 +7,14 @@ import u from './utils.mjs';
|
||||
const BAZEL_DIST_DIR = '../dist/bin/aio/build';
|
||||
const DIST_DIR = 'dist';
|
||||
const FIREBASE_JSON_PATH = 'firebase.json';
|
||||
const NGSW_JSON_PATH = `${DIST_DIR}/ngsw.json`;
|
||||
const NGSW_JSON_BAK_PATH = `${NGSW_JSON_PATH}.bak`;
|
||||
|
||||
// Exports
|
||||
const exp = {
|
||||
build,
|
||||
checkPayloadSize,
|
||||
disableServiceWorker,
|
||||
undo: {
|
||||
build: undoBuild,
|
||||
checkPayloadSize: undoCheckPayloadSize,
|
||||
disableServiceWorker: undoDisableServiceWorker,
|
||||
},
|
||||
};
|
||||
Object.keys(u.ORIGINS).forEach(originLabel => {
|
||||
@@ -56,14 +52,6 @@ function checkPayloadSize() {
|
||||
u.yarn('payload-size');
|
||||
}
|
||||
|
||||
function disableServiceWorker() {
|
||||
u.logSectionHeader('Disable the ServiceWorker.');
|
||||
|
||||
// Rename the SW manifest (`ngsw.json`). This will cause the ServiceWorker to unregister itself.
|
||||
// See https://angular.io/guide/service-worker-devops#fail-safe.
|
||||
sh.mv(NGSW_JSON_PATH, NGSW_JSON_BAK_PATH);
|
||||
}
|
||||
|
||||
function escapeForRegex(str) {
|
||||
return str.replace(/[.?*+\\|^$()[\]{}]/g, '\\$&');
|
||||
}
|
||||
@@ -121,8 +109,3 @@ function undoBuild() {
|
||||
function undoCheckPayloadSize() {
|
||||
// Nothing to undo.
|
||||
}
|
||||
|
||||
function undoDisableServiceWorker() {
|
||||
u.logSectionHeader('Re-enable the ServiceWorker.');
|
||||
sh.mv(NGSW_JSON_BAK_PATH, NGSW_JSON_PATH);
|
||||
}
|
||||
|
||||
@@ -84,17 +84,6 @@ describe('deploy-to-firebase/pre-deploy-actions:', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('disableServiceWorker()', () => {
|
||||
let mvSpy;
|
||||
|
||||
beforeEach(() => mvSpy = spyOn(sh, 'mv'));
|
||||
|
||||
it('should disable the ServiceWorker by renaming the `ngsw.json` manifest', () => {
|
||||
pre.disableServiceWorker();
|
||||
expect(mvSpy).toHaveBeenCalledWith('dist/ngsw.json', 'dist/ngsw.json.bak');
|
||||
});
|
||||
});
|
||||
|
||||
Object.entries(u.ORIGINS).forEach(([originLabel, origin]) => {
|
||||
[true, false].forEach(allRequests => {
|
||||
const redirectToFnName = `redirect${allRequests ? 'All' : 'NonFiles'}To${originLabel}`;
|
||||
@@ -168,17 +157,6 @@ describe('deploy-to-firebase/pre-deploy-actions:', () => {
|
||||
it('does not need tests', () => expect().nothing());
|
||||
});
|
||||
|
||||
describe('undo.disableServiceWorker()', () => {
|
||||
let mvSpy;
|
||||
|
||||
beforeEach(() => mvSpy = spyOn(sh, 'mv'));
|
||||
|
||||
it('should undo `disableServiceWorker()`', () => {
|
||||
pre.undo.disableServiceWorker();
|
||||
expect(mvSpy).toHaveBeenCalledWith('dist/ngsw.json.bak', 'dist/ngsw.json');
|
||||
});
|
||||
});
|
||||
|
||||
Object.entries(u.ORIGINS).forEach(([originLabel, origin]) => {
|
||||
[true, false].forEach(allRequests => {
|
||||
const redirectToFnName = `redirect${allRequests ? 'All' : 'NonFiles'}To${originLabel}`;
|
||||
|
||||
Reference in New Issue
Block a user