create-project-template-cli 1.0.1 → 1.0.4

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.
Files changed (38) hide show
  1. package/README.md +112 -5
  2. package/index.js +133 -133
  3. package/package.json +9 -4
  4. package/template/react-shadcn/.husky/commit-msg +4 -4
  5. package/template/react-shadcn/.stylelintignore +19 -19
  6. package/template/react-shadcn/.stylelintrc.cjs +258 -258
  7. package/template/react-shadcn/.vscode/extensions.json +7 -7
  8. package/template/react-shadcn/README.md +75 -75
  9. package/template/react-shadcn/commitlint.config.cjs +90 -90
  10. package/template/react-shadcn/components.json +22 -22
  11. package/template/react-shadcn/eslint.config.js +58 -58
  12. package/template/react-shadcn/index.html +13 -13
  13. package/template/react-shadcn/lint-staged.config.cjs +4 -4
  14. package/template/react-shadcn/package.json +62 -62
  15. package/template/react-shadcn/pnpm-lock.yaml +4514 -4514
  16. package/template/react-shadcn/src/App.css +23 -23
  17. package/template/react-shadcn/src/App.tsx +20 -20
  18. package/template/react-shadcn/src/assets/css/tailwindcss.css +120 -120
  19. package/template/react-shadcn/src/components/ui/button.tsx +58 -58
  20. package/template/react-shadcn/src/components/ui/card.tsx +92 -92
  21. package/template/react-shadcn/src/components/ui/input.tsx +21 -21
  22. package/template/react-shadcn/src/components/ui/label.tsx +22 -22
  23. package/template/react-shadcn/src/components/ui/navigation-menu.tsx +168 -168
  24. package/template/react-shadcn/src/lib/utils.ts +6 -6
  25. package/template/react-shadcn/src/main.tsx +11 -11
  26. package/template/react-shadcn/src/router/index.tsx +71 -71
  27. package/template/react-shadcn/src/views/404/index.scss +133 -133
  28. package/template/react-shadcn/src/views/404/index.tsx +26 -26
  29. package/template/react-shadcn/src/views/Index/index.tsx +7 -7
  30. package/template/react-shadcn/src/views/index.tsx +58 -58
  31. package/template/react-shadcn/tsconfig.app.json +33 -33
  32. package/template/react-shadcn/tsconfig.json +13 -13
  33. package/template/react-shadcn/tsconfig.node.json +32 -32
  34. package/template/react-shadcn/vite.config.ts +36 -36
  35. package/template/vue-tailwindcss/src/axios/index.ts +1 -1
  36. package/utils.js +73 -73
  37. package/template/react-shadcn/.gitignore +0 -24
  38. package/template/vue-tailwindcss/.gitignore +0 -30
