Skip to content
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

📝 git branch lockfiles #455

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ exports.isCI = !!(

[CI environments]: https://github.com/watson/ci-info#supported-ci-tools

### --merge-git-branch-lockfiles

Merge all git branch lockfiles.
[Read more about git branch lockfiles.](../git_branch_lockfiles)


### --reporter=<name\>

* Default:
Expand Down
54 changes: 54 additions & 0 deletions docs/git_branch_lockfiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
id: git_branch_lockfiles
title: Git Branch Lockfiles
---

Git branch lockfiles allows you to totally avoid lockfile merge conflicts and solve it later.

## Use git branch lockfiles

You can turn on this feature by configuring the `.npmrc` file.

```ini
git-branch-lockfiles=true
```

By doing this, lockfile name will be generated based on the current branch name.

For instance, the current branch name is `feature-1`. Then, the generated lockfile name will
be `pnpm-lock.feature-1.yaml`. You can commit it to the Git, and merge all git branch lockfiles later.

```
- <project_folder>
|- pnpm-lock.yaml
|- pnpm-lock.feature-1.yaml
|- pnpm-lock.<branch_name>.yaml
```

:::note

`feature/1` is special in that the `/` is automatically converted to `!`, so the corresponding
lockfile name would be `pnpm-lock.feature!1.yaml`.

:::

## Merge git branch lockfiles

### `pnpm install --merge-git-branch-lockfiles`

To merge all git branch lockfiles, just specify `--merge-git-branch-lockfiles` to `pnpm install` command.

After that, all git branch lockfiles will be merged into one `pnpm-lock.yaml`


### Branch Matching

pnpm allows you to specify `--merge-git-branch-lockfiles` by matching the current branch name.

For instance, by the following setting in `.npmrc` file, `pnpm install` will merge all git branch lockfiles when
running in the `main` branch and the branch name starts with `release`.

```ini
merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*
```
31 changes: 31 additions & 0 deletions docs/npmrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,37 @@ modify the lockfile.

Add the full URL to the package's tarball to every entry in `pnpm-lock.yaml`.

### git-branch-lockfile

* Default: **false**
* Type: **Boolean**

When set to `true`, the generated lockfile name after installation will be named
based on the current branch name to completely avoid merge conflicts. For example,
if the current branch name is `feature-foo`, the corresponding lockfile name will
be `pnpm-lock.feature-foo.yaml` instead of `pnpm-lock.yaml`. It is typically used
in conjunction with the command line argument `--merge-git-branch-lockfiles` or by
setting `merge-git-branch-lockfiles-branch-pattern` in the `.npmrc` file.

### merge-git-branch-lockfiles-branch-pattern

* Default: **null**
* Type: **Array or null**

This configuration matches the current branch name to determine whether to merge
all git branch lockfile files. By default, you need to manually pass the
`--merge-git-branch-lockfiles` command line parameter. This configuration allows
this process to be automatically completed.

For instance:

```ini
merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*
```

You may also exclude patterns using `!`.

## Registry & Authentication Settings

### registry
Expand Down
3 changes: 2 additions & 1 deletion sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"Features": [
"workspaces",
"aliases",
"completion"
"completion",
"git_branch_lockfiles"
],
"Recipes": [
"using-changesets",
Expand Down
7 changes: 7 additions & 0 deletions versioned_docs/version-7.x/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ exports.isCI = !!(

[CI environments]: https://github.com/watson/ci-info#supported-ci-tools

### --merge-git-branch-lockfiles

Added in: v7.3.0

Merge all git branch lockfiles.
[Read more about git branch lockfiles.](../git_branch_lockfiles)

### --reporter=&lt;name\>

* Default:
Expand Down
54 changes: 54 additions & 0 deletions versioned_docs/version-7.x/git_branch_lockfiles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
id: git_branch_lockfiles
title: Git Branch Lockfiles
---

Added in: v7.3.0

Git branch lockfiles allows you to totally avoid lockfile merge conflicts and solve it later.

## Use git branch lockfiles

You can turn on this feature by configuring the `.npmrc` file.

```ini
git-branch-lockfiles=true
```

By doing this, lockfile name will be generated based on the current branch name.

For instance, the current branch name is `feature-1`. Then, the generated lockfile name will
be `pnpm-lock.feature-1.yaml`. You can commit it to the Git, and merge all git branch lockfiles later.

```
- <project_folder>
|- pnpm-lock.yaml
|- pnpm-lock.feature-1.yaml
|- pnpm-lock.<branch_name>.yaml
```

NOTE: `feature/1` is special in that the `/` is automatically converted to `!`, so the corresponding
lockfile name would be `pnpm-lock.feature!1.yaml`.

## Merge git branch lockfiles

### `pnpm install --merge-git-branch-lockfiles`

To merge all git branch lockfiles, just specify `--merge-git-branch-lockfiles` to `pnpm install` command.

After that, all git branch lockfiles will be merged into one `pnpm-lock.yaml`


### Branch Matching

Pnpm allows you to specify `--merge-git-branch-lockfiles` by matching the current branch name.

For instance,

By the following setting in `.npmrc` file, `pnpm install` will merge all git branch lockfiles when
running in the `main` branch and the branch name starts with `release`.

```ini
merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*
```
35 changes: 35 additions & 0 deletions versioned_docs/version-7.x/npmrc.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,41 @@ Added in: v7.6.0

Add the full URL to the package's tarball to every entry in `pnpm-lock.yaml`.

### git-branch-lockfile

Added in: v7.3.0

* Default: **false**
* Type: **Boolean**

When set to `true`, the generated lockfile name after installation will be named
based on the current branch name to completely avoid merge conflicts. For example,
if the current branch name is `feature-foo`, the corresponding lockfile name will
be `pnpm-lock.feature-foo.yaml` instead of `pnpm-lock.yaml`. It is typically used
in conjunction with the command line argument `--merge-git-branch-lockfiles` or by
setting `merge-git-branch-lockfiles-branch-pattern` in the `.npmrc` file.

### merge-git-branch-lockfiles-branch-pattern

Added in: v7.3.0

* Default: **null**
* Type: **Array or null**

This configuration matches the current branch name to determine whether to merge
all git branch lockfile files. By default, you need to manually pass the
`--merge-git-branch-lockfiles` command line parameter. This configuration allows
this process to be automatically completed.

For instance:

```ini
merge-git-branch-lockfiles-branch-pattern[]=main
merge-git-branch-lockfiles-branch-pattern[]=release*
```

You may also exclude patterns using `!`.

### use-lockfile-v6

Added in: v7.24.0
Expand Down
4 changes: 4 additions & 0 deletions versioned_sidebars/version-7.x-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@
{
"type": "doc",
"id": "version-7.x/completion"
},
{
"type": "doc",
"id": "version-7.x/git_branch_lockfiles"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions versioned_sidebars/version-8.x-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@
{
"type": "doc",
"id": "version-8.x/completion"
},
{
"type": "doc",
"id": "version-8.x/git_branch_lockfiles"
}
]
},
Expand Down