aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-07-19 22:26:45 +0800
committerFabio Berger <me@fabioberger.com>2018-07-19 22:26:45 +0800
commit1df9370bc21e93267b5432668967118d7001abf2 (patch)
treef93659fd5bb33c988893ffdb467bfaa091ddbd0a
parent7d840c7a1825f9aad16f3ab644e6f31819fefd59 (diff)
downloaddexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar.gz
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar.bz2
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar.lz
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar.xz
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.tar.zst
dexon-sol-tools-1df9370bc21e93267b5432668967118d7001abf2.zip
Renames to remove mention of Lerna
-rw-r--r--packages/monorepo-scripts/src/find_unused_dependencies.ts10
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts44
-rw-r--r--packages/monorepo-scripts/src/publish.ts35
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts15
-rw-r--r--packages/monorepo-scripts/src/types.ts4
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts24
6 files changed, 64 insertions, 68 deletions
diff --git a/packages/monorepo-scripts/src/find_unused_dependencies.ts b/packages/monorepo-scripts/src/find_unused_dependencies.ts
index 1a36aceee..4bb4b7dc5 100644
--- a/packages/monorepo-scripts/src/find_unused_dependencies.ts
+++ b/packages/monorepo-scripts/src/find_unused_dependencies.ts
@@ -12,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 = utils.getLernaPackages(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/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index 81b2f414b..431e848ca 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -4,35 +4,33 @@ import semver = require('semver');
import semverSort = require('semver-sort');
import { constants } from './constants';
-import { LernaPackage } from './types';
+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];
@@ -50,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
@@ -85,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);
@@ -106,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 94b67eab3..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 { LernaPackage, 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 34d065c58..668d4ef1d 100644
--- a/packages/monorepo-scripts/src/test_installation.ts
+++ b/packages/monorepo-scripts/src/test_installation.ts
@@ -10,17 +10,14 @@ import { utils } from './utils/utils';
(async () => {
const monorepoRootPath = path.join(__dirname, '../../..');
- const lernaPackages = utils.getLernaPackages(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 052a38d1f..9f991c86c 100644
--- a/packages/monorepo-scripts/src/types.ts
+++ b/packages/monorepo-scripts/src/types.ts
@@ -41,9 +41,9 @@ export interface GitTagsByPackageName {
[packageName: string]: string[];
}
-export interface LernaPackage {
+export interface Package {
location: string;
- package: {
+ packageJson: {
private?: boolean;
version: string;
name: string;
diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts
index 78bac1e4e..f04b9b671 100644
--- a/packages/monorepo-scripts/src/utils/utils.ts
+++ b/packages/monorepo-scripts/src/utils/utils.ts
@@ -4,7 +4,7 @@ import { exec as execAsync } from 'promisify-child-process';
import semver = require('semver');
import { constants } from '../constants';
-import { GitTagsByPackageName, LernaPackage, UpdatedPackage } from '../types';
+import { GitTagsByPackageName, Package, UpdatedPackage } from '../types';
import { changelogUtils } from './changelog_utils';
@@ -12,13 +12,13 @@ export const utils = {
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
- getLernaPackages(rootDir: string): 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 lernaPackages = [];
+ const packages = [];
for (const workspace of rootPackageJson.workspaces) {
const workspacePath = workspace.replace('*', '');
const subpackageNames = fs.readdirSync(`${rootDir}/${workspacePath}`);
@@ -30,27 +30,27 @@ export const utils = {
try {
const packageJsonString = fs.readFileSync(`${pathToPackageJson}/package.json`, 'utf8');
const packageJson = JSON.parse(packageJsonString);
- const lernaPackage = {
+ const pkg = {
location: pathToPackageJson,
- package: packageJson,
+ packageJson,
};
- lernaPackages.push(lernaPackage);
+ packages.push(pkg);
} catch (err) {
utils.log(`Couldn't find a 'package.json' for ${subpackageName}. Skipping...`);
}
}
}
- return lernaPackages;
+ return packages;
},
- async getUpdatedLernaPackagesAsync(shouldIncludePrivate: boolean): Promise<LernaPackage[]> {
+ async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> {
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
- const allLernaPackages = utils.getLernaPackages(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`, {