From 1fadb4f915a48f68cd818de30806d96980bb52a8 Mon Sep 17 00:00:00 2001 From: T-Hax <> Date: Fri, 28 Apr 2023 17:40:24 +0000 Subject: [PATCH] init Signed-off-by: T-Hax <> --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ TLDR.md | 30 +++++++++++++++++++++++++ env.example | 2 ++ gitignore | 19 ++++++++++++++++ yarnrc.yml | 25 +++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 README.md create mode 100644 TLDR.md create mode 100644 env.example create mode 100644 gitignore create mode 100644 yarnrc.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0a417c --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Setting up yarn v3 to work with Gitea + +Instead of using Yarn Classic (V1), we are using V3 for working with new projects. This is for the reason that Yarn Classic is annoying when working with Gitea repositories and shouldn't really be bothered with. + +The guide to installing and configuring Yarn V3 follows. + +# Install guide + +Checkout [tl;dr](./TLDR.md) 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**](https://nodejs.org/dist/latest/docs/api/corepack.html). 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: + +```bash +npm i -g corepack +corepack prepare yarn@ --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: + +```bash +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.](./yarnrc.yml). + +## Tip + +Yarn V1 renaming a package: + +```json +{ + "dependencies": { + "some-package": "npm:@scope/some-package" + } +} +``` + +Yarn V2/3 doing the same: + +```json +{ + "dependencies": { + "some-package": "npm:@scope/some-package@" + } +} +``` + +The range is necessary for installing the package. \ No newline at end of file diff --git a/TLDR.md b/TLDR.md new file mode 100644 index 0000000..b40b9c9 --- /dev/null +++ b/TLDR.md @@ -0,0 +1,30 @@ +install + +```bash +# first deinstall yarn to be safe +npm i -g corepack +corepack prepare yarn@ --activate +yarn --version +# Should print 3.X.X or above +``` + +for node <16.10 + +```bash +# first deinstall yarn to be safe +corepack enable +corepack prepare yarn@stable --activate +yarn --version +# Should print 3.X.X or above +``` + +for node >=16.10 + +then to setup a project + +```bash +cp yarnrc.yml your-project-dir/.yarnrc.yml +cp env.example your-project-dir/.env +cat gitignore >> your-project-dir/.gitignore +# Then uncomment one of the possibilities in gitignore +``` \ No newline at end of file diff --git a/env.example b/env.example new file mode 100644 index 0000000..ad48a67 --- /dev/null +++ b/env.example @@ -0,0 +1,2 @@ +#!/bin/bash +export GITEA_AUTH_TOKEN= \ No newline at end of file diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..c8600e0 --- /dev/null +++ b/gitignore @@ -0,0 +1,19 @@ +# If you're using Zero-Installs: + +# .yarn/* +# !.yarn/cache +# !.yarn/patches +# !.yarn/plugins +# !.yarn/releases +# !.yarn/sdks +# !.yarn/versions + +# If you're not using Zero-Installs: + +# .pnp.* +# .yarn/* +# !.yarn/patches +# !.yarn/plugins +# !.yarn/releases +# !.yarn/sdks +# !.yarn/versions \ No newline at end of file diff --git a/yarnrc.yml b/yarnrc.yml new file mode 100644 index 0000000..2e9a700 --- /dev/null +++ b/yarnrc.yml @@ -0,0 +1,25 @@ +# So basically, we want to selectively download packages from the Gitea repository but still allow the +# main repositories, so we are going to have to scope OUR packages properly. This means, unless the tornadocash +# Gitea organization defines a default scope, that we'll have to add every user scope. Including my own below. +# Note that all scopes are after @ prefix. So my prefix is @thax +npmScopes: + thax: + npmPublishRegistry: "https://development.tornadocash.community/api/packages/T-Hax/npm/" + npmRegistryServer: "https://development.tornadocash.community/api/packages/T-Hax/npm/" + # The below can be EXPORTED via some env file which actually exports the variables though + # Check the env.example, you will notice it's not a regular env + # So split your env files up, since this is only for manual actions + # npmAuthToken: ${GITEA_AUTH_TOKEN} + +# If the following isn't set you won't have a node_modules folder +# You might be used to a node_modules folder instead of a pnp or other folder type +# If you want to use the new linkers uncomment or change the following +nodeLinker: "node-modules" + +# So the tornadocash org, the person who maintains it, might setup something (in future) like, +# tornadocash: +# npmPublishRegistry: "https://development.tornadocash.community/api/packages/tornadocash/npm/" +# npmRegistryServer: "https://development.tornadocash.community/api/packages/tornadocash/npm/" + +# We disable telemetry for obvious reasons. +enableTelemetry: false \ No newline at end of file