Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(version): display verions of @angular/* and @ngtools/* #3592

Merged
merged 1 commit into from
Dec 19, 2016

Conversation

Brocco
Copy link
Contributor

@Brocco Brocco commented Dec 16, 2016

Fixes #3589

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting and building are both failing.

@Brocco
Copy link
Contributor Author

Brocco commented Dec 18, 2016

@hansl PR updated to resolve the lint and build issues.

Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments.

@@ -14,12 +14,19 @@ const VersionCommand = Command.extend({
}],

run: function (options: any) {
const versions: any = process.versions;
let versions: any = process.versions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because later on I have this...

versions = Object.assign(versions, this.getModules(projPkg, root));

which disallows the use of const

isRoot = true;
}
});
if (options.verbose || alwaysPrint.indexOf(module) > -1 || isRoot) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRoot could be set to roots.some(root => module.startsWith(root)) and it would be simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, cleaner

},

getVersion: function(moduleName: string): string {
const modulePkg = require(path.resolve(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you at least try locally to nom link angular itself and run ng version? Just wanna make sure that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested locally via npm link for both inside and outside of CLI projects.

}
}
if (pkg.devDependencies) {
for (let key of Object.keys(pkg.devDependencies)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole function could be simplified to:

Object.keys(pkg.dependencies || {})
  .concat(Object.keys(pkg.devDependencies || {}))
  .filter(depName => depName && depName.startsWith(prefix))
  .forEach(depName => modules[key] = this.getVersion(key));

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this as well, updated this function, but had to fix a minor issue with what you have here

this.printVersion(module, versions[module]);
}
}
},

getModules: function(pkg: any, prefix: string): any {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDependencyVersions or getVersionsOfDependencies might be a better name, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like getDependencyVersions and went with that.

@hansl
Copy link
Contributor

hansl commented Dec 19, 2016

LGTM! Thanks!

@hansl hansl merged commit 123f74d into angular:master Dec 19, 2016
@Brocco Brocco deleted the ng-version branch December 19, 2016 20:58
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this pull request Feb 9, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ng version should show more information
3 participants