Skip to content

[feat] Added support for Bun #630

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
修正tsconfig文件指向错误,选项的国际化支持
  • Loading branch information
mchao123 committed Dec 5, 2024
commit 0a824b526b842ebdca4ad23ad255daa65fdfef1c
28 changes: 14 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function init() {
needsEslint?: false | 'eslintOnly' | 'speedUpWithOxlint'
needsOxlint?: boolean
needsPrettier?: boolean
runtime?: 'nodejs' | 'bun'
runtime?: 'node' | 'bun'
} = {}

try {
Expand Down Expand Up @@ -168,16 +168,16 @@ async function init() {
initial: 0,
choices: [
{
title: language.needsRuntime.selectOptions.nodejs.title,
description: language.needsRuntime.selectOptions.nodejs.desc,
value: 'nodejs'
title: language.needsRuntime.selectOptions.node.title,
description: language.needsRuntime.selectOptions.node.desc,
value: 'node',
},
{
title: language.needsRuntime.selectOptions.bun.title,
description: language.needsRuntime.selectOptions.bun.desc,
value: 'bun'
}
]
value: 'bun',
},
],
},
{
name: 'projectName',
Expand Down Expand Up @@ -345,7 +345,7 @@ async function init() {
needsPinia = argv.pinia,
needsVitest = argv.vitest || argv.tests,
needsPrettier = argv['eslint-with-prettier'],
runtime = 'nodejs',
runtime = 'node',
} = result

const needsEslint = Boolean(argv.eslint || argv['eslint-with-prettier'] || result.needsEslint)
Expand Down Expand Up @@ -378,8 +378,8 @@ async function init() {
const templateRoot = path.resolve(__dirname, 'template')
const callbacks = []
const render = function render(templateName: string) {
let templateDir = fs.existsSync(path.resolve(templateRoot, runtime, templateName))
if (!fs.existsSync(targetDir)) {
let templateDir = path.resolve(templateRoot, 'others-runtime', runtime, templateName)
if (!fs.existsSync(templateDir)) {
templateDir = path.resolve(templateRoot, templateName)
}
renderTemplate(templateDir, root, callbacks)
Expand Down Expand Up @@ -428,7 +428,7 @@ async function init() {
// All templates contain at least a `.node` and a `.app` tsconfig.
references: [
{
path: './tsconfig.node.json',
path: `./tsconfig.${runtime}.json`,
},
{
path: './tsconfig.app.json',
Expand Down Expand Up @@ -526,7 +526,7 @@ async function init() {
// EJS template rendering
preOrderDirectoryTraverse(
root,
() => { },
() => {},
(filepath) => {
if (filepath.endsWith('.ejs')) {
const template = fs.readFileSync(filepath, 'utf-8')
Expand Down Expand Up @@ -556,7 +556,7 @@ async function init() {
// `jsconfig.json` is not reused, because we use solution-style `tsconfig`s, which are much more complicated.
preOrderDirectoryTraverse(
root,
() => { },
() => {},
(filepath) => {
if (filepath.endsWith('.js') && !filepath.endsWith('eslint.config.js')) {
const tsFilePath = filepath.replace(/\.js$/, '.ts')
Expand All @@ -579,7 +579,7 @@ async function init() {
// Remove all the remaining `.ts` files
preOrderDirectoryTraverse(
root,
() => { },
() => {},
(filepath) => {
if (filepath.endsWith('.ts')) {
fs.unlinkSync(filepath)
Expand Down
2 changes: 1 addition & 1 deletion locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"needsRuntime": {
"message": "Choose runtime environment:",
"selectOptions": {
"nodejs": {
"node": {
"title": "Node.js",
"desc": "Traditional and widely supported runtime"
},
Expand Down
2 changes: 1 addition & 1 deletion locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"needsRuntime": {
"message": "Choisir l'environnement d'exécution :",
"selectOptions": {
"nodejs": {
"node": {
"title": "Node.js",
"desc": "Runtime traditionnel largement supporté"
},
Expand Down
13 changes: 13 additions & 0 deletions locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@
"needsPrettier": {
"message": "Kod formatlama için Prettier eklensin mi?"
},
"needsRuntime": {
"message": "Çalışma zamanı ortamını seçin:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "Geleneksel ve yaygın olarak desteklenen çalışma zamanı"
},
"bun": {
"title": "Bun",
"desc": "Hızlı, hepsi bir arada JavaScript çalışma zamanı"
}
}
},
"errors": {
"operationCancelled": "İşlem iptal edildi"
},
Expand Down
2 changes: 1 addition & 1 deletion locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"needsRuntime": {
"message": "选择运行时环境:",
"selectOptions": {
"nodejs": {
"node": {
"title": "Node.js",
"desc": "传统且广泛支持的运行时"
},
Expand Down
13 changes: 13 additions & 0 deletions locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@
"needsPrettier": {
"message": "是否引入 Prettier 用於程式碼格式化?"
},
"needsRuntime": {
"message": "選擇執行環境:",
"selectOptions": {
"node": {
"title": "Node.js",
"desc": "傳統且廣泛支援的執行環境"
},
"bun": {
"title": "Bun",
"desc": "快速的一體化 JavaScript 執行環境"
}
}
},
"errors": {
"operationCancelled": "操作取消"
},
Expand Down
Loading