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
9 changes: 0 additions & 9 deletions bun.lock

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

149 changes: 68 additions & 81 deletions dist/index.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions dist/index.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@elide-dev/format",
"description": "GitHub Action to check source formatting using Elide",
"version": "1.1.0",
"version": "1.1.2",
"author": "Elide Team (https://elide.dev)",
"private": true,
"homepage": "https://github.com/elide-dev/format",
Expand Down Expand Up @@ -31,8 +31,7 @@
"dependencies": {
"@actions/core": "3.0.1",
"@actions/exec": "3.0.0",
"@sentry/node": "^10.63.0",
"syntax": "^1.6.3"
"@sentry/node": "^10.63.0"
},
"devDependencies": {
"@biomejs/biome": "^2.5.2",
Expand All @@ -48,8 +47,7 @@
"turbo:build": "bun run turbo build --token $BUILDLESS_APIKEY --no-daemon --remote-only",
"turbo:test": "bun run turbo test --token $BUILDLESS_APIKEY --no-daemon --remote-only",
"build": "bun run bundle",
"bundle": "bun run format:write && bun run vendor && bun run package",
"vendor": "node scripts/vendor-syntax.mjs",
"bundle": "bun run format:write && bun run package",
"ci:build": "bun run turbo:build",
"ci:test": "bun run turbo:test",
"format:write": "biome format --write src __tests__",
Expand Down
45 changes: 0 additions & 45 deletions scripts/vendor-syntax.mjs

This file was deleted.

51 changes: 7 additions & 44 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as core from '@actions/core'
import { readdirSync, statSync } from 'node:fs'
import path from 'node:path'
import Syntax from './vendor/syntax.cjs'
import buildOptions, {
buildOptionsFromInputs,
type ElideFormatActionOptions,
Expand Down Expand Up @@ -172,38 +171,15 @@ function shellQuote(p: string): string {
return `'${p.replace(/'/g, "'\\''")}'`
}

const MARKUP_COLORS: Record<string, string> = {
comment: '\x1b[2m',
keyword: '\x1b[34m',
literal: '\x1b[33m'
}

function applyMarkup(text: string, markup: Record<string, unknown>): string {
const ranges: { start: number; end: number; color: string }[] = []
for (const [type, spans] of Object.entries(markup)) {
const color = MARKUP_COLORS[type]
if (!color || !Array.isArray(spans)) continue
for (const span of spans) {
const [start, end] = span as [number, number]
ranges.push({ start, end, color })
}
}
ranges.sort((a, b) => a.start - b.start)
let result = ''
let pos = 0
for (const { start, end, color } of ranges) {
result += text.slice(pos, start)
result += color + text.slice(start, end) + '\x1b[0m'
pos = end
}
return result + text.slice(pos)
}

function addDiffLineColors(text: string): string {
return text
export function formatDiff(
_formatter: FormatterName,
diffText: string
): string {
return diffText
.split('\n')
.map(line => {
if (line.startsWith('---') || line.startsWith('+++')) return line
if (line.startsWith('---') || line.startsWith('+++'))
return `\x1b[2m${line}\x1b[0m`
if (line.startsWith('@@')) return `\x1b[36m${line}\x1b[0m`
if (line.startsWith('+')) return `\x1b[32m${line}\x1b[0m`
if (line.startsWith('-')) return `\x1b[31m${line}\x1b[0m`
Expand All @@ -212,19 +188,6 @@ function addDiffLineColors(text: string): string {
.join('\n')
}

export function formatDiff(
_formatter: FormatterName,
diffText: string
): string {
try {
const syn = new Syntax({ language: 'diff', cssPrefix: '' })
syn.richtext(diffText)
return addDiffLineColors(applyMarkup(diffText, syn.markup()))
} catch {
return addDiffLineColors(diffText)
}
}

export function printOutputModeResult(
outputMode: OutputMode,
formatter: FormatterName,
Expand Down
12 changes: 0 additions & 12 deletions src/syntax.d.ts

This file was deleted.

Loading
Loading