-
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.
refactor: ♻️ html-vue模板增加package.json
- Loading branch information
1 parent
837cf84
commit d1b158c
Showing
13 changed files
with
371 additions
and
78,706 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
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,51 +1,53 @@ | ||
const inquirer = require('inquirer'); | ||
const { copyDir, checkMkdirExists } = require("../copy"); | ||
const path = require("path"); | ||
const path = require('node:path') | ||
const process = require('node:process') | ||
const inquirer = require('inquirer') | ||
const { copyDir, checkMkdirExists } = require('../copy') | ||
|
||
function inquirerPrompt(argv) { | ||
const { name } = argv; | ||
const { name } = argv | ||
return new Promise((resolve, reject) => { | ||
inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: '项目名称', | ||
default: name, | ||
validate: function (val) { | ||
validate(val) { | ||
if (!val) { | ||
return "请输入项目名称:"; | ||
return '请输入项目名称:' | ||
} | ||
return true; | ||
return true | ||
}, | ||
}, | ||
]).then(answers => { | ||
]).then((answers) => { | ||
resolve(answers) | ||
}).catch(error => { | ||
}).catch((error) => { | ||
reject(error) | ||
}) | ||
}) | ||
|
||
} | ||
|
||
exports.inquirerHtmlPrompt = function(argv){ | ||
exports.inquirerHtmlPrompt = function (argv) { | ||
inquirerPrompt(argv).then((answers) => { | ||
const { name } = answers; | ||
const { name } = answers | ||
const isMkdirExists = checkMkdirExists( | ||
path.resolve(process.cwd(), `./${name}`) | ||
); | ||
path.resolve(process.cwd(), `./${name}`), | ||
) | ||
|
||
if (isMkdirExists) { | ||
console.log(`${name}文件夹已经存在`); | ||
console.log(`${name}文件夹已经存在`) | ||
} else { | ||
copyDir( | ||
path.resolve(__dirname, `../../template/html/vue`), | ||
path.resolve(process.cwd(), `./${name}`) | ||
); | ||
path.resolve(process.cwd(), `./${name}`), | ||
) | ||
|
||
console.log('\x1B[32m%s\x1B[0m', ` | ||
create successful | ||
cd ./${name} and can use live-server run | ||
cd ./${name} | ||
pnpm i | ||
live-server | ||
`) | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
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
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,61 +1,60 @@ | ||
const inquirer = require('inquirer'); | ||
const { copyDir, checkMkdirExists } = require("../copy"); | ||
const path = require("path"); | ||
const path = require('node:path') | ||
const process = require('node:process') | ||
const inquirer = require('inquirer') | ||
const { copyDir, checkMkdirExists } = require('../copy') | ||
|
||
function inquirerPrompt(argv) { | ||
const { name } = argv; | ||
const { name } = argv | ||
return new Promise((resolve, reject) => { | ||
inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: '项目名称', | ||
default: name, | ||
validate: function (val) { | ||
validate(val) { | ||
if (!val) { | ||
return "请输入项目名称:"; | ||
return '请输入项目名称:' | ||
} | ||
return true; | ||
return true | ||
}, | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'build_type', | ||
message: '构建工具', | ||
choices: ['rsbuild', 'vite'], | ||
filter: function (value) { | ||
filter(value) { | ||
return { | ||
'rsbuild': "rsbuild", | ||
'vite': "vite", | ||
}[value]; | ||
rsbuild: 'rsbuild', | ||
vite: 'vite', | ||
}[value] | ||
}, | ||
}, | ||
]).then(answers => { | ||
]).then((answers) => { | ||
resolve(answers) | ||
}).catch(error => { | ||
}).catch((error) => { | ||
reject(error) | ||
}) | ||
}) | ||
} | ||
|
||
|
||
|
||
exports.inquirerProjectPrompt = function(argv){ | ||
exports.inquirerProjectPrompt = function (argv) { | ||
inquirerPrompt(argv).then((answers) => { | ||
const { name, build_type } = answers; | ||
const { name, build_type } = answers | ||
const isMkdirExists = checkMkdirExists( | ||
path.resolve(process.cwd(), `./${name}`) | ||
); | ||
path.resolve(process.cwd(), `./${name}`), | ||
) | ||
|
||
if (isMkdirExists) { | ||
console.log(`${name}文件夹已经存在`); | ||
console.log(`${name}文件夹已经存在`) | ||
} else { | ||
copyDir( | ||
path.resolve(__dirname, ` ../../template/projects/${build_type}`), | ||
path.resolve(process.cwd(), `./${name}`) | ||
); | ||
path.resolve(process.cwd(), `./${name}`), | ||
) | ||
|
||
console.log('\x1B[32m%s\x1B[0m', `cd ./${name}`) | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
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
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,35 +1,33 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>vue template</title> | ||
<link rel="stylesheet" href="./node_modules/element-plus/dist/index.css" /> | ||
</head> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>vue template</title> | ||
<link rel="stylesheet" href="./source/element-plus.css" /> | ||
</head> | ||
<body> | ||
<script src="./node_modules/vue/dist/vue.global.js"></script> | ||
<script src="./node_modules/element-plus/dist//index.full.min.js"></script> | ||
|
||
<body> | ||
<script src="./source/vue.global.js"></script> | ||
<script src="./source/element-plus.js"></script> | ||
<div id="app"> | ||
<el-button type="primary">测试</el-button> | ||
</div> | ||
|
||
<div id="app"> | ||
<el-button type="primary">测试</el-button> | ||
</div> | ||
<script> | ||
const { createApp, ref } = Vue | ||
|
||
<script> | ||
const { createApp, ref } = Vue | ||
|
||
createApp({ | ||
setup() { | ||
const message = ref('Hello vue!') | ||
return { | ||
message | ||
} | ||
} | ||
}) | ||
.use(ElementPlus) | ||
.mount('#app') | ||
</script> | ||
</body> | ||
|
||
</html> | ||
createApp({ | ||
setup() { | ||
const message = ref('Hello vue!') | ||
return { | ||
message, | ||
} | ||
}, | ||
}) | ||
.use(ElementPlus) | ||
.mount('#app') | ||
</script> | ||
</body> | ||
</html> |
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,14 @@ | ||
{ | ||
"name": "html-vue", | ||
"version": "1.0.0", | ||
"description": "", | ||
"author": "", | ||
"license": "ISC", | ||
"keywords": [], | ||
"main": "index.js", | ||
"scripts": {}, | ||
"dependencies": { | ||
"element-plus": "^2.8.7", | ||
"vue": "^3.5.12" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.