-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5024feb
commit 45ac2cd
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
package-lock.json | ||
# Logs | ||
logs | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env node | ||
|
||
const { execSync } = require('child_process'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const readline = require('readline'); | ||
const rimraf = require('rimraf'); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
function askQuestion(query) { | ||
return new Promise(resolve => rl.question(query, resolve)); | ||
} | ||
|
||
async function main() { | ||
const projectName = await askQuestion('请输入项目名称 (Enter project name): '); | ||
const projectDescription = await askQuestion('请输入项目简介 (Enter project description): '); | ||
|
||
rl.close(); | ||
|
||
// 克隆模板项目 | ||
execSync(`git clone https://github.com/firecatjs/fire-cat-started.git ${projectName}`, { stdio: 'inherit' }); | ||
|
||
const projectPath = path.join(process.cwd(), projectName); | ||
|
||
// 删除 .git 文件夹 | ||
rimraf.sync(path.join(projectPath, '.git')); | ||
|
||
const packageJsonPath = path.join(projectPath, 'package.json'); | ||
|
||
// 读取 package.json | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); | ||
|
||
// 修改 package.json 中的 name 和 description | ||
packageJson.name = projectName; | ||
packageJson.description = projectDescription; | ||
|
||
// 写回 package.json | ||
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
|
||
console.log('项目创建成功! (Project created successfully!)'); | ||
console.log(`cd ${projectName}`); | ||
console.log('npm install'); | ||
console.log('npm run dev'); | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
rl.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters