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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"scripts": {
"prepare": "pnpm run check prepare --pre-commit",
"check": "pnpm exec --filter=./packages/uncheck unbuild --stub && uncheck",
"check": "pnpm exec --filter=./packages/uncheck obuild --stub && uncheck",
"fix": "pnpm run check --fix",
"test": "pnpm run -r test && vitest run",
"test:coverage": "pnpm run -r test && vitest run --coverage",
Expand All @@ -20,12 +20,12 @@
"@vitest/coverage-v8": "^5.0.1",
"bumpp": "^12.3.0",
"changelogithub": "^15.0.5",
"obuild": "^0.4.43",
"oxfmt": "^0.68.0",
"oxlint": "^1.83.0",
"pkg-pr-new": "^0.0.88",
"sherif": "^1.13.0",
"typescript": "^7.0.2",
"unbuild": "^3.6.1",
"uncheck": "workspace:*",
"vitest": "^5.0.1"
},
Expand Down
13 changes: 9 additions & 4 deletions packages/uncheck/build.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { defineBuildConfig } from 'unbuild'
import { defineBuildConfig } from 'obuild/config'

export default defineBuildConfig({
rollup: {
inlineDependencies: true,
},
entries: [
{
type: 'bundle',
input: ['./src/bin.ts', './src/presets/oxfmt.ts', './src/presets/oxlint.ts'],
minifyLibs: true,
dts: { sourcemap: false },
},
],
})
2 changes: 1 addition & 1 deletion packages/uncheck/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"./package.json": "./package.json"
},
"scripts": {
"prepack": "unbuild"
"prepack": "obuild"
},
"devDependencies": {
"@effect/platform-node": "^4.0.0-rc.116",
Expand Down
2 changes: 1 addition & 1 deletion packages/uncheck/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import { enableCompileCache } from 'node:module'
// The cache only covers modules compiled after it is on, hence the import that follows it.
enableCompileCache()

await import('./cli')
await import('./cli.ts')
6 changes: 3 additions & 3 deletions packages/uncheck/src/checks/oxfmt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Effect } from 'effect'

import { NothingToCheck } from '../errors'
import { argvBatches, resolveBin } from '../tool'
import type { Check } from '../types'
import { NothingToCheck } from '../errors.ts'
import { argvBatches, resolveBin } from '../tool.ts'
import type { Check } from '../types.ts'

export const oxfmt: Check = {
name: 'oxfmt',
Expand Down
6 changes: 3 additions & 3 deletions packages/uncheck/src/checks/oxlint.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Effect } from 'effect'

import { NothingToCheck } from '../errors'
import { argvBatches, resolveBin } from '../tool'
import type { Check } from '../types'
import { NothingToCheck } from '../errors.ts'
import { argvBatches, resolveBin } from '../tool.ts'
import type { Check } from '../types.ts'

