aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/monorepo-scripts/src/find_unused_dependencies.ts3
-rw-r--r--packages/monorepo-scripts/src/globals.d.ts20
-rw-r--r--packages/monorepo-scripts/src/prepublish_checks.ts1
-rw-r--r--packages/monorepo-scripts/src/publish.ts2
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts3
-rw-r--r--packages/monorepo-scripts/src/types.ts14
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts36
-rw-r--r--packages/typescript-typings/types/lerna-get-packages/index.d.ts16
-rw-r--r--yarn.lock35
9 files changed, 79 insertions, 51 deletions
diff --git a/packages/monorepo-scripts/src/find_unused_dependencies.ts b/packages/monorepo-scripts/src/find_unused_dependencies.ts
index 11e48ab13..1a36aceee 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,7 +12,7 @@ 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);
+ const lernaPackages = utils.getLernaPackages(constants.monorepoRootPath);
for (const lernaPackage of lernaPackages) {
if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
continue; // skip
diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts
index 1693a6dbb..ccdf90d2a 100644
--- a/packages/monorepo-scripts/src/globals.d.ts
+++ b/packages/monorepo-scripts/src/globals.d.ts
@@ -13,23 +13,5 @@ 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';
+declare module '@lerna/project';
diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts
index 3b4ff9082..81b2f414b 100644
--- a/packages/monorepo-scripts/src/prepublish_checks.ts
+++ b/packages/monorepo-scripts/src/prepublish_checks.ts
@@ -4,6 +4,7 @@ import semver = require('semver');
import semverSort = require('semver-sort');
import { constants } from './constants';
+import { LernaPackage } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { npmUtils } from './utils/npm_utils';
import { utils } from './utils/utils';
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts
index 72c6c0a71..94b67eab3 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 { LernaPackage, PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
import { changelogUtils } from './utils/changelog_utils';
import { utils } from './utils/utils';
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts
index b67154667..34d065c58 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,7 +10,7 @@ import { utils } from './utils/utils';
(async () => {
const monorepoRootPath = path.join(__dirname, '../../..');
- const lernaPackages = lernaGetPackages(monorepoRootPath);
+ const lernaPackages = utils.getLernaPackages(monorepoRootPath);
const installablePackages = _.filter(
lernaPackages,
lernaPackage =>
diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts
index 61bd75732..052a38d1f 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 LernaPackage {
+ location: string;
+ package: {
+ 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..78bac1e4e 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, LernaPackage, UpdatedPackage } from '../types';
import { changelogUtils } from './changelog_utils';
@@ -12,11 +12,41 @@ export const utils = {
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
+ getLernaPackages(rootDir: string): LernaPackage[] {
+ 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 = [];
+ for (const workspace of rootPackageJson.workspaces) {
+ const workspacePath = workspace.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 lernaPackage = {
+ location: pathToPackageJson,
+ package: packageJson,
+ };
+ lernaPackages.push(lernaPackage);
+ } catch (err) {
+ utils.log(`Couldn't find a 'package.json' for ${subpackageName}. Skipping...`);
+ }
+ }
+ }
+ return lernaPackages;
+ },
async getUpdatedLernaPackagesAsync(shouldIncludePrivate: boolean): Promise<LernaPackage[]> {
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
- const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
+ const allLernaPackages = utils.getLernaPackages(constants.monorepoRootPath);
const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
return _.includes(updatedPackageNames, pkg.package.name);
});
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;
-}
diff --git a/yarn.lock b/yarn.lock
index 5bbd1c4c0..9c4acc88a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -534,13 +534,27 @@
npm-package-arg "^6.0.0"
semver "^5.5.0"
-"@lerna/package@^3.0.0-beta.17":
+"@lerna/package@^3.0.0-beta.12", "@lerna/package@^3.0.0-beta.17":
version "3.0.0-beta.17"
resolved "https://registry.yarnpkg.com/@lerna/package/-/package-3.0.0-beta.17.tgz#ccc833926ddfce5cac6194d2e6b415899a8e753e"
dependencies:
npm-package-arg "^6.0.0"
write-pkg "^3.1.0"
+"@lerna/project@^3.0.0-beta.12":
+ version "3.0.0-beta.12"
+ resolved "https://registry.yarnpkg.com/@lerna/project/-/project-3.0.0-beta.12.tgz#38a5160fe6b42407092a70c2dc96e4ba941fc3b7"
+ dependencies:
+ "@lerna/package" "^3.0.0-beta.12"
+ "@lerna/validation-error" "^3.0.0-beta.10"
+ cosmiconfig "^4.0.0"
+ dedent "^0.7.0"
+ glob-parent "^3.1.0"
+ load-json-file "^4.0.0"
+ npmlog "^4.1.2"
+ resolve-from "^4.0.0"
+ write-json-file "^2.3.0"
+
"@lerna/project@^3.0.0-beta.20":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@lerna/project/-/project-3.0.0-beta.20.tgz#27a0330b7b13d8eebe9266f03eb60de94b15c86d"
@@ -3515,6 +3529,15 @@ cors@^2.8.1:
object-assign "^4"
vary "^1"
+cosmiconfig@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc"
+ dependencies:
+ is-directory "^0.3.1"
+ js-yaml "^3.9.0"
+ parse-json "^4.0.0"
+ require-from-string "^2.0.1"
+
cosmiconfig@^5.0.2:
version "5.0.5"
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.5.tgz#a809e3c2306891ce17ab70359dc8bdf661fe2cd0"
@@ -4926,9 +4949,9 @@ ethereumjs-wallet@~0.6.0:
utf8 "^2.1.1"
uuid "^2.0.1"
-ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22:
- version "3.0.18"
- resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
+ethers@3.0.22:
+ version "3.0.22"
+ resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436"
dependencies:
aes-js "3.0.0"
bn.js "^4.4.0"
@@ -7542,10 +7565,6 @@ lead@^1.0.0:
dependencies:
flush-write-stream "^1.0.2"
-lerna-get-packages@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/lerna-get-packages/-/lerna-get-packages-1.0.0.tgz#60fa309a71cf2e34eec63224368de2fe8f61ba65"
-
lerna@3.0.0-beta.14:
version "3.0.0-beta.14"
resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.0.0-beta.14.tgz#1ebada4f95fa5ae828caf88f3da80b888d43f1bc"