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
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: NPM Publish

on:
release:
types: [created]

permissions:
id-token: write # Required for OIDC
contents: read

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- run: npm install -g npm@latest
- run: npm ci --ignore-scripts --no-fund --no-audit
- run: npm test
- run: npm run build
- run: npm publish --access public
81 changes: 66 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Test
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Tests

on:
push:
Expand All @@ -8,20 +11,68 @@ on:

jobs:
test:
name: Node.js v${{ matrix.nodejs }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 3
strategy:
matrix:
nodejs: [18, 20, 22]
os: [ubuntu-latest]
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: 'npm'
node-version: 22
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm test

check:
name: Check types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: 'npm'
node-version: 22
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm run check --if-present

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: 'npm'
node-version: 22
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm run build

lint-pkg:
name: Lint package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: 'npm'
node-version: 22
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm run build
- run: npm run lint-package

npm-audit:
name: Audit packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Checkout code
uses: actions/checkout@v6
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.nodejs }}
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Run tests
run: npm test
node-version: 22
- run: npm audit --audit-level=high
80 changes: 72 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/projectwallace/wallace-cli"
"url": "git+https://github.com/projectwallace/wallace-cli.git"
},
"keywords": [
"stylesheets",
Expand All @@ -21,29 +21,30 @@
"stats",
"statistics",
"cli",
"cli-app",
"projectwallace",
"wallace",
"terminal",
"performance"
],
"engines": {
"node": ">=18"
"node": ">=20.12.0"
},
"scripts": {
"pretest": "npm run build",
"test": "uvu",
"build": "esbuild --bundle ./src/bin.js --outfile=./dist/cli.cjs --platform=node --format=cjs --minify"
"build": "esbuild --bundle ./src/bin.js --outfile=./dist/cli.js --platform=node --format=esm --external:@projectwallace/css-analyzer",
"lint-package": "publint"
},
"bin": {
"wallace": "./dist/cli.cjs"
"wallace": "./dist/cli.js"
},
"files": [
"dist"
],
"dependencies": {
"@projectwallace/css-analyzer": "^9.3.0"
},
"devDependencies": {
"@projectwallace/css-analyzer": "^9.3.0",
"esbuild": "^0.27.3",
"picocolors": "^1.1.1",
"publint": "^0.3.18",
"uvu": "^0.5.6"
}
}
10 changes: 9 additions & 1 deletion src/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

import { readFile as fsReadFile } from 'fs/promises'
import { join } from 'path'
import pc from 'picocolors'
import { styleText } from 'util'
import { Program } from './program'

const pc = {
bold: str => styleText('bold', str),
dim: str => styleText('dim', str),
italic: str => styleText('italic', str),
underline: str => styleText('underline', str),
red: str => styleText('red', str),
}

async function get_stdin() {
const { stdin } = process
if (stdin.isTTY) {
Expand Down