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

Fix/npm workspaces #268

Merged
merged 7 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
66 changes: 33 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ name: CI

on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "15"

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

- name: Install nodejs dependencies
run: npm ci && npm run bootstrap

- name: Build TS
run: npm run build

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "15"

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

- name: Install nodejs dependencies
run: npm ci && npm run bootstrap

- name: Run tests
run: npm run coverage -- --verbose
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "15"

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

- name: Install nodejs dependencies
run: npm ci

- name: Build TS
run: npm run build

tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "15"

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

- name: Install nodejs dependencies
run: npm ci

- name: Run tests
run: npm run coverage -- --verbose
66 changes: 32 additions & 34 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@

name: Update docs

on:
push:
branches:
- master
- "release/**"
push:
branches:
- master
- "release/**"

jobs:
build:
runs-on: ubuntu-latest
if: startsWith(github.repository, 'codeoverflow-org') # don't run this in forks
steps:

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8.3

- uses: actions/checkout@v2

- name: Checkout docs
uses: actions/checkout@v2
with:
repository: codeoverflow-org/nodecg-io-docs
path: docs
ssh-key: ${{ secrets.DOCS_SSH_KEY }}
ref: ${{ github.ref }}
build:
runs-on: ubuntu-latest
if: startsWith(github.repository, 'codeoverflow-org') # don't run this in forks
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8.3

- uses: actions/checkout@v2

- name: Checkout docs
uses: actions/checkout@v2
with:
repository: codeoverflow-org/nodecg-io-docs
path: docs
ssh-key: ${{ secrets.DOCS_SSH_KEY }}
ref: ${{ github.ref }}

- name: Build docs
run: python .scripts/build-docs.py
- name: Build docs
run: python .scripts/build-docs.py

- name: GitHub Push
run: |
cd docs
git config --global user.email "<>"
git config --global user.name "codeoverflow-org"
git add .
git diff-index --quiet HEAD || git commit --message "Update generated documentation (codeoverflow-org/nodecg-io@${{ github.sha }})"
git push origin "${GITHUB_REF#refs/heads/}"
- name: GitHub Push
run: |
cd docs
git config --global user.email "<>"
git config --global user.name "codeoverflow-org"
git add .
git diff-index --quiet HEAD || git commit --message "Update generated documentation (codeoverflow-org/nodecg-io@${{ github.sha }})"
git push origin "${GITHUB_REF#refs/heads/}"
26 changes: 15 additions & 11 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ name: Linter

on: pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: "15"
- uses: actions/setup-node@v2
with:
node-version: "15"

- name: Install nodejs dependencies
run: npm i
- name: Run ESLint
run: npm run lint
- name: Install system dependencies
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev

- name: Install nodejs dependencies
run: npm i

- name: Run ESLint
run: npm run lint
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ node_modules/
# generated type definitions
*.d.ts

# generated source mapping files
*.d.ts.map

# generated build info
*.tsbuildinfo

# Coverage reports by jest
coverage

Expand Down
36 changes: 24 additions & 12 deletions .scripts/create-service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# What this file does:
# + It creates all required files for a new nodecg-io service
# + It copies version and dependency information (e.q fpr typescript) from noodecg-io-template
# + 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:
Expand All @@ -22,7 +22,7 @@
service_name_c = service_name.replace("-", " ").title().replace(" ", "")
service_name_cc = service_name_c[0].lower() + service_name_c[1:]

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

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

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

shutil.copy('nodecg-io-template/schema.json', f'nodecg-io-{service_name}/schema.json')
shutil.copy('nodecg-io-template/tsconfig.json', f'nodecg-io-{service_name}/tsconfig.json')
shutil.copy('services/nodecg-io-template/schema.json',
f'services/nodecg-io-{service_name}/schema.json')
shutil.copy('services/nodecg-io-template/tsconfig.json',
f'services/nodecg-io-{service_name}/tsconfig.json')

os.mkdir(f'nodecg-io-{service_name}/extension')
with open(f'nodecg-io-{service_name}/extension/index.ts', mode='w') as file:
os.mkdir(f'services/nodecg-io-{service_name}/extension')
with open(f'services/nodecg-io-{service_name}/extension/index.ts', mode='w') as file:
file.writelines([
'import { NodeCG } from "nodecg-types/types/server";\n',
'import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core";\n',
Expand Down Expand Up @@ -83,7 +85,7 @@
'}\n'
])

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

