aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-02 01:40:48 +0800
committerFabio Berger <me@fabioberger.com>2018-04-02 01:40:48 +0800
commitbf52ce7e725224de23c2a5318b8224cc92e5188a (patch)
treeeb2fc6b1c715a428a7532985764b50fa4a41f981 /packages/monorepo-scripts/src
parent33ec9fdf47de4d8ab9d8ce43adedf4615dece4d9 (diff)
downloaddexon-sol-tools-bf52ce7e725224de23c2a5318b8224cc92e5188a.tar.gz
dexon-sol-tools-bf52ce7e725224de23c2a5318b8224cc92e5188a.tar.zst
dexon-sol-tools-bf52ce7e725224de23c2a5318b8224cc92e5188a.zip
Add temp comment, clean up code
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r--packages/monorepo-scripts/src/convert_changelogs.ts29
1 files changed, 21 insertions, 8 deletions
diff --git a/packages/monorepo-scripts/src/convert_changelogs.ts b/packages/monorepo-scripts/src/convert_changelogs.ts
index 76ce50ced..7ba4c544e 100644
--- a/packages/monorepo-scripts/src/convert_changelogs.ts
+++ b/packages/monorepo-scripts/src/convert_changelogs.ts
@@ -1,4 +1,9 @@
#!/usr/bin/env node
+/**
+ * TEMPORARY SCRIPT
+ * This script exists to migrate the legacy CHANGELOG.md to the canonical CHANGELOG.md
+ * TODO: Remove after migration is successful and committed.
+ */
import * as fs from 'fs';
import lernaGetPackages = require('lerna-get-packages');
@@ -6,13 +11,14 @@ import * as _ from 'lodash';
import * as moment from 'moment';
import * as path from 'path';
+import { constants } from './constants';
import { Changelog, Changes, UpdatedPackage } from './types';
import { utils } from './utils';
-const MONOREPO_ROOT_PATH = path.join(__dirname, '../../..');
+const HEADER_PRAGMA = '##';
(async () => {
- const allLernaPackages = lernaGetPackages(MONOREPO_ROOT_PATH);
+ const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
const publicLernaPackages = _.filter(allLernaPackages, pkg => !pkg.package.private);
_.each(publicLernaPackages, lernaPackage => {
const changelogMdIfExists = getChangelogMdIfExists(lernaPackage.package.name, lernaPackage.location);
@@ -20,14 +26,20 @@ const MONOREPO_ROOT_PATH = path.join(__dirname, '../../..');
throw new Error(`${lernaPackage.package.name} should have CHANGELOG.md b/c it's public. Add one.`);
}
- const lines = (changelogMdIfExists as any).split('\n');
+ const lines = (changelogMdIfExists as string).split('\n');
const changelogs: Changelog[] = [];
let changelog: Changelog = {
version: '',
changes: [],
};
+ /**
+ * Example MD entry:
+ * ## v0.3.1 - _March 18, 2018_
+ *
+ * * Add TS types for `yargs` (#400)
+ */
for (const line of lines) {
- if (_.startsWith(line, '## ')) {
+ if (_.startsWith(line, `${HEADER_PRAGMA} `)) {
let version = line.substr(4).split(' - ')[0];
if (version === '0.x.x') {
version = utils.getNextPatchVersion(lernaPackage.package.version);
@@ -47,7 +59,7 @@ const MONOREPO_ROOT_PATH = path.join(__dirname, '../../..');
if (!_.includes(dateStr, 'TBD')) {
changelog.isPublished = true;
}
- (changelogs as any).push(changelog);
+ changelogs.push(changelog);
} else if (_.includes(line, '* ')) {
const note = line.split('* ')[1].split(' (#')[0];
const prChunk = line.split(' (#')[1];
@@ -55,10 +67,12 @@ const MONOREPO_ROOT_PATH = path.join(__dirname, '../../..');
if (!_.isUndefined(prChunk)) {
pr = prChunk.split(')')[0];
}
- const changes = {
+ const changes: Changes = {
note,
- pr,
};
+ if (!_.isUndefined(pr)) {
+ changes.pr = _.parseInt(pr);
+ }
changelog.changes.push(changes);
}
}
@@ -77,7 +91,6 @@ function getChangelogMdIfExists(packageName: string, location: string): string |
changelogMd = fs.readFileSync(changelogPath, 'utf-8');
return changelogMd;
} catch (err) {
- // If none exists, create new, empty one.
return undefined;
}
}