From 42273e8bf5cd92433ad115f10dad567bf30aca15 Mon Sep 17 00:00:00 2001 From: Tim_Tech_Dev Date: Wed, 20 Oct 2021 22:09:40 +0200 Subject: [PATCH 1/3] fix/npm-workspaces - Remove description of how to use lerna from contribute.md - Change tsconfig in create_sample.md - Update create_service.md Signed-off-by: Tim_Tech_Dev --- docs/contribute/contribute.md | 10 ++---- docs/contribute/create_sample.md | 14 ++++++++- docs/contribute/create_service.md | 51 +++++++++++++++++++++++++------ 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/docs/contribute/contribute.md b/docs/contribute/contribute.md index 8a264c05..bca48316 100644 --- a/docs/contribute/contribute.md +++ b/docs/contribute/contribute.md @@ -48,19 +48,15 @@ cd path/to/nodecg-io npm run watch ``` -_Note:_ Watching all packages requires a lot of RAM. -Instead, you can watch just the packages you are actively working on e.g., `npm run watch -- --scope nodecg-io-twitch-chat --scope twitch-chat`. -This will just spawn a watch process for the twitch-chat sample and service and require way less memory. - ## Run -To test the changes you simply need to start/restart nodecg. +To test the changes you simply need to start/restart NodeCG. ## Adding dependencies to packages -This project uses [lerna](https://lerna.js.org) to manage our monorepo, and most importantly link all our packages together. +This project uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces/) to manage our monorepo, and most importantly link all our packages together. Because of linking you should not use `npm install xyz --save` to add dependencies because npm can't get the development version of internal packages like `nodecg-io-core`. Doing so will result in an error and break the link. -Instead, you should edit the `package.json` directly using a text editor and the run `npm run bootstrap` in the repository root. +Instead, you should edit the `package.json` directly using a text editor and the run `npm install` in the repository root. ## Open a Pull Request diff --git a/docs/contribute/create_sample.md b/docs/contribute/create_sample.md index 58976a3b..696ebf31 100644 --- a/docs/contribute/create_sample.md +++ b/docs/contribute/create_sample.md @@ -5,6 +5,8 @@ E.g. `twitch-chat` or `obs-scenelist`. Create a folder in `samples` named after the sample and add a `package.json` and a `tsconfig.json`: +`package.json` + ```json { "name": "", @@ -32,9 +34,19 @@ Create a folder in `samples` named after the sample and add a `package.json` and } ``` +`tsconfig.json` + ```json { - "extends": "../../tsconfig.common.json" + "extends": "../../tsconfig.common.json", + "references": [ + { + "path": "../../nodecg-io-core" + }, + { + "path": "../../services/nodecg-io-" + } + ] } ``` diff --git a/docs/contribute/create_service.md b/docs/contribute/create_service.md index 9c771555..895828e3 100644 --- a/docs/contribute/create_service.md +++ b/docs/contribute/create_service.md @@ -7,7 +7,37 @@ This guide helps you to create a service integration such as _twitch-chat_ or _d Go to [npmjs.com](https://www.npmjs.com/) and look whether there's already a package that wraps around the API of your service. If there's no such package, you need to create one yourself. This process is not described here. You may read the [“Contributing packages to the registry” from the npm Docs](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry). -## Create a package +## Create a service + +To create the service you can either use a premade Python 3 script in `.scripts/create-service.py`, or create the files manually. + +## Using the script + +What this script does: + +- It creates all required files for a new nodecg-io service +- It copies version and dependency information (e.g., for typescript) from `noodecg-io-template` + +It'll also create a sample and the files for the docs +Requirements: + +- python3 in your PATH +- executed from root of nodecg-io repo + +The script waits for your input for each of those fields: + +```shell +$ python3 .scripts/create-service.py +Service name: +Short description: +Author name: +Author url: +Sample name: +``` + +Now the script will rebuild your environment. + +## Create the files manually From here you will have to replace: @@ -17,7 +47,7 @@ From here you will have to replace: Now you need to create a package. You should call it `nodecg-io-your-service-name`. -First create a directory with that name put file called `package.json` into it. +First create a directory with that name in `/services/` put file called `package.json` into it. Put the following into it: @@ -34,15 +64,11 @@ Put the following into it: "repository": { "type": "git", "url": "https://github.com/codeoverflow-org/nodecg-io.git", - "directory": "nodecg-io-" + "directory": "services/nodecg-io-" }, "files": ["**/*.js", "**/*.js.map", "**/*.d.ts", "*.json"], "main": "extension", - "scripts": { - "build": "tsc -b", - "watch": "tsc -b -w", - "clean": "tsc -b --clean" - }, + "scripts": {}, "keywords": ["nodecg-io", "nodecg-bundle"], "nodecg": { "compatibleRange": "^1.1.1", @@ -67,11 +93,16 @@ Next you need to put a file called `tsconfig.json` next to your `package.json`. ```json { - "extends": "../tsconfig.common.json" + "extends": "../tsconfig.common.json", + "references": [ + { + "path": "../../nodecg-io-core" + } + ] } ``` -Now run `npm install` and `npm run bootstrap` in the repository root. +Now run `npm install` and in the repository root. ## Create a configuration schema From 71470c95d77fd8b0f801f85721e794e0f9ef6af3 Mon Sep 17 00:00:00 2001 From: Tim_Tech_Dev Date: Thu, 21 Oct 2021 20:08:02 +0200 Subject: [PATCH 2/3] Update create_service.md - Fix path in tsconfig.json - Reccomend using the create-service.py script Signed-off-by: Tim_Tech_Dev --- docs/contribute/create_service.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contribute/create_service.md b/docs/contribute/create_service.md index 895828e3..6f04e46f 100644 --- a/docs/contribute/create_service.md +++ b/docs/contribute/create_service.md @@ -11,7 +11,7 @@ Go to [npmjs.com](https://www.npmjs.com/) and look whether there's already a pac To create the service you can either use a premade Python 3 script in `.scripts/create-service.py`, or create the files manually. -## Using the script +## Using the script (recommended) What this script does: @@ -93,7 +93,7 @@ Next you need to put a file called `tsconfig.json` next to your `package.json`. ```json { - "extends": "../tsconfig.common.json", + "extends": "../../tsconfig.common.json", "references": [ { "path": "../../nodecg-io-core" From ac8a5a31ed0d3346cf2d2919d1f47507d5baaa2d Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 21 Oct 2021 21:30:35 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Daniel Huber --- docs/contribute/create_service.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/contribute/create_service.md b/docs/contribute/create_service.md index 6f04e46f..5b629642 100644 --- a/docs/contribute/create_service.md +++ b/docs/contribute/create_service.md @@ -47,7 +47,7 @@ From here you will have to replace: Now you need to create a package. You should call it `nodecg-io-your-service-name`. -First create a directory with that name in `/services/` put file called `package.json` into it. +First create a directory with that name in `/services/` and put file called `package.json` into it. Put the following into it: @@ -102,7 +102,7 @@ Next you need to put a file called `tsconfig.json` next to your `package.json`. } ``` -Now run `npm install` and in the repository root. +Now run `npm install` in the repository root. ## Create a configuration schema