@tanyueran/cli 0.0.21 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/template/module/vue/vue-ts-empty/index.module.scss.hbs +6 -0
- package/template/module/vue/vue-ts-empty/index.vue.hbs +55 -0
- package/template/project/vue/vite-vue-ts/.editorconfig +8 -0
- package/template/project/vue/vite-vue-ts/.env +0 -0
- package/template/project/vue/vite-vue-ts/.env.dev +1 -0
- package/template/project/vue/vite-vue-ts/.env.qa +1 -0
- package/template/project/vue/vite-vue-ts/.gitattributes +1 -0
- package/template/project/vue/vite-vue-ts/.prettierrc.json +6 -0
- package/template/project/vue/vite-vue-ts/.vscode/extensions.json +8 -0
- package/template/project/vue/vite-vue-ts/README.md +39 -0
- package/template/project/vue/vite-vue-ts/build/plugins/vite-plugin-html-replace-flag.js +13 -0
- package/template/project/vue/vite-vue-ts/env.d.ts +1 -0
- package/template/project/vue/vite-vue-ts/eslint.config.ts +22 -0
- package/template/project/vue/vite-vue-ts/index.html +13 -0
- package/template/project/vue/vite-vue-ts/package.json.hbs +40 -0
- package/template/project/vue/vite-vue-ts/pnpm-lock.yaml +3219 -0
- package/template/project/vue/vite-vue-ts/public/favicon.ico +0 -0
- package/template/project/vue/vite-vue-ts/src/App.vue +15 -0
- package/template/project/vue/vite-vue-ts/src/main.ts +12 -0
- package/template/project/vue/vite-vue-ts/src/router/index.ts +23 -0
- package/template/project/vue/vite-vue-ts/src/stores/counter.ts +12 -0
- package/template/project/vue/vite-vue-ts/src/views/about/index.vue +28 -0
- package/template/project/vue/vite-vue-ts/src/views/home/index.vue +28 -0
- package/template/project/vue/vite-vue-ts/tsconfig.json +22 -0
- package/template/project/vue/vite-vue-ts/vite.config.ts +45 -0
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t,a=require("commander"),s=require("prompts"),o=require("node:path"),n=require("fs-extra"),r=require("handlebars");!function(e){e.ViteVueTs="vite-vue-ts",e.WebpackVueTs="webpack-vue-ts"}(e||(e={})),function(e){e.VueTsPageTemplate="vue-ts-page-template",e.VueTsDetailTemplate="vue-ts-detail-template",e.VueTsEmpty="vue-ts-empty"}(t||(t={}));const c=[{label:"vite + vue + ts项目",value:e.ViteVueTs,path:"
|
|
1
|
+
"use strict";var e,t,a=require("commander"),s=require("prompts"),o=require("node:path"),n=require("fs-extra"),r=require("handlebars");!function(e){e.ViteVueTs="vite-vue-ts",e.WebpackVueTs="webpack-vue-ts"}(e||(e={})),function(e){e.VueTsPageTemplate="vue-ts-page-template",e.VueTsDetailTemplate="vue-ts-detail-template",e.VueTsEmpty="vue-ts-empty"}(t||(t={}));const c=[{label:"vite + vue + ts项目",value:e.ViteVueTs,path:"../template/project/vue/vite-vue-ts"}],i=[{label:"vue-ts的空模板",value:t.VueTsEmpty,path:"../template/module/vue/vue-ts-empty"}];const l=require("node:path");function m(e){const{targetPath:t,sourcePath:a,templateData:s}=e;if(n.statSync(a).isDirectory()){n.mkdirSync(t,{recursive:!0}),n.readdirSync(a).forEach(e=>{m({targetPath:l.join(t,e),sourcePath:l.join(a,e),templateData:s})})}else if(a.endsWith(".hbs")){const e=n.readFileSync(a),o=r.compile(e.toString())(s);n.writeFileSync(t.replace(".hbs",""),o)}else n.copyFileSync(a,t)}function p(e){const{targetPath:t,sourcePath:a}=e;if(!n.statSync(a).isDirectory())throw new Error("源文件路劲必须是一个目录");n.existsSync(t)&&n.removeSync(t),n.mkdirSync(t,{recursive:!0}),m(e)}r.registerHelper("toPascalCase",function(e){return function(e){return e&&"string"==typeof e?e.split(/[\s-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(""):e}(e)});const u=require("picocolors"),v=new a.Command;v.name("tx cli").description("一个简单CLI 工具").version("0.1.0"),v.option("-m, --module-name <moduleName>","模块名称").option("-p, --project-name <projectName>","项目名称"),v.command("create").description("创建项目").action(async()=>{let e=v.opts().projectName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入项目名称"}]);e=t.name?t.name:"test-project-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:c.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green("项目名称:"+t.template)),console.log(u.green("选择模板:"+e));const a=c.find(e=>e.value===t.template);p({targetPath:o.resolve(process.cwd(),e),sourcePath:o.resolve(__dirname,a.path),templateData:{name:e}}),console.log(u.green("创建成功")),console.log(u.green(`cd ./${e} && pnpm install`))}),v.command("add").description("添加模块").action(async()=>{let e=v.opts().moduleName;if(!e){const t=await s([{type:"text",name:"name",message:"请输入模块名"}]);e=t.name?t.name:"test-module-name"}const t=await s([{type:"select",name:"template",message:"请选择模板",choices:i.map(e=>({title:e.label,value:e.value}))}]);console.log(u.green("模板名称:"+e)),console.log(u.green("选择模板:"+t.template));const a=i.find(e=>e.value===t.template);p({targetPath:o.resolve(process.cwd(),e),sourcePath:o.resolve(__dirname,a.path),templateData:{name:e}})}),exports.start=function(){v.parse(process.argv)};
|
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="style['{{name}}-wrapper']">{{ name }}</div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { defineOptions } from "vue";
|
|
7
|
+
import style from "./index.module.scss";
|
|
8
|
+
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: "{{ toPascalCase name}}",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// #region Props
|
|
14
|
+
// default
|
|
15
|
+
// const props = withDefaults(defineProps<{}>(), {});
|
|
16
|
+
// props
|
|
17
|
+
// const props = defineProps<{}>();
|
|
18
|
+
// #endregion
|
|
19
|
+
|
|
20
|
+
// #region Emits
|
|
21
|
+
// const emits = defineEmits<{
|
|
22
|
+
// // (e: 'eventName', 参数1: '', 参数2: '', ...): void;
|
|
23
|
+
// }>();
|
|
24
|
+
// #endregion
|
|
25
|
+
|
|
26
|
+
// #region Hooks
|
|
27
|
+
// #endregion
|
|
28
|
+
|
|
29
|
+
// #region Vars
|
|
30
|
+
// #endregion
|
|
31
|
+
|
|
32
|
+
// #region Computed
|
|
33
|
+
// #endregion
|
|
34
|
+
|
|
35
|
+
// #region Methods
|
|
36
|
+
// #endregion
|
|
37
|
+
|
|
38
|
+
// #region Public
|
|
39
|
+
// #endregion
|
|
40
|
+
|
|
41
|
+
// #region Event Handler
|
|
42
|
+
// #endregion
|
|
43
|
+
|
|
44
|
+
// #region Watch
|
|
45
|
+
// #endregion
|
|
46
|
+
|
|
47
|
+
// #region Life Cycle
|
|
48
|
+
// onBeforeMount(() => {});
|
|
49
|
+
// onMounted(() => {});
|
|
50
|
+
// onBeforeUpdate(() => {});
|
|
51
|
+
// onUpdated(() => {});
|
|
52
|
+
// onBeforeUnmount(() => {});
|
|
53
|
+
// onUnmounted(() => {});
|
|
54
|
+
// #endregion
|
|
55
|
+
</script>
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MODE=dev
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MODE=qa
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# vite-vue-ts
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 in Vite.
|
|
4
|
+
|
|
5
|
+
## Recommended IDE Setup
|
|
6
|
+
|
|
7
|
+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
|
8
|
+
|
|
9
|
+
## Type Support for `.vue` Imports in TS
|
|
10
|
+
|
|
11
|
+
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
|
12
|
+
|
|
13
|
+
## Customize configuration
|
|
14
|
+
|
|
15
|
+
See [Vite Configuration Reference](https://vite.dev/config/).
|
|
16
|
+
|
|
17
|
+
## Project Setup
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pnpm install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Compile and Hot-Reload for Development
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pnpm dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Type-Check, Compile and Minify for Production
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pnpm build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Lint with [ESLint](https://eslint.org/)
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
pnpm lint
|
|
39
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import pkg from '../../package.json'
|
|
2
|
+
|
|
3
|
+
export function VitePluginHtmlReplaceFlag() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'vite-plugin-html-replace-flag',
|
|
6
|
+
transformIndexHtml(html) {
|
|
7
|
+
// 添加版本号
|
|
8
|
+
return html
|
|
9
|
+
.replace(`version="%version%"`, `version="${pkg.version}"`)
|
|
10
|
+
.replace(`build-time="%buildTime%"`, `build-time="${new Date().toLocaleString()}"`)
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { globalIgnores } from 'eslint/config'
|
|
2
|
+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
|
3
|
+
import pluginVue from 'eslint-plugin-vue'
|
|
4
|
+
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
|
5
|
+
|
|
6
|
+
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
|
7
|
+
// import { configureVueProject } from '@vue/eslint-config-typescript'
|
|
8
|
+
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
|
9
|
+
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
|
10
|
+
|
|
11
|
+
export default defineConfigWithVueTs(
|
|
12
|
+
{
|
|
13
|
+
name: 'app/files-to-lint',
|
|
14
|
+
files: ['**/*.{ts,mts,tsx,vue}'],
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
|
18
|
+
|
|
19
|
+
pluginVue.configs['flat/essential'],
|
|
20
|
+
vueTsConfigs.recommended,
|
|
21
|
+
skipFormatting,
|
|
22
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh_CN" version="%version%" build-time="%buildTime%">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite App</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{name}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "vite --mode dev",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"build": "vite build",
|
|
13
|
+
"type-check": "vue-tsc --build",
|
|
14
|
+
"lint": "eslint . --fix",
|
|
15
|
+
"format": "prettier --write src/"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"pinia": "^3.0.3",
|
|
19
|
+
"vue": "^3.5.18",
|
|
20
|
+
"vue-router": "^4.5.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@tsconfig/node22": "^22.0.2",
|
|
24
|
+
"@types/node": "^22.16.5",
|
|
25
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
26
|
+
"@vitejs/plugin-vue-jsx": "^5.0.1",
|
|
27
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
28
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
29
|
+
"@vue/tsconfig": "^0.7.0",
|
|
30
|
+
"eslint": "^9.31.0",
|
|
31
|
+
"eslint-plugin-vue": "~10.3.0",
|
|
32
|
+
"jiti": "^2.4.2",
|
|
33
|
+
"npm-run-all2": "^8.0.4",
|
|
34
|
+
"prettier": "3.6.2",
|
|
35
|
+
"typescript": "~5.8.0",
|
|
36
|
+
"vite": "^7.0.6",
|
|
37
|
+
"vite-plugin-vue-devtools": "^8.0.0",
|
|
38
|
+
"vue-tsc": "^3.0.4"
|
|
39
|
+
}
|
|
40
|
+
}
|