aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-03 08:36:43 +0800
committerFabio Berger <me@fabioberger.com>2018-04-03 08:36:43 +0800
commit29042e1939315b997422d095fc1c23364f752a63 (patch)
tree49352c2cffd98863e388c594a6b48c22d8993b73 /packages/monorepo-scripts
parent4dbf6559aa28362dae6a7513eae1ccff5e371078 (diff)
downloaddexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar.gz
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar.bz2
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar.lz
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar.xz
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.tar.zst
dexon-sol-tools-29042e1939315b997422d095fc1c23364f752a63.zip
Remove temporary convert_changelog script
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r--packages/monorepo-scripts/package.json2
-rw-r--r--packages/monorepo-scripts/src/convert_changelogs.ts99
2 files changed, 0 insertions, 101 deletions
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index 28729b37c..2000899cf 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -10,10 +10,8 @@
"clean": "shx rm -rf lib",
"build": "tsc",
"test:publish": "run-s build script:publish",
- "convert_changelogs": "run-s build script:convert_changelogs",
"script:deps_versions": "node ./lib/deps_versions.js",
"script:publish": "IS_DRY_RUN=true node ./lib/publish.js",
- "script:convert_changelogs": "node ./lib/convert_changelogs.js"
},
"repository": {
"type": "git",
diff --git a/packages/monorepo-scripts/src/convert_changelogs.ts b/packages/monorepo-scripts/src/convert_changelogs.ts
deleted file mode 100644
index b5be14ed8..000000000
--- a/packages/monorepo-scripts/src/convert_changelogs.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/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');
-import * as _ from 'lodash';
-import * as moment from 'moment';
-import * as path from 'path';
-import { exec as execAsync } from 'promisify-child-process';
-
-import { constants } from './constants';
-import { Changelog, Changes, UpdatedPackage } from './types';
-import { utils } from './utils';
-
-const HEADER_PRAGMA = '##';
-
-(async () => {
- const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
- const publicLernaPackages = _.filter(allLernaPackages, pkg => !pkg.package.private);
- for (const lernaPackage of publicLernaPackages) {
- const changelogMdIfExists = getChangelogMdIfExists(lernaPackage.package.name, lernaPackage.location);
- if (_.isUndefined(changelogMdIfExists)) {
- throw new Error(`${lernaPackage.package.name} should have CHANGELOG.md b/c it's public. Add one.`);
- }
-
- const lines = changelogMdIfExists.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, `${HEADER_PRAGMA} `)) {
- let version = line.substr(4).split(' - ')[0];
- if (version === '0.x.x') {
- version = utils.getNextPatchVersion(lernaPackage.package.version);
- }
- const dateStr = line.split('_')[1];
- let date;
- if (!_.includes(dateStr, 'TBD')) {
- date = moment(dateStr, 'MMMM D, YYYY');
- }
- changelog = {
- version,
- changes: [],
- };
- if (!_.isUndefined(date)) {
- changelog.timestamp = date.unix();
- }
- if (!_.includes(dateStr, 'TBD')) {
- changelog.isPublished = true;
- }
- changelogs.push(changelog);
- } else if (_.includes(line, '* ')) {
- const note = line.split('* ')[1].split(' (#')[0];
- const prChunk = line.split(' (#')[1];
- let pr;
- if (!_.isUndefined(prChunk)) {
- pr = prChunk.split(')')[0];
- }
- const changes: Changes = {
- note,
- };
- if (!_.isUndefined(pr)) {
- changes.pr = _.parseInt(pr);
- }
- changelog.changes.push(changes);
- }
- }
- const changelogJSON = JSON.stringify(changelogs, null, 4);
- const changelogJSONPath = `${lernaPackage.location}/CHANGELOG.json`;
- fs.writeFileSync(changelogJSONPath, changelogJSON);
- await utils.prettifyAsync(changelogJSONPath, constants.monorepoRootPath);
- }
-})().catch(err => {
- utils.log(err.stdout);
- process.exit(1);
-});
-
-function getChangelogMdIfExists(packageName: string, location: string): string | undefined {
- const changelogPath = path.join(location, 'CHANGELOG.md');
- let changelogMd: string;
- try {
- changelogMd = fs.readFileSync(changelogPath, 'utf-8');
- return changelogMd;
- } catch (err) {
- return undefined;
- }
-}