vona-cli-set-api 1.0.113 → 1.0.115
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/basic/boilerplate/.vscode/vona.code-snippets +72 -0
- package/cli/templates/create/project/basic/boilerplate/env/.env +1 -1
- package/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/dist/.metadata/index.d.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/src/.metadata/index.ts +12 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/tsconfig.build.tsbuildinfo +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/dist/.metadata/index.d.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/src/.metadata/index.ts +12 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/tsconfig.build.tsbuildinfo +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/.metadata/index.d.ts +182 -38
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/config/locale/en-us.d.ts +9 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/config/locale/zh-cn.d.ts +9 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/controller/passport.d.ts +1 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/dto/auth.d.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/entity/role.d.ts +3 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/entity/roleUser.d.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/entity/user.d.ts +3 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/entity/userRole.d.ts +2 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/model/role.d.ts +4 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/model/roleUser.d.ts +7 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/model/user.d.ts +4 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/model/userRole.d.ts +4 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/service/roleInnerAdapter.d.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/dist/types/passport.d.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/index.ts +188 -44
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/meta.index.ts +5 -5
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/meta.version.ts +10 -8
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/config/locale/en-us.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/config/locale/zh-cn.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/controller/passport.ts +6 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/dto/auth.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/role.ts +6 -5
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/roleUser.ts +14 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/user.ts +7 -6
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/authAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/roleAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/lib/userAdapter.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/model/role.ts +5 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/model/roleUser.ts +8 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/model/user.ts +12 -2
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/service/roleInnerAdapter.ts +3 -3
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/types/passport.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/tsconfig.build.tsbuildinfo +1 -1
- package/cli/templates/init/lib/boilerplate/lib/index.ts +1 -0
- package/cli/templates/init/types/boilerplate/types/index.ts +1 -0
- package/cli/templates/tools/crud/boilerplate/src/controller/{{resourceName}}.ts_ +1 -1
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}Create.ts_ +3 -3
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}Update.ts_ +3 -3
- package/cli/templates/tools/crud/boilerplate/src/entity/{{resourceName}}.ts_ +4 -4
- package/cli/templates/tools/crud/boilerplate/src/model/{{resourceName}}.ts_ +5 -2
- package/cli/templates/tools/crud/boilerplate/src/service/{{resourceName}}.ts_ +1 -1
- package/cli/templates/tools/crud/snippets/2-meta.index.ts +2 -5
- package/cli/templates/tools/crud/snippets/2-meta.version.ts +3 -2
- package/dist/lib/bean/cli.init.lib.d.ts +8 -0
- package/dist/lib/bean/cli.init.lib.js +36 -0
- package/dist/lib/bean/cli.init.types.d.ts +8 -0
- package/dist/lib/bean/cli.init.types.js +36 -0
- package/dist/lib/bean/cli.tools.metadata.d.ts +1 -0
- package/dist/lib/bean/cli.tools.metadata.js +43 -20
- package/dist/lib/bean/toolsMetadata/generateOnions.js +10 -1
- package/dist/lib/bean/toolsMetadata/utils.js +2 -0
- package/dist/lib/beans.d.ts +4 -0
- package/dist/lib/beans.js +4 -0
- package/dist/lib/command/init.lib.d.ts +9 -0
- package/dist/lib/command/init.lib.js +10 -0
- package/dist/lib/command/init.types.d.ts +9 -0
- package/dist/lib/command/init.types.js +10 -0
- package/dist/lib/commands.d.ts +16 -0
- package/dist/lib/commands.js +4 -0
- package/package.json +5 -5
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/userRole.ts +0 -14
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/model/userRole.ts +0 -5
- package/dist/lib/bean/toolsMetadata/generateBeans.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateBeans.js +0 -72
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
3
|
import { BeanBase } from 'vona';
|
|
4
4
|
import { Api, Arg, v } from 'vona-module-a-openapi';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
-
import {
|
|
2
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
3
3
|
import { Dto } from 'vona-module-a-web';
|
|
4
|
-
import {
|
|
4
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
5
5
|
|
|
6
6
|
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Create extends IDecoratorDtoOptions {}
|
|
7
7
|
|
|
8
8
|
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Create>()
|
|
9
|
-
export class Dto<%=argv.resourceNameCapitalize%>Create extends
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>Create extends $Dto.create(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
-
import {
|
|
2
|
+
import { $Dto } from 'vona-module-a-orm';
|
|
3
3
|
import { Dto } from 'vona-module-a-web';
|
|
4
|
-
import {
|
|
4
|
+
import { Model<%=argv.resourceNameCapitalize%> } from '../model/<%=argv.resourceName%>.ts';
|
|
5
5
|
|
|
6
6
|
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Update extends IDecoratorDtoOptions {}
|
|
7
7
|
|
|
8
8
|
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Update>()
|
|
9
|
-
export class Dto<%=argv.resourceNameCapitalize%>Update extends
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>Update extends $Dto.update(() => Model<%=argv.resourceNameCapitalize%>) {}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { IDecoratorEntityOptions } from 'vona-module-a-
|
|
2
|
-
import { Entity, EntityBase } from 'vona-module-a-
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
3
3
|
import { Api, v } from 'vona-module-a-openapi';
|
|
4
4
|
import { $locale } from '../.metadata/index.ts';
|
|
5
5
|
|
|
6
6
|
export interface IEntityOptions<%=argv.resourceNameCapitalize%> extends IDecoratorEntityOptions {}
|
|
7
7
|
|
|
8
|
-
@Entity<IEntityOptions<%=argv.resourceNameCapitalize%>>('<%=argv.moduleResourceName%>')
|
|
8
|
+
@Entity<IEntityOptions<%=argv.resourceNameCapitalize%>>('<%=argv.moduleResourceName%>', { openapi: { title: $locale('<%=argv.resourceNameCapitalize%>') } })
|
|
9
9
|
export class Entity<%=argv.resourceNameCapitalize%> extends EntityBase {
|
|
10
|
-
@Api.field(v.openapi({ title: $locale('Name') }), v.min(3))
|
|
10
|
+
@Api.field(v.openapi({ title: $locale('Name') }), v.default(''), v.min(3))
|
|
11
11
|
name: string;
|
|
12
12
|
|
|
13
13
|
@Api.field(v.openapi({ title: $locale('Description') }), v.optional())
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IDecoratorModelOptions } from 'vona-module-a-orm';
|
|
2
|
+
import { BeanModelBase, Model } from 'vona-module-a-orm';
|
|
2
3
|
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export interface IModelOptions<%=argv.resourceNameCapitalize%> extends IDecoratorModelOptions<Entity<%=argv.resourceNameCapitalize%>> {}
|
|
6
|
+
|
|
7
|
+
@Model<IModelOptions<%=argv.resourceNameCapitalize%>>({ entity: Entity<%=argv.resourceNameCapitalize%> })
|
|
5
8
|
export class Model<%=argv.resourceNameCapitalize%> extends BeanModelBase<Entity<%=argv.resourceNameCapitalize%>> {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableIdentity } from 'vona-module-a-
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-orm';
|
|
2
2
|
import type { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
3
3
|
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
4
4
|
import type { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
@@ -8,12 +8,9 @@ declare module '@cabloy/cli' {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const __snippet_import1 = 'import { $tableColumns } from \'vona-module-a-
|
|
11
|
+
const __snippet_import1 = 'import { $tableColumns } from \'vona-module-a-orm\';\n';
|
|
12
12
|
const __snippet_import2 = 'import { Entity<%=argv.resourceNameCapitalize%> } from \'../entity/<%=argv.resourceName%>.ts\';\n';
|
|
13
|
-
const __snippet_update =
|
|
14
|
-
() => Entity<%=argv.resourceNameCapitalize%>,
|
|
15
|
-
entity => entity.name,
|
|
16
|
-
),`;
|
|
13
|
+
const __snippet_update = '...$tableColumns(() => Entity<%=argv.resourceNameCapitalize%>, \'name\'),';
|
|
17
14
|
|
|
18
15
|
export default metadataCustomSnippet({
|
|
19
16
|
file: 'src/bean/meta.index.ts',
|
|
@@ -11,9 +11,10 @@ declare module '@cabloy/cli' {
|
|
|
11
11
|
const __snippet_update = `if (options.version === <%=argv.fileVersion%>) {
|
|
12
12
|
const entity<%=argv.resourceNameCapitalize%> = this.scope.entity.<%=argv.resourceName%>;
|
|
13
13
|
await this.bean.model.createTable(entity<%=argv.resourceNameCapitalize%>.$table, table => {
|
|
14
|
+
table.comment(entity<%=argv.resourceNameCapitalize%>.$comment.$table);
|
|
14
15
|
table.basicFields();
|
|
15
|
-
table.string(entity<%=argv.resourceNameCapitalize%>.name, 50);
|
|
16
|
-
table.string(entity<%=argv.resourceNameCapitalize%>.description, 255);
|
|
16
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.name, 50).defaultTo(entity<%=argv.resourceNameCapitalize%>.$default.name).comment(entity<%=argv.resourceNameCapitalize%>.$comment.name);
|
|
17
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.description, 255).comment(entity<%=argv.resourceNameCapitalize%>.$comment.description);
|
|
17
18
|
});
|
|
18
19
|
}`;
|
|
19
20
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import { __ThisSetName__ } from "../this.js";
|
|
5
|
+
export class CliInitLib extends BeanCliBase {
|
|
6
|
+
async execute() {
|
|
7
|
+
const { argv } = this.context;
|
|
8
|
+
// super
|
|
9
|
+
await super.execute();
|
|
10
|
+
// module name/info
|
|
11
|
+
const moduleName = argv._[0];
|
|
12
|
+
if (!moduleName)
|
|
13
|
+
return;
|
|
14
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
+
// check if exists
|
|
16
|
+
const _module = this.helper.findModule(moduleName);
|
|
17
|
+
if (!_module) {
|
|
18
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
+
}
|
|
20
|
+
// target dir
|
|
21
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
+
const mainFile = path.join(targetDir, 'src/lib/index.ts');
|
|
23
|
+
if (fse.existsSync(mainFile)) {
|
|
24
|
+
throw new Error(`lib exists: ${moduleName}`);
|
|
25
|
+
}
|
|
26
|
+
// render boilerplate
|
|
27
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
+
targetDir: path.join(targetDir, 'src'),
|
|
29
|
+
setName: __ThisSetName__,
|
|
30
|
+
snippetsPath: null,
|
|
31
|
+
boilerplatePath: 'init/lib/boilerplate',
|
|
32
|
+
});
|
|
33
|
+
// tools.metadata
|
|
34
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import { __ThisSetName__ } from "../this.js";
|
|
5
|
+
export class CliInitTypes extends BeanCliBase {
|
|
6
|
+
async execute() {
|
|
7
|
+
const { argv } = this.context;
|
|
8
|
+
// super
|
|
9
|
+
await super.execute();
|
|
10
|
+
// module name/info
|
|
11
|
+
const moduleName = argv._[0];
|
|
12
|
+
if (!moduleName)
|
|
13
|
+
return;
|
|
14
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
+
// check if exists
|
|
16
|
+
const _module = this.helper.findModule(moduleName);
|
|
17
|
+
if (!_module) {
|
|
18
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
+
}
|
|
20
|
+
// target dir
|
|
21
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
+
const mainFile = path.join(targetDir, 'src/types/index.ts');
|
|
23
|
+
if (fse.existsSync(mainFile)) {
|
|
24
|
+
throw new Error(`types exists: ${moduleName}`);
|
|
25
|
+
}
|
|
26
|
+
// render boilerplate
|
|
27
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
+
targetDir: path.join(targetDir, 'src'),
|
|
29
|
+
setName: __ThisSetName__,
|
|
30
|
+
snippetsPath: null,
|
|
31
|
+
boilerplatePath: 'init/types/boilerplate',
|
|
32
|
+
});
|
|
33
|
+
// tools.metadata
|
|
34
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -8,6 +8,7 @@ export declare class CliToolsMetadata extends BeanCliBase {
|
|
|
8
8
|
execute(): Promise<void>;
|
|
9
9
|
_generateMetadata(moduleName: string, force: boolean): Promise<void>;
|
|
10
10
|
_generatePatch(content: string): string;
|
|
11
|
+
_generatePatch_resources(content: string, packageName: string, resources: string[], type: boolean): string;
|
|
11
12
|
_generateThis(moduleName: string, relativeNameCapitalize: string, modulePath: string): Promise<void>;
|
|
12
13
|
_generateIndex(modulePath: string): Promise<void>;
|
|
13
14
|
}
|
|
@@ -4,7 +4,6 @@ import { getOnionMetasMeta, getOnionScenesMeta } from '@cabloy/module-info';
|
|
|
4
4
|
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
5
5
|
import fse from 'fs-extra';
|
|
6
6
|
import { generateBeanGenerals } from "./toolsMetadata/generateBeanGenerals.js";
|
|
7
|
-
import { generateBeans } from "./toolsMetadata/generateBeans.js";
|
|
8
7
|
import { generateConfig, generateConstant, generateError, generateLocale } from "./toolsMetadata/generateConfig.js";
|
|
9
8
|
import { generateMetadataCustom } from "./toolsMetadata/generateMetadataCustom.js";
|
|
10
9
|
import { generateMain, generateMonkey } from "./toolsMetadata/generateMonkey.js";
|
|
@@ -55,8 +54,6 @@ export class CliToolsMetadata extends BeanCliBase {
|
|
|
55
54
|
const onionScenesMeta = getOnionScenesMeta(this.modulesMeta.modules);
|
|
56
55
|
// content
|
|
57
56
|
let content = '';
|
|
58
|
-
// beans
|
|
59
|
-
content += await generateBeans(onionScenesMeta, moduleName, modulePath);
|
|
60
57
|
// onions
|
|
61
58
|
const scopeResources = {};
|
|
62
59
|
for (const sceneName in onionScenesMeta) {
|
|
@@ -137,17 +134,29 @@ export class CliToolsMetadata extends BeanCliBase {
|
|
|
137
134
|
_generatePatch(content) {
|
|
138
135
|
if (!content)
|
|
139
136
|
return content;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
content = this._generatePatch_resources(content, 'vona-module-a-openapi', ['TypeEntityOptionsFields', 'TypeControllerOptionsActions'], true);
|
|
138
|
+
content = this._generatePatch_resources(content, 'vona-module-a-orm', [
|
|
139
|
+
'TypeEntityMeta',
|
|
140
|
+
'TypeModelsClassLikeGeneral',
|
|
141
|
+
'TypeSymbolKeyFieldsMore',
|
|
142
|
+
'IModelRelationHasOne',
|
|
143
|
+
'IModelRelationBelongsTo',
|
|
144
|
+
'IModelRelationHasMany',
|
|
145
|
+
'IModelRelationBelongsToMany',
|
|
146
|
+
], true);
|
|
147
|
+
content = this._generatePatch_resources(content, 'vona', ['PowerPartial'], true);
|
|
149
148
|
return content;
|
|
150
149
|
}
|
|
150
|
+
_generatePatch_resources(content, packageName, resources, type) {
|
|
151
|
+
const items = resources.filter(item => {
|
|
152
|
+
const regexp = new RegExp(`${item}[\\[\\]<,;?:\\s]`);
|
|
153
|
+
return !!regexp.exec(content);
|
|
154
|
+
});
|
|
155
|
+
if (items.length === 0)
|
|
156
|
+
return content;
|
|
157
|
+
const importContent = `import ${type ? 'type ' : ''}{ ${items.join(',')} } from '${packageName}';`;
|
|
158
|
+
return `${importContent}\n${content}`;
|
|
159
|
+
}
|
|
151
160
|
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
152
161
|
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
153
162
|
if (fse.existsSync(thisDest))
|
|
@@ -159,19 +168,33 @@ export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts'
|
|
|
159
168
|
await fse.writeFile(thisDest, content);
|
|
160
169
|
}
|
|
161
170
|
async _generateIndex(modulePath) {
|
|
162
|
-
|
|
171
|
+
let jsContent = '';
|
|
163
172
|
const jsFile = path.join(modulePath, 'src/index.ts');
|
|
164
|
-
let jsContent;
|
|
165
173
|
if (fse.existsSync(jsFile)) {
|
|
166
174
|
jsContent = (await fse.readFile(jsFile)).toString();
|
|
167
|
-
if (jsContent.includes(jsExport))
|
|
168
|
-
return;
|
|
169
|
-
jsContent = `${jsExport}\n${jsContent}`;
|
|
170
|
-
jsContent = jsContent.replace('export {};\n', '');
|
|
171
175
|
}
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
// jsTypes
|
|
177
|
+
const jsTypes = "export * from './types/index.ts';";
|
|
178
|
+
const jsTypesFile = path.join(modulePath, 'src/types/index.ts');
|
|
179
|
+
if (fse.existsSync(jsTypesFile) && !jsContent.includes(jsTypes)) {
|
|
180
|
+
jsContent = `${jsTypes}\n${jsContent}`;
|
|
181
|
+
}
|
|
182
|
+
// jsLib
|
|
183
|
+
const jsLib = "export * from './lib/index.ts';";
|
|
184
|
+
const jsLibFile = path.join(modulePath, 'src/lib/index.ts');
|
|
185
|
+
if (fse.existsSync(jsLibFile) && !jsContent.includes(jsLib)) {
|
|
186
|
+
jsContent = `${jsLib}\n${jsContent}`;
|
|
187
|
+
}
|
|
188
|
+
// jsMetadata
|
|
189
|
+
const jsMetadata = "export * from './.metadata/index.ts';";
|
|
190
|
+
const jsMetadataFile = path.join(modulePath, 'src/.metadata/index.ts');
|
|
191
|
+
if (fse.existsSync(jsMetadataFile) && !jsContent.includes(jsMetadata)) {
|
|
192
|
+
jsContent = `${jsMetadata}\n${jsContent}`;
|
|
174
193
|
}
|
|
194
|
+
// trim empty
|
|
195
|
+
jsContent = jsContent.replace('export {};\n', '');
|
|
196
|
+
// write
|
|
175
197
|
await fse.writeFile(jsFile, jsContent);
|
|
198
|
+
await this.helper.formatFile({ fileName: jsFile, logPrefix: 'format: ' });
|
|
176
199
|
}
|
|
177
200
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { replaceTemplate } from '@cabloy/utils';
|
|
2
2
|
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
3
|
+
import { beanFullNameFromOnionName } from 'vona-core';
|
|
3
4
|
import { extractBeanInfo, getScopeModuleName, globBeanFiles } from "./utils.js";
|
|
4
5
|
export async function generateOnions(sceneName, sceneMeta, moduleName, modulePath) {
|
|
5
6
|
const scopeModuleName = getScopeModuleName(moduleName);
|
|
@@ -15,7 +16,8 @@ export async function generateOnions(sceneName, sceneMeta, moduleName, modulePat
|
|
|
15
16
|
const contentRecordsLocal = [];
|
|
16
17
|
let needImportOptionsGlobalInterface;
|
|
17
18
|
for (const globFile of globFiles) {
|
|
18
|
-
const { fileContent, fileNameJSRelative, className, beanNameFull, isIgnore, isVirtual } = globFile;
|
|
19
|
+
const { fileContent, fileNameJSRelative, sceneName, className, beanNameFull, isIgnore, isVirtual } = globFile;
|
|
20
|
+
const isBeanGlobal = fileNameJSRelative.includes('../bean/bean.');
|
|
19
21
|
contentExports.push(`export * from '${fileNameJSRelative}';`);
|
|
20
22
|
if (isIgnore)
|
|
21
23
|
continue; // get scope() also can be ignored
|
|
@@ -26,6 +28,13 @@ export async function generateOnions(sceneName, sceneMeta, moduleName, modulePat
|
|
|
26
28
|
/** @internal */
|
|
27
29
|
get scope(): ${scopeModuleName};
|
|
28
30
|
}`);
|
|
31
|
+
if (!isBeanGlobal) {
|
|
32
|
+
contentScopes.push(`
|
|
33
|
+
export interface ${className} {
|
|
34
|
+
get $beanFullName(): '${beanFullNameFromOnionName(beanNameFull, sceneName)}';
|
|
35
|
+
get $onionName(): '${beanNameFull}';
|
|
36
|
+
}`);
|
|
37
|
+
}
|
|
29
38
|
}
|
|
30
39
|
if (sceneMeta.optionsNone)
|
|
31
40
|
continue;
|
|
@@ -39,6 +39,7 @@ export async function globBeanFiles(sceneName, sceneMeta, moduleName, modulePath
|
|
|
39
39
|
const className = (sceneMeta.sceneIsolate ? sceneNameCapitalize : '') + parts.map(item => toUpperCaseFirstChar(item)).join('');
|
|
40
40
|
const beanName = parts[parts.length - 1];
|
|
41
41
|
const beanNameFull = `${moduleName}:${beanName}`;
|
|
42
|
+
const beanNameCapitalize = toUpperCaseFirstChar(beanName);
|
|
42
43
|
const fileContent = isIgnore ? '' : fse.readFileSync(filePath).toString();
|
|
43
44
|
const isVirtual = fileContent.includes('@Virtual()');
|
|
44
45
|
result.push({
|
|
@@ -52,6 +53,7 @@ export async function globBeanFiles(sceneName, sceneMeta, moduleName, modulePath
|
|
|
52
53
|
className,
|
|
53
54
|
beanName,
|
|
54
55
|
beanNameFull,
|
|
56
|
+
beanNameCapitalize,
|
|
55
57
|
isIgnore,
|
|
56
58
|
isVirtual,
|
|
57
59
|
});
|
package/dist/lib/beans.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ import { CliDefaultList } from './bean/cli.default.list.ts';
|
|
|
14
14
|
import { CliInitConfig } from './bean/cli.init.config.ts';
|
|
15
15
|
import { CliInitConstant } from './bean/cli.init.constant.ts';
|
|
16
16
|
import { CliInitError } from './bean/cli.init.error.ts';
|
|
17
|
+
import { CliInitLib } from './bean/cli.init.lib.ts';
|
|
17
18
|
import { CliInitLocale } from './bean/cli.init.locale.ts';
|
|
18
19
|
import { CliInitMain } from './bean/cli.init.main.ts';
|
|
19
20
|
import { CliInitMonkey } from './bean/cli.init.monkey.ts';
|
|
20
21
|
import { CliInitStatic } from './bean/cli.init.static.ts';
|
|
22
|
+
import { CliInitTypes } from './bean/cli.init.types.ts';
|
|
21
23
|
import { CliToolsCrud } from './bean/cli.tools.crud.ts';
|
|
22
24
|
import { CliToolsDeps } from './bean/cli.tools.deps.ts';
|
|
23
25
|
import { CliToolsMetadata } from './bean/cli.tools.metadata.ts';
|
|
@@ -42,6 +44,8 @@ export declare const beans: {
|
|
|
42
44
|
'init.monkey': typeof CliInitMonkey;
|
|
43
45
|
'init.main': typeof CliInitMain;
|
|
44
46
|
'init.static': typeof CliInitStatic;
|
|
47
|
+
'init.lib': typeof CliInitLib;
|
|
48
|
+
'init.types': typeof CliInitTypes;
|
|
45
49
|
'tools.deps': typeof CliToolsDeps;
|
|
46
50
|
'tools.metadata': typeof CliToolsMetadata;
|
|
47
51
|
'tools.crud': typeof CliToolsCrud;
|
package/dist/lib/beans.js
CHANGED
|
@@ -14,10 +14,12 @@ import { CliDefaultList } from "./bean/cli.default.list.js";
|
|
|
14
14
|
import { CliInitConfig } from "./bean/cli.init.config.js";
|
|
15
15
|
import { CliInitConstant } from "./bean/cli.init.constant.js";
|
|
16
16
|
import { CliInitError } from "./bean/cli.init.error.js";
|
|
17
|
+
import { CliInitLib } from "./bean/cli.init.lib.js";
|
|
17
18
|
import { CliInitLocale } from "./bean/cli.init.locale.js";
|
|
18
19
|
import { CliInitMain } from "./bean/cli.init.main.js";
|
|
19
20
|
import { CliInitMonkey } from "./bean/cli.init.monkey.js";
|
|
20
21
|
import { CliInitStatic } from "./bean/cli.init.static.js";
|
|
22
|
+
import { CliInitTypes } from "./bean/cli.init.types.js";
|
|
21
23
|
import { CliToolsCrud } from "./bean/cli.tools.crud.js";
|
|
22
24
|
import { CliToolsDeps } from "./bean/cli.tools.deps.js";
|
|
23
25
|
import { CliToolsMetadata } from "./bean/cli.tools.metadata.js";
|
|
@@ -42,6 +44,8 @@ export const beans = {
|
|
|
42
44
|
'init.monkey': CliInitMonkey,
|
|
43
45
|
'init.main': CliInitMain,
|
|
44
46
|
'init.static': CliInitStatic,
|
|
47
|
+
'init.lib': CliInitLib,
|
|
48
|
+
'init.types': CliInitTypes,
|
|
45
49
|
'tools.deps': CliToolsDeps,
|
|
46
50
|
'tools.metadata': CliToolsMetadata,
|
|
47
51
|
'tools.crud': CliToolsCrud,
|
package/dist/lib/commands.d.ts
CHANGED
|
@@ -391,6 +391,22 @@ export declare const commands: {
|
|
|
391
391
|
usage: string;
|
|
392
392
|
};
|
|
393
393
|
};
|
|
394
|
+
lib: {
|
|
395
|
+
bean: string;
|
|
396
|
+
info: {
|
|
397
|
+
version: string;
|
|
398
|
+
title: string;
|
|
399
|
+
usage: string;
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
types: {
|
|
403
|
+
bean: string;
|
|
404
|
+
info: {
|
|
405
|
+
version: string;
|
|
406
|
+
title: string;
|
|
407
|
+
usage: string;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
394
410
|
};
|
|
395
411
|
refactor: {};
|
|
396
412
|
tools: {
|
package/dist/lib/commands.js
CHANGED
|
@@ -14,10 +14,12 @@ import defaultList from "./command/default.list.js";
|
|
|
14
14
|
import initConfig from "./command/init.config.js";
|
|
15
15
|
import initConstant from "./command/init.constant.js";
|
|
16
16
|
import initError from "./command/init.error.js";
|
|
17
|
+
import initLib from "./command/init.lib.js";
|
|
17
18
|
import initLocale from "./command/init.locale.js";
|
|
18
19
|
import initMain from "./command/init.main.js";
|
|
19
20
|
import initMonkey from "./command/init.monkey.js";
|
|
20
21
|
import initStatic from "./command/init.static.js";
|
|
22
|
+
import initTypes from "./command/init.types.js";
|
|
21
23
|
import toolsCrud from "./command/tools.crud.js";
|
|
22
24
|
import toolsDeps from "./command/tools.deps.js";
|
|
23
25
|
import toolsMetadata from "./command/tools.metadata.js";
|
|
@@ -49,6 +51,8 @@ export const commands = {
|
|
|
49
51
|
monkey: initMonkey,
|
|
50
52
|
main: initMain,
|
|
51
53
|
static: initStatic,
|
|
54
|
+
lib: initLib,
|
|
55
|
+
types: initTypes,
|
|
52
56
|
},
|
|
53
57
|
refactor: {},
|
|
54
58
|
tools: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.115",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
32
32
|
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
33
33
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
34
|
-
"@cabloy/cli": "^3.0.
|
|
34
|
+
"@cabloy/cli": "^3.0.41",
|
|
35
35
|
"@cabloy/dotenv": "^1.1.10",
|
|
36
36
|
"@cabloy/extend": "^3.1.10",
|
|
37
|
-
"@cabloy/module-glob": "^5.2.
|
|
38
|
-
"@cabloy/module-info": "^1.3.
|
|
37
|
+
"@cabloy/module-glob": "^5.2.23",
|
|
38
|
+
"@cabloy/module-info": "^1.3.25",
|
|
39
39
|
"@cabloy/word-utils": "^2.0.1",
|
|
40
40
|
"@lcov-viewer/cli": "^1.3.0",
|
|
41
41
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
62
|
"urllib": "^4.6.11",
|
|
63
63
|
"uuid": "^11.1.0",
|
|
64
|
-
"vona-core": "^5.0.
|
|
64
|
+
"vona-core": "^5.0.38",
|
|
65
65
|
"why-is-node-running": "^3.2.2",
|
|
66
66
|
"yargs-parser": "^21.1.1"
|
|
67
67
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IDecoratorEntityOptions, TableIdentity } from 'vona-module-a-database';
|
|
2
|
-
import { Entity, EntityBase } from 'vona-module-a-database';
|
|
3
|
-
import { Api, v } from 'vona-module-a-openapi';
|
|
4
|
-
|
|
5
|
-
export interface IEntityOptionsUserRole extends IDecoratorEntityOptions {}
|
|
6
|
-
|
|
7
|
-
@Entity<IEntityOptionsUserRole>('homeUserRole')
|
|
8
|
-
export class EntityUserRole extends EntityBase {
|
|
9
|
-
@Api.field(v.tableIdentity())
|
|
10
|
-
userId: TableIdentity;
|
|
11
|
-
|
|
12
|
-
@Api.field(v.tableIdentity())
|
|
13
|
-
roleId: TableIdentity;
|
|
14
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
3
|
-
import { globby } from 'globby';
|
|
4
|
-
import { checkIgnoreOfParts, getScopeModuleName } from "./utils.js";
|
|
5
|
-
// todo: remove
|
|
6
|
-
export async function generateBeans(onionScenesMeta, moduleName, modulePath) {
|
|
7
|
-
const scopeModuleName = getScopeModuleName(moduleName);
|
|
8
|
-
// ignore
|
|
9
|
-
const ignore = Object.keys(onionScenesMeta).map(item => `**/${item}.*.ts`);
|
|
10
|
-
// files
|
|
11
|
-
const files = await globby('src/bean/*.ts', { ignore, cwd: modulePath });
|
|
12
|
-
if (files.length === 0)
|
|
13
|
-
return '';
|
|
14
|
-
files.sort();
|
|
15
|
-
const contentExports = [];
|
|
16
|
-
const contentScopes = [];
|
|
17
|
-
const contentImports = [];
|
|
18
|
-
const contentRecordsGlobal = [];
|
|
19
|
-
const contentRecordsGeneral = [];
|
|
20
|
-
for (const file of files) {
|
|
21
|
-
const fileName = path.basename(file);
|
|
22
|
-
if (fileName.startsWith('_'))
|
|
23
|
-
continue;
|
|
24
|
-
const parts = fileName.split('.').slice(0, -1);
|
|
25
|
-
if (parts.length < 2)
|
|
26
|
-
continue;
|
|
27
|
-
const isIgnore = checkIgnoreOfParts(parts);
|
|
28
|
-
const isBeanGlobal = parts[0] === 'bean';
|
|
29
|
-
// const sceneName = parts.slice(0, -1).join('.');
|
|
30
|
-
// const beanName = parts[parts.length - 1];
|
|
31
|
-
// const beanNameCapitalize = toUpperCaseFirstChar(beanName);
|
|
32
|
-
const fileNameJS = fileName; // fileName.replace('.ts', '.js');
|
|
33
|
-
const className = parts.map(item => toUpperCaseFirstChar(item)).join('');
|
|
34
|
-
const beanFullName = isBeanGlobal ? parts[1] : `${moduleName}.${parts.join('.')}`;
|
|
35
|
-
contentExports.push(`export * from '../bean/${fileNameJS}';`);
|
|
36
|
-
// ignore virtual
|
|
37
|
-
contentScopes.push(`
|
|
38
|
-
export interface ${className} {
|
|
39
|
-
/** @internal */
|
|
40
|
-
get scope(): ${scopeModuleName};
|
|
41
|
-
}`);
|
|
42
|
-
if (isBeanGlobal || !isIgnore) {
|
|
43
|
-
contentImports.push(`import type { ${className} } from '../bean/${fileNameJS}';`);
|
|
44
|
-
}
|
|
45
|
-
if (isBeanGlobal && !isIgnore) {
|
|
46
|
-
contentRecordsGlobal.push(`'${beanFullName}': ${className};`);
|
|
47
|
-
}
|
|
48
|
-
if ((isBeanGlobal && isIgnore) || (!isBeanGlobal && !isIgnore)) {
|
|
49
|
-
contentRecordsGeneral.push(`'${beanFullName}': ${className};`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// combine
|
|
53
|
-
const content = `/** beans: begin */
|
|
54
|
-
${contentExports.join('\n')}
|
|
55
|
-
${contentImports.join('\n')}
|
|
56
|
-
import 'vona';
|
|
57
|
-
declare module 'vona' {
|
|
58
|
-
export interface IBeanRecordGlobal {
|
|
59
|
-
${contentRecordsGlobal.join('\n')}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface IBeanRecordGeneral {
|
|
63
|
-
${contentRecordsGeneral.join('\n')}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
declare module 'vona-module-${moduleName}' {
|
|
67
|
-
${contentScopes.join('\n')}
|
|
68
|
-
}
|
|
69
|
-
/** beans: end */
|
|
70
|
-
`;
|
|
71
|
-
return content;
|
|
72
|
-
}
|