zova-cli-set-front 1.2.37 → 1.2.41
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/component/boilerplateFormField/controller.tsx_ +4 -2
- package/cli/templates/refactor/componentModel/snippets/1-controller.ts +8 -9
- package/cli/templates/rest/_package.json +12 -0
- package/cli/templates/rest/component.ts +87 -0
- package/cli/templates/rest/index.ts +3 -0
- package/cli/templates/rest/inner.ts +22 -0
- package/cli/templates/rest/modules.ts +1 -0
- package/cli/templates/rest/render.ts +41 -0
- package/cli/templates/rest/rest.ts +51 -0
- package/cli/templates/rest/utils.ts +27 -0
- package/dist/index.js +66 -9
- package/dist/lib/bean/cli.bin.buildRest.d.ts +6 -1
- package/dist-cli/templates/refactor/componentModel/snippets/1-controller.js +6 -9
- package/package.json +3 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { IComponentOptions } from 'zova';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IFormFieldPresetOptionsBase } from 'zova-module-a-form';
|
|
3
|
+
import type { IResourceFormFieldOptionsBase } from 'zova-module-a-openapi';
|
|
4
|
+
|
|
3
5
|
import { BeanControllerBase } from 'zova';
|
|
4
6
|
import { Controller } from 'zova-module-a-bean';
|
|
5
7
|
import { ZFormField } from 'zova-module-a-form';
|
|
6
8
|
|
|
7
|
-
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends
|
|
9
|
+
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IFormFieldPresetOptionsBase<IResourceFormFieldOptionsBase> {}
|
|
8
10
|
|
|
9
11
|
@Controller()
|
|
10
12
|
export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
|
|
@@ -3,15 +3,16 @@ import { metadataCustomSnippet } from '@cabloy/cli';
|
|
|
3
3
|
declare module '@cabloy/cli' {
|
|
4
4
|
interface ICommandArgv {
|
|
5
5
|
modelName: string;
|
|
6
|
+
controllerFileName: string;
|
|
7
|
+
controllerClassName: string;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
const __regProps = /interface Controller[^<]*Props<(.*?)>/;
|
|
10
12
|
const __regModelsReplace = /interface [^<]*Models([^{]*) \{/;
|
|
11
|
-
const __regModelValue = /import \{[^}]*ModelValue[^}]*\} from 'zova';/;
|
|
12
|
-
const __regModelValueReplace = /import \{ ([^}]*) \} from 'zova';/;
|
|
13
13
|
const __regPropsDefaultReplace = /static \$propsDefault([^{]*) = \{/;
|
|
14
14
|
const __regLocalNameReplace = /protected async __init__/;
|
|
15
|
+
const __regLocalNameInitReplace = /protected async __init__([^{]*){/;
|
|
15
16
|
|
|
16
17
|
export default metadataCustomSnippet({
|
|
17
18
|
file: ({ argv }) => {
|
|
@@ -38,19 +39,17 @@ export default metadataCustomSnippet({
|
|
|
38
39
|
ast = ast.replace(__regModelsReplace, $0 => {
|
|
39
40
|
return `${$0}\n '${typeName}'?: number;`;
|
|
40
41
|
});
|
|
41
|
-
// @Model
|
|
42
|
-
if (!__regModelValue.test(ast)) {
|
|
43
|
-
ast = ast.replace(__regModelValueReplace, (_, $1) => {
|
|
44
|
-
return `import { ${$1}, ModelValue } from 'zova';`;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
42
|
// propsDefault
|
|
48
43
|
ast = ast.replace(__regPropsDefaultReplace, $0 => {
|
|
49
44
|
return `${$0}\n ${modelName}: 0,`;
|
|
50
45
|
});
|
|
51
46
|
// localName
|
|
52
47
|
ast = ast.replace(__regLocalNameReplace, $0 => {
|
|
53
|
-
return
|
|
48
|
+
return `${localName}: number;\n\n ${$0}`;
|
|
49
|
+
});
|
|
50
|
+
// init
|
|
51
|
+
ast = ast.replace(__regLocalNameInitReplace, $0 => {
|
|
52
|
+
return `${$0}\n this.${localName} = this.$useModel('${modelName}');`;
|
|
54
53
|
});
|
|
55
54
|
// ok
|
|
56
55
|
return ast;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { TypeRenderComponentJsx } from 'zova-jsx';
|
|
3
|
+
import type {
|
|
4
|
+
IResourceComponentFormFieldRecord,
|
|
5
|
+
TypeFormSchemaScene,
|
|
6
|
+
IResourceComponentTableCellActionRowRecord,
|
|
7
|
+
IResourceActionRowRecord,
|
|
8
|
+
IResourceComponentActionRowOptionsAction,
|
|
9
|
+
IResourceActionBulkRecord,
|
|
10
|
+
IResourceComponentActionBulkOptionsAction,
|
|
11
|
+
IResourceComponentBlockRecord,
|
|
12
|
+
IResourceComponentBlockOptionsBlock,
|
|
13
|
+
} from 'zova-module-a-openapi';
|
|
14
|
+
|
|
15
|
+
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
16
|
+
|
|
17
|
+
import { _generalSchemaRest } from './inner.ts';
|
|
18
|
+
|
|
19
|
+
export function schemaRenderField<K extends keyof IResourceComponentFormFieldRecord, T extends z.ZodType>(
|
|
20
|
+
name: K,
|
|
21
|
+
options?: IResourceComponentFormFieldRecord[K],
|
|
22
|
+
scene?: TypeFormSchemaScene,
|
|
23
|
+
) {
|
|
24
|
+
return function (schema: T): T {
|
|
25
|
+
const options2 = options !== undefined ? { render: name as never, options } : { render: name as never };
|
|
26
|
+
return _generalSchemaRest(schema, options2, scene ?? 'form'); // diff from table
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function schemaRenderFieldJsx<T extends z.ZodType>(renderComponentJsx: TypeRenderComponentJsx, scene?: TypeFormSchemaScene) {
|
|
31
|
+
return function (schema: T): T {
|
|
32
|
+
const options = { render: renderComponentJsx };
|
|
33
|
+
return _generalSchemaRest(schema, options, scene ?? 'form'); //diff from table
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function schemaRenderCell<K extends keyof IResourceComponentTableCellActionRowRecord, T extends z.ZodType>(
|
|
38
|
+
name: K,
|
|
39
|
+
options?: IResourceComponentTableCellActionRowRecord[K],
|
|
40
|
+
) {
|
|
41
|
+
return function (schema: T): T {
|
|
42
|
+
const options2 = options !== undefined ? { render: name as never, columnProps: options } : { render: name as never };
|
|
43
|
+
return _generalSchemaRest(schema, options2, 'table');
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function schemaRenderCellJsx<T extends z.ZodType>(renderComponentJsx: TypeRenderComponentJsx) {
|
|
48
|
+
return function (schema: T): T {
|
|
49
|
+
const options = { render: renderComponentJsx };
|
|
50
|
+
return _generalSchemaRest(schema, options, 'table');
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function schemaRenderActionRow<K extends keyof IResourceActionRowRecord>(
|
|
55
|
+
name: K,
|
|
56
|
+
options?: IResourceActionRowRecord[K],
|
|
57
|
+
): IResourceComponentActionRowOptionsAction {
|
|
58
|
+
const render = 'Action' + toUpperCaseFirstChar(name);
|
|
59
|
+
return { $$typeof: 'zova-jsx:actionRow', name, render: render as any, options };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function schemaRenderActionRowJsx<K extends keyof IResourceActionRowRecord>(name: K, renderComponentJsx: TypeRenderComponentJsx) {
|
|
63
|
+
return { name, render: renderComponentJsx };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function schemaRenderActionBulk<K extends keyof IResourceActionBulkRecord>(
|
|
67
|
+
name: K,
|
|
68
|
+
options?: IResourceActionBulkRecord[K],
|
|
69
|
+
): IResourceComponentActionBulkOptionsAction {
|
|
70
|
+
const render = 'Action' + toUpperCaseFirstChar(name);
|
|
71
|
+
return { $$typeof: 'zova-jsx:actionBulk', name, render: render as any, options };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function schemaRenderActionBulkJsx<K extends IResourceActionBulkRecord>(name: K, renderComponentJsx: TypeRenderComponentJsx) {
|
|
75
|
+
return { name, render: renderComponentJsx };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function schemaRenderBlock<K extends keyof IResourceComponentBlockRecord>(
|
|
79
|
+
name: K,
|
|
80
|
+
options?: IResourceComponentBlockRecord[K],
|
|
81
|
+
): IResourceComponentBlockOptionsBlock {
|
|
82
|
+
return { $$typeof: 'zova-jsx:block', render: name, options };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function schemaRenderBlockJsx(renderComponentJsx: TypeRenderComponentJsx) {
|
|
86
|
+
return { render: renderComponentJsx };
|
|
87
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import type { TypeSchemaOrderLevel, TypeSchemaScene } from 'zova-module-a-openapi';
|
|
3
|
+
|
|
4
|
+
export const OrderCoreBase = 100;
|
|
5
|
+
export const OrderBusinessBase = 1000;
|
|
6
|
+
export const OrderUnknownBase = 10000;
|
|
7
|
+
export const OrderMaxBase = 100000;
|
|
8
|
+
|
|
9
|
+
export const OrderLevelBaseMap = {
|
|
10
|
+
core: OrderCoreBase,
|
|
11
|
+
business: OrderBusinessBase,
|
|
12
|
+
max: OrderMaxBase,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function _generalSchemaRest<T extends z.ZodType>(schema: T, options: any, scene?: TypeSchemaScene) {
|
|
16
|
+
return schema.openapi(scene ? { rest: { [scene]: options } } : { rest: options });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function _order(order: number, level?: TypeSchemaOrderLevel) {
|
|
20
|
+
const levelBase = OrderLevelBaseMap[level ?? 'business'];
|
|
21
|
+
return levelBase + order;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%-argv.Modules%>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
schemaRenderActionBulk,
|
|
3
|
+
schemaRenderActionBulkJsx,
|
|
4
|
+
schemaRenderActionRow,
|
|
5
|
+
schemaRenderActionRowJsx,
|
|
6
|
+
schemaRenderBlock,
|
|
7
|
+
schemaRenderBlockJsx,
|
|
8
|
+
schemaRenderCell,
|
|
9
|
+
schemaRenderCellJsx,
|
|
10
|
+
schemaRenderField,
|
|
11
|
+
schemaRenderFieldJsx,
|
|
12
|
+
} from './component.ts';
|
|
13
|
+
import {
|
|
14
|
+
schemaRenderDisableNotifyChanged,
|
|
15
|
+
schemaRenderFieldSource,
|
|
16
|
+
schemaRenderLayout,
|
|
17
|
+
schemaRenderOrder,
|
|
18
|
+
schemaRenderReadonly,
|
|
19
|
+
schemaRenderVisible,
|
|
20
|
+
} from './rest.ts';
|
|
21
|
+
|
|
22
|
+
export const render = {
|
|
23
|
+
// render
|
|
24
|
+
layout: schemaRenderLayout,
|
|
25
|
+
visible: schemaRenderVisible,
|
|
26
|
+
readonly: schemaRenderReadonly,
|
|
27
|
+
order: schemaRenderOrder,
|
|
28
|
+
disableNotifyChanged: schemaRenderDisableNotifyChanged,
|
|
29
|
+
fieldSource: schemaRenderFieldSource,
|
|
30
|
+
// component
|
|
31
|
+
field: schemaRenderField,
|
|
32
|
+
fieldJsx: schemaRenderFieldJsx,
|
|
33
|
+
cell: schemaRenderCell,
|
|
34
|
+
cellJsx: schemaRenderCellJsx,
|
|
35
|
+
actionRow: schemaRenderActionRow,
|
|
36
|
+
actionRowJsx: schemaRenderActionRowJsx,
|
|
37
|
+
actionBulk: schemaRenderActionBulk,
|
|
38
|
+
actionBulkJsx: schemaRenderActionBulkJsx,
|
|
39
|
+
block: schemaRenderBlock,
|
|
40
|
+
blockJsx: schemaRenderBlockJsx,
|
|
41
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
|
|
3
|
+
import { TypeFormSchemaScene } from 'zova-module-a-openapi';
|
|
4
|
+
import { ISchemaRenderComponentLayoutOptions } from 'zova-module-a-openapi';
|
|
5
|
+
import { TypeSchemaScene } from 'zova-module-a-openapi';
|
|
6
|
+
import { TypeSchemaOrderLevel } from 'zova-module-a-openapi';
|
|
7
|
+
|
|
8
|
+
import { _generalSchemaRest, _order } from './inner.ts';
|
|
9
|
+
|
|
10
|
+
export function schemaRenderLayout<T extends z.ZodType>(layoutOptions: ISchemaRenderComponentLayoutOptions, scene?: TypeFormSchemaScene) {
|
|
11
|
+
return function (schema: T): T {
|
|
12
|
+
const options = { layout: layoutOptions };
|
|
13
|
+
return _generalSchemaRest(schema, options, scene);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function schemaRenderVisible<T extends z.ZodType>(visible?: boolean, scene?: TypeSchemaScene) {
|
|
18
|
+
return function (schema: T): T {
|
|
19
|
+
const options = { visible };
|
|
20
|
+
return _generalSchemaRest(schema, options, scene);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function schemaRenderReadonly<T extends z.ZodType>(readonly?: boolean, scene?: TypeSchemaScene) {
|
|
25
|
+
return function (schema: T): T {
|
|
26
|
+
const options = { readonly };
|
|
27
|
+
return _generalSchemaRest(schema, options, scene);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function schemaRenderDisableNotifyChanged<T extends z.ZodType>(disableNotifyChanged?: boolean, scene?: TypeSchemaScene) {
|
|
32
|
+
return function (schema: T): T {
|
|
33
|
+
const options = { disableNotifyChanged };
|
|
34
|
+
return _generalSchemaRest(schema, options, scene);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function schemaRenderFieldSource<T extends z.ZodType>(fieldSource: string, scene?: TypeSchemaScene) {
|
|
39
|
+
return function (schema: T): T {
|
|
40
|
+
const options = { fieldSource };
|
|
41
|
+
return _generalSchemaRest(schema, options, scene);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function schemaRenderOrder<T extends z.ZodType>(order: number, level?: TypeSchemaOrderLevel, scene?: TypeSchemaScene) {
|
|
46
|
+
const orderReal = _order(order, level);
|
|
47
|
+
return function (schema: T): T {
|
|
48
|
+
const options = { order: orderReal };
|
|
49
|
+
return _generalSchemaRest(schema, options, scene);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IActionRecord, TypeActionOptions } from 'zova-module-a-action';
|
|
2
|
+
import type { IVonaComponentRecord, TypeComponentOptions } from 'zova-module-a-bean';
|
|
3
|
+
import type { IIconRecord } from 'zova-module-a-icon';
|
|
4
|
+
import type { TypePagePathSchema } from 'zova-module-a-router';
|
|
5
|
+
|
|
6
|
+
declare module 'zova-module-a-router' {
|
|
7
|
+
export interface IPagePathRecord {
|
|
8
|
+
'/': TypePagePathSchema<undefined, undefined>;
|
|
9
|
+
'presetLogin': TypePagePathSchema<undefined, undefined>;
|
|
10
|
+
'presetErrorExpired': TypePagePathSchema<undefined, undefined>;
|
|
11
|
+
'presetResource': TypePagePathSchema<undefined, undefined>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function $iconName<K extends keyof IIconRecord>(name: K): any {
|
|
16
|
+
return name;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Action<K extends keyof IActionRecord>(options: TypeActionOptions<K>) {
|
|
20
|
+
if (!options.name) throw new Error('should specify the action name');
|
|
21
|
+
return options.name.replace(':', '.action.');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Component<K extends keyof IVonaComponentRecord>(options: TypeComponentOptions<K>) {
|
|
25
|
+
if (!options.name) throw new Error('should specify the component name');
|
|
26
|
+
return options.name;
|
|
27
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { camelToKebab, replaceTemplate, toUpperCaseFirstChar, toLowerCaseFirstCh
|
|
|
11
11
|
import fse from 'fs-extra';
|
|
12
12
|
import { build as build$1 } from 'tsdown';
|
|
13
13
|
import yaml from 'yaml';
|
|
14
|
-
import { saveJSONFile as saveJSONFile$1
|
|
14
|
+
import { createConfigUtils, saveJSONFile as saveJSONFile$1 } from 'zova-vite';
|
|
15
15
|
import fs from 'node:fs';
|
|
16
16
|
import 'node:url';
|
|
17
17
|
import { getOnionScenesMeta, getOnionMetasMeta } from '@cabloy/module-info';
|
|
@@ -169,6 +169,8 @@ async function saveJSONFile(fileName, json) {
|
|
|
169
169
|
await fse.writeFile(fileName, `${JSON.stringify(json, null, 2)}\n`);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
const __ThisSetName__ = 'front';
|
|
173
|
+
|
|
172
174
|
function svgResolverPlugin() {
|
|
173
175
|
return {
|
|
174
176
|
name: 'svg-resolver',
|
|
@@ -239,6 +241,53 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
239
241
|
await rimraf(srcDir);
|
|
240
242
|
}
|
|
241
243
|
async _prepareResources(context) {
|
|
244
|
+
const {
|
|
245
|
+
projectPath,
|
|
246
|
+
flavor,
|
|
247
|
+
bundleName,
|
|
248
|
+
srcDir
|
|
249
|
+
} = context;
|
|
250
|
+
const {
|
|
251
|
+
argv
|
|
252
|
+
} = this.context;
|
|
253
|
+
//
|
|
254
|
+
const mode = 'production';
|
|
255
|
+
const appMode = 'ssr';
|
|
256
|
+
const configMeta = {
|
|
257
|
+
flavor,
|
|
258
|
+
mode,
|
|
259
|
+
appMode
|
|
260
|
+
};
|
|
261
|
+
const configOptions = {
|
|
262
|
+
appDir: projectPath,
|
|
263
|
+
runtimeDir: '.zova'
|
|
264
|
+
};
|
|
265
|
+
const configUtils = createConfigUtils(configMeta, configOptions);
|
|
266
|
+
// env
|
|
267
|
+
const env = configUtils.loadEnvs();
|
|
268
|
+
// modulesMeta
|
|
269
|
+
const modulesMeta = await configUtils.loadModulesMeta();
|
|
270
|
+
// Modules
|
|
271
|
+
const modules = [];
|
|
272
|
+
const bundleModules = [];
|
|
273
|
+
for (const module of modulesMeta.modulesArray) {
|
|
274
|
+
modules.push(`export * from '${module.info.fullName}';`);
|
|
275
|
+
const moduleRoot = module.root.replaceAll('\\', '/');
|
|
276
|
+
if (moduleRoot.includes('/src/module/') || moduleRoot.includes('/src/suite/')) {
|
|
277
|
+
bundleModules.push(module.info.fullName);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
context.bundleModules = bundleModules;
|
|
281
|
+
argv.Modules = modules.join('\n');
|
|
282
|
+
// Name/Version
|
|
283
|
+
argv.Name = bundleName;
|
|
284
|
+
argv.Version = env.APP_VERSION;
|
|
285
|
+
// templateDir
|
|
286
|
+
const templateDir = this.template.resolveTemplatePath(__ThisSetName__, 'rest');
|
|
287
|
+
// render
|
|
288
|
+
await this.template.renderDir(srcDir, templateDir);
|
|
289
|
+
}
|
|
290
|
+
async _prepareResources_(context) {
|
|
242
291
|
// package.json
|
|
243
292
|
await this._prepareResourcesPackage(context);
|
|
244
293
|
// index.ts
|
|
@@ -271,8 +320,8 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
271
320
|
alwaysBundle: _id => {
|
|
272
321
|
return false;
|
|
273
322
|
}
|
|
274
|
-
}
|
|
275
|
-
minify: true
|
|
323
|
+
}
|
|
324
|
+
// minify: true,
|
|
276
325
|
});
|
|
277
326
|
const fileIndex = path.join(outDir, 'index.mjs');
|
|
278
327
|
let fileContent = (await fse.readFile(fileIndex)).toString();
|
|
@@ -281,9 +330,9 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
281
330
|
}
|
|
282
331
|
async _buildDts({
|
|
283
332
|
srcDir,
|
|
284
|
-
outDir
|
|
333
|
+
outDir,
|
|
334
|
+
bundleModules
|
|
285
335
|
}) {
|
|
286
|
-
const bundleModules = this._prepareBundleModules();
|
|
287
336
|
// entry
|
|
288
337
|
const entry = path.join(srcDir, 'index.ts');
|
|
289
338
|
// build
|
|
@@ -307,8 +356,8 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
307
356
|
if (bundleModules.includes(id)) return true;
|
|
308
357
|
return false;
|
|
309
358
|
}
|
|
310
|
-
}
|
|
311
|
-
minify: true
|
|
359
|
+
}
|
|
360
|
+
// minify: true,
|
|
312
361
|
});
|
|
313
362
|
}
|
|
314
363
|
async _build(buildContext) {
|
|
@@ -373,6 +422,8 @@ import type { TypePagePathSchema } from 'zova-module-a-router';
|
|
|
373
422
|
export type { IPagePathRecord } from 'zova-module-a-router';
|
|
374
423
|
import type { IActionRecord, TypeActionOptions } from 'zova-module-a-action';
|
|
375
424
|
export type { IActionRecord } from 'zova-module-a-action';
|
|
425
|
+
import type { IVonaComponentRecord, TypeComponentOptions } from 'zova-module-a-bean';
|
|
426
|
+
export type { IVonaComponentRecord } from 'zova-module-a-bean';
|
|
376
427
|
export type {
|
|
377
428
|
IResourceComponentActionBulkRecord,
|
|
378
429
|
IResourceComponentActionRowRecord,
|
|
@@ -426,9 +477,17 @@ export type {
|
|
|
426
477
|
} else if (fse.existsSync(dirStartOpenapi)) {
|
|
427
478
|
content += `import 'zova-module-start-openapi';\n`;
|
|
428
479
|
}
|
|
480
|
+
// actions
|
|
429
481
|
content += `export function Action<K extends keyof IActionRecord>(options: TypeActionOptions<K>) {
|
|
482
|
+
if(!options.name) throw new Error('should specify the action name');
|
|
430
483
|
return options.name.replace(':','.action.');
|
|
431
484
|
}
|
|
485
|
+
`;
|
|
486
|
+
// components
|
|
487
|
+
content += `export function Component<K extends keyof IVonaComponentRecord>(options: TypeComponentOptions<K>) {
|
|
488
|
+
if (!options.name) throw new Error('should specify the component name');
|
|
489
|
+
return options.name;
|
|
490
|
+
}
|
|
432
491
|
`;
|
|
433
492
|
return content;
|
|
434
493
|
}
|
|
@@ -515,8 +574,6 @@ async function getPackageVersionFromNodeModules(projectPath, packageName) {
|
|
|
515
574
|
return pkgContent.version;
|
|
516
575
|
}
|
|
517
576
|
|
|
518
|
-
const __ThisSetName__ = 'front';
|
|
519
|
-
|
|
520
577
|
let __snippetsPathPrefix;
|
|
521
578
|
class CliCreateBean extends BeanCliBase {
|
|
522
579
|
async execute() {
|
|
@@ -3,6 +3,9 @@ import { BeanCliBase } from '@cabloy/cli';
|
|
|
3
3
|
declare module '@cabloy/cli' {
|
|
4
4
|
interface ICommandArgv {
|
|
5
5
|
flavor?: ZovaMetaFlavor;
|
|
6
|
+
Modules: string;
|
|
7
|
+
Name: string;
|
|
8
|
+
Version: string;
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
11
|
interface IBinBuildRestContext {
|
|
@@ -12,13 +15,15 @@ interface IBinBuildRestContext {
|
|
|
12
15
|
bundleNameCopy: string;
|
|
13
16
|
srcDir: string;
|
|
14
17
|
outDir: string;
|
|
18
|
+
bundleModules?: string[];
|
|
15
19
|
}
|
|
16
20
|
export declare class CliBinBuildRest extends BeanCliBase {
|
|
17
21
|
execute(): Promise<void>;
|
|
18
22
|
_prepareResources(context: IBinBuildRestContext): Promise<void>;
|
|
23
|
+
_prepareResources_(context: IBinBuildRestContext): Promise<void>;
|
|
19
24
|
_prepareBundleModules(): string[];
|
|
20
25
|
_buildTs({ srcDir, outDir }: IBinBuildRestContext): Promise<void>;
|
|
21
|
-
_buildDts({ srcDir, outDir }: IBinBuildRestContext): Promise<void>;
|
|
26
|
+
_buildDts({ srcDir, outDir, bundleModules }: IBinBuildRestContext): Promise<void>;
|
|
22
27
|
_build(buildContext: IBinBuildRestContext): Promise<void>;
|
|
23
28
|
_prepareResourcesPackage({ projectPath, flavor, bundleName, srcDir }: IBinBuildRestContext): Promise<void>;
|
|
24
29
|
_prepareResourcesIndex({ srcDir, projectPath }: IBinBuildRestContext): Promise<void>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
2
|
const __regProps = /interface Controller[^<]*Props<(.*?)>/;
|
|
3
3
|
const __regModelsReplace = /interface [^<]*Models([^{]*) \{/;
|
|
4
|
-
const __regModelValue = /import \{[^}]*ModelValue[^}]*\} from 'zova';/;
|
|
5
|
-
const __regModelValueReplace = /import \{ ([^}]*) \} from 'zova';/;
|
|
6
4
|
const __regPropsDefaultReplace = /static \$propsDefault([^{]*) = \{/;
|
|
7
5
|
const __regLocalNameReplace = /protected async __init__/;
|
|
6
|
+
const __regLocalNameInitReplace = /protected async __init__([^{]*){/;
|
|
8
7
|
export default metadataCustomSnippet({
|
|
9
8
|
file: ({ argv }) => {
|
|
10
9
|
return argv.controllerFileName;
|
|
@@ -30,19 +29,17 @@ export default metadataCustomSnippet({
|
|
|
30
29
|
ast = ast.replace(__regModelsReplace, $0 => {
|
|
31
30
|
return `${$0}\n '${typeName}'?: number;`;
|
|
32
31
|
});
|
|
33
|
-
// @Model
|
|
34
|
-
if (!__regModelValue.test(ast)) {
|
|
35
|
-
ast = ast.replace(__regModelValueReplace, (_, $1) => {
|
|
36
|
-
return `import { ${$1}, ModelValue } from 'zova';`;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
32
|
// propsDefault
|
|
40
33
|
ast = ast.replace(__regPropsDefaultReplace, $0 => {
|
|
41
34
|
return `${$0}\n ${modelName}: 0,`;
|
|
42
35
|
});
|
|
43
36
|
// localName
|
|
44
37
|
ast = ast.replace(__regLocalNameReplace, $0 => {
|
|
45
|
-
return
|
|
38
|
+
return `${localName}: number;\n\n ${$0}`;
|
|
39
|
+
});
|
|
40
|
+
// init
|
|
41
|
+
ast = ast.replace(__regLocalNameInitReplace, $0 => {
|
|
42
|
+
return `${$0}\n this.${localName} = this.$useModel('${modelName}');`;
|
|
46
43
|
});
|
|
47
44
|
// ok
|
|
48
45
|
return ast;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-cli-set-front",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "1.2.41",
|
|
4
|
+
"gitHead": "6c7a09c8f0a8a0f41c5090b544a1667dbc689f0e",
|
|
5
5
|
"description": "zova cli-set-front",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"framework",
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"vite": "^8.0.2",
|
|
66
66
|
"yaml": "^2.8.3",
|
|
67
67
|
"zova-openapi": "^1.1.9",
|
|
68
|
-
"zova-vite": "^1.1.
|
|
68
|
+
"zova-vite": "^1.1.23"
|
|
69
69
|
}
|
|
70
70
|
}
|