vona-cli-set-api 1.0.8 → 1.0.11
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/module/boilerplate/_package.json +27 -7
- package/cli/templates/create/module/boilerplate/_tsconfig.build.json +8 -0
- package/cli/templates/create/module/boilerplate/_tsconfig.json +2 -3
- package/cli/templates/create/module/snippets/package.json.ts +17 -0
- package/cli/templates/create/module/snippets/tsconfig.json.ts +19 -0
- package/cli/templates/create/project/basic/boilerplate/.editorconfig +9 -0
- package/cli/templates/create/project/basic/boilerplate/.gitattributes +2 -0
- package/cli/templates/create/project/basic/boilerplate/.vscode/extensions.json +4 -0
- package/cli/templates/create/project/basic/boilerplate/.vscode/settings.json +45 -0
- package/cli/templates/create/project/basic/boilerplate/.vscode/vona.code-snippets +51 -0
- package/cli/templates/create/project/basic/boilerplate/env/.env +59 -0
- package/cli/templates/create/project/basic/boilerplate/env/.env.local +0 -0
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod +26 -0
- package/cli/templates/create/project/basic/boilerplate/env/.env.test +0 -0
- package/cli/templates/create/project/basic/boilerplate/eslint.config.mjs +16 -0
- package/cli/templates/create/project/basic/boilerplate/package.original.json +45 -0
- package/cli/templates/create/project/basic/boilerplate/pnpm-workspace.yaml +7 -0
- package/cli/templates/create/project/basic/boilerplate/scripts/app-init.sh +4 -0
- package/cli/templates/create/project/basic/boilerplate/scripts/wait-for-it.sh +156 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.local.ts +10 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.prod.ts +21 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.test.ts +10 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.ts +10 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/locale/en-us.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/locale/zh-cn.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/locales.ts +7 -0
- package/cli/templates/create/project/basic/boilerplate/src/backend/typing/env.d.ts +5 -0
- package/cli/templates/create/project/basic/boilerplate/src/module/.gitkeep +0 -0
- package/cli/templates/create/project/basic/boilerplate/src/module-vendor/.gitkeep +0 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/.gitkeep +0 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite-vendor/.gitkeep +0 -0
- package/cli/templates/create/project/basic/boilerplate/tsconfig.base.esm.json +10 -0
- package/cli/templates/create/project/basic/boilerplate/tsconfig.base.json +3 -0
- package/cli/templates/create/project/basic/boilerplate/tsconfig.json +12 -0
- package/cli/templates/create/suite/_package.json +2 -2
- package/cli/templates/create/suite/_tsconfig.json +2 -2
- package/cli/templates/create/test/boilerplate/{{name}}.test.ts +11 -0
- package/cli/templates/init/config/boilerplate/config/config.ts +5 -0
- package/cli/templates/init/constant/boilerplate/config/constants.ts +1 -0
- package/cli/templates/init/error/boilerplate/config/errors.ts +1 -0
- package/cli/templates/init/locale/boilerplate/config/locale/en-us.ts +1 -0
- package/cli/templates/init/locale/boilerplate/config/locale/zh-cn.ts +1 -0
- package/cli/templates/init/main/boilerplate/main.ts +2 -1
- package/cli/templates/init/monkey/boilerplate/monkey.ts +3 -1
- package/cli/templates/init/static/boilerplate/static/img/vona.png +0 -0
- package/cli/templates/tools/crud/boilerplate/src/controller/{{resourceName}}.ts_ +43 -0
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}Create.ts_ +9 -0
- package/cli/templates/tools/crud/boilerplate/src/dto/{{resourceName}}Update.ts_ +9 -0
- package/cli/templates/tools/crud/boilerplate/src/entity/{{resourceName}}.ts_ +15 -0
- package/cli/templates/tools/crud/boilerplate/src/model/{{resourceName}}.ts_ +5 -0
- package/cli/templates/tools/crud/boilerplate/src/service/{{resourceName}}.ts_ +32 -0
- package/cli/templates/tools/crud/boilerplate/test/{{resourceName}}.test.ts_ +46 -0
- package/cli/templates/tools/crud/snippets/1-package.json.ts +16 -0
- package/cli/templates/tools/crud/snippets/2-meta.version.ts +42 -0
- package/cli/templates/tools/crud/snippets/3-en-us.ts +27 -0
- package/cli/templates/tools/crud/snippets/4-zh-cn.ts +10 -0
- package/cli/templates/tools/crud/utils.ts +20 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/lib/bean/cli.bin.build.d.ts +15 -0
- package/dist/lib/bean/cli.bin.build.js +139 -0
- package/dist/lib/bean/cli.bin.dbReset.d.ts +13 -0
- package/dist/lib/bean/cli.bin.dbReset.js +46 -0
- package/dist/lib/bean/cli.bin.demo.d.ts +12 -0
- package/dist/lib/bean/cli.bin.demo.js +50 -0
- package/dist/lib/bean/cli.bin.dev.d.ts +14 -0
- package/dist/lib/bean/cli.bin.dev.js +53 -0
- package/dist/lib/bean/cli.bin.test.d.ts +15 -0
- package/dist/lib/bean/cli.bin.test.js +67 -0
- package/dist/lib/bean/{cli.tools.build.d.ts → cli.bin.tsc.d.ts} +2 -3
- package/dist/lib/bean/{cli.tools.build.js → cli.bin.tsc.js} +13 -5
- package/dist/lib/bean/cli.create.bean.d.ts +3 -4
- package/dist/lib/bean/cli.create.bean.js +42 -28
- package/dist/lib/bean/cli.create.module.d.ts +1 -2
- package/dist/lib/bean/cli.create.module.js +3 -4
- package/dist/lib/bean/cli.create.project.d.ts +26 -0
- package/dist/lib/bean/cli.create.project.js +115 -0
- package/dist/lib/bean/cli.create.suite.d.ts +1 -2
- package/dist/lib/bean/cli.create.suite.js +5 -9
- package/dist/lib/bean/cli.create.test.d.ts +15 -0
- package/dist/lib/bean/cli.create.test.js +39 -0
- package/dist/lib/bean/cli.default.list.d.ts +0 -1
- package/dist/lib/bean/cli.default.list.js +0 -1
- package/dist/lib/bean/cli.init.config.d.ts +8 -0
- package/dist/lib/bean/cli.init.config.js +36 -0
- package/dist/lib/bean/cli.init.constant.d.ts +8 -0
- package/dist/lib/bean/cli.init.constant.js +36 -0
- package/dist/lib/bean/cli.init.error.d.ts +8 -0
- package/dist/lib/bean/cli.init.error.js +47 -0
- package/dist/lib/bean/cli.init.locale.d.ts +8 -0
- package/dist/lib/bean/cli.init.locale.js +36 -0
- package/dist/lib/bean/cli.init.main.d.ts +0 -1
- package/dist/lib/bean/cli.init.main.js +2 -3
- package/dist/lib/bean/cli.init.monkey.d.ts +0 -1
- package/dist/lib/bean/cli.init.monkey.js +8 -10
- package/dist/lib/bean/cli.init.static.d.ts +8 -0
- package/dist/lib/bean/cli.init.static.js +36 -0
- package/dist/lib/bean/cli.tools.crud.d.ts +15 -0
- package/dist/lib/bean/cli.tools.crud.js +42 -0
- package/dist/lib/bean/cli.tools.deps.d.ts +2 -10
- package/dist/lib/bean/cli.tools.deps.js +16 -123
- package/dist/lib/bean/cli.tools.metadata.d.ts +1 -1
- package/dist/lib/bean/cli.tools.metadata.js +71 -32
- package/dist/lib/bean/toolsBin/configUtils.d.ts +7 -0
- package/dist/lib/bean/toolsBin/configUtils.js +56 -0
- package/dist/lib/bean/toolsBin/dbReset.d.ts +1 -0
- package/dist/lib/bean/toolsBin/dbReset.js +8 -0
- package/dist/lib/bean/toolsBin/demo.d.ts +1 -0
- package/dist/lib/bean/toolsBin/demo.js +41 -0
- package/dist/lib/bean/toolsBin/generateEntryFiles.d.ts +4 -0
- package/dist/lib/bean/toolsBin/generateEntryFiles.js +75 -0
- package/dist/lib/bean/toolsBin/generateVonaMeta.d.ts +10 -0
- package/dist/lib/bean/toolsBin/generateVonaMeta.js +17 -0
- package/dist/lib/bean/toolsBin/test.d.ts +1 -0
- package/dist/lib/bean/toolsBin/test.js +121 -0
- package/dist/lib/bean/toolsBin/types.d.ts +5 -0
- package/dist/lib/bean/toolsBin/types.js +1 -0
- package/dist/lib/bean/toolsMetadata/generateBeanGenerals.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateBeanGenerals.js +33 -0
- package/dist/lib/bean/toolsMetadata/generateBeans.d.ts +2 -2
- package/dist/lib/bean/toolsMetadata/generateBeans.js +33 -21
- package/dist/lib/bean/toolsMetadata/generateConfig.d.ts +3 -4
- package/dist/lib/bean/toolsMetadata/generateConfig.js +12 -14
- package/dist/lib/bean/toolsMetadata/generateMetadataCustom.d.ts +3 -0
- package/dist/lib/bean/toolsMetadata/generateMetadataCustom.js +23 -0
- package/dist/lib/bean/toolsMetadata/generateMonkey.d.ts +2 -3
- package/dist/lib/bean/toolsMetadata/generateMonkey.js +3 -4
- package/dist/lib/bean/toolsMetadata/generateOnions.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateOnions.js +90 -0
- package/dist/lib/bean/toolsMetadata/generateScope.d.ts +1 -4
- package/dist/lib/bean/toolsMetadata/generateScope.js +43 -16
- package/dist/lib/bean/toolsMetadata/generateScopeResources.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateScopeResources.js +29 -0
- package/dist/lib/bean/toolsMetadata/generateScopeResourcesMeta.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateScopeResourcesMeta.js +13 -0
- package/dist/lib/bean/toolsMetadata/utils.d.ts +9 -0
- package/dist/lib/bean/toolsMetadata/utils.js +82 -0
- package/dist/lib/beans.d.ts +36 -11
- package/dist/lib/beans.js +36 -11
- package/dist/lib/command/bin.build.d.ts +19 -0
- package/dist/lib/command/bin.build.js +18 -0
- package/dist/lib/command/bin.dbReset.d.ts +15 -0
- package/dist/lib/command/bin.dbReset.js +14 -0
- package/dist/lib/command/bin.demo.d.ts +15 -0
- package/dist/lib/command/bin.demo.js +14 -0
- package/dist/lib/command/bin.dev.d.ts +19 -0
- package/dist/lib/command/bin.dev.js +18 -0
- package/dist/lib/command/bin.test.d.ts +19 -0
- package/dist/lib/command/bin.test.js +18 -0
- package/dist/lib/command/{tools.build.d.ts → bin.tsc.d.ts} +0 -1
- package/dist/lib/command/{tools.build.js → bin.tsc.js} +3 -4
- package/dist/lib/command/create.bean.d.ts +0 -1
- package/dist/lib/command/create.bean.js +0 -1
- package/dist/lib/command/create.module.d.ts +0 -1
- package/dist/lib/command/create.module.js +0 -1
- package/dist/lib/command/create.project.d.ts +45 -0
- package/dist/lib/command/create.project.js +43 -0
- package/dist/lib/command/create.suite.d.ts +0 -1
- package/dist/lib/command/create.suite.js +0 -1
- package/dist/lib/command/create.test.d.ts +34 -0
- package/dist/lib/command/create.test.js +33 -0
- package/dist/lib/command/default.list.d.ts +0 -1
- package/dist/lib/command/default.list.js +0 -1
- package/dist/lib/command/init.config.d.ts +9 -0
- package/dist/lib/command/init.config.js +10 -0
- package/dist/lib/command/init.constant.d.ts +9 -0
- package/dist/lib/command/init.constant.js +10 -0
- package/dist/lib/command/init.error.d.ts +9 -0
- package/dist/lib/command/init.error.js +10 -0
- package/dist/lib/command/init.locale.d.ts +9 -0
- package/dist/lib/command/init.locale.js +10 -0
- package/dist/lib/command/init.main.d.ts +0 -1
- package/dist/lib/command/init.main.js +0 -1
- package/dist/lib/command/init.monkey.d.ts +0 -1
- package/dist/lib/command/init.monkey.js +0 -1
- package/dist/lib/command/init.static.d.ts +9 -0
- package/dist/lib/command/init.static.js +10 -0
- package/dist/lib/command/tools.crud.d.ts +34 -0
- package/dist/lib/command/tools.crud.js +33 -0
- package/dist/lib/command/tools.deps.d.ts +1 -11
- package/dist/lib/command/tools.deps.js +2 -12
- package/dist/lib/command/tools.metadata.d.ts +0 -1
- package/dist/lib/command/tools.metadata.js +0 -1
- package/dist/lib/commands.d.ts +237 -13
- package/dist/lib/commands.js +38 -11
- package/dist/lib/this.d.ts +0 -1
- package/dist/lib/this.js +0 -1
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.js +63 -0
- package/dist/typings.d.ts +0 -1
- package/dist/typings.js +0 -1
- package/package.json +50 -26
- package/templates/app/app.ejs +15 -0
- package/templates/app/bootstrap.ejs +13 -0
- package/templates/app/vona-modules-meta.ejs +49 -0
- package/templates/config/_tsconfig_project.json +12 -0
- package/templates/config/_tsconfig_source.json +40 -0
- package/templates/test/done-only.test.ts +3 -0
- package/templates/test/done.test.ts +3 -0
- package/cli/templates/create/bean/boilerplate/{{sceneName}}.{{beanName}}.ts_ +0 -4
- package/cli/templates/create/module/snippets/package.json.cjs +0 -11
- package/cli/templates/create/module/snippets/tsconfig.json.cjs +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/bean/cli.create.bean.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.bean.js.map +0 -1
- package/dist/lib/bean/cli.create.module.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.module.js.map +0 -1
- package/dist/lib/bean/cli.create.suite.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.suite.js.map +0 -1
- package/dist/lib/bean/cli.default.list.d.ts.map +0 -1
- package/dist/lib/bean/cli.default.list.js.map +0 -1
- package/dist/lib/bean/cli.init.main.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.main.js.map +0 -1
- package/dist/lib/bean/cli.init.monkey.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.monkey.js.map +0 -1
- package/dist/lib/bean/cli.tools.build.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.build.js.map +0 -1
- package/dist/lib/bean/cli.tools.deps.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.deps.js.map +0 -1
- package/dist/lib/bean/cli.tools.metadata.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.metadata.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateAtoms.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateAtoms.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateAtoms.js +0 -24
- package/dist/lib/bean/toolsMetadata/generateAtoms.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeans.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeans.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateConfig.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateConfig.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateControllers.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateControllers.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateControllers.js +0 -24
- package/dist/lib/bean/toolsMetadata/generateControllers.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateEntities.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateEntities.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateEntities.js +0 -24
- package/dist/lib/bean/toolsMetadata/generateEntities.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateModels.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateModels.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateModels.js +0 -34
- package/dist/lib/bean/toolsMetadata/generateModels.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateMonkey.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateMonkey.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateScope.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateScope.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateServices.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateServices.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateServices.js +0 -54
- package/dist/lib/bean/toolsMetadata/generateServices.js.map +0 -1
- package/dist/lib/beans.d.ts.map +0 -1
- package/dist/lib/beans.js.map +0 -1
- package/dist/lib/command/create.bean.d.ts.map +0 -1
- package/dist/lib/command/create.bean.js.map +0 -1
- package/dist/lib/command/create.module.d.ts.map +0 -1
- package/dist/lib/command/create.module.js.map +0 -1
- package/dist/lib/command/create.suite.d.ts.map +0 -1
- package/dist/lib/command/create.suite.js.map +0 -1
- package/dist/lib/command/default.list.d.ts.map +0 -1
- package/dist/lib/command/default.list.js.map +0 -1
- package/dist/lib/command/init.main.d.ts.map +0 -1
- package/dist/lib/command/init.main.js.map +0 -1
- package/dist/lib/command/init.monkey.d.ts.map +0 -1
- package/dist/lib/command/init.monkey.js.map +0 -1
- package/dist/lib/command/tools.build.d.ts.map +0 -1
- package/dist/lib/command/tools.build.js.map +0 -1
- package/dist/lib/command/tools.deps.d.ts.map +0 -1
- package/dist/lib/command/tools.deps.js.map +0 -1
- package/dist/lib/command/tools.metadata.d.ts.map +0 -1
- package/dist/lib/command/tools.metadata.js.map +0 -1
- package/dist/lib/commands.d.ts.map +0 -1
- package/dist/lib/commands.js.map +0 -1
- package/dist/lib/this.d.ts.map +0 -1
- package/dist/lib/this.js.map +0 -1
- package/dist/typings.d.ts.map +0 -1
- package/dist/typings.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": true
|
|
5
|
+
},
|
|
6
|
+
"references": [],
|
|
7
|
+
"include": [".vona/**/*.ts", "src/backend/package.json", "src/backend/config", "src/backend/demo", "src/backend/typing"],
|
|
8
|
+
"exclude": [],
|
|
9
|
+
"ts-node": {
|
|
10
|
+
"swc": true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-suite-<%=argv.name%>",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"version": "5.0.0",
|
|
4
5
|
"title": "<%=argv.suiteInfo.relativeName%>",
|
|
5
|
-
"
|
|
6
|
-
"files": ["dist"],
|
|
6
|
+
"files": [],
|
|
7
7
|
"description": "<%=argv.description%>",
|
|
8
8
|
"author": "<%=argv.author%>",
|
|
9
9
|
"dependencies": {}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { describe, it } from 'node:test';
|
|
3
|
+
import { app } from 'vona-mock';
|
|
4
|
+
|
|
5
|
+
describe('<%=argv.name%>.test.ts', () => {
|
|
6
|
+
it('action:<%=argv.name%>', async () => {
|
|
7
|
+
await app.bean.executor.mockCtx(async () => {
|
|
8
|
+
assert.equal(app.ctx.instanceName, '');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const constants = {} as const;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export enum Errors {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IModule } from '@cabloy/module-info';
|
|
2
|
+
import type { IMonkeyModule } from 'vona';
|
|
3
|
+
import { BeanSimple } from 'vona';
|
|
2
4
|
|
|
3
5
|
export class Monkey extends BeanSimple implements IMonkeyModule {
|
|
4
6
|
async moduleLoading(_module: IModule) {}
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-database';
|
|
2
|
+
import type { IDecoratorControllerOptions } from 'vona-module-a-web';
|
|
3
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { Api, Arg, v } from 'vona-module-a-openapi';
|
|
6
|
+
import { Controller, Web } from 'vona-module-a-web';
|
|
7
|
+
import { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
8
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
9
|
+
|
|
10
|
+
export interface IControllerOptions<%=argv.resourceNameCapitalize%> extends IDecoratorControllerOptions {}
|
|
11
|
+
|
|
12
|
+
@Controller<IControllerOptions<%=argv.resourceNameCapitalize%>>('<%=argv.resourceName%>')
|
|
13
|
+
export class Controller<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
14
|
+
@Web.post()
|
|
15
|
+
@Api.body(v.object(Entity<%=argv.resourceNameCapitalize%>))
|
|
16
|
+
async create(@Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<Entity<%=argv.resourceNameCapitalize%>> {
|
|
17
|
+
return await this.scope.service.<%=argv.resourceName%>.create(<%=argv.resourceName%>);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Web.get()
|
|
21
|
+
@Api.body(v.array(v.object(Entity<%=argv.resourceNameCapitalize%>)))
|
|
22
|
+
async findAll(): Promise<Entity<%=argv.resourceNameCapitalize%>[]> {
|
|
23
|
+
return await this.scope.service.<%=argv.resourceName%>.findAll();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Web.get(':id')
|
|
27
|
+
@Api.body(v.object(Entity<%=argv.resourceNameCapitalize%>))
|
|
28
|
+
async findOne(@Arg.param('id') id: TableIdentity): Promise<Entity<%=argv.resourceNameCapitalize%>> {
|
|
29
|
+
const <%=argv.resourceName%> = await this.scope.service.<%=argv.resourceName%>.findOne(id);
|
|
30
|
+
if (!<%=argv.resourceName%>) this.app.throw(404);
|
|
31
|
+
return <%=argv.resourceName%>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Web.patch(':id')
|
|
35
|
+
async update(@Arg.param('id') id: TableIdentity, @Arg.body() <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Update) {
|
|
36
|
+
return await this.scope.service.<%=argv.resourceName%>.update(id, <%=argv.resourceName%>);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Web.delete(':id')
|
|
40
|
+
async remove(@Arg.param('id') id: TableIdentity) {
|
|
41
|
+
return await this.scope.service.<%=argv.resourceName%>.remove(id);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
import { ClassMapped } from 'vona';
|
|
3
|
+
import { Dto } from 'vona-module-a-web';
|
|
4
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
5
|
+
|
|
6
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Create extends IDecoratorDtoOptions {}
|
|
7
|
+
|
|
8
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Create>()
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>Create extends ClassMapped.pick(Entity<%=argv.resourceNameCapitalize%>, ['name', 'description']) {}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IDecoratorDtoOptions } from 'vona-module-a-web';
|
|
2
|
+
import { ClassMapped } from 'vona';
|
|
3
|
+
import { Dto } from 'vona-module-a-web';
|
|
4
|
+
import { Dto<%=argv.resourceNameCapitalize%>Create } from './<%=argv.resourceName%>Create.ts';
|
|
5
|
+
|
|
6
|
+
export interface IDtoOptions<%=argv.resourceNameCapitalize%>Update extends IDecoratorDtoOptions {}
|
|
7
|
+
|
|
8
|
+
@Dto<IDtoOptions<%=argv.resourceNameCapitalize%>Update>()
|
|
9
|
+
export class Dto<%=argv.resourceNameCapitalize%>Update extends ClassMapped.partial(Dto<%=argv.resourceNameCapitalize%>Create) {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-database';
|
|
2
|
+
import { Entity, EntityBase } from 'vona-module-a-database';
|
|
3
|
+
import { Api, v } from 'vona-module-a-openapi';
|
|
4
|
+
import { $locale } from '../.metadata/index.ts';
|
|
5
|
+
|
|
6
|
+
export interface IEntityOptions<%=argv.resourceNameCapitalize%> extends IDecoratorEntityOptions {}
|
|
7
|
+
|
|
8
|
+
@Entity<IEntityOptions<%=argv.resourceNameCapitalize%>>('<%=argv.moduleResourceName%>')
|
|
9
|
+
export class Entity<%=argv.resourceNameCapitalize%> extends EntityBase {
|
|
10
|
+
@Api.field(v.openapi({ title: $locale('Name') }), v.min(3))
|
|
11
|
+
name: string;
|
|
12
|
+
|
|
13
|
+
@Api.field(v.openapi({ title: $locale('Description') }), v.optional())
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BeanModelBase, Model } from 'vona-module-a-database';
|
|
2
|
+
import { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
3
|
+
|
|
4
|
+
@Model({ entity: Entity<%=argv.resourceNameCapitalize%> })
|
|
5
|
+
export class Model<%=argv.resourceNameCapitalize%> extends BeanModelBase<Entity<%=argv.resourceNameCapitalize%>> {}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TableIdentity } from 'vona-module-a-database';
|
|
2
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Create } from '../dto/<%=argv.resourceName%>Create.ts';
|
|
3
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Update } from '../dto/<%=argv.resourceName%>Update.ts';
|
|
4
|
+
import type { Entity<%=argv.resourceNameCapitalize%> } from '../entity/<%=argv.resourceName%>.ts';
|
|
5
|
+
import { BeanBase } from 'vona';
|
|
6
|
+
import { Service } from 'vona-module-a-web';
|
|
7
|
+
|
|
8
|
+
@Service()
|
|
9
|
+
export class Service<%=argv.resourceNameCapitalize%> extends BeanBase {
|
|
10
|
+
async create(<%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Create): Promise<Entity<%=argv.resourceNameCapitalize%>> {
|
|
11
|
+
return await this.scope.model.<%=argv.resourceName%>.insert(<%=argv.resourceName%>);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async findAll(): Promise<Entity<%=argv.resourceNameCapitalize%>[]> {
|
|
15
|
+
return await this.scope.model.<%=argv.resourceName%>.select();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async findOne(id: TableIdentity): Promise<Entity<%=argv.resourceNameCapitalize%> | undefined> {
|
|
19
|
+
return await this.scope.model.<%=argv.resourceName%>.get({ id });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async update(id: TableIdentity, <%=argv.resourceName%>: Dto<%=argv.resourceNameCapitalize%>Update) {
|
|
23
|
+
return await this.scope.model.<%=argv.resourceName%>.update({
|
|
24
|
+
...<%=argv.resourceName%>,
|
|
25
|
+
id,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async remove(id: TableIdentity) {
|
|
30
|
+
return await this.scope.model.<%=argv.resourceName%>.delete({ id });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Dto<%=argv.resourceNameCapitalize%>Create, 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 { catchError } from '@cabloy/utils';
|
|
5
|
+
import { app } from 'vona-mock';
|
|
6
|
+
|
|
7
|
+
describe('<%=argv.resourceName%>.test.ts', () => {
|
|
8
|
+
it('action:<%=argv.resourceName%>', async () => {
|
|
9
|
+
await app.bean.executor.mockCtx(async () => {
|
|
10
|
+
// data
|
|
11
|
+
const data: Dto<%=argv.resourceNameCapitalize%>Create = {
|
|
12
|
+
name: '__Tom__',
|
|
13
|
+
description: 'This is a test',
|
|
14
|
+
};
|
|
15
|
+
const dataUpdate: Dto<%=argv.resourceNameCapitalize%>Update = {
|
|
16
|
+
name: '__TomNew__',
|
|
17
|
+
description: 'This is a test',
|
|
18
|
+
};
|
|
19
|
+
// login
|
|
20
|
+
await app.bean.passport.signinMock();
|
|
21
|
+
// create
|
|
22
|
+
const <%=argv.resourceName%>: Entity<%=argv.resourceNameCapitalize%> = await app.bean.executor.performAction('post', '<%=argv.moduleActionPathRaw%>', { body: data });
|
|
23
|
+
assert.equal(<%=argv.resourceName%>.name, data.name);
|
|
24
|
+
// findAll
|
|
25
|
+
const <%=argv.resourceName%>s: Entity<%=argv.resourceNameCapitalize%>[] = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>');
|
|
26
|
+
assert.equal(<%=argv.resourceName%>s.findIndex(item => item.name === data.name) > -1, true);
|
|
27
|
+
// update
|
|
28
|
+
await app.bean.executor.performAction('patch', '<%=argv.moduleActionPathRaw%>/:id', {
|
|
29
|
+
params: { id: <%=argv.resourceName%>.id },
|
|
30
|
+
body: dataUpdate,
|
|
31
|
+
});
|
|
32
|
+
// findOne
|
|
33
|
+
const <%=argv.resourceName%>One: Entity<%=argv.resourceNameCapitalize%> = await app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>.id } });
|
|
34
|
+
assert.equal(<%=argv.resourceName%>One.name, dataUpdate.name);
|
|
35
|
+
// delete
|
|
36
|
+
await app.bean.executor.performAction('delete', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>One.id } });
|
|
37
|
+
// findOne
|
|
38
|
+
const [_, err] = await catchError(() => {
|
|
39
|
+
return app.bean.executor.performAction('get', '<%=argv.moduleActionPathRaw%>/:id', { params: { id: <%=argv.resourceName%>One.id } });
|
|
40
|
+
});
|
|
41
|
+
assert.equal(err?.code, 404);
|
|
42
|
+
// logout
|
|
43
|
+
await app.bean.passport.signout();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -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,42 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
3
|
+
import { catchError } from '@cabloy/utils';
|
|
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.basicFields();
|
|
15
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.$column('name'), 50);
|
|
16
|
+
table.string(entity<%=argv.resourceNameCapitalize%>.$column('description'), 255);
|
|
17
|
+
});
|
|
18
|
+
}`;
|
|
19
|
+
|
|
20
|
+
export default metadataCustomSnippet({
|
|
21
|
+
file: 'src/bean/meta.version.ts',
|
|
22
|
+
language: 'gogo',
|
|
23
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
24
|
+
await catchError(() => {
|
|
25
|
+
return cli.helper.invokeCli([
|
|
26
|
+
':create:bean',
|
|
27
|
+
'meta',
|
|
28
|
+
'version',
|
|
29
|
+
`--module=${argv.module}`,
|
|
30
|
+
], { cwd: argv.projectPath });
|
|
31
|
+
});
|
|
32
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
33
|
+
},
|
|
34
|
+
async transform({ cli, ast }) {
|
|
35
|
+
// update
|
|
36
|
+
ast.replace('async update(_options: IMetaVersionUpdateOptions) {$$$1}', 'async update(options: IMetaVersionUpdateOptions) {$$$1}');
|
|
37
|
+
const code = await cli.template.renderContent({ content: __snippet_update });
|
|
38
|
+
ast.replace('async update($$$0) {$$$1}', `async update($$$0) {$$$1 \n ${code}}`);
|
|
39
|
+
// ok
|
|
40
|
+
return ast;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
3
|
+
import { catchError } from '@cabloy/utils';
|
|
4
|
+
import { locale_transform } from '../utils.ts';
|
|
5
|
+
|
|
6
|
+
declare module '@cabloy/cli' {
|
|
7
|
+
interface ICommandArgv {
|
|
8
|
+
module: string;
|
|
9
|
+
resourceNameCapitalize: string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default metadataCustomSnippet({
|
|
14
|
+
file: 'src/config/locale/en-us.ts',
|
|
15
|
+
language: 'gogo',
|
|
16
|
+
init: async ({ cli, argv, targetFile }) => {
|
|
17
|
+
await catchError(() => {
|
|
18
|
+
return cli.helper.invokeCli([':init:locale', argv.module], {
|
|
19
|
+
cwd: argv.projectPath,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
return fs.readFileSync(targetFile).toString('utf8');
|
|
23
|
+
},
|
|
24
|
+
async transform({ ast, argv }) {
|
|
25
|
+
return locale_transform({ ast, argv });
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { metadataCustomSnippet } from '@cabloy/cli';
|
|
2
|
+
import { locale_transform } from '../utils.ts';
|
|
3
|
+
|
|
4
|
+
export default metadataCustomSnippet({
|
|
5
|
+
file: 'src/config/locale/zh-cn.ts',
|
|
6
|
+
language: 'gogo',
|
|
7
|
+
async transform({ ast, argv }) {
|
|
8
|
+
return locale_transform({ ast, argv });
|
|
9
|
+
},
|
|
10
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const __names = ['Name', 'Description'];
|
|
2
|
+
|
|
3
|
+
export async function locale_transform({ ast, argv }) {
|
|
4
|
+
const names = __names.concat(argv.resourceNameCapitalize);
|
|
5
|
+
const nodes = ast.find('export default {$$$0}');
|
|
6
|
+
for (const name of names) {
|
|
7
|
+
const node = nodes.match.$$$0.find(node => {
|
|
8
|
+
return (node as any).key.name === name;
|
|
9
|
+
});
|
|
10
|
+
if (!node) {
|
|
11
|
+
const code = `${name}: '${name}',`;
|
|
12
|
+
ast.replace(
|
|
13
|
+
'export default {$$$0}',
|
|
14
|
+
`export default { $$$0, \n ${code}}`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// ok
|
|
19
|
+
return ast;
|
|
20
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './lib/beans.
|
|
2
|
-
export * from './lib/commands.
|
|
3
|
-
|
|
1
|
+
export * from './lib/beans.ts';
|
|
2
|
+
export * from './lib/commands.ts';
|
|
3
|
+
export * from './lib/utils.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
|
|
1
|
+
export * from "./lib/beans.js";
|
|
2
|
+
export * from "./lib/commands.js";
|
|
3
|
+
export * from "./lib/utils.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { glob } from '@cabloy/module-glob';
|
|
2
|
+
import type { VonaMetaFlavor } from '@cabloy/module-info';
|
|
3
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
4
|
+
declare module '@cabloy/cli' {
|
|
5
|
+
interface ICommandArgv {
|
|
6
|
+
workers?: number;
|
|
7
|
+
flavor?: VonaMetaFlavor;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare class CliBinBuild extends BeanCliBase {
|
|
11
|
+
execute(): Promise<void>;
|
|
12
|
+
_build(projectPath: string): Promise<void>;
|
|
13
|
+
_assets(projectPath: string, modulesMeta: Awaited<ReturnType<typeof glob>>): Promise<void>;
|
|
14
|
+
_rollup(projectPath: string, env: NodeJS.ProcessEnv): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
import aliasImport from '@rollup/plugin-alias';
|
|
4
|
+
import babelImport from '@rollup/plugin-babel';
|
|
5
|
+
import commonjsImport from '@rollup/plugin-commonjs';
|
|
6
|
+
import jsonImport from '@rollup/plugin-json';
|
|
7
|
+
import resolveImport from '@rollup/plugin-node-resolve';
|
|
8
|
+
import replaceImport from '@rollup/plugin-replace';
|
|
9
|
+
import terserImport from '@rollup/plugin-terser';
|
|
10
|
+
import fse from 'fs-extra';
|
|
11
|
+
import { rimraf } from 'rimraf';
|
|
12
|
+
import { rollup } from 'rollup';
|
|
13
|
+
import { generateConfigDefine } from "../utils.js";
|
|
14
|
+
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
15
|
+
const commonjs = commonjsImport;
|
|
16
|
+
const resolve = resolveImport;
|
|
17
|
+
// const swc = swcImport as any as typeof swcImport.default;
|
|
18
|
+
const json = jsonImport;
|
|
19
|
+
const babel = babelImport;
|
|
20
|
+
const terser = terserImport;
|
|
21
|
+
const alias = aliasImport;
|
|
22
|
+
const replace = replaceImport;
|
|
23
|
+
export class CliBinBuild extends BeanCliBase {
|
|
24
|
+
async execute() {
|
|
25
|
+
const { argv } = this.context;
|
|
26
|
+
// super
|
|
27
|
+
await super.execute();
|
|
28
|
+
const projectPath = argv.projectPath;
|
|
29
|
+
await this._build(projectPath);
|
|
30
|
+
}
|
|
31
|
+
async _build(projectPath) {
|
|
32
|
+
const { argv } = this.context;
|
|
33
|
+
const mode = 'prod';
|
|
34
|
+
const flavor = argv.flavor || 'normal';
|
|
35
|
+
const configMeta = { flavor, mode };
|
|
36
|
+
const configOptions = {
|
|
37
|
+
appDir: projectPath,
|
|
38
|
+
runtimeDir: '.vona',
|
|
39
|
+
workers: argv.workers,
|
|
40
|
+
};
|
|
41
|
+
const { env, modulesMeta } = await generateVonaMeta(configMeta, configOptions);
|
|
42
|
+
await rimraf(path.join(projectPath, 'dist'));
|
|
43
|
+
await this._rollup(projectPath, env);
|
|
44
|
+
await this._assets(projectPath, modulesMeta);
|
|
45
|
+
await rimraf(path.join(projectPath, '.vona'));
|
|
46
|
+
}
|
|
47
|
+
async _assets(projectPath, modulesMeta) {
|
|
48
|
+
const assetsPath = path.join(projectPath, 'dist/assets');
|
|
49
|
+
for (const relativeName in modulesMeta.modules) {
|
|
50
|
+
const module = modulesMeta.modules[relativeName];
|
|
51
|
+
if (!module.package.files)
|
|
52
|
+
continue;
|
|
53
|
+
for (const scene of module.package.files) {
|
|
54
|
+
if (['dist', 'cli', 'test'].includes(scene))
|
|
55
|
+
continue;
|
|
56
|
+
const scenePath = path.join(module.root, scene);
|
|
57
|
+
if (fse.existsSync(scenePath)) {
|
|
58
|
+
const destPath = path.join(assetsPath, scene, relativeName);
|
|
59
|
+
await fse.copy(scenePath, destPath);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async _rollup(projectPath, env) {
|
|
65
|
+
const aliasEntries = [];
|
|
66
|
+
for (const name of ['better-sqlite3', 'mysql', 'oracledb', 'pg-native', 'pg-query-stream', 'sqlite3', 'tedious', 'cloudflare:sockets']) {
|
|
67
|
+
aliasEntries.push({ find: name, replacement: 'vona-shared' });
|
|
68
|
+
}
|
|
69
|
+
const replaceValues = generateConfigDefine(env, ['NODE_ENV', 'META_MODE', 'META_FLAVOR']);
|
|
70
|
+
const plugins = [
|
|
71
|
+
alias({
|
|
72
|
+
entries: aliasEntries,
|
|
73
|
+
}),
|
|
74
|
+
resolve({
|
|
75
|
+
preferBuiltins: true,
|
|
76
|
+
}),
|
|
77
|
+
replace({
|
|
78
|
+
values: replaceValues,
|
|
79
|
+
preventAssignment: false,
|
|
80
|
+
}),
|
|
81
|
+
json(),
|
|
82
|
+
commonjs(),
|
|
83
|
+
babel({
|
|
84
|
+
include: '**/*.ts',
|
|
85
|
+
extensions: ['.ts', '.tsx'],
|
|
86
|
+
babelHelpers: 'bundled',
|
|
87
|
+
skipPreflightCheck: true,
|
|
88
|
+
babelrc: false,
|
|
89
|
+
configFile: false,
|
|
90
|
+
plugins: [
|
|
91
|
+
['babel-plugin-zova-bean-module', { brandName: 'vona' }],
|
|
92
|
+
['babel-plugin-transform-typescript-metadata'],
|
|
93
|
+
['@babel/plugin-proposal-decorators', { version: 'legacy' }],
|
|
94
|
+
['@babel/plugin-transform-class-properties', { loose: true }],
|
|
95
|
+
['@babel/plugin-transform-typescript'],
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
];
|
|
99
|
+
if (process.env.BUILD_MINIFY === 'true') {
|
|
100
|
+
plugins.push(terser({
|
|
101
|
+
keep_classnames: true,
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
const inputOptions = {
|
|
105
|
+
input: path.join(projectPath, '.vona/bootstrap.ts'),
|
|
106
|
+
plugins,
|
|
107
|
+
onLog: (level, log, defaultHandler) => {
|
|
108
|
+
if (log.code === 'CIRCULAR_DEPENDENCY' && process.env.BUILD_LOG_CIRCULAR_DEPENDENCY === 'false')
|
|
109
|
+
return;
|
|
110
|
+
if (log.code === 'THIS_IS_UNDEFINED' && log.message.includes('ramda/es/partialObject.js'))
|
|
111
|
+
return;
|
|
112
|
+
if (log.code === 'EVAL' && log.message.includes('depd/index.js'))
|
|
113
|
+
return;
|
|
114
|
+
if (log.code === 'EVAL' && log.message.includes('bluebird/js/release/util.js'))
|
|
115
|
+
return;
|
|
116
|
+
defaultHandler(level, log);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const outputOption = {
|
|
120
|
+
dir: path.join(projectPath, 'dist'),
|
|
121
|
+
// file: path.join(projectPath, 'dist/index.js'),
|
|
122
|
+
format: 'esm',
|
|
123
|
+
sourcemap: process.env.BUILD_SOURCEMAP === 'true',
|
|
124
|
+
// https://github.com/rollup/rollup/issues/4166
|
|
125
|
+
inlineDynamicImports: process.env.BUILD_INLINEDYNAMICIMPORTS === 'true',
|
|
126
|
+
};
|
|
127
|
+
let bundle;
|
|
128
|
+
try {
|
|
129
|
+
bundle = await rollup(inputOptions);
|
|
130
|
+
await bundle.write(outputOption);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
if (bundle) {
|
|
134
|
+
// closes the bundle
|
|
135
|
+
await bundle.close();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { glob } from '@cabloy/module-glob';
|
|
2
|
+
import type { VonaMetaFlavor } from '@cabloy/module-info';
|
|
3
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
4
|
+
declare module '@cabloy/cli' {
|
|
5
|
+
interface ICommandArgv {
|
|
6
|
+
flavor?: VonaMetaFlavor;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class CliBinDbReset extends BeanCliBase {
|
|
10
|
+
execute(): Promise<void>;
|
|
11
|
+
_dbReset(projectPath: string): Promise<void>;
|
|
12
|
+
_run(projectPath: string, _modulesMeta: Awaited<ReturnType<typeof glob>>): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
import fse from 'fs-extra';
|
|
4
|
+
import { rimraf } from 'rimraf';
|
|
5
|
+
import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
|
|
6
|
+
export class CliBinDbReset extends BeanCliBase {
|
|
7
|
+
async execute() {
|
|
8
|
+
const { argv } = this.context;
|
|
9
|
+
// super
|
|
10
|
+
await super.execute();
|
|
11
|
+
const projectPath = argv.projectPath;
|
|
12
|
+
// test
|
|
13
|
+
await this._dbReset(projectPath);
|
|
14
|
+
}
|
|
15
|
+
async _dbReset(projectPath) {
|
|
16
|
+
const { argv } = this.context;
|
|
17
|
+
const mode = 'test';
|
|
18
|
+
const flavor = argv.flavor || 'normal';
|
|
19
|
+
const configMeta = { flavor, mode };
|
|
20
|
+
const configOptions = {
|
|
21
|
+
appDir: projectPath,
|
|
22
|
+
runtimeDir: '.vona',
|
|
23
|
+
workers: 1,
|
|
24
|
+
};
|
|
25
|
+
const { modulesMeta } = await generateVonaMeta(configMeta, configOptions);
|
|
26
|
+
await this._run(projectPath, modulesMeta);
|
|
27
|
+
await rimraf(path.join(projectPath, '.vona'));
|
|
28
|
+
}
|
|
29
|
+
async _run(projectPath, _modulesMeta) {
|
|
30
|
+
// testFile
|
|
31
|
+
let testFile = path.join(import.meta.dirname, './toolsBin/dbReset.ts');
|
|
32
|
+
if (!fse.existsSync(testFile)) {
|
|
33
|
+
testFile = path.join(import.meta.dirname, './toolsBin/dbReset.js');
|
|
34
|
+
}
|
|
35
|
+
// run
|
|
36
|
+
let args = [];
|
|
37
|
+
args = args.concat(['--experimental-transform-types', '--loader=ts-node/esm', testFile, projectPath]);
|
|
38
|
+
await this.helper.spawnExe({
|
|
39
|
+
cmd: 'node',
|
|
40
|
+
args,
|
|
41
|
+
options: {
|
|
42
|
+
cwd: projectPath,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { VonaMetaFlavor } from '@cabloy/module-info';
|
|
2
|
+
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
+
declare module '@cabloy/cli' {
|
|
4
|
+
interface ICommandArgv {
|
|
5
|
+
flavor?: VonaMetaFlavor;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class CliBinDemo extends BeanCliBase {
|
|
9
|
+
execute(): Promise<void>;
|
|
10
|
+
_demo(projectPath: string): Promise<void>;
|
|
11
|
+
_run(projectPath: string): Promise<void>;
|
|
12
|
+
}
|