chore(config): pin @types/bun, tighten TypeScript strictness, and refactor config logic
- Pin `@types/bun` to `^1.3.14` for reproducible builds instead of using `latest` - Update `tsconfig.json` with stricter type-checking flags and reorganize compiler options - Refactor `initConfig` to DRY up the model default logic and add a null guard before process exit
This commit is contained in:
parent
d98ddb3ca7
commit
f668037582
5 changed files with 39 additions and 26 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "2.4.12",
|
"@biomejs/biome": "2.4.12",
|
||||||
"@types/bun": "latest",
|
"@types/bun": "^1.3.14",
|
||||||
"esbuild": "0.28.0"
|
"esbuild": "0.28.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
||||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
|
|
@ -55,7 +55,7 @@ importers:
|
||||||
specifier: 2.4.12
|
specifier: 2.4.12
|
||||||
version: 2.4.12
|
version: 2.4.12
|
||||||
'@types/bun':
|
'@types/bun':
|
||||||
specifier: latest
|
specifier: ^1.3.14
|
||||||
version: 1.3.14
|
version: 1.3.14
|
||||||
esbuild:
|
esbuild:
|
||||||
specifier: 0.28.0
|
specifier: 0.28.0
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,20 @@ export async function initConfig(old: AppConfig | null): Promise<AppConfig> {
|
||||||
if (isCancel(baseURL)) process.exit(1);
|
if (isCancel(baseURL)) process.exit(1);
|
||||||
|
|
||||||
const models = await getModels(baseURL);
|
const models = await getModels(baseURL);
|
||||||
|
const initialValue = models.includes(old?.model ?? "")
|
||||||
|
? old?.model
|
||||||
|
: models[0];
|
||||||
const model = await autocomplete({
|
const model = await autocomplete({
|
||||||
message: "Choose a default model:",
|
message: "Choose a default model:",
|
||||||
initialValue: models.includes(old?.model ?? "") ? old?.model : models[0],
|
initialValue,
|
||||||
placeholder: models.includes(old?.model ?? "") ? old?.model : models[0],
|
placeholder: initialValue ?? "Start typing...",
|
||||||
options: models.map((model) => ({ value: model })),
|
options: models.map((model) => ({ value: model })),
|
||||||
validate: (value) =>
|
validate: (value) =>
|
||||||
models.includes(typeof value === "string" ? value : "")
|
models.includes(typeof value === "string" ? value : "")
|
||||||
? undefined
|
? undefined
|
||||||
: `Unable to find model "${value}"`,
|
: `Unable to find model "${value}"`,
|
||||||
});
|
});
|
||||||
if (isCancel(model)) process.exit(1);
|
if (!model || isCancel(model)) process.exit(1);
|
||||||
|
|
||||||
const config = { baseURL, model } satisfies AppConfig;
|
const config = { baseURL, model } satisfies AppConfig;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { renderMarkdown } from "./src/render/markdown.ts";
|
import { renderMarkdown } from "./src/render/markdown";
|
||||||
|
|
||||||
const text = await Bun.file("README.md").text();
|
const text = await Bun.file("README.md").text();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,39 @@
|
||||||
{
|
{
|
||||||
|
// Visit https://aka.ms/tsconfig to read more about this file
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
// Environment setup & latest features
|
// Environment Settings
|
||||||
"lib": ["ESNext"],
|
// See also https://aka.ms/tsconfig/module
|
||||||
"target": "ESNext",
|
"module": "esnext",
|
||||||
"module": "Preserve",
|
"target": "esnext",
|
||||||
"moduleDetection": "force",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"allowJs": true,
|
|
||||||
|
|
||||||
// Bundler mode
|
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"allowImportingTsExtensions": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true,
|
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
// For nodejs:
|
||||||
|
"lib": ["esnext"],
|
||||||
|
"types": ["bun"],
|
||||||
|
// and npm install -D @types/node
|
||||||
|
|
||||||
// Best practices
|
// Stricter Typechecking Options
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"noUncheckedIndexedAccess": true,
|
"noUncheckedIndexedAccess": true,
|
||||||
"noImplicitOverride": true,
|
"exactOptionalPropertyTypes": true,
|
||||||
|
|
||||||
// Some stricter flags (disabled by default)
|
// Style Options
|
||||||
"noUnusedLocals": false,
|
"noImplicitReturns": true,
|
||||||
"noUnusedParameters": false,
|
"noImplicitOverride": true,
|
||||||
"noPropertyAccessFromIndexSignature": false
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"noPropertyAccessFromIndexSignature": true,
|
||||||
|
|
||||||
|
// Recommended Options
|
||||||
|
"strict": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
//"allowImportingTsExtensions": true,
|
||||||
|
"allowArbitraryExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noUncheckedSideEffectImports": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"skipLibCheck": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue