react-nest-cli 1.0.3 → 1.0.5

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 (72) hide show
  1. package/.cspell/project-words.txt +3 -0
  2. package/.editorconfig +5 -0
  3. package/.husky/commit-msg +3 -0
  4. package/.husky/pre-commit +3 -0
  5. package/.prettierignore +1 -0
  6. package/apps/components/Button/index.css +9 -0
  7. package/apps/components/Button/index.jsx +12 -0
  8. package/apps/components/Button/index.less +10 -0
  9. package/apps/components/Button/index.tsx +21 -0
  10. package/apps/components/Card/index.css +10 -0
  11. package/apps/components/Card/index.jsx +11 -0
  12. package/apps/components/Card/index.less +9 -0
  13. package/apps/components/Card/index.tsx +20 -0
  14. package/commitlint.config.ts +113 -0
  15. package/cspell.config.ts +16 -0
  16. package/eslint.config.ts +52 -0
  17. package/package.json +86 -38
  18. package/packages/cli/dist/chunk-2LOTRMC6.js +24 -0
  19. package/packages/cli/dist/chunk-2LOTRMC6.js.map +1 -0
  20. package/packages/cli/dist/chunk-6IS4OKS7.js +69 -0
  21. package/packages/cli/dist/chunk-6IS4OKS7.js.map +1 -0
  22. package/packages/cli/dist/chunk-B7N5IJK6.js +120 -0
  23. package/packages/cli/dist/chunk-B7N5IJK6.js.map +1 -0
  24. package/packages/cli/dist/chunk-K5MQOF6Z.js +12 -0
  25. package/packages/cli/dist/chunk-K5MQOF6Z.js.map +1 -0
  26. package/packages/cli/dist/chunk-NCNZGYLV.js +13 -0
  27. package/packages/cli/dist/chunk-NCNZGYLV.js.map +1 -0
  28. package/packages/cli/dist/chunk-PMB2T2TP.js +13 -0
  29. package/packages/cli/dist/chunk-PMB2T2TP.js.map +1 -0
  30. package/packages/cli/dist/chunk-YUGLQSSS.js +19 -0
  31. package/packages/cli/dist/chunk-YUGLQSSS.js.map +1 -0
  32. package/packages/cli/dist/commands/base/info.d.ts +6 -0
  33. package/packages/cli/dist/commands/base/info.js +10 -0
  34. package/packages/cli/dist/commands/base/info.js.map +1 -0
  35. package/packages/cli/dist/commands/base/init.d.ts +5 -0
  36. package/packages/cli/dist/commands/base/init.js +8 -0
  37. package/packages/cli/dist/commands/base/init.js.map +1 -0
  38. package/packages/cli/dist/commands/base/initComponent.d.ts +5 -0
  39. package/packages/cli/dist/commands/base/initComponent.js +7 -0
  40. package/packages/cli/dist/commands/base/initComponent.js.map +1 -0
  41. package/packages/cli/dist/commands/base/version.d.ts +5 -0
  42. package/packages/cli/dist/commands/base/version.js +8 -0
  43. package/packages/cli/dist/commands/base/version.js.map +1 -0
  44. package/packages/cli/dist/commands/baseRegisterCommands.d.ts +7 -0
  45. package/packages/cli/dist/commands/baseRegisterCommands.js +7 -0
  46. package/packages/cli/dist/commands/baseRegisterCommands.js.map +1 -0
  47. package/packages/cli/dist/configs/prompts.config.d.ts +10 -0
  48. package/packages/cli/dist/configs/prompts.config.js +7 -0
  49. package/packages/cli/dist/configs/prompts.config.js.map +1 -0
  50. package/packages/cli/dist/configs/text.config.d.ts +5 -0
  51. package/packages/cli/dist/configs/text.config.js +7 -0
  52. package/packages/cli/dist/configs/text.config.js.map +1 -0
  53. package/packages/cli/dist/index.js +38 -85
  54. package/packages/cli/dist/index.js.map +1 -1
  55. package/packages/cli/package.json +13 -0
  56. package/packages/cli/src/commands/base/info.ts +22 -0
  57. package/packages/cli/src/commands/base/init.ts +73 -0
  58. package/packages/cli/src/commands/base/initComponent.ts +174 -0
  59. package/packages/cli/src/commands/base/version.ts +16 -0
  60. package/packages/cli/src/commands/baseRegisterCommands.ts +9 -0
  61. package/packages/cli/src/configs/prompts.config.ts +21 -6
  62. package/packages/cli/src/index.ts +22 -102
  63. package/packages/templates/react-nest/index.css +7 -0
  64. package/packages/templates/react-nest/index.js +1 -0
  65. package/packages/templates/react-nest-ts/index.js +1 -0
  66. package/packages/templates/vue-template/vue +0 -0
  67. package/pnpm-workspace.yaml +2 -2
  68. package/prettier.config.js +6 -0
  69. package/stylelint.config.mjs +17 -0
  70. package/tsconfig.json +40 -39
  71. package/tsup.config.ts +12 -5
  72. package/turbo.json +0 -0