export const oxlint: Check = {
name: 'oxlint',
Expand Down
8 changes: 4 additions & 4 deletions packages/uncheck/src/checks/sherif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import process from 'node:process'

import { Effect, Path, Predicate } from 'effect'

import { CannotCheck, NothingToCheck } from '../errors'
import { isWorkspaceRoot, readJson } from '../files'
import { resolveBin } from '../tool'
import type { Check } from '../types'
import { CannotCheck, NothingToCheck } from '../errors.ts'
import { isWorkspaceRoot, readJson } from '../files.ts'
import { resolveBin } from '../tool.ts'
import type { Check } from '../types.ts'

const WORKSPACE_FILES = new Set(['package.json', 'pnpm-workspace.yaml'])

Expand Down
12 changes: 6 additions & 6 deletions packages/uncheck/src/checks/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { posix } from 'node:path'
import { Cache, Effect, FileSystem, Option, Path, Predicate } from 'effect'
import { parse as parseJsonc } from 'jsonc-parser'

import { CannotCheck, NothingToCheck } from '../errors'
import { CannotCheck, NothingToCheck } from '../errors.ts'
import {
ancestors,
fileKind,
Expand All @@ -12,11 +12,11 @@ import {
listProjectFiles,
readJson,
resolveFolders,
} from '../files'
import { git } from '../git'
import type { Bin } from '../tool'
import { argvBatches, resolveBin } from '../tool'
import type { Check } from '../types'
} from '../files.ts'
import { git } from '../git.ts'
import type { Bin } from '../tool.ts'
import { argvBatches, resolveBin } from '../tool.ts'
import type { Check } from '../types.ts'

/**
* TypeScript replaces this token at the start of `files`, `include`, `exclude` and path-valued
Expand Down
12 changes: 6 additions & 6 deletions packages/uncheck/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import * as NodeServices from '@effect/platform-node/NodeServices'
import { Console, Effect } from 'effect'
import { CliConfig, CliError, CliOutput, Command, GlobalFlag } from 'effect/unstable/cli'

import pkg from '../package.json'
import { hooks } from './commands/hooks'
import { init } from './commands/init'
import { prepare } from './commands/prepare'
import { staged } from './commands/staged'
import { uncheck } from './commands/uncheck'
import pkg from '../package.json' with { type: 'json' }
import { hooks } from './commands/hooks/index.ts'
import { init } from './commands/init.ts'
import { prepare } from './commands/prepare.ts'
import { staged } from './commands/staged.ts'
import { uncheck } from './commands/uncheck.ts'

// Any failed write (a reader gone after `| head`, a closed terminal, a full disk) would otherwise end
// the run before `staged` puts unstaged changes back, so output errors are ignored.
Expand Down
4 changes: 2 additions & 2 deletions packages/uncheck/src/commands/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from 'effect/unstable/cli'

import { install } from './install'
import { run } from './run'
import { install } from './install.ts'
import { run } from './run.ts'

export const hooks = Command.make('hooks').pipe(
Command.withDescription('Agent hooks: `install` writes the configs, `run` is what they execute'),
Expand Down
14 changes: 7 additions & 7 deletions packages/uncheck/src/commands/hooks/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Console, Effect, FileSystem, Path, Predicate, Stdio } from 'effect'
import { Argument, Command, Prompt } from 'effect/unstable/cli'
import { type ParseError, parse as parseJsonc, printParseErrorCode } from 'jsonc-parser'

import { userError } from '../../errors'
import { readJson, readTextIfExists } from '../../files'
import { gitLocation } from '../../git'
import { detectExec, invokes } from '../../pm'
import { bold, dim, green } from '../../style'
import type { CheckSelection } from '../uncheck'
import { cwdFlag, selectionArgs, selectionFlags, validateSelection } from '../uncheck'
import { userError } from '../../errors.ts'
import { readJson, readTextIfExists } from '../../files.ts'
import { gitLocation } from '../../git.ts'
import { detectExec, invokes } from '../../pm.ts'
import { bold, dim, green } from '../../style.ts'
import type { CheckSelection } from '../uncheck.ts'
import { cwdFlag, selectionArgs, selectionFlags, validateSelection } from '../uncheck.ts'

// Copilot (30 s) and CodeBuddy (60 s) kill a typecheck at their default timeout and end the turn as
// if no hook ran.
Expand Down
10 changes: 5 additions & 5 deletions packages/uncheck/src/commands/hooks/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { stripVTControlCharacters } from 'node:util'
import { Console, Effect, FileSystem, Option, Path, Predicate, Stdio, Stream } from 'effect'
import { Command, Flag } from 'effect/unstable/cli'

import { StopBlocked, userError } from '../../errors'
import { fileKind, isOutside, listChangedFiles, slashedRelative } from '../../files'
import { git, refusesRepository } from '../../git'
import { captureLines } from '../../tool'
import { fixFlag, followLinks, runChecks, selectionFlags } from '../uncheck'
import { StopBlocked, userError } from '../../errors.ts'
import { fileKind, isOutside, listChangedFiles, slashedRelative } from '../../files.ts'
import { git, refusesRepository } from '../../git.ts'
import { captureLines } from '../../tool.ts'
import { fixFlag, followLinks, runChecks, selectionFlags } from '../uncheck.ts'

export const run = Command.make(
'run',
Expand Down
18 changes: 9 additions & 9 deletions packages/uncheck/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Console, Effect, FileSystem, Option, Path, Predicate, Stdio } from 'eff
import { Command, Flag, Prompt } from 'effect/unstable/cli'
import { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process'

import { userError } from '../errors'
import { ancestors, firstFile, isWorkspaceRoot, readJson } from '../files'
import { detectExec, detectPackageManager } from '../pm'
import { bold, dim, green, listed } from '../style'
import { resolveBin } from '../tool'
import type { AgentId } from './hooks/install'
import { userError } from '../errors.ts'
import { ancestors, firstFile, isWorkspaceRoot, readJson } from '../files.ts'
import { detectExec, detectPackageManager } from '../pm.ts'
import { bold, dim, green, listed } from '../style.ts'
import { resolveBin } from '../tool.ts'
import type { AgentId } from './hooks/install.ts'
import {
AGENTS,
agentHookCommand,
Expand All @@ -18,9 +18,9 @@ import {
hasOwnHook,
validateAgentHookDir,
writeAgentHooks,
} from './hooks/install'
import { writePreCommitHook } from './prepare'
import { cwdFlag } from './uncheck'
} from './hooks/install.ts'
import { writePreCommitHook } from './prepare.ts'
import { cwdFlag } from './uncheck.ts'

const NO_SELECTION = { only: [], required: [], skipped: [] }

Expand Down
14 changes: 7 additions & 7 deletions packages/uncheck/src/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { randomBytes } from 'node:crypto'
import { Console, Effect, FileSystem, Option, Path, Result, Schedule } from 'effect'
import { Command, Flag } from 'effect/unstable/cli'

import { platformMessage, userError } from '../errors'
import { readTextIfExists } from '../files'
import { git, gitLocation, refusesRepository } from '../git'
import { detectExec, invokes } from '../pm'
import { bold, dim, green, red } from '../style'
import type { CheckSelection } from './uncheck'
import { cwdFlag, selectionArgs, selectionFlags, validateSelection } from './uncheck'
import { platformMessage, userError } from '../errors.ts'
import { readTextIfExists } from '../files.ts'
import { git, gitLocation, refusesRepository } from '../git.ts'
import { detectExec, invokes } from '../pm.ts'
import { bold, dim, green, red } from '../style.ts'
import type { CheckSelection } from './uncheck.ts'
import { cwdFlag, selectionArgs, selectionFlags, validateSelection } from './uncheck.ts'

const HOOK_COMMAND = 'uncheck staged'
const HEADER = '#!/bin/sh\n# Written by `uncheck prepare`, run it again to change the command.\n'
Expand Down
20 changes: 14 additions & 6 deletions packages/uncheck/src/commands/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import process from 'node:process'
import { Console, Effect, FileSystem, Path, Ref } from 'effect'
import { Command, Flag } from 'effect/unstable/cli'

import { userError } from '../errors'
import { inNodeModules } from '../files'
import { git, gitBytes, GitFailed, gitLocation, gitPaths, rawDiff, refusesRepository } from '../git'
import { dim, green, listFiles, red } from '../style'
import { argvBatches, logLines } from '../tool'
import { checkPaths, cwdFlag, fixFlag, selectionFlags, validateSelection } from './uncheck'
import { userError } from '../errors.ts'
import { inNodeModules } from '../files.ts'
import {
git,
gitBytes,
GitFailed,
gitLocation,
gitPaths,
rawDiff,
refusesRepository,
} from '../git.ts'
import { dim, green, listFiles, red } from '../style.ts'
import { argvBatches, logLines } from '../tool.ts'
import { checkPaths, cwdFlag, fixFlag, selectionFlags, validateSelection } from './uncheck.ts'

/** What became of the unstaged hunks that were set aside while the checks ran. */
interface Unstaged {
Expand Down
20 changes: 10 additions & 10 deletions packages/uncheck/src/commands/uncheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import type { CliError } from 'effect/unstable/cli'
import { Argument, Command, Flag } from 'effect/unstable/cli'
import type { ChildProcessSpawner } from 'effect/unstable/process'

import { oxfmt } from '../checks/oxfmt'
import { oxlint } from '../checks/oxlint'
import { sherif } from '../checks/sherif'
import { tsc } from '../checks/tsc'
import { CheckFailed, platformMessage, userError } from '../errors'
import { checkableFiles, listProjectFiles, resolvePaths } from '../files'
import type { GitFailed } from '../git'
import { bold, dim, green, listed, listFiles, red } from '../style'
import { captureLines, execute, logLines } from '../tool'
import type { Check, CheckCommand, CheckName, CheckOutcome } from '../types'
import { oxfmt } from '../checks/oxfmt.ts'
import { oxlint } from '../checks/oxlint.ts'
import { sherif } from '../checks/sherif.ts'
import { tsc } from '../checks/tsc.ts'
import { CheckFailed, platformMessage, userError } from '../errors.ts'
import { checkableFiles, listProjectFiles, resolvePaths } from '../files.ts'
import type { GitFailed } from '../git.ts'
import { bold, dim, green, listed, listFiles, red } from '../style.ts'
import { captureLines, execute, logLines } from '../tool.ts'
import type { Check, CheckCommand, CheckName, CheckOutcome } from '../types.ts'

const CHECKS: ReadonlyArray<Check> = [sherif, oxlint, oxfmt, tsc]

Expand Down
2 changes: 1 addition & 1 deletion packages/uncheck/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PlatformError } from 'effect'
import { Data, Effect } from 'effect'
import { CliError } from 'effect/unstable/cli'

import type { CheckOutcome } from './types'
import type { CheckOutcome } from './types.ts'

export class NothingToCheck extends Data.TaggedError('NothingToCheck')<{
readonly reason: string
Expand Down
4 changes: 2 additions & 2 deletions packages/uncheck/src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Effect, FileSystem, Path, Predicate } from 'effect'
import type { ChildProcessSpawner } from 'effect/unstable/process'
import { Minimatch } from 'minimatch'

import { userError } from './errors'
import { gitPaths, rawDiff } from './git'
import { userError } from './errors.ts'
import { gitPaths, rawDiff } from './git.ts'

export type ProjectFiles = Effect.Effect<
ReadonlyArray<string>,
Expand Down
2 changes: 1 addition & 1 deletion packages/uncheck/src/pm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import process from 'node:process'

import { Effect, FileSystem, Option, Path } from 'effect'

import { ancestors, fileKind, readJson } from './files'
import { ancestors, fileKind, readJson } from './files.ts'

// Hooks never get a terminal to ask in, so plain `npx` and `bunx` would download and run the latest
// release whenever the project has none, and Yarn 1 wraps a run in lines of its own on stdout, where
Expand Down
6 changes: 3 additions & 3 deletions packages/uncheck/src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import process from 'node:process'
import { Console, Effect, Path, Predicate, Stream } from 'effect'
import { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process'

import { ancestors, readJson } from './files'
import { colors } from './style'
import type { CheckCommand } from './types'
import { ancestors, readJson } from './files.ts'
import { colors } from './style.ts'
import type { CheckCommand } from './types.ts'

export interface Bin {
readonly name: string
Expand Down
6 changes: 3 additions & 3 deletions packages/uncheck/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Effect, FileSystem, Path, PlatformError } from 'effect'
import type { ChildProcessSpawner } from 'effect/unstable/process'

import type { CannotCheck, NothingToCheck } from './errors'
import type { ProjectFiles } from './files'
import type { Bin } from './tool'
import type { CannotCheck, NothingToCheck } from './errors.ts'
import type { ProjectFiles } from './files.ts'
import type { Bin } from './tool.ts'

export type CheckName = 'sherif' | 'oxlint' | 'oxfmt' | 'tsc'

Expand Down
3 changes: 1 addition & 2 deletions packages/uncheck/tests/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export interface Run {
}

const PACKAGE = fileURLToPath(new URL('../..', import.meta.url))
const REGISTER = fileURLToPath(new URL('register.ts', import.meta.url))
export const CLI = [process.execPath, '--import', REGISTER, join(PACKAGE, 'src/bin.ts')] as const
export const CLI = [process.execPath, join(PACKAGE, 'src/bin.ts')] as const

/** What the CLI and the tools it runs read above a project, so one above the tests leaks into them all. */
const PROJECT_MARKERS = [
Expand Down
30 changes: 0 additions & 30 deletions packages/uncheck/tests/utils/register.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/uncheck/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "uncheck/tsconfig/middleapi/lib",
"compilerOptions": {
"module": "ESNext",
"types": ["node"]
},
"include": ["./package.json", "src"],
Expand Down
Loading
Loading