Skip to content

Commit

Permalink
Merge pull request #1074 from codeoverflow-org/migrate/pretty-quick-t…
Browse files Browse the repository at this point in the history
…o-lint-staged

Switch from pretty-quick to lint-staged for auto formatting on commit
  • Loading branch information
hlxid authored Jan 6, 2024
2 parents 6868627 + d43d26b commit 9ac7a7d
Show file tree
Hide file tree
Showing 16 changed files with 1,148 additions and 53 deletions.
49 changes: 24 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ jobs:
tar cvzf compilation-results.tar.gz --exclude "node_modules" **/*.js **/*.js.map **/*.d.ts **/*.d.ts.map **/*.tsbuildinfo **/*.ttf
- name: Upload compilation results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: compilation-results
path: compilation-results.tar.gz
name: compilation-results
path: compilation-results.tar.gz

tests:
runs-on: ubuntu-latest
Expand All @@ -60,8 +60,8 @@ jobs:
# You may check for other NodeCG runtime errors in the output (these
# may not fail the run).
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, windows-2019]
matrix:
os: [ubuntu-22.04, ubuntu-20.04, windows-2019]
runs-on: ${{ matrix.os }}
continue-on-error: true
steps:
Expand All @@ -72,7 +72,7 @@ jobs:
- name: Download NodeCG
uses: actions/checkout@v4
with:
repository: nodecg/nodecg
repository: nodecg/nodecg

- name: Get NodeCG commit hash
id: nodecgHash
Expand All @@ -83,15 +83,15 @@ jobs:
id: cache-nodecg-deps
uses: actions/cache@v3
with:
path: 'node_modules'
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-deps
path: "node_modules"
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-deps

- name: Cache NodeCG compilation outputs
id: cache-nodecg-build
uses: actions/cache@v3
with:
path: 'build'
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-build
path: "build"
key: ${{ runner.os }}-${{ env.NODECG_HASH }}-nodecg-build

- name: Install NodeCG dependencies
# Only get dependencies if we didn't get them from the cache
Expand Down Expand Up @@ -124,14 +124,13 @@ jobs:
- name: Install system dependencies
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-20.04')
run: sudo apt update && sudo apt-get -y install libusb-1.0-0-dev libasound2-dev libudev-dev

- name: Temp patch \#1030 (ubuntu 22.04) – Removing midi services / samples
working-directory: ./nodecg-io
if: matrix.os == 'ubuntu-22.04'
run: |
sudo rm -rf ./services/nodecg-io-midi-*
sudo rm -rf ./samples/midi-*
sudo rm -rf ./services/nodecg-io-midi-*
sudo rm -rf ./samples/midi-*
- name: Install node native development files
shell: bash
Expand Down Expand Up @@ -170,19 +169,19 @@ jobs:
if: startsWith(github.repository, 'codeoverflow-org') && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.ref_type != 'tag'
# Only publish anything if we're sure this version compiles (obviously) and all tests pass.
needs:
- build
- tests
- nodecg
- build
- tests
- nodecg
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.0.1
with:
node-version: "18"
node-version: "18"

- name: Download compilation results # From the build step
uses: actions/download-artifact@v4
with:
name: compilation-results
name: compilation-results

- name: Extract compilation results
run: tar xvf compilation-results.tar.gz
Expand All @@ -195,13 +194,13 @@ jobs:
# to also reference the published tarball.
- name: Patch twitch-auth dependency to use published current tarball
run: |
# Get current version as it is needed for the tarball file name
TWITCH_AUTH_VERSION=$(cat utils/nodecg-io-twitch-auth/package.json | jq .version -r)
# Get current version as it is needed for the tarball file name
TWITCH_AUTH_VERSION=$(cat utils/nodecg-io-twitch-auth/package.json | jq .version -r)
# Find usages in all package.json files and replace with the corresponding tarball url
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print # Print found files for debug purposes
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print0 | \
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"
# Find usages in all package.json files and replace with the corresponding tarball url
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print # Print found files for debug purposes
find . -name 'package.json' -exec grep -q -E '"nodecg-io-twitch-auth": ".+"' {} \; -print0 | \
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"
- name: Create npm tarballs
run: npm pack --workspaces
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run format-pre-commit
npx lint-staged
5 changes: 2 additions & 3 deletions nodecg-io-core/dashboard/bundles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ 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
2 changes: 1 addition & 1 deletion nodecg-io-core/dashboard/panel.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
5 changes: 4 additions & 1 deletion nodecg-io-core/extension/utils/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import NodeCG from "@nodecg/types";

export class Logger {
constructor(private name: string, private nodecg: NodeCG.ServerAPI) {}
constructor(
private name: string,
private nodecg: NodeCG.ServerAPI,
) {}
trace(...args: any[]): void {
this.nodecg.log.trace(`[${this.name}] ${args[0]}`, ...args.slice(1));
}
Expand Down
Loading

0 comments on commit 9ac7a7d

Please sign in to comment.