Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tools with generated changelog cli #763

Merged
merged 1 commit into from
Sep 23, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
40 changes: 32 additions & 8 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 @@ -69,18 +79,36 @@ rtsp-ws:
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
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 +134,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