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

Commit acacc80

Browse files
committed
Merge branch 'main' into feat/encrypt-using-password-hash
2 parents 40ac791 + bb9cca7 commit acacc80

File tree

222 files changed

+6898
-10081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+6898
-10081
lines changed

.devcontainer/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Base devcontainer for node.js development
2+
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:1-20-bullseye
3+
USER node
4+
5+
# Install required system dependencies
6+
RUN sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev libc-bin
7+
8+
# Create a NodeCG installation
9+
WORKDIR /workspaces
10+
RUN git clone https://github.com/nodecg/nodecg.git
11+
12+
# Install dependencies and add configuration that includes the nodecg-io install
13+
RUN cd nodecg && npm install --prod && mkdir cfg
14+
COPY ./nodecg.json /workspaces/nodecg/cfg/nodecg.json
15+

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/typescript-node
3+
{
4+
"name": "nodecg-io inside a NodeCG installation",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
9+
// Configure tool-specific properties.
10+
"customizations": {
11+
// Configure properties specific to VS Code.
12+
"vscode": {
13+
// Add the IDs of extensions you want installed when the container is created.
14+
"extensions": ["dbaeumer.vscode-eslint", "streetsidesoftware.code-spell-checker", "esbenp.prettier-vscode"]
15+
}
16+
},
17+
18+
"forwardPorts": [
19+
9090 // NodeCG dashboard port
20+
],
21+
22+
// Install node.js dependencies and build project after the container has been created.
23+
"postCreateCommand": "npm install && npm run build",
24+
25+
// Change directory from /workspaces/nodecg-io to /workspaces/nodecg/nodecg-io inside the NodeCG installation
26+
"workspaceFolder": "/workspaces/nodecg/nodecg-io",
27+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/nodecg/nodecg-io,type=bind",
28+
29+
"remoteUser": "node"
30+
}

.devcontainer/nodecg.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bundles": {
3+
"paths": [
4+
"/workspaces/nodecg/nodecg-io",
5+
"/workspaces/nodecg/nodecg-io/services",
6+
"/workspaces/nodecg/nodecg-io/samples"
7+
]
8+
}
9+
}

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ updates:
66
interval: "monthly"
77
- package-ecosystem: "npm"
88
directory: "/"
9+
open-pull-requests-limit: 15
10+
schedule:
11+
interval: "monthly"
12+
- package-ecosystem: "docker"
13+
directory: ".devcontainer"
914
schedule:
1015
interval: "monthly"

.github/workflows/ci.yml

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3.5.0
15+
- uses: actions/setup-node@v3.6.0
1616
with:
17-
node-version: "16"
17+
node-version: "18"
1818

1919
- name: Install system dependencies
2020
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
@@ -40,9 +40,9 @@ jobs:
4040
runs-on: ubuntu-latest
4141
steps:
4242
- uses: actions/checkout@v3
43-
- uses: actions/setup-node@v3.5.0
43+
- uses: actions/setup-node@v3.6.0
4444
with:
45-
node-version: "16"
45+
node-version: "18"
4646

4747
- name: Install system dependencies
4848
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
@@ -64,9 +64,9 @@ jobs:
6464
os: [ubuntu-latest, windows-2019]
6565
runs-on: ${{ matrix.os }}
6666
steps:
67-
- uses: actions/setup-node@v3.5.0
67+
- uses: actions/setup-node@v3.6.0
6868
with:
69-
node-version: "16"
69+
node-version: "18"
7070

7171
- name: Download NodeCG
7272
uses: actions/checkout@v3
@@ -76,19 +76,31 @@ jobs:
7676
- name: Get NodeCG commit hash
7777
id: nodecgHash
7878
shell: bash
79-
run: echo "::set-output name=nodecgHash::$(git rev-parse HEAD)"
79+
run: echo "NODECG_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
8080

