aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-21 07:15:04 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-21 07:15:04 +0800
commit6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8 (patch)
tree7b6a6eb86d6a0463221a502fb886bae6ff5a243c /packages/monorepo-scripts/src
parent938aabde3db0044c658e86765e1bbdbdce4e4a17 (diff)
parente54501522dcf93521c8ff7dfe5b216cffeaa1b29 (diff)
downloaddexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.gz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.bz2
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.lz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.xz
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.tar.zst
dexon-sol-tools-6ffa907f0ef3c94d3ea7d79d99a24939f62e0eb8.zip
Merge branch 'v2-prototype' into feature/website/jobs-page-part2
* v2-prototype: (103 commits) Add changelog entry for @0xproject/utils Add AbortController polyfill to fetchAsync in utils Increase node heap size for webpack command Add missing timestamp to CHANGELOG entries Upgrade some @0xproject packages to 1.0.0 in website Hard code fillOrder selector into abiEncodeFillOrder Returns byte array instead of memory range for encoding fillOrder calldata Created LibAbiEncoder with `fillOrderNoThrow` Add missing dep in migrations Fix the abi-gen entry point Fix linter error Remove the postinstall hook Update website package.json with original imports @0xproject/sra-report@1.0.0 Change all package to depend on the new @0xproject/connect@1.0.0 @0xproject/connect@1.0.0 Use old assert version in @0xproject/connect FIx a typo Remove rc versions from unmigrated packages 0x.js@1.0.0-rc.2 ...
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r--packages/monorepo-scripts/src/constants.ts2
-rw-r--r--packages/monorepo-scripts/src/find_unused_dependencies.ts11
-rw-r--r--packages/monorepo-scripts/src/globals.d.ts19
-rw-r--r--packages/monorepo-scripts/src/postpublish_utils.ts2
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts43
-rw-r--r--packages/monorepo-scripts/src/publish.ts35
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts16
-rw-r--r--packages/monorepo-scripts/src/types.ts14
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts46
9 files changed, 105 insertions, 83 deletions
diff --git a/packages/monorepo-scripts/src/constants.ts b/packages/monorepo-scripts/src/constants.ts
index 3aaf881cb..f08313bd2 100644
--- a/packages/monorepo-scripts/src/constants.ts
+++ b/packages/monorepo-scripts/src/constants.ts
@@ -3,6 +3,6 @@ import * as path from 'path';
export const constants = {
monorepoRootPath: path.join(__dirname, '../../..'),
stagingWebsite: 'http://staging-0xproject.s3-website-us-east-1.amazonaws.com',
- lernaExecutable: path.join('node_modules', 'lerna', 'bin', 'lerna.js'),
+ lernaExecutable: path.join('node_modules', 'lerna', 'cli.js'),
githubPersonalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS,
};
diff --git a/packages/monorepo-scripts/src/find_unused_dependencies.ts b/packages/monorepo-scripts/src/find_unused_dependencies.ts
index 11e48ab13..4bb4b7dc5 100644
--- a/packages/monorepo-scripts/src/find_unused_dependencies.ts
+++ b/packages/monorepo-scripts/src/find_unused_dependencies.ts
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import * as depcheckAsync from 'depcheck';
-import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import { constants } from './constants';
@@ -13,15 +12,15 @@ const IGNORE_PACKAGES = ['@0xproject/sol-compiler'];
(async () => {
utils.log('*** NOTE: Not all deps listed here are actually not required. ***');
utils.log("*** `depcheck` isn't perfect so double check before actually removing any. ***\n");
- const lernaPackages = lernaGetPackages(constants.monorepoRootPath);
- for (const lernaPackage of lernaPackages) {
- if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
+ const packages = utils.getPackages(constants.monorepoRootPath);
+ for (const pkg of packages) {
+ if (_.includes(IGNORE_PACKAGES, pkg.packageJson.name)) {
continue; // skip
}
- utils.log(`Checking ${lernaPackage.package.name} for unused deps. This might take a while...`);
+ utils.log(`Checking ${pkg.packageJson.name} for unused deps. This might take a while...`);
const configs = {};
- const { dependencies } = await depcheckAsync(lernaPackage.location, configs);
+ const { dependencies } = await depcheckAsync(pkg.location, configs);
if (!_.isEmpty(dependencies)) {
_.each(dependencies, dep => {
utils.log(dep);
diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts
index 1693a6dbb..cb6a61b55 100644
--- a/packages/monorepo-scripts/src/globals.d.ts
+++ b/packages/monorepo-scripts/src/globals.d.ts
@@ -13,23 +13,4 @@ declare module 'semver-sort' {
const desc: (versions: string[]) => string[];
}
-declare interface LernaPackage {
- location: string;
- package: {
- private?: boolean;
- version: string;
- name: string;
- main?: string;
- scripts?: { [command: string]: string };
- config?: {
- additionalTsTypings?: string[];
- };
- };
-}
-declare function lernaGetPackages(path: string): LernaPackage[];
-// lerna-get-packages declarations
-declare module 'lerna-get-packages' {
- export = lernaGetPackages;
-}
-
declare module 'promisify-child-process';
diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts
index 85b32ed83..3ecb7b7c5 100644
--- a/packages/monorepo-scripts/src/postpublish_utils.ts
+++ b/packages/monorepo-scripts/src/postpublish_utils.ts
@@ -128,7 +128,7 @@ export const postpublishUtils = {
_.each(latestLog.changes, change => {
notes += `* ${change.note}`;
if (change.pr) {
- notes += ` (${change.pr})`;
+ notes += ` (#${change.pr})`;
}
notes += `\n`;
});
diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index 3b4ff9082..431e848ca 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -4,34 +4,33 @@ import semver = require('semver');
import semverSort = require('semver-sort');
import { constants } from './constants';
+import { Package } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { npmUtils } from './utils/npm_utils';
import { utils } from './utils/utils';
async function prepublishChecksAsync(): Promise<void> {
const shouldIncludePrivate = false;
- const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
+ const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);
- await checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(updatedPublicLernaPackages);
- await checkChangelogFormatAsync(updatedPublicLernaPackages);
- await checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicLernaPackages);
+ await checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(updatedPublicPackages);
+ await checkChangelogFormatAsync(updatedPublicPackages);
+ await checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages);
await checkPublishRequiredSetupAsync();
}
-async function checkGitTagsForNextVersionAndDeleteIfExistAsync(
- updatedPublicLernaPackages: LernaPackage[],
-): Promise<void> {
- const packageNames = _.map(updatedPublicLernaPackages, lernaPackage => lernaPackage.package.name);
+async function checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages: Package[]): Promise<void> {
+ const packageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name);
const localGitTags = await utils.getLocalGitTagsAsync();
const localTagVersionsByPackageName = await utils.getGitTagsByPackageNameAsync(packageNames, localGitTags);
const remoteGitTags = await utils.getRemoteGitTagsAsync();
const remoteTagVersionsByPackageName = await utils.getGitTagsByPackageNameAsync(packageNames, remoteGitTags);
- for (const lernaPackage of updatedPublicLernaPackages) {
- const currentVersion = lernaPackage.package.version;
- const packageName = lernaPackage.package.name;
- const packageLocation = lernaPackage.location;
+ for (const pkg of updatedPublicPackages) {
+ const currentVersion = pkg.packageJson.version;
+ const packageName = pkg.packageJson.name;
+ const packageLocation = pkg.location;
const nextVersion = await utils.getNextPackageVersionAsync(currentVersion, packageName, packageLocation);
const remoteTagVersions = remoteTagVersionsByPackageName[packageName];
@@ -49,13 +48,13 @@ async function checkGitTagsForNextVersionAndDeleteIfExistAsync(
}
async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
- updatedPublicLernaPackages: LernaPackage[],
+ updatedPublicPackages: Package[],
): Promise<void> {
utils.log('Check package versions against npmjs.org...');
const versionMismatches = [];
- for (const lernaPackage of updatedPublicLernaPackages) {
- const packageName = lernaPackage.package.name;
- const packageVersion = lernaPackage.package.version;
+ for (const pkg of updatedPublicPackages) {
+ const packageName = pkg.packageJson.name;
+ const packageVersion = pkg.packageJson.version;
const packageRegistryJsonIfExists = await npmUtils.getPackageRegistryJsonIfExistsAsync(packageName);
if (_.isUndefined(packageRegistryJsonIfExists)) {
continue; // noop for packages not yet published to NPM
@@ -84,14 +83,14 @@ async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
}
}
-async function checkChangelogFormatAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<void> {
+async function checkChangelogFormatAsync(updatedPublicPackages: Package[]): Promise<void> {
utils.log('Check CHANGELOGs for inconsistencies...');
const changeLogInconsistencies = [];
- for (const lernaPackage of updatedPublicLernaPackages) {
- const packageName = lernaPackage.package.name;
- const changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, lernaPackage.location);
+ for (const pkg of updatedPublicPackages) {
+ const packageName = pkg.packageJson.name;
+ const changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, pkg.location);
- const currentVersion = lernaPackage.package.version;
+ const currentVersion = pkg.packageJson.version;
if (!_.isEmpty(changelog)) {
const lastEntry = changelog[0];
const doesLastEntryHaveTimestamp = !_.isUndefined(lastEntry.timestamp);
@@ -105,7 +104,7 @@ async function checkChangelogFormatAsync(updatedPublicLernaPackages: LernaPackag
// Remove incorrectly added timestamp
delete changelog[0].timestamp;
// Save updated CHANGELOG.json
- await changelogUtils.writeChangelogJsonFileAsync(lernaPackage.location, changelog);
+ await changelogUtils.writeChangelogJsonFileAsync(pkg.location, changelog);
utils.log(`${packageName}: Removed timestamp from latest CHANGELOG.json entry.`);
}
}
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index 72c6c0a71..c44e1f85e 100644
--- a/packages/monorepo-scripts/src/publish.ts
+++ b/packages/monorepo-scripts/src/publish.ts
@@ -11,7 +11,7 @@ import semverDiff = require('semver-diff');
import semverSort = require('semver-sort');
import { constants } from './constants';
-import { PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
+import { Package, PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { utils } from './utils/utils';
@@ -34,19 +34,20 @@ const packageNameToWebsitePath: { [name: string]: string } = {
'sol-cov': 'sol-cov',
subproviders: 'subproviders',
'order-utils': 'order-utils',
+ 'ethereum-types': 'ethereum-types',
};
(async () => {
// Fetch public, updated Lerna packages
const shouldIncludePrivate = false;
- const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
+ const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);
- await confirmDocPagesRenderAsync(updatedPublicLernaPackages);
+ await confirmDocPagesRenderAsync(updatedPublicPackages);
// Update CHANGELOGs
- const updatedPublicLernaPackageNames = _.map(updatedPublicLernaPackages, pkg => pkg.package.name);
- utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicLernaPackageNames.join('\n')}\n`);
- const packageToVersionChange = await updateChangeLogsAsync(updatedPublicLernaPackages);
+ const updatedPublicPackageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name);
+ utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicPackageNames.join('\n')}\n`);
+ const packageToVersionChange = await updateChangeLogsAsync(updatedPublicPackages);
// Push changelog changes to Github
if (!IS_DRY_RUN) {
@@ -65,7 +66,7 @@ const packageNameToWebsitePath: { [name: string]: string } = {
process.exit(1);
});
-async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise<void> {
+async function confirmDocPagesRenderAsync(packages: Package[]): Promise<void> {
// push docs to staging
utils.log("Upload all docJson's to S3 staging...");
await execAsync(`yarn stage_docs`, { cwd: constants.monorepoRootPath });
@@ -76,14 +77,14 @@ async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise<voi
await execAsync(`yarn deploy_staging`, { cwd: pathToWebsite });
const packagesWithDocs = _.filter(packages, pkg => {
- const scriptsIfExists = pkg.package.scripts;
+ const scriptsIfExists = pkg.packageJson.scripts;
if (_.isUndefined(scriptsIfExists)) {
throw new Error('Found a public package without any scripts in package.json');
}
return !_.isUndefined(scriptsIfExists[DOC_GEN_COMMAND]);
});
_.each(packagesWithDocs, pkg => {
- const name = pkg.package.name;
+ const name = pkg.packageJson.name;
const nameWithoutPrefix = _.startsWith(name, NPM_NAMESPACE) ? name.split('@0xproject/')[1] : name;
const docSegmentIfExists = packageNameToWebsitePath[nameWithoutPrefix];
if (_.isUndefined(docSegmentIfExists)) {
@@ -114,15 +115,15 @@ async function pushChangelogsToGithubAsync(): Promise<void> {
utils.log(`Pushed CHANGELOG updates to Github`);
}
-async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<PackageToVersionChange> {
+async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise<PackageToVersionChange> {
const packageToVersionChange: PackageToVersionChange = {};
- for (const lernaPackage of updatedPublicLernaPackages) {
- const packageName = lernaPackage.package.name;
- let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, lernaPackage.location);
+ for (const pkg of updatedPublicPackages) {
+ const packageName = pkg.packageJson.name;
+ let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, pkg.location);
- const currentVersion = lernaPackage.package.version;
+ const currentVersion = pkg.packageJson.version;
const shouldAddNewEntry = changelogUtils.shouldAddNewChangelogEntry(
- lernaPackage.package.name,
+ pkg.packageJson.name,
currentVersion,
changelog,
);
@@ -157,11 +158,11 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[])
}
// Save updated CHANGELOG.json
- await changelogUtils.writeChangelogJsonFileAsync(lernaPackage.location, changelog);
+ await changelogUtils.writeChangelogJsonFileAsync(pkg.location, changelog);
utils.log(`${packageName}: Updated CHANGELOG.json`);
// Generate updated CHANGELOG.md
const changelogMd = changelogUtils.generateChangelogMd(changelog);
- await changelogUtils.writeChangelogMdFileAsync(lernaPackage.location, changelogMd);
+ await changelogUtils.writeChangelogMdFileAsync(pkg.location, changelogMd);
utils.log(`${packageName}: Updated CHANGELOG.md`);
}
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts
index b67154667..668d4ef1d 100644
--- a/packages/monorepo-scripts/src/test_installation.ts
+++ b/packages/monorepo-scripts/src/test_installation.ts
@@ -1,7 +1,6 @@
#!/usr/bin/env node
import * as fs from 'fs';
-import lernaGetPackages = require('lerna-get-packages');
import * as _ from 'lodash';
import * as path from 'path';
import { exec as execAsync } from 'promisify-child-process';
@@ -11,17 +10,14 @@ import { utils } from './utils/utils';
(async () => {
const monorepoRootPath = path.join(__dirname, '../../..');
- const lernaPackages = lernaGetPackages(monorepoRootPath);
+ const packages = utils.getPackages(monorepoRootPath);
const installablePackages = _.filter(
- lernaPackages,
- lernaPackage =>
- !lernaPackage.package.private &&
- !_.isUndefined(lernaPackage.package.main) &&
- lernaPackage.package.main.endsWith('.js'),
+ packages,
+ pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'),
);
- for (const installableLernaPackage of installablePackages) {
- const packagePath = installableLernaPackage.location;
- const packageName = installableLernaPackage.package.name;
+ for (const installablePackage of installablePackages) {
+ const packagePath = installablePackage.location;
+ const packageName = installablePackage.packageJson.name;
utils.log(`Testing ${packageName}`);
let result = await execAsync('npm pack', { cwd: packagePath });
const packedPackageFileName = result.stdout.trim();
diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts
index 61bd75732..9f991c86c 100644
--- a/packages/monorepo-scripts/src/types.ts
+++ b/packages/monorepo-scripts/src/types.ts
@@ -40,3 +40,17 @@ export interface PackageRegistryJson {
export interface GitTagsByPackageName {
[packageName: string]: string[];
}
+
+export interface Package {
+ location: string;
+ packageJson: {
+ private?: boolean;
+ version: string;
+ name: string;
+ main?: string;
+ scripts?: { [command: string]: string };
+ config?: {
+ additionalTsTypings?: string[];
+ };
+ };
+}
diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts
index be3ad950f..8ba59c81d 100644
--- a/packages/monorepo-scripts/src/utils/utils.ts
+++ b/packages/monorepo-scripts/src/utils/utils.ts
@@ -1,10 +1,10 @@
-import lernaGetPackages = require('lerna-get-packages');
+import * as fs from 'fs';
import * as _ from 'lodash';
import { exec as execAsync } from 'promisify-child-process';
import semver = require('semver');
import { constants } from '../constants';
-import { GitTagsByPackageName, UpdatedPackage } from '../types';
+import { GitTagsByPackageName, Package, UpdatedPackage } from '../types';
import { changelogUtils } from './changelog_utils';
@@ -12,15 +12,47 @@ export const utils = {
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
- async getUpdatedLernaPackagesAsync(shouldIncludePrivate: boolean): Promise<LernaPackage[]> {
+ getPackages(rootDir: string): Package[] {
+ const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8');
+ const rootPackageJson = JSON.parse(rootPackageJsonString);
+ if (_.isUndefined(rootPackageJson.workspaces)) {
+ throw new Error(`Did not find 'workspaces' key in root package.json`);
+ }
+ const packages = [];
+ for (const workspace of rootPackageJson.workspaces) {
+ // HACK: Remove allowed wildcards from workspace entries.
+ // This might be entirely comprehensive.
+ const workspacePath = workspace.replace('*', '').replace('**/*', '');
+ const subpackageNames = fs.readdirSync(`${rootDir}/${workspacePath}`);
+ for (const subpackageName of subpackageNames) {
+ if (_.startsWith(subpackageName, '.')) {
+ continue;
+ }
+ const pathToPackageJson = `${rootDir}/${workspacePath}${subpackageName}`;
+ try {
+ const packageJsonString = fs.readFileSync(`${pathToPackageJson}/package.json`, 'utf8');
+ const packageJson = JSON.parse(packageJsonString);
+ const pkg = {
+ location: pathToPackageJson,
+ packageJson,
+ };
+ packages.push(pkg);
+ } catch (err) {
+ utils.log(`Couldn't find a 'package.json' for ${subpackageName}. Skipping.`);
+ }
+ }
+ }
+ return packages;
+ },
+ async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> {
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
- const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
- const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
- return _.includes(updatedPackageNames, pkg.package.name);
+ const allPackages = utils.getPackages(constants.monorepoRootPath);
+ const updatedPackages = _.filter(allPackages, pkg => {
+ return _.includes(updatedPackageNames, pkg.packageJson.name);
});
- return updatedPublicLernaPackages;
+ return updatedPackages;
},
async getLernaUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<UpdatedPackage[]> {
const result = await execAsync(`${constants.lernaExecutable} updated --json`, {