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

Commit 5a1f8d9

Browse files
committed
Merge branch 'main' into feat/encrypt-using-password-hash
2 parents 6d549da + 0f70435 commit 5a1f8d9

File tree

134 files changed

+5654
-6021
lines changed

Some content is hidden

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

134 files changed

+5654
-6021
lines changed

.eslintrc.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1+
/** @type {import("eslint").ESLint.Options} */
12
module.exports = {
23
parser: "@typescript-eslint/parser",
34
parserOptions: {
45
ecmaVersion: 2017,
56
sourceType: "module",
67
},
7-
extends: [
8-
"eslint:recommended",
9-
"plugin:@typescript-eslint/recommended",
10-
],
8+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
119
// Don't traverse fs up to root.
1210
// This caused problems when nodecg-io was cloned into a NodeCG installation as it then
1311
// tried to lint nodecg-io with that config.
1412
root: true,
1513
rules: {
1614
// Allow for unused function arguments when they are prefixed with an underscore.
1715
// This is the TypeScript convention to mark unused arguments.
18-
"@typescript-eslint/no-unused-vars": ["warn", {argsIgnorePattern: "^_"}],
16+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
1917

2018
// We simply have empty functions at some places, so we ignore this rule.
2119
"@typescript-eslint/no-empty-function": ["warn", { allow: ["arrowFunctions"] }],
@@ -24,6 +22,6 @@ module.exports = {
2422
"no-console": ["warn"],
2523

2624
// Enforce triple equals for comparisons
27-
"eqeqeq": ["warn"]
25+
"eqeqeq": ["warn"],
2826
},
2927
};

.github/workflows/ci.yml

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v2
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3.4.1
1616
with:
1717
node-version: "16"
1818

@@ -31,16 +31,16 @@ jobs:
3131
tar cvzf compilation-results.tar.gz --exclude "node_modules" **/*.js **/*.js.map **/*.d.ts **/*.d.ts.map **/*.tsbuildinfo **/*.ttf
3232
3333
- name: Upload compilation results
34-
uses: actions/upload-artifact@v2
34+
uses: actions/upload-artifact@v3
3535
with:
3636
name: compilation-results
3737
path: compilation-results.tar.gz
3838

3939
tests:
4040
runs-on: ubuntu-latest
4141
steps:
42-
- uses: actions/checkout@v2
43-
- uses: actions/setup-node@v2
42+
- uses: actions/checkout@v3
43+
- uses: actions/setup-node@v3.4.1
4444
with:
4545
node-version: "16"
4646

@@ -59,31 +59,63 @@ jobs:
5959
# are mounted by NodeCG. It will fail if one of them is not mounted.
6060
# You may check for other NodeCG runtime errors in the output (these
6161
# may not fail the run).
62-
runs-on: ubuntu-latest
62+
strategy:
63+
matrix:
64+
os: [ubuntu-latest, windows-2019]
65+
runs-on: ${{ matrix.os }}
6366
steps:
64-
- uses: actions/setup-node@v2
67+
- uses: actions/setup-node@v3.4.1
6568
with:
6669
node-version: "16"
6770

68-
- name: Install nodecg-cli
69-
run: npm install --global nodecg-cli
71+
- name: Download NodeCG
72+
uses: actions/checkout@v3
73+
with:
74+
repository: nodecg/nodecg
75+
76+
- name: Get NodeCG commit hash
77+
id: nodecgHash
78+
shell: bash
79+
run: echo "::set-output name=nodecgHash::$(git rev-parse HEAD)"
80+
81+
- name: Cache NodeCG dependencies
82+
id: cache-nodecg
83+
uses: actions/cache@v3
84+
with:
85+
path: 'node_modules'
86+
key: ${{ runner.os }}-${{ steps.nodecgHash.outputs.nodecgHash }}-nodecg
7087

71-
- name: Setup NodeCG
72-
run: nodecg setup
88+
- name: Install NodeCG dependencies
89+
# 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
7392

74-
- name: Setup NodeCG config
93+
- name: Setup NodeCG config linux
94+
if: matrix.os == 'ubuntu-latest'
7595
run: |
7696
mkdir cfg
7797
echo '{"bundles": {"paths": ["'${GITHUB_WORKSPACE}'/nodecg-io","'${GITHUB_WORKSPACE}'/nodecg-io/services","'${GITHUB_WORKSPACE}'/nodecg-io/samples"]}}' > ./cfg/nodecg.json
7898
79-
# nodecg-io needs to be cloned after NodeCG setup because the nodecg-cli requires an empty directory.
80-
- uses: actions/checkout@v2
99+
- name: Setup NodeCG config windows
100+
if: matrix.os == 'windows-2019'
101+
shell: bash
102+
run: |
103+
mkdir cfg
104+
# We need to escape backslashes to get valid json. Replaces each "\" with "\\"
105+
echo '{"bundles": {"paths": ["'${GITHUB_WORKSPACE//\\/\\\\}'\\nodecg-io","'${GITHUB_WORKSPACE//\\/\\\\}'\\nodecg-io\\services","'${GITHUB_WORKSPACE//\\/\\\\}'\\nodecg-io\\samples"]}}' > ./cfg/nodecg.json
106+
107+
- uses: actions/checkout@v3
81108
with:
82109
path: "nodecg-io"
83110

84111
- name: Install system dependencies
112+
if: matrix.os == 'ubuntu-latest'
85113
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
86114

115+
- name: Install node native development files
116+
shell: bash
117+
run: npx node-gyp install
118+
87119
- name: Install nodejs dependencies
88120
run: npm ci
89121
working-directory: ./nodecg-io
@@ -93,6 +125,7 @@ jobs:
93125
working-directory: ./nodecg-io
94126

95127
- name: Run test
128+
shell: bash
96129
run: node .scripts/ci-nodecg-integration.mjs
97130
working-directory: ./nodecg-io
98131

@@ -108,13 +141,13 @@ jobs:
108141
- tests
109142
- nodecg
110143
steps:
111-
- uses: actions/checkout@v2
112-
- uses: actions/setup-node@v2
144+
- uses: actions/checkout@v3
145+
- uses: actions/setup-node@v3.4.1
113146
with:
114147
node-version: "16"
115148

116149
- name: Download compilation results # From the build step
117-
uses: actions/download-artifact@v2
150+
uses: actions/download-artifact@v3
118151
with:
119152
name: compilation-results
120153

@@ -125,7 +158,7 @@ jobs:
125158
run: npm pack --workspaces
126159

127160
- name: Clone publish repository
128-
uses: actions/checkout@v2
161+
uses: actions/checkout@v3
129162
with:
130163
repository: codeoverflow-org/nodecg-io-publish
131164
ssh-key: ${{ secrets.PUBLISH_SSH_KEY }}

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
if: startsWith(github.repository, 'codeoverflow-org') && github.actor != 'dependabot[bot]'
1818
steps:
1919
- name: Setup Python
20-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v4
2121
with:
2222
python-version: 3.8.3
2323

24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525

2626
- name: Checkout docs
27-
uses: actions/checkout@v2
27+
uses: actions/checkout@v3
2828
with:
2929
repository: codeoverflow-org/nodecg-io-docs
3030
path: docs

.github/workflows/lint.yaml

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ jobs:
55
build:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
8+
- uses: actions/checkout@v3
99

10-
- uses: actions/setup-node@v2
10+
- uses: actions/setup-node@v3.4.1
1111
with:
1212
node-version: "16"
1313

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services/nodecg-io-debug/dashboard/dist
3333

3434
# Launch configurations and settings
3535
!/.vscode/launch.json
36+
!/.vscode/tasks.json
3637
!/.vscode/settings.json
3738

3839
# Lerna temporary files
@@ -55,7 +56,7 @@ lerna-debug.log
5556
install.json
5657

5758
# Autogenerated tsconfig.json files
58-
tsconfig.json
59-
samples/tsconfig.json
60-
services/tsconfig.json
61-
utils/tsconfig.json
59+
/tsconfig.json
60+
/samples/tsconfig.json
61+
/services/tsconfig.json
62+
/utils/tsconfig.json

.prettierignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ docs/build
33
coverage
44

55
# Autogenerated tsconfig.json files
6-
tsconfig.json
7-
samples/tsconfig.json
8-
services/tsconfig.json
9-
utils/tsconfig.json
6+
/tsconfig.json
7+
/samples/tsconfig.json
8+
/services/tsconfig.json
9+
/utils/tsconfig.json

.prettierrc.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
/** @type {import("prettier").RequiredOptions} */
12
module.exports = {
2-
semi: true,
3-
trailingComma: "all",
4-
singleQuote: false,
53
printWidth: 120,
64
tabWidth: 4,
75
useTabs: false,
8-
endOfLine: "auto"
6+
semi: true,
7+
singleQuote: false,
8+
quoteProps: "consistent",
9+
jsxSingleQuote: false,
10+
trailingComma: "all",
11+
bracketSpacing: true,
12+
arrowParens: "always",
13+
proseWrap: "preserve",
14+
vueIndentScriptAndStyle: false,
15+
endOfLine: "lf",
916
};

.scripts/ci-nodecg-integration.mjs

Lines changed: 41 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from "fs";
22
import * as path from "path";
33
import * as child_process from "child_process";
4+
import { getPackages } from "@manypkg/get-packages";
45

56
const cwd = path.parse(process.cwd());
67
const nodecgiodir = fs.readdirSync(process.cwd()).some((v) => v === "nodecg-io-core");
@@ -9,66 +10,53 @@ const nodecgiodir = fs.readdirSync(process.cwd()).some((v) => v === "nodecg-io-c
910
if (!nodecgiodir) {
1011
throw new Error("You will have to run this script from inside the nodecg-io folder!");
1112
}
12-
/**
13-
* expected data:
14-
*
15-
* ~~~json
16-
* {
17-
* name: 'nodecg-io',
18-
* dependencies: {
19-
* 'name': {
20-
* version: 'version',
21-
* resolved: 'optional'
22-
* },
23-
* }
24-
* }
25-
* ~~~
26-
*/
27-
const npm = JSON.parse(child_process.execSync("npm ls --json"));
2813

29-
// Filter out any dependencies which are not resolved locally in samples or services because the other npm packages will not be loaded by NodeCG
30-
let bundles = Object.entries(npm.dependencies)
31-
.filter((i) =>
32-
Object.entries(i[1]).some(
33-
(j) =>
34-
j[0] === "resolved" &&
35-
(`${j[1]}`.startsWith("file:../samples/") ||
36-
`${j[1]}`.startsWith("file:../services/" || `${j[1]}` === "file:../nodecg-io-core")),
37-
),
38-
)
39-
.map((v) => v[0]);
14+
const { packages } = await getPackages(process.cwd());
4015

41-
console.log(`Found ${bundles.length} bundles in this install.`);
16+
// Filter out packages other than core, samples and services, because they should not be NodeCG-bundles (dashboard, utils)
17+
const bundles = packages.filter(
18+
(v) =>
19+
v.packageJson.name === "nodecg-io-core" ||
20+
path.parse(v.dir).dir.endsWith("samples") ||
21+
path.parse(v.dir).dir.endsWith("services"),
22+
);
4223

43-
console.log("");
44-
console.log("NodeCG sterr");
24+
console.log(`Found ${bundles.length} bundles in this install.`);
25+
console.log("\nStarted NodeCG");
4526
console.log("--------------------------------------------------------------------------------");
4627

47-
// expects a NodeCG folder be the parent of the cwd needs timeout
48-
const log = child_process
49-
.execSync("timeout --preserve-status 15s node " + cwd.dir + path.sep + "index.js", { cwd: cwd.dir })
50-
.toString("utf8");
28+
// 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 });
5130

52-
const lines = log.split("\n");
31+
// Store stdout and pipe the output of the child process to the output of this process
32+
const buffer = [];
33+
child.stdout.on("data", (data) => buffer.push(data));
34+
child.stdout.pipe(process.stdout);
35+
child.stderr.pipe(process.stderr);
5336

54-
// Try to find each bundle in the logs.
55-
const missing = bundles.filter(
56-
/*Using endsWith here to remove possible ansi styling of "[info]" caused by ModeCG's logger when run locally*/
57-
(i) => !lines.some((j) => j.endsWith("[nodecg/lib/server/extensions] Mounted " + i + " extension")),
58-
);
59-
60-
// Fail the run if there are missing bundles.
61-
if (missing.length > 0) {
62-
// Only log stout if the run has failed because otherwise its unimportant and everything important should be in stderr
63-
console.log("");
64-
console.log("NodeCG stout");
37+
child.once("exit", (exitCode, signal) => {
6538
console.log("--------------------------------------------------------------------------------");
66-
console.log(log);
39+
console.log("Stopped NodeCG\n");
6740

68-
console.log("");
69-
console.log("Missing Bundles");
70-
console.log("--------------------------------------------------------------------------------");
71-
console.log(missing);
41+
// Check exit code for failure
42+
if (exitCode !== null && exitCode !== 0) {
43+
throw new Error(`NodeCG exited with code ${exitCode} ${signal}`);
44+
}
7245

73-
throw new Error(`NodeCG did not mount ${missing.length} bundle(s).`);
74-
}
46+
const log = Buffer.concat(buffer).toString();
47+
48+
// Try to find each bundle in the logs.
49+
const missing = bundles.filter(
50+
(i) => !log.includes(`[nodecg/lib/server/extensions] Mounted ${i.packageJson.name} extension`),
51+
);
52+
53+
// Fail the run if there are missing bundles.
54+
if (missing.length > 0) {
55+
console.log("Missing Bundles:");
56+
console.log(missing.map((v) => v.packageJson.name));
57+
58+
throw new Error(`NodeCG did not mount ${missing.length} bundle(s).`);
59+
}
60+
61+
console.log("No Errors!");
62+
});

.scripts/exec.mjs

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

44
const COMMAND = process.argv[2];
55

6-
/**@type {import('concurrently').CommandObj[]}*/
6+
/**@type {import('concurrently').ConcurrentlyCommandInput[]}*/
77
const commands = packages
88
.filter((v) => v.packageJson["scripts"] && v.packageJson["scripts"][COMMAND])
99
.map((v) => ({
@@ -43,8 +43,8 @@ const colors = [
4343
if (commands.length > 0) {
4444
concurrently(commands, {
4545
prefixColors: colors,
46-
}).catch(() => {
47-
console.log("At least one build task has failed")
46+
}).result.catch(() => {
47+
console.log("At least one build task has failed");
4848
process.exit(1);
4949
});
5050
}

.scripts/update-paths.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ const tsconfig = {
1414
};
1515

1616
let content = "// This file will be overwritten automatically! Do not store options here.\n" + JSON.stringify(tsconfig);
17+
console.log("Update root tsconfig.json…");
1718
fs.writeFileSync(rootTSconfig, content, { encoding: "utf8" });

0 commit comments

Comments
 (0)