-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(attest): add Bun support #1130
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { format } from "prettier" | ||
import { createSyncFn } from "synckit" | ||
import { fileURLToPath } from "url" | ||
import { getConfig } from "../config.ts" | ||
|
||
const formatSync = createSyncFn<typeof format>( | ||
fileURLToPath(import.meta.resolve("./formatWorker.js")) | ||
) | ||
|
||
const declarationPrefix = "type T = " | ||
|
||
export const formatTypeString = ( | ||
typeString: string, | ||
filename: string | ||
): string => | ||
formatSync(`${declarationPrefix}${typeString}`, { | ||
semi: false, | ||
printWidth: 60, | ||
trailingComma: "none", | ||
// use filepath to allow global formatting options | ||
filepath: filename, | ||
...getConfig().typeToStringFormat | ||
}) | ||
.slice(declarationPrefix.length) | ||
.trimEnd() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { format } from "prettier" | ||
import { runAsWorker } from "synckit" | ||
|
||
runAsWorker(format) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ export const forTypeScriptVersions = ( | |
const nodeModules = join(assertPackageRoot(process.cwd()), "node_modules") | ||
const tsPrimaryPath = join(nodeModules, "typescript") | ||
const tsTemporaryPath = join(nodeModules, "typescript-temp") | ||
if (existsSync(tsTemporaryPath)) unlinkSync(tsTemporaryPath) | ||
if (existsSync(tsPrimaryPath)) renameSync(tsPrimaryPath, tsTemporaryPath) | ||
|
||
try { | ||
|
@@ -41,7 +42,7 @@ export const forTypeScriptVersions = ( | |
try { | ||
if (existsSync(tsPrimaryPath)) unlinkSync(tsPrimaryPath) | ||
|
||
symlinkSync(targetPath, tsPrimaryPath) | ||
symlinkSync(targetPath, tsPrimaryPath, "junction") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also from the other PR correct? It's possible though that this does break on Windows as the cross-os CI doesn't run across multiple TS versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version that doesn't touch default TS was not on main yet so I did need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still, I'd rather There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll may drop this commit from this PR later, I did need it to test if it does work |
||
fn(version) | ||
passedVersions.push(version) | ||
} catch (e) { | ||
|
@@ -65,6 +66,7 @@ export const forTypeScriptVersions = ( | |
} finally { | ||
if (existsSync(tsTemporaryPath)) { | ||
console.log(`⏮️ Restoring your original TypeScript version...`) | ||
unlinkSync(tsPrimaryPath) | ||
renameSync(tsTemporaryPath, tsPrimaryPath) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference types="@types/bun" /> | ||
import { cleanup, setup } from "@ark/attest" | ||
import { afterAll, beforeAll, describe, it } from "bun:test" | ||
|
||
process.env.TZ = "America/New_York" | ||
|
||
// $ bun test --preload ./repo/bun.globalSetup.ts | ||
|
||
Object.assign(globalThis, { describe, it }) | ||
|
||
beforeAll(() => { | ||
setup({ | ||
typeToStringFormat: { | ||
useTabs: true | ||
} | ||
}) | ||
}) | ||
|
||
afterAll(cleanup) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,8 @@ | |
}, | ||
"bin": { | ||
"ts": "./ts.js" | ||
}, | ||
"devDependencies": { | ||
"@types/bun": "^1.1.9" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
"0.9.1"
instead