Skip to content
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
6 changes: 5 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

version: 2
updates:
- package-ecosystem: 'npm' # pnpm is detected automatically via pnpm-lock.yaml
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'monthly'
Expand All @@ -16,6 +16,8 @@ updates:
- '*'
exclude-patterns:
- '@projectwallace/*'
cooldown:
default-days: 7
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
Expand All @@ -24,3 +26,5 @@ updates:
github-actions:
patterns:
- '*'
cooldown:
default-days: 7
78 changes: 78 additions & 0 deletions .github/workflows/dependency-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Dependency Diff

on:
pull_request:
branches: [main]

jobs:
build-base:
name: Pack base branch
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
ref: main
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm run build
- run: pnpm pack --pack-destination ./base-packs
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: base-packages
path: ./base-packs/*.tgz

build-pr:
name: Pack PR branch
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm run build
- run: pnpm pack --pack-destination ./source-packs
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: source-packages
path: ./source-packs/*.tgz

diff-dependencies:
name: Diff dependencies
runs-on: ubuntu-latest
needs: [build-base, build-pr]
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: base-packages
path: ./base-packs
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: source-packages
path: ./source-packs
- uses: e18e/action-dependency-diff@8e9b8c1957ab066d36235a43f4c1ff1522e1bdbc # v1.6.1
with:
base-packages: './base-packs/*.tgz'
source-packages: './source-packs/*.tgz'
pack-size-threshold: -1
duplicate-threshold: 2
89 changes: 74 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,92 @@ on:
release:
types: [created]

permissions:
id-token: write # Required for OIDC provenance attestations
contents: write # Required for pushing version bump commit
permissions: {}

jobs:
publish-npm:
test:
runs-on: ubuntu-latest
permissions: {}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
registry-url: https://registry.npmjs.org/
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: Bump version from release tag
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
node-version: 24
package-manager-cache: false
- run: pnpm install --frozen-lockfile
- run: pnpm test

build:
needs: test
runs-on: ubuntu-latest
permissions: {}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 24
package-manager-cache: false
- run: pnpm install --frozen-lockfile
- run: pnpm run build
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist
path: dist/

bump-version:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: true
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- run: |
VERSION=${GITHUB_REF_NAME#v}
pnpm version $VERSION --no-git-tag-version
- name: Commit and push version bump
env:
DEFAULT_BRANCH: main
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json pnpm-lock.yaml
git commit -m "chore: bump version to $VERSION"
git commit -m "chore: bump version to ${GITHUB_REF_NAME#v}"
git push origin HEAD:$DEFAULT_BRANCH
- run: pnpm test
- run: pnpm run build
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: package-json
path: package.json

publish:
needs: bump-version
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC provenance
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 24
package-manager-cache: false
registry-url: 'https://registry.npmjs.org'
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: dist/
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: package-json
- run: pnpm publish --no-git-checks
68 changes: 31 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Tests

on:
push:
Expand All @@ -14,78 +14,72 @@ jobs:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
cache: 'pnpm'
node-version: 24
- run: pnpm install --frozen-lockfile
- run: pnpm test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: projectwallace/css-time-sort

check:
name: Check types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
cache: 'pnpm'
node-version: 24
- run: pnpm install --frozen-lockfile
- run: pnpm run check

build:
name: Build and inspect bundle size
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
cache: 'pnpm'
node-version: 24
- run: pnpm install --frozen-lockfile
- run: pnpm run build
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
cache: 'pnpm'
node-version: 24
- run: pnpm install --frozen-lockfile
- run: pnpm run lint

pnpm-audit:
npm-audit:
name: Audit packages
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile --ignore-scripts
- name: pnpm audit
run: pnpm audit --audit-level=high
persist-credentials: false
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
- run: pnpm audit --audit-level=high
3 changes: 3 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["./node_modules/@projectwallace/preset-oxlint/index.json"]
}
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const MS_REGEX = /\d+ms$/i
const S_REGEX = /\d+s$/i

/**
* Compare two CSS <time> values
* @param {string} a
Expand All @@ -13,7 +16,7 @@ export function compare(a, b) {

// If times are the same, put ms in front of s
if (A === B) {
return /\d+ms$/i.test(a) ? -1 : 1
return MS_REGEX.test(a) ? -1 : 1
}

return A - B
Expand All @@ -31,11 +34,11 @@ export function compare(a, b) {
* convert('bars') // Number.MAX_SAFE_INTEGER
*/
export function convert(time) {
if (/\d+ms$/i.test(time)) {
if (MS_REGEX.test(time)) {
return Number(time.slice(0, time.length - 2))
}

if (/\d+s$/i.test(time)) {
if (S_REGEX.test(time)) {
return Number(time.slice(0, time.length - 1)) * 1000
}

Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"lint": "oxlint; oxfmt --check"
},
"devDependencies": {
"@codecov/rollup-plugin": "^2.0.1",
"@projectwallace/preset-oxlint": "^0.0.11",
"c8": "^12.0.0",
"oxfmt": "^0.61.0",
"oxlint": "^1.51.0",
Expand All @@ -56,8 +56,5 @@
"pnpm": ">=11.0.0"
},
"packageManager": "pnpm@11.1.1",
"pnpm": {
"onlyBuiltDependencies": []
},
"issues": "https://github.com/projectwallace/css-time-sort/issues"
}
Loading