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 --only-updated option to exec and run subcommands #726
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.
This needs unit tests to validate.
I've got some easier-to-grok unit tests coming in #714.
src/Command.js
Outdated
@@ -182,6 +183,13 @@ export default class Command { | |||
if (this.getOptions().includeFilteredDependencies) { | |||
this.filteredPackages = PackageUtilities.addDependencies(this.filteredPackages, this.packageGraph); | |||
} | |||
if (this.flags.onlyUpdated) { |
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.
This belongs in ExecCommand and RunCommand, not the base class, yes?
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.
Looks like it'll also work for clean
, ls
and bootstrap
however I can move the logic to a utility fn and call it separately in exec
and run
if you prefer.
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.
Well, consider that those other commands really have no use for this flag, and might even be considered broken if they were to adhere to it. I would recommend a separate shared file to encapsulate, yes.
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.
😎 will refactor
src/PackageUtilities.js
Outdated
@@ -138,6 +139,14 @@ export default class PackageUtilities { | |||
return packages; | |||
} | |||
|
|||
static filterPackagesThatAreNotUpdated(packagesToFilter, command) { |
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.
Taking the whole command
here feels a bit gross, but couldn't think of an alternative.
@evocateur I've thrown together some tests and moved the code into the specific commands (meaning there's now some duplication). Let me know if you'd like me to change anything else. |
src/commands/ExecCommand.js
Outdated
export const builder = {}; | ||
export const builder = { | ||
"only-updated": { | ||
"describe": "When exectuting scripts/commands, only run the script/command on packages which " |
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.
exectuting
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.
src/commands/RunCommand.js
Outdated
@@ -13,6 +13,10 @@ export const describe = "Run an npm script in each package that contains that sc | |||
export const builder = { | |||
"stream": { | |||
describe: "Stream output with lines prefixed by package." | |||
}, | |||
"only-updated": { | |||
"describe": "When exectuting scripts/commands, only run the script/command on packages which " |
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.
exectuting
README.md
Outdated
@@ -654,6 +654,18 @@ $ lerna bootstrap --scope "package-*" --ignore "package-util-*" --include-filter | |||
# package matched by "package-*" | |||
``` | |||
|
|||
#### --only-updated | |||
|
|||
When exectuting a script or command, only run the script or command on packages that have been updated since the last release. |
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.
exectuting
README.md
Outdated
@@ -654,6 +654,18 @@ $ lerna bootstrap --scope "package-*" --ignore "package-util-*" --include-filter | |||
# package matched by "package-*" | |||
``` | |||
|
|||
#### --only-updated | |||
|
|||
When exectuting a script or command, only run the script or command on packages that have been updated since the last release. |
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.
It'd be nice to clarify the semantics of what updated
means. Perhaps just add to this sentence:
A package is considered "updated" using the same rules as
lerna updated
.
@evocateur The tests are all passing but npm is getting an exit status of 0 on node v4 without any visible error. How can I re-run the tests or debug what's going wrong? |
`nvm use 4 && yarn ci`
… On Apr 26, 2017, at 17:57, James Newell ***@***.***> wrote:
@evocateur The tests are all passing but npm is getting an exit status of 0 on node v4 without any visible error. How can I re-run the tests or debug the issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
test/PackageUtilities.js
Outdated
expect(updatedPackages).toHaveLength(0); | ||
}); | ||
|
||
it.only("should return only packages that are to be filtered and have been updated", () => { |
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.
we should definitely break lint when something like it.only
is committed...
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.
😱
The failures in node v4 appear to be in the
Edit: @evocateur I get those same errors on master in node v4 |
hey @evocateur anything I can do to get this merged? |
@jameslnewell Thanks for your patience! |
Is this still in the project? Don't see this in the README anymore and it is just what I am looking for! |
Should be achievable with `--since`
… On May 31, 2018, at 04:05, Ben Flowers ***@***.***> wrote:
Is this still in the project? Don't see this in the README anymore and it is just what I am looking for!
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
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. |
Description
I have added a new flag that only
run
s/exec
s packages that have been updated.Works with
scope
so that only packages that match thescope
AND that have been updated will berun
/exec
.Motivation and Context
I have a situation where package B depends on package A. I've made a breaking change to package A and want to release package A, but I don't want/have-time to update package B to work with these changes yet. When
lerna run typescript
runs on package B, it will fail because the version of package A hasn't been bumped yet and lerna is symlinking the latest package A to package B.lerna run --only-updated typescript
will allow me to publish package A, re-runlerna bootstrap
to install the previous version of package A in package B (instead of a symlink) and enable me to continue developing package B independently of package A.How Has This Been Tested?
Minimal manual tests checking the
run
andexec
commands, with and without thescope
flag.e.g.
Types of changes
Checklist:
filteredPackages
- will happily add some with guidance)