aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r--packages/monorepo-scripts/src/doc_generate_and_upload.ts2
-rw-r--r--packages/monorepo-scripts/src/publish.ts3
-rw-r--r--packages/monorepo-scripts/src/publish_release_notes.ts2
-rw-r--r--packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts (renamed from packages/monorepo-scripts/src/utils/publish_utils.ts)99
-rw-r--r--packages/monorepo-scripts/src/utils/github_release_utils.ts102
5 files changed, 106 insertions, 102 deletions
diff --git a/packages/monorepo-scripts/src/doc_generate_and_upload.ts b/packages/monorepo-scripts/src/doc_generate_and_upload.ts
index ab1f97ad8..e0e7e1bb5 100644
--- a/packages/monorepo-scripts/src/doc_generate_and_upload.ts
+++ b/packages/monorepo-scripts/src/doc_generate_and_upload.ts
@@ -1,6 +1,6 @@
import * as yargs from 'yargs';
-import { generateAndUploadDocsAsync } from './utils/publish_utils';
+import { generateAndUploadDocsAsync } from './utils/doc_generate_and_upload_utils';
const args = yargs
.option('package', {
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index 64ba73e36..932d912b8 100644
--- a/packages/monorepo-scripts/src/publish.ts
+++ b/packages/monorepo-scripts/src/publish.ts
@@ -14,7 +14,8 @@ import { Package, PackageToNextVersion, VersionChangelog } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { configs } from './utils/configs';
import { utils } from './utils/utils';
-import { publishReleaseNotesAsync, generateAndUploadDocsAsync } from './utils/publish_utils';
+import { publishReleaseNotesAsync } from './utils/github_release_utils';
+import { generateAndUploadDocsAsync } from './utils/doc_generate_and_upload_utils';
const DOC_GEN_COMMAND = 'docs:json';
const NPM_NAMESPACE = '@0xproject/';
diff --git a/packages/monorepo-scripts/src/publish_release_notes.ts b/packages/monorepo-scripts/src/publish_release_notes.ts
index d708e8275..964f5b0bb 100644
--- a/packages/monorepo-scripts/src/publish_release_notes.ts
+++ b/packages/monorepo-scripts/src/publish_release_notes.ts
@@ -2,7 +2,7 @@ import * as promisify from 'es6-promisify';
import * as publishRelease from 'publish-release';
import { utils } from './utils/utils';
-import { publishReleaseNotesAsync } from './utils/publish_utils';
+import { publishReleaseNotesAsync } from './utils/github_release_utils';
(async () => {
const shouldIncludePrivate = false;
diff --git a/packages/monorepo-scripts/src/utils/publish_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
index 13edb70d2..870cbe17c 100644
--- a/packages/monorepo-scripts/src/utils/publish_utils.ts
+++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
@@ -1,9 +1,6 @@
import * as _ from 'lodash';
-import * as promisify from 'es6-promisify';
-import * as publishRelease from 'publish-release';
import { constants } from '../constants';
-import { Package } from '../types';
import { utils } from './utils';
import { readFileSync, writeFileSync } from 'fs';
@@ -22,102 +19,6 @@ interface ExportNameToTypedocNames {
[exportName: string]: string[];
}
-interface Metadata {
- exportPathToTypedocNames: ExportNameToTypedocNames;
- exportPathOrder: string[];
-}
-
-const publishReleaseAsync = promisify(publishRelease);
-export async function publishReleaseNotesAsync(updatedPublishPackages: Package[]): Promise<void> {
- // Git push a tag representing this publish (publish-{commit-hash}) (truncate hash)
- const result = await execAsync('git log -n 1 --pretty=format:"%H"', { cwd: constants.monorepoRootPath });
- const latestGitCommit = result.stdout;
- const shortenedGitCommit = latestGitCommit.slice(0, 7);
- const tagName = `monorepo@${shortenedGitCommit}`;
-
- await execAsync(`git rev-parse ${tagName}`);
- await execAsync('git tag ${tagName}');
-
- await execAsync('git push origin ${tagName}');
- const releaseName = `0x monorepo - ${shortenedGitCommit}`;
-
- let assets: string[] = [];
- let aggregateNotes = '';
- _.each(updatedPublishPackages, pkg => {
- const notes = getReleaseNotesForPackage(pkg.packageJson.name, pkg.packageJson.version);
- if (_.isEmpty(notes)) {
- return; // don't include it
- }
- aggregateNotes += `### ${pkg.packageJson.name}@${pkg.packageJson.version}\n${notes}\n\n`;
-
- const packageAssets = _.get(pkg.packageJson, 'config.postpublish.assets');
- if (!_.isUndefined(packageAssets)) {
- assets = [...assets, ...packageAssets];
- }
- });
- const finalAssets = adjustAssetPaths(assets);
-
- utils.log('Publishing release notes ', releaseName, '...');
- // TODO: Currently publish-release doesn't let you specify the labels for each asset uploaded
- // Ideally we would like to name the assets after the package they are from
- // Source: https://github.com/remixz/publish-release/issues/39
- await publishReleaseAsync({
- token: constants.githubPersonalAccessToken,
- owner: '0xProject',
- tag: tagName,
- repo: '0x-monorepo',
- name: releaseName,
- notes: aggregateNotes,
- draft: false,
- prerelease: false,
- reuseRelease: true,
- reuseDraftOnly: false,
- assets: finalAssets,
- });
-}
-
-// Asset paths should described from the monorepo root. This method prefixes
-// the supplied path with the absolute path to the monorepo root.
-function adjustAssetPaths(assets: string[]): string[] {
- const finalAssets: string[] = [];
- _.each(assets, (asset: string) => {
- const finalAsset = `${constants.monorepoRootPath}/${asset}`;
- finalAssets.push(finalAsset);
- });
- return finalAssets;
-}
-
-function getReleaseNotesForPackage(packageName: string, version: string): string {
- const packageNameWithoutNamespace = packageName.replace('@0xproject/', '');
- const changelogJSONPath = path.join(
- constants.monorepoRootPath,
- 'packages',
- packageNameWithoutNamespace,
- 'CHANGELOG.json',
- );
- const changelogJSON = readFileSync(changelogJSONPath, 'utf-8');
- const changelogs = JSON.parse(changelogJSON);
- const latestLog = changelogs[0];
- // If only has a `Dependencies updated` changelog, we don't include it in release notes
- if (latestLog.changes.length === 1 && latestLog.changes[0].note === constants.dependenciesUpdatedMessage) {
- return '';
- }
- // We sanity check that the version for the changelog notes we are about to publish to Github
- // correspond to the new version of the package.
- // if (version !== latestLog.version) {
- // throw new Error('Expected CHANGELOG.json latest entry version to coincide with published version.');
- // }
- let notes = '';
- _.each(latestLog.changes, change => {
- notes += `* ${change.note}`;
- if (change.pr) {
- notes += ` (#${change.pr})`;
- }
- notes += `\n`;
- });
- return notes;
-}
-
export async function generateAndUploadDocsAsync(packageName: string, isStaging: boolean): Promise<void> {
const monorepoPackages = utils.getPackages(constants.monorepoRootPath);
const pkg = _.find(monorepoPackages, monorepoPackage => {
diff --git a/packages/monorepo-scripts/src/utils/github_release_utils.ts b/packages/monorepo-scripts/src/utils/github_release_utils.ts
new file mode 100644
index 000000000..1f4c4f1e9
--- /dev/null
+++ b/packages/monorepo-scripts/src/utils/github_release_utils.ts
@@ -0,0 +1,102 @@
+import * as _ from 'lodash';
+import * as promisify from 'es6-promisify';
+import * as publishRelease from 'publish-release';
+
+import { constants } from '../constants';
+import { Package } from '../types';
+import { utils } from './utils';
+
+import { readFileSync } from 'fs';
+import * as path from 'path';
+import { exec as execAsync } from 'promisify-child-process';
+
+const publishReleaseAsync = promisify(publishRelease);
+export async function publishReleaseNotesAsync(updatedPublishPackages: Package[]): Promise<void> {
+ // Git push a tag representing this publish (publish-{commit-hash}) (truncate hash)
+ const result = await execAsync('git log -n 1 --pretty=format:"%H"', { cwd: constants.monorepoRootPath });
+ const latestGitCommit = result.stdout;
+ const shortenedGitCommit = latestGitCommit.slice(0, 7);
+ const tagName = `monorepo@${shortenedGitCommit}`;
+
+ await execAsync(`git rev-parse ${tagName}`);
+ await execAsync('git tag ${tagName}');
+
+ await execAsync('git push origin ${tagName}');
+ const releaseName = `0x monorepo - ${shortenedGitCommit}`;
+
+ let assets: string[] = [];
+ let aggregateNotes = '';
+ _.each(updatedPublishPackages, pkg => {
+ const notes = getReleaseNotesForPackage(pkg.packageJson.name, pkg.packageJson.version);
+ if (_.isEmpty(notes)) {
+ return; // don't include it
+ }
+ aggregateNotes += `### ${pkg.packageJson.name}@${pkg.packageJson.version}\n${notes}\n\n`;
+
+ const packageAssets = _.get(pkg.packageJson, 'config.postpublish.assets');
+ if (!_.isUndefined(packageAssets)) {
+ assets = [...assets, ...packageAssets];
+ }
+ });
+ const finalAssets = adjustAssetPaths(assets);
+
+ utils.log('Publishing release notes ', releaseName, '...');
+ // TODO: Currently publish-release doesn't let you specify the labels for each asset uploaded
+ // Ideally we would like to name the assets after the package they are from
+ // Source: https://github.com/remixz/publish-release/issues/39
+ await publishReleaseAsync({
+ token: constants.githubPersonalAccessToken,
+ owner: '0xProject',
+ tag: tagName,
+ repo: '0x-monorepo',
+ name: releaseName,
+ notes: aggregateNotes,
+ draft: false,
+ prerelease: false,
+ reuseRelease: true,
+ reuseDraftOnly: false,
+ assets: finalAssets,
+ });
+}
+
+// Asset paths should described from the monorepo root. This method prefixes
+// the supplied path with the absolute path to the monorepo root.
+function adjustAssetPaths(assets: string[]): string[] {
+ const finalAssets: string[] = [];
+ _.each(assets, (asset: string) => {
+ const finalAsset = `${constants.monorepoRootPath}/${asset}`;
+ finalAssets.push(finalAsset);
+ });
+ return finalAssets;
+}
+
+function getReleaseNotesForPackage(packageName: string, version: string): string {
+ const packageNameWithoutNamespace = packageName.replace('@0xproject/', '');
+ const changelogJSONPath = path.join(
+ constants.monorepoRootPath,
+ 'packages',
+ packageNameWithoutNamespace,
+ 'CHANGELOG.json',
+ );
+ const changelogJSON = readFileSync(changelogJSONPath, 'utf-8');
+ const changelogs = JSON.parse(changelogJSON);
+ const latestLog = changelogs[0];
+ // If only has a `Dependencies updated` changelog, we don't include it in release notes
+ if (latestLog.changes.length === 1 && latestLog.changes[0].note === constants.dependenciesUpdatedMessage) {
+ return '';
+ }
+ // We sanity check that the version for the changelog notes we are about to publish to Github
+ // correspond to the new version of the package.
+ // if (version !== latestLog.version) {
+ // throw new Error('Expected CHANGELOG.json latest entry version to coincide with published version.');
+ // }
+ let notes = '';
+ _.each(latestLog.changes, change => {
+ notes += `* ${change.note}`;
+ if (change.pr) {
+ notes += ` (#${change.pr})`;
+ }
+ notes += `\n`;
+ });
+ return notes;
+}