shutil.copy('samples/template/tsconfig.json', f'samples/{sample_name}/tsconfig.json')
with open('samples/template/tsconfig.json') as file:
sample_tsconfig = json.loads(file.read())

# Replace reference in template tsconfig.json

sample_tsconfig['references'][1]["path"] = sample_tsconfig['references'][1]["path"].replace(
'template', service_name)

with open(f'samples/{sample_name}/tsconfig.json', mode='w') as file:
file.write(json.dumps(sample_tsconfig, indent=4))

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

os.system('npm run bsb')
os.system('npm install')
os.system('npm run rebuild')

print(f"\n\nService {service_name_c} created. Please add it to mkdocs.yml")
22 changes: 22 additions & 0 deletions .scripts/update-paths.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as fs from "fs";

const DIRS = ["./samples", "./services", "./utils"];

for (const dir of DIRS) {
let tsconfig = {
files: [],
references: []
}
let contents = fs.opendirSync(dir);
let item;
while ((item = contents.readSync()) !== null) {
if (item.isDirectory() && fs.readdirSync(`${dir}/${item.name}`).includes("tsconfig.json")) {
tsconfig.references.push({
path: "./" + item.name
})
}
}

let content = "// This file will be overwritten automatically! Do not store options here.\n" + JSON.stringify(tsconfig)
fs.writeFileSync(dir + "/tsconfig.json", content, { encoding: "utf8" });
}
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
// Hides js, js map and ts definition files, that are generated by the build process, in the explorer windows of vs code
"vscode.tsc.compiler.alertTSConfigChanges": "never",
"files.exclude": {
"**/*.js": { "when": "$(basename).ts" },
"**/*.js": {
"when": "$(basename).ts"
},
"**/*.js.map": true,
"**/*.d.ts": { "when": "$(basename).ts" }
"**/*.d.ts": {
"when": "$(basename).ts"
},
"**/*.d.ts.map": true,
"**/*.tsbuildinfo": true
}
}
4 changes: 0 additions & 4 deletions lerna.json

This file was deleted.

3 changes: 0 additions & 3 deletions nodecg-io-ahk/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions nodecg-io-android/tsconfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions nodecg-io-artnet/tsconfig.json

This file was deleted.

5 changes: 3 additions & 2 deletions nodecg-io-core/dashboard/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export function renderInstanceSelector(): void {
return;
}

const currentInstance = config.data.bundles[bundle]?.find((dep) => dep.serviceType === serviceType)
?.serviceInstance;
const currentInstance = config.data.bundles[bundle]?.find(
(dep) => dep.serviceType === serviceType,
)?.serviceInstance;

let index = 0;
for (let i = 0; i < selectBundleInstance.options.length; i++) {
Expand Down
1 change: 0 additions & 1 deletion nodecg-io-core/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"ts-loader": "^9.1.2",
"typescript": "^4.2.4",
"webpack": "^5.36.2",
"webpack-cli": "^4.7.0"
Expand Down
4 changes: 2 additions & 2 deletions nodecg-io-core/dashboard/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@
<script src="./dist/main.bundle.js"></script>

<!-- monaco is manually included because when including it using webpack it created formatting issues. -->
<script src="node_modules/monaco-editor/min/vs/loader.js"></script>
<script src="../modules/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { vs: "node_modules/monaco-editor/min/vs" } });
require.config({ paths: { vs: "../modules/monaco-editor/min/vs" } });
require(["vs/editor/editor.main"], onMonacoReady);
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions nodecg-io-core/dashboard/serviceInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function saveInstanceConfig(): Promise<void> {
showNotice("Successfully saved.");
} catch (err) {
nodecg.log.error(`Couldn't save instance config: ${err}`);
showNotice(err);
showNotice(String(err));
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ export async function createInstance(): Promise<void> {
try {
await sendAuthenticatedMessage("createServiceInstance", msg);
} catch (e) {
showNotice(e);
showNotice(String(e));
return;
}

Expand Down
12 changes: 7 additions & 5 deletions nodecg-io-core/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"extends": "../../tsconfig.common.json",
"compilerOptions": {
"target": "ES2015",

"lib": ["ES2015", "dom"],
"module": "ES2015",
"sourceMap": true,
"declaration": false
"module": "ES2015"
},
"extends": "../../tsconfig.common.json"
"references": [
{
"path": "../"
}
]
}
Loading