-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add 'changedSince' option #80
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
88de296
Remove unneeded variable from the Prefixer class.
ivasilov d1f1ad3
Add jest-changed-files package.
ivasilov 8d484f6
Remove duplicate setup for prettier.
ivasilov 6805da4
Add new option called changedSince. Add implementation for it.
ivasilov f0c710b
Update the help for the new command.
ivasilov 4275aca
Separate the changedSince functionality in a separate function.
ivasilov 3cb54ab
The filter function has been separated in a separate file. Added test…
ivasilov 5230ab8
Added documentation for changedSince.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { filterChangedPackages } from './filter-changed-packages' | ||
|
|
||
| describe('filterChangedPackages', () => { | ||
| it('should filter only the right package', async () => { | ||
| const res = filterChangedPackages( | ||
| ['packages/a/e.ts', 'packages/c/e.ts'], | ||
| { a: 'a', b: 'b' }, | ||
| 'packages' | ||
| ) | ||
|
|
||
| expect(res).toEqual(['a']) | ||
| }) | ||
|
|
||
| it('should filter out all packages if no package match is found', async () => { | ||
| const res = filterChangedPackages(['packages2/c/example.ts'], { a: 'a', b: 'b' }, 'packages2') | ||
|
|
||
| expect(res).toEqual([]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { Dict } from './workspace' | ||
| import * as path from 'path' | ||
|
|
||
| /** | ||
| * filter the packages by checking if they have any changed files. This way is quicker | ||
| * (mapping over packages) because package count is usually lower than changed files count | ||
| * and we only need to check once per package. | ||
| */ | ||
| export const filterChangedPackages = ( | ||
| files: string[], | ||
| pkgPaths: Dict<string>, | ||
| workspacePath: string | ||
| ) => { | ||
| return Object.keys(pkgPaths).filter(pkg => { | ||
| const pkgPath = pkgPaths[pkg] | ||
| const p = path.join(workspacePath, pkgPath) | ||
|
|
||
| return files.some(f => f.startsWith(p)) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,15 @@ | |
| esutils "^2.0.2" | ||
| js-tokens "^4.0.0" | ||
|
|
||
| "@jest/types@^24.9.0": | ||
| version "24.9.0" | ||
| resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.9.0.tgz#63cb26cb7500d069e5a389441a7c6ab5e909fc59" | ||
| integrity sha512-XKK7ze1apu5JWQ5eZjHITP66AX+QsLlbaJRBGYr8pNzwcAE2JVkwnf0yqjHTsDRcjR0mujy/NmZMXw5kl+kGBw== | ||
| dependencies: | ||
| "@types/istanbul-lib-coverage" "^2.0.0" | ||
| "@types/istanbul-reports" "^1.1.1" | ||
| "@types/yargs" "^13.0.0" | ||
|
|
||
| "@nodelib/[email protected]": | ||
| version "2.1.1" | ||
| resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.1.tgz#7fa8fed654939e1a39753d286b48b4836d00e0eb" | ||
|
|
@@ -190,6 +199,26 @@ | |
| "@types/minimatch" "*" | ||
| "@types/node" "*" | ||
|
|
||
| "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": | ||
| version "2.0.1" | ||
| resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff" | ||
| integrity sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg== | ||
|
|
||
| "@types/istanbul-lib-report@*": | ||
| version "1.1.1" | ||
| resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-1.1.1.tgz#e5471e7fa33c61358dd38426189c037a58433b8c" | ||
| integrity sha512-3BUTyMzbZa2DtDI2BkERNC6jJw2Mr2Y0oGI7mRxYNBPxppbtEK1F66u3bKwU2g+wxwWI7PAoRpJnOY1grJqzHg== | ||
| dependencies: | ||
| "@types/istanbul-lib-coverage" "*" | ||
|
|
||
| "@types/istanbul-reports@^1.1.1": | ||
| version "1.1.1" | ||
| resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz#7a8cbf6a406f36c8add871625b278eaf0b0d255a" | ||
| integrity sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA== | ||
| dependencies: | ||
| "@types/istanbul-lib-coverage" "*" | ||
| "@types/istanbul-lib-report" "*" | ||
|
|
||
| "@types/jest@^21.1.6": | ||
| version "21.1.10" | ||
| resolved "https://registry.yarnpkg.com/@types/jest/-/jest-21.1.10.tgz#dcacb5217ddf997a090cc822bba219b4b2fd7984" | ||
|
|
@@ -254,11 +283,23 @@ | |
| dependencies: | ||
| "@types/node" "*" | ||
|
|
||
| "@types/yargs-parser@*": | ||
| version "13.1.0" | ||
| resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-13.1.0.tgz#c563aa192f39350a1d18da36c5a8da382bbd8228" | ||
| integrity sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg== | ||
|
|
||
| "@types/yargs@^11.1.3": | ||
| version "11.1.3" | ||
| resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-11.1.3.tgz#33c8ebf05f78f1edeb249c1cde1a42ae57f5664e" | ||
| integrity sha512-moBUF6X8JsK5MbLZGP3vCfG/TVHZHsaePj3EimlLKp8+ESUjGjpXalxyn90a2L9fTM2ZGtW4swb6Am1DvVRNGA== | ||
|
|
||
| "@types/yargs@^13.0.0": | ||
| version "13.0.3" | ||
| resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-13.0.3.tgz#76482af3981d4412d65371a318f992d33464a380" | ||
| integrity sha512-K8/LfZq2duW33XW/tFwEAfnZlqIfVsoyRB3kfXdPXYhl0nfM8mmh7GS0jg7WrX2Dgq/0Ha/pR1PaR+BvmWwjiQ== | ||
| dependencies: | ||
| "@types/yargs-parser" "*" | ||
|
|
||
| JSONStream@^1.0.4, JSONStream@^1.3.4, JSONStream@^1.3.5: | ||
| version "1.3.5" | ||
| resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" | ||
|
|
@@ -3106,6 +3147,15 @@ jest-changed-files@^23.4.2: | |
| dependencies: | ||
| throat "^4.0.0" | ||
|
|
||
| jest-changed-files@^24.9.0: | ||
| version "24.9.0" | ||
| resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-24.9.0.tgz#08d8c15eb79a7fa3fc98269bc14b451ee82f8039" | ||
| integrity sha512-6aTWpe2mHF0DhL28WjdkO8LyGjs3zItPET4bMSeXU6T3ub4FPMw+mcOcbdGXQOAfmLcxofD23/5Bl9Z4AkFwqg== | ||
| dependencies: | ||
| "@jest/types" "^24.9.0" | ||
| execa "^1.0.0" | ||
| throat "^4.0.0" | ||
|
|
||
| jest-cli@^23.6.0: | ||
| version "23.6.0" | ||
| resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-23.6.0.tgz#61ab917744338f443ef2baa282ddffdd658a5da4" | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Is the return type Promise<PkgJson[]> ?
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.
No. The
expandGlobsfunction returnsPromise<string[]>(in master) so the new functionfilterChangedPackageshas the same signature.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.
ah since it
.mapsp => p.namefirst. got it.