@@ -0,0 +1,3 @@
1
+ giget
2
+ javascriptx
3
+ liaolonghui
package/.editorconfig ADDED
@@ -0,0 +1,5 @@
1
+ [*]
2
+ semi = true
3
+ singleQuote = true
4
+ tabWidth = 4
5
+ trailingComma = "none"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+
3
+ npx commitlint --edit "$1"
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+
3
+ pnpm spellcheck && pnpm typecheck && npx lint-staged
@@ -0,0 +1 @@
1
+ /dist
@@ -0,0 +1,9 @@
1
+ .button {
2
+ padding: 8px 16px;
3
+ border-radius: 4px;
4
+ cursor: pointer;
5
+ }
6
+
7
+ .button:hover {
8
+ background-color: #f0f0f0;
9
+ }
@@ -0,0 +1,12 @@
1
+ const Button = (props) => {
2
+ const { className, children, onClick } = props || {};
3
+
4
+ return (
5
+ <div className={`button ${className || ''}`} onClick={onClick}>
6
+ {children}
7
+ </div>
8
+ )
9
+ }
10
+
11
+
12
+ export default Button;
@@ -0,0 +1,10 @@
1
+ .button {
2
+ padding: 8px 16px;
3
+ border-radius: 4px;
4
+ cursor: pointer;
5
+
6
+
7
+ &:hover {
8
+ background-color: #f0f0f0;
9
+ }
10
+ }
@@ -0,0 +1,21 @@
1
+ import React, { ReactNode } from 'react'
2
+
3
+
4
+ export interface IButtonProps {
5
+ className?: string
6
+ children: ReactNode
7
+ onClick?: (e: React.MouseEvent<HTMLDivElement>) => void
8
+ }
9
+
10
+ const Button = (props: IButtonProps) => {
11
+ const { className, children, onClick } = props
12
+
13
+ return (
14
+ <div className={`button ${className || ''}`} onClick={onClick}>
15
+ {children}
16
+ </div>
17
+ )
18
+ }
19
+
20
+
21
+ export default Button;
@@ -0,0 +1,10 @@
1
+ .card {
2
+ padding: 16px;
3
+ border-radius: 4px;
4
+ background-color: #fff;
5
+ }
6
+
7
+ .card .title {
8
+ font-size: 16px;
9
+ font-weight: bold;
10
+ }
@@ -0,0 +1,11 @@
1
+ const Card = (props) => {
2
+ const { className, children } = props || {};
3
+
4
+ return (
5
+ <div className={`card ${className || ''}`}>
6
+ {children}
7
+ </div>
8
+ )
9
+ }
10
+
11
+ export default Card;
@@ -0,0 +1,9 @@
1
+ .card {
2
+ padding: 16px;
3
+ border-radius: 4px;
4
+ background-color: #fff;
5
+ &.title {
6
+ font-size: 16px;
7
+ font-weight: bold;
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ import React, { ReactNode } from 'react'
2
+
3
+
4
+ export interface ICardProps {
5
+ className?: string
6
+ children: ReactNode
7
+ }
8
+
9
+ const Card = (props: ICardProps) => {
10
+ const { className, children } = props || {};
11
+
12
+ return (
13
+ <div className={`card ${className || ''}`}>
14
+ {children}
15
+ </div>
16
+ )
17
+ }
18
+
19
+
20
+ export default Card;
@@ -0,0 +1,113 @@
1
+ import { defineConfig, type CommitizenGitOptions } from 'cz-git'
2
+
3
+ export default defineConfig({
4
+ extends: ['@commitlint/config-conventional'], // 引入 conventional 规则
5
+ rules: {
6
+ // @see: https://commitlint.js.org/#/reference-rules
7
+ },
8
+ prompt: {
9
+ alias: { fd: 'docs: fix typos' },
10
+ messages: {
11
+ type: "Select the type of change that you're committing:",
12
+ scope: 'Denote the SCOPE of this change (optional):',
13
+ customScope: 'Denote the SCOPE of this change:',
14
+ subject:
15
+ 'Write a SHORT, IMPERATIVE tense description of the change:\n',
16
+ body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
17
+ breaking:
18
+ 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
19
+ footerPrefixesSelect:
20
+ 'Select the ISSUES type of changeList by this change (optional):',
21
+ customFooterPrefix: 'Input ISSUES prefix:',
22
+ footer: 'List any ISSUES by this change. E.g.: #31, #34:\n',
23
+ generatingByAI: 'Generating your AI commit subject...',
24
+ generatedSelectByAI: 'Select suitable subject by AI generated:',
25
+ confirmCommit:
26
+ 'Are you sure you want to proceed with the commit above?',
27
+ },
28
+ types: [
29
+ {
30
+ value: 'feat',
31
+ name: 'feat: ✨ A new feature',
32
+ emoji: ':sparkles:',
33
+ },
34
+ { value: 'fix', name: 'fix: 🐛 A bug fix', emoji: ':bug:' },
35
+ {
36
+ value: 'docs',
37
+ name: 'docs: 📝 Documentation only changes',
38
+ emoji: ':memo:',
39
+ },
40
+ {
41
+ value: 'style',
42
+ name: 'style: 💄 Changes that do not affect the meaning of the code',
43
+ emoji: ':lipstick:',
44
+ },
45
+ {
46
+ value: 'refactor',
47
+ name: 'refactor: ♻️ A code change that neither fixes a bug nor adds a feature',
48
+ emoji: ':recycle:',
49
+ },
50
+ {
51
+ value: 'perf',
52
+ name: 'perf: ⚡️ A code change that improves performance',
53
+ emoji: ':zap:',
54
+ },
55
+ {
56
+ value: 'test',
57
+ name: 'test: ✅ Adding missing tests or correcting existing tests',
58
+ emoji: ':white_check_mark:',
59
+ },
60
+ {
61
+ value: 'build',
62
+ name: 'build: 📦️ Changes that affect the build system or external dependencies',
63
+ emoji: ':package:',
64
+ },
65
+ {
66
+ value: 'ci',
67
+ name: 'ci: 🎡 Changes to our CI configuration files and scripts',
68
+ emoji: ':ferris_wheel:',
69
+ },
70
+ {
71
+ value: 'chore',
72
+ name: "chore: 🔨 Other changes that don't modify src or test files",
73
+ emoji: ':hammer:',
74
+ },
75
+ {
76
+ value: 'revert',
77
+ name: 'revert: ⏪️ Reverts a previous commit',
78
+ emoji: ':rewind:',
79
+ },
80
+ ],
81
+ useEmoji: true,
82
+ emojiAlign: 'center',
83
+ useAI: false,
84
+ aiNumber: 1,
85
+ themeColorCode: '',
86
+ scopes: [],
87
+ allowCustomScopes: true,
88
+ allowEmptyScopes: true,
89
+ customScopesAlign: 'bottom',
90
+ customScopesAlias: 'custom',
91
+ emptyScopesAlias: 'empty',
92
+ upperCaseSubject: null,
93
+ markBreakingChangeMode: false,
94
+ allowBreakingChanges: ['feat', 'fix'],
95
+ breaklineNumber: 100,
96
+ breaklineChar: '|',
97
+ skipQuestions: [],
98
+ issuePrefixes: [
99
+ { value: 'closed', name: 'closed: ISSUES has been processed' },
100
+ ],
101
+ customIssuePrefixAlign: 'top',
102
+ emptyIssuePrefixAlias: 'skip',
103
+ customIssuePrefixAlias: 'custom',
104
+ allowCustomIssuePrefix: true,
105
+ allowEmptyIssuePrefix: true,
106
+ confirmColorize: true,
107
+ // scopeOverrides: undefined,
108
+ defaultBody: '',
109
+ defaultIssues: '',
110
+ defaultScope: '',
111
+ defaultSubject: '',
112
+ } as CommitizenGitOptions,
113
+ })
@@ -0,0 +1,16 @@
1
+ // TypeScript version of the CSpell config.
2
+ // Requires Node.js >= 22.18 to run natively.
3
+ import { defineConfig } from 'cspell'
4
+
5
+ export default defineConfig({
6
+ version: '0.2',
7
+ dictionaryDefinitions: [
8
+ {
9
+ name: 'project-words',
10
+ path: './.cspell/project-words.txt',
11
+ addWords: true,
12
+ },
13
+ ],
14
+ dictionaries: ['project-words'],
15
+ ignorePaths: ['node_modules', './.cspell/project-words.txt', 'dist'],
16
+ })
@@ -0,0 +1,52 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import tseslint from 'typescript-eslint'
4
+ import { defineConfig } from 'eslint/config'
5
+ import simpleImportSort from 'eslint-plugin-simple-import-sort'
6
+ import prettier from 'eslint-plugin-prettier'
7
+ import prettierConfig from 'eslint-config-prettier'
8
+
9
+ export default defineConfig([
10
+ {
11
+ files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
12
+ ignores: [
13
+ '**/dist/**',
14
+ 'node_modules/**',
15
+ '**/*.config.ts',
16
+ '**/packages/templates/**',
17
+ ],
18
+ plugins: {
19
+ 'simple-import-sort': simpleImportSort,
20
+ prettier: prettier,
21
+ },
22
+ rules: {
23
+ '@typescript-eslint/array-type': 'error',
24
+ '@typescript-eslint/no-for-in-array': 'error',
25
+ 'no-undef': 'warn',
26
+ 'no-unused-vars': 'error',
27
+ 'no-console': 'warn',
28
+ 'prettier/prettier': 'error',
29
+ ...prettierConfig.rules,
30
+
31
+ // "simple-import-sort/imports": [
32
+ // "error",
33
+ // ],
34
+ // "simple-import-sort/exports": [
35
+ // "error",
36
+ // ],
37
+ },
38
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
39
+ languageOptions: {
40
+ globals: {
41
+ ...globals.browser,
42
+ ...globals.node,
43
+ },
44
+ parser: tseslint.parser,
45
+ parserOptions: {
46
+ projects: ['eslint.config.ts', 'tsconfig.json'],
47
+ tsconfigRootDir: import.meta.dirname,
48
+ },
49
+ },
50
+ },
51
+ tseslint.configs.recommended,
52
+ ])
package/package.json CHANGED
@@ -1,40 +1,88 @@
1
1
  {
2
- "name": "react-nest-cli",
3
- "version": "1.0.3",
4
- "description": "一个脚手架工具,用于快速生成 react+nest 项目",
5
- "type": "module",
6
- "bin": {
7
- "react-nest": "./packages/cli/dist/index.js"
8
- },
9
- "main": "./packages/cli/dist/index.js",
10
- "scripts": {
11
- "build": "tsup",
12
- "start": "ts-node ./packages/cli/src/index.ts",
13
- "preview": "tsup && node ./packages/cli/dist/index.js"
14
- },
15
- "keywords": [
16
- "react",
17
- "nest",
18
- "脚手架"
19
- ],
20
- "author": "liaolonghui",
21
- "license": "ISC",
22
- "dependencies": {
23
- "commander": "^14.0.3",
24
- "consola": "^3.4.2",
25
- "figlet": "^1.10.0",
26
- "fs-extra": "^11.3.3",
27
- "giget": "^3.1.2",
28
- "ora": "^9.3.0",
29
- "picocolors": "^1.1.1",
30
- "prompts": "^2.4.2",
31
- "tsup": "^8.5.1"
32
- },
33
- "devDependencies": {
34
- "@types/fs-extra": "^11.0.4",
35
- "@types/node": "^25.2.1",
36
- "@types/prompts": "^2.4.9",
37
- "ts-node": "^10.9.2",
38
- "typescript": "^5.9.3"
39
- }
2
+ "name": "react-nest-cli",
3
+ "version": "1.0.5",
4
+ "description": "一个脚手架工具,用于快速生成 react+nest 项目",
5
+ "type": "module",
6
+ "packageManager": "pnpm@9.6.0",
7
+ "bin": {
8
+ "react-nest": "./packages/cli/dist/index.js"
9
+ },
10
+ "main": "./packages/cli/dist/index.js",
11
+ "scripts": {
12
+ "build": "tsup",
13
+ "start": "ts-node ./packages/cli/src/index.ts",
14
+ "preview": "tsup && node ./packages/cli/dist/index.js",
15
+ "commit": "git-cz",
16
+ "prepare": "husky",
17
+ "typecheck": "tsc --noEmit",
18
+ "lint:es": "eslint \"{packages,apps}/**/*.{js,jsx,ts,tsx}\"",
19
+ "lint:style": "stylelint \"{packages,apps}/**/*.{css,scss}\"",
20
+ "format": "prettier --write .",
21
+ "spellcheck": "cspell lint --dot --gitignore --color --cache --show-suggestions \"(packages|apps)/**/*.@(html|ts|js|tsx|jsx|css|scss|json|md)\"",
22
+ "graph": "madge --extensions ts --ts-config tsconfig.json packages/*/src"
23
+ },
24
+ "keywords": [
25
+ "react",
26
+ "nest",
27
+ "脚手架"
28
+ ],
29
+ "author": "liaolonghui",
30
+ "license": "ISC",
31
+ "config": {
32
+ "commitizen": {
33
+ "path": "node_modules/cz-git"
34
+ }
35
+ },
36
+ "lint-staged": {
37
+ "*.{json|md}": [
38
+ "prettier --cache --write --no-error-on-unmatched-pattern"
39
+ ],
40
+ "*.{js|jsx}": [
41
+ "eslint --fix",
42
+ "prettier --cache --write --no-error-on-unmatched-pattern"
43
+ ],
44
+ "*.{ts|tsx}": [
45
+ "eslint --fix",
46
+ "prettier --cache --parser=typescript --write"
47
+ ]
48
+ },
49
+ "dependencies": {
50
+ "commander": "^14.0.3",
51
+ "consola": "^3.4.2",
52
+ "figlet": "^1.10.0",
53
+ "fs-extra": "^11.3.3",
54
+ "giget": "^3.1.2",
55
+ "ora": "^9.3.0",
56
+ "picocolors": "^1.1.1",
57
+ "prompts": "^2.4.2",
58
+ "tsup": "^8.5.1"
59
+ },
60
+ "devDependencies": {
61
+ "@commitlint/cli": "^20.4.1",
62
+ "@commitlint/config-conventional": "^20.4.1",
63
+ "@eslint/js": "^10.0.1",
64
+ "@types/fs-extra": "^11.0.4",
65
+ "@types/node": "^25.2.1",
66
+ "@types/prompts": "^2.4.9",
67
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
68
+ "commitizen": "^4.3.1",
69
+ "cspell": "^9.6.4",
70
+ "cz-git": "^1.12.0",
71
+ "eslint": "^10.0.0",
72
+ "eslint-config-prettier": "^10.1.8",
73
+ "eslint-plugin-prettier": "^5.5.5",
74
+ "eslint-plugin-simple-import-sort": "^12.1.1",
75
+ "globals": "^17.3.0",
76
+ "husky": "^9.1.7",
77
+ "lint-staged": "^16.2.7",
78
+ "madge": "^8.0.0",
79
+ "postcss-styled-syntax": "^0.7.1",
80
+ "prettier": "^3.8.1",
81
+ "stylelint": "^17.1.1",
82
+ "stylelint-config-standard": "^40.0.0",
83
+ "ts-node": "^10.9.2",
84
+ "turbo": "^2.8.3",
85
+ "typescript": "^5.9.3",
86
+ "typescript-eslint": "^8.54.0"
87
+ }
40
88
  }
@@ -0,0 +1,24 @@
1
+ import {
2
+ text_config_default
3
+ } from "./chunk-NCNZGYLV.js";
4
+
5
+ // packages/cli/src/commands/base/info.ts
6
+ import consola from "consola";
7
+ import figlet from "figlet";
8
+ import picocolors from "picocolors";
9
+ var logInfo = (program) => {
10
+ console.log(
11
+ picocolors.yellow(figlet.textSync("React Nest CLI", text_config_default))
12
+ );
13
+ consola.start(picocolors.yellow(program.description()));
14
+ consola.info(picocolors.yellow(program.version()));
15
+ };
16
+ function info(program) {
17
+ program.command("info").description("\u8F93\u51FA\u9879\u76EE\u4FE1\u606F").action(() => logInfo(program));
18
+ }
19
+
20
+ export {
21
+ logInfo,
22
+ info
23
+ };
24
+ //# sourceMappingURL=chunk-2LOTRMC6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/base/info.ts"],"sourcesContent":["import type { Command } from 'commander'\nimport consola from 'consola'\nimport figlet from 'figlet'\nimport picocolors from 'picocolors'\nimport textConfig from '../../configs/text.config.ts'\n\n// 输出项目信息\nexport const logInfo = (program: Command) => {\n console.log(\n picocolors.yellow(figlet.textSync('React Nest CLI', textConfig))\n )\n consola.start(picocolors.yellow(program.description()))\n consola.info(picocolors.yellow(program.version()))\n}\n\nexport default function info(program: Command) {\n // 输出项目信息\n program\n .command('info')\n .description('输出项目信息')\n .action(() => logInfo(program))\n}\n"],"mappings":";;;;;AACA,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,gBAAgB;AAIhB,IAAM,UAAU,CAAC,YAAqB;AACzC,UAAQ;AAAA,IACJ,WAAW,OAAO,OAAO,SAAS,kBAAkB,mBAAU,CAAC;AAAA,EACnE;AACA,UAAQ,MAAM,WAAW,OAAO,QAAQ,YAAY,CAAC,CAAC;AACtD,UAAQ,KAAK,WAAW,OAAO,QAAQ,QAAQ,CAAC,CAAC;AACrD;AAEe,SAAR,KAAsB,SAAkB;AAE3C,UACK,QAAQ,MAAM,EACd,YAAY,sCAAQ,EACpB,OAAO,MAAM,QAAQ,OAAO,CAAC;AACtC;","names":[]}
@@ -0,0 +1,69 @@
1
+ import {
2
+ prompts_config_default
3
+ } from "./chunk-PMB2T2TP.js";
4
+
5
+ // packages/cli/src/commands/base/init.ts
6
+ import prompts from "prompts";
7
+ import consola from "consola";
8
+ import fsExtra from "fs-extra";
9
+ import path from "path";
10
+ import { cwd } from "process";
11
+ import { downloadTemplate } from "giget";
12
+ import ora from "ora";
13
+ function init(program) {
14
+ program.command("init").description("\u521D\u59CB\u5316\u9879\u76EE").argument("[project-name]", "\u9879\u76EE\u540D\u79F0").option("--template <template-name>", "\u9879\u76EE\u6A21\u677F\u540D\u79F0").action(async (projectName, rest) => {
15
+ let { template } = rest || {};
16
+ if (!projectName) {
17
+ const response = await prompts({
18
+ type: "text",
19
+ initial: "my-project",
20
+ // 默认值
21
+ name: "projectName",
22
+ message: "\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0"
23
+ // validate: value => value.length ? true : '请输入项目名称'
24
+ });
25
+ projectName = response.projectName;
26
+ }
27
+ const noTemplate = template && !prompts_config_default.templates.find((item) => item.value === template);
28
+ if (!template || noTemplate) {
29
+ if (noTemplate) {
30
+ consola.error(`\u9879\u76EE\u6A21\u677F ${template} \u4E0D\u5B58\u5728, \u8BF7\u9009\u62E9\u5176\u4ED6\u6A21\u677F`);
31
+ }
32
+ const response = await prompts({
33
+ type: "select",
34
+ name: "template",
35
+ message: "\u8BF7\u9009\u62E9\u9879\u76EE\u6A21\u677F",
36
+ choices: prompts_config_default.templates,
37
+ initial: 0
38
+ // 默认选择第一个
39
+ });
40
+ template = response.template;
41
+ }
42
+ const tip = `\u521D\u59CB\u5316\u9879\u76EE ${projectName}\uFF0C\u6A21\u677F ${template}`;
43
+ const spinner = ora({
44
+ text: tip,
45
+ color: "blue"
46
+ // spinner: 'growVertical',
47
+ // isEnabled: false
48
+ });
49
+ spinner.start();
50
+ const projectDir = path.resolve(cwd(), projectName);
51
+ if (fsExtra.existsSync(projectDir)) {
52
+ spinner.fail(`\u{1F4A5}\u521D\u59CB\u5316\u5931\u8D25: \u9879\u76EE\u76EE\u5F55 ${projectName} \u5DF2\u5B58\u5728`);
53
+ return;
54
+ }
55
+ const res = await downloadTemplate(
56
+ `github:liaolonghui/react-nest-cli/packages/templates/${template}#main`,
57
+ {
58
+ dir: projectDir
59
+ }
60
+ );
61
+ const { dir } = res;
62
+ spinner.succeed(`\u9879\u76EE\u521D\u59CB\u5316\u6210\u529F\uFF0C\u9879\u76EE\u76EE\u5F55\uFF1A${dir}`);
63
+ });
64
+ }
65
+
66
+ export {
67
+ init
68
+ };
69
+ //# sourceMappingURL=chunk-6IS4OKS7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/base/init.ts"],"sourcesContent":["import type { Command } from 'commander'\nimport prompts from 'prompts'\nimport promptsConfig from '../../configs/prompts.config.ts'\nimport consola from 'consola'\nimport fsExtra from 'fs-extra'\nimport path from 'node:path'\nimport { cwd } from 'node:process'\nimport { downloadTemplate } from 'giget'\nimport ora from 'ora'\n\nexport default function init(program: Command) {\n program\n .command('init')\n .description('初始化项目')\n .argument('[project-name]', '项目名称')\n .option('--template <template-name>', '项目模板名称')\n .action(async (projectName, rest) => {\n let { template } = rest || {}\n // 如果projectName没有提供,让用户输入\n if (!projectName) {\n const response = await prompts({\n type: 'text',\n initial: 'my-project', // 默认值\n name: 'projectName',\n message: '请输入项目名称',\n // validate: value => value.length ? true : '请输入项目名称'\n })\n projectName = response.projectName\n }\n\n // 如果template没有提供或者template不存在,让用户选择\n const noTemplate =\n template &&\n !promptsConfig.templates.find((item) => item.value === template)\n if (!template || noTemplate) {\n if (noTemplate) {\n consola.error(`项目模板 ${template} 不存在, 请选择其他模板`)\n }\n const response = await prompts({\n type: 'select',\n name: 'template',\n message: '请选择项目模板',\n choices: promptsConfig.templates,\n initial: 0, // 默认选择第一个\n })\n template = response.template\n }\n\n const tip = `初始化项目 ${projectName},模板 ${template}`\n const spinner = ora({\n text: tip,\n color: 'blue',\n // spinner: 'growVertical',\n // isEnabled: false\n })\n spinner.start()\n\n const projectDir = path.resolve(cwd(), projectName)\n if (fsExtra.existsSync(projectDir)) {\n spinner.fail(`💥初始化失败: 项目目录 ${projectName} 已存在`)\n return\n }\n\n const res = await downloadTemplate(\n `github:liaolonghui/react-nest-cli/packages/templates/${template}#main`,\n {\n dir: projectDir,\n }\n )\n const { dir } = res\n spinner.succeed(`项目初始化成功,项目目录:${dir}`)\n })\n}\n"],"mappings":";;;;;AACA,OAAO,aAAa;AAEpB,OAAO,aAAa;AACpB,OAAO,aAAa;AACpB,OAAO,UAAU;AACjB,SAAS,WAAW;AACpB,SAAS,wBAAwB;AACjC,OAAO,SAAS;AAED,SAAR,KAAsB,SAAkB;AAC3C,UACK,QAAQ,MAAM,EACd,YAAY,gCAAO,EACnB,SAAS,kBAAkB,0BAAM,EACjC,OAAO,8BAA8B,sCAAQ,EAC7C,OAAO,OAAO,aAAa,SAAS;AACjC,QAAI,EAAE,SAAS,IAAI,QAAQ,CAAC;AAE5B,QAAI,CAAC,aAAa;AACd,YAAM,WAAW,MAAM,QAAQ;AAAA,QAC3B,MAAM;AAAA,QACN,SAAS;AAAA;AAAA,QACT,MAAM;AAAA,QACN,SAAS;AAAA;AAAA,MAEb,CAAC;AACD,oBAAc,SAAS;AAAA,IAC3B;AAGA,UAAM,aACF,YACA,CAAC,uBAAc,UAAU,KAAK,CAAC,SAAS,KAAK,UAAU,QAAQ;AACnE,QAAI,CAAC,YAAY,YAAY;AACzB,UAAI,YAAY;AACZ,gBAAQ,MAAM,4BAAQ,QAAQ,iEAAe;AAAA,MACjD;AACA,YAAM,WAAW,MAAM,QAAQ;AAAA,QAC3B,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS,uBAAc;AAAA,QACvB,SAAS;AAAA;AAAA,MACb,CAAC;AACD,iBAAW,SAAS;AAAA,IACxB;AAEA,UAAM,MAAM,kCAAS,WAAW,sBAAO,QAAQ;AAC/C,UAAM,UAAU,IAAI;AAAA,MAChB,MAAM;AAAA,MACN,OAAO;AAAA;AAAA;AAAA,IAGX,CAAC;AACD,YAAQ,MAAM;AAEd,UAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,WAAW;AAClD,QAAI,QAAQ,WAAW,UAAU,GAAG;AAChC,cAAQ,KAAK,qEAAiB,WAAW,qBAAM;AAC/C;AAAA,IACJ;AAEA,UAAM,MAAM,MAAM;AAAA,MACd,wDAAwD,QAAQ;AAAA,MAChE;AAAA,QACI,KAAK;AAAA,MACT;AAAA,IACJ;AACA,UAAM,EAAE,IAAI,IAAI;AAChB,YAAQ,QAAQ,iFAAgB,GAAG,EAAE;AAAA,EACzC,CAAC;AACT;","names":[]}