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

Commit 305bba6

Browse files
authored
Merge pull request #268 from Tim-Tech-Dev/fix/npm-workspaces
Fix/npm workspaces
2 parents f9db3d0 + ee19272 commit 305bba6

File tree

345 files changed

+26505
-37112
lines changed

Some content is hidden

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

345 files changed

+26505
-37112
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@ name: CI
22

33
on: [push, pull_request]
44
jobs:
5-
build:
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v2
9-
- uses: actions/setup-node@v2
10-
with:
11-
node-version: "15"
12-
13-
- name: Install system dependencies
14-
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
15-
16-
- name: Install nodejs dependencies
17-
run: npm ci && npm run bootstrap
18-
19-
- name: Build TS
20-
run: npm run build
21-
22-
tests:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v2
26-
- uses: actions/setup-node@v2
27-
with:
28-
node-version: "15"
29-
30-
- name: Install system dependencies
31-
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
32-
33-
- name: Install nodejs dependencies
34-
run: npm ci && npm run bootstrap
35-
36-
- name: Run tests
37-
run: npm run coverage -- --verbose
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-node@v2
10+
with:
11+
node-version: "15"
12+
13+
- name: Install system dependencies
14+
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
15+
16+
- name: Install nodejs dependencies
17+
run: npm ci
18+
19+
- name: Build TS
20+
run: npm run build
21+
22+
tests:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions/setup-node@v2
27+
with:
28+
node-version: "15"
29+
30+
- name: Install system dependencies
31+
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
32+
33+
- name: Install nodejs dependencies
34+
run: npm ci
35+
36+
- name: Run tests
37+
run: npm run coverage -- --verbose

.github/workflows/docs.yml

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
1-
21
name: Update docs
32

43
on:
5-
push:
6-
branches:
7-
- master
8-
- "release/**"
4+
push:
5+
branches:
6+
- master
7+
- "release/**"
98

109
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
if: startsWith(github.repository, 'codeoverflow-org') # don't run this in forks
14-
steps:
15-
16-
- name: Setup Python
17-
uses: actions/setup-python@v2
18-
with:
19-
python-version: 3.8.3
20-
21-
- uses: actions/checkout@v2
22-
23-
- name: Checkout docs
24-
uses: actions/checkout@v2
25-
with:
26-
repository: codeoverflow-org/nodecg-io-docs
27-
path: docs
28-
ssh-key: ${{ secrets.DOCS_SSH_KEY }}
29-
ref: ${{ github.ref }}
10+
build:
11+
runs-on: ubuntu-latest
12+
if: startsWith(github.repository, 'codeoverflow-org') # don't run this in forks
13+
steps:
14+
- name: Setup Python
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.8.3
18+
19+
- uses: actions/checkout@v2
20+
21+
- name: Checkout docs
22+
uses: actions/checkout@v2
23+
with:
24+
repository: codeoverflow-org/nodecg-io-docs
25+
path: docs
26+
ssh-key: ${{ secrets.DOCS_SSH_KEY }}
27+
ref: ${{ github.ref }}
3028

31-
- name: Build docs
32-
run: python .scripts/build-docs.py
29+
- name: Build docs
30+
run: python .scripts/build-docs.py
3331

34-
- name: GitHub Push
35-
run: |
36-
cd docs
37-
git config --global user.email "<>"
38-
git config --global user.name "codeoverflow-org"
39-
git add .
40-
git diff-index --quiet HEAD || git commit --message "Update generated documentation (codeoverflow-org/nodecg-io@${{ github.sha }})"
41-
git push origin "${GITHUB_REF#refs/heads/}"
32+
- name: GitHub Push
33+
run: |
34+
cd docs
35+
git config --global user.email "<>"
36+
git config --global user.name "codeoverflow-org"
37+
git add .
38+
git diff-index --quiet HEAD || git commit --message "Update generated documentation (codeoverflow-org/nodecg-io@${{ github.sha }})"
39+
git push origin "${GITHUB_REF#refs/heads/}"

.github/workflows/lint.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ name: Linter
22

33
on: pull_request
44
jobs:
5-
build:
6-
runs-on: ubuntu-latest
7-
steps:
8-
- uses: actions/checkout@v2
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
99

10-
- uses: actions/setup-node@v2
11-
with:
12-
node-version: "15"
10+
- uses: actions/setup-node@v2
11+
with:
12+
node-version: "15"
1313

