Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 1fd1185

Browse files
TimTechDevhlxid
andauthored
fix/npm-workspaces (#75)
* 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 <[email protected]> * Update create_service.md - Fix path in tsconfig.json - Reccomend using the create-service.py script Signed-off-by: Tim_Tech_Dev <[email protected]> * Apply suggestions from code review Co-authored-by: Daniel Huber <[email protected]> Co-authored-by: Daniel Huber <[email protected]>
1 parent 1f07780 commit 1fd1185

File tree

3 files changed

+57
-18
lines changed

3 files changed

+57
-18
lines changed

docs/contribute/contribute.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,15 @@ cd path/to/nodecg-io
4848
npm run watch
4949
```
5050

51-
_Note:_ Watching all packages requires a lot of RAM.
52-
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`.
53-
This will just spawn a watch process for the twitch-chat sample and service and require way less memory.
54-
5551
## Run
5652

57-
To test the changes you simply need to start/restart nodecg.
53+
To test the changes you simply need to start/restart NodeCG.
5854

5955
## Adding dependencies to packages
6056

61-
This project uses [lerna](https://lerna.js.org) to manage our monorepo, and most importantly link all our packages together.
57+
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.
6258
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.
63-
Instead, you should edit the `package.json` directly using a text editor and the run `npm run bootstrap` in the repository root.
59+
Instead, you should edit the `package.json` directly using a text editor and the run `npm install` in the repository root.
6460

6561
## Open a Pull Request
6662

docs/contribute/create_sample.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ E.g. `twitch-chat` or `obs-scenelist`.
55

66
Create a folder in `samples` named after the sample and add a `package.json` and a `tsconfig.json`:
77

8+
`package.json`
9+
810
```json
911
{
1012
"name": "<the sample name>",
@@ -32,9 +34,19 @@ Create a folder in `samples` named after the sample and add a `package.json` and
3234
}
3335
```
3436

37+
`tsconfig.json`
38+
3539
```json
3640
{
37-
"extends": "../../tsconfig.common.json"
41+
"extends": "../../tsconfig.common.json",
42+
"references": [
43+
{
44+
"path": "../../nodecg-io-core"
45+
},
46+
{
47+
"path": "../../services/nodecg-io-<the service name>"
48+
}
49+
]
3850
}
3951
```
4052

docs/contribute/create_service.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,37 @@ This guide helps you to create a service integration such as _twitch-chat_ or _d
77
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
88
[“Contributing packages to the registry” from the npm Docs](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry).
99

10-
## Create a package
10+
## Create a service
11+
12+
To create the service you can either use a premade Python 3 script in `.scripts/create-service.py`, or create the files manually.
13+
14+
## Using the script (recommended)
15+
16+
What this script does:
17+
18+
- It creates all required files for a new nodecg-io service
19+
- It copies version and dependency information (e.g., for typescript) from `noodecg-io-template`
20+
21+
It'll also create a sample and the files for the docs
22+
Requirements:
23+
24+
- python3 in your PATH
25+
- executed from root of nodecg-io repo
26+
27+
The script waits for your input for each of those fields:
28+
29+
```shell
30+
$ python3 .scripts/create-service.py
31+
Service name: <name here>
32+
Short description: <description here>
33+
Author name: <author here>
34+
Author url: <url here>
35+
Sample name: <name here>
36+
```
37+
38+
Now the script will rebuild your environment.
39+
40+
## Create the files manually
1141

1242
From here you will have to replace:
1343

@@ -17,7 +47,7 @@ From here you will have to replace:
1747

1848
Now you need to create a package. You should call it `nodecg-io-your-service-name`.
1949

20-
First create a directory with that name put file called `package.json` into it.
50+
First create a directory with that name in `/services/` and put file called `package.json` into it.
2151

2252
Put the following into it:
2353

@@ -34,15 +64,11 @@ Put the following into it:
3464
"repository": {
3565
"type": "git",
3666
"url": "https://github.com/codeoverflow-org/nodecg-io.git",
37-
"directory": "nodecg-io-<your-service-name>"
67+
"directory": "services/nodecg-io-<your-service-name>"
3868
},
3969
"files": ["**/*.js", "**/*.js.map", "**/*.d.ts", "*.json"],
4070
"main": "extension",
41-
"scripts": {
42-
"build": "tsc -b",
43-
"watch": "tsc -b -w",
44-
"clean": "tsc -b --clean"
45-
},
71+
"scripts": {},
4672
"keywords": ["nodecg-io", "nodecg-bundle"],
4773
"nodecg": {
4874
"compatibleRange": "^1.1.1",
@@ -67,11 +93,16 @@ Next you need to put a file called `tsconfig.json` next to your `package.json`.
6793

6894
```json
6995
{
70-
"extends": "../tsconfig.common.json"
96+
"extends": "../../tsconfig.common.json",
97+
"references": [
98+
{
99+
"path": "../../nodecg-io-core"
100+
}
101+
]
71102
}
72103
```
73104

74-
Now run `npm install` and `npm run bootstrap` in the repository root.
105+
Now run `npm install` in the repository root.
75106

76107
## Create a configuration schema
77108

0 commit comments

Comments
 (0)