8181
- name: Cache NodeCG dependencies
82-
id: cache-nodecg
82+
id: cache-nodecg-deps
8383
uses: actions/cache@v3
8484
with:
8585
path: 'node_modules'
86-
key: ${{ runner.os }}-${{ steps.nodecgHash.outputs.nodecgHash }}-nodecg
86+
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-deps
87+
88+
- name: Cache NodeCG compilation outputs
89+
id: cache-nodecg-build
90+
uses: actions/cache@v3
91+
with:
92+
path: 'build'
93+
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-build
8794

8895
- name: Install NodeCG dependencies
8996
# Only get dependencies if we didn't get them from the cache
90-
if: steps.cache-nodecg.outputs.cache-hit != 'true'
91-
run: npm install --prod
97+
if: steps.cache-nodecg-deps.outputs.cache-hit != 'true'
98+
run: npm install
99+
100+
- name: Build NodeCG
101+
# Only build NodeCG if we didn't have cached compilation results
102+
if: steps.cache-nodecg-build.outputs.cache-hit != 'true'
103+
run: npm run build
92104

93105
- name: Setup NodeCG config linux
94106
if: matrix.os == 'ubuntu-latest'
@@ -124,7 +136,19 @@ jobs:
124136
run: npm run build
125137
working-directory: ./nodecg-io
126138

127-
- name: Run test
139+
# Under linux we need to run the test as the root user because
140+
# the midi service requires access to audio devices.
141+
# By default the GitHub Actions user is not in the `audio` group and therefore
142+
# has no access. Either we need to run as root to get access or need to add the user
143+
# to the `audio` group which doesn't work for us, as it would only take affect on next login,
144+
# but we cannot logout and login in CI.
145+
- name: Run test (ubuntu)
146+
if: matrix.os == 'ubuntu-latest'
147+
run: sudo node .scripts/ci-nodecg-integration.mjs
148+
working-directory: ./nodecg-io
149+
150+
- name: Run test (windows)
151+
if: matrix.os == 'windows-2019'
128152
shell: bash
129153
run: node .scripts/ci-nodecg-integration.mjs
130154
working-directory: ./nodecg-io
@@ -142,9 +166,9 @@ jobs:
142166
- nodecg
143167
steps:
144168
- uses: actions/checkout@v3
145-
- uses: actions/setup-node@v3.5.0
169+
- uses: actions/setup-node@v3.6.0
146170
with:
147-
node-version: "16"
171+
node-version: "18"
148172

149173
- name: Download compilation results # From the build step
150174
uses: actions/download-artifact@v3
@@ -154,6 +178,22 @@ jobs:
154178
- name: Extract compilation results
155179
run: tar xvf compilation-results.tar.gz
156180

181+
# All twitch services depend on the utility package `nodecg-io-twitch-auth`.
182+
# In the repository the services depend on the latest development version which is not yet published.
183+
# If someone installs the service using the published tarball npm would try to get the
184+
# unpublished version of twitch-auth from the npm registry which is not possible.
185+
# To fix this we update the version of the twitch-auth package in all usages
186+
# to also reference the published tarball.
187+
- name: Patch twitch-auth dependency to use published current tarball
188+
run: |
189+
# Get current version as it is needed for the tarball file name
190+
TWITCH_AUTH_VERSION=$(cat utils/nodecg-io-twitch-auth/package.json | jq .version -r)
191+
192+
# Find usages in all package.json files and replace with the corresponding tarball url
193+
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print # Print found files for debug purposes
194+
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print0 | \
195+
xargs -0 sed -i "s/\"nodecg-io-twitch-auth\": \".*\"/\"nodecg-io-twitch-auth\": \"https:\/\/codeoverflow-org.github.io\/nodecg-io-publish\/nodecg-io-twitch-auth-${TWITCH_AUTH_VERSION}.tgz\"/g"
196+
157197
- name: Create npm tarballs
158198
run: npm pack --workspaces
159199

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Python
2020
uses: actions/setup-python@v4
2121
with:
22-
python-version: 3.8.3
22+
python-version: 3.10.8
2323

2424
- uses: actions/checkout@v3
2525

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ jobs:
77
steps:
88
- uses: actions/checkout@v3
99