14-
- name: Install nodejs dependencies
15-
run: npm i
16-
- name: Run ESLint
17-
run: npm run lint
14+
- name: Install system dependencies
15+
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev
16+
17+
- name: Install nodejs dependencies
18+
run: npm i
19+
20+
- name: Run ESLint
21+
run: npm run lint

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ node_modules/
1010
# generated type definitions
1111
*.d.ts
1212

13+
# generated source mapping files
14+
*.d.ts.map
15+
16+
# generated build info
17+
*.tsbuildinfo
18+
1319
# Coverage reports by jest
1420
coverage
1521

.scripts/create-service.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# What this file does:
44
# + It creates all required files for a new nodecg-io service
5-
# + It copies version and dependency information (e.q fpr typescript) from noodecg-io-template
5+
# + It copies version and dependency information (e.g., for typescript) from noodecg-io-template
66
# + It'll also create a sample and the files for the docs
77
#
88
# Requirements:
@@ -22,7 +22,7 @@
2222
service_name_c = service_name.replace("-", " ").title().replace(" ", "")
2323
service_name_cc = service_name_c[0].lower() + service_name_c[1:]
2424

25-
with open('nodecg-io-template/package.json') as file:
25+
with open('services/nodecg-io-template/package.json') as file:
2626
package = json.loads(file.read())
2727

2828
# Replace some entries from the template package.json
@@ -33,17 +33,19 @@
3333
'name': author_name,
3434
'url': author_url
3535
}
36-
package['repository']['directory'] = f'nodecg-io-{service_name}'
36+
package['repository']['directory'] = f'services/nodecg-io-{service_name}'
3737

38-
os.mkdir(f'nodecg-io-{service_name}')
39-
with open(f'nodecg-io-{service_name}/package.json', mode='w') as file:
38+
os.mkdir(f'services/nodecg-io-{service_name}')
39+
with open(f'services/nodecg-io-{service_name}/package.json', mode='w') as file:
4040
file.write(json.dumps(package, indent=4))
4141

42-
shutil.copy('nodecg-io-template/schema.json', f'nodecg-io-{service_name}/schema.json')
43-
shutil.copy('nodecg-io-template/tsconfig.json', f'nodecg-io-{service_name}/tsconfig.json')
42+
shutil.copy('services/nodecg-io-template/schema.json',
43+
f'services/nodecg-io-{service_name}/schema.json')
44+
shutil.copy('services/nodecg-io-template/tsconfig.json',
45+
f'services/nodecg-io-{service_name}/tsconfig.json')
4446

45-
os.mkdir(f'nodecg-io-{service_name}/extension')
46-
with open(f'nodecg-io-{service_name}/extension/index.ts', mode='w') as file:
47+
os.mkdir(f'services/nodecg-io-{service_name}/extension')
48+
with open(f'services/nodecg-io-{service_name}/extension/index.ts', mode='w') as file:
4749
file.writelines([
4850
'import { NodeCG } from "nodecg-types/types/server";\n',
4951
'import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core";\n',
@@ -83,7 +85,7 @@
8385
'}\n'
8486
])
8587

86-
with open(f'nodecg-io-{service_name}/extension/{service_name_cc}Client.ts', mode='w') as file:
88+
with open(f'services/nodecg-io-{service_name}/extension/{service_name_cc}Client.ts', mode='w') as file:
8789
file.writelines([
8890
f'import {{ {service_name_c}Config }} from "./index";\n',
8991
'\n',
@@ -119,7 +121,16 @@
119121
with open(f'samples/{sample_name}/package.json', mode='w') as file:
120122
file.write(json.dumps(sample_package, indent=4))
121123

122-
shutil.copy('samples/template/tsconfig.json', f'samples/{sample_name}/tsconfig.json')
124+
with open('samples/template/tsconfig.json') as file:
125+
sample_tsconfig = json.loads(file.read())
126+
127+
# Replace reference in template tsconfig.json
128+
129+
sample_tsconfig['references'][1]["path"] = sample_tsconfig['references'][1]["path"].replace(
130+
'template', service_name)
131+
132+
with open(f'samples/{sample_name}/tsconfig.json', mode='w') as file:
133+
file.write(json.dumps(sample_tsconfig, indent=4))
123134

124135
os.mkdir(f'samples/{sample_name}/extension')
125136
with open(f'samples/{sample_name}/extension/index.ts', mode='w') as file:
@@ -157,6 +168,7 @@
157168
'You can help us [create it](../contribute/sample_documentation.md).'
158169
])
159170

