wanzhuang-cli 1.0.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.
Files changed (87) hide show
  1. package/.gitattributes +41 -0
  2. package/README.md +113 -0
  3. package/dist/commands/create.d.ts +10 -0
  4. package/dist/commands/create.js +145 -0
  5. package/dist/commands/generate.d.ts +8 -0
  6. package/dist/commands/generate.js +26 -0
  7. package/dist/commands/update.d.ts +6 -0
  8. package/dist/commands/update.js +26 -0
  9. package/dist/createApiTest/displayEnumLabel.d.ts +3 -0
  10. package/dist/createApiTest/displayEnumLabel.js +10 -0
  11. package/dist/createApiTest/displayTypeLabel.d.ts +19 -0
  12. package/dist/createApiTest/displayTypeLabel.js +135 -0
  13. package/dist/createApiTest/index.d.ts +6 -0
  14. package/dist/createApiTest/index.js +24 -0
  15. package/dist/createApiTest/pet.d.ts +58 -0
  16. package/dist/createApiTest/pet.js +102 -0
  17. package/dist/createApiTest/store.d.ts +28 -0
  18. package/dist/createApiTest/store.js +48 -0
  19. package/dist/createApiTest/types.d.ts +110 -0
  20. package/dist/createApiTest/types.js +17 -0
  21. package/dist/createApiTest/user.d.ts +50 -0
  22. package/dist/createApiTest/user.js +85 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +52 -0
  25. package/dist/utils/api.d.ts +1 -0
  26. package/dist/utils/api.js +48 -0
  27. package/dist/utils/configGen.d.ts +28 -0
  28. package/dist/utils/configGen.js +178 -0
  29. package/dist/utils/deps.d.ts +13 -0
  30. package/dist/utils/deps.js +47 -0
  31. package/dist/utils/fileOps.d.ts +29 -0
  32. package/dist/utils/fileOps.js +124 -0
  33. package/dist/utils/template.d.ts +12 -0
  34. package/dist/utils/template.js +31 -0
  35. package/package.json +44 -0
  36. package/src/commands/create.ts +141 -0
  37. package/src/commands/generate.ts +23 -0
  38. package/src/commands/update.ts +22 -0
  39. package/src/createApiTest/displayEnumLabel.ts +13 -0
  40. package/src/createApiTest/displayTypeLabel.ts +160 -0
  41. package/src/createApiTest/index.ts +10 -0
  42. package/src/createApiTest/pet.ts +159 -0
  43. package/src/createApiTest/store.ts +71 -0
  44. package/src/createApiTest/types.ts +134 -0
  45. package/src/createApiTest/user.ts +131 -0
  46. package/src/index.ts +54 -0
  47. package/src/utils/api.ts +47 -0
  48. package/src/utils/configGen.ts +139 -0
  49. package/src/utils/deps.ts +40 -0
  50. package/src/utils/fileOps.ts +86 -0
  51. package/src/utils/template.ts +32 -0
  52. package/templates/react/README.md +12 -0
  53. package/templates/react/eslint.config.js +33 -0
  54. package/templates/react/index.html +13 -0
  55. package/templates/react/package.json +27 -0
  56. package/templates/react/public/vite.svg +1 -0
  57. package/templates/react/src/App.css +42 -0
  58. package/templates/react/src/App.jsx +35 -0
  59. package/templates/react/src/assets/react.svg +1 -0
  60. package/templates/react/src/index.css +68 -0
  61. package/templates/react/src/main.jsx +10 -0
  62. package/templates/react/vite.config.js +7 -0
  63. package/templates/uniapp/index.html +20 -0
  64. package/templates/uniapp/package.json +67 -0
  65. package/templates/uniapp/shims-uni.d.ts +10 -0
  66. package/templates/uniapp/src/App.vue +17 -0
  67. package/templates/uniapp/src/main.js +10 -0
  68. package/templates/uniapp/src/manifest.json +72 -0
  69. package/templates/uniapp/src/pages/index/index.vue +48 -0
  70. package/templates/uniapp/src/pages.json +16 -0
  71. package/templates/uniapp/src/shime-uni.d.ts +6 -0
  72. package/templates/uniapp/src/static/logo.png +0 -0
  73. package/templates/uniapp/src/uni.scss +76 -0
  74. package/templates/uniapp/vite.config.js +8 -0
  75. package/templates/vue/.vscode/extensions.json +3 -0
  76. package/templates/vue/README.md +5 -0
  77. package/templates/vue/index.html +13 -0
  78. package/templates/vue/package.json +18 -0
  79. package/templates/vue/public/vite.svg +1 -0
  80. package/templates/vue/src/App.vue +30 -0
  81. package/templates/vue/src/assets/vue.svg +1 -0
  82. package/templates/vue/src/components/HelloWorld.vue +43 -0
  83. package/templates/vue/src/main.js +5 -0
  84. package/templates/vue/src/style.css +79 -0
  85. package/templates/vue/vite.config.js +7 -0
  86. package/tsconfig.json +19 -0
  87. package/vitest.config.ts +8 -0
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.petUsingPut = petUsingPut;
7
+ exports.petUsingPost = petUsingPost;
8
+ exports.petPetIdUsingGet = petPetIdUsingGet;
9
+ exports.petPetIdUsingPost = petPetIdUsingPost;
10
+ exports.petPetIdUsingDelete = petPetIdUsingDelete;
11
+ exports.petPetIdUploadImageUsingPost = petPetIdUploadImageUsingPost;
12
+ exports.petFindByStatusUsingGet = petFindByStatusUsingGet;
13
+ exports.petFindByTagsUsingGet = petFindByTagsUsingGet;
14
+ /* eslint-disable */
15
+ // @ts-ignore
16
+ const request_1 = __importDefault(require("./request"));
17
+ /** Update an existing pet. Update an existing pet by Id. 返回值: Unexpected error PUT /pet */
18
+ async function petUsingPut({ body, options, }) {
19
+ return (0, request_1.default)('/pet', {
20
+ method: 'PUT',
21
+ headers: {
22
+ 'Content-Type': 'application/json',
23
+ },
24
+ data: body,
25
+ ...(options || {}),
26
+ });
27
+ }
28
+ /** Add a new pet to the store. Add a new pet to the store. 返回值: Unexpected error POST /pet */
29
+ async function petUsingPost({ body, options, }) {
30
+ return (0, request_1.default)('/pet', {
31
+ method: 'POST',
32
+ headers: {
33
+ 'Content-Type': 'application/json',
34
+ },
35
+ data: body,
36
+ ...(options || {}),
37
+ });
38
+ }
39
+ /** Find pet by ID. Returns a single pet. 返回值: Unexpected error GET /pet/${param0} */
40
+ async function petPetIdUsingGet({ params, options, }) {
41
+ const { petId: param0, ...queryParams } = params;
42
+ return (0, request_1.default)(`/pet/${param0}`, {
43
+ method: 'GET',
44
+ params: { ...queryParams },
45
+ ...(options || {}),
46
+ });
47
+ }
48
+ /** Updates a pet in the store with form data. Updates a pet resource based on the form data. 返回值: Unexpected error POST /pet/${param0} */
49
+ async function petPetIdUsingPost({ params, options, }) {
50
+ const { petId: param0, ...queryParams } = params;
51
+ return (0, request_1.default)(`/pet/${param0}`, {
52
+ method: 'POST',
53
+ params: {
54
+ ...queryParams,
55
+ },
56
+ ...(options || {}),
57
+ });
58
+ }
59
+ /** Deletes a pet. Delete a pet. 返回值: Unexpected error DELETE /pet/${param0} */
60
+ async function petPetIdUsingDelete({ params, options, }) {
61
+ const { petId: param0, ...queryParams } = params;
62
+ return (0, request_1.default)(`/pet/${param0}`, {
63
+ method: 'DELETE',
64
+ params: { ...queryParams },
65
+ ...(options || {}),
66
+ });
67
+ }
68
+ /** Uploads an image. Upload image of the pet. 返回值: Unexpected error POST /pet/${param0}/uploadImage */
69
+ async function petPetIdUploadImageUsingPost({ params, body, options, }) {
70
+ const { petId: param0, ...queryParams } = params;
71
+ return (0, request_1.default)(`/pet/${param0}/uploadImage`, {
72
+ method: 'POST',
73
+ headers: {
74
+ 'Content-Type': 'application/octet-stream',
75
+ },
76
+ params: {
77
+ ...queryParams,
78
+ },
79
+ data: body,
80
+ ...(options || {}),
81
+ });
82
+ }
83
+ /** Finds Pets by status. Multiple status values can be provided with comma separated strings. 返回值: Unexpected error GET /pet/findByStatus */
84
+ async function petFindByStatusUsingGet({ params, options, }) {
85
+ return (0, request_1.default)('/pet/findByStatus', {
86
+ method: 'GET',
87
+ params: {
88
+ ...params,
89
+ },
90
+ ...(options || {}),
91
+ });
92
+ }
93
+ /** Finds Pets by tags. Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 返回值: Unexpected error GET /pet/findByTags */
94
+ async function petFindByTagsUsingGet({ params, options, }) {
95
+ return (0, request_1.default)('/pet/findByTags', {
96
+ method: 'GET',
97
+ params: {
98
+ ...params,
99
+ },
100
+ ...(options || {}),
101
+ });
102
+ }
@@ -0,0 +1,28 @@
1
+ import * as API from './types';
2
+ /** Returns pet inventories by status. Returns a map of status codes to quantities. 返回值: Unexpected error GET /store/inventory */
3
+ export declare function storeInventoryUsingGet({ options, }: {
4
+ options?: {
5
+ [key: string]: unknown;
6
+ };
7
+ }): Promise<any>;
8
+ /** Place an order for a pet. Place a new order in the store. 返回值: Unexpected error POST /store/order */
9
+ export declare function storeOrderUsingPost({ body, options, }: {
10
+ body: API.Order;
11
+ options?: {
12
+ [key: string]: unknown;
13
+ };
14
+ }): Promise<any>;
15
+ /** Find purchase order by ID. For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 返回值: Unexpected error GET /store/order/${param0} */
16
+ export declare function storeOrderOrderIdUsingGet({ params, options, }: {
17
+ params: API.storeOrderOrderIdUsingGetParams;
18
+ options?: {
19
+ [key: string]: unknown;
20
+ };
21
+ }): Promise<any>;
22
+ /** Delete purchase order by identifier. For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 返回值: Unexpected error DELETE /store/order/${param0} */
23
+ export declare function storeOrderOrderIdUsingDelete({ params, options, }: {
24
+ params: API.storeOrderOrderIdUsingDeleteParams;
25
+ options?: {
26
+ [key: string]: unknown;
27
+ };
28
+ }): Promise<any>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.storeInventoryUsingGet = storeInventoryUsingGet;
7
+ exports.storeOrderUsingPost = storeOrderUsingPost;
8
+ exports.storeOrderOrderIdUsingGet = storeOrderOrderIdUsingGet;
9
+ exports.storeOrderOrderIdUsingDelete = storeOrderOrderIdUsingDelete;
10
+ /* eslint-disable */
11
+ // @ts-ignore
12
+ const request_1 = __importDefault(require("./request"));
13
+ /** Returns pet inventories by status. Returns a map of status codes to quantities. 返回值: Unexpected error GET /store/inventory */
14
+ async function storeInventoryUsingGet({ options, }) {
15
+ return (0, request_1.default)('/store/inventory', {
16
+ method: 'GET',
17
+ ...(options || {}),
18
+ });
19
+ }
20
+ /** Place an order for a pet. Place a new order in the store. 返回值: Unexpected error POST /store/order */
21
+ async function storeOrderUsingPost({ body, options, }) {
22
+ return (0, request_1.default)('/store/order', {
23
+ method: 'POST',
24
+ headers: {
25
+ 'Content-Type': 'application/json',
26
+ },
27
+ data: body,
28
+ ...(options || {}),
29
+ });
30
+ }
31
+ /** Find purchase order by ID. For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 返回值: Unexpected error GET /store/order/${param0} */
32
+ async function storeOrderOrderIdUsingGet({ params, options, }) {
33
+ const { orderId: param0, ...queryParams } = params;
34
+ return (0, request_1.default)(`/store/order/${param0}`, {
35
+ method: 'GET',
36
+ params: { ...queryParams },
37
+ ...(options || {}),
38
+ });
39
+ }
40
+ /** Delete purchase order by identifier. For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 返回值: Unexpected error DELETE /store/order/${param0} */
41
+ async function storeOrderOrderIdUsingDelete({ params, options, }) {
42
+ const { orderId: param0, ...queryParams } = params;
43
+ return (0, request_1.default)(`/store/order/${param0}`, {
44
+ method: 'DELETE',
45
+ params: { ...queryParams },
46
+ ...(options || {}),
47
+ });
48
+ }
@@ -0,0 +1,110 @@
1
+ export type ApiResponse = {
2
+ code?: number;
3
+ type?: string;
4
+ message?: string;
5
+ };
6
+ export type Category = {
7
+ id?: number;
8
+ name?: string;
9
+ };
10
+ export type Order = {
11
+ id?: number;
12
+ petId?: number;
13
+ quantity?: number;
14
+ shipDate?: string;
15
+ /** Order Status */
16
+ status?: 'placed' | 'approved' | 'delivered';
17
+ complete?: boolean;
18
+ };
19
+ export type Pet = {
20
+ id?: number;
21
+ name: string;
22
+ category?: Category;
23
+ photoUrls: string[];
24
+ tags?: Tag[];
25
+ /** pet status in the store */
26
+ status?: 'available' | 'pending' | 'sold';
27
+ };
28
+ export type petFindByStatusUsingGetParams = {
29
+ /** Status values that need to be considered for filter */
30
+ status: 'available' | 'pending' | 'sold';
31
+ };
32
+ export type petFindByTagsUsingGetParams = {
33
+ /** Tags to filter by */
34
+ tags: string[];
35
+ };
36
+ export type petPetIdUploadImageUsingPostParams = {
37
+ /** ID of pet to update */
38
+ petId: number;
39
+ /** Additional Metadata */
40
+ additionalMetadata?: string;
41
+ };
42
+ export type petPetIdUsingDeleteParams = {
43
+ /** Pet id to delete */
44
+ petId: number;
45
+ };
46
+ export type petPetIdUsingGetParams = {
47
+ /** ID of pet to return */
48
+ petId: number;
49
+ };
50
+ export type petPetIdUsingPostParams = {
51
+ /** ID of pet that needs to be updated */
52
+ petId: number;
53
+ /** Name of pet that needs to be updated */
54
+ name?: string;
55
+ /** Status of pet that needs to be updated */
56
+ status?: string;
57
+ };
58
+ export declare enum StatusEnum {
59
+ placed = "placed",
60
+ approved = "approved",
61
+ delivered = "delivered"
62
+ }
63
+ export type IStatusEnum = keyof typeof StatusEnum;
64
+ export declare enum StatusEnum2 {
65
+ available = "available",
66
+ pending = "pending",
67
+ sold = "sold"
68
+ }
69
+ export type IStatusEnum2 = keyof typeof StatusEnum2;
70
+ export type storeOrderOrderIdUsingDeleteParams = {
71
+ /** ID of the order that needs to be deleted */
72
+ orderId: number;
73
+ };
74
+ export type storeOrderOrderIdUsingGetParams = {
75
+ /** ID of order that needs to be fetched */
76
+ orderId: number;
77
+ };
78
+ export type Tag = {
79
+ id?: number;
80
+ name?: string;
81
+ };
82
+ export type User = {
83
+ id?: number;
84
+ username?: string;
85
+ firstName?: string;
86
+ lastName?: string;
87
+ email?: string;
88
+ password?: string;
89
+ phone?: string;
90
+ /** User Status */
91
+ userStatus?: number;
92
+ };
93
+ export type userLoginUsingGetParams = {
94
+ /** The user name for login */
95
+ username?: string;
96
+ /** The password for login in clear text */
97
+ password?: string;
98
+ };
99
+ export type userUsernameUsingDeleteParams = {
100
+ /** The name that needs to be deleted */
101
+ username: string;
102
+ };
103
+ export type userUsernameUsingGetParams = {
104
+ /** The name that needs to be fetched. Use user1 for testing */
105
+ username: string;
106
+ };
107
+ export type userUsernameUsingPutParams = {
108
+ /** name that need to be deleted */
109
+ username: string;
110
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ // @ts-ignore
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.StatusEnum2 = exports.StatusEnum = void 0;
6
+ var StatusEnum;
7
+ (function (StatusEnum) {
8
+ StatusEnum["placed"] = "placed";
9
+ StatusEnum["approved"] = "approved";
10
+ StatusEnum["delivered"] = "delivered";
11
+ })(StatusEnum || (exports.StatusEnum = StatusEnum = {}));
12
+ var StatusEnum2;
13
+ (function (StatusEnum2) {
14
+ StatusEnum2["available"] = "available";
15
+ StatusEnum2["pending"] = "pending";
16
+ StatusEnum2["sold"] = "sold";
17
+ })(StatusEnum2 || (exports.StatusEnum2 = StatusEnum2 = {}));
@@ -0,0 +1,50 @@
1
+ import * as API from './types';
2
+ /** Create user. This can only be done by the logged in user. 返回值: Unexpected error POST /user */
3
+ export declare function userUsingPost({ body, options, }: {
4
+ body: API.User;
5
+ options?: {
6
+ [key: string]: unknown;
7
+ };
8
+ }): Promise<any>;
9
+ /** Get user by user name. Get user detail based on username. 返回值: Unexpected error GET /user/${param0} */
10
+ export declare function userUsernameUsingGet({ params, options, }: {
11
+ params: API.userUsernameUsingGetParams;
12
+ options?: {
13
+ [key: string]: unknown;
14
+ };
15
+ }): Promise<any>;
16
+ /** Update user resource. This can only be done by the logged in user. 返回值: Unexpected error PUT /user/${param0} */
17
+ export declare function userUsernameUsingPut({ params, body, options, }: {
18
+ params: API.userUsernameUsingPutParams;
19
+ body: API.User;
20
+ options?: {
21
+ [key: string]: unknown;
22
+ };
23
+ }): Promise<any>;
24
+ /** Delete user resource. This can only be done by the logged in user. 返回值: Unexpected error DELETE /user/${param0} */
25
+ export declare function userUsernameUsingDelete({ params, options, }: {
26
+ params: API.userUsernameUsingDeleteParams;
27
+ options?: {
28
+ [key: string]: unknown;
29
+ };
30
+ }): Promise<any>;
31
+ /** Creates list of users with given input array. Creates list of users with given input array. 返回值: Unexpected error POST /user/createWithList */
32
+ export declare function userCreateWithListUsingPost({ body, options, }: {
33
+ body: API.User[];
34
+ options?: {
35
+ [key: string]: unknown;
36
+ };
37
+ }): Promise<any>;
38
+ /** Logs user into the system. Log into the system. 返回值: Unexpected error GET /user/login */
39
+ export declare function userLoginUsingGet({ params, options, }: {
40
+ params: API.userLoginUsingGetParams;
41
+ options?: {
42
+ [key: string]: unknown;
43
+ };
44
+ }): Promise<any>;
45
+ /** Logs out current logged in user session. Log user out of the system. 返回值: Unexpected error GET /user/logout */
46
+ export declare function userLogoutUsingGet({ options, }: {
47
+ options?: {
48
+ [key: string]: unknown;
49
+ };
50
+ }): Promise<any>;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.userUsingPost = userUsingPost;
7
+ exports.userUsernameUsingGet = userUsernameUsingGet;
8
+ exports.userUsernameUsingPut = userUsernameUsingPut;
9
+ exports.userUsernameUsingDelete = userUsernameUsingDelete;
10
+ exports.userCreateWithListUsingPost = userCreateWithListUsingPost;
11
+ exports.userLoginUsingGet = userLoginUsingGet;
12
+ exports.userLogoutUsingGet = userLogoutUsingGet;
13
+ /* eslint-disable */
14
+ // @ts-ignore
15
+ const request_1 = __importDefault(require("./request"));
16
+ /** Create user. This can only be done by the logged in user. 返回值: Unexpected error POST /user */
17
+ async function userUsingPost({ body, options, }) {
18
+ return (0, request_1.default)('/user', {
19
+ method: 'POST',
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ data: body,
24
+ ...(options || {}),
25
+ });
26
+ }
27
+ /** Get user by user name. Get user detail based on username. 返回值: Unexpected error GET /user/${param0} */
28
+ async function userUsernameUsingGet({ params, options, }) {
29
+ const { username: param0, ...queryParams } = params;
30
+ return (0, request_1.default)(`/user/${param0}`, {
31
+ method: 'GET',
32
+ params: { ...queryParams },
33
+ ...(options || {}),
34
+ });
35
+ }
36
+ /** Update user resource. This can only be done by the logged in user. 返回值: Unexpected error PUT /user/${param0} */
37
+ async function userUsernameUsingPut({ params, body, options, }) {
38
+ const { username: param0, ...queryParams } = params;
39
+ return (0, request_1.default)(`/user/${param0}`, {
40
+ method: 'PUT',
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ },
44
+ params: { ...queryParams },
45
+ data: body,
46
+ ...(options || {}),
47
+ });
48
+ }
49
+ /** Delete user resource. This can only be done by the logged in user. 返回值: Unexpected error DELETE /user/${param0} */
50
+ async function userUsernameUsingDelete({ params, options, }) {
51
+ const { username: param0, ...queryParams } = params;
52
+ return (0, request_1.default)(`/user/${param0}`, {
53
+ method: 'DELETE',
54
+ params: { ...queryParams },
55
+ ...(options || {}),
56
+ });
57
+ }
58
+ /** Creates list of users with given input array. Creates list of users with given input array. 返回值: Unexpected error POST /user/createWithList */
59
+ async function userCreateWithListUsingPost({ body, options, }) {
60
+ return (0, request_1.default)('/user/createWithList', {
61
+ method: 'POST',
62
+ headers: {
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ data: body,
66
+ ...(options || {}),
67
+ });
68
+ }
69
+ /** Logs user into the system. Log into the system. 返回值: Unexpected error GET /user/login */
70
+ async function userLoginUsingGet({ params, options, }) {
71
+ return (0, request_1.default)('/user/login', {
72
+ method: 'GET',
73
+ params: {
74
+ ...params,
75
+ },
76
+ ...(options || {}),
77
+ });
78
+ }
79
+ /** Logs out current logged in user session. Log user out of the system. 返回值: Unexpected error GET /user/logout */
80
+ async function userLogoutUsingGet({ options, }) {
81
+ return (0, request_1.default)('/user/logout', {
82
+ method: 'GET',
83
+ ...(options || {}),
84
+ });
85
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const generate_1 = require("./commands/generate");
6
+ const update_1 = require("./commands/update");
7
+ const create_1 = require("./commands/create");
8
+ const path_1 = require("path");
9
+ const fs_1 = require("fs");
10
+ // 读取 package.json 中的版本号
11
+ const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json'), 'utf-8'));
12
+ commander_1.program.name('wz').description('万桩项目脚手架工具').version(packageJson.version);
13
+ commander_1.program
14
+ .command('create <name>')
15
+ .description('创建新项目')
16
+ .option('-t, --template <template>', '项目模板 (react、vue 或 uniapp)', 'react')
17
+ .option('-f, --force', '强制覆盖已存在的目录')
18
+ .action(async (name, options) => {
19
+ try {
20
+ await (0, create_1.createProject)(name, options);
21
+ }
22
+ catch (error) {
23
+ console.error('创建项目失败:', error);
24
+ process.exit(1);
25
+ }
26
+ });
27
+ commander_1.program
28
+ .command('api <url>')
29
+ .description('生成 API')
30
+ .option('-o, --output <dir>', '输出目录', './src/api')
31
+ .action(async (url, options) => {
32
+ try {
33
+ await (0, generate_1.generateApi)(url, options);
34
+ }
35
+ catch (error) {
36
+ console.error('生成 API 失败:', error);
37
+ process.exit(1);
38
+ }
39
+ });
40
+ commander_1.program
41
+ .command('update')
42
+ .description('更新依赖')
43
+ .action(async () => {
44
+ try {
45
+ await (0, update_1.updateDeps)();
46
+ }
47
+ catch (error) {
48
+ console.error('更新依赖失败:', error);
49
+ process.exit(1);
50
+ }
51
+ });
52
+ commander_1.program.parse();
@@ -0,0 +1 @@
1
+ export declare function generateApi(schemaPath: string, outputDir: string): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateApi = generateApi;
4
+ const openapi_ts_request_1 = require("openapi-ts-request");
5
+ const fs_extra_1 = require("fs-extra");
6
+ const prettier_1 = require("prettier");
7
+ const path_1 = require("path");
8
+ async function generateApi(schemaPath, outputDir) {
9
+ try {
10
+ // 确保输出目录存在
11
+ const absoluteOutputDir = (0, path_1.resolve)(process.cwd(), outputDir);
12
+ await (0, fs_extra_1.ensureDir)(absoluteOutputDir);
13
+ // 生成 API 代码
14
+ await (0, openapi_ts_request_1.generateService)({
15
+ schemaPath,
16
+ serversPath: absoluteOutputDir,
17
+ requestLibPath: './request',
18
+ isGenReactQuery: false,
19
+ isDisplayTypeLabel: true,
20
+ isGenJsonSchemas: false,
21
+ isCamelCase: true,
22
+ enableLogging: true,
23
+ });
24
+ // 格式化生成的文件
25
+ const files = ['api.ts', 'types.ts', 'request.ts'];
26
+ for (const file of files) {
27
+ const filePath = (0, path_1.join)(absoluteOutputDir, file);
28
+ try {
29
+ const content = await (0, fs_extra_1.readFile)(filePath, 'utf-8');
30
+ const formattedContent = await (0, prettier_1.format)(content, {
31
+ parser: 'typescript',
32
+ singleQuote: true,
33
+ trailingComma: 'all',
34
+ printWidth: 100,
35
+ });
36
+ await (0, fs_extra_1.writeFile)(filePath, formattedContent);
37
+ }
38
+ catch (error) {
39
+ console.warn(`警告:无法格式化 ${file}:`, error);
40
+ }
41
+ }
42
+ console.log('API 生成成功');
43
+ }
44
+ catch (error) {
45
+ console.error('生成 API 时出错:', error);
46
+ throw error;
47
+ }
48
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 生成 tsconfig.json,支持 react/vue/uniapp
3
+ * @param targetDir 目标目录
4
+ * @param type 模板类型
5
+ */
6
+ export declare function genTsConfig(targetDir: string, type: 'react' | 'vue' | 'uniapp'): void;
7
+ /**
8
+ * 生成 .eslintrc.json,自动适配类型和 features
9
+ * @param targetDir 目标目录
10
+ * @param type 模板类型
11
+ * @param features 功能选项
12
+ */
13
+ export declare function genEslintConfig(targetDir: string, type: string, features: string[]): void;
14
+ /**
15
+ * 生成 .prettierrc 和 .prettierignore
16
+ * @param targetDir 目标目录
17
+ */
18
+ export declare function genPrettierConfig(targetDir: string): void;
19
+ /**
20
+ * 生成 uno.config.ts
21
+ * @param targetDir 目标目录
22
+ */
23
+ export declare function genUnoConfig(targetDir: string): void;
24
+ /**
25
+ * 生成 tailwind.config.js 和 postcss.config.js
26
+ * @param targetDir 目标目录
27
+ */
28
+ export declare function genTailwindConfig(targetDir: string): void;