zova-cli-set-front 1.2.42 → 1.2.43
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/boilerplateActionBulk/controller.tsx_ +9 -3
- package/cli/templates/create/component/boilerplateActionRow/controller.tsx_ +9 -3
- package/cli/templates/create/component/boilerplateBlockPage/controller.tsx_ +7 -1
- package/cli/templates/create/component/boilerplateBlockPageEntry/controller.tsx_ +7 -1
- package/cli/templates/create/component/boilerplateFormField/controller.tsx_ +1 -1
- package/cli/templates/rest/component.ts +6 -6
- package/dist/index.js +1 -150
- package/dist/lib/bean/cli.bin.buildRest.d.ts +0 -8
- package/package.json +2 -2
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type { IJsxRenderContextPage,
|
|
1
|
+
import type { IJsxRenderContextPage, IResourceTableActionBulkOptionsBase } from 'zova-module-a-openapi';
|
|
2
2
|
|
|
3
|
-
import { BeanControllerBase, IComponentOptions, Use } from 'zova';
|
|
3
|
+
import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
|
|
4
4
|
import { Controller } from 'zova-module-a-bean';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceTableActionBulkRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceTableActionBulkOptionsBase {}
|
|
7
13
|
|
|
8
14
|
@Controller()
|
|
9
15
|
export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type { IJsxRenderContextPageEntry,
|
|
1
|
+
import type { IJsxRenderContextPageEntry, IResourceFormActionRowOptionsBase } from 'zova-module-a-openapi';
|
|
2
2
|
|
|
3
|
-
import { BeanControllerBase, IComponentOptions, Use } from 'zova';
|
|
3
|
+
import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
|
|
4
4
|
import { Controller } from 'zova-module-a-bean';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceFormActionRowRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceFormActionRowOptionsBase {}
|
|
7
13
|
|
|
8
14
|
@Controller()
|
|
9
15
|
export class Controller<%=argv.nameMeta.fullCapitalize%> extends BeanControllerBase {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { IResourceBlockOptionsBase, IJsxRenderContextPage } from 'zova-module-a-openapi';
|
|
2
2
|
|
|
3
|
-
import { BeanControllerBase, IComponentOptions, Use } from 'zova';
|
|
3
|
+
import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
|
|
4
4
|
import { Controller } from 'zova-module-a-bean';
|
|
5
5
|
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceBlockRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceBlockOptionsBase {}
|
|
7
13
|
|
|
8
14
|
@Controller()
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { IResourceBlockOptionsBase, IJsxRenderContextPageEntry } from 'zova-module-a-openapi';
|
|
2
2
|
|
|
3
|
-
import { BeanControllerBase, IComponentOptions, Use } from 'zova';
|
|
3
|
+
import { BeanControllerBase, type IComponentOptions, Use } from 'zova';
|
|
4
4
|
import { Controller } from 'zova-module-a-bean';
|
|
5
5
|
|
|
6
|
+
declare module 'zova-module-a-openapi' {
|
|
7
|
+
export interface IResourceBlockRecord {
|
|
8
|
+
'<%=argv.module%>:<%=argv.nameMeta.full%>'?: Controller<%=argv.nameMeta.fullCapitalize%>Props;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
export interface Controller<%=argv.nameMeta.fullCapitalize%>Props extends IResourceBlockOptionsBase {}
|
|
7
13
|
|
|
8
14
|
@Controller()
|
|
@@ -6,7 +6,7 @@ import { Controller } from 'zova-module-a-bean';
|
|
|
6
6
|
import { ZFormField, type IFormFieldComponentOptions } from 'zova-module-a-form';
|
|
7
7
|
|
|
8
8
|
declare module 'zova-module-a-openapi' {
|
|
9
|
-
export interface
|
|
9
|
+
export interface IResourceFormFieldRecord {
|
|
10
10
|
'<%=argv.module%>:<%=argv.nameMeta.full%>'?: IResource<%=argv.nameMeta.fullCapitalize%>Options;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type z from 'zod';
|
|
2
2
|
import type { TypeRenderComponentJsx } from 'zova-jsx';
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
IResourceFormFieldRecord,
|
|
5
5
|
TypeFormSchemaScene,
|
|
6
|
-
|
|
6
|
+
IResourceTableActionRowRecordBoth,
|
|
7
7
|
IResourceActionRowRecord,
|
|
8
8
|
IResourceComponentActionRowOptionsAction,
|
|
9
9
|
IResourceActionBulkRecord,
|
|
@@ -16,9 +16,9 @@ import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
|
16
16
|
|
|
17
17
|
import { _generalSchemaRest } from './inner.ts';
|
|
18
18
|
|
|
19
|
-
export function schemaRenderField<K extends keyof
|
|
19
|
+
export function schemaRenderField<K extends keyof IResourceFormFieldRecord, T extends z.ZodType>(
|
|
20
20
|
name: K,
|
|
21
|
-
options?:
|
|
21
|
+
options?: IResourceFormFieldRecord[K],
|
|
22
22
|
scene?: TypeFormSchemaScene,
|
|
23
23
|
) {
|
|
24
24
|
return function (schema: T): T {
|
|
@@ -34,9 +34,9 @@ export function schemaRenderFieldJsx<T extends z.ZodType>(renderComponentJsx: Ty
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function schemaRenderCell<K extends keyof
|
|
37
|
+
export function schemaRenderCell<K extends keyof IResourceTableActionRowRecordBoth, T extends z.ZodType>(
|
|
38
38
|
name: K,
|
|
39
|
-
options?:
|
|
39
|
+
options?: IResourceTableActionRowRecordBoth[K],
|
|
40
40
|
) {
|
|
41
41
|
return function (schema: T): T {
|
|
42
42
|
const options2 = options !== undefined ? { render: name as never, columnProps: options } : { render: name as never };
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { rolldown } from 'rolldown';
|
|
|
7
7
|
import { dts } from 'rolldown-plugin-dts';
|
|
8
8
|
import { build } from 'vite';
|
|
9
9
|
import { createRequire } from 'node:module';
|
|
10
|
-
import { camelToKebab,
|
|
10
|
+
import { camelToKebab, toUpperCaseFirstChar, toLowerCaseFirstChar, skipPrefix, stringToCapitalize, replaceTemplate } from '@cabloy/word-utils';
|
|
11
11
|
import fse from 'fs-extra';
|
|
12
12
|
import { build as build$1 } from 'tsdown';
|
|
13
13
|
import yaml from 'yaml';
|
|
@@ -192,21 +192,6 @@ function svgResolverPlugin() {
|
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
const __template_package = `{
|
|
196
|
-
"name": "{{Name}}",
|
|
197
|
-
"version": "{{Version}}",
|
|
198
|
-
"type": "module",
|
|
199
|
-
"exports": {
|
|
200
|
-
".": {
|
|
201
|
-
"types": [
|
|
202
|
-
"./index.d.mts"
|
|
203
|
-
],
|
|
204
|
-
"import": "./index.mjs"
|
|
205
|
-
},
|
|
206
|
-
"./package.json": "./package.json"
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
`;
|
|
210
195
|
class CliBinBuildRest extends BeanCliBase {
|
|
211
196
|
async execute() {
|
|
212
197
|
const {
|
|
@@ -287,22 +272,6 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
287
272
|
// render
|
|
288
273
|
await this.template.renderDir(srcDir, templateDir);
|
|
289
274
|
}
|
|
290
|
-
async _prepareResources_(context) {
|
|
291
|
-
// package.json
|
|
292
|
-
await this._prepareResourcesPackage(context);
|
|
293
|
-
// index.ts
|
|
294
|
-
await this._prepareResourcesIndex(context);
|
|
295
|
-
}
|
|
296
|
-
_prepareBundleModules() {
|
|
297
|
-
const modules = [];
|
|
298
|
-
for (const module of this.modulesMeta.modulesArray) {
|
|
299
|
-
const moduleRoot = module.root.replaceAll('\\', '/');
|
|
300
|
-
if (moduleRoot.includes('/src/module/') || moduleRoot.includes('/src/suite/')) {
|
|
301
|
-
modules.push(module.info.fullName);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return modules;
|
|
305
|
-
}
|
|
306
275
|
async _buildTs({
|
|
307
276
|
srcDir,
|
|
308
277
|
outDir
|
|
@@ -385,124 +354,6 @@ class CliBinBuildRest extends BeanCliBase {
|
|
|
385
354
|
// copy
|
|
386
355
|
_copyToTarget(outDir, process.env.BUILD_REST_COPY_DIST, bundleNameCopy);
|
|
387
356
|
}
|
|
388
|
-
async _prepareResourcesPackage({
|
|
389
|
-
projectPath,
|
|
390
|
-
flavor,
|
|
391
|
-
bundleName,
|
|
392
|
-
srcDir
|
|
393
|
-
}) {
|
|
394
|
-
const mode = 'production';
|
|
395
|
-
const appMode = 'ssr';
|
|
396
|
-
const configMeta = {
|
|
397
|
-
flavor,
|
|
398
|
-
mode,
|
|
399
|
-
appMode
|
|
400
|
-
};
|
|
401
|
-
const configOptions = {
|
|
402
|
-
appDir: projectPath,
|
|
403
|
-
runtimeDir: '.zova'
|
|
404
|
-
};
|
|
405
|
-
const configUtils = createConfigUtils(configMeta, configOptions);
|
|
406
|
-
// env
|
|
407
|
-
const env = configUtils.loadEnvs();
|
|
408
|
-
// package.json
|
|
409
|
-
const pkgContent = replaceTemplate(__template_package, {
|
|
410
|
-
Name: bundleName,
|
|
411
|
-
Version: env.APP_VERSION
|
|
412
|
-
});
|
|
413
|
-
await fse.writeFile(path.join(srcDir, 'package.json'), pkgContent);
|
|
414
|
-
}
|
|
415
|
-
async _prepareResourcesIndex({
|
|
416
|
-
srcDir,
|
|
417
|
-
projectPath
|
|
418
|
-
}) {
|
|
419
|
-
let indexContent = `import type { IIconRecord } from 'zova-module-a-icon';
|
|
420
|
-
export type { IIconRecord } from 'zova-module-a-icon';
|
|
421
|
-
import type { TypePagePathSchema } from 'zova-module-a-router';
|
|
422
|
-
export type { IPagePathRecord } from 'zova-module-a-router';
|
|
423
|
-
import type { IActionRecord, TypeActionOptions } from 'zova-module-a-action';
|
|
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';
|
|
427
|
-
export type {
|
|
428
|
-
IResourceComponentActionBulkRecord,
|
|
429
|
-
IResourceComponentActionRowRecord,
|
|
430
|
-
IResourceComponentBlockRecord,
|
|
431
|
-
IResourceComponentFormFieldRecord,
|
|
432
|
-
IResourceComponentTableCellRecord,
|
|
433
|
-
ISchemaRenderComponentLayoutOptions,
|
|
434
|
-
} from 'zova-module-a-openapi';
|
|
435
|
-
`;
|
|
436
|
-
indexContent += await this._prepareResourcesIndex_rest(srcDir);
|
|
437
|
-
indexContent += await this._prepareResourcesIndex_icons(srcDir);
|
|
438
|
-
indexContent += await this._prepareResourcesIndex_pages(srcDir);
|
|
439
|
-
indexContent += await this._prepareResourcesIndex_providers(srcDir, projectPath);
|
|
440
|
-
await fse.writeFile(path.join(srcDir, 'index.ts'), indexContent);
|
|
441
|
-
}
|
|
442
|
-
async _prepareResourcesIndex_rest(srcDir) {
|
|
443
|
-
let content = '';
|
|
444
|
-
for (const module of this.modulesMeta.modulesArray) {
|
|
445
|
-
const restDir = path.join(module.root, 'rest');
|
|
446
|
-
if (!fse.existsSync(restDir)) continue;
|
|
447
|
-
let tempDir;
|
|
448
|
-
if (module.info.node_modules) {
|
|
449
|
-
tempDir = path.join(srcDir, 'modules', module.info.relativeName, 'rest');
|
|
450
|
-
await fse.copy(restDir, tempDir);
|
|
451
|
-
} else {
|
|
452
|
-
tempDir = path.join(module.root, 'rest');
|
|
453
|
-
}
|
|
454
|
-
const restIndexFile = path.join(tempDir, 'index.ts');
|
|
455
|
-
let restIndexFileRelative = path.relative(srcDir, restIndexFile);
|
|
456
|
-
if (!restIndexFileRelative.startsWith('.')) {
|
|
457
|
-
restIndexFileRelative = `./${restIndexFileRelative}`;
|
|
458
|
-
}
|
|
459
|
-
content += `export * from '${restIndexFileRelative.replaceAll('\\', '/')}';\n`;
|
|
460
|
-
}
|
|
461
|
-
return content;
|
|
462
|
-
}
|
|
463
|
-
async _prepareResourcesIndex_icons(_srcDir) {
|
|
464
|
-
const content = `export function $iconName<K extends keyof IIconRecord>(name: K): any {
|
|
465
|
-
return name;
|
|
466
|
-
}
|
|
467
|
-
`;
|
|
468
|
-
return content;
|
|
469
|
-
}
|
|
470
|
-
async _prepareResourcesIndex_providers(_srcDir, projectPath) {
|
|
471
|
-
// openapi
|
|
472
|
-
const dirBasicOpenapi = path.join(projectPath, './src/suite/cabloy-basic/modules/basic-openapi');
|
|
473
|
-
const dirStartOpenapi = path.join(projectPath, './src/suite/cabloy-start/modules/start-openapi');
|
|
474
|
-
let content = '';
|
|
475
|
-
if (fse.existsSync(dirBasicOpenapi)) {
|
|
476
|
-
content += `import 'zova-module-basic-openapi';\n`;
|
|
477
|
-
} else if (fse.existsSync(dirStartOpenapi)) {
|
|
478
|
-
content += `import 'zova-module-start-openapi';\n`;
|
|
479
|
-
}
|
|
480
|
-
// actions
|
|
481
|
-
content += `export function Action<K extends keyof IActionRecord>(options: TypeActionOptions<K>) {
|
|
482
|
-
if(!options.name) throw new Error('should specify the action name');
|
|
483
|
-
return options.name.replace(':','.action.');
|
|
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
|
-
}
|
|
491
|
-
`;
|
|
492
|
-
return content;
|
|
493
|
-
}
|
|
494
|
-
async _prepareResourcesIndex_pages(_srcDir) {
|
|
495
|
-
const content = `declare module 'zova-module-a-router' {
|
|
496
|
-
export interface IPagePathRecord {
|
|
497
|
-
'/': TypePagePathSchema<undefined, undefined>;
|
|
498
|
-
'presetLogin': TypePagePathSchema<undefined, undefined>;
|
|
499
|
-
'presetErrorExpired': TypePagePathSchema<undefined, undefined>;
|
|
500
|
-
'presetResource': TypePagePathSchema<undefined, undefined>;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
`;
|
|
504
|
-
return content;
|
|
505
|
-
}
|
|
506
357
|
}
|
|
507
358
|
function _copyToTarget(outDir, target, bundleNameCopy) {
|
|
508
359
|
if (!target) return;
|
|
@@ -20,16 +20,8 @@ interface IBinBuildRestContext {
|
|
|
20
20
|
export declare class CliBinBuildRest extends BeanCliBase {
|
|
21
21
|
execute(): Promise<void>;
|
|
22
22
|
_prepareResources(context: IBinBuildRestContext): Promise<void>;
|
|
23
|
-
_prepareResources_(context: IBinBuildRestContext): Promise<void>;
|
|
24
|
-
_prepareBundleModules(): string[];
|
|
25
23
|
_buildTs({ srcDir, outDir }: IBinBuildRestContext): Promise<void>;
|
|
26
24
|
_buildDts({ srcDir, outDir, bundleModules }: IBinBuildRestContext): Promise<void>;
|
|
27
25
|
_build(buildContext: IBinBuildRestContext): Promise<void>;
|
|
28
|
-
_prepareResourcesPackage({ projectPath, flavor, bundleName, srcDir }: IBinBuildRestContext): Promise<void>;
|
|
29
|
-
_prepareResourcesIndex({ srcDir, projectPath }: IBinBuildRestContext): Promise<void>;
|
|
30
|
-
_prepareResourcesIndex_rest(srcDir: string): Promise<string>;
|
|
31
|
-
_prepareResourcesIndex_icons(_srcDir: string): Promise<string>;
|
|
32
|
-
_prepareResourcesIndex_providers(_srcDir: string, projectPath: string): Promise<string>;
|
|
33
|
-
_prepareResourcesIndex_pages(_srcDir: string): Promise<string>;
|
|
34
26
|
}
|
|
35
27
|
export {};
|
package/package.json
CHANGED