Skip to content

Add option to ignore packages when bootstrapping (fixes #117)#168

Merged
hzoo merged 4 commits intolerna:masterfrom
awakesecurity:ignore-bootstrap-packages
Jun 14, 2016
Merged

Add option to ignore packages when bootstrapping (fixes #117)#168
hzoo merged 4 commits intolerna:masterfrom
awakesecurity:ignore-bootstrap-packages

Conversation

@rygine
Copy link
Copy Markdown
Contributor

@rygine rygine commented May 26, 2016

  • Added ignore flag to CLI
  • Check bootstrapConfig.ignore key in lerna.json

The CLI flag will override the bootstrapConfig option in lerna.json. Both the flag and the option accept a glob pattern of package names to ignore.

this is the new PR from my company's github org

@joscha
Copy link
Copy Markdown
Contributor

joscha commented May 27, 2016

I think potentially we could use the --scope parameter introduced in #152 for this as well.

@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented May 27, 2016

@joscha hmm, --scope seems more suited to be a whitelist, where this would be a blacklist. maybe a more general --ignore flag would serve this purpose. i understand that negative matches could be applied to scope, but perhaps it would be confusing as it would not be readily apparent that --scope could be used that way.

edit: for comparison, the babel cli has only and ignore flags.

@joscha
Copy link
Copy Markdown
Contributor

joscha commented May 28, 2016

@rygine you are right, I guess it might be confusing ;)

@jamiebuilds
Copy link
Copy Markdown
Contributor

Sorry about the confusion with flag names, I don't want it to turn into a mess, but haven't really thought about it holistically.

@rygine rygine force-pushed the ignore-bootstrap-packages branch from 3ead3e3 to b4223d2 Compare June 1, 2016 20:12
@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 3, 2016

the more i think about it, the more inclined i am make the flag name more generic. i think ignore would work well here. that way, it could apply to other commands, such as lerna run. the ignore flag would be opposite of the scope flag, unless that's renamed to something else like only. it makes sense to have both of these options when running commands.

i like the way babel-cli has done it.

@joscha
Copy link
Copy Markdown
Contributor

joscha commented Jun 4, 2016

I am happy to work on it to make it work for both black- and whitelisting.
It could be a generic --include and --exclude for example and the last
of the two options given trumps the one before.

Cheers,
Joscha
On 4 Jun 2016 8:10 AM, "Ry Racherbaumer" [email protected] wrote:

the more i think about it, the more inclined i am make the flag name more
generic. i think ignore would work well here. that way, it could apply
to other commands, such as lerna run. the ignore flag would be opposite
of the scope flag, unless that's renamed to something else like only. it
makes sense to have both of these options when running commands.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#168 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AALehsRsbr8sIDrIyj-TEx81QtAD3EhHks5qIKZLgaJpZM4IoCf-
.

@rygine rygine force-pushed the ignore-bootstrap-packages branch 2 times, most recently from 3a235fb to 3b1eed5 Compare June 7, 2016 21:26
@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 7, 2016

@joscha: I've added another commit that renames the flag to exclude as per your suggestion. I think that makes sense. Each command will have to process the flag separately. Once your PR is done, I think I could use your filterPackages utility in place of what I currently have.

@thejameskyle: I remember you saying that you didn't want an ignore option to apply to all commands out of the box. I agree, and with this new generic naming (include and exclude), I think we can move forward and apply the flags to certain commands when it makes sense.

@paulyoung
Copy link
Copy Markdown

This would be really useful. Please let me know if I can help in any way.

@joscha
Copy link
Copy Markdown
Contributor

joscha commented Jun 7, 2016

@rygine @thejameskyle does that mean I should rename the flag in #152 to --include? I am happy to do that if that finally makes it mergeable and integrated.

@hzoo
Copy link
Copy Markdown
Contributor

hzoo commented Jun 8, 2016

this LGTM

@rygine rygine force-pushed the ignore-bootstrap-packages branch 2 times, most recently from a928273 to ae5df47 Compare June 9, 2016 06:20
@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 9, 2016

@hzoo @joscha @thejameskyle i've updated the PR to include usage of PackageUtilities.filterPackages from the latest commit. i had to slightly modify it to allow for negation. perhaps there's a better way of doing this.

i settled on --ignore for the flag, and placed it beneath scope in the CLI help, with a similar message.

the new scope flag could easily be applied to the bootstrap command, and truthfully, i'm going to need it for my current project. the same goes for the ignore flag and other commands.

i can do a PR for adding scope to the bootstrap command after this is merged.

Comment thread src/PackageUtilities.js Outdated
static filterPackages(packages, glob, negate = false) {
if (typeof glob !== "undefined") {
packages = packages.filter(pkg => minimatch(pkg.name, glob));
packages = packages.filter(pkg => negate ? !minimatch(pkg.name, glob) : minimatch(pkg.name, glob));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't that an xor? negate ^ minimatch(pkg.name, glob) should do it I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i knew there was a better way. this works! thanks. amending...

@joscha
Copy link
Copy Markdown
Contributor

joscha commented Jun 9, 2016

@rygine nice! What if you specify both --ignore and --scope? I guess ignore would trump scope?

@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 9, 2016

@joscha i think specifying both should throw an error so that there's no confusion as to what gets precedence.

@rygine rygine force-pushed the ignore-bootstrap-packages branch from ae5df47 to 30f928b Compare June 9, 2016 07:17
Comment thread src/PackageUtilities.js Outdated
static filterPackages(packages, glob, negate = false) {
if (typeof glob !== "undefined") {
packages = packages.filter(pkg => minimatch(pkg.name, glob));
packages = packages.filter(pkg => negate ^ minimatch(pkg.name, glob));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think theres approximately 7 people in the universe that know what the ^ operator does. I'd rather have something longer that expresses what happens better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😂 I think the name of the variable kinda gives the functionality away though...

Copy link
Copy Markdown
Contributor Author

@rygine rygine Jun 9, 2016

Choose a reason for hiding this comment

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

should i go back to the ternary operator i had before?

packages = packages.filter(pkg => negate ? !minimatch(pkg.name, glob) : minimatch(pkg.name, glob));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either that or just a if else

packages.filter(pkg => {
  if (negate) {

  } else {

  }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know what they do and how to read them if I need to, but I also 100% agree that they are unreadable and unclear unless you're actually doing bitwise math.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if minimatch returns a boolean, couldn't ^ simply be replaced with !==? in case the operator is the issue.

@joscha
Copy link
Copy Markdown
Contributor

joscha commented Jun 9, 2016

@rygine fair enough, I guess the use case for such a thing is very slim anyway, as you can always express one through the other or just use a more specific glob.

@hzoo
Copy link
Copy Markdown
Contributor

hzoo commented Jun 9, 2016

👍 Can you add a corresponding readme update?

@rygine rygine force-pushed the ignore-bootstrap-packages branch 2 times, most recently from 0f411f4 to 5cd1b0f Compare June 10, 2016 04:24
@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 10, 2016

@hzoo docs added

@hzoo
Copy link
Copy Markdown
Contributor

hzoo commented Jun 14, 2016

Can you rebase again?

* Added `ignore` flag to CLI
* Check `bootstrapConfig.ignore` key in `lerna.json`

The CLI flag will override the `bootstrapConfig` option in `lerna.json`. Both the flag and the option accept a glob pattern of package names to ignore.
Ry Racherbaumer added 2 commits June 14, 2016 10:58
Used a simple `if` statement rather than a ternary or bitwise XOR operator when filtering packages.
@rygine rygine force-pushed the ignore-bootstrap-packages branch from c3c7b1c to f9664c4 Compare June 14, 2016 17:59
@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 14, 2016

done

@rygine
Copy link
Copy Markdown
Contributor Author

rygine commented Jun 14, 2016

needed to update the stub in the a unit test. should be good now.

@lock
Copy link
Copy Markdown

lock Bot commented Dec 28, 2018

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Dec 28, 2018
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.

7 participants