vona-cli-set-api 1.1.61 → 1.1.64
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/cli/templates/create/project/cabloy-basic/boilerplate/__CABLOY_BASIC__ +0 -0
- package/cli/templates/create/project/cabloy-basic/boilerplate/__VONA__ +1 -0
- package/cli/templates/create/project/cabloy-basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/cabloy-basic/package.json +2 -2
- package/cli/templates/create/project/cabloy-start/boilerplate/__CABLOY_START__ +0 -0
- package/cli/templates/create/project/cabloy-start/boilerplate/__VONA__ +1 -0
- package/cli/templates/create/project/cabloy-start/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/src/dto/login.ts +2 -2
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/src/dto/register.ts +2 -2
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/cabloy-start/modules/start-siteadmin/src/bean/ssrMenu.home.ts +2 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/cabloy-start/modules/start-siteadmin/src/bean/ssrMenuGroup.management.ts +4 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/cabloy-start/modules/start-siteadmin/src/bean/ssrSite.admin.ts +3 -2
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/cabloy-start/modules/start-siteweb/src/bean/ssrSite.web.ts +3 -2
- package/cli/templates/tools/crudStart/boilerplate/src/controller/{{resourceName}}.ts_ +49 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}Create.tsx_ +28 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}SelectReq.tsx_ +21 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}SelectRes.tsx_ +11 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}SelectResItem.tsx_ +36 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}Update.tsx_ +28 -0
- package/cli/templates/tools/crudStart/boilerplate/src/dto/{{resourceName}}View.tsx_ +23 -0
- package/cli/templates/tools/crudStart/boilerplate/src/entity/{{resourceName}}.tsx_ +49 -0
- package/cli/templates/tools/crudStart/boilerplate/src/model/{{resourceName}}.ts_ +8 -0
- package/cli/templates/tools/crudStart/boilerplate/src/service/{{resourceName}}.ts_ +35 -0
- package/cli/templates/tools/crudStart/boilerplate/test/{{resourceName}}.test.ts_ +43 -0
- package/cli/templates/tools/crudStart/snippets/1-package.json.ts +16 -0
- package/cli/templates/tools/crudStart/snippets/2-meta.index.ts +48 -0
- package/cli/templates/tools/crudStart/snippets/2-meta.version.ts +55 -0
- package/cli/templates/tools/crudStart/snippets/3-en-us.ts +30 -0
- package/cli/templates/tools/crudStart/snippets/4-zh-cn.ts +13 -0
- package/cli/templates/tools/crudStart/utils.ts +27 -0
- package/dist/index.js +92 -4
- package/dist/lib/bean/cli.tools.crudStart.d.ts +15 -0
- package/dist/lib/beans.d.ts +2 -0
- package/dist/lib/command/tools.crudStart.d.ts +34 -0
- package/dist/lib/commands.d.ts +33 -0
- package/dist-cli/templates/tools/crudStart/snippets/1-package.json.js +9 -0
- package/dist-cli/templates/tools/crudStart/snippets/2-meta.index.js +35 -0
- package/dist-cli/templates/tools/crudStart/snippets/2-meta.version.js +41 -0
- package/dist-cli/templates/tools/crudStart/snippets/3-en-us.js +20 -0
- package/dist-cli/templates/tools/crudStart/snippets/4-zh-cn.js +10 -0
- package/dist-cli/templates/tools/crudStart/utils.js +13 -0
- package/package.json +6 -6
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/cabloy-basic/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-suite-cabloy-basic",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.33",
|
|
4
4
|
"gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"vona-module-basic-siteadmin": "workspace:^",
|
|
14
|
-
"vona-suite-a-cabloy": "^5.1.
|
|
14
|
+
"vona-suite-a-cabloy": "^5.1.16"
|
|
15
15
|
},
|
|
16
16
|
"title": "cabloy-basic"
|
|
17
17
|
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -3,7 +3,7 @@ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
|
3
3
|
import { DtoCaptchaVerify } from 'vona-module-a-captcha';
|
|
4
4
|
import { Api, v } from 'vona-module-a-openapiutils';
|
|
5
5
|
import { Dto } from 'vona-module-a-web';
|
|
6
|
-
import { ZovaRender } from 'zova-rest-cabloy-
|
|
6
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
7
7
|
|
|
8
8
|
export interface IDtoOptionsLogin extends IDecoratorDtoOptions {}
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ export class DtoLogin {
|
|
|
18
18
|
@Api.field(
|
|
19
19
|
v.required(),
|
|
20
20
|
ZovaRender.layout({ iconPrefix: ':editor:code-block' }),
|
|
21
|
-
ZovaRender.field('
|
|
21
|
+
ZovaRender.field('start-captcha:formFieldCaptcha'),
|
|
22
22
|
)
|
|
23
23
|
captcha: DtoCaptchaVerify;
|
|
24
24
|
}
|
|
@@ -3,7 +3,7 @@ import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
|
3
3
|
import { DtoCaptchaVerify } from 'vona-module-a-captcha';
|
|
4
4
|
import { Api, v } from 'vona-module-a-openapiutils';
|
|
5
5
|
import { Dto } from 'vona-module-a-web';
|
|
6
|
-
import { ZovaRender } from 'zova-rest-cabloy-
|
|
6
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
7
7
|
|
|
8
8
|
export interface IDtoOptionsRegister extends IDecoratorDtoOptions {}
|
|
9
9
|
|
|
@@ -23,6 +23,6 @@ export class DtoRegister {
|
|
|
23
23
|
@Api.field(v.min(6), v.max(20))
|
|
24
24
|
passwordConfirm: string;
|
|
25
25
|
|
|
26
|
-
@Api.field(ZovaRender.field('
|
|
26
|
+
@Api.field(ZovaRender.field('start-captcha:formFieldCaptcha'))
|
|
27
27
|
captcha: DtoCaptchaVerify;
|
|
28
28
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { IDecoratorSsrMenuOptions } from 'vona-module-a-ssr';
|
|
2
|
-
import type { ISsrSiteOptionsAdmin } from 'vona-module-start-siteadmin';
|
|
3
2
|
|
|
4
3
|
import { BeanBase } from 'vona';
|
|
5
4
|
import { $order } from 'vona-module-a-openapiutils';
|
|
6
5
|
import { SsrMenu } from 'vona-module-a-ssr';
|
|
7
6
|
|
|
7
|
+
import type { ISsrSiteOptionsAdmin } from './ssrSite.admin.ts';
|
|
8
|
+
|
|
8
9
|
import { $locale } from '../.metadata/locales.ts';
|
|
9
10
|
|
|
10
11
|
export interface ISsrMenuOptionsHome extends IDecoratorSsrMenuOptions<ISsrSiteOptionsAdmin> {}
|
|
@@ -4,14 +4,17 @@ import { BeanBase } from 'vona';
|
|
|
4
4
|
import { $order } from 'vona-module-a-openapiutils';
|
|
5
5
|
import { SsrMenuGroup } from 'vona-module-a-ssr';
|
|
6
6
|
|
|
7
|
+
import type { ISsrSiteOptionsAdmin } from './ssrSite.admin.ts';
|
|
8
|
+
|
|
7
9
|
import { $locale } from '../.metadata/locales.ts';
|
|
8
10
|
|
|
9
|
-
export interface ISsrMenuGroupOptionsManagement extends IDecoratorSsrMenuGroupOptions {}
|
|
11
|
+
export interface ISsrMenuGroupOptionsManagement extends IDecoratorSsrMenuGroupOptions<ISsrSiteOptionsAdmin> {}
|
|
10
12
|
|
|
11
13
|
@SsrMenuGroup<ISsrMenuGroupOptionsManagement>({
|
|
12
14
|
item: {
|
|
13
15
|
title: $locale('Management'),
|
|
14
16
|
order: $order(2),
|
|
17
|
+
icon: undefined,
|
|
15
18
|
},
|
|
16
19
|
site: ['start-siteadmin:admin'],
|
|
17
20
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IDecoratorSsrSiteOptions } from 'vona-module-a-ssr';
|
|
2
|
-
import type { IPagePathRecord } from 'zova-rest-cabloy-start-admin';
|
|
2
|
+
import type { IIconRecord, IPagePathRecord } from 'zova-rest-cabloy-start-admin';
|
|
3
3
|
|
|
4
4
|
import { BeanSsrSiteBase, SsrSite } from 'vona-module-a-ssr';
|
|
5
5
|
|
|
@@ -15,7 +15,8 @@ export interface ISsrSiteOptionsAdminPagesData {}
|
|
|
15
15
|
|
|
16
16
|
export interface ISsrSiteOptionsAdmin extends IDecoratorSsrSiteOptions<
|
|
17
17
|
ISsrSiteOptionsAdminPages,
|
|
18
|
-
ISsrSiteOptionsAdminPagesData
|
|
18
|
+
ISsrSiteOptionsAdminPagesData,
|
|
19
|
+
IIconRecord
|
|
19
20
|
> {}
|
|
20
21
|
|
|
21
22
|
@SsrSite<ISsrSiteOptionsAdmin>({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IDecoratorSsrSiteOptions } from 'vona-module-a-ssr';
|
|
2
|
-
import type { IPagePathRecord } from 'zova-rest-cabloy-start-web';
|
|
2
|
+
import type { IIconRecord, IPagePathRecord } from 'zova-rest-cabloy-start-web';
|
|
3
3
|
|
|
4
4
|
import { BeanSsrSiteBase, SsrSite } from 'vona-module-a-ssr';
|
|
5
5
|
|
|
@@ -15,7 +15,8 @@ export interface ISsrSiteOptionsWebPagesData {}
|
|
|
15
15
|
|
|
16
16
|
export interface ISsrSiteOptionsWeb extends IDecoratorSsrSiteOptions<
|
|
17
17
|
ISsrSiteOptionsWebPages,
|
|
18
|
-
ISsrSiteOptionsWebPagesData
|
|
18
|
+
ISsrSiteOptionsWebPagesData,
|
|
19
|
+
IIconRecord
|
|
19
20
|
> {}
|
|
20
21
|
|
|
21
22
|
@SsrSite<ISsrSiteOptionsWeb>({
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IQueryParams } from 'vona-module-a-orm';
|
|
3
|
+
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
4
|
+
|
|
5
|
+
import { BeanBase } from 'vona';
|
|
6
|
+
import { Api, Resource, v } from 'vona-module-a-openapiutils';
|
|
7
|
+
import { Arg, Controller, Web } from 'vona-module-a-web';
|
|
8
|
+
|
|
9
|
+
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
10
|
+
|
|
11
|
+
import { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.tsx';
|
|
12
|
+
import { Dto<%=argv.resourceNameCapitalize%>SelectReq } from '../dto/<%=argv.resourceName%>SelectReq.tsx';
|
|
13
|
+
import { Dto<%=argv.resourceNameCapitalize%>SelectRes } from '../dto/<%=argv.resourceName%>SelectRes.tsx';
|
|
14
|
+
import { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.tsx';
|
|
15
|
+
import { Dto<%=argv.resourceNameCapitalize%>View } from '../dto/<%=argv.resourceName%>View.tsx';
|
|
16
|
+
|
|
17
|
+
export interface IControllerOptions<%=argv.resourceNameCapitalize%> extends IDecoratorControllerOptions {}
|
|
18
|
+
|
|
19
|
+
@Controller<IControllerOptions<%=argv.resourceNameCapitalize%>>('<%=argv.resourceName%>')
|
|
20
|
+
@Resource()
|
|
21
|
+
export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
22
|
+
@Web.post()
|
|
23
|
+
@Api.body(v.tableIdentity())
|
|
24
|
+
async create(@Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<TableIdentity> {
|
|
25
|
+
return (await this.scope.service.<%=argv.resourceName%>.create(<%=argv.resourceName%>)).id;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Web.get()
|
|
29
|
+
@Api.body(Dto<%=argv.resourceNameCapitalize%>SelectRes)
|
|
30
|
+
async select(@Arg.filter(Dto<%=argv.resourceNameCapitalize%>SelectReq) params: IQueryParams<Model<%=argv.resourceNameCapitalize%>>): Promise<Dto<%=argv.resourceNameCapitalize%>SelectRes> {
|
|
31
|
+
return await this.scope.service.<%=argv.resourceName%>.select(params);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Web.get(':id')
|
|
35
|
+
@Api.body(v.optional(), v.object(Dto<%=argv.resourceNameCapitalize%>View))
|
|
36
|
+
async view(@Arg.param('id', v.tableIdentity()) id: TableIdentity): Promise<Dto<%=argv.resourceNameCapitalize%>View | undefined> {
|
|
37
|
+
return await this.scope.service.<%=argv.resourceName%>.view(id);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Web.patch(':id')
|
|
41
|
+
async update(@Arg.param('id', v.tableIdentity()) id: TableIdentity, @Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Update) {
|
|
42
|
+
return await this.scope.service.<%=argv.resourceName%>.update(id, <%=argv.resourceName%>);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@Web.delete(':id')
|
|
46
|
+
async delete(@Arg.param('id', v.tableIdentity()) id: TableIdentity) {
|
|
47
|
+
return await this.scope.service.<%=argv.resourceName%>.delete(id);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
6
|
+
|
|
7
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Create extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Create>({
|
|
12
|
+
blocks: [
|
|
13
|
+
ZovaRender.block('start-pageentry:blockPageEntry', {
|
|
14
|
+
blocks: [
|
|
15
|
+
ZovaRender.block('start-pageentry:blockForm'),
|
|
16
|
+
ZovaRender.block('start-pageentry:blockToolbarRow', {
|
|
17
|
+
actions: [
|
|
18
|
+
ZovaRender.formActionRow('start-form:actionSubmit', {
|
|
19
|
+
permission: { action: 'update', formScene: ['create', 'edit'] },
|
|
20
|
+
}),
|
|
21
|
+
ZovaRender.formActionRow('start-form:actionBack', { permission: { public: true } }),
|
|
22
|
+
],
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
export class Dto<%=argv.resourceNameCapitalize%>Create extends $Dto.create(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
5
|
+
import { Dto } from 'vona-module-a-web';
|
|
6
|
+
import z from 'zod';
|
|
7
|
+
|
|
8
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.tsx';
|
|
9
|
+
|
|
10
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>SelectReq extends IDecoratorDtoOptions {}
|
|
11
|
+
|
|
12
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>SelectReq>({
|
|
13
|
+
openapi: { filter: { table: '<%=argv.moduleResourceName%>' } },
|
|
14
|
+
fields: {
|
|
15
|
+
createdAt: z.string().optional(),
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
export class Dto<%=argv.resourceNameCapitalize%>SelectReq extends $Dto.queryPage(Entity<%=argv.resourceNameCapitalize%>, ['name', 'createdAt']) {
|
|
19
|
+
@Api.field(v.optional())
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
|
|
6
|
+
import { Dto<%=argv.resourceNameCapitalize%>SelectResItem } from './<%=argv.resourceName%>SelectResItem.tsx';
|
|
7
|
+
|
|
8
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>SelectRes extends IDecoratorDtoOptions {}
|
|
9
|
+
|
|
10
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>SelectRes>()
|
|
11
|
+
export class Dto<%=argv.resourceNameCapitalize%>SelectRes extends $Dto.listAndCount(Dto<%=argv.resourceNameCapitalize%>SelectResItem) {}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
5
|
+
import { Dto } from 'vona-module-a-web';
|
|
6
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
7
|
+
|
|
8
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
9
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
10
|
+
|
|
11
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>SelectResItem extends IDecoratorDtoOptions {}
|
|
12
|
+
|
|
13
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>SelectResItem>({
|
|
14
|
+
blocks: [
|
|
15
|
+
ZovaRender.block('start-page:blockPage', {
|
|
16
|
+
blocks: [
|
|
17
|
+
ZovaRender.block('start-page:blockFilter'),
|
|
18
|
+
ZovaRender.block('start-page:blockToolbarBulk', {
|
|
19
|
+
actions: [ZovaRender.tableActionBulk('start-table:actionCreate')],
|
|
20
|
+
}),
|
|
21
|
+
ZovaRender.block('start-page:blockTable'),
|
|
22
|
+
ZovaRender.block('start-page:blockPager'),
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
export class Dto<%=argv.resourceNameCapitalize%>SelectResItem extends $Dto.get(() => Model<%=argv.resourceNameCapitalize%>) {
|
|
28
|
+
@Api.field(
|
|
29
|
+
v.title($locale('Operations')),
|
|
30
|
+
ZovaRender.order(1, 'max'),
|
|
31
|
+
ZovaRender.cell('start-table:actionOperationsRow', {
|
|
32
|
+
actions: [ZovaRender.tableActionRow('start-table:actionUpdate'), ZovaRender.tableActionRow('start-table:actionDelete')],
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
35
|
+
_operationsRow?: unknown;
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
6
|
+
|
|
7
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Update extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Update>({
|
|
12
|
+
blocks: [
|
|
13
|
+
ZovaRender.block('start-pageentry:blockPageEntry', {
|
|
14
|
+
blocks: [
|
|
15
|
+
ZovaRender.block('start-pageentry:blockForm'),
|
|
16
|
+
ZovaRender.block('start-pageentry:blockToolbarRow', {
|
|
17
|
+
actions: [
|
|
18
|
+
ZovaRender.formActionRow('start-form:actionSubmit', {
|
|
19
|
+
permission: { action: 'update', formScene: ['create', 'edit'] },
|
|
20
|
+
}),
|
|
21
|
+
ZovaRender.formActionRow('start-form:actionBack', { permission: { public: true } }),
|
|
22
|
+
],
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
export class Dto<%=argv.resourceNameCapitalize%>Update extends $Dto.update(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
|
|
3
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
4
|
+
import { Dto } from 'vona-module-a-web';
|
|
5
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
6
|
+
|
|
7
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
8
|
+
|
|
9
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>View extends IDecoratorDtoOptions {}
|
|
10
|
+
|
|
11
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>View>({
|
|
12
|
+
blocks: [
|
|
13
|
+
ZovaRender.block('start-pageentry:blockPageEntry', {
|
|
14
|
+
blocks: [
|
|
15
|
+
ZovaRender.block('start-pageentry:blockForm'),
|
|
16
|
+
ZovaRender.block('start-pageentry:blockToolbarRow', {
|
|
17
|
+
actions: [ZovaRender.formActionRow('start-form:actionBack', { permission: { public: true } })],
|
|
18
|
+
}),
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
],
|
|
22
|
+
})
|
|
23
|
+
export class Dto<%=argv.resourceNameCapitalize%>View extends $Dto.get(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
|
|
3
|
+
import { $makeMetadata, Api, v } from 'vona-module-a-openapiutils';
|
|
4
|
+
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
5
|
+
import { ZovaRender } from 'zova-rest-cabloy-start-admin';
|
|
6
|
+
|
|
7
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
8
|
+
|
|
9
|
+
export interface IEntityOptions<%=argv.resourceNameCapitalize%> extends IDecoratorEntityOptions {}
|
|
10
|
+
|
|
11
|
+
@Entity<IEntityOptions<%=argv.resourceNameCapitalize%>>('<%=argv.moduleResourceName%>', {
|
|
12
|
+
openapi: { title: $locale('<%=argv.resourceNameCapitalize%>') },
|
|
13
|
+
fields: {
|
|
14
|
+
id: $makeMetadata(ZovaRender.order(1, 'core')),
|
|
15
|
+
iid: $makeMetadata(ZovaRender.visible(false)),
|
|
16
|
+
deleted: $makeMetadata(ZovaRender.visible(false)),
|
|
17
|
+
createdAt: $makeMetadata(
|
|
18
|
+
ZovaRender.order(-2, 'max'),
|
|
19
|
+
ZovaRender.field('start-date:formFieldDate'),
|
|
20
|
+
ZovaRender.cell('start-date:date'),
|
|
21
|
+
ZovaRender.field('start-date:formFieldDateRange', undefined, 'filter'),
|
|
22
|
+
v.filterTransform('a-web:dateRange'),
|
|
23
|
+
),
|
|
24
|
+
updatedAt: $makeMetadata(
|
|
25
|
+
ZovaRender.order(-1, 'max'),
|
|
26
|
+
ZovaRender.field('start-date:formFieldDate'),
|
|
27
|
+
ZovaRender.cell('start-date:date'),
|
|
28
|
+
ZovaRender.field('start-date:formFieldDateRange', undefined, 'filter'),
|
|
29
|
+
v.filterTransform('a-web:dateRange'),
|
|
30
|
+
),
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
export class Entity<%=argv.resourceNameCapitalize%> extends EntityBase {
|
|
34
|
+
@Api.field(
|
|
35
|
+
v.title($locale('Name')),
|
|
36
|
+
v.required(),
|
|
37
|
+
v.min(2),
|
|
38
|
+
ZovaRender.order(1),
|
|
39
|
+
ZovaRender.cell('start-table:actionView'),
|
|
40
|
+
)
|
|
41
|
+
name: string;
|
|
42
|
+
|
|
43
|
+
@Api.field(
|
|
44
|
+
v.title($locale('Description')),
|
|
45
|
+
v.optional(),
|
|
46
|
+
ZovaRender.order(2),
|
|
47
|
+
)
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IDecoratorModelOptions } from 'vona-module-a-orm';
|
|
2
|
+
import { BeanModelBase, Model } from 'vona-module-a-orm';
|
|
3
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.tsx';
|
|
4
|
+
|
|
5
|
+
export interface IModelOptions<%=argv.resourceNameCapitalize%> extends IDecoratorModelOptions<Entity<%=argv.resourceNameCapitalize%>> {}
|
|
6
|
+
|
|
7
|
+
@Model<IModelOptions<%=argv.resourceNameCapitalize%>>({ entity: Entity<%=argv.resourceNameCapitalize%> })
|
|
8
|
+
export class Model<%=argv.resourceNameCapitalize%> extends BeanModelBase<Entity<%=argv.resourceNameCapitalize%>> {}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
|
+
import type { IQueryParams } from 'vona-module-a-orm';
|
|
3
|
+
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { Service } from 'vona-module-a-bean';
|
|
6
|
+
|
|
7
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.tsx';
|
|
8
|
+
import type { Dto<%=argv.resourceNameCapitalize%>SelectRes } from '../dto/<%=argv.resourceName%>SelectRes.tsx';
|
|
9
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.tsx';
|
|
10
|
+
import type { Dto<%=argv.resourceNameCapitalize%>View } from '../dto/<%=argv.resourceName%>View.tsx';
|
|
11
|
+
import type { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.tsx';
|
|
12
|
+
import type { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
13
|
+
|
|
14
|
+
@Service()
|
|
15
|
+
export class Service<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
16
|
+
async create(<%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<Entity<%=argv.resourceNameCapitalize%>> {
|
|
17
|
+
return await this.scope.model.<%=argv.resourceName%>.insert(<%=argv.resourceName%>);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async select(params?: IQueryParams<Model<%=argv.resourceNameCapitalize%>>): Promise<Dto<%=argv.resourceNameCapitalize%>SelectRes> {
|
|
21
|
+
return await this.scope.model.<%=argv.resourceName%>.selectAndCount(params);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async view(id: TableIdentity): Promise<Dto<%=argv.resourceNameCapitalize%>View | undefined> {
|
|
25
|
+
return await this.scope.model.<%=argv.resourceName%>.getById(id);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async update(id: TableIdentity, <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Update) {
|
|
29
|
+
return await this.scope.model.<%=argv.resourceName%>.updateById(id, <%=argv.resourceName%>);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async delete(id: TableIdentity) {
|
|
33
|
+
return await this.scope.model.<%=argv.resourceName%>.deleteById(id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Create, Dto<%=argv.resourceNameCapitalize%>SelectRes, Dto<%=argv.resourceNameCapitalize%>Update, Entity<%=argv.resourceNameCapitalize%> } from 'vona-module-<%=argv.moduleInfo.relativeName%>';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import { app } from 'vona-mock';
|
|
5
|
+
|
|
6
|
+
describe('<%=argv.resourceName%>.test.ts', () => {
|
|
7
|
+
it('action:<%=argv.resourceName%>', async () => {
|
|
8
|
+
await app.bean.executor.mockCtx(async () => {
|
|
9
|
+
// data
|
|
10
|
+
const data: Dto<%=argv.resourceNameCapitalize%>Create = {
|
|
11
|
+
name: '__Tom__',
|
|
12
|
+
description: 'This is a test',
|
|
13
|
+
};
|
|
14
|
+
const dataUpdate: Dto<%=argv.resourceNameCapitalize%>Update = {
|
|
15
|
+
name: '__TomNew__',
|
|
16
|
+
description: 'This is a test',
|
|
17
|
+
};
|
|
18
|
+
// login
|
|
19
|
+
await app.bean.passport.signinMock();
|
|
20
|
+
// create
|
|
21
|
+
const <%=argv.resourceName%>Id = await app.bean.executor.performAction('post', '<%=argv.moduleActionPathRaw%>', { body: data });
|
|
22
|
+
assert.equal(!!<%=argv.resourceName%>Id, true);
|
|
23
|
+
// findMany
|
|
24
|
+
const selectRes: Dto<%=argv.resourceNameCapitalize%>SelectRes = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>');
|
|
25
|
+
assert.equal(selectRes.list.findIndex(item => item.name === data.name) > -1, true);
|
|
26
|
+
// update
|
|
27
|
+
await app.bean.executor.performAction('patch', '<%=argv.moduleActionPathRaw%>/:id', {
|
|
28
|
+
params: { id: <%=argv.resourceName%>Id },
|
|
29
|
+
body: dataUpdate,
|
|
30
|
+
});
|
|
31
|
+
// findOne
|
|
32
|
+
let <%=argv.resourceName%>: Entity<%=argv.resourceNameCapitalize%> = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>Id } });
|
|
33
|
+
assert.equal(<%=argv.resourceName%>.name, dataUpdate.name);
|
|
34
|
+
// delete
|
|
35
|
+
await app.bean.executor.performAction('delete', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>.id } });
|
|
36
|
+
// findOne
|
|
37
|
+
<%=argv.resourceName%> = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>.id } });
|
|
38
|
+
assert.equal(<%=argv.resourceName%>, undefined);
|
|
39
|
+
// logout
|
|
40
|
+
await app.bean.passport.signout();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
|
|
3
|
+
declare module '@cabloy/cli' {
|
|
4
|
+
interface ICommandArgv {
|
|
5
|
+
fileVersion: number;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default metadataCustomSnippet({
|
|
10
|
+
file: 'package.json',
|
|
11
|
+
language: 'json',
|
|
12
|
+
async transform({ ast, argv }) {
|
|
13
|
+
argv.fileVersion = ast.vonaModule.fileVersion = 1 + (ast.vonaModule.fileVersion ?? 0);
|
|
14
|
+
return ast;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
declare module '@cabloy/cli' {
|
|
6
|
+
interface ICommandArgv {
|
|
7
|
+
module: string;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const __snippet_import1 = "import { $tableColumns } from 'vona-module-a-ormutils';";
|
|
12
|
+
const __snippet_update = "...$tableColumns('<%=argv.moduleResourceName%>', 'name'),";
|
|
13
|
+
|
|
14
|
+
export default metadataCustomSnippet({
|
|
15
|
+
file: 'src/bean/meta.index.ts',
|
|
16
|
+
language: 'plain',
|
|
17
|
+
format: true,
|
|
18
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
19
|
+
await catchError(() => {
|
|
20
|
+
return cli.helper.invokeCli(
|
|
21
|
+
[':create:bean', 'meta', 'index', `--module=${argv.module}`, '--nometadata', '--noformat'],
|
|
22
|
+
{
|
|
23
|
+
cwd: argv.projectPath,
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
28
|
+
},
|
|
29
|
+
async transform({ cli, ast }) {
|
|
30
|
+
// import1
|
|
31
|
+
if (!ast.includes(__snippet_import1)) {
|
|
32
|
+
const code = await cli.template.renderContent({ content: __snippet_import1 });
|
|
33
|
+
ast = ast.replace(
|
|
34
|
+
"import { Meta } from 'vona-module-a-meta';",
|
|
35
|
+
`import { Meta } from 'vona-module-a-meta';\n${code}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
// update
|
|
39
|
+
const code = await cli.template.renderContent({ content: __snippet_update });
|
|
40
|
+
if (ast.includes('indexes: {}')) {
|
|
41
|
+
ast = ast.replace('indexes: {', `indexes: {\n ${code}\n `);
|
|
42
|
+
} else {
|
|
43
|
+
ast = ast.replace('indexes: {', `indexes: {\n ${code}`);
|
|
44
|
+
}
|
|
45
|
+
// ok
|
|
46
|
+
return ast;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
declare module '@cabloy/cli' {
|
|
6
|
+
interface ICommandArgv {
|
|
7
|
+
module: string;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const __snippet_update = `if (options.version === <%=argv.fileVersion%>) {
|
|
12
|
+
const entity<%=argv.resourceNameCapitalize%> = this.scope.entity.<%=argv.resourceName%>;
|
|
13
|
+
await this.bean.model.createTable(entity<%=argv.resourceNameCapitalize%>.$table, table => {
|
|
14
|
+
table.comment(entity<%=argv.resourceNameCapitalize%>.$comment.$table);
|
|
15
|
+
table.basicFields();
|
|
16
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.name, 50).comment(entity<%=argv.resourceNameCapitalize%>.$comment.name);
|
|
17
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.description, 255).comment(entity<%=argv.resourceNameCapitalize%>.$comment.description);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export default metadataCustomSnippet({
|
|
23
|
+
file: 'src/bean/meta.version.ts',
|
|
24
|
+
language: 'gogo',
|
|
25
|
+
format: true,
|
|
26
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
27
|
+
await catchError(() => {
|
|
28
|
+
return cli.helper.invokeCli(
|
|
29
|
+
[
|
|
30
|
+
':create:bean',
|
|
31
|
+
'meta',
|
|
32
|
+
'version',
|
|
33
|
+
`--module=${argv.module}`,
|
|
34
|
+
'--nometadata',
|
|
35
|
+
'--noformat',
|
|
36
|
+
],
|
|
37
|
+
{
|
|
38
|
+
cwd: argv.projectPath,
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
43
|
+
},
|
|
44
|
+
async transform({ cli, ast }) {
|
|
45
|
+
// update
|
|
46
|
+
ast.replace(
|
|
47
|
+
'async update(_options: IMetaVersionUpdateOptions) {$$$1}',
|
|
48
|
+
'async update(options: IMetaVersionUpdateOptions) {$$$1}',
|
|
49
|
+
);
|
|
50
|
+
const code = await cli.template.renderContent({ content: __snippet_update });
|
|
51
|
+
ast.replace('async update($$$0) {$$$1}', `async update($$$0) {\n $$$1\n ${code}}`);
|
|
52
|
+
// ok
|
|
53
|
+
return ast;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
import { locale_transform } from '../utils.ts';
|
|
6
|
+
|
|
7
|
+
const __resources = { Name: 'Name', Description: 'Description', Operations: 'Operations' };
|
|
8
|
+
|
|
9
|
+
declare module '@cabloy/cli' {
|
|
10
|
+
interface ICommandArgv {
|
|
11
|
+
module: string;
|
|
12
|
+
resourceNameCapitalize: string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default metadataCustomSnippet({
|
|
17
|
+
file: 'src/config/locale/en-us.ts',
|
|
18
|
+
language: 'plain',
|
|
19
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
20
|
+
await catchError(() => {
|
|
21
|
+
return cli.helper.invokeCli([':init:locale', argv.module, '--nometadata', '--noformat'], {
|
|
22
|
+
cwd: argv.projectPath,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
26
|
+
},
|
|
27
|
+
async transform({ ast, argv }) {
|
|
28
|
+
return locale_transform({ ast, argv, resources: __resources });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
|
|
3
|
+
import { locale_transform } from '../utils.ts';
|
|
4
|
+
|
|
5
|
+
const __resources = { Name: '名称', Description: '描述', Operations: '操作' };
|
|
6
|
+
|
|
7
|
+
export default metadataCustomSnippet({
|
|
8
|
+
file: 'src/config/locale/zh-cn.ts',
|
|
9
|
+
language: 'plain',
|
|
10
|
+
async transform({ ast, argv }) {
|
|
11
|
+
return locale_transform({ ast, argv, resources: __resources });
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { evaluateSimple } from '@cabloy/utils';
|
|
2
|
+
|
|
3
|
+
export async function locale_transform({
|
|
4
|
+
ast,
|
|
5
|
+
argv,
|
|
6
|
+
resources,
|
|
7
|
+
}: {
|
|
8
|
+
ast: string;
|
|
9
|
+
argv: any;
|
|
10
|
+
resources: any;
|
|
11
|
+
}) {
|
|
12
|
+
const values = evaluateSimple(ast.replace('export default', '').replace(';', ''));
|
|
13
|
+
resources = Object.assign(
|
|
14
|
+
{},
|
|
15
|
+
resources,
|
|
16
|
+
{ [argv.resourceNameCapitalize]: argv.resourceNameCapitalize },
|
|
17
|
+
values,
|
|
18
|
+
);
|
|
19
|
+
const keys = Object.keys(resources).sort();
|
|
20
|
+
let content = '';
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
content += ` ${key}: '${resources[key].replaceAll("'", "\\'")}',\n`;
|
|
23
|
+
}
|
|
24
|
+
ast = `export default {\n${content}};\n`;
|
|
25
|
+
// ok
|
|
26
|
+
return ast;
|
|
27
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1972,9 +1972,10 @@ class CliToolsCrud extends BeanCliBase {
|
|
|
1972
1972
|
// noformat
|
|
1973
1973
|
// argv.noformat = true;
|
|
1974
1974
|
// ssrSiteModuleName
|
|
1975
|
-
|
|
1976
|
-
argv.
|
|
1977
|
-
argv.
|
|
1975
|
+
const isCabloyStart = fs.existsSync(path.join(argv.projectPath, '__CABLOY_START__'));
|
|
1976
|
+
argv.ssrSiteModuleName = isCabloyStart ? 'vona-module-start-siteadmin' : 'vona-module-basic-siteadmin';
|
|
1977
|
+
argv.ssrSiteOnionName = isCabloyStart ? 'start-siteadmin:admin' : 'basic-siteadmin:admin';
|
|
1978
|
+
argv.ssrSiteGroupName = isCabloyStart ? 'start-siteadmin:management' : 'basic-siteadmin:management';
|
|
1978
1979
|
// module name/info
|
|
1979
1980
|
const moduleName = argv.module;
|
|
1980
1981
|
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
@@ -1994,7 +1995,8 @@ class CliToolsCrud extends BeanCliBase {
|
|
|
1994
1995
|
throw new Error(`resource exists: ${resourceName}`);
|
|
1995
1996
|
}
|
|
1996
1997
|
// tools:crud
|
|
1997
|
-
|
|
1998
|
+
const commandName = isCabloyStart ? ':tools:crudStart' : ':tools:crudBasic';
|
|
1999
|
+
await this.helper.invokeCli([commandName, resourceName, `--module=${argv.module}`, '--nometadata'], {
|
|
1998
2000
|
cwd: argv.projectPath
|
|
1999
2001
|
});
|
|
2000
2002
|
// render
|
|
@@ -2059,6 +2061,52 @@ class CliToolsCrudBasic extends BeanCliBase {
|
|
|
2059
2061
|
}
|
|
2060
2062
|
}
|
|
2061
2063
|
|
|
2064
|
+
class CliToolsCrudStart extends BeanCliBase {
|
|
2065
|
+
async execute() {
|
|
2066
|
+
const {
|
|
2067
|
+
argv
|
|
2068
|
+
} = this.context;
|
|
2069
|
+
// super
|
|
2070
|
+
await super.execute();
|
|
2071
|
+
// noformat
|
|
2072
|
+
// argv.noformat = true;
|
|
2073
|
+
// module name/info
|
|
2074
|
+
const moduleName = argv.module;
|
|
2075
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2076
|
+
// check if exists
|
|
2077
|
+
const _module = this.helper.findModule(moduleName);
|
|
2078
|
+
if (!_module) {
|
|
2079
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2080
|
+
}
|
|
2081
|
+
// target dir
|
|
2082
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2083
|
+
// resourceName
|
|
2084
|
+
const resourceName = argv.resourceName;
|
|
2085
|
+
argv.resourceNameCapitalize = this.helper.firstCharToUpperCase(resourceName);
|
|
2086
|
+
// moduleResourceName
|
|
2087
|
+
argv.moduleResourceName = this.helper.combineModuleNameAndResource(argv.moduleInfo.relativeName, argv.resourceName);
|
|
2088
|
+
argv.moduleActionPathRaw = combineApiPathControllerAndActionRaw(moduleName, resourceName, '', true);
|
|
2089
|
+
// controller
|
|
2090
|
+
const controllerFile = path.join(targetDir, 'src/controller', `${resourceName}.ts`);
|
|
2091
|
+
if (fs.existsSync(controllerFile)) {
|
|
2092
|
+
throw new Error(`resource exists: ${resourceName}`);
|
|
2093
|
+
}
|
|
2094
|
+
// render
|
|
2095
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2096
|
+
targetDir,
|
|
2097
|
+
setName: __ThisSetName__,
|
|
2098
|
+
snippetsPath: 'tools/crudStart/snippets',
|
|
2099
|
+
boilerplatePath: 'tools/crudStart/boilerplate'
|
|
2100
|
+
});
|
|
2101
|
+
// tools.metadata
|
|
2102
|
+
if (!argv.nometadata) {
|
|
2103
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2104
|
+
cwd: argv.projectPath
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2062
2110
|
class CliToolsDeps extends BeanCliBase {
|
|
2063
2111
|
async execute() {
|
|
2064
2112
|
const {
|
|
@@ -2749,6 +2797,10 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2749
2797
|
const localesDest = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
2750
2798
|
// save
|
|
2751
2799
|
await fse.writeFile(localesDest, contentLocales);
|
|
2800
|
+
await this.helper.formatFile({
|
|
2801
|
+
fileName: localesDest,
|
|
2802
|
+
logPrefix: 'format: '
|
|
2803
|
+
});
|
|
2752
2804
|
}
|
|
2753
2805
|
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
2754
2806
|
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
@@ -2868,6 +2920,7 @@ const beans = {
|
|
|
2868
2920
|
'tools.deps': CliToolsDeps,
|
|
2869
2921
|
'tools.metadata': CliToolsMetadata,
|
|
2870
2922
|
'tools.crudBasic': CliToolsCrudBasic,
|
|
2923
|
+
'tools.crudStart': CliToolsCrudStart,
|
|
2871
2924
|
'tools.crud': CliToolsCrud
|
|
2872
2925
|
};
|
|
2873
2926
|
|
|
@@ -3445,6 +3498,40 @@ var toolsCrudBasic = {
|
|
|
3445
3498
|
}
|
|
3446
3499
|
};
|
|
3447
3500
|
|
|
3501
|
+
var toolsCrudStart = {
|
|
3502
|
+
bean: 'tools.crudStart',
|
|
3503
|
+
info: {
|
|
3504
|
+
version: '5.0.0',
|
|
3505
|
+
title: 'Cli: Tools: Crud Start',
|
|
3506
|
+
usage: 'vona :tools:crudStart resourceName [--module=]'
|
|
3507
|
+
},
|
|
3508
|
+
options: {
|
|
3509
|
+
module: {
|
|
3510
|
+
description: 'module name',
|
|
3511
|
+
type: 'string'
|
|
3512
|
+
}
|
|
3513
|
+
},
|
|
3514
|
+
groups: {
|
|
3515
|
+
default: {
|
|
3516
|
+
questions: {
|
|
3517
|
+
resourceName: {
|
|
3518
|
+
type: 'input',
|
|
3519
|
+
message: 'resourceName',
|
|
3520
|
+
initial: {
|
|
3521
|
+
expression: 'arg0'
|
|
3522
|
+
},
|
|
3523
|
+
required: true
|
|
3524
|
+
},
|
|
3525
|
+
module: {
|
|
3526
|
+
type: 'input',
|
|
3527
|
+
message: 'module name',
|
|
3528
|
+
required: true
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
};
|
|
3534
|
+
|
|
3448
3535
|
var toolsDeps = {
|
|
3449
3536
|
bean: 'tools.deps',
|
|
3450
3537
|
info: {
|
|
@@ -3509,6 +3596,7 @@ const commands = {
|
|
|
3509
3596
|
deps: toolsDeps,
|
|
3510
3597
|
metadata: toolsMetadata,
|
|
3511
3598
|
crudBasic: toolsCrudBasic,
|
|
3599
|
+
crudStart: toolsCrudStart,
|
|
3512
3600
|
crud: toolsCrud
|
|
3513
3601
|
}
|
|
3514
3602
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IModuleInfo } from '@cabloy/module-info';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
declare module '@cabloy/cli' {
|
|
4
|
+
interface ICommandArgv {
|
|
5
|
+
module: string;
|
|
6
|
+
moduleInfo: IModuleInfo;
|
|
7
|
+
resourceName: string;
|
|
8
|
+
resourceNameCapitalize: string;
|
|
9
|
+
moduleResourceName: string;
|
|
10
|
+
moduleActionPathRaw: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare class CliToolsCrudStart extends BeanCliBase {
|
|
14
|
+
execute(): Promise<void>;
|
|
15
|
+
}
|
package/dist/lib/beans.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { CliInitStatic } from './bean/cli.init.static.ts';
|
|
|
25
25
|
import { CliInitTypes } from './bean/cli.init.types.ts';
|
|
26
26
|
import { CliToolsCrud } from './bean/cli.tools.crud.ts';
|
|
27
27
|
import { CliToolsCrudBasic } from './bean/cli.tools.crudBasic.ts';
|
|
28
|
+
import { CliToolsCrudStart } from './bean/cli.tools.crudStart.ts';
|
|
28
29
|
import { CliToolsDeps } from './bean/cli.tools.deps.ts';
|
|
29
30
|
import { CliToolsMetadata } from './bean/cli.tools.metadata.ts';
|
|
30
31
|
export declare const beans: {
|
|
@@ -56,5 +57,6 @@ export declare const beans: {
|
|
|
56
57
|
'tools.deps': typeof CliToolsDeps;
|
|
57
58
|
'tools.metadata': typeof CliToolsMetadata;
|
|
58
59
|
'tools.crudBasic': typeof CliToolsCrudBasic;
|
|
60
|
+
'tools.crudStart': typeof CliToolsCrudStart;
|
|
59
61
|
'tools.crud': typeof CliToolsCrud;
|
|
60
62
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bean: string;
|
|
3
|
+
info: {
|
|
4
|
+
version: string;
|
|
5
|
+
title: string;
|
|
6
|
+
usage: string;
|
|
7
|
+
};
|
|
8
|
+
options: {
|
|
9
|
+
module: {
|
|
10
|
+
description: string;
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
groups: {
|
|
15
|
+
default: {
|
|
16
|
+
questions: {
|
|
17
|
+
resourceName: {
|
|
18
|
+
type: string;
|
|
19
|
+
message: string;
|
|
20
|
+
initial: {
|
|
21
|
+
expression: string;
|
|
22
|
+
};
|
|
23
|
+
required: boolean;
|
|
24
|
+
};
|
|
25
|
+
module: {
|
|
26
|
+
type: string;
|
|
27
|
+
message: string;
|
|
28
|
+
required: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|
package/dist/lib/commands.d.ts
CHANGED
|
@@ -523,6 +523,39 @@ export declare const commands: {
|
|
|
523
523
|
};
|
|
524
524
|
};
|
|
525
525
|
};
|
|
526
|
+
crudStart: {
|
|
527
|
+
bean: string;
|
|
528
|
+
info: {
|
|
529
|
+
version: string;
|
|
530
|
+
title: string;
|
|
531
|
+
usage: string;
|
|
532
|
+
};
|
|
533
|
+
options: {
|
|
534
|
+
module: {
|
|
535
|
+
description: string;
|
|
536
|
+
type: string;
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
groups: {
|
|
540
|
+
default: {
|
|
541
|
+
questions: {
|
|
542
|
+
resourceName: {
|
|
543
|
+
type: string;
|
|
544
|
+
message: string;
|
|
545
|
+
initial: {
|
|
546
|
+
expression: string;
|
|
547
|
+
};
|
|
548
|
+
required: boolean;
|
|
549
|
+
};
|
|
550
|
+
module: {
|
|
551
|
+
type: string;
|
|
552
|
+
message: string;
|
|
553
|
+
required: boolean;
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
};
|
|
526
559
|
crud: {
|
|
527
560
|
bean: string;
|
|
528
561
|
info: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
export default metadataCustomSnippet({
|
|
3
|
+
file: 'package.json',
|
|
4
|
+
language: 'json',
|
|
5
|
+
async transform({ ast, argv }) {
|
|
6
|
+
argv.fileVersion = ast.vonaModule.fileVersion = 1 + (ast.vonaModule.fileVersion ?? 0);
|
|
7
|
+
return ast;
|
|
8
|
+
},
|
|
9
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
const __snippet_import1 = "import { $tableColumns } from 'vona-module-a-ormutils';";
|
|
5
|
+
const __snippet_update = "...$tableColumns('<%=argv.moduleResourceName%>', 'name'),";
|
|
6
|
+
export default metadataCustomSnippet({
|
|
7
|
+
file: 'src/bean/meta.index.ts',
|
|
8
|
+
language: 'plain',
|
|
9
|
+
format: true,
|
|
10
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
11
|
+
await catchError(() => {
|
|
12
|
+
return cli.helper.invokeCli([':create:bean', 'meta', 'index', `--module=${argv.module}`, '--nometadata', '--noformat'], {
|
|
13
|
+
cwd: argv.projectPath,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
17
|
+
},
|
|
18
|
+
async transform({ cli, ast }) {
|
|
19
|
+
// import1
|
|
20
|
+
if (!ast.includes(__snippet_import1)) {
|
|
21
|
+
const code = await cli.template.renderContent({ content: __snippet_import1 });
|
|
22
|
+
ast = ast.replace("import { Meta } from 'vona-module-a-meta';", `import { Meta } from 'vona-module-a-meta';\n${code}`);
|
|
23
|
+
}
|
|
24
|
+
// update
|
|
25
|
+
const code = await cli.template.renderContent({ content: __snippet_update });
|
|
26
|
+
if (ast.includes('indexes: {}')) {
|
|
27
|
+
ast = ast.replace('indexes: {', `indexes: {\n ${code}\n `);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
ast = ast.replace('indexes: {', `indexes: {\n ${code}`);
|
|
31
|
+
}
|
|
32
|
+
// ok
|
|
33
|
+
return ast;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
const __snippet_update = `if (options.version === <%=argv.fileVersion%>) {
|
|
5
|
+
const entity<%=argv.resourceNameCapitalize%> = this.scope.entity.<%=argv.resourceName%>;
|
|
6
|
+
await this.bean.model.createTable(entity<%=argv.resourceNameCapitalize%>.$table, table => {
|
|
7
|
+
table.comment(entity<%=argv.resourceNameCapitalize%>.$comment.$table);
|
|
8
|
+
table.basicFields();
|
|
9
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.name, 50).comment(entity<%=argv.resourceNameCapitalize%>.$comment.name);
|
|
10
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.description, 255).comment(entity<%=argv.resourceNameCapitalize%>.$comment.description);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export default metadataCustomSnippet({
|
|
15
|
+
file: 'src/bean/meta.version.ts',
|
|
16
|
+
language: 'gogo',
|
|
17
|
+
format: true,
|
|
18
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
19
|
+
await catchError(() => {
|
|
20
|
+
return cli.helper.invokeCli([
|
|
21
|
+
':create:bean',
|
|
22
|
+
'meta',
|
|
23
|
+
'version',
|
|
24
|
+
`--module=${argv.module}`,
|
|
25
|
+
'--nometadata',
|
|
26
|
+
'--noformat',
|
|
27
|
+
], {
|
|
28
|
+
cwd: argv.projectPath,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
32
|
+
},
|
|
33
|
+
async transform({ cli, ast }) {
|
|
34
|
+
// update
|
|
35
|
+
ast.replace('async update(_options: IMetaVersionUpdateOptions) {$$$1}', 'async update(options: IMetaVersionUpdateOptions) {$$$1}');
|
|
36
|
+
const code = await cli.template.renderContent({ content: __snippet_update });
|
|
37
|
+
ast.replace('async update($$$0) {$$$1}', `async update($$$0) {\n $$$1\n ${code}}`);
|
|
38
|
+
// ok
|
|
39
|
+
return ast;
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { catchError } from '@cabloy/utils';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { locale_transform } from "../utils.js";
|
|
5
|
+
const __resources = { Name: 'Name', Description: 'Description', Operations: 'Operations' };
|
|
6
|
+
export default metadataCustomSnippet({
|
|
7
|
+
file: 'src/config/locale/en-us.ts',
|
|
8
|
+
language: 'plain',
|
|
9
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
10
|
+
await catchError(() => {
|
|
11
|
+
return cli.helper.invokeCli([':init:locale', argv.module, '--nometadata', '--noformat'], {
|
|
12
|
+
cwd: argv.projectPath,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
16
|
+
},
|
|
17
|
+
async transform({ ast, argv }) {
|
|
18
|
+
return locale_transform({ ast, argv, resources: __resources });
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { locale_transform } from "../utils.js";
|
|
3
|
+
const __resources = { Name: '名称', Description: '描述', Operations: '操作' };
|
|
4
|
+
export default metadataCustomSnippet({
|
|
5
|
+
file: 'src/config/locale/zh-cn.ts',
|
|
6
|
+
language: 'plain',
|
|
7
|
+
async transform({ ast, argv }) {
|
|
8
|
+
return locale_transform({ ast, argv, resources: __resources });
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { evaluateSimple } from '@cabloy/utils';
|
|
2
|
+
export async function locale_transform({ ast, argv, resources, }) {
|
|
3
|
+
const values = evaluateSimple(ast.replace('export default', '').replace(';', ''));
|
|
4
|
+
resources = Object.assign({}, resources, { [argv.resourceNameCapitalize]: argv.resourceNameCapitalize }, values);
|
|
5
|
+
const keys = Object.keys(resources).sort();
|
|
6
|
+
let content = '';
|
|
7
|
+
for (const key of keys) {
|
|
8
|
+
content += ` ${key}: '${resources[key].replaceAll("'", "\\'")}',\n`;
|
|
9
|
+
}
|
|
10
|
+
ast = `export default {\n${content}};\n`;
|
|
11
|
+
// ok
|
|
12
|
+
return ast;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.64",
|
|
4
4
|
"gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"keywords": [
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"uuid": "^11.1.0",
|
|
63
63
|
"why-is-node-running": "^3.2.2",
|
|
64
64
|
"yargs-parser": "^22.0.0",
|
|
65
|
-
"@cabloy/cli": "^3.1.
|
|
65
|
+
"@cabloy/cli": "^3.1.11",
|
|
66
66
|
"@cabloy/dotenv": "^1.2.5",
|
|
67
|
-
"@cabloy/
|
|
68
|
-
"@cabloy/module-glob": "^5.3.8",
|
|
67
|
+
"@cabloy/module-glob": "^5.3.9",
|
|
69
68
|
"babel-plugin-vona-bean-module": "^1.1.6",
|
|
70
|
-
"vona-core": "^5.1.
|
|
71
|
-
"@cabloy/utils": "^2.1.
|
|
69
|
+
"vona-core": "^5.1.14",
|
|
70
|
+
"@cabloy/utils": "^2.1.18",
|
|
71
|
+
"@cabloy/extend": "^3.2.5"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"clean": "rimraf dist dist-cli dist-toolsIsolate tsconfig.build.tsbuildinfo tsconfig.cli.tsbuildinfo tsconfig.isolate.tsbuildinfo",
|