Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1be8414
💥 First draft of v1.0 luxon-style code, expanded to support a lot mor…
ammuench Aug 11, 2025
9f664fa
🚨 Fix linter, run it
ammuench Aug 11, 2025
9a5687a
🚚 Rearrange code layout, clean up textContrast outputs
ammuench Aug 12, 2025
ddac686
♻️ Refactor types
ammuench Aug 12, 2025
7e012d1
🎨 Add overloads for types, write util tests
ammuench Aug 12, 2025
ce81145
🔧 Fix exports, rename entrypoint file
ammuench Aug 12, 2025
969cc49
✅ First-pass on core module tests
ammuench Aug 15, 2025
2ede29f
♻️ Clean up contrast tests
ammuench Aug 16, 2025
6355c97
🐛 Fix HSL parsing, update tests to stress parsing better
ammuench Aug 16, 2025
2cc616f
✅ Update tests to use reference values, clean up structure
ammuench Aug 16, 2025
619f5bb
📝 add jsdoc for all methods
ammuench Aug 16, 2025
a84eb80
🔧 Add config options for parsing
ammuench Aug 16, 2025
72cb630
✅ Add tests for new parseopts config
ammuench Aug 16, 2025
8be58b1
🚚 Move reference color files to more appropriate directory
ammuench Aug 16, 2025
e9ace55
📝 Update README, add some type comments
ammuench Aug 17, 2025
298a64c
💚 Add ci quality, build and publish stuff
ammuench Aug 17, 2025
21e6abb
💚 update CI to run on every PR, fix dupe
ammuench Aug 17, 2025
4965ee0
💚 Drop deno 1.x test running (it wasn't worth it)
ammuench Aug 17, 2025
45909c3
💚 Drop code coverage uploading for now
ammuench Aug 17, 2025
1f8c2f4
Merge pull request #1 from ammuench/feature/v1.0.0-buildscripts
ammuench Aug 17, 2025
efde402
💚 Update CI build upload artifact script
ammuench Aug 17, 2025
5585597
💚 Update npm build script, add new attw check to
ammuench Aug 17, 2025
a9a5324
✅ Add tests to bring up coverage, clean up deno, package.json files
ammuench Aug 17, 2025
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
44 changes: 44 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR Validation

on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build-validation:
name: Build Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Build NPM package
run: deno run -A scripts/build_npm.ts

- name: Verify NPM package structure
run: |
test -f npm/package.json
test -d npm/esm
test -d npm/script

- name: Test NPM package can be imported
working-directory: npm
run: |
npm install
node -e "const contrastrast = require('./script/mod.js'); console.log('NPM package import successful')"

- name: Validate TypeScript types with attw
run: npx @arethetypeswrong/cli --pack ./npm

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: npm-package
path: npm/
retention-days: 7
84 changes: 84 additions & 0 deletions .github/workflows/publish-jsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Publish to JSR

on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (e.g., v1.0.0)"
required: true
type: string

jobs:
validate:
name: Pre-publish Validation
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Publishing version: ${VERSION}"

- name: Verify version in deno.json matches tag
run: |
DENO_VERSION=$(jq -r '.version' deno.json)
TAG_VERSION="${{ steps.version.outputs.version }}"
TAG_VERSION_CLEAN="${TAG_VERSION#v}"

if [ "$DENO_VERSION" != "$TAG_VERSION_CLEAN" ]; then
echo "Error: Version mismatch!"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION_CLEAN"
exit 1
fi

- name: Run quality checks
run: |
deno fmt --check
deno lint
deno test

publish:
name: Publish to JSR
runs-on: ubuntu-latest
needs: validate
environment: publishing
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Publish to JSR
env:
JSR_TOKEN: ${{ secrets.JSR_TOKEN }}
run: deno publish

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.validate.outputs.version }}
name: Release ${{ needs.validate.outputs.version }}
generate_release_notes: true
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
122 changes: 122 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Publish to NPM

on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (e.g., v1.0.0)"
required: true
type: string

jobs:
validate:
name: Pre-publish Validation
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Extract version from tag
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Publishing version: ${VERSION}"

- name: Verify version in deno.json matches tag
run: |
DENO_VERSION=$(jq -r '.version' deno.json)
TAG_VERSION="${{ steps.version.outputs.version }}"
TAG_VERSION_CLEAN="${TAG_VERSION#v}"

if [ "$DENO_VERSION" != "$TAG_VERSION_CLEAN" ]; then
echo "Error: Version mismatch!"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION_CLEAN"
exit 1
fi

- name: Run quality checks
run: |
deno fmt --check
deno lint
deno test

build-and-publish:
name: Build and Publish to NPM
runs-on: ubuntu-latest
needs: validate
environment: publishing
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

- name: Build NPM package with dnt
run: deno run -A scripts/build_npm.ts

- name: Verify NPM package version matches tag
run: |
NPM_VERSION=$(jq -r '.version' npm/package.json)
TAG_VERSION="${{ needs.validate.outputs.version }}"
TAG_VERSION_CLEAN="${TAG_VERSION#v}"

if [ "$NPM_VERSION" != "$TAG_VERSION_CLEAN" ]; then
echo "Error: NPM package version mismatch!"
echo "npm/package.json version: $NPM_VERSION"
echo "Tag version: $TAG_VERSION_CLEAN"
exit 1
fi

- name: Verify package structure
run: |
test -f npm/package.json
test -d npm/esm
test -d npm/script
test -f npm/LICENSE
test -f npm/README.md

- name: Test NPM package imports
working-directory: npm
run: |
# Test CommonJS import
node -e "const contrastrast = require('./script/mod.js'); console.log('CommonJS import successful:', typeof contrastrast);"

# Test ESM import
node -e "import('./esm/mod.js').then(m => console.log('ESM import successful:', typeof m.default || typeof m));"

- name: Publish to NPM
working-directory: npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [[ "${{ needs.validate.outputs.version }}" == *"-"* ]]; then
echo "Publishing non-stable release with beta tag"
npm publish --tag beta
else
echo "Publishing stable release"
npm publish
fi
52 changes: 52 additions & 0 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Quality Checks

on:
pull_request:
workflow_dispatch:

jobs:
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Check formatting
run: deno fmt --check

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Run linter
run: deno lint

test:
name: Test w/ Deno
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x

- name: Run tests
run: deno test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ coverage

# Build artifacts
npm/

# Development and planning
__SPECS__/
demo.ts

.env
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deno run lint-staged
deno task lint-staged
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"*.{js,ts,cjs}": ["deno lint --fix", "deno fmt"],
"*.{json,md}": "deno fmt",
"*.{json,md}": "deno fmt"
}

Loading