Replace lerna-get-packages with our own implementation
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import * as depcheckAsync from 'depcheck';
|
import * as depcheckAsync from 'depcheck';
|
||||||
import lernaGetPackages = require('lerna-get-packages');
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { constants } from './constants';
|
import { constants } from './constants';
|
||||||
@@ -13,7 +12,7 @@ const IGNORE_PACKAGES = ['@0xproject/sol-compiler'];
|
|||||||
(async () => {
|
(async () => {
|
||||||
utils.log('*** NOTE: Not all deps listed here are actually not required. ***');
|
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");
|
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) {
|
for (const lernaPackage of lernaPackages) {
|
||||||
if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
|
if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
|
||||||
continue; // skip
|
continue; // skip
|
||||||
|
20
packages/monorepo-scripts/src/globals.d.ts
vendored
20
packages/monorepo-scripts/src/globals.d.ts
vendored
@@ -13,23 +13,5 @@ declare module 'semver-sort' {
|
|||||||
const desc: (versions: string[]) => string[];
|
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 'promisify-child-process';
|
||||||
|
declare module '@lerna/project';
|
||||||
|
@@ -4,6 +4,7 @@ import semver = require('semver');
|
|||||||
import semverSort = require('semver-sort');
|
import semverSort = require('semver-sort');
|
||||||
|
|
||||||
import { constants } from './constants';
|
import { constants } from './constants';
|
||||||
|
import { LernaPackage } from './types';
|
||||||
import { changelogUtils } from './utils/changelog_utils';
|
import { changelogUtils } from './utils/changelog_utils';
|
||||||
import { npmUtils } from './utils/npm_utils';
|
import { npmUtils } from './utils/npm_utils';
|
||||||
import { utils } from './utils/utils';
|
import { utils } from './utils/utils';
|
||||||
|
@@ -11,7 +11,7 @@ import semverDiff = require('semver-diff');
|
|||||||
import semverSort = require('semver-sort');
|
import semverSort = require('semver-sort');
|
||||||
|
|
||||||
import { constants } from './constants';
|
import { constants } from './constants';
|
||||||
import { PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
|
import { LernaPackage, PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
|
||||||
import { changelogUtils } from './utils/changelog_utils';
|
import { changelogUtils } from './utils/changelog_utils';
|
||||||
import { utils } from './utils/utils';
|
import { utils } from './utils/utils';
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import lernaGetPackages = require('lerna-get-packages');
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { exec as execAsync } from 'promisify-child-process';
|
import { exec as execAsync } from 'promisify-child-process';
|
||||||
@@ -11,7 +10,7 @@ import { utils } from './utils/utils';
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const monorepoRootPath = path.join(__dirname, '../../..');
|
const monorepoRootPath = path.join(__dirname, '../../..');
|
||||||
const lernaPackages = lernaGetPackages(monorepoRootPath);
|
const lernaPackages = utils.getLernaPackages(monorepoRootPath);
|
||||||
const installablePackages = _.filter(
|
const installablePackages = _.filter(
|
||||||
lernaPackages,
|
lernaPackages,
|
||||||
lernaPackage =>
|
lernaPackage =>
|
||||||
|
@@ -40,3 +40,17 @@ export interface PackageRegistryJson {
|
|||||||
export interface GitTagsByPackageName {
|
export interface GitTagsByPackageName {
|
||||||
[packageName: string]: string[];
|
[packageName: string]: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LernaPackage {
|
||||||
|
location: string;
|
||||||
|
package: {
|
||||||
|
private?: boolean;
|
||||||
|
version: string;
|
||||||
|
name: string;
|
||||||
|
main?: string;
|
||||||
|
scripts?: { [command: string]: string };
|
||||||
|
config?: {
|
||||||
|
additionalTsTypings?: string[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import lernaGetPackages = require('lerna-get-packages');
|
import * as fs from 'fs';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { exec as execAsync } from 'promisify-child-process';
|
import { exec as execAsync } from 'promisify-child-process';
|
||||||
import semver = require('semver');
|
import semver = require('semver');
|
||||||
|
|
||||||
import { constants } from '../constants';
|
import { constants } from '../constants';
|
||||||
import { GitTagsByPackageName, UpdatedPackage } from '../types';
|
import { GitTagsByPackageName, LernaPackage, UpdatedPackage } from '../types';
|
||||||
|
|
||||||
import { changelogUtils } from './changelog_utils';
|
import { changelogUtils } from './changelog_utils';
|
||||||
|
|
||||||
@@ -12,11 +12,41 @@ export const utils = {
|
|||||||
log(...args: any[]): void {
|
log(...args: any[]): void {
|
||||||
console.log(...args); // tslint:disable-line:no-console
|
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[]> {
|
async getUpdatedLernaPackagesAsync(shouldIncludePrivate: boolean): Promise<LernaPackage[]> {
|
||||||
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
|
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
|
||||||
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
|
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
|
||||||
|
|
||||||
const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
|
const allLernaPackages = utils.getLernaPackages(constants.monorepoRootPath);
|
||||||
const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
|
const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
|
||||||
return _.includes(updatedPackageNames, pkg.package.name);
|
return _.includes(updatedPackageNames, pkg.package.name);
|
||||||
});
|
});
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
35
yarn.lock
35
yarn.lock
@@ -534,13 +534,27 @@
|
|||||||
npm-package-arg "^6.0.0"
|
npm-package-arg "^6.0.0"
|
||||||
semver "^5.5.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"
|
version "3.0.0-beta.17"
|
||||||
resolved "https://registry.yarnpkg.com/@lerna/package/-/package-3.0.0-beta.17.tgz#ccc833926ddfce5cac6194d2e6b415899a8e753e"
|
resolved "https://registry.yarnpkg.com/@lerna/package/-/package-3.0.0-beta.17.tgz#ccc833926ddfce5cac6194d2e6b415899a8e753e"
|
||||||
dependencies:
|
dependencies:
|
||||||
npm-package-arg "^6.0.0"
|
npm-package-arg "^6.0.0"
|
||||||
write-pkg "^3.1.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":
|
"@lerna/project@^3.0.0-beta.20":
|
||||||
version "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"
|
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"
|
object-assign "^4"
|
||||||
vary "^1"
|
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:
|
cosmiconfig@^5.0.2:
|
||||||
version "5.0.5"
|
version "5.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.5.tgz#a809e3c2306891ce17ab70359dc8bdf661fe2cd0"
|
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"
|
utf8 "^2.1.1"
|
||||||
uuid "^2.0.1"
|
uuid "^2.0.1"
|
||||||
|
|
||||||
ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22:
|
ethers@3.0.22:
|
||||||
version "3.0.18"
|
version "3.0.22"
|
||||||
resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447"
|
resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436"
|
||||||
dependencies:
|
dependencies:
|
||||||
aes-js "3.0.0"
|
aes-js "3.0.0"
|
||||||
bn.js "^4.4.0"
|
bn.js "^4.4.0"
|
||||||
@@ -7542,10 +7565,6 @@ lead@^1.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flush-write-stream "^1.0.2"
|
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:
|
lerna@3.0.0-beta.14:
|
||||||
version "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"
|
resolved "https://registry.yarnpkg.com/lerna/-/lerna-3.0.0-beta.14.tgz#1ebada4f95fa5ae828caf88f3da80b888d43f1bc"
|
||||||
|
Reference in New Issue
Block a user