Skip to content

Commit

Permalink
feat: add tools with generated changelog cli
Browse files Browse the repository at this point in the history
  • Loading branch information
steabert committed Sep 23, 2023
1 parent 36150ca commit 9081d6f
Show file tree
Hide file tree
Showing 27 changed files with 12,608 additions and 511 deletions.
17 changes: 2 additions & 15 deletions .eslint-import-groups.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,16 @@ const externalDeps = [
),
].sort()

const nodeDeps = [
'child_process',
'crypto',
'dgram',
'electron',
'fs',
'http',
'https',
'net',
'os',
'path',
'tls',
'url',
]
const reactDeps = ['react', 'react-dom']
const baseUrlPatterns = ['^[a-z_]']
const parentPatterns = ['^\\.\\.']
const siblingPatterns = ['^\\.']
const nakedImports = ['^\\u0000']
const explicitNodeImports = ['^node:']

module.exports = [
nakedImports,
nodeDeps.map((dep) => `^${dep}$`),
explicitNodeImports,
reactDeps.map((dep) => `^${dep}(\\/|$)`),
externalDeps.map((dep) => `^${dep}(\\/|$)`),
baseUrlPatterns,
Expand Down
11 changes: 8 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ module.exports = {
ecmaFeatures: { jsx: true },
ecmaVersion: 2022,
project: [
'./tsconfig.eslint.json',
'./example-overlay-react/tsconfig.json',
'./overlay/tsconfig.json',
'./player/tsconfig.json',
'./streams/tsconfig.json',
'./example-overlay-react/tsconfig.json',
'./tools/tsconfig.json',
'./tsconfig.eslint.json',
],
sourceType: 'module',
tsconfigRootDir: __dirname,
Expand All @@ -34,5 +35,9 @@ module.exports = {
settings: {
react: { version: '18' },
},
ignorePatterns: ['**/dist/'],
ignorePatterns: [
'**/*.min.js*',
'**/__generated__/',
'**/dist/',
],
}
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
with:
tag_name: ${{ steps.vars.outputs.version }}
release_name: Release ${{ steps.vars.outputs.version }}
body_path: changeset.md
body_path: CHANGELOG.md
draft: false
prerelease: false

Expand Down
43 changes: 34 additions & 9 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set shell := ["bash", "-uc"]

export PATH := "./node_modules/.bin:" + env_var('PATH')
export PATH := "./node_modules/.bin" + ":" + join(justfile_directory(), "node_modules/.bin") + ":" + env_var('PATH')

# just setup -- default when running just with no command
default:
Expand All @@ -13,9 +13,19 @@ build: _build-streams _build-player _build-overlay
@changed:
git diff --diff-filter=d --name-only $(git merge-base --fork-point origin/main)

# create a changelog or changeset
# create a changelog
changelog:
scripts/changelog.mjs --write=CHANGELOG.md > changeset.md
#!/usr/bin/env bash
set -euo pipefail
new_version="$(jq -r .version package.json)"
old_version="$(git show HEAD:package.json | jq -r .version)"
url="$(jq -r .repository.url package.json)"
range=$(just sha v$old_version)..$(just sha HEAD)
changelog $new_version $range --url $url --outfile=CHANGELOG.md
# check if there are uncommitted changes in the workspace
@check-dirty:
git diff --quiet || (echo "workspace dirty!"; git diff; exit 1)

# format or check files with dprint (default formats all matching files)
dprint +args="fmt":
Expand Down Expand Up @@ -62,25 +72,44 @@ rtsp-ws:
set -euo pipefail
trap "kill 0" EXIT SIGINT
scripts/rtsp-server.sh &
scripts/tcp-ws-proxy.cjs >& tcp-ws-proxy.log &
tcp-ws-proxy >& tcp-ws-proxy.log &
wait
# statically serve a directory
serve path *args='--bind 0.0.0.0':
http-server {{ path }} {{ args }}

# get the complete SHA ID for a commit
@sha $commitish='HEAD':
git rev-parse $commitish

# generate tools
tools:
cd tools && esbuild --platform=node --outfile=src/__generated__/changelog.mjs --format=esm --out-extension:.js=.mjs --bundle --external:cmd-ts src/changelog/cli.ts
cd tools && esbuild --platform=node --outfile=src/__generated__/tcp-ws-proxy.mjs --format=esm --out-extension:.js=.mjs --bundle --external:cmd-ts src/tcp-ws-proxy.ts
just dprint fmt 'tools/src/__generated__/*'

# update a specific dependency to latest
update package:
just ncu -u {{ package }}
npm install
npm update --include-workspace-root --workspaces {{ package }}

# CI verification
verify:
just build
just lint .
just test
just tools
just check-dirty

# update the package version of all workspaces
version $level='prerelease':
#!/usr/bin/env bash
current=$(jq -r '.version' package.json)
next=$(semver -i $level --preid alpha $current)
echo "update: $current => $next"
npm version $next --workspace=streams --workspace=player --workspace=overlay
npm version $next --git-tag-version=false --workspace=streams --workspace=player --workspace=overlay --include-workspace-root
# run vite development server, WORKSPACE=(player)
vite WORKSPACE *ARGS:
Expand All @@ -106,10 +135,6 @@ tsc workspace:
uvu path pattern='.*\.test\.tsx?':
c8 -r none --clean=false --src={{ path }} -- tsx --tsconfig {{ path }}/tsconfig.json node_modules/uvu/bin.js {{ path }}/tests/ {{ pattern }}

# get workspace from pathname
@workspace pathname=invocation_directory():
node scripts/top-level-dir.mjs {{ justfile_directory() }} {{ pathname }}

#
# hidden commands (these can be run but they are not shown with just --list)
#
Expand Down
4 changes: 2 additions & 2 deletions overlay/esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import { existsSync, mkdirSync } from 'fs'
import { join } from 'path'
import { existsSync, mkdirSync } from 'node:fs'
import { join } from 'node:path'

import { buildSync } from 'esbuild'

Expand Down
Loading

0 comments on commit 9081d6f

Please sign in to comment.