160-
os.system('npm run bsb')
171+
os.system('npm install')
172+
os.system('npm run rebuild')
161173

162174
print(f"\n\nService {service_name_c} created. Please add it to mkdocs.yml")

.scripts/update-paths.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as fs from "fs";
2+
3+
const DIRS = ["./samples", "./services", "./utils"];
4+
5+
for (const dir of DIRS) {
6+
let tsconfig = {
7+
files: [],
8+
references: []
9+
}
10+
let contents = fs.opendirSync(dir);
11+
let item;
12+
while ((item = contents.readSync()) !== null) {
13+
if (item.isDirectory() && fs.readdirSync(`${dir}/${item.name}`).includes("tsconfig.json")) {
14+
tsconfig.references.push({
15+
path: "./" + item.name
16+
})
17+
}
18+
}
19+
20+
let content = "// This file will be overwritten automatically! Do not store options here.\n" + JSON.stringify(tsconfig)
21+
fs.writeFileSync(dir + "/tsconfig.json", content, { encoding: "utf8" });
22+
}

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
// Hides js, js map and ts definition files, that are generated by the build process, in the explorer windows of vs code
33
"vscode.tsc.compiler.alertTSConfigChanges": "never",
44
"files.exclude": {
5-
"**/*.js": { "when": "$(basename).ts" },
5+
"**/*.js": {
6+
"when": "$(basename).ts"
7+
},
68
"**/*.js.map": true,
7-
"**/*.d.ts": { "when": "$(basename).ts" }
9+
"**/*.d.ts": {
10+
"when": "$(basename).ts"
11+
},
12+
"**/*.d.ts.map": true,
13+
"**/*.tsbuildinfo": true
814
}
915
}

lerna.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

nodecg-io-ahk/tsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

nodecg-io-android/tsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

nodecg-io-artnet/tsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

nodecg-io-core/dashboard/bundles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ export function renderInstanceSelector(): void {
7777
return;
7878
}
7979

80-
const currentInstance = config.data.bundles[bundle]?.find((dep) => dep.serviceType === serviceType)
81-
?.serviceInstance;
80+
const currentInstance = config.data.bundles[bundle]?.find(
81+
(dep) => dep.serviceType === serviceType,
82+
)?.serviceInstance;
8283

8384
let index = 0;
8485
for (let i = 0; i < selectBundleInstance.options.length; i++) {

nodecg-io-core/dashboard/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
},
88
"devDependencies": {
99
"clean-webpack-plugin": "^3.0.0",
10-
"ts-loader": "^9.1.2",
1110
"typescript": "^4.2.4",
1211
"webpack": "^5.36.2",
1312
"webpack-cli": "^4.7.0"

nodecg-io-core/dashboard/panel.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
<script src="./dist/main.bundle.js"></script>
9494

9595
<!-- monaco is manually included because when including it using webpack it created formatting issues. -->
96-
<script src="node_modules/monaco-editor/min/vs/loader.js"></script>
96+
<script src="../modules/monaco-editor/min/vs/loader.js"></script>
9797
<script>
98-
require.config({ paths: { vs: "node_modules/monaco-editor/min/vs" } });
98+
require.config({ paths: { vs: "../modules/monaco-editor/min/vs" } });
9999
require(["vs/editor/editor.main"], onMonacoReady);
100100
</script>
101101
</body>

nodecg-io-core/dashboard/serviceInstance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export async function saveInstanceConfig(): Promise<void> {
139139
showNotice("Successfully saved.");
140140
} catch (err) {
141141
nodecg.log.error(`Couldn't save instance config: ${err}`);
142-
showNotice(err);
142+
showNotice(String(err));
143143
}
144144
}
145145

@@ -173,7 +173,7 @@ export async function createInstance(): Promise<void> {
173173
try {
174174
await sendAuthenticatedMessage("createServiceInstance", msg);
175175
} catch (e) {
176-
showNotice(e);
176+
showNotice(String(e));
177177
return;
178178
}
179179

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2+
"extends": "../../tsconfig.common.json",
23
"compilerOptions": {
34
"target": "ES2015",
4-
55
"lib": ["ES2015", "dom"],
6-
"module": "ES2015",
7-
"sourceMap": true,
8-
"declaration": false
6+
"module": "ES2015"
97
},
10-
"extends": "../../tsconfig.common.json"
8+
"references": [
9+
{
10+
"path": "../"
11+
}
12+
]
1113
}

0 commit comments

Comments
 (0)