gitea-guide/README.md
T-Hax 19bf152be5 Unhide .env and other
Signed-off-by: T-Hax <>
2023-05-10 18:45:53 +00:00

2.7 KiB

Setting up npmor yarn v3 to work with Gitea

This is a guide to working with Gitea Tornado packages.

We can either use NPM or Yarn V3 for working with new projects. Yarn classic does not support other registries nicely. Using Yarn V3 requires more time (you have to know how to write the config), but Yarn is much more powerful and allow smoother dependency management.

The guide to installing and configuring NPM and Yarn V3 follows.

Short npm solution

# Add into your .npmrc
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

or

# Add into your .npmrc
@tornado:registry=https://development.tornadocash.community/api/packages/T-Hax/npm/

Proper yarn solution (more privacy)

Checkout tl;dr if you are about to fall asleep.

You should first deinstall the current version of yarn which you are using. If you have legacy repositories with aliased package names (e.g. "my-package": "npm:@scope/my-package"), then you should look into use corepack on using an older Yarn version on that specific repository.

If you have Node 16.10 or higher, you should already have a program called Corepack. If you don't, read the section "Node.js <16.10" below. Otherwise, enable as stated in the section after it.

Node.js <16.10

Corepack isn't included with Node.js in versions before the 16.10; to address that, run:

npm i -g corepack
corepack prepare yarn@<version> --activate
yarn --version

Node.js >=16.10

Corepack is included by default with all Node.js installs, but is currently opt-in. To enable it, run the following command:

corepack enable
corepack prepare yarn@stable --activate
yarn --version

Configuration

Yarn V3 doesn't support global options and instead has project (dir) specific options which write for any non-defaults a new .yarnrc.yml file in your current dir.

This is similar to python packaging (pip and venvs) and is preferable for working with projects.

In any case check out the sample config for this gitea, it will be kept updated..

You also need to configure the .env

Tips

Errors

If you are installing packages and you meet Invalid authentication (as an unknown user) then try to comment out the AUTH token for the install process.

Breaking changes

Yarn V1 renaming a package:

{
    "dependencies": {
        "some-package": "npm:@scope/some-package"
    }
}

Yarn V2/3 doing the same:

{
    "dependencies": {
        "some-package": "npm:@scope/some-package@<version statement>"
    }
}

The range is necessary for installing the package.