github-desktop/docs/contributing/working-with-packages.md
Jean Dubois e965a51ee6
fix typo
"it's" is "it is" and not "its" !!
2023-04-21 15:31:40 +02:00

86 lines
2 KiB
Markdown

# Working with Packages
As we are using `yarn` for managing packages, here are some helpful tips for
whenever you need to work with them.
### Install packages
To ensure you have the right version of dependencies, run this command after
cloning or switching branches.
```sh
> yarn
```
This will restore the versions stored in the lock file to the `node_modules`
folder.
### Add new packages
Rather than updating the `package.json` explicitly, you can install new
dependencies via the `yarn` command line:
```sh
# adds the package to the dependencies list
> yarn add [package-name]
# adds the package to the devDependencies list
> yarn add [package-name] --dev
```
### Updating packages
To see which packages have newer versions available:
```sh
> yarn outdated
```
To upgrade a package to its latest version:
```sh
> yarn upgrade --latest [package-name]
```
To upgrade a package to a specific version (or [version range](https://docs.npmjs.com/misc/semver#x-ranges-12x-1x-12-)):
```sh
> yarn upgrade [package-name]@[version]
```
### Removing packages
To remove any packages that are no longer needed:
```sh
> yarn remove [package-name]
```
### Upgrading Yarn
Desktop uses a local version of `yarn` to ensure one version is used on all
platforms that we develop on. To upgrade Desktop to the latest version of `yarn`:
- download the `yarn-x-y.z.js` file from the latest release on [GitHub](https://github.com/yarnpkg/yarn/releases)
- add it to the root `vendor` folder on disk
- remove any previous version
- edit `.yarnrc` to use this new version (ensuring the `x.y.z` matches the
version you just downloaded)
```
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
yarn-path "./vendor/yarn-x.y.z.js"
```
- edit `app/.yarnrc` to use this new version (ensuring the `x.y.z` matches the
version you just downloaded)
```
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
yarn-path "../vendor/yarn-x.y.z.js"
```
- Commit these changes and open a pull request to get them reviewed