10-
- uses: actions/setup-node@v3.5.0
10+
- uses: actions/setup-node@v3.6.0
1111
with:
12-
node-version: "16"
12+
node-version: "18"
1313

1414
- name: Install system dependencies
1515
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev

.scripts/ci-nodecg-integration.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ console.log("\nStarted NodeCG");
2626
console.log("--------------------------------------------------------------------------------");
2727

2828
// Spawn a process that runs NodeCG and let it run for 15 seconds to load all bundles
29-
const child = child_process.spawn("node", ["index.js"], { cwd: cwd.dir, timeout: 15000 });
29+
const child = child_process.spawn("node", ["index.js"], { cwd: cwd.dir, timeout: 20000 });
3030

3131
// Store stdout and pipe the output of the child process to the output of this process
3232
const buffer = [];
@@ -39,15 +39,16 @@ child.once("exit", (exitCode, signal) => {
3939
console.log("Stopped NodeCG\n");
4040

4141
// Check exit code for failure
42-
if (exitCode !== null && exitCode !== 0) {
42+
// 143 is the exit code when the process is killed by the timeout (SIGTERM)
43+
if (exitCode !== null && exitCode !== 143) {
4344
throw new Error(`NodeCG exited with code ${exitCode} ${signal}`);
4445
}
4546

4647
const log = Buffer.concat(buffer).toString();
4748

4849
// Try to find each bundle in the logs.
4950
const missing = bundles.filter(
50-
(i) => !log.includes(`[nodecg/lib/server/extensions] Mounted ${i.packageJson.name} extension`),
51+
(bundle) => !log.includes(` [extensions] Mounted ${bundle.packageJson.name} extension`),
5152
);
5253

5354
// Fail the run if there are missing bundles.

.scripts/create-service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
os.mkdir(f'services/nodecg-io-{service_name}/extension')
4848
with open(f'services/nodecg-io-{service_name}/extension/index.ts', mode='w') as file:
4949
file.writelines([
50-
'import { NodeCG } from "nodecg-types/types/server";\n',
50+
'import NodeCG from "@nodecg/types";\n',
5151
'import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core";\n',
5252
f'import {{ {service_name_c}Client }} from "./{service_name_cc}Client";\n',
5353
'\n',
@@ -57,7 +57,7 @@
5757
'\n',
5858
f'export {{ {service_name_c}Client }} from "./{service_name_cc}Client";\n',
5959
'\n',
60-
'module.exports = (nodecg: NodeCG) => {\n',
60+
'module.exports = (nodecg: NodeCG.ServerAPI) => {\n',
6161
f' new {service_name_c}Service(nodecg, "{service_name}", __dirname, "../schema.json").register();\n',
6262
'};\n',
6363
'\n',
@@ -135,11 +135,11 @@
135135
os.mkdir(f'samples/{sample_name}/extension')
136136
with open(f'samples/{sample_name}/extension/index.ts', mode='w') as file:
137137
file.writelines([
138-
'import { NodeCG } from "nodecg-types/types/server";\n',
138+
'import NodeCG from "@nodecg/types";\n',
139139
f'import {{ {service_name_c}Client }} from "nodecg-io-{service_name}";\n',
140140
'import { requireService } from "nodecg-io-core";\n',
141141
'\n',
142-
'module.exports = function (nodecg: NodeCG) {\n',
142+
'module.exports = function (nodecg: NodeCG.ServerAPI) {\n',
143143
f' nodecg.log.info("Sample bundle for {service_name_c} started.");\n',
144144
'\n',
145145
f' const {service_name_cc} = requireService<{service_name_c}Client>(nodecg, "{service_name}");\n',

.scripts/exec.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { root, packages } from "./update-paths.mjs";
1+
import { rootDir, packages, rootPackage } from "./update-paths.mjs";
22
import concurrently from "concurrently";
33

44
const COMMAND = process.argv[2];
@@ -12,12 +12,12 @@ const commands = packages
1212
cwd: v.dir,
1313
}));
1414

15-
const scripts = root.packageJson["scripts"];
15+
const scripts = rootPackage?.packageJson["scripts"];
1616
if (scripts && scripts[COMMAND + ":root"]) {
1717
commands.unshift({
18-
name: root.packageJson.name,
18+
name: rootPackage?.packageJson.name,
1919
command: "npm:" + COMMAND + ":root",
20-
cwd: root.dir,
20+
cwd: rootDir,
2121
});
2222
}
2323

.scripts/update-paths.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import path from "path";
33

44
import { getPackages } from "@manypkg/get-packages";
55

6-
export const { root, packages } = await getPackages(process.cwd());
6+
export const { rootDir, packages, rootPackage } = await getPackages(process.cwd());
77

8-
const rootTSconfig = path.join(root.dir, "tsconfig.json");
8+
const rootTSconfig = path.join(rootDir, "tsconfig.json");
99
const tsconfig = {
1010
files: [],
1111
references: packages
1212
.filter((pkg) => fs.readdirSync(pkg.dir).includes("tsconfig.json"))
13-
.map((v) => ({ path: path.relative(root.dir, v.dir) })),
13+
.map((v) => ({ path: path.relative(rootDir, v.dir) })),
1414
};
1515

1616
let content = "// This file will be overwritten automatically! Do not store options here.\n" + JSON.stringify(tsconfig);

jest.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getPackages } from "@manypkg/get-packages";
55

66
let projects = [];
77
// @ts-ignore
8-
const { root, packages } = await getPackages(cwd());
8+
const { packages } = await getPackages(cwd());
99

1010
/** @param pkg {import("@manypkg/get-packages").Package} */
1111
function hasJestConfig(pkg) {
@@ -21,7 +21,7 @@ function hasJestConfig(pkg) {
2121
);
2222
}
2323

24-
projects = packages.filter((pkg) => hasJestConfig(pkg)).map((v) => `<rootDir>/${path.relative(root.dir, v.dir)}`);
24+
projects = packages.filter((pkg) => hasJestConfig(pkg)).map((v) => `<rootDir>/${path.relative(cwd(), v.dir)}`);
2525

2626
console.log(projects);
2727

nodecg-io-core/dashboard/authentication.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// <reference types="nodecg-types/types/browser" />
2-
31
import { updateMonacoLayout } from "./serviceInstance";
42
import { setPassword, isPasswordSet } from "./crypto";
53

@@ -41,7 +39,7 @@ document.addEventListener("DOMContentLoaded", () => {
4139

4240
export async function isLoaded(): Promise<boolean> {
4341
return new Promise((resolve, _reject) => {
44-
nodecg.sendMessage("isLoaded", (_err, res) => resolve(res));
42+
nodecg.sendMessage("isLoaded", (_err, res: boolean) => resolve(res));
4543
setTimeout(() => resolve(false), 5000); // Fallback in case connection gets lost.
4644
});
4745
}

nodecg-io-core/dashboard/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// Define NodeCG instance on global scope
2+
import type { NodeCGAPIClient } from "@nodecg/types/client/api/api.client";
3+
4+
declare global {
5+
const NodeCG: typeof NodeCGAPIClient;
6+
const nodecg: NodeCGAPIClient;
7+
}
8+
19
// Re-export functions that are used in panel.html to the global scope
210
import { loadFramework } from "./authentication";
311
import {

nodecg-io-core/dashboard/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"watch": "node esbuild.config.js --watch"
2020
},
2121
"devDependencies": {
22-
"esbuild": "^0.15.8",
23-
"monaco-editor": "^0.34.0",
24-
"nodecg-types": "^1.9.0",
25-
"typescript": "^4.8.4"
22+
"esbuild": "^0.16.12",
23+
"monaco-editor": "^0.38.0",
24+
"@nodecg/types": "^2.1.11",
25+
"typescript": "^5.1.6"
2626
},
2727
"dependencies": {
2828
"crypto-js": "^4.1.1",

0 commit comments

Comments
 (0)