-
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.
Add support for tagging private packages when their version changes (#…
…662) * Tag private packages when their version changes * Fixed formatting * Export tagExists function * Implement config option to opt into the private packages versioning feature * Added doco on tracking private packages * Fixed tests compilation * Filter package list based on tracking private packages config Fixes #620 * Fixed lint issue * Fixed tests * Update docs again * Remove requirement of being logged into NPM if there are no unpublished packages When only publishing private packages (apps?) we shouldn't need users to be logged into NPM * Update .changeset/khaki-kangaroos-tie.md Co-authored-by: Mateusz Burzyński <[email protected]> * Update packages/config/src/index.ts Co-authored-by: Mateusz Burzyński <[email protected]> * Update packages/git/src/index.test.ts Co-authored-by: Mateusz Burzyński <[email protected]> * Use remote tag check instead of local * Updated config to work against a privatePackages flag Allows opting into tagging private package versions & also opting out of versioning private packages entirely * Fixed lint error * Fixed tests * Fixed linting errors * Update packages/cli/src/commands/publish/publishPackages.ts Co-authored-by: Mateusz Burzyński <[email protected]> * Update packages/cli/src/commands/add/createChangeset.ts Co-authored-by: Mateusz Burzyński <[email protected]> * Fixed duplication of logic when filtering listable packages * Removed flags enum and simplified config * Added cwd to tagExists and fixed tests * Hoist tagging private packages out of publish package * Addressed feedback * Fix linting issues after rebase * Fixed up issues around config * Fixed some minor config issues * Expanded scope of privatePackages changesets to include config and types packages * tweak changesets Co-authored-by: Mateusz Burzyński <[email protected]>
- Loading branch information
1 parent
98d63e0
commit 8c08469
Showing
20 changed files
with
294 additions
and
49 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,9 @@ | ||
--- | ||
"@changesets/cli": minor | ||
--- | ||
|
||
Private packages can now be tagged in the same way public packages do when they are published to npm. | ||
|
||
To enable set `privatePackages: { version: true, tag: true }` in your config.json. | ||
|
||
You can also now opt private packages out of versioning entirely by setting `privatePackages: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@changesets/git": minor | ||
--- | ||
|
||
Add `tagExists` & `remoteTagExists` git helpers |
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,6 @@ | ||
--- | ||
"@changesets/config": minor | ||
"@changesets/types": minor | ||
--- | ||
|
||
Added support for the `privatePackages` property in the config. |
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,22 @@ | ||
# Managing applications or non-npm packages | ||
|
||
Changesets can also be used to manage application versions or non-npm packages (ie dotnet NuGet packages, ruby gems, docker images etc). | ||
|
||
The only requirement is that the project has a package.json file to manage the versions and dependencies within the repo. | ||
|
||
To enable this feature set `privatePackages` to `{ version: true, tag: true }` in your `.changesets/config.json` file. By default changesets will only update the changelog and version (ie `{ version: true, tag: false }`). | ||
|
||
> **Note** | ||
> Changesets only versions NPM package.json files, you can trigger releases for other package formats by creating workflows which trigger on tags/releases being created by changesets. | ||
## Setting up a package | ||
|
||
To enable a project to be tracked by changesets, it needs a minimal package.json with at least `name`, `private` and `version`. | ||
|
||
```json | ||
{ | ||
"name": "my-project", | ||
"private": true, | ||
"version": "0.0.1" | ||
} | ||
``` |
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
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,17 @@ | ||
import { Config } from "@changesets/types"; | ||
import { PackageJSON } from "@changesets/types"; | ||
|
||
export function isListablePackage(config: Config, packageJson: PackageJSON) { | ||
const packageIgnoredInConfig = config.ignore.includes(packageJson.name); | ||
|
||
if (packageIgnoredInConfig) { | ||
return false; | ||
} | ||
|
||
if (!config.privatePackages && packageJson.private) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Andarist
Author
Member
|
||
return false; | ||
} | ||
|
||
const hasVersionField = !!packageJson.version; | ||
return hasVersionField; | ||
} |
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
38 changes: 38 additions & 0 deletions
38
packages/cli/src/commands/publish/getUntaggedPrivatePackages.ts
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,38 @@ | ||
import * as git from "@changesets/git"; | ||
import { Package, Tool } from "@manypkg/get-packages"; | ||
import { PublishedResult } from "./publishPackages"; | ||
|
||
export async function getUntaggedPrivatePackages( | ||
privatePackages: Package[], | ||
cwd: string, | ||
tool: Tool | ||
) { | ||
const packageWithTags = await Promise.all( | ||
privatePackages.map(async (privatePkg) => { | ||
const tagName = | ||
tool === "root" | ||
? `v${privatePkg.packageJson.version}` | ||
: `${privatePkg.packageJson.name}@${privatePkg.packageJson.version}`; | ||
const isMissingTag = !( | ||
(await git.tagExists(tagName, cwd)) || | ||
(await git.remoteTagExists(tagName)) | ||
); | ||
|
||
return { pkg: privatePkg, isMissingTag }; | ||
}) | ||
); | ||
|
||
const untagged: PublishedResult[] = []; | ||
|
||
for (const packageWithTag of packageWithTags) { | ||
if (packageWithTag.isMissingTag) { | ||
untagged.push({ | ||
name: packageWithTag.pkg.packageJson.name, | ||
newVersion: packageWithTag.pkg.packageJson.version, | ||
published: false, | ||
}); | ||
} | ||
} | ||
|
||
return untagged; | ||
} |
Oops, something went wrong.
is something wrong? or i misunderstand