aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-19 13:19:34 +0800
committerFabio Berger <me@fabioberger.com>2018-04-19 13:19:34 +0800
commit2b15c03b9ac516f7e38eef174503096026162b90 (patch)
treefc35b9cd37619c1bb3de82c1fde765cd342e55d3
parent60d879e04537f2af4d7476d384fd0e2002a0fbd3 (diff)
downloaddexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar.gz
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar.bz2
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar.lz
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar.xz
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.tar.zst
dexon-sol-tools-2b15c03b9ac516f7e38eef174503096026162b90.zip
Use methods moved to utils since now shared by multiple scripts
-rw-r--r--packages/monorepo-scripts/src/publish.ts36
1 files changed, 3 insertions, 33 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index 827d6165e..2ae9bbb60 100644
--- a/packages/monorepo-scripts/src/publish.ts
+++ b/packages/monorepo-scripts/src/publish.ts
@@ -44,7 +44,8 @@ const packageNameToWebsitePath: { [name: string]: string } = {
}
// Fetch public, updated Lerna packages
- const updatedPublicLernaPackages = await getUpdatedPublicLernaPackagesAsync();
+ const shouldIncludePrivate = false;
+ const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
await confirmDocPagesRenderAsync(updatedPublicLernaPackages);
@@ -165,23 +166,12 @@ async function pushChangelogsToGithubAsync() {
utils.log(`Pushed CHANGELOG updates to Github`);
}
-async function getUpdatedPublicLernaPackagesAsync(): Promise<LernaPackage[]> {
- const updatedPublicPackages = await getPublicLernaUpdatedPackagesAsync();
- const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
-
- const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
- const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
- return _.includes(updatedPackageNames, pkg.package.name);
- });
- return updatedPublicLernaPackages;
-}
-
async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<PackageToVersionChange> {
const packageToVersionChange: PackageToVersionChange = {};
for (const lernaPackage of updatedPublicLernaPackages) {
const packageName = lernaPackage.package.name;
const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json');
- const changelogJSON = getChangelogJSONOrCreateIfMissing(lernaPackage.package.name, changelogJSONPath);
+ const changelogJSON = utils.getChangelogJSONOrCreateIfMissing(changelogJSONPath);
let changelogs: Changelog[];
try {
changelogs = JSON.parse(changelogJSON);
@@ -276,13 +266,6 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin
});
}
-async function getPublicLernaUpdatedPackagesAsync(): Promise<UpdatedPackage[]> {
- const result = await execAsync(`${LERNA_EXECUTABLE} updated --json`, { cwd: constants.monorepoRootPath });
- const updatedPackages = JSON.parse(result.stdout);
- const updatedPublicPackages = _.filter(updatedPackages, updatedPackage => !updatedPackage.private);
- return updatedPublicPackages;
-}
-
function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string) {
if (proposedNextVersion === currentVersion) {
return utils.getNextPatchVersion(currentVersion);
@@ -294,19 +277,6 @@ function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion
return proposedNextVersion;
}
-function getChangelogJSONOrCreateIfMissing(packageName: string, changelogPath: string): string {
- let changelogJSON: string;
- try {
- changelogJSON = fs.readFileSync(changelogPath, 'utf-8');
- return changelogJSON;
- } catch (err) {
- // If none exists, create new, empty one.
- const emptyChangelogJSON = JSON.stringify([], null, 4);
- fs.writeFileSync(changelogPath, emptyChangelogJSON);
- return emptyChangelogJSON;
- }
-}
-
function shouldAddNewChangelogEntry(currentVersion: string, changelogs: Changelog[]): boolean {
if (_.isEmpty(changelogs)) {
return true;