@@ -1,36 +1,36 @@
1
- import { defineConfig } from "vite";
2
- import path from "path";
3
- import react from "@vitejs/plugin-react";
4
- import tailwindcss from "@tailwindcss/vite";
5
- import { codeInspectorPlugin } from "code-inspector-plugin";
6
- // https://vite.dev/config/
7
- export default defineConfig(({ mode }) => {
8
- return {
9
- plugins: [
10
- tailwindcss(),
11
- react({
12
- babel: {
13
- plugins: [["babel-plugin-react-compiler"]],
14
- },
15
- }),
16
- codeInspectorPlugin({
17
- bundler: "vite",
18
- }),
19
- ],
20
- resolve: {
21
- alias: {
22
- "@": path.resolve(__dirname, "./src"),
23
- },
24
- },
25
- build: {
26
- minify: "terser",
27
- terserOptions: {
28
- compress: {
29
- drop_console: mode !== "development",
30
- drop_debugger: true,
31
- },
32
- },
33
- } as any,
34
- };
35
- });
36
- console.log("\x1b[36m%s\x1b[0m", "{^_^} 启动成功了哦!");
1
+ import { defineConfig } from "vite";
2
+ import path from "path";
3
+ import react from "@vitejs/plugin-react";
4
+ import tailwindcss from "@tailwindcss/vite";
5
+ import { codeInspectorPlugin } from "code-inspector-plugin";
6
+ // https://vite.dev/config/
7
+ export default defineConfig(({ mode }) => {
8
+ return {
9
+ plugins: [
10
+ tailwindcss(),
11
+ react({
12
+ babel: {
13
+ plugins: [["babel-plugin-react-compiler"]],
14
+ },
15
+ }),
16
+ codeInspectorPlugin({
17
+ bundler: "vite",
18
+ }),
19
+ ],
20
+ resolve: {
21
+ alias: {
22
+ "@": path.resolve(__dirname, "./src"),
23
+ },
24
+ },
25
+ build: {
26
+ minify: "terser",
27
+ terserOptions: {
28
+ compress: {
29
+ drop_console: mode !== "development",
30
+ drop_debugger: true,
31
+ },
32
+ },
33
+ } as any,
34
+ };
35
+ });
36
+ console.log("\x1b[36m%s\x1b[0m", "{^_^} 启动成功了哦!");
@@ -71,7 +71,7 @@ request.interceptors.response.use(
71
71
  if (error === '重复请求') {
72
72
  return Promise.reject('重复请求')
73
73
  }
74
- console.log(error)
74
+
75
75
  const key = genKey(error.config)
76
76
  // 每次请求后删除newSet中的key
77
77
  newSet.delete(key)
package/utils.js CHANGED
@@ -1,73 +1,73 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import chalk from "chalk";
4
- import { fileURLToPath } from "url";
5
- import { dirname } from "path";
6
- import download from "download-git-repo";
7
- import ora from "ora";
8
-
9
- // 获取当前文件的完整路径(类似 CommonJS 中的 __filename)
10
- const __filename = fileURLToPath(import.meta.url);
11
-
12
- // 获取当前文件所在的目录(类似 CommonJS 中的 __dirname)
13
- const __dirname = dirname(__filename);
14
-
15
- // 模板目录路径(当前文件所在目录下的 template 文件夹)
16
-
17
- const TEMPLATES_DIR = path.resolve(__dirname, "./template");
18
- /**
19
- * 读取template文件夹下的目录
20
- */
21
- async function getTemplateList() {
22
- try {
23
- if (!(await fs.pathExists(TEMPLATES_DIR))) {
24
- console.log(chalk.red("读取模板列表失败"));
25
- return [];
26
- }
27
- // 读取子目录
28
- const templateList = await fs.readdir(TEMPLATES_DIR, {
29
- // 返回目录
30
- withFileTypes: true,
31
- });
32
- // 如果没有目录,返回空数组
33
- if (templateList.length === 0) {
34
- console.log(chalk.red("当前模板为空,请添加"));
35
- return [];
36
- }
37
- // 过滤出目录
38
- const dirs = templateList.filter((item) => item.isDirectory());
39
- // 提取目录名
40
- const templateNames = dirs.map((item) => {
41
- // 名称和value都用文件名
42
- const name = item.name;
43
-
44
- return { name, value: name };
45
- });
46
- templateNames.push({
47
- name: "自定义项目",
48
- value: "custom",
49
- });
50
- return templateNames;
51
- } catch (error) {
52
- console.log(chalk.red("读取模板列表失败"));
53
- // console.log(chalk.red(error.message));
54
- return [];
55
- }
56
- }
57
-
58
- async function downloadCustomTemplate(templatePath, projectPath) {
59
- const spinner = ora("正在下载项目模板...").start(); //下载中
60
- return new Promise((resolve, reject) => {
61
- download(`direct:${templatePath}`, projectPath, { clone: true }, (err) => {
62
- if (err) {
63
- reject(err);
64
- spinner.fail("项目模板下载失败"); //下载失败
65
- } else {
66
- resolve();
67
- // console.log(chalk.green("项目模板下载成功"));
68
- spinner.succeed("项目模板下载成功"); //下载成功
69
- }
70
- });
71
- });
72
- }
73
- export { getTemplateList, downloadCustomTemplate };
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+ import chalk from "chalk";
4
+ import { fileURLToPath } from "url";
5
+ import { dirname } from "path";
6
+ import download from "download-git-repo";
7
+ import ora from "ora";
8
+
9
+ // 获取当前文件的完整路径(类似 CommonJS 中的 __filename)
10
+ const __filename = fileURLToPath(import.meta.url);
11
+
12
+ // 获取当前文件所在的目录(类似 CommonJS 中的 __dirname)
13
+ const __dirname = dirname(__filename);
14
+
15
+ // 模板目录路径(当前文件所在目录下的 template 文件夹)
16
+
17
+ const TEMPLATES_DIR = path.resolve(__dirname, "./template");
18
+ /**
19
+ * 读取template文件夹下的目录
20
+ */
21
+ async function getTemplateList() {
22
+ try {
23
+ if (!(await fs.pathExists(TEMPLATES_DIR))) {
24
+ console.log(chalk.red("读取模板列表失败"));
25
+ return [];
26
+ }
27
+ // 读取子目录
28
+ const templateList = await fs.readdir(TEMPLATES_DIR, {
29
+ // 返回目录
30
+ withFileTypes: true,
31
+ });
32
+ // 如果没有目录,返回空数组
33
+ if (templateList.length === 0) {
34
+ console.log(chalk.red("当前模板为空,请添加"));
35
+ return [];
36
+ }
37
+ // 过滤出目录
38
+ const dirs = templateList.filter((item) => item.isDirectory());
39
+ // 提取目录名
40
+ const templateNames = dirs.map((item) => {
41
+ // 名称和value都用文件名
42
+ const name = item.name;
43
+
44
+ return { name, value: name };
45
+ });
46
+ templateNames.push({
47
+ name: "自定义项目",
48
+ value: "custom",
49
+ });
50
+ return templateNames;
51
+ } catch (error) {
52
+ console.log(chalk.red("读取模板列表失败"));
53
+ // console.log(chalk.red(error.message));
54
+ return [];
55
+ }
56
+ }
57
+
58
+ async function downloadCustomTemplate(templatePath, projectPath) {
59
+ const spinner = ora("正在下载项目模板...").start(); //下载中
60
+ return new Promise((resolve, reject) => {
61
+ download(`direct:${templatePath}`, projectPath, { clone: true }, (err) => {
62
+ if (err) {
63
+ reject(err);
64
+ spinner.fail("项目模板下载失败"); //下载失败
65
+ } else {
66
+ resolve();
67
+ // console.log(chalk.green("项目模板下载成功"));
68
+ spinner.succeed("项目模板下载成功"); //下载成功
69
+ }
70
+ });
71
+ });
72
+ }
73
+ export { getTemplateList, downloadCustomTemplate };
@@ -1,24 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- pnpm-debug.log*
8
- lerna-debug.log*
9
-
10
- node_modules
11
- dist
12
- dist-ssr
13
- *.local
14
-
15
- # Editor directories and files
16
- .vscode/*
17
- !.vscode/extensions.json
18
- .idea
19
- .DS_Store
20
- *.suo
21
- *.ntvs*
22
- *.njsproj
23
- *.sln
24
- *.sw?
@@ -1,30 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- pnpm-debug.log*
8
- lerna-debug.log*
9
-
10
- node_modules
11
- .DS_Store
12
- dist
13
- dist-ssr
14
- coverage
15
- *.local
16
-
17
- /cypress/videos/
18
- /cypress/screenshots/
19
-
20
- # Editor directories and files
21
- .vscode/*
22
- !.vscode/extensions.json
23
- .idea
24
- *.suo
25
- *.ntvs*
26
- *.njsproj
27
- *.sln
28
- *.sw?
29
-
30
- *.tsbuildinfo