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

fix/npm-workspaces #75

Merged
merged 3 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions docs/contribute/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion docs/contribute/create_sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<the sample name>",
Expand Down Expand Up @@ -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-<the service name>"
}
]
}
```

Expand Down
51 changes: 41 additions & 10 deletions docs/contribute/create_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (recommended)

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: <name here>
Short description: <description here>
Author name: <author here>
Author url: <url here>
Sample name: <name here>
```

Now the script will rebuild your environment.

## Create the files manually

From here you will have to replace:

Expand All @@ -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/` and put file called `package.json` into it.

Put the following into it:

Expand All @@ -34,15 +64,11 @@ Put the following into it:
"repository": {
"type": "git",
"url": "https://github.com/codeoverflow-org/nodecg-io.git",
"directory": "nodecg-io-<your-service-name>"
"directory": "services/nodecg-io-<your-service-name>"
},
"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",
Expand All @@ -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` in the repository root.

## Create a configuration schema

Expand Down