aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/monorepo-scripts/package.json5
-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/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
-rw-r--r--packages/typescript-typings/types/lerna-get-packages/index.d.ts16
10 files changed, 106 insertions, 101 deletions
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index f3a6aa793..1d641a7f5 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -33,12 +33,11 @@
"@types/node": "^8.0.53",
"@types/opn": "^5.1.0",
"@types/rimraf": "^2.0.2",
+ "@types/semver": "5.5.0",
"depcheck": "^0.6.9",
- "lerna-get-packages": "^1.0.0",
"make-promises-safe": "^1.1.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
- "@types/semver": "5.5.0",
"tslint": "5.11.0",
"typescript": "2.7.1"
},
@@ -56,8 +55,8 @@
"prompt": "^1.0.0",
"publish-release": "0xproject/publish-release",
"rimraf": "^2.6.2",
- "semver-diff": "^2.1.0",
"semver": "5.5.0",
+ "semver-diff": "^2.1.0",
"semver-sort": "0.0.4"
},
"publishConfig": {
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/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..862656fbf 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`, {
diff --git a/packages/typescript-typings/types/lerna-get-packages/index.d.ts b/packages/typescript-typings/types/lerna-get-packages/index.d.ts
deleted file mode 100644
index 0650a542c..000000000
--- a/packages/typescript-typings/types/lerna-get-packages/index.d.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-declare interface LernaPackage {
- location: string;
- package: {
- private?: boolean;
- version: string;
- name: string;
- main?: string;
- config?: {
- additionalTsTypings?: string[];
- };
- };
-}
-declare function lernaGetPackages(path: string): LernaPackage[];
-declare module 'lerna-get-packages' {
- export = lernaGetPackages;
-}