Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

fix(scripts): Update release scripts for newest lerna version #259

Merged
merged 1 commit into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions scripts/determine-pkg-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,10 @@ const commitMatches = childProcess
const componentPkgs = updatedPkgs.filter(({name}) => name.indexOf('@material') === 0);
const mdcPkg = updatedPkgs.find(({name}) => name === 'material-components-web');
const newPkgVersions = collectNewPkgVersions(componentPkgs, commitMatches);
const newMDCVersion = {
const newMDCVersion = Object.assign(collectMDCVersion(mdcPkg, newPkgVersions), {
name: 'material-components-web',
version: collectMDCVersion(mdcPkg, newPkgVersions),
changeType: 'N/A',
causedByCommit: 'N/A',
};
});

const allPkgVersions = [newMDCVersion].concat(newPkgVersions);
writeSummaryToScreen(allPkgVersions);
Expand Down Expand Up @@ -125,8 +123,8 @@ function determineVersion(pkg, commitInfos) {

return commitInfos.reduce(pickBestVersionInfo(pkg), {
version: currentVersion,
changeType: '',
causedByCommit: '',
changeType: 'patch',
causedByCommit: '(dependency update - part of packages to be updated but no explicit commits referencing it)',
});
}

Expand Down Expand Up @@ -175,10 +173,13 @@ function collectMDCVersion(mdcPkg, newPkgVersions) {
[VersionType.MINOR]: 1,
[VersionType.MAJOR]: 2,
};
const overallChangeType = [...changeTypes]
.sort((ct1, ct2) => versionRanks[ct1] - versionRanks[ct2])
.pop();
return semver.inc(currentVersion, overallChangeType) || '(no update needed)';
const overallChangeTypes = [...changeTypes]
.sort((ct1, ct2) => versionRanks[ct1] - versionRanks[ct2]);
const overallChangeType = overallChangeTypes.pop();
return {
version: semver.inc(currentVersion, overallChangeType) || '(no update needed)',
changeType: overallChangeType,
};
}

function writeSummary(pkgVersions, performWrite) {
Expand Down
18 changes: 8 additions & 10 deletions scripts/lib/get-updated-pkgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@
* for exposing a public API at https://github.com/lerna/lerna/issues/167.
*/

const path = require('path');

const PackageUtilities = require('lerna/lib/PackageUtilities');
const Repository = require('lerna/lib/Repository');
const UpdatedPackagesCollector = require('lerna/lib/UpdatedPackagesCollector');
const lernaLogger = require('lerna/lib/logger');
const progressBar = require('lerna/lib/progressBar');

const PKGS_PATH = path.resolve(__dirname, '../../packages');

module.exports = function() {
const packages = PackageUtilities.getPackages(PKGS_PATH);
const packageGraph = PackageUtilities.getPackageGraph(packages);
const repository = new Repository();
const origInfoFn = lernaLogger.info;
const origBarDescriptor = Object.getOwnPropertyDescriptor(progressBar, 'bar');
const collector = new UpdatedPackagesCollector(
packages, packageGraph, {} /* flags (unused) */, {} /* publishConfig (unused) */);
const lernaCommand = {
repository,
getOptions: () => ({}),
publishConfig: {},
};
const collector = new UpdatedPackagesCollector(lernaCommand);

lernaLogger.info = () => {};
Object.defineProperty(progressBar, 'bar', {
Expand All @@ -45,7 +44,6 @@ module.exports = function() {
enumerable: true,
configurable: true,
});

const updates = collector.getUpdates();

Object.defineProperty(progressBar, 'bar', origBarDescriptor);
Expand Down