-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed
changeset status
combined with ignored and non-versionable pr…
…ivate packages (#1354) * Fixed `changeset status` combined with ignored and non-versionable private packages * add tests * extract common bits
- Loading branch information
Showing
6 changed files
with
187 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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,8 @@ | ||
--- | ||
"@changesets/cli": patch | ||
--- | ||
|
||
Fixed an issue with `changeset status` incorrectly returning an error status in two cases: | ||
|
||
- for changed ignored packages | ||
- for changed private packages when `privatePackage.version` was set to `false` |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,48 @@ | ||
import { Config } from "@changesets/types"; | ||
import { getChangedPackagesSinceRef } from "@changesets/git"; | ||
import { Package } from "@manypkg/get-packages"; | ||
|
||
function isVersionablePackage( | ||
{ packageJson }: Package, | ||
{ | ||
ignoredPackages, | ||
versionPrivatePackages, | ||
}: { | ||
ignoredPackages: Set<string>; | ||
versionPrivatePackages: boolean; | ||
} | ||
) { | ||
if (ignoredPackages.has(packageJson.name)) { | ||
return false; | ||
} | ||
|
||
if (packageJson.private && !versionPrivatePackages) { | ||
return false; | ||
} | ||
|
||
const hasVersionField = !!packageJson.version; | ||
return hasVersionField; | ||
} | ||
|
||
export function filterVersionablePackages(config: Config, packages: Package[]) { | ||
const options = { | ||
ignoredPackages: new Set(config.ignore), | ||
versionPrivatePackages: config.privatePackages.version, | ||
}; | ||
return packages.filter((pkg) => isVersionablePackage(pkg, options)); | ||
} | ||
|
||
export async function getVersionableChangedPackages( | ||
config: Config, | ||
options: { | ||
cwd: string; | ||
ref?: string; | ||
} | ||
) { | ||
const changedPackages = await getChangedPackagesSinceRef({ | ||
ref: config.baseBranch, | ||
changedFilePatterns: config.changedFilePatterns, | ||
...options, | ||
}); | ||
return filterVersionablePackages(config, changedPackages); | ||
} |