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
Add option to include additional packages #8769
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mpowaga - thanks for re-submitting this PR! I've added a few small code comments inline.
One thing I think is missing though are tests for this. I know creating selftest
's for the build tool can be a bit of pain, but in this case it shouldn't be that bad. You can create a test app in tools/tests/apps
, then fire this test app up with the --extra-packages
option set with some package (take a look at the tests in tools/tests/command-line.js
to get an idea of how to do this). Once the app is loaded, you could then just make a call that requires the package to be loaded, and verify the call succeeded.
Everything else looks great - thanks again!
tools/cli/commands.js
Outdated
@@ -289,10 +290,16 @@ function doRunCommand(options) { | |||
const { parsedServerUrl, parsedMobileServerUrl } = | |||
parseServerOptionsForRunCommand(options, runTargets); | |||
|
|||
var includePackages = []; | |||
if (options['extra-packages']) { | |||
includePackages = options['extra-packages'].split(','); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to strip blank spaces after your comma split, to handle your example of "package1, package2" properly. I know you're trimming later on down the chain in your code changes, but it might be useful to just trim right alongside the split. So something like:
includePackages = options['extra-packages'].split(',').map(item => item.trim());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with this, but I think I'd have a strong preference to:
includePackages = options['extra-packages'].trim().split(/\s*,\s*/);
...which I believe would be more performant, though the chances of someone passing too many packages here is slim.
EDITED FOR CORRECTNESS! ;)
tools/cli/help.txt
Outdated
@@ -86,6 +86,7 @@ Options: | |||
downgraded to versions that are potentially incompatible with | |||
the current versions, if required to satisfy all package | |||
version constraints. | |||
--extra-packages Run with additional packages (comma separated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an example here (similar to the --mobile-server
option help):
--extra-packages Run with additional packages (comma separated, for example: --extra-packages "package-name1, package-name2@1.2.3")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides @hwillson's requested changes, we agreed --extra-packages
is a fine name, and there is no need to support this (yet) for meteor build
or meteor deploy
(since that's kind of what the prodOnly
flag is for).
However, we would like this option to work with meteor test ...
and meteor test-packages ...
.
To your final question, yes, I think --extra-packages
should be able to override version constraints from .meteor/packages
.
Thanks for working on this!
Added this option to Extra packages will now override constraints specified in I also created |
@@ -985,7 +1013,7 @@ _.extend(exports.ProjectConstraintsFile.prototype, { | |||
eachConstraint: function (iterator) { | |||
var self = this; | |||
_.each(self._constraintLines, function (lineRecord) { | |||
if (lineRecord.constraint) | |||
if (! lineRecord.skipOnRead && lineRecord.constraint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If eachConstraint
ignores extra-packages
maybe this needs to happen in getConstraint
and the other functions too? So should this really be skipping in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eachConstraint
iterates through self._constraintLines
which may contain duplicate packages. This is because it needs to preserve all constraints from .meteor/packages
(so this file can be later reproduced by _write
method) as well as self._includePackages
.
On the contrary, getConstraint
reads from self._constraintMap
which contains unique packages.
Maybe there should be separate property for extra constraints instead of pushing them to self._constraintLines
? For example self._extraConstraintLines
. But then eachConstraint
would need iterate through self._extraConstraintLines
and self._constraintLines
and find duplicates along the way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eachConstraint iterates through self._constraintLines which may contain duplicate packages. This is because it needs to preserve all constraints from .meteor/packages (so this file can be later reproduced by _write method) as well as self._includePackages.
On the contrary, getConstraint reads from self._constraintMap which contains unique packages.
Sounds reasonable.
Maybe there should be separate property for extra constraints instead of pushing them to self._constraintLines? For example self._extraConstraintLines. But then eachConstraint would need iterate through self._extraConstraintLines and self._constraintLines and find duplicates along the way.
Feels like that might be overkill but I'm not too familiar with this part of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like that might be overkill but I'm not too familiar with this part of the code.
Yes, that would be unnecessarily complex solution.
Another option would be to iterate over values of self._constraintMap
. But I'm not sure if eachConstraint
must iterate with correct order (first-in, first-out; as defined in .meteor/packages) and if so whether this would be still guaranteed with this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I'm not sure if eachConstraint must iterate with correct order (first-in, first-out; as defined in .meteor/packages)
I'm pretty sure that ordering of the packages in .meteor/packages
matters.
This PR only have changes that affect I'm thinking about meteor/meteor-feature-requests#31, where we're waiting for this PR. ~~It would be nice if we can just look through |
Related to my previous comment. Turns out we might use This actually made be think that the constraint resolver will ignore extra packages if we ignore them in |
|
Ah, I mixed up |
It's related to meteor/meteor-feature-requests#31.
|
Thanks for your work on this @mpowaga - looks like all outstanding requests/suggestions have been addressed (and your @zimme Based on your findings in meteor/meteor-feature-requests#31, do you have any remaining concerns about the changes in this PR? |
@mpowaga Actually, one small nitpick - could you wrap the help text example a little earlier, to keep it under 80 chars wide? Maybe just move everything after |
Right now this PR only adds the extra packages to In meteor/meteor-feature-requests#31 I'm looking through |
How about using |
@hwillson Something like this:
? |
Yes, that formatting looks great - thanks! |
Thanks for the update @zimme - makes sense. Given that (I think) we're really close to merging this PR, maybe we should merge as is (to get the |
I would have no problem adding the extended support for |
Hi all - I've added a |
This is rework of #8735 as discussed in #8739.
Example usage:
meteor run --extra-packages "bundle-visualizer, jquery@1.11.10"
Things to consider:
--with-packages
or other name?meteor build
?.meteor/packages
but with different version constraint should--extra-packages
override it?