Skip to content

Commit bf43523

Browse files
committed
add dryRun option to the exp release script
1 parent 2a18beb commit bf43523

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

scripts/exp/release.ts

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ import { promisify } from 'util';
2727
import chalk from 'chalk';
2828
import Listr from 'listr';
2929
import { prepare as prepareFirestoreForRelease } from './prepare-firestore-for-exp-release';
30+
import * as yargs from 'yargs';
31+
32+
const argv = yargs
33+
.options({
34+
dryRun: {
35+
type: 'boolean',
36+
default: false
37+
}
38+
})
39+
.help().argv;
3040

3141
const writeFile = promisify(_writeFile);
3242
const git = simpleGit(projectRoot);
3343
const FIREBASE_UMBRELLA_PACKAGE_NAME = 'firebase-exp';
3444

35-
async function publishExpPackages() {
45+
async function publishExpPackages({ dryRun }: { dryRun: boolean }) {
3646
try {
3747
/**
3848
* Welcome to the firebase release CLI!
@@ -68,28 +78,36 @@ async function publishExpPackages() {
6878
const versions = await updatePackageNamesAndVersions(packagePaths);
6979

7080
/**
71-
* Release packages to NPM
81+
* Do not publish to npm and create tags if it's a dryrun
7282
*/
73-
await publishToNpm(packagePaths);
74-
75-
/**
76-
* reset the working tree to recover package names with -exp in the package.json files,
77-
* then bump patch version of firebase-exp (the umbrella package) only
78-
*/
79-
const firebaseExpVersion = new Map<string, string>();
80-
firebaseExpVersion.set(
81-
FIREBASE_UMBRELLA_PACKAGE_NAME,
82-
versions.get(FIREBASE_UMBRELLA_PACKAGE_NAME)
83-
);
84-
const firebaseExpPath = packagePaths.filter(p =>
85-
p.includes(FIREBASE_UMBRELLA_PACKAGE_NAME)
86-
);
87-
await resetWorkingTreeAndBumpVersions(firebaseExpPath, firebaseExpVersion);
83+
if (!dryRun) {
84+
/**
85+
* Release packages to NPM
86+
*/
87+
await publishToNpm(packagePaths);
88+
89+
/**
90+
* reset the working tree to recover package names with -exp in the package.json files,
91+
* then bump patch version of firebase-exp (the umbrella package) only
92+
*/
93+
const firebaseExpVersion = new Map<string, string>();
94+
firebaseExpVersion.set(
95+
FIREBASE_UMBRELLA_PACKAGE_NAME,
96+
versions.get(FIREBASE_UMBRELLA_PACKAGE_NAME)
97+
);
98+
const firebaseExpPath = packagePaths.filter(p =>
99+
p.includes(FIREBASE_UMBRELLA_PACKAGE_NAME)
100+
);
101+
await resetWorkingTreeAndBumpVersions(
102+
firebaseExpPath,
103+
firebaseExpVersion
104+
);
88105

89-
/**
90-
* push to github
91-
*/
92-
await commitAndPush(versions);
106+
/**
107+
* push to github
108+
*/
109+
await commitAndPush(versions);
110+
}
93111
} catch (err) {
94112
/**
95113
* Log any errors that happened during the process
@@ -347,4 +365,4 @@ async function getCurrentSha() {
347365
return (await git.revparse(['--short', 'HEAD'])).trim();
348366
}
349367

350-
publishExpPackages();
368+
publishExpPackages(argv);

0 commit comments

Comments
 (0)