diff options
Diffstat (limited to 'packages/monorepo-scripts/src/utils')
-rw-r--r-- | packages/monorepo-scripts/src/utils/utils.ts | 24 |
1 files changed, 12 insertions, 12 deletions
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`, { |