Skip to content

Commit

Permalink
fix: update project initialization logic and template handling
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackRam-oss committed Nov 27, 2024
1 parent 4ab0063 commit 3296c32
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/questions/projectInfoQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default async function projectInfoQuestions({ argTargetDir, targetDir }:
value: YesNoCancelEnum.Yes,
},
{
description: "Ignore files and continue",
description: "Keep existing files and continue",
name: "Ignore",
value: YesNoCancelEnum.No,
},
Expand Down
15 changes: 14 additions & 1 deletion src/steps/gitInit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import spawn from 'cross-spawn'
import fs from 'node:fs'
import path from 'node:path'
import gitQuestions from '../questions/gitQuestions'

export default async function gitInit({ rootFolder }: {
rootFolder: string
}) {
// Check if exist in rootFolder a .git folder
const gitFolder = path.join(rootFolder, '.git`')
try {
if (fs.existsSync(gitFolder)) {
console.log(`\n.git folder already exists.`)
return
}
} catch (error) {
}

let { initGit } = await gitQuestions()
try {
if (initGit) {
console.log(`\nInitializing git repository...`)
spawn.sync('git', ['init'], { cwd: rootFolder, stdio: 'inherit' })
spawn.sync('git', ['init', '-b', 'main'], { cwd: rootFolder, stdio: 'inherit' })
spawn.sync('git', ['add', '.'], { cwd: rootFolder, stdio: 'inherit' })

console.log(`Done.`)
console.log(`\nNow, you can use GitHub Desktop upload your project to GitHub.`)
Expand Down
6 changes: 3 additions & 3 deletions src/steps/selectTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export default async function selectTemplate(argTargetDir: string | undefined):
file = file.replace(/my-app-project-name/g, projectName)
write(fileName, file)
break
case '.git':
case 'package-lock.json':
break
default:
write(fileName)
}
Expand All @@ -112,9 +115,6 @@ export default async function selectTemplate(argTargetDir: string | undefined):
file = file.replace(/my-app-project-name/g, projectName)
file = file.replace(/com.my-app-project-name.app/g, identifier)
write(path.join('src-tauri', fileName), file)
break
default:
write(path.join('src-tauri', fileName))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion template-react-vite-muijoy-tauri

0 comments on commit 3296c32

Please sign in to comment.