aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-24 22:07:11 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-24 22:07:11 +0800
commitd1e33a3dff3f62b7c84fd5b5d1307572853beeee (patch)
treefc1fa964f1ec82a17c5f69d3cd60a7e45e177655 /packages
parentf50ac932d6de28b3474ef8023813835badff4b09 (diff)
downloaddexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar.gz
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar.bz2
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar.lz
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar.xz
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.tar.zst
dexon-sol-tools-d1e33a3dff3f62b7c84fd5b5d1307572853beeee.zip
Add utils.getTopologicallySortedPackages
Diffstat (limited to 'packages')
-rw-r--r--packages/monorepo-scripts/src/utils/utils.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts
index 8ba59c81d..d9bae3ea9 100644
--- a/packages/monorepo-scripts/src/utils/utils.ts
+++ b/packages/monorepo-scripts/src/utils/utils.ts
@@ -1,10 +1,11 @@
+import batchPackages = require('@lerna/batch-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, Package, UpdatedPackage } from '../types';
+import { GitTagsByPackageName, Package, PackageJSON, UpdatedPackage } from '../types';
import { changelogUtils } from './changelog_utils';
@@ -12,6 +13,15 @@ export const utils = {
log(...args: any[]): void {
console.log(...args); // tslint:disable-line:no-console
},
+ getTopologicallySortedPackages(rootDir: string): Package[] {
+ const packages = utils.getPackages(rootDir);
+ const batchedPackages: PackageJSON[] = _.flatten(batchPackages(_.map(packages, pkg => pkg.packageJson), false));
+ const topsortedPackages: Package[] = _.map(
+ batchedPackages,
+ (pkg: PackageJSON) => _.find(packages, pkg1 => pkg1.packageJson.name === pkg.name) as Package,
+ );
+ return topsortedPackages;
+ },
getPackages(rootDir: string): Package[] {
const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8');
const rootPackageJson = JSON.parse(rootPackageJsonString);