zova-cli-set-front 1.1.199 → 1.2.0
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/LICENSE +0 -0
- package/README.md +0 -0
- package/cli/templates/create/component/boilerplate/controller.tsx_ +11 -0
- package/cli/templates/create/component/boilerplateFormField/controller.tsx_ +23 -0
- package/cli/templates/create/module/boilerplate/_package.json +17 -3
- package/cli/templates/create/module/boilerplate/_tsconfig.build.json +13 -0
- package/cli/templates/create/module/boilerplate/_tsconfig.json +5 -1
- package/cli/templates/create/module/boilerplate/src/index.ts_ +0 -0
- package/cli/templates/create/module/snippets/package.json.ts +17 -0
- package/cli/templates/create/page/boilerplate/controller.tsx_ +11 -0
- package/cli/templates/create/page/snippets/{routes.cjs → routes.ts} +7 -9
- package/cli/templates/create/suite/_package.json +5 -5
- package/cli/templates/create/suite/modules/.gitkeep +0 -0
- package/cli/templates/init/appMonkey/boilerplate/monkey.ts +13 -0
- package/cli/templates/init/config/boilerplate/config/config.ts +2 -2
- package/cli/templates/init/constant/boilerplate/config/constants.ts +1 -1
- package/cli/templates/init/error/boilerplate/config/errors.ts +1 -1
- package/cli/templates/init/icon/boilerplate/icons/default/zova.svg +2 -2
- package/cli/templates/init/legacy/boilerplate/components/counter.vue +2 -0
- package/cli/templates/init/legacy/boilerplate/pages/counter.vue +3 -2
- package/cli/templates/init/legacy/boilerplate/routes.ts +1 -1
- package/cli/templates/init/lib/boilerplate/lib/index.ts +1 -0
- package/cli/templates/init/main/boilerplate/main.ts +8 -0
- package/cli/templates/init/mainSys/boilerplate/mainSys.ts +9 -0
- package/cli/templates/init/monkey/boilerplate/monkey.ts +3 -1
- package/cli/templates/init/monkeySys/boilerplate/monkeySys.ts +7 -0
- package/cli/templates/init/sysMonkey/boilerplate/monkeySys.ts +14 -0
- package/cli/templates/init/types/boilerplate/types/index.ts +1 -0
- package/cli/templates/openapi/config/boilerplate/module/openapi.config.ts +5 -0
- package/cli/templates/openapi/config/boilerplate/project/openapi.config.ts +10 -0
- package/cli/templates/openapi/config/snippets/openapi.config.ts +18 -0
- package/cli/templates/refactor/anotherRender/boilerplate/render.{{renderName}}.tsx_ +7 -0
- package/cli/templates/refactor/anotherRender/snippets/render.ts +30 -0
- package/cli/templates/refactor/anotherStyle/boilerplate/style.{{styleName}}.ts_ +7 -0
- package/cli/templates/refactor/anotherStyle/snippets/style.ts +27 -0
- package/cli/templates/refactor/componentEmits/snippets/2-controller.ts +29 -0
- package/cli/templates/refactor/componentGeneric/snippets/2-controller.ts +23 -0
- package/cli/templates/refactor/componentModel/snippets/1-controller.ts +58 -0
- package/cli/templates/refactor/componentProps/snippets/2-controller.ts +24 -0
- package/cli/templates/refactor/componentSlots/snippets/1-controller.ts +22 -0
- package/cli/templates/refactor/firstRender/boilerplate/{{renderName}}.tsx_ +7 -0
- package/cli/templates/refactor/firstStyle/boilerplate/{{styleName}}.ts_ +7 -0
- package/cli/templates/refactor/pageParams/snippets/1-controller.ts +20 -0
- package/cli/templates/refactor/pageQuery/snippets/1-controller.ts +20 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4707 -3
- package/dist/lib/bean/cli.bin.buildModule.d.ts +14 -0
- package/dist/lib/bean/cli.bin.buildRest.d.ts +26 -0
- package/dist/lib/bean/cli.create.bean.d.ts +19 -5
- package/dist/lib/bean/cli.create.component.d.ts +2 -3
- package/dist/lib/bean/cli.create.mock.d.ts +3 -3
- package/dist/lib/bean/cli.create.module.d.ts +1 -2
- package/dist/lib/bean/cli.create.page.d.ts +2 -3
- package/dist/lib/bean/cli.create.project.d.ts +2 -2
- package/dist/lib/bean/cli.create.suite.d.ts +1 -2
- package/dist/lib/bean/cli.default.list.d.ts +0 -1
- package/dist/lib/bean/cli.init.appMonkey.d.ts +8 -0
- package/dist/lib/bean/cli.init.asset.d.ts +12 -0
- package/dist/lib/bean/cli.init.config.d.ts +0 -1
- package/dist/lib/bean/cli.init.constant.d.ts +0 -1
- package/dist/lib/bean/cli.init.error.d.ts +0 -1
- package/dist/lib/bean/cli.init.icon.d.ts +0 -1
- package/dist/lib/bean/cli.init.legacy.d.ts +0 -1
- package/dist/lib/bean/cli.init.lib.d.ts +8 -0
- package/dist/lib/bean/cli.init.locale.d.ts +0 -1
- package/dist/lib/bean/cli.init.main.d.ts +8 -0
- package/dist/lib/bean/cli.init.mainSys.d.ts +8 -0
- package/dist/lib/bean/cli.init.monkey.d.ts +0 -1
- package/dist/lib/bean/cli.init.monkeySys.d.ts +9 -0
- package/dist/lib/bean/cli.init.sysMonkey.d.ts +8 -0
- package/dist/lib/bean/cli.init.types.d.ts +8 -0
- package/dist/lib/bean/cli.openapi.config.d.ts +9 -0
- package/dist/lib/bean/cli.openapi.generate.d.ts +41 -0
- package/dist/lib/bean/cli.refactor.anotherRender.d.ts +4 -3
- package/dist/lib/bean/cli.refactor.anotherStyle.d.ts +4 -3
- package/dist/lib/bean/cli.refactor.componentEmits.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.componentGeneric.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.componentModel.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.componentProps.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.componentSlots.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.firstRender.d.ts +17 -0
- package/dist/lib/bean/cli.refactor.firstStyle.d.ts +18 -0
- package/dist/lib/bean/cli.refactor.pageParams.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.pageQuery.d.ts +5 -3
- package/dist/lib/bean/cli.refactor.renameComponent.d.ts +3 -3
- package/dist/lib/bean/cli.tools.deps.d.ts +1 -5
- package/dist/lib/bean/cli.tools.metadata.d.ts +2 -1
- package/dist/lib/bean/toolsMetadata/generateBeanGenerals.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateConfig.d.ts +3 -3
- package/dist/lib/bean/toolsMetadata/generateIcons.d.ts +0 -1
- package/dist/lib/bean/toolsMetadata/generateMetadataCustom.d.ts +3 -0
- package/dist/lib/bean/toolsMetadata/generateMonkey.d.ts +4 -2
- package/dist/lib/bean/toolsMetadata/generateOnions.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateOptionsPackage.d.ts +3 -0
- package/dist/lib/bean/toolsMetadata/generateScope.d.ts +1 -4
- package/dist/lib/bean/toolsMetadata/generateScopeResources.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/generateScopeResourcesMeta.d.ts +2 -0
- package/dist/lib/bean/toolsMetadata/utils.d.ts +13 -0
- package/dist/lib/beans.d.ts +56 -45
- package/dist/lib/command/bin.buildModule.d.ts +23 -0
- package/dist/lib/command/{tools.icons.d.ts → bin.buildRest.d.ts} +6 -1
- package/dist/lib/command/create.bean.d.ts +8 -1
- package/dist/lib/command/create.component.d.ts +4 -1
- package/dist/lib/command/create.mock.d.ts +0 -1
- package/dist/lib/command/create.module.d.ts +0 -9
- package/dist/lib/command/create.page.d.ts +0 -1
- package/dist/lib/command/create.project.d.ts +0 -1
- package/dist/lib/command/create.suite.d.ts +0 -9
- package/dist/lib/command/default.list.d.ts +0 -1
- package/dist/lib/command/{tools.res.d.ts → init.appMonkey.d.ts} +0 -1
- package/dist/lib/command/{bean.tool.d.ts → init.asset.d.ts} +1 -2
- package/dist/lib/command/init.config.d.ts +0 -1
- package/dist/lib/command/init.constant.d.ts +0 -1
- package/dist/lib/command/init.error.d.ts +0 -1
- package/dist/lib/command/init.icon.d.ts +0 -1
- package/dist/lib/command/init.legacy.d.ts +0 -1
- package/dist/lib/command/{init.mock.d.ts → init.lib.d.ts} +0 -1
- package/dist/lib/command/init.locale.d.ts +0 -1
- package/dist/lib/command/{tools.icon.d.ts → init.main.d.ts} +0 -1
- package/dist/lib/command/{init.icons.d.ts → init.mainSys.d.ts} +0 -1
- package/dist/lib/command/init.monkey.d.ts +0 -1
- package/dist/lib/command/init.monkeySys.d.ts +9 -0
- package/dist/lib/command/init.sysMonkey.d.ts +9 -0
- package/dist/lib/command/init.types.d.ts +9 -0
- package/dist/lib/command/openapi.config.d.ts +9 -0
- package/dist/lib/command/openapi.generate.d.ts +9 -0
- package/dist/lib/command/refactor.anotherRender.d.ts +0 -1
- package/dist/lib/command/refactor.anotherStyle.d.ts +0 -1
- package/dist/lib/command/refactor.componentEmits.d.ts +0 -1
- package/dist/lib/command/refactor.componentGeneric.d.ts +0 -1
- package/dist/lib/command/refactor.componentModel.d.ts +0 -1
- package/dist/lib/command/refactor.componentProps.d.ts +0 -1
- package/dist/lib/command/refactor.componentSlots.d.ts +0 -1
- package/dist/lib/command/{bean.model.d.ts → refactor.firstRender.d.ts} +1 -2
- package/dist/lib/command/{bean.local.d.ts → refactor.firstStyle.d.ts} +1 -2
- package/dist/lib/command/refactor.pageParams.d.ts +0 -1
- package/dist/lib/command/refactor.pageQuery.d.ts +0 -1
- package/dist/lib/command/refactor.renameComponent.d.ts +0 -1
- package/dist/lib/command/tools.deps.d.ts +0 -1
- package/dist/lib/command/tools.metadata.d.ts +0 -1
- package/dist/lib/commands.d.ts +139 -232
- package/dist/lib/common/cliCreateComponent.d.ts +4 -3
- package/dist/lib/common/cliCreatePage.d.ts +3 -3
- package/dist/lib/common/utils.d.ts +6 -0
- package/dist/lib/this.d.ts +0 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/typings.d.ts +0 -1
- package/dist-cli/templates/create/module/snippets/package.json.js +10 -0
- package/dist-cli/templates/create/page/snippets/routes.js +24 -0
- package/dist-cli/templates/openapi/config/snippets/openapi.config.js +17 -0
- package/dist-cli/templates/refactor/anotherRender/snippets/render.js +17 -0
- package/dist-cli/templates/refactor/anotherStyle/snippets/style.js +17 -0
- package/dist-cli/templates/refactor/componentEmits/snippets/2-controller.js +20 -0
- package/dist-cli/templates/refactor/componentGeneric/snippets/2-controller.js +21 -0
- package/dist-cli/templates/refactor/componentModel/snippets/1-controller.js +50 -0
- package/dist-cli/templates/refactor/componentProps/snippets/2-controller.js +22 -0
- package/dist-cli/templates/refactor/componentSlots/snippets/1-controller.js +20 -0
- package/dist-cli/templates/refactor/pageParams/snippets/1-controller.js +20 -0
- package/dist-cli/templates/refactor/pageQuery/snippets/1-controller.js +20 -0
- package/package.json +51 -35
- package/cli/templates/create/bean/boilerplate/{{sceneName}}.{{nameMeta.full}}.ts_ +0 -6
- package/cli/templates/create/component/boilerplate/controller.ts_ +0 -7
- package/cli/templates/create/component/boilerplate/index.vue_ +0 -12
- package/cli/templates/create/component/boilerplate/render.tsx_ +0 -12
- package/cli/templates/create/component/boilerplate/style.ts_ +0 -10
- package/cli/templates/create/component/snippets/components.cjs +0 -36
- package/cli/templates/create/local/boilerplate/{{nameMeta.short}}.ts_ +0 -6
- package/cli/templates/create/module/snippets/package.json.cjs +0 -11
- package/cli/templates/create/page/boilerplate/controller.ts_ +0 -7
- package/cli/templates/create/page/boilerplate/index.vue_ +0 -11
- package/cli/templates/create/page/boilerplate/render.tsx_ +0 -12
- package/cli/templates/create/page/boilerplate/style.ts_ +0 -10
- package/cli/templates/create/page/snippets/-index.cjs +0 -13
- package/cli/templates/create/page/snippets/-pages.cjs +0 -48
- package/cli/templates/create/service/boilerplate/{{serviceName}}.ts_ +0 -11
- package/cli/templates/refactor/anotherRender/boilerplate/{{renderName}}.tsx_ +0 -10
- package/cli/templates/refactor/anotherRender/snippets/render.cjs +0 -21
- package/cli/templates/refactor/anotherStyle/boilerplate/{{styleName}}.ts_ +0 -10
- package/cli/templates/refactor/anotherStyle/snippets/style.cjs +0 -21
- package/cli/templates/refactor/componentEmits/snippets/1-index.cjs +0 -19
- package/cli/templates/refactor/componentEmits/snippets/2-controller.cjs +0 -23
- package/cli/templates/refactor/componentGeneric/snippets/1-index.cjs +0 -14
- package/cli/templates/refactor/componentGeneric/snippets/2-controller.cjs +0 -26
- package/cli/templates/refactor/componentModel/snippets/1-controller.cjs +0 -31
- package/cli/templates/refactor/componentProps/snippets/1-index.cjs +0 -24
- package/cli/templates/refactor/componentProps/snippets/2-controller.cjs +0 -38
- package/cli/templates/refactor/componentSlots/snippets/1-controller.cjs +0 -35
- package/cli/templates/refactor/pageParams/snippets/1-controller.cjs +0 -29
- package/cli/templates/refactor/pageQuery/snippets/1-controller.cjs +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/bean/cli.bean.general.d.ts +0 -6
- package/dist/lib/bean/cli.bean.general.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.general.js +0 -7
- package/dist/lib/bean/cli.bean.general.js.map +0 -1
- package/dist/lib/bean/cli.bean.local.d.ts +0 -14
- package/dist/lib/bean/cli.bean.local.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.local.js +0 -49
- package/dist/lib/bean/cli.bean.local.js.map +0 -1
- package/dist/lib/bean/cli.bean.model.d.ts +0 -6
- package/dist/lib/bean/cli.bean.model.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.model.js +0 -7
- package/dist/lib/bean/cli.bean.model.js.map +0 -1
- package/dist/lib/bean/cli.bean.store.d.ts +0 -6
- package/dist/lib/bean/cli.bean.store.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.store.js +0 -7
- package/dist/lib/bean/cli.bean.store.js.map +0 -1
- package/dist/lib/bean/cli.bean.style.d.ts +0 -6
- package/dist/lib/bean/cli.bean.style.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.style.js +0 -7
- package/dist/lib/bean/cli.bean.style.js.map +0 -1
- package/dist/lib/bean/cli.bean.theme.d.ts +0 -6
- package/dist/lib/bean/cli.bean.theme.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.theme.js +0 -7
- package/dist/lib/bean/cli.bean.theme.js.map +0 -1
- package/dist/lib/bean/cli.bean.tool.d.ts +0 -6
- package/dist/lib/bean/cli.bean.tool.d.ts.map +0 -1
- package/dist/lib/bean/cli.bean.tool.js +0 -7
- package/dist/lib/bean/cli.bean.tool.js.map +0 -1
- package/dist/lib/bean/cli.create.bean.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.bean.js +0 -7
- package/dist/lib/bean/cli.create.bean.js.map +0 -1
- package/dist/lib/bean/cli.create.component.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.component.js +0 -7
- package/dist/lib/bean/cli.create.component.js.map +0 -1
- package/dist/lib/bean/cli.create.data.d.ts +0 -6
- package/dist/lib/bean/cli.create.data.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.data.js +0 -7
- package/dist/lib/bean/cli.create.data.js.map +0 -1
- package/dist/lib/bean/cli.create.local.d.ts +0 -14
- package/dist/lib/bean/cli.create.local.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.local.js +0 -49
- package/dist/lib/bean/cli.create.local.js.map +0 -1
- package/dist/lib/bean/cli.create.mock.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.mock.js +0 -40
- package/dist/lib/bean/cli.create.mock.js.map +0 -1
- package/dist/lib/bean/cli.create.model.d.ts +0 -6
- package/dist/lib/bean/cli.create.model.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.model.js +0 -7
- package/dist/lib/bean/cli.create.model.js.map +0 -1
- package/dist/lib/bean/cli.create.module.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.module.js +0 -70
- package/dist/lib/bean/cli.create.module.js.map +0 -1
- package/dist/lib/bean/cli.create.page.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.page.js +0 -7
- package/dist/lib/bean/cli.create.page.js.map +0 -1
- package/dist/lib/bean/cli.create.project.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.project.js +0 -102
- package/dist/lib/bean/cli.create.project.js.map +0 -1
- package/dist/lib/bean/cli.create.service.d.ts +0 -14
- package/dist/lib/bean/cli.create.service.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.service.js +0 -42
- package/dist/lib/bean/cli.create.service.js.map +0 -1
- package/dist/lib/bean/cli.create.store.d.ts +0 -6
- package/dist/lib/bean/cli.create.store.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.store.js +0 -7
- package/dist/lib/bean/cli.create.store.js.map +0 -1
- package/dist/lib/bean/cli.create.style.d.ts +0 -6
- package/dist/lib/bean/cli.create.style.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.style.js +0 -7
- package/dist/lib/bean/cli.create.style.js.map +0 -1
- package/dist/lib/bean/cli.create.suite.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.suite.js +0 -37
- package/dist/lib/bean/cli.create.suite.js.map +0 -1
- package/dist/lib/bean/cli.create.theme.d.ts +0 -6
- package/dist/lib/bean/cli.create.theme.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.theme.js +0 -7
- package/dist/lib/bean/cli.create.theme.js.map +0 -1
- package/dist/lib/bean/cli.create.tool.d.ts +0 -6
- package/dist/lib/bean/cli.create.tool.d.ts.map +0 -1
- package/dist/lib/bean/cli.create.tool.js +0 -7
- package/dist/lib/bean/cli.create.tool.js.map +0 -1
- package/dist/lib/bean/cli.default.list.d.ts.map +0 -1
- package/dist/lib/bean/cli.default.list.js +0 -94
- package/dist/lib/bean/cli.default.list.js.map +0 -1
- package/dist/lib/bean/cli.init.config.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.config.js +0 -37
- package/dist/lib/bean/cli.init.config.js.map +0 -1
- package/dist/lib/bean/cli.init.constant.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.constant.js +0 -37
- package/dist/lib/bean/cli.init.constant.js.map +0 -1
- package/dist/lib/bean/cli.init.error.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.error.js +0 -48
- package/dist/lib/bean/cli.init.error.js.map +0 -1
- package/dist/lib/bean/cli.init.icon.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.icon.js +0 -51
- package/dist/lib/bean/cli.init.icon.js.map +0 -1
- package/dist/lib/bean/cli.init.icons.d.ts +0 -10
- package/dist/lib/bean/cli.init.icons.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.icons.js +0 -52
- package/dist/lib/bean/cli.init.icons.js.map +0 -1
- package/dist/lib/bean/cli.init.legacy.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.legacy.js +0 -24
- package/dist/lib/bean/cli.init.legacy.js.map +0 -1
- package/dist/lib/bean/cli.init.locale.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.locale.js +0 -37
- package/dist/lib/bean/cli.init.locale.js.map +0 -1
- package/dist/lib/bean/cli.init.mock.d.ts +0 -9
- package/dist/lib/bean/cli.init.mock.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.mock.js +0 -35
- package/dist/lib/bean/cli.init.mock.js.map +0 -1
- package/dist/lib/bean/cli.init.monkey.d.ts.map +0 -1
- package/dist/lib/bean/cli.init.monkey.js +0 -64
- package/dist/lib/bean/cli.init.monkey.js.map +0 -1
- package/dist/lib/bean/cli.refactor.anotherRender.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.anotherRender.js +0 -45
- package/dist/lib/bean/cli.refactor.anotherRender.js.map +0 -1
- package/dist/lib/bean/cli.refactor.anotherStyle.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.anotherStyle.js +0 -46
- package/dist/lib/bean/cli.refactor.anotherStyle.js.map +0 -1
- package/dist/lib/bean/cli.refactor.componentEmits.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.componentEmits.js +0 -40
- package/dist/lib/bean/cli.refactor.componentEmits.js.map +0 -1
- package/dist/lib/bean/cli.refactor.componentGeneric.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.componentGeneric.js +0 -40
- package/dist/lib/bean/cli.refactor.componentGeneric.js.map +0 -1
- package/dist/lib/bean/cli.refactor.componentModel.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.componentModel.js +0 -49
- package/dist/lib/bean/cli.refactor.componentModel.js.map +0 -1
- package/dist/lib/bean/cli.refactor.componentProps.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.componentProps.js +0 -40
- package/dist/lib/bean/cli.refactor.componentProps.js.map +0 -1
- package/dist/lib/bean/cli.refactor.componentSlots.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.componentSlots.js +0 -40
- package/dist/lib/bean/cli.refactor.componentSlots.js.map +0 -1
- package/dist/lib/bean/cli.refactor.pageParams.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.pageParams.js +0 -40
- package/dist/lib/bean/cli.refactor.pageParams.js.map +0 -1
- package/dist/lib/bean/cli.refactor.pageQuery.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.pageQuery.js +0 -40
- package/dist/lib/bean/cli.refactor.pageQuery.js.map +0 -1
- package/dist/lib/bean/cli.refactor.renameComponent.d.ts.map +0 -1
- package/dist/lib/bean/cli.refactor.renameComponent.js +0 -103
- package/dist/lib/bean/cli.refactor.renameComponent.js.map +0 -1
- package/dist/lib/bean/cli.tools.deps.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.deps.js +0 -100
- package/dist/lib/bean/cli.tools.deps.js.map +0 -1
- package/dist/lib/bean/cli.tools.icon.d.ts +0 -19
- package/dist/lib/bean/cli.tools.icon.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.icon.js +0 -151
- package/dist/lib/bean/cli.tools.icon.js.map +0 -1
- package/dist/lib/bean/cli.tools.icons.d.ts +0 -19
- package/dist/lib/bean/cli.tools.icons.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.icons.js +0 -151
- package/dist/lib/bean/cli.tools.icons.js.map +0 -1
- package/dist/lib/bean/cli.tools.metadata.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.metadata.js +0 -127
- package/dist/lib/bean/cli.tools.metadata.js.map +0 -1
- package/dist/lib/bean/cli.tools.res.d.ts +0 -12
- package/dist/lib/bean/cli.tools.res.d.ts.map +0 -1
- package/dist/lib/bean/cli.tools.res.js +0 -112
- package/dist/lib/bean/cli.tools.res.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeans.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateBeans.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeans.js +0 -38
- package/dist/lib/bean/toolsMetadata/generateBeans.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateComponents.d.ts +0 -2
- package/dist/lib/bean/toolsMetadata/generateComponents.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateComponents.js +0 -48
- package/dist/lib/bean/toolsMetadata/generateComponents.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateConfig.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateConfig.js +0 -64
- package/dist/lib/bean/toolsMetadata/generateConfig.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateIcons.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateIcons.js +0 -113
- package/dist/lib/bean/toolsMetadata/generateIcons.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateMonkey.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateMonkey.js +0 -14
- package/dist/lib/bean/toolsMetadata/generateMonkey.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generatePages.d.ts +0 -3
- package/dist/lib/bean/toolsMetadata/generatePages.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generatePages.js +0 -114
- package/dist/lib/bean/toolsMetadata/generatePages.js.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateScope.d.ts.map +0 -1
- package/dist/lib/bean/toolsMetadata/generateScope.js +0 -40
- 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 -27
- package/dist/lib/bean/toolsMetadata/generateServices.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateBeans.d.ts +0 -2
- package/dist/lib/bean/toolsRes/generateBeans.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateBeans.js +0 -37
- package/dist/lib/bean/toolsRes/generateBeans.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateComponents.d.ts +0 -2
- package/dist/lib/bean/toolsRes/generateComponents.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateComponents.js +0 -42
- package/dist/lib/bean/toolsRes/generateComponents.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateConfig.d.ts +0 -5
- package/dist/lib/bean/toolsRes/generateConfig.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateConfig.js +0 -63
- package/dist/lib/bean/toolsRes/generateConfig.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateIcons.d.ts +0 -2
- package/dist/lib/bean/toolsRes/generateIcons.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateIcons.js +0 -111
- package/dist/lib/bean/toolsRes/generateIcons.js.map +0 -1
- package/dist/lib/bean/toolsRes/generatePages.d.ts +0 -3
- package/dist/lib/bean/toolsRes/generatePages.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generatePages.js +0 -96
- package/dist/lib/bean/toolsRes/generatePages.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateScope.d.ts +0 -10
- package/dist/lib/bean/toolsRes/generateScope.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateScope.js +0 -41
- package/dist/lib/bean/toolsRes/generateScope.js.map +0 -1
- package/dist/lib/bean/toolsRes/generateServices.d.ts +0 -2
- package/dist/lib/bean/toolsRes/generateServices.d.ts.map +0 -1
- package/dist/lib/bean/toolsRes/generateServices.js +0 -26
- package/dist/lib/bean/toolsRes/generateServices.js.map +0 -1
- package/dist/lib/beans.d.ts.map +0 -1
- package/dist/lib/beans.js +0 -73
- package/dist/lib/beans.js.map +0 -1
- package/dist/lib/command/bean.general.d.ts +0 -35
- package/dist/lib/command/bean.general.d.ts.map +0 -1
- package/dist/lib/command/bean.general.js +0 -34
- package/dist/lib/command/bean.general.js.map +0 -1
- package/dist/lib/command/bean.local.d.ts.map +0 -1
- package/dist/lib/command/bean.local.js +0 -34
- package/dist/lib/command/bean.local.js.map +0 -1
- package/dist/lib/command/bean.model.d.ts.map +0 -1
- package/dist/lib/command/bean.model.js +0 -34
- package/dist/lib/command/bean.model.js.map +0 -1
- package/dist/lib/command/bean.store.d.ts +0 -35
- package/dist/lib/command/bean.store.d.ts.map +0 -1
- package/dist/lib/command/bean.store.js +0 -34
- package/dist/lib/command/bean.store.js.map +0 -1
- package/dist/lib/command/bean.style.d.ts +0 -35
- package/dist/lib/command/bean.style.d.ts.map +0 -1
- package/dist/lib/command/bean.style.js +0 -34
- package/dist/lib/command/bean.style.js.map +0 -1
- package/dist/lib/command/bean.theme.d.ts +0 -35
- package/dist/lib/command/bean.theme.d.ts.map +0 -1
- package/dist/lib/command/bean.theme.js +0 -34
- package/dist/lib/command/bean.theme.js.map +0 -1
- package/dist/lib/command/bean.tool.d.ts.map +0 -1
- package/dist/lib/command/bean.tool.js +0 -34
- package/dist/lib/command/bean.tool.js.map +0 -1
- package/dist/lib/command/create.bean.d.ts.map +0 -1
- package/dist/lib/command/create.bean.js +0 -34
- package/dist/lib/command/create.bean.js.map +0 -1
- package/dist/lib/command/create.component.d.ts.map +0 -1
- package/dist/lib/command/create.component.js +0 -34
- package/dist/lib/command/create.component.js.map +0 -1
- package/dist/lib/command/create.data.d.ts +0 -35
- package/dist/lib/command/create.data.d.ts.map +0 -1
- package/dist/lib/command/create.data.js +0 -34
- package/dist/lib/command/create.data.js.map +0 -1
- package/dist/lib/command/create.local.d.ts +0 -35
- package/dist/lib/command/create.local.d.ts.map +0 -1
- package/dist/lib/command/create.local.js +0 -34
- package/dist/lib/command/create.local.js.map +0 -1
- package/dist/lib/command/create.mock.d.ts.map +0 -1
- package/dist/lib/command/create.mock.js +0 -34
- package/dist/lib/command/create.mock.js.map +0 -1
- package/dist/lib/command/create.model.d.ts +0 -35
- package/dist/lib/command/create.model.d.ts.map +0 -1
- package/dist/lib/command/create.model.js +0 -34
- package/dist/lib/command/create.model.js.map +0 -1
- package/dist/lib/command/create.module.d.ts.map +0 -1
- package/dist/lib/command/create.module.js +0 -45
- package/dist/lib/command/create.module.js.map +0 -1
- package/dist/lib/command/create.page.d.ts.map +0 -1
- package/dist/lib/command/create.page.js +0 -34
- package/dist/lib/command/create.page.js.map +0 -1
- package/dist/lib/command/create.project.d.ts.map +0 -1
- package/dist/lib/command/create.project.js +0 -48
- package/dist/lib/command/create.project.js.map +0 -1
- package/dist/lib/command/create.service.d.ts +0 -35
- package/dist/lib/command/create.service.d.ts.map +0 -1
- package/dist/lib/command/create.service.js +0 -34
- package/dist/lib/command/create.service.js.map +0 -1
- package/dist/lib/command/create.store.d.ts +0 -35
- package/dist/lib/command/create.store.d.ts.map +0 -1
- package/dist/lib/command/create.store.js +0 -34
- package/dist/lib/command/create.store.js.map +0 -1
- package/dist/lib/command/create.style.d.ts +0 -35
- package/dist/lib/command/create.style.d.ts.map +0 -1
- package/dist/lib/command/create.style.js +0 -34
- package/dist/lib/command/create.style.js.map +0 -1
- package/dist/lib/command/create.suite.d.ts.map +0 -1
- package/dist/lib/command/create.suite.js +0 -32
- package/dist/lib/command/create.suite.js.map +0 -1
- package/dist/lib/command/create.theme.d.ts +0 -35
- package/dist/lib/command/create.theme.d.ts.map +0 -1
- package/dist/lib/command/create.theme.js +0 -34
- package/dist/lib/command/create.theme.js.map +0 -1
- package/dist/lib/command/create.tool.d.ts +0 -35
- package/dist/lib/command/create.tool.d.ts.map +0 -1
- package/dist/lib/command/create.tool.js +0 -34
- package/dist/lib/command/create.tool.js.map +0 -1
- package/dist/lib/command/default.list.d.ts.map +0 -1
- package/dist/lib/command/default.list.js +0 -19
- package/dist/lib/command/default.list.js.map +0 -1
- package/dist/lib/command/init.config.d.ts.map +0 -1
- package/dist/lib/command/init.config.js +0 -11
- package/dist/lib/command/init.config.js.map +0 -1
- package/dist/lib/command/init.constant.d.ts.map +0 -1
- package/dist/lib/command/init.constant.js +0 -11
- package/dist/lib/command/init.constant.js.map +0 -1
- package/dist/lib/command/init.error.d.ts.map +0 -1
- package/dist/lib/command/init.error.js +0 -11
- package/dist/lib/command/init.error.js.map +0 -1
- package/dist/lib/command/init.icon.d.ts.map +0 -1
- package/dist/lib/command/init.icon.js +0 -11
- package/dist/lib/command/init.icon.js.map +0 -1
- package/dist/lib/command/init.icons.d.ts.map +0 -1
- package/dist/lib/command/init.icons.js +0 -11
- package/dist/lib/command/init.icons.js.map +0 -1
- package/dist/lib/command/init.legacy.d.ts.map +0 -1
- package/dist/lib/command/init.legacy.js +0 -11
- package/dist/lib/command/init.legacy.js.map +0 -1
- package/dist/lib/command/init.locale.d.ts.map +0 -1
- package/dist/lib/command/init.locale.js +0 -11
- package/dist/lib/command/init.locale.js.map +0 -1
- package/dist/lib/command/init.mock.d.ts.map +0 -1
- package/dist/lib/command/init.mock.js +0 -11
- package/dist/lib/command/init.mock.js.map +0 -1
- package/dist/lib/command/init.monkey.d.ts.map +0 -1
- package/dist/lib/command/init.monkey.js +0 -11
- package/dist/lib/command/init.monkey.js.map +0 -1
- package/dist/lib/command/refactor.anotherRender.d.ts.map +0 -1
- package/dist/lib/command/refactor.anotherRender.js +0 -42
- package/dist/lib/command/refactor.anotherRender.js.map +0 -1
- package/dist/lib/command/refactor.anotherStyle.d.ts.map +0 -1
- package/dist/lib/command/refactor.anotherStyle.js +0 -42
- package/dist/lib/command/refactor.anotherStyle.js.map +0 -1
- package/dist/lib/command/refactor.componentEmits.d.ts.map +0 -1
- package/dist/lib/command/refactor.componentEmits.js +0 -34
- package/dist/lib/command/refactor.componentEmits.js.map +0 -1
- package/dist/lib/command/refactor.componentGeneric.d.ts.map +0 -1
- package/dist/lib/command/refactor.componentGeneric.js +0 -34
- package/dist/lib/command/refactor.componentGeneric.js.map +0 -1
- package/dist/lib/command/refactor.componentModel.d.ts.map +0 -1
- package/dist/lib/command/refactor.componentModel.js +0 -42
- package/dist/lib/command/refactor.componentModel.js.map +0 -1
- package/dist/lib/command/refactor.componentProps.d.ts.map +0 -1
- package/dist/lib/command/refactor.componentProps.js +0 -34
- package/dist/lib/command/refactor.componentProps.js.map +0 -1
- package/dist/lib/command/refactor.componentSlots.d.ts.map +0 -1
- package/dist/lib/command/refactor.componentSlots.js +0 -34
- package/dist/lib/command/refactor.componentSlots.js.map +0 -1
- package/dist/lib/command/refactor.pageParams.d.ts.map +0 -1
- package/dist/lib/command/refactor.pageParams.js +0 -34
- package/dist/lib/command/refactor.pageParams.js.map +0 -1
- package/dist/lib/command/refactor.pageQuery.d.ts.map +0 -1
- package/dist/lib/command/refactor.pageQuery.js +0 -34
- package/dist/lib/command/refactor.pageQuery.js.map +0 -1
- package/dist/lib/command/refactor.renameComponent.d.ts.map +0 -1
- package/dist/lib/command/refactor.renameComponent.js +0 -42
- package/dist/lib/command/refactor.renameComponent.js.map +0 -1
- package/dist/lib/command/tools.deps.d.ts.map +0 -1
- package/dist/lib/command/tools.deps.js +0 -15
- package/dist/lib/command/tools.deps.js.map +0 -1
- package/dist/lib/command/tools.icon.d.ts.map +0 -1
- package/dist/lib/command/tools.icon.js +0 -11
- package/dist/lib/command/tools.icon.js.map +0 -1
- package/dist/lib/command/tools.icons.d.ts.map +0 -1
- package/dist/lib/command/tools.icons.js +0 -11
- package/dist/lib/command/tools.icons.js.map +0 -1
- package/dist/lib/command/tools.metadata.d.ts.map +0 -1
- package/dist/lib/command/tools.metadata.js +0 -15
- package/dist/lib/command/tools.metadata.js.map +0 -1
- package/dist/lib/command/tools.res.d.ts.map +0 -1
- package/dist/lib/command/tools.res.js +0 -11
- package/dist/lib/command/tools.res.js.map +0 -1
- package/dist/lib/commands.d.ts.map +0 -1
- package/dist/lib/commands.js +0 -85
- package/dist/lib/commands.js.map +0 -1
- package/dist/lib/common/cliCreateBean.d.ts +0 -23
- package/dist/lib/common/cliCreateBean.d.ts.map +0 -1
- package/dist/lib/common/cliCreateBean.js +0 -62
- package/dist/lib/common/cliCreateBean.js.map +0 -1
- package/dist/lib/common/cliCreateComponent.d.ts.map +0 -1
- package/dist/lib/common/cliCreateComponent.js +0 -59
- package/dist/lib/common/cliCreateComponent.js.map +0 -1
- package/dist/lib/common/cliCreatePage.d.ts.map +0 -1
- package/dist/lib/common/cliCreatePage.js +0 -90
- package/dist/lib/common/cliCreatePage.js.map +0 -1
- package/dist/lib/this.d.ts.map +0 -1
- package/dist/lib/this.js +0 -2
- package/dist/lib/this.js.map +0 -1
- package/dist/typings.d.ts.map +0 -1
- package/dist/typings.js +0 -2
- package/dist/typings.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4707 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BeanCliBase, getCommandsMeta } from '@cabloy/cli';
|
|
2
|
+
import babelPlugin from '@cabloy/vite-plugin-babel';
|
|
3
|
+
import vueJsxPlugin from '@vitejs/plugin-vue-jsx';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { rimraf } from 'rimraf';
|
|
6
|
+
import { rolldown } from 'rolldown';
|
|
7
|
+
import { dts } from 'rolldown-plugin-dts';
|
|
8
|
+
import { build } from 'vite';
|
|
9
|
+
import { createRequire } from 'node:module';
|
|
10
|
+
import { camelToKebab, replaceTemplate, toUpperCaseFirstChar, toLowerCaseFirstChar, skipPrefix, stringToCapitalize } from '@cabloy/word-utils';
|
|
11
|
+
import fse from 'fs-extra';
|
|
12
|
+
import { build as build$1 } from 'tsdown';
|
|
13
|
+
import { createConfigUtils } from 'zova-vite';
|
|
14
|
+
import { getOnionScenesMeta, getOnionMetasMeta } from '@cabloy/module-info';
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import compressing from 'compressing';
|
|
17
|
+
import os from 'node:os';
|
|
18
|
+
import urllib from 'urllib';
|
|
19
|
+
import { extend } from '@cabloy/extend';
|
|
20
|
+
import { catchError, matchSelector, getPropertyObject, evaluateSimple, StringPrefixRegexp } from '@cabloy/utils';
|
|
21
|
+
import ts from 'typescript';
|
|
22
|
+
import 'node:url';
|
|
23
|
+
import { globbySync, globby } from 'globby';
|
|
24
|
+
import gogocode from 'gogocode';
|
|
25
|
+
import { optimize } from 'svgo';
|
|
26
|
+
|
|
27
|
+
function getAbsolutePathOfModule(id, postfix = 'index.js') {
|
|
28
|
+
const require = createRequire(import.meta.url);
|
|
29
|
+
let modulePath = require.resolve(id);
|
|
30
|
+
if (postfix) {
|
|
31
|
+
const pos = modulePath.lastIndexOf(postfix);
|
|
32
|
+
if (pos > -1) {
|
|
33
|
+
modulePath = modulePath.substring(0, modulePath.length - postfix.length - 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return modulePath;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class CliBinBuildModule extends BeanCliBase {
|
|
40
|
+
async execute() {
|
|
41
|
+
const {
|
|
42
|
+
argv
|
|
43
|
+
} = this.context;
|
|
44
|
+
// super
|
|
45
|
+
await super.execute();
|
|
46
|
+
const projectPath = argv.projectPath;
|
|
47
|
+
await this._vite(projectPath);
|
|
48
|
+
}
|
|
49
|
+
async _vite(projectPath) {
|
|
50
|
+
const {
|
|
51
|
+
argv
|
|
52
|
+
} = this.context;
|
|
53
|
+
await rimraf(path.join(projectPath, 'dist'));
|
|
54
|
+
await this._buildSrc(projectPath);
|
|
55
|
+
if (argv.dts) {
|
|
56
|
+
await this._buildDts(projectPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async _buildDts(projectPath) {
|
|
60
|
+
const {
|
|
61
|
+
argv
|
|
62
|
+
} = this.context;
|
|
63
|
+
const sourceMap = argv.sourcemap;
|
|
64
|
+
const inputOptions = {
|
|
65
|
+
input: 'src/index.ts',
|
|
66
|
+
plugins: [dts({
|
|
67
|
+
tsconfig: 'tsconfig.build.json',
|
|
68
|
+
emitDtsOnly: true
|
|
69
|
+
})],
|
|
70
|
+
external: id => {
|
|
71
|
+
return !id.startsWith('.') && !path.isAbsolute(id);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const outputOption = {
|
|
75
|
+
dir: path.join(projectPath, 'dist'),
|
|
76
|
+
format: 'esm',
|
|
77
|
+
sourcemap: sourceMap
|
|
78
|
+
};
|
|
79
|
+
let bundle;
|
|
80
|
+
try {
|
|
81
|
+
bundle = await rolldown(inputOptions);
|
|
82
|
+
await bundle.write(outputOption);
|
|
83
|
+
} finally {
|
|
84
|
+
if (bundle) {
|
|
85
|
+
// closes the bundle
|
|
86
|
+
await bundle.close();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async _buildSrc(_projectPath) {
|
|
91
|
+
const {
|
|
92
|
+
argv
|
|
93
|
+
} = this.context;
|
|
94
|
+
const sourceMap = argv.sourcemap;
|
|
95
|
+
const minify = argv.minify;
|
|
96
|
+
const babelPluginZovaComponent = getAbsolutePathOfModule('babel-plugin-zova-component', '');
|
|
97
|
+
const babelPluginZovaBehavior = getAbsolutePathOfModule('babel-plugin-zova-behavior', '');
|
|
98
|
+
const babelPluginZovaBeanModule = getAbsolutePathOfModule('babel-plugin-zova-bean-module', '');
|
|
99
|
+
const babelPluginZovaBeanUse = getAbsolutePathOfModule('babel-plugin-zova-bean-use', '');
|
|
100
|
+
const babelPluginTransformTypescriptMetadata = getAbsolutePathOfModule('babel-plugin-transform-typescript-metadata', '');
|
|
101
|
+
const babelPluginProposalDecorators = getAbsolutePathOfModule('@babel/plugin-proposal-decorators', '');
|
|
102
|
+
const babelPluginTransformClassProperties = getAbsolutePathOfModule('@babel/plugin-transform-class-properties', '');
|
|
103
|
+
const babelPluginTransformTypescript = getAbsolutePathOfModule('@babel/plugin-transform-typescript', '');
|
|
104
|
+
const plugins = [babelPlugin({
|
|
105
|
+
filter: /\.ts$/,
|
|
106
|
+
babelConfig: {
|
|
107
|
+
babelrc: false,
|
|
108
|
+
configFile: false,
|
|
109
|
+
plugins: [[babelPluginZovaBeanModule, {
|
|
110
|
+
brandName: 'zova'
|
|
111
|
+
}], [babelPluginZovaBeanUse], [babelPluginTransformTypescriptMetadata], [babelPluginProposalDecorators, {
|
|
112
|
+
version: 'legacy'
|
|
113
|
+
}], [babelPluginTransformClassProperties, {
|
|
114
|
+
loose: true
|
|
115
|
+
}], [babelPluginTransformTypescript]]
|
|
116
|
+
}
|
|
117
|
+
}), vueJsxPlugin({
|
|
118
|
+
include: /\.[jt]sx$/,
|
|
119
|
+
babelPlugins: [[babelPluginZovaComponent], [babelPluginZovaBehavior], [babelPluginZovaBeanModule, {
|
|
120
|
+
brandName: 'zova'
|
|
121
|
+
}], [babelPluginZovaBeanUse], [babelPluginTransformTypescriptMetadata], [babelPluginProposalDecorators, {
|
|
122
|
+
version: 'legacy'
|
|
123
|
+
}], [babelPluginTransformClassProperties, {
|
|
124
|
+
loose: true
|
|
125
|
+
}]]
|
|
126
|
+
})];
|
|
127
|
+
const viteConfig = {
|
|
128
|
+
plugins,
|
|
129
|
+
build: {
|
|
130
|
+
lib: {
|
|
131
|
+
entry: 'src/index.ts',
|
|
132
|
+
formats: ['es'],
|
|
133
|
+
fileName: 'index'
|
|
134
|
+
},
|
|
135
|
+
rolldownOptions: {
|
|
136
|
+
external: id => {
|
|
137
|
+
if (id.includes('/assets/')) return true;
|
|
138
|
+
return !id.startsWith('.') && !path.isAbsolute(id);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
sourcemap: sourceMap,
|
|
142
|
+
// keep_classnames not take effect for 'oxc'
|
|
143
|
+
minify: minify ? 'terser' : false,
|
|
144
|
+
terserOptions: {
|
|
145
|
+
keep_classnames: true
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
await build(viteConfig);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const __template_package = `{
|
|
154
|
+
"name": "{{Name}}",
|
|
155
|
+
"version": "{{Version}}",
|
|
156
|
+
"type": "module",
|
|
157
|
+
"exports": {
|
|
158
|
+
".": {
|
|
159
|
+
"types": [
|
|
160
|
+
"./index.d.mts"
|
|
161
|
+
],
|
|
162
|
+
"import": "./index.mjs"
|
|
163
|
+
},
|
|
164
|
+
"./package.json": "./package.json"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
class CliBinBuildRest extends BeanCliBase {
|
|
169
|
+
async execute() {
|
|
170
|
+
const {
|
|
171
|
+
argv
|
|
172
|
+
} = this.context;
|
|
173
|
+
// super
|
|
174
|
+
await super.execute();
|
|
175
|
+
const projectPath = argv.projectPath;
|
|
176
|
+
//
|
|
177
|
+
const flavor = argv.flavor || 'admin';
|
|
178
|
+
const bundleName = `zova-rest-${camelToKebab(flavor)}`;
|
|
179
|
+
const bundleNameCopy = `${camelToKebab(flavor)}`;
|
|
180
|
+
//
|
|
181
|
+
const srcDir = path.join(projectPath, '.zova-rest');
|
|
182
|
+
const outDir = path.join(projectPath, 'dist', `rest-${flavor}`);
|
|
183
|
+
await rimraf(srcDir);
|
|
184
|
+
await fse.ensureDir(srcDir);
|
|
185
|
+
await rimraf(outDir);
|
|
186
|
+
// context
|
|
187
|
+
const context = {
|
|
188
|
+
projectPath,
|
|
189
|
+
flavor,
|
|
190
|
+
bundleName,
|
|
191
|
+
bundleNameCopy,
|
|
192
|
+
srcDir,
|
|
193
|
+
outDir
|
|
194
|
+
};
|
|
195
|
+
//
|
|
196
|
+
await this._prepareResources(context);
|
|
197
|
+
await this._build(context);
|
|
198
|
+
//
|
|
199
|
+
await rimraf(srcDir);
|
|
200
|
+
}
|
|
201
|
+
async _prepareResources(context) {
|
|
202
|
+
// package.json
|
|
203
|
+
await this._prepareResourcesPackage(context);
|
|
204
|
+
// index.ts
|
|
205
|
+
await this._prepareResourcesIndex(context);
|
|
206
|
+
}
|
|
207
|
+
async _build({
|
|
208
|
+
projectPath,
|
|
209
|
+
flavor,
|
|
210
|
+
bundleNameCopy,
|
|
211
|
+
srcDir,
|
|
212
|
+
outDir
|
|
213
|
+
}) {
|
|
214
|
+
const entry = path.join(srcDir, 'index.ts');
|
|
215
|
+
// build
|
|
216
|
+
await build$1({
|
|
217
|
+
entry: [entry],
|
|
218
|
+
format: ['esm'],
|
|
219
|
+
outDir,
|
|
220
|
+
tsconfig: 'tsconfig.rest.json',
|
|
221
|
+
dts: {
|
|
222
|
+
resolve: true,
|
|
223
|
+
resolver: 'tsc',
|
|
224
|
+
tsgo: true,
|
|
225
|
+
eager: true,
|
|
226
|
+
tsconfig: 'tsconfig.rest.json'
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
// package.json
|
|
230
|
+
await fse.copyFile(path.join(srcDir, 'package.json'), path.join(outDir, 'package.json'));
|
|
231
|
+
// release
|
|
232
|
+
const outReleasesDir = path.join(projectPath, 'dist-releases', `rest-${flavor}-${process.env.APP_VERSION}`);
|
|
233
|
+
await fse.copy(outDir, outReleasesDir);
|
|
234
|
+
// copy
|
|
235
|
+
_copyToTarget(outDir, process.env.BUILD_REST_COPY_DIST, bundleNameCopy);
|
|
236
|
+
}
|
|
237
|
+
async _prepareResourcesPackage({
|
|
238
|
+
projectPath,
|
|
239
|
+
flavor,
|
|
240
|
+
bundleName,
|
|
241
|
+
srcDir
|
|
242
|
+
}) {
|
|
243
|
+
const mode = 'production';
|
|
244
|
+
const appMode = 'ssr';
|
|
245
|
+
const configMeta = {
|
|
246
|
+
flavor,
|
|
247
|
+
mode,
|
|
248
|
+
appMode
|
|
249
|
+
};
|
|
250
|
+
const configOptions = {
|
|
251
|
+
appDir: projectPath,
|
|
252
|
+
runtimeDir: '.zova'
|
|
253
|
+
};
|
|
254
|
+
const configUtils = createConfigUtils(configMeta, configOptions);
|
|
255
|
+
// env
|
|
256
|
+
const env = configUtils.loadEnvs();
|
|
257
|
+
// package.json
|
|
258
|
+
const pkgContent = replaceTemplate(__template_package, {
|
|
259
|
+
Name: bundleName,
|
|
260
|
+
Version: env.APP_VERSION
|
|
261
|
+
});
|
|
262
|
+
await fse.writeFile(path.join(srcDir, 'package.json'), pkgContent);
|
|
263
|
+
}
|
|
264
|
+
async _prepareResourcesIndex({
|
|
265
|
+
srcDir
|
|
266
|
+
}) {
|
|
267
|
+
let indexContent = '';
|
|
268
|
+
indexContent += await this._prepareResourcesIndex_rest(srcDir);
|
|
269
|
+
indexContent += await this._prepareResourcesIndex_icons(srcDir);
|
|
270
|
+
indexContent += await this._prepareResourcesIndex_pages(srcDir);
|
|
271
|
+
await fse.writeFile(path.join(srcDir, 'index.ts'), indexContent);
|
|
272
|
+
}
|
|
273
|
+
async _prepareResourcesIndex_rest(srcDir) {
|
|
274
|
+
let content = '';
|
|
275
|
+
for (const module of this.modulesMeta.modulesArray) {
|
|
276
|
+
const restIndexFile = path.join(module.root, 'rest/index.ts');
|
|
277
|
+
if (!fse.existsSync(restIndexFile)) continue;
|
|
278
|
+
const restIndexFileRelative = path.relative(srcDir, restIndexFile);
|
|
279
|
+
content += `export * from '${restIndexFileRelative}';\n`;
|
|
280
|
+
}
|
|
281
|
+
return content;
|
|
282
|
+
}
|
|
283
|
+
async _prepareResourcesIndex_icons(_srcDir) {
|
|
284
|
+
let content = '';
|
|
285
|
+
for (const module of this.modulesMeta.modulesArray) {
|
|
286
|
+
const restIconsFile = path.join(module.root, 'rest/icons.txt');
|
|
287
|
+
if (!fse.existsSync(restIconsFile)) continue;
|
|
288
|
+
const contentIcons = (await fse.readFile(restIconsFile)).toString();
|
|
289
|
+
content += `${contentIcons}\n`;
|
|
290
|
+
}
|
|
291
|
+
if (content) {
|
|
292
|
+
content = `export interface IIconRecord {
|
|
293
|
+
${content}
|
|
294
|
+
}
|
|
295
|
+
export function $iconName<K extends keyof IIconRecord>(name: K): any {
|
|
296
|
+
return name;
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
}
|
|
300
|
+
return content;
|
|
301
|
+
}
|
|
302
|
+
async _prepareResourcesIndex_pages(_srcDir) {
|
|
303
|
+
let contentImport = '';
|
|
304
|
+
let contentRecord = '';
|
|
305
|
+
for (const module of this.modulesMeta.modulesArray) {
|
|
306
|
+
const restPagesRecordFile = path.join(module.root, 'rest/pagesRecord.txt');
|
|
307
|
+
if (!fse.existsSync(restPagesRecordFile)) continue;
|
|
308
|
+
const restPagesImportFile = path.join(module.root, 'rest/pagesImport.txt');
|
|
309
|
+
const contentPagesImport = (await fse.readFile(restPagesImportFile)).toString();
|
|
310
|
+
const contentPagesRecord = (await fse.readFile(restPagesRecordFile)).toString();
|
|
311
|
+
contentImport += `${contentPagesImport}\n`;
|
|
312
|
+
contentRecord += `${contentPagesRecord}\n`;
|
|
313
|
+
}
|
|
314
|
+
let content = '';
|
|
315
|
+
if (contentRecord) {
|
|
316
|
+
content = `${contentImport}
|
|
317
|
+
export interface TypePagePathSchema<PARAMS = unknown, QUERY = unknown> {
|
|
318
|
+
params?: PARAMS;
|
|
319
|
+
query?: QUERY;
|
|
320
|
+
}
|
|
321
|
+
export interface IPagePathRecord {
|
|
322
|
+
${contentRecord}
|
|
323
|
+
'/': TypePagePathSchema<undefined,undefined>;
|
|
324
|
+
presetLogin: TypePagePathSchema<undefined,undefined>;
|
|
325
|
+
presetErrorExpired: TypePagePathSchema<undefined,undefined>;
|
|
326
|
+
presetResource: TypePagePathSchema<undefined,undefined>;
|
|
327
|
+
}
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
return content;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function _copyToTarget(outDir, target, bundleNameCopy) {
|
|
334
|
+
if (!target) return;
|
|
335
|
+
const dirs = target.split(',');
|
|
336
|
+
for (const dir of dirs) {
|
|
337
|
+
const outReleasesDirCopy = path.join(dir, bundleNameCopy);
|
|
338
|
+
fse.removeSync(outReleasesDirCopy);
|
|
339
|
+
fse.copySync(outDir, outReleasesDirCopy, {
|
|
340
|
+
preserveTimestamps: true
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const __ThisSetName__ = 'front';
|
|
346
|
+
|
|
347
|
+
let __snippetsPathPrefix;
|
|
348
|
+
class CliCreateBean extends BeanCliBase {
|
|
349
|
+
async execute() {
|
|
350
|
+
const {
|
|
351
|
+
argv
|
|
352
|
+
} = this.context;
|
|
353
|
+
// super
|
|
354
|
+
await super.execute();
|
|
355
|
+
// module name/info
|
|
356
|
+
const moduleName = argv.module;
|
|
357
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
358
|
+
// check if exists
|
|
359
|
+
const _module = this.helper.findModule(moduleName);
|
|
360
|
+
if (!_module) {
|
|
361
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
362
|
+
}
|
|
363
|
+
// target dir
|
|
364
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
365
|
+
// scene name
|
|
366
|
+
const sceneName = argv.sceneName;
|
|
367
|
+
argv.sceneNameCapitalize = this.helper.firstCharToUpperCase(sceneName);
|
|
368
|
+
// scene meta
|
|
369
|
+
// onionScenesMeta
|
|
370
|
+
const onionScenesMeta = getOnionScenesMeta(this.modulesMeta.modules);
|
|
371
|
+
const onionSceneMeta = onionScenesMeta[sceneName];
|
|
372
|
+
// bean name
|
|
373
|
+
let beanName = argv.beanName;
|
|
374
|
+
let beanDir;
|
|
375
|
+
if (beanName.includes('/')) {
|
|
376
|
+
// service in component/page
|
|
377
|
+
const pos = beanName.lastIndexOf('/');
|
|
378
|
+
const subDir = beanName.substring(0, pos);
|
|
379
|
+
beanDir = path.join(targetDir, `src/${subDir}`);
|
|
380
|
+
beanName = argv.beanName = beanName.substring(pos + 1);
|
|
381
|
+
argv.fileName = `${sceneName}.${beanName}`;
|
|
382
|
+
} else {
|
|
383
|
+
beanDir = path.join(targetDir, onionSceneMeta.sceneIsolate ? `src/${sceneName}` : 'src/bean');
|
|
384
|
+
argv.fileName = onionSceneMeta.sceneIsolate ? beanName : `${sceneName}.${beanName}`;
|
|
385
|
+
}
|
|
386
|
+
argv.beanNameCapitalize = this.helper.firstCharToUpperCase(beanName);
|
|
387
|
+
// moduleResourceName
|
|
388
|
+
argv.moduleResourceName = this.helper.combineModuleNameAndResource(argv.moduleInfo.relativeName, argv.beanName);
|
|
389
|
+
// file
|
|
390
|
+
const beanFile = path.join(beanDir, `${argv.fileName}.ts`);
|
|
391
|
+
if (fs.existsSync(beanFile)) {
|
|
392
|
+
throw new Error(`${sceneName} bean exists: ${beanName}`);
|
|
393
|
+
}
|
|
394
|
+
// dir
|
|
395
|
+
await this.helper.ensureDir(beanDir);
|
|
396
|
+
// boilerplate name
|
|
397
|
+
const snippets = this._getBoilerplatesOrSnippets('snippets');
|
|
398
|
+
const boilerplates = this._getBoilerplatesOrSnippets('boilerplate', argv.boilerplate);
|
|
399
|
+
const snippetsName = snippets[`${sceneName}:${argv.beanName}`] || snippets[sceneName];
|
|
400
|
+
const boilerplateName = boilerplates[`${sceneName}:${argv.beanName}`] || boilerplates[sceneName];
|
|
401
|
+
// render boilerplate
|
|
402
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
403
|
+
targetDir: beanDir,
|
|
404
|
+
setName: __ThisSetName__,
|
|
405
|
+
snippetsPath: snippetsName,
|
|
406
|
+
boilerplatePath: boilerplateName
|
|
407
|
+
});
|
|
408
|
+
if (!argv.nometadata) {
|
|
409
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
410
|
+
cwd: argv.projectPath
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
_getBoilerplatesOrSnippets(type, custom) {
|
|
415
|
+
const type2 = custom ? `${type}${toUpperCaseFirstChar(custom)}` : type;
|
|
416
|
+
const result = {};
|
|
417
|
+
// scenes
|
|
418
|
+
const onionScenesMeta = getOnionScenesMeta(this.modulesMeta.modules);
|
|
419
|
+
for (const sceneName in onionScenesMeta) {
|
|
420
|
+
const onionSceneMeta = onionScenesMeta[sceneName];
|
|
421
|
+
const scenePath = onionSceneMeta[type2];
|
|
422
|
+
if (scenePath) {
|
|
423
|
+
result[sceneName] = this._combineBoilerplatesOrSnippetsPath(type, onionSceneMeta.module.root, scenePath);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// metas
|
|
427
|
+
const onionMetasMeta = getOnionMetasMeta(this.modulesMeta.modules);
|
|
428
|
+
for (const sceneName in onionMetasMeta) {
|
|
429
|
+
const onionMetaMeta = onionMetasMeta[sceneName];
|
|
430
|
+
const scenePath = onionMetaMeta[type2];
|
|
431
|
+
if (scenePath) {
|
|
432
|
+
result[`meta:${sceneName}`] = this._combineBoilerplatesOrSnippetsPath(type, onionMetaMeta.module.root, scenePath);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
_combineBoilerplatesOrSnippetsPath(type, moduleRoot, scenePath) {
|
|
438
|
+
// boilerplate
|
|
439
|
+
if (type === 'boilerplate') {
|
|
440
|
+
return path.join(moduleRoot, 'cli', scenePath);
|
|
441
|
+
}
|
|
442
|
+
// snippets
|
|
443
|
+
if (__snippetsPathPrefix) {
|
|
444
|
+
return path.join(moduleRoot, __snippetsPathPrefix, scenePath);
|
|
445
|
+
}
|
|
446
|
+
let snippetsPath = path.join(moduleRoot, 'dist-cli', scenePath);
|
|
447
|
+
if (!fse.existsSync(snippetsPath)) {
|
|
448
|
+
snippetsPath = path.join(moduleRoot, 'cli', scenePath);
|
|
449
|
+
__snippetsPathPrefix = 'cli';
|
|
450
|
+
} else {
|
|
451
|
+
__snippetsPathPrefix = 'dist-cli';
|
|
452
|
+
}
|
|
453
|
+
return snippetsPath;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
class CliCreateComponentBase extends BeanCliBase {
|
|
458
|
+
constructor(options, componentMode) {
|
|
459
|
+
super(options);
|
|
460
|
+
this.componentMode = void 0;
|
|
461
|
+
this.componentMode = componentMode;
|
|
462
|
+
}
|
|
463
|
+
async execute() {
|
|
464
|
+
const {
|
|
465
|
+
argv
|
|
466
|
+
} = this.context;
|
|
467
|
+
// super
|
|
468
|
+
await super.execute();
|
|
469
|
+
// module name/info
|
|
470
|
+
const moduleName = argv.module;
|
|
471
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
472
|
+
// check if exists
|
|
473
|
+
const _module = this.helper.findModule(moduleName);
|
|
474
|
+
if (!_module) {
|
|
475
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
476
|
+
}
|
|
477
|
+
// target dir
|
|
478
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
479
|
+
// componentName
|
|
480
|
+
const componentName = argv.componentName;
|
|
481
|
+
// nameMeta
|
|
482
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName);
|
|
483
|
+
// directory
|
|
484
|
+
let componentDir = path.join(targetDir, 'src/component');
|
|
485
|
+
componentDir = path.join(componentDir, componentName);
|
|
486
|
+
if (fs.existsSync(componentDir)) {
|
|
487
|
+
throw new Error(`component exists: ${componentName}`);
|
|
488
|
+
}
|
|
489
|
+
await this.helper.ensureDir(componentDir);
|
|
490
|
+
// // render snippets
|
|
491
|
+
// await this.template.renderBoilerplateAndSnippets({
|
|
492
|
+
// targetDir,
|
|
493
|
+
// setName: __ThisSetName__,
|
|
494
|
+
// snippetsPath: `create/${this.componentMode}/snippets`,
|
|
495
|
+
// boilerplatePath: null,
|
|
496
|
+
// });
|
|
497
|
+
// boilerplate
|
|
498
|
+
let boilerplate = 'boilerplate';
|
|
499
|
+
if (argv.boilerplate) {
|
|
500
|
+
boilerplate = `${boilerplate}${toUpperCaseFirstChar(argv.boilerplate)}`;
|
|
501
|
+
}
|
|
502
|
+
// render boilerplate
|
|
503
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
504
|
+
targetDir: componentDir,
|
|
505
|
+
setName: __ThisSetName__,
|
|
506
|
+
snippetsPath: null,
|
|
507
|
+
boilerplatePath: `create/${this.componentMode}/${boilerplate}`
|
|
508
|
+
});
|
|
509
|
+
// tools.metadata
|
|
510
|
+
if (!argv.nometadata) {
|
|
511
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
512
|
+
cwd: argv.projectPath
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
class CliCreateComponent extends CliCreateComponentBase {
|
|
519
|
+
constructor(options) {
|
|
520
|
+
super(options, 'component');
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
class CliCreateMock extends BeanCliBase {
|
|
525
|
+
async execute() {
|
|
526
|
+
const {
|
|
527
|
+
argv
|
|
528
|
+
} = this.context;
|
|
529
|
+
// super
|
|
530
|
+
await super.execute();
|
|
531
|
+
// module name/info
|
|
532
|
+
const moduleName = argv.module;
|
|
533
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
534
|
+
// check if exists
|
|
535
|
+
const _module = this.helper.findModule(moduleName);
|
|
536
|
+
if (!_module) {
|
|
537
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
538
|
+
}
|
|
539
|
+
// target dir
|
|
540
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
541
|
+
// mockName
|
|
542
|
+
const mockName = argv.mockName;
|
|
543
|
+
// nameMeta
|
|
544
|
+
argv.nameMeta = this.helper.parseNameMeta(mockName, ['mock']);
|
|
545
|
+
// directory
|
|
546
|
+
const mockDir = path.join(targetDir, 'mock');
|
|
547
|
+
const mockFile = path.join(mockDir, `${mockName}.fake.ts`);
|
|
548
|
+
if (fs.existsSync(mockFile)) {
|
|
549
|
+
throw new Error(`mock exists: ${mockFile}`);
|
|
550
|
+
}
|
|
551
|
+
await this.helper.ensureDir(mockDir);
|
|
552
|
+
// render boilerplate
|
|
553
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
554
|
+
targetDir: mockDir,
|
|
555
|
+
setName: __ThisSetName__,
|
|
556
|
+
snippetsPath: null,
|
|
557
|
+
boilerplatePath: 'create/mock/boilerplate'
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
class CliCreateModule extends BeanCliBase {
|
|
563
|
+
async execute() {
|
|
564
|
+
const {
|
|
565
|
+
argv
|
|
566
|
+
} = this.context;
|
|
567
|
+
// super
|
|
568
|
+
await super.execute();
|
|
569
|
+
// noformat
|
|
570
|
+
// argv.noformat = true;
|
|
571
|
+
// suite name/info
|
|
572
|
+
const suiteName = argv.suite;
|
|
573
|
+
if (suiteName) {
|
|
574
|
+
argv.suiteInfo = this.helper.parseSuiteInfo(suiteName);
|
|
575
|
+
// check if exists
|
|
576
|
+
argv._suite = this.helper.findSuite(suiteName);
|
|
577
|
+
if (!argv._suite) {
|
|
578
|
+
throw new Error(`suite does not exist: ${suiteName}`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
// nameMeta
|
|
582
|
+
const nameMeta = this.helper.parseNameMeta(argv.name);
|
|
583
|
+
const moduleDir = nameMeta.directory || 'module';
|
|
584
|
+
argv.name = nameMeta.short;
|
|
585
|
+
// module name/info
|
|
586
|
+
const moduleName = argv.name;
|
|
587
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
588
|
+
argv.relativeNameCapitalize = this.helper.stringToCapitalize(argv.moduleInfo.relativeName, '-');
|
|
589
|
+
// check if exists
|
|
590
|
+
const _module = this.helper.findModule(moduleName);
|
|
591
|
+
if (!argv.force && _module) {
|
|
592
|
+
throw new Error(`module exists: ${moduleName}`);
|
|
593
|
+
}
|
|
594
|
+
// target dir
|
|
595
|
+
let targetDir;
|
|
596
|
+
if (suiteName) {
|
|
597
|
+
targetDir = path.join(argv._suite.root, 'modules', moduleName);
|
|
598
|
+
} else {
|
|
599
|
+
targetDir = path.join(argv.projectPath, `src/${moduleDir}`, moduleName);
|
|
600
|
+
}
|
|
601
|
+
if (!argv.force && fs.existsSync(targetDir)) {
|
|
602
|
+
throw new Error(`module exists: ${moduleName}`);
|
|
603
|
+
}
|
|
604
|
+
// render module snippets for suite
|
|
605
|
+
if (suiteName) {
|
|
606
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
607
|
+
targetDir: argv._suite.root,
|
|
608
|
+
setName: __ThisSetName__,
|
|
609
|
+
snippetsPath: 'create/module/snippets',
|
|
610
|
+
boilerplatePath: null
|
|
611
|
+
});
|
|
612
|
+
await this.helper.removeGitkeep(path.join(argv._suite.root, 'modules'));
|
|
613
|
+
}
|
|
614
|
+
// render module boilerplate
|
|
615
|
+
targetDir = await this.helper.ensureDir(targetDir);
|
|
616
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
617
|
+
targetDir,
|
|
618
|
+
setName: __ThisSetName__,
|
|
619
|
+
snippetsPath: null,
|
|
620
|
+
boilerplatePath: 'create/module/boilerplate'
|
|
621
|
+
});
|
|
622
|
+
// tools.deps
|
|
623
|
+
if (!argv.vscode) {
|
|
624
|
+
await this.helper.invokeCli([':tools:deps'], {
|
|
625
|
+
cwd: argv.projectPath
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
// pnpm install
|
|
629
|
+
if (!argv.vscode && !argv.ci) {
|
|
630
|
+
await this.helper.pnpmInstall();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
class CliCreatePageBase extends BeanCliBase {
|
|
636
|
+
constructor(options, pageMode) {
|
|
637
|
+
super(options);
|
|
638
|
+
this.pageMode = void 0;
|
|
639
|
+
this.pageMode = pageMode;
|
|
640
|
+
}
|
|
641
|
+
async execute() {
|
|
642
|
+
const {
|
|
643
|
+
argv
|
|
644
|
+
} = this.context;
|
|
645
|
+
// super
|
|
646
|
+
await super.execute();
|
|
647
|
+
// module name/info
|
|
648
|
+
const moduleName = argv.module;
|
|
649
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
650
|
+
// check if exists
|
|
651
|
+
const _module = this.helper.findModule(moduleName);
|
|
652
|
+
if (!_module) {
|
|
653
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
654
|
+
}
|
|
655
|
+
// target dir
|
|
656
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
657
|
+
// pageName
|
|
658
|
+
const pageName = argv.pageName;
|
|
659
|
+
// nameMeta
|
|
660
|
+
argv.nameMeta = this.helper.parseNameMeta(pageName);
|
|
661
|
+
// directory
|
|
662
|
+
let pageDir = path.join(targetDir, 'src/page');
|
|
663
|
+
pageDir = path.join(pageDir, pageName);
|
|
664
|
+
if (fs.existsSync(pageDir)) {
|
|
665
|
+
throw new Error(`page exists: ${pageName}`);
|
|
666
|
+
}
|
|
667
|
+
await this.helper.ensureDir(pageDir);
|
|
668
|
+
// render snippets
|
|
669
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
670
|
+
targetDir,
|
|
671
|
+
setName: __ThisSetName__,
|
|
672
|
+
snippetsPath: `create/${this.pageMode}/snippets`,
|
|
673
|
+
boilerplatePath: null
|
|
674
|
+
});
|
|
675
|
+
// render boilerplate
|
|
676
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
677
|
+
targetDir: pageDir,
|
|
678
|
+
setName: __ThisSetName__,
|
|
679
|
+
snippetsPath: null,
|
|
680
|
+
boilerplatePath: `create/${this.pageMode}/boilerplate`
|
|
681
|
+
});
|
|
682
|
+
// tools.metadata
|
|
683
|
+
if (!argv.nometadata) {
|
|
684
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
685
|
+
cwd: argv.projectPath
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
// log url
|
|
689
|
+
await this.logUrl(argv);
|
|
690
|
+
}
|
|
691
|
+
async logUrl(argv) {
|
|
692
|
+
const env = await this.loadEnvs();
|
|
693
|
+
const host = !env.DEV_SERVER_HOSTNAME || env.DEV_SERVER_HOSTNAME === 'true' ? 'localhost' : env.DEV_SERVER_HOSTNAME;
|
|
694
|
+
const port = env.DEV_SERVER_PORT;
|
|
695
|
+
const url = `http://${host}:${port}/${argv.moduleInfo.pid}/${argv.moduleInfo.name}/${argv.pageName}`;
|
|
696
|
+
const message = `Page URL: ${url}`;
|
|
697
|
+
await this.console.log(message);
|
|
698
|
+
}
|
|
699
|
+
async loadEnvs() {
|
|
700
|
+
const configMeta = {
|
|
701
|
+
flavor: 'admin',
|
|
702
|
+
mode: 'development',
|
|
703
|
+
appMode: 'spa'
|
|
704
|
+
};
|
|
705
|
+
const configOptions = {
|
|
706
|
+
appDir: process.cwd(),
|
|
707
|
+
runtimeDir: '.zova',
|
|
708
|
+
zovaManualChunk: {
|
|
709
|
+
debug: false,
|
|
710
|
+
vendors: []
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
// config utils
|
|
714
|
+
const configUtils = createConfigUtils(configMeta, configOptions);
|
|
715
|
+
// env
|
|
716
|
+
const env = configUtils.loadEnvs();
|
|
717
|
+
return env;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
class CliCreatePage extends CliCreatePageBase {
|
|
722
|
+
constructor(options) {
|
|
723
|
+
super(options, 'page');
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// import { __ThisSetName__ } from '../this.ts';
|
|
728
|
+
|
|
729
|
+
class CliCreateProject extends BeanCliBase {
|
|
730
|
+
constructor(options) {
|
|
731
|
+
super(options);
|
|
732
|
+
this.httpClient = void 0;
|
|
733
|
+
this.httpClient = urllib;
|
|
734
|
+
}
|
|
735
|
+
async execute() {
|
|
736
|
+
const {
|
|
737
|
+
argv
|
|
738
|
+
} = this.context;
|
|
739
|
+
// super
|
|
740
|
+
await super.execute();
|
|
741
|
+
// noformat
|
|
742
|
+
// argv.noformat = true;
|
|
743
|
+
// project name
|
|
744
|
+
const projectName = argv.name;
|
|
745
|
+
// target dir
|
|
746
|
+
const targetDir = path.join(argv.projectPath, projectName);
|
|
747
|
+
if (!argv.force && fs.existsSync(targetDir)) {
|
|
748
|
+
throw new Error(`project exists: ${projectName}`);
|
|
749
|
+
}
|
|
750
|
+
// template
|
|
751
|
+
const template = argv.template;
|
|
752
|
+
const packageName = `zova-ui-${template}`;
|
|
753
|
+
// download boilerplate
|
|
754
|
+
const templateDir = await this.downloadBoilerplate(packageName);
|
|
755
|
+
fse.copySync(templateDir, targetDir);
|
|
756
|
+
// remove LICENSE
|
|
757
|
+
fse.removeSync(path.join(targetDir, 'LICENSE'));
|
|
758
|
+
// copy package.json
|
|
759
|
+
fse.copyFileSync(path.join(targetDir, 'package.original.json'), path.join(targetDir, 'package.json'));
|
|
760
|
+
// npm run init
|
|
761
|
+
await this.helper.spawnCmd({
|
|
762
|
+
cmd: 'npm',
|
|
763
|
+
args: ['run', 'init'],
|
|
764
|
+
options: {
|
|
765
|
+
cwd: targetDir
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
// done
|
|
769
|
+
await this.printUsage(targetDir);
|
|
770
|
+
}
|
|
771
|
+
async printUsage(targetDir) {
|
|
772
|
+
await this.console.log(`usage:
|
|
773
|
+
- cd ${targetDir}
|
|
774
|
+
- pnpm install
|
|
775
|
+
- npm run dev
|
|
776
|
+
- npm run build
|
|
777
|
+
- npm run preview
|
|
778
|
+
`);
|
|
779
|
+
}
|
|
780
|
+
async downloadBoilerplate(packageName) {
|
|
781
|
+
const result = await this.getPackageInfo(packageName, false);
|
|
782
|
+
const tgzUrl = result.dist.tarball;
|
|
783
|
+
await this.console.log(`downloading ${tgzUrl}`);
|
|
784
|
+
const saveDir = path.join(os.tmpdir(), 'zova-project-boilerplate');
|
|
785
|
+
await rimraf(saveDir);
|
|
786
|
+
const response = await this.curl(tgzUrl, {
|
|
787
|
+
streaming: true,
|
|
788
|
+
followRedirect: true
|
|
789
|
+
});
|
|
790
|
+
await compressing.tgz.uncompress(response.res, saveDir);
|
|
791
|
+
await this.console.log(`extract to ${saveDir}`);
|
|
792
|
+
return path.join(saveDir, '/package');
|
|
793
|
+
}
|
|
794
|
+
async getPackageInfo(packageName, withFallback) {
|
|
795
|
+
await this.console.log(`fetching npm info of ${packageName}`);
|
|
796
|
+
try {
|
|
797
|
+
const registry = await this.helper.getRegistry();
|
|
798
|
+
const result = await this.curl(`${registry}${packageName}/latest`, {
|
|
799
|
+
dataType: 'json',
|
|
800
|
+
followRedirect: true,
|
|
801
|
+
maxRedirects: 5
|
|
802
|
+
});
|
|
803
|
+
if (result.status !== 200) {
|
|
804
|
+
const message = `npm info ${packageName} got error: ${result.status}, ${result.data.reason}`;
|
|
805
|
+
throw new Error(message);
|
|
806
|
+
}
|
|
807
|
+
return result.data;
|
|
808
|
+
} catch (err) {
|
|
809
|
+
if (withFallback) {
|
|
810
|
+
await this.console.log(`use fallback from ${packageName}`);
|
|
811
|
+
const require = createRequire(import.meta.url);
|
|
812
|
+
return require(`${packageName}/package.json`);
|
|
813
|
+
}
|
|
814
|
+
throw err;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
async curl(url, options) {
|
|
818
|
+
options = options || {};
|
|
819
|
+
if (!options.timeout) {
|
|
820
|
+
options.timeout = 30000;
|
|
821
|
+
}
|
|
822
|
+
return await this.httpClient.request(url, options);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
class CliCreateSuite extends BeanCliBase {
|
|
827
|
+
async execute() {
|
|
828
|
+
const {
|
|
829
|
+
argv
|
|
830
|
+
} = this.context;
|
|
831
|
+
// super
|
|
832
|
+
await super.execute();
|
|
833
|
+
// noformat
|
|
834
|
+
// argv.noformat = true;
|
|
835
|
+
// nameMeta
|
|
836
|
+
const nameMeta = this.helper.parseNameMeta(argv.name);
|
|
837
|
+
const suiteDir = nameMeta.directory || 'suite';
|
|
838
|
+
argv.name = nameMeta.short;
|
|
839
|
+
// suite name/info
|
|
840
|
+
const suiteName = argv.name;
|
|
841
|
+
argv.suiteInfo = this.helper.parseSuiteInfo(suiteName);
|
|
842
|
+
// check if exists
|
|
843
|
+
const _suite = this.helper.findSuite(suiteName);
|
|
844
|
+
if (_suite) {
|
|
845
|
+
throw new Error(`suite exists: ${suiteName}`);
|
|
846
|
+
}
|
|
847
|
+
// target dir
|
|
848
|
+
let targetDir = path.join(argv.projectPath, `src/${suiteDir}`, suiteName);
|
|
849
|
+
if (fs.existsSync(targetDir)) {
|
|
850
|
+
throw new Error(`suite exists: ${suiteName}`);
|
|
851
|
+
}
|
|
852
|
+
targetDir = await this.helper.ensureDir(targetDir);
|
|
853
|
+
// templateDir
|
|
854
|
+
const templateDir = this.template.resolveTemplatePath(__ThisSetName__, 'create/suite');
|
|
855
|
+
// render
|
|
856
|
+
await this.template.renderDir(targetDir, templateDir);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
class CliDefaultList extends BeanCliBase {
|
|
861
|
+
async execute() {
|
|
862
|
+
const {
|
|
863
|
+
argv
|
|
864
|
+
} = this.context;
|
|
865
|
+
// super
|
|
866
|
+
await super.execute();
|
|
867
|
+
// set/group
|
|
868
|
+
const setWant = argv.set;
|
|
869
|
+
let groupWant = argv.group;
|
|
870
|
+
if (!setWant) groupWant = undefined;
|
|
871
|
+
// commandsAll
|
|
872
|
+
const commandsAll = (await getCommandsMeta()).all;
|
|
873
|
+
// setsShow
|
|
874
|
+
let setsShow;
|
|
875
|
+
if (setWant) {
|
|
876
|
+
if (!commandsAll[setWant]) throw new Error(`cli set not found: ${setWant}`);
|
|
877
|
+
setsShow = [setWant];
|
|
878
|
+
} else {
|
|
879
|
+
setsShow = Object.keys(commandsAll);
|
|
880
|
+
}
|
|
881
|
+
// loop
|
|
882
|
+
const total = setsShow.length;
|
|
883
|
+
for (let index = 0; index < total; index++) {
|
|
884
|
+
const setShow = setsShow[index];
|
|
885
|
+
// log
|
|
886
|
+
await this.console.log({
|
|
887
|
+
total,
|
|
888
|
+
progress: index,
|
|
889
|
+
text: setShow
|
|
890
|
+
});
|
|
891
|
+
// show
|
|
892
|
+
await this._setShow({
|
|
893
|
+
setShow,
|
|
894
|
+
groupWant,
|
|
895
|
+
commandsAll
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
// await this.console.log({ text: JSON.stringify(modulesWant) });
|
|
899
|
+
}
|
|
900
|
+
async _setShow({
|
|
901
|
+
setShow,
|
|
902
|
+
groupWant,
|
|
903
|
+
commandsAll
|
|
904
|
+
}) {
|
|
905
|
+
// _set
|
|
906
|
+
const _set = commandsAll[setShow];
|
|
907
|
+
// groupsShow
|
|
908
|
+
let groupsShow;
|
|
909
|
+
if (groupWant) {
|
|
910
|
+
if (!_set[groupWant]) throw new Error(`cli set group not found: ${setShow}:${groupWant}`);
|
|
911
|
+
groupsShow = [groupWant];
|
|
912
|
+
} else {
|
|
913
|
+
groupsShow = Object.keys(_set);
|
|
914
|
+
}
|
|
915
|
+
// table
|
|
916
|
+
const table = this.helper.newTable({
|
|
917
|
+
head: ['Command', 'Version', 'Description'],
|
|
918
|
+
colWidths: [30, 10, 40]
|
|
919
|
+
});
|
|
920
|
+
// group
|
|
921
|
+
const groupCount = groupsShow.length;
|
|
922
|
+
for (let index = 0; index < groupCount; index++) {
|
|
923
|
+
const groupShow = groupsShow[index];
|
|
924
|
+
const _group = _set[groupShow];
|
|
925
|
+
for (const commandName in _group) {
|
|
926
|
+
const _command = _group[commandName].command;
|
|
927
|
+
const cliFullName = this._combineCliFullName({
|
|
928
|
+
setShow,
|
|
929
|
+
groupShow,
|
|
930
|
+
commandName
|
|
931
|
+
});
|
|
932
|
+
const version = _command.info.version;
|
|
933
|
+
const description = _command.info.description || _command.info.title;
|
|
934
|
+
table.push([cliFullName, version, description]);
|
|
935
|
+
}
|
|
936
|
+
if (index < groupCount - 1) {
|
|
937
|
+
table.push([]);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
// log
|
|
941
|
+
await this.console.log({
|
|
942
|
+
text: table.toString()
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
_combineCliFullName({
|
|
946
|
+
setShow,
|
|
947
|
+
groupShow,
|
|
948
|
+
commandName
|
|
949
|
+
}) {
|
|
950
|
+
const parts = [];
|
|
951
|
+
if (setShow === 'front') {
|
|
952
|
+
parts.push('');
|
|
953
|
+
} else {
|
|
954
|
+
parts.push(setShow);
|
|
955
|
+
}
|
|
956
|
+
if (groupShow === 'default') {
|
|
957
|
+
parts.push('');
|
|
958
|
+
} else {
|
|
959
|
+
parts.push(groupShow);
|
|
960
|
+
}
|
|
961
|
+
parts.push(commandName);
|
|
962
|
+
return parts.join(':');
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
class CliInitAppMonkey extends BeanCliBase {
|
|
967
|
+
async execute() {
|
|
968
|
+
const {
|
|
969
|
+
argv
|
|
970
|
+
} = this.context;
|
|
971
|
+
// super
|
|
972
|
+
await super.execute();
|
|
973
|
+
// target dir
|
|
974
|
+
const targetDir = path.join(argv.projectPath, 'src/front/config');
|
|
975
|
+
const monkeyFile = path.join(targetDir, 'monkey.ts');
|
|
976
|
+
if (fse.existsSync(monkeyFile)) {
|
|
977
|
+
throw new Error('app monkey exists');
|
|
978
|
+
}
|
|
979
|
+
// render boilerplate
|
|
980
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
981
|
+
targetDir,
|
|
982
|
+
setName: __ThisSetName__,
|
|
983
|
+
snippetsPath: null,
|
|
984
|
+
boilerplatePath: 'init/appMonkey/boilerplate'
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
class CliInitAsset extends BeanCliBase {
|
|
990
|
+
async execute() {
|
|
991
|
+
const {
|
|
992
|
+
argv
|
|
993
|
+
} = this.context;
|
|
994
|
+
// super
|
|
995
|
+
await super.execute();
|
|
996
|
+
// noformat
|
|
997
|
+
// argv.noformat = true;
|
|
998
|
+
// module name/info
|
|
999
|
+
const moduleName = argv.module;
|
|
1000
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1001
|
+
// check if exists
|
|
1002
|
+
const _module = this.helper.findModule(moduleName);
|
|
1003
|
+
if (!_module) {
|
|
1004
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1005
|
+
}
|
|
1006
|
+
// target dir
|
|
1007
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1008
|
+
// scene
|
|
1009
|
+
const scene = argv.scene;
|
|
1010
|
+
// directory
|
|
1011
|
+
const assetDir = path.join(targetDir, 'assets', scene);
|
|
1012
|
+
if (fse.existsSync(assetDir)) {
|
|
1013
|
+
throw new Error(`asset exists: ${moduleName}/assets/${scene}`);
|
|
1014
|
+
}
|
|
1015
|
+
await this.helper.ensureDir(assetDir);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
class CliInitConfig extends BeanCliBase {
|
|
1020
|
+
async execute() {
|
|
1021
|
+
const {
|
|
1022
|
+
argv
|
|
1023
|
+
} = this.context;
|
|
1024
|
+
// super
|
|
1025
|
+
await super.execute();
|
|
1026
|
+
// module name/info
|
|
1027
|
+
const moduleName = argv._[0];
|
|
1028
|
+
if (!moduleName) return;
|
|
1029
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1030
|
+
// check if exists
|
|
1031
|
+
const _module = this.helper.findModule(moduleName);
|
|
1032
|
+
if (!_module) {
|
|
1033
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1034
|
+
}
|
|
1035
|
+
// target dir
|
|
1036
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1037
|
+
const configFile = path.join(targetDir, 'src/config/config.ts');
|
|
1038
|
+
if (fse.existsSync(configFile)) {
|
|
1039
|
+
throw new Error(`config exists: ${moduleName}`);
|
|
1040
|
+
}
|
|
1041
|
+
// render boilerplate
|
|
1042
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1043
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1044
|
+
setName: __ThisSetName__,
|
|
1045
|
+
snippetsPath: null,
|
|
1046
|
+
boilerplatePath: 'init/config/boilerplate'
|
|
1047
|
+
});
|
|
1048
|
+
// tools.metadata
|
|
1049
|
+
if (!argv.nometadata) {
|
|
1050
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1051
|
+
cwd: argv.projectPath
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
class CliInitConstant extends BeanCliBase {
|
|
1058
|
+
async execute() {
|
|
1059
|
+
const {
|
|
1060
|
+
argv
|
|
1061
|
+
} = this.context;
|
|
1062
|
+
// super
|
|
1063
|
+
await super.execute();
|
|
1064
|
+
// module name/info
|
|
1065
|
+
const moduleName = argv._[0];
|
|
1066
|
+
if (!moduleName) return;
|
|
1067
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1068
|
+
// check if exists
|
|
1069
|
+
const _module = this.helper.findModule(moduleName);
|
|
1070
|
+
if (!_module) {
|
|
1071
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1072
|
+
}
|
|
1073
|
+
// target dir
|
|
1074
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1075
|
+
const constantFile = path.join(targetDir, 'src/config/constants.ts');
|
|
1076
|
+
if (fse.existsSync(constantFile)) {
|
|
1077
|
+
throw new Error(`constant exists: ${moduleName}`);
|
|
1078
|
+
}
|
|
1079
|
+
// render boilerplate
|
|
1080
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1081
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1082
|
+
setName: __ThisSetName__,
|
|
1083
|
+
snippetsPath: null,
|
|
1084
|
+
boilerplatePath: 'init/constant/boilerplate'
|
|
1085
|
+
});
|
|
1086
|
+
// tools.metadata
|
|
1087
|
+
if (!argv.nometadata) {
|
|
1088
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1089
|
+
cwd: argv.projectPath
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
class CliInitError extends BeanCliBase {
|
|
1096
|
+
async execute() {
|
|
1097
|
+
const {
|
|
1098
|
+
argv
|
|
1099
|
+
} = this.context;
|
|
1100
|
+
// super
|
|
1101
|
+
await super.execute();
|
|
1102
|
+
// module name/info
|
|
1103
|
+
const moduleName = argv._[0];
|
|
1104
|
+
if (!moduleName) return;
|
|
1105
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1106
|
+
// check if exists
|
|
1107
|
+
const _module = this.helper.findModule(moduleName);
|
|
1108
|
+
if (!_module) {
|
|
1109
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1110
|
+
}
|
|
1111
|
+
// target dir
|
|
1112
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1113
|
+
const errorFile = path.join(targetDir, 'src/config/errors.ts');
|
|
1114
|
+
if (fse.existsSync(errorFile)) {
|
|
1115
|
+
throw new Error(`error exists: ${moduleName}`);
|
|
1116
|
+
}
|
|
1117
|
+
// render boilerplate
|
|
1118
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1119
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1120
|
+
setName: __ThisSetName__,
|
|
1121
|
+
snippetsPath: null,
|
|
1122
|
+
boilerplatePath: 'init/error/boilerplate'
|
|
1123
|
+
});
|
|
1124
|
+
// special for locale
|
|
1125
|
+
const localeFile = path.join(targetDir, 'src/config/locale');
|
|
1126
|
+
if (!fse.existsSync(localeFile)) {
|
|
1127
|
+
// render boilerplate
|
|
1128
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1129
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1130
|
+
setName: __ThisSetName__,
|
|
1131
|
+
snippetsPath: null,
|
|
1132
|
+
boilerplatePath: 'init/locale/boilerplate'
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
// tools.metadata
|
|
1136
|
+
if (!argv.nometadata) {
|
|
1137
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1138
|
+
cwd: argv.projectPath
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
class CliInitIcon extends BeanCliBase {
|
|
1145
|
+
async execute() {
|
|
1146
|
+
const {
|
|
1147
|
+
argv
|
|
1148
|
+
} = this.context;
|
|
1149
|
+
// super
|
|
1150
|
+
await super.execute();
|
|
1151
|
+
// module name/info
|
|
1152
|
+
const moduleName = argv._[0];
|
|
1153
|
+
if (!moduleName) return;
|
|
1154
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1155
|
+
// check if exists
|
|
1156
|
+
const _module = this.helper.findModule(moduleName);
|
|
1157
|
+
if (!_module) {
|
|
1158
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1159
|
+
}
|
|
1160
|
+
// target dir
|
|
1161
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1162
|
+
const iconDir = path.join(targetDir, 'icons');
|
|
1163
|
+
if (fse.existsSync(iconDir)) {
|
|
1164
|
+
throw new Error(`icon exists: ${moduleName}`);
|
|
1165
|
+
}
|
|
1166
|
+
// render boilerplate
|
|
1167
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1168
|
+
targetDir,
|
|
1169
|
+
setName: __ThisSetName__,
|
|
1170
|
+
snippetsPath: null,
|
|
1171
|
+
boilerplatePath: 'init/icon/boilerplate'
|
|
1172
|
+
});
|
|
1173
|
+
// set zovaModule.capabilities.icon: true
|
|
1174
|
+
await this._setPackageInfo(targetDir);
|
|
1175
|
+
// tools.metadata
|
|
1176
|
+
if (!argv.nometadata) {
|
|
1177
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1178
|
+
cwd: argv.projectPath
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
async _setPackageInfo(modulePath) {
|
|
1183
|
+
const pkgFile = path.join(modulePath, 'package.json');
|
|
1184
|
+
const pkg = await this.helper.loadJSONFile(pkgFile);
|
|
1185
|
+
if (!pkg.zovaModule) pkg.zovaModule = {};
|
|
1186
|
+
if (!pkg.zovaModule.capabilities) pkg.zovaModule.capabilities = {};
|
|
1187
|
+
if (pkg.zovaModule.capabilities.icon) return;
|
|
1188
|
+
pkg.zovaModule.capabilities.icon = true;
|
|
1189
|
+
await this.helper.saveJSONFile(pkgFile, pkg);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
class CliInitLegacy extends BeanCliBase {
|
|
1194
|
+
async execute() {
|
|
1195
|
+
const {
|
|
1196
|
+
argv
|
|
1197
|
+
} = this.context;
|
|
1198
|
+
// super
|
|
1199
|
+
await super.execute();
|
|
1200
|
+
// target dir
|
|
1201
|
+
const legacyDir = path.join(argv.projectPath, 'src/legacy');
|
|
1202
|
+
if (fse.existsSync(legacyDir)) {
|
|
1203
|
+
throw new Error(`legacy exists: ${legacyDir}`);
|
|
1204
|
+
}
|
|
1205
|
+
// render boilerplate
|
|
1206
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1207
|
+
targetDir: legacyDir,
|
|
1208
|
+
setName: __ThisSetName__,
|
|
1209
|
+
snippetsPath: null,
|
|
1210
|
+
boilerplatePath: 'init/legacy/boilerplate'
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
class CliInitLib extends BeanCliBase {
|
|
1216
|
+
async execute() {
|
|
1217
|
+
const {
|
|
1218
|
+
argv
|
|
1219
|
+
} = this.context;
|
|
1220
|
+
// super
|
|
1221
|
+
await super.execute();
|
|
1222
|
+
// module name/info
|
|
1223
|
+
const moduleName = argv._[0];
|
|
1224
|
+
if (!moduleName) return;
|
|
1225
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1226
|
+
// check if exists
|
|
1227
|
+
const _module = this.helper.findModule(moduleName);
|
|
1228
|
+
if (!_module) {
|
|
1229
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1230
|
+
}
|
|
1231
|
+
// target dir
|
|
1232
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1233
|
+
const mainFile = path.join(targetDir, 'src/lib/index.ts');
|
|
1234
|
+
if (fse.existsSync(mainFile)) {
|
|
1235
|
+
throw new Error(`lib exists: ${moduleName}`);
|
|
1236
|
+
}
|
|
1237
|
+
// render boilerplate
|
|
1238
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1239
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1240
|
+
setName: __ThisSetName__,
|
|
1241
|
+
snippetsPath: null,
|
|
1242
|
+
boilerplatePath: 'init/lib/boilerplate'
|
|
1243
|
+
});
|
|
1244
|
+
// tools.metadata
|
|
1245
|
+
if (!argv.nometadata) {
|
|
1246
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1247
|
+
cwd: argv.projectPath
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
class CliInitLocale extends BeanCliBase {
|
|
1254
|
+
async execute() {
|
|
1255
|
+
const {
|
|
1256
|
+
argv
|
|
1257
|
+
} = this.context;
|
|
1258
|
+
// super
|
|
1259
|
+
await super.execute();
|
|
1260
|
+
// module name/info
|
|
1261
|
+
const moduleName = argv._[0];
|
|
1262
|
+
if (!moduleName) return;
|
|
1263
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1264
|
+
// check if exists
|
|
1265
|
+
const _module = this.helper.findModule(moduleName);
|
|
1266
|
+
if (!_module) {
|
|
1267
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1268
|
+
}
|
|
1269
|
+
// target dir
|
|
1270
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1271
|
+
const localeFile = path.join(targetDir, 'src/config/locale');
|
|
1272
|
+
if (fse.existsSync(localeFile)) {
|
|
1273
|
+
throw new Error(`locale exists: ${moduleName}`);
|
|
1274
|
+
}
|
|
1275
|
+
// render boilerplate
|
|
1276
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1277
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1278
|
+
setName: __ThisSetName__,
|
|
1279
|
+
snippetsPath: null,
|
|
1280
|
+
boilerplatePath: 'init/locale/boilerplate'
|
|
1281
|
+
});
|
|
1282
|
+
// tools.metadata
|
|
1283
|
+
if (!argv.nometadata) {
|
|
1284
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1285
|
+
cwd: argv.projectPath
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
class CliInitMain extends BeanCliBase {
|
|
1292
|
+
async execute() {
|
|
1293
|
+
const {
|
|
1294
|
+
argv
|
|
1295
|
+
} = this.context;
|
|
1296
|
+
// super
|
|
1297
|
+
await super.execute();
|
|
1298
|
+
// module name/info
|
|
1299
|
+
const moduleName = argv._[0];
|
|
1300
|
+
if (!moduleName) return;
|
|
1301
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1302
|
+
// check if exists
|
|
1303
|
+
const _module = this.helper.findModule(moduleName);
|
|
1304
|
+
if (!_module) {
|
|
1305
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1306
|
+
}
|
|
1307
|
+
// target dir
|
|
1308
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1309
|
+
const mainFile = path.join(targetDir, 'src/main.ts');
|
|
1310
|
+
if (fse.existsSync(mainFile)) {
|
|
1311
|
+
throw new Error(`main exists: ${moduleName}`);
|
|
1312
|
+
}
|
|
1313
|
+
// render boilerplate
|
|
1314
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1315
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1316
|
+
setName: __ThisSetName__,
|
|
1317
|
+
snippetsPath: null,
|
|
1318
|
+
boilerplatePath: 'init/main/boilerplate'
|
|
1319
|
+
});
|
|
1320
|
+
// tools.metadata
|
|
1321
|
+
if (!argv.nometadata) {
|
|
1322
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1323
|
+
cwd: argv.projectPath
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
class CliInitMainSys extends BeanCliBase {
|
|
1330
|
+
async execute() {
|
|
1331
|
+
const {
|
|
1332
|
+
argv
|
|
1333
|
+
} = this.context;
|
|
1334
|
+
// super
|
|
1335
|
+
await super.execute();
|
|
1336
|
+
// module name/info
|
|
1337
|
+
const moduleName = argv._[0];
|
|
1338
|
+
if (!moduleName) return;
|
|
1339
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1340
|
+
// check if exists
|
|
1341
|
+
const _module = this.helper.findModule(moduleName);
|
|
1342
|
+
if (!_module) {
|
|
1343
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1344
|
+
}
|
|
1345
|
+
// target dir
|
|
1346
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1347
|
+
const mainFile = path.join(targetDir, 'src/mainSys.ts');
|
|
1348
|
+
if (fse.existsSync(mainFile)) {
|
|
1349
|
+
throw new Error(`mainSys exists: ${moduleName}`);
|
|
1350
|
+
}
|
|
1351
|
+
// render boilerplate
|
|
1352
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1353
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1354
|
+
setName: __ThisSetName__,
|
|
1355
|
+
snippetsPath: null,
|
|
1356
|
+
boilerplatePath: 'init/mainSys/boilerplate'
|
|
1357
|
+
});
|
|
1358
|
+
// tools.metadata
|
|
1359
|
+
if (!argv.nometadata) {
|
|
1360
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1361
|
+
cwd: argv.projectPath
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
class CliInitMonkey extends BeanCliBase {
|
|
1368
|
+
async execute() {
|
|
1369
|
+
const {
|
|
1370
|
+
argv
|
|
1371
|
+
} = this.context;
|
|
1372
|
+
// super
|
|
1373
|
+
await super.execute();
|
|
1374
|
+
// module name/info
|
|
1375
|
+
const moduleName = argv._[0];
|
|
1376
|
+
if (!moduleName) return;
|
|
1377
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1378
|
+
// check if exists
|
|
1379
|
+
const _module = this.helper.findModule(moduleName);
|
|
1380
|
+
if (!_module) {
|
|
1381
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1382
|
+
}
|
|
1383
|
+
// target dir
|
|
1384
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1385
|
+
const monkeyFile = path.join(targetDir, 'src/monkey.ts');
|
|
1386
|
+
if (fse.existsSync(monkeyFile)) {
|
|
1387
|
+
throw new Error(`monkey exists: ${moduleName}`);
|
|
1388
|
+
}
|
|
1389
|
+
// render boilerplate
|
|
1390
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1391
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1392
|
+
setName: __ThisSetName__,
|
|
1393
|
+
snippetsPath: null,
|
|
1394
|
+
boilerplatePath: 'init/monkey/boilerplate'
|
|
1395
|
+
});
|
|
1396
|
+
// set zovaModule.capabilities.monkey: true
|
|
1397
|
+
await this._setPackageInfo(targetDir);
|
|
1398
|
+
// tools.metadata
|
|
1399
|
+
if (!argv.nometadata) {
|
|
1400
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1401
|
+
cwd: argv.projectPath
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
async _setPackageInfo(modulePath) {
|
|
1406
|
+
const pkgFile = path.join(modulePath, 'package.json');
|
|
1407
|
+
const pkg = await this.helper.loadJSONFile(pkgFile);
|
|
1408
|
+
if (!pkg.zovaModule) pkg.zovaModule = {};
|
|
1409
|
+
if (!pkg.zovaModule.capabilities) pkg.zovaModule.capabilities = {};
|
|
1410
|
+
let changed;
|
|
1411
|
+
// monkey
|
|
1412
|
+
if (!pkg.zovaModule.capabilities.monkey) {
|
|
1413
|
+
pkg.zovaModule.capabilities.monkey = true;
|
|
1414
|
+
changed = true;
|
|
1415
|
+
}
|
|
1416
|
+
// dependencies
|
|
1417
|
+
if (!pkg.zovaModule.dependencies) pkg.zovaModule.dependencies = {};
|
|
1418
|
+
if (!pkg.zovaModule.dependencies['a-zova']) {
|
|
1419
|
+
pkg.zovaModule.dependencies['a-zova'] = '5.0.0';
|
|
1420
|
+
changed = true;
|
|
1421
|
+
}
|
|
1422
|
+
// save
|
|
1423
|
+
if (changed) {
|
|
1424
|
+
await this.helper.saveJSONFile(pkgFile, pkg);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
class CliInitMonkeySys extends BeanCliBase {
|
|
1430
|
+
async execute() {
|
|
1431
|
+
const {
|
|
1432
|
+
argv
|
|
1433
|
+
} = this.context;
|
|
1434
|
+
// super
|
|
1435
|
+
await super.execute();
|
|
1436
|
+
// module name/info
|
|
1437
|
+
const moduleName = argv._[0];
|
|
1438
|
+
if (!moduleName) return;
|
|
1439
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1440
|
+
// check if exists
|
|
1441
|
+
const _module = this.helper.findModule(moduleName);
|
|
1442
|
+
if (!_module) {
|
|
1443
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1444
|
+
}
|
|
1445
|
+
// target dir
|
|
1446
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1447
|
+
const monkeyFile = path.join(targetDir, 'src/monkeySys.ts');
|
|
1448
|
+
if (fse.existsSync(monkeyFile)) {
|
|
1449
|
+
throw new Error(`monkeySys exists: ${moduleName}`);
|
|
1450
|
+
}
|
|
1451
|
+
// render boilerplate
|
|
1452
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1453
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1454
|
+
setName: __ThisSetName__,
|
|
1455
|
+
snippetsPath: null,
|
|
1456
|
+
boilerplatePath: 'init/monkeySys/boilerplate'
|
|
1457
|
+
});
|
|
1458
|
+
// set zovaModule.capabilities.monkey: true
|
|
1459
|
+
await this._setPackageInfo(targetDir);
|
|
1460
|
+
// tools.metadata
|
|
1461
|
+
if (!argv.nometadata) {
|
|
1462
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1463
|
+
cwd: argv.projectPath
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
async _setPackageInfo(modulePath) {
|
|
1468
|
+
const pkgFile = path.join(modulePath, 'package.json');
|
|
1469
|
+
const pkg = await this.helper.loadJSONFile(pkgFile);
|
|
1470
|
+
if (!pkg.zovaModule) pkg.zovaModule = {};
|
|
1471
|
+
if (!pkg.zovaModule.capabilities) pkg.zovaModule.capabilities = {};
|
|
1472
|
+
let changed;
|
|
1473
|
+
// monkey
|
|
1474
|
+
if (!pkg.zovaModule.capabilities.monkey) {
|
|
1475
|
+
pkg.zovaModule.capabilities.monkey = true;
|
|
1476
|
+
changed = true;
|
|
1477
|
+
}
|
|
1478
|
+
// dependencies
|
|
1479
|
+
if (!pkg.zovaModule.dependencies) pkg.zovaModule.dependencies = {};
|
|
1480
|
+
if (!pkg.zovaModule.dependencies['a-zova']) {
|
|
1481
|
+
pkg.zovaModule.dependencies['a-zova'] = '5.0.0';
|
|
1482
|
+
changed = true;
|
|
1483
|
+
}
|
|
1484
|
+
// save
|
|
1485
|
+
if (changed) {
|
|
1486
|
+
await this.helper.saveJSONFile(pkgFile, pkg);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
class CliInitSysMonkey extends BeanCliBase {
|
|
1492
|
+
async execute() {
|
|
1493
|
+
const {
|
|
1494
|
+
argv
|
|
1495
|
+
} = this.context;
|
|
1496
|
+
// super
|
|
1497
|
+
await super.execute();
|
|
1498
|
+
// target dir
|
|
1499
|
+
const targetDir = path.join(argv.projectPath, 'src/front/config');
|
|
1500
|
+
const monkeyFile = path.join(targetDir, 'monkeySys.ts');
|
|
1501
|
+
if (fse.existsSync(monkeyFile)) {
|
|
1502
|
+
throw new Error('sys monkey exists');
|
|
1503
|
+
}
|
|
1504
|
+
// render boilerplate
|
|
1505
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1506
|
+
targetDir,
|
|
1507
|
+
setName: __ThisSetName__,
|
|
1508
|
+
snippetsPath: null,
|
|
1509
|
+
boilerplatePath: 'init/sysMonkey/boilerplate'
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
class CliInitTypes extends BeanCliBase {
|
|
1515
|
+
async execute() {
|
|
1516
|
+
const {
|
|
1517
|
+
argv
|
|
1518
|
+
} = this.context;
|
|
1519
|
+
// super
|
|
1520
|
+
await super.execute();
|
|
1521
|
+
// module name/info
|
|
1522
|
+
const moduleName = argv._[0];
|
|
1523
|
+
if (!moduleName) return;
|
|
1524
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1525
|
+
// check if exists
|
|
1526
|
+
const _module = this.helper.findModule(moduleName);
|
|
1527
|
+
if (!_module) {
|
|
1528
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1529
|
+
}
|
|
1530
|
+
// target dir
|
|
1531
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1532
|
+
const mainFile = path.join(targetDir, 'src/types/index.ts');
|
|
1533
|
+
if (fse.existsSync(mainFile)) {
|
|
1534
|
+
throw new Error(`types exists: ${moduleName}`);
|
|
1535
|
+
}
|
|
1536
|
+
// render boilerplate
|
|
1537
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1538
|
+
targetDir: path.join(targetDir, 'src'),
|
|
1539
|
+
setName: __ThisSetName__,
|
|
1540
|
+
snippetsPath: null,
|
|
1541
|
+
boilerplatePath: 'init/types/boilerplate'
|
|
1542
|
+
});
|
|
1543
|
+
// tools.metadata
|
|
1544
|
+
if (!argv.nometadata) {
|
|
1545
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
1546
|
+
cwd: argv.projectPath
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
class CliOpenapiConfig extends BeanCliBase {
|
|
1553
|
+
async execute() {
|
|
1554
|
+
const {
|
|
1555
|
+
argv
|
|
1556
|
+
} = this.context;
|
|
1557
|
+
// super
|
|
1558
|
+
await super.execute();
|
|
1559
|
+
const moduleNames = argv._;
|
|
1560
|
+
if (moduleNames.length === 0) {
|
|
1561
|
+
moduleNames.push('home-api');
|
|
1562
|
+
}
|
|
1563
|
+
// module config
|
|
1564
|
+
for (const moduleName of moduleNames) {
|
|
1565
|
+
await this._generateModuleConfig(moduleName);
|
|
1566
|
+
}
|
|
1567
|
+
// project config
|
|
1568
|
+
const configFile = path.join(argv.projectPath, 'openapi.config.ts');
|
|
1569
|
+
if (fse.existsSync(configFile)) return;
|
|
1570
|
+
// render boilerplate
|
|
1571
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1572
|
+
targetDir: argv.projectPath,
|
|
1573
|
+
setName: __ThisSetName__,
|
|
1574
|
+
snippetsPath: null,
|
|
1575
|
+
boilerplatePath: 'openapi/config/boilerplate/project'
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
async _generateModuleConfig(moduleName) {
|
|
1579
|
+
// check if exists
|
|
1580
|
+
const _module = this.helper.findModule(moduleName);
|
|
1581
|
+
if (!_module) {
|
|
1582
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
1583
|
+
}
|
|
1584
|
+
// target dir
|
|
1585
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
1586
|
+
const configFile = path.join(targetDir, 'cli/openapi.config.ts');
|
|
1587
|
+
if (fse.existsSync(configFile)) return;
|
|
1588
|
+
// render boilerplate
|
|
1589
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
1590
|
+
targetDir: path.join(targetDir, 'cli'),
|
|
1591
|
+
setName: __ThisSetName__,
|
|
1592
|
+
snippetsPath: null,
|
|
1593
|
+
boilerplatePath: 'openapi/config/boilerplate/module'
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
class CliOpenapiGenerate extends BeanCliBase {
|
|
1599
|
+
async execute() {
|
|
1600
|
+
const {
|
|
1601
|
+
argv
|
|
1602
|
+
} = this.context;
|
|
1603
|
+
// super
|
|
1604
|
+
await super.execute();
|
|
1605
|
+
// config file
|
|
1606
|
+
const configFile = path.join(argv.projectPath, 'openapi.config.ts');
|
|
1607
|
+
if (!fse.existsSync(configFile)) {
|
|
1608
|
+
throw new Error('Please generate config first!');
|
|
1609
|
+
}
|
|
1610
|
+
const configInstance = await this.helper.importDynamic(configFile);
|
|
1611
|
+
const config = await configInstance.default();
|
|
1612
|
+
// modules: not vendor/node_modules
|
|
1613
|
+
let moduleNames = argv._;
|
|
1614
|
+
if (moduleNames.length === 0) {
|
|
1615
|
+
moduleNames = this.modulesMeta.modulesArray.filter(item => {
|
|
1616
|
+
if (item.info.node_modules || item.info.vendor) return false;
|
|
1617
|
+
const configFile = path.join(item.root, 'cli/openapi.config.ts');
|
|
1618
|
+
return fse.existsSync(configFile);
|
|
1619
|
+
}).map(item => item.info.relativeName);
|
|
1620
|
+
}
|
|
1621
|
+
if (moduleNames.length === 0) return;
|
|
1622
|
+
// openapi-typescript
|
|
1623
|
+
const openapiTypescript = await import('@cabloy/openapi-typescript');
|
|
1624
|
+
// loop
|
|
1625
|
+
const total = moduleNames.length;
|
|
1626
|
+
const __caches = {};
|
|
1627
|
+
for (let index = 0; index < total; index++) {
|
|
1628
|
+
const moduleName = moduleNames[index];
|
|
1629
|
+
// log
|
|
1630
|
+
await this.console.log({
|
|
1631
|
+
total,
|
|
1632
|
+
progress: index,
|
|
1633
|
+
text: moduleName
|
|
1634
|
+
});
|
|
1635
|
+
// generate res
|
|
1636
|
+
const moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
1637
|
+
const module = this.helper.findModule(moduleName);
|
|
1638
|
+
await this._generateOpenapi(total, openapiTypescript, config, moduleInfo, module, __caches);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
async _generateOpenapi(total, openapiTypescript, config, moduleInfo, module, __caches) {
|
|
1642
|
+
const {
|
|
1643
|
+
argv
|
|
1644
|
+
} = this.context;
|
|
1645
|
+
// config file
|
|
1646
|
+
const configFile = path.join(module.root, 'cli/openapi.config.ts');
|
|
1647
|
+
if (!fse.existsSync(configFile)) {
|
|
1648
|
+
throw new Error(`Please generate config of ${moduleInfo.relativeName} first!`);
|
|
1649
|
+
}
|
|
1650
|
+
const configInstance = await this.helper.importDynamic(configFile);
|
|
1651
|
+
const moduleConfigCli = await configInstance.default();
|
|
1652
|
+
const moduleConfig = extend(true, {
|
|
1653
|
+
apiMeta: false,
|
|
1654
|
+
apiSchema: true
|
|
1655
|
+
}, config.default, moduleConfigCli, config.modules[moduleInfo.relativeName]);
|
|
1656
|
+
const cache = await this._outputFiles(openapiTypescript, moduleConfig, moduleInfo, module, __caches);
|
|
1657
|
+
// generate
|
|
1658
|
+
await this._generateApis(openapiTypescript, cache.ast, moduleConfig, moduleInfo, module);
|
|
1659
|
+
// tools.metadata
|
|
1660
|
+
if (!argv.nometadata || total > 1) {
|
|
1661
|
+
await this.helper.invokeCli([':tools:metadata', moduleInfo.relativeName], {
|
|
1662
|
+
cwd: argv.projectPath
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
async _outputFiles(openapiTypescript, moduleConfig, _moduleInfo, module, __caches) {
|
|
1667
|
+
if (!moduleConfig.source) throw new Error('source not found');
|
|
1668
|
+
// cache
|
|
1669
|
+
let cache = __caches[moduleConfig.source];
|
|
1670
|
+
if (!cache) {
|
|
1671
|
+
const [ast, error] = await catchError(() => {
|
|
1672
|
+
return openapiTypescript.default(moduleConfig.source, _patchOpenapiTSOptions(moduleConfig.options));
|
|
1673
|
+
});
|
|
1674
|
+
if (error) {
|
|
1675
|
+
error.message = `${error.message}: ${moduleConfig.source}`;
|
|
1676
|
+
throw error;
|
|
1677
|
+
}
|
|
1678
|
+
const contents = openapiTypescript.astToString(ast);
|
|
1679
|
+
cache = __caches[moduleConfig.source] = {
|
|
1680
|
+
ast: ast,
|
|
1681
|
+
contents
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
// rimraf
|
|
1685
|
+
await rimraf(path.join(module.root, 'src/api'));
|
|
1686
|
+
// rimraf
|
|
1687
|
+
await rimraf(path.join(module.root, 'src/apiMeta'));
|
|
1688
|
+
// rimraf
|
|
1689
|
+
await rimraf(path.join(module.root, 'src/apiSchema'));
|
|
1690
|
+
// output: openapi/types.ts
|
|
1691
|
+
const outputFile = path.join(module.root, 'src/api/openapi/types.ts');
|
|
1692
|
+
await fse.outputFile(outputFile, cache.contents);
|
|
1693
|
+
await this.helper.formatFile({
|
|
1694
|
+
fileName: outputFile
|
|
1695
|
+
});
|
|
1696
|
+
// output: openapi/schemas.ts
|
|
1697
|
+
const schemasFile = path.join(module.root, 'src/api/openapi/schemas.ts');
|
|
1698
|
+
const contentSchemas = this._generateSchemas(cache.ast);
|
|
1699
|
+
await fse.outputFile(schemasFile, contentSchemas || 'export {}');
|
|
1700
|
+
await this.helper.formatFile({
|
|
1701
|
+
fileName: schemasFile
|
|
1702
|
+
});
|
|
1703
|
+
// output: openapi/baseURL.ts
|
|
1704
|
+
const baseURLFile = path.join(module.root, 'src/api/openapi/baseURL.ts');
|
|
1705
|
+
await fse.outputFile(baseURLFile, `import type { ZovaSys } from 'zova';
|
|
1706
|
+
|
|
1707
|
+
export const OpenApiBaseURL = (sys: ZovaSys) => {
|
|
1708
|
+
return sys.util.getOpenApiBaseURL('OPENAPI_BASE_URL_${module.name.replace('-', '_').toUpperCase()}');
|
|
1709
|
+
};
|
|
1710
|
+
`);
|
|
1711
|
+
await this.helper.formatFile({
|
|
1712
|
+
fileName: baseURLFile
|
|
1713
|
+
});
|
|
1714
|
+
// output: openapi/index.ts
|
|
1715
|
+
const indexFile = path.join(module.root, 'src/api/openapi/index.ts');
|
|
1716
|
+
await fse.outputFile(indexFile, "export * from './baseURL.js';\nexport * from './schemas.js';\nexport * from './types.js';");
|
|
1717
|
+
await this.helper.formatFile({
|
|
1718
|
+
fileName: indexFile
|
|
1719
|
+
});
|
|
1720
|
+
return cache;
|
|
1721
|
+
}
|
|
1722
|
+
_generateSchemas(ast) {
|
|
1723
|
+
const nodeComponents = ast.find(node => ts.isInterfaceDeclaration(node) && node.name.text === 'components');
|
|
1724
|
+
if (!nodeComponents) return '';
|
|
1725
|
+
const nodeTypeInfoComponents = _parseNodeType(nodeComponents);
|
|
1726
|
+
if (!nodeTypeInfoComponents.schemas) return '';
|
|
1727
|
+
const nodeTypeInfoSchemas = _parseNodeType(nodeTypeInfoComponents.schemas.nodeType);
|
|
1728
|
+
const typeSchemas = [];
|
|
1729
|
+
for (const key in nodeTypeInfoSchemas) {
|
|
1730
|
+
const schemaName = `ApiSchema${key.replaceAll('.', '-').split('-').map(item => toUpperCaseFirstChar(item)).join('')}`;
|
|
1731
|
+
typeSchemas.push(`export type ${schemaName} = components["schemas"]["${key}"];`);
|
|
1732
|
+
typeSchemas.push(`export type ${schemaName}Partial = Partial<${schemaName}>;`);
|
|
1733
|
+
}
|
|
1734
|
+
let contentSchemas = typeSchemas.join('\n');
|
|
1735
|
+
if (contentSchemas.includes('components["schemas"]')) {
|
|
1736
|
+
contentSchemas = `import type { components } from './types.js';\n${contentSchemas}`;
|
|
1737
|
+
}
|
|
1738
|
+
contentSchemas = `// eslint-disable\n${contentSchemas}`;
|
|
1739
|
+
return contentSchemas;
|
|
1740
|
+
}
|
|
1741
|
+
async _generateApis(openapiTypescript, ast, moduleConfig, _moduleInfo, module) {
|
|
1742
|
+
const nodeApis = this._getNodeApis(ast, moduleConfig);
|
|
1743
|
+
if (!nodeApis) return;
|
|
1744
|
+
for (const apiName in nodeApis) {
|
|
1745
|
+
const apiNameLower = toLowerCaseFirstChar(apiName);
|
|
1746
|
+
const nodeApi = nodeApis[apiName];
|
|
1747
|
+
const {
|
|
1748
|
+
apiContent,
|
|
1749
|
+
apiMetaContent,
|
|
1750
|
+
apiSchemaContent
|
|
1751
|
+
} = this._generateApi(openapiTypescript, ast, apiName, nodeApi);
|
|
1752
|
+
// api
|
|
1753
|
+
const apiFile = path.join(module.root, `src/api/${apiNameLower}.ts`);
|
|
1754
|
+
await fse.outputFile(apiFile, apiContent);
|
|
1755
|
+
await this.helper.formatFile({
|
|
1756
|
+
fileName: apiFile
|
|
1757
|
+
});
|
|
1758
|
+
// apiMeta
|
|
1759
|
+
if (moduleConfig.apiMeta) {
|
|
1760
|
+
const apiMetaFile = path.join(module.root, `src/apiMeta/${apiNameLower}.ts`);
|
|
1761
|
+
await fse.outputFile(apiMetaFile, apiMetaContent);
|
|
1762
|
+
await this.helper.formatFile({
|
|
1763
|
+
fileName: apiMetaFile
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
// apiSchema
|
|
1767
|
+
if (moduleConfig.apiSchema) {
|
|
1768
|
+
const apiSchemaFile = path.join(module.root, `src/apiSchema/${apiNameLower}.ts`);
|
|
1769
|
+
await fse.outputFile(apiSchemaFile, apiSchemaContent);
|
|
1770
|
+
await this.helper.formatFile({
|
|
1771
|
+
fileName: apiSchemaFile
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
_generateAction(openapiTypescript, ast, nodeActionInfo) {
|
|
1777
|
+
// pathInfo
|
|
1778
|
+
const pathInfo = _getRequestPathInfo(ast, nodeActionInfo);
|
|
1779
|
+
// contentTypes
|
|
1780
|
+
const contentTypes = [];
|
|
1781
|
+
contentTypes.push(`\n/** ${nodeActionInfo.operationId} */`);
|
|
1782
|
+
// name: ApiAction
|
|
1783
|
+
const nameApiAction = `Api${nodeActionInfo.api}${nodeActionInfo.action}`;
|
|
1784
|
+
// name: path
|
|
1785
|
+
const nameRequestPath = `Api${nameApiAction}Path`;
|
|
1786
|
+
contentTypes.push(`export const ${nameRequestPath} = '${pathInfo.path}';`);
|
|
1787
|
+
contentTypes.push(`export type ${nameRequestPath} = '${pathInfo.path}' `);
|
|
1788
|
+
// name: method
|
|
1789
|
+
const nameRequestMethod = `Api${nameApiAction}Method`;
|
|
1790
|
+
contentTypes.push(`export type ${nameRequestMethod} = '${pathInfo.method}';`);
|
|
1791
|
+
// name: params/query/headers
|
|
1792
|
+
const parametersInfo = {};
|
|
1793
|
+
const nodeTypeInfoParameters = _parseNodeType(nodeActionInfo.nodeTypeInfo.parameters.nodeType);
|
|
1794
|
+
// authToken
|
|
1795
|
+
let contentAuthToken = '';
|
|
1796
|
+
if (nodeActionInfo.nodeTypeInfo.authToken) {
|
|
1797
|
+
contentAuthToken = ', true';
|
|
1798
|
+
}
|
|
1799
|
+
for (const key of ['path', 'query', 'header']) {
|
|
1800
|
+
if (_isNodeNever(nodeTypeInfoParameters[key].nodeType)) continue;
|
|
1801
|
+
const key2 = key === 'path' ? 'params' : key === 'header' ? 'headers' : key;
|
|
1802
|
+
const key2Upper = toUpperCaseFirstChar(key2);
|
|
1803
|
+
const info = {
|
|
1804
|
+
name: `Api${nameApiAction}Request${key2Upper}`,
|
|
1805
|
+
question: nodeTypeInfoParameters[key].question
|
|
1806
|
+
};
|
|
1807
|
+
parametersInfo[key2] = info;
|
|
1808
|
+
contentTypes.push(`export type ${info.name} = paths[${nameRequestPath}][${nameRequestMethod}]['parameters']['${key}'];`);
|
|
1809
|
+
}
|
|
1810
|
+
// name: request body
|
|
1811
|
+
let nameRequestBody = '';
|
|
1812
|
+
let nameRequestBodyQuestion = true;
|
|
1813
|
+
let isUpload = false;
|
|
1814
|
+
if (!_isNodeNever(nodeActionInfo.nodeTypeInfo.requestBody.nodeType)) {
|
|
1815
|
+
nameRequestBody = `Api${nameApiAction}RequestBody`;
|
|
1816
|
+
nameRequestBodyQuestion = nodeActionInfo.nodeTypeInfo.requestBody.question;
|
|
1817
|
+
const nodeRequestBodyInfo = _parseNodeType(nodeActionInfo.nodeTypeInfo.requestBody.nodeType);
|
|
1818
|
+
const nodeRequestBodyContentInfo = _parseNodeType(nodeRequestBodyInfo.content.nodeType);
|
|
1819
|
+
const nodeRequestBodyApplicationJson = nodeRequestBodyContentInfo['application/json'] ?? nodeRequestBodyContentInfo['multipart/form-data'];
|
|
1820
|
+
isUpload = !!nodeRequestBodyContentInfo['multipart/form-data'];
|
|
1821
|
+
const typeRequestBody = openapiTypescript.astToString(nodeRequestBodyApplicationJson.nodeType);
|
|
1822
|
+
contentTypes.push(`export type ${nameRequestBody} = ${typeRequestBody};`);
|
|
1823
|
+
}
|
|
1824
|
+
// name: response body
|
|
1825
|
+
const nameResponseBody = `Api${nameApiAction}ResponseBody`;
|
|
1826
|
+
contentTypes.push(`export type ${nameResponseBody} = paths[${nameRequestPath}][${nameRequestMethod}]['responses']['200']['content']['application/json']['data'];`);
|
|
1827
|
+
// content: options
|
|
1828
|
+
const contentOptions = [];
|
|
1829
|
+
let contentOptionsQuestion = true;
|
|
1830
|
+
for (const key of ['params', 'query', 'headers']) {
|
|
1831
|
+
const info = parametersInfo[key];
|
|
1832
|
+
if (!info) continue;
|
|
1833
|
+
if (!info.question) contentOptionsQuestion = false;
|
|
1834
|
+
contentOptions.push(`${key}${_q(info.question)}: ${info.name};`);
|
|
1835
|
+
}
|
|
1836
|
+
const contentOptions2 = contentOptions.length > 0 ? `options${_q(contentOptionsQuestion)}: {\n${contentOptions.join('\n')}\n} & IApiActionOptions,` : `options${_q(contentOptionsQuestion)}: IApiActionOptions,`;
|
|
1837
|
+
// content: request body
|
|
1838
|
+
let contentRequestBody = '';
|
|
1839
|
+
if (!['get', 'delete'].includes(pathInfo.method)) {
|
|
1840
|
+
if (!nameRequestBody) {
|
|
1841
|
+
contentRequestBody = `body${_q(contentOptionsQuestion)}: undefined,`;
|
|
1842
|
+
} else {
|
|
1843
|
+
if (nameRequestBodyQuestion) {
|
|
1844
|
+
contentRequestBody = `body${_q(contentOptionsQuestion)}: ${nameRequestBody} | undefined,`;
|
|
1845
|
+
} else {
|
|
1846
|
+
contentRequestBody = `body: ${nameRequestBody},`;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
// content: path translate
|
|
1851
|
+
const contentPathTranslate = parametersInfo.params ? `this.$pathTranslate(${nameRequestPath}, options${_q(contentOptionsQuestion)}.params),` : `${nameRequestPath},`;
|
|
1852
|
+
// content: comment
|
|
1853
|
+
const contentComments = pathInfo.comments && pathInfo.comments.length > 0 ? `/*${pathInfo.comments.join()}*/\n` : '';
|
|
1854
|
+
// content: body
|
|
1855
|
+
const contentBodyParams = isUpload ? 'this.$formData(body)' : 'body';
|
|
1856
|
+
// content: signature
|
|
1857
|
+
const contentSignature = `${contentComments}${nodeActionInfo.action}(
|
|
1858
|
+
${contentRequestBody}
|
|
1859
|
+
${contentOptions2}
|
|
1860
|
+
) {
|
|
1861
|
+
return this.$fetch.${pathInfo.method}<any, ${nameResponseBody}>(
|
|
1862
|
+
${contentPathTranslate} ${contentRequestBody ? `${contentBodyParams},` : ''}
|
|
1863
|
+
this.$configPrepare(OpenApiBaseURL(this.sys), options${contentAuthToken}),
|
|
1864
|
+
);
|
|
1865
|
+
}\n`;
|
|
1866
|
+
return [contentTypes.join('\n'), contentSignature, nodeActionInfo.action, nameRequestPath, pathInfo.method];
|
|
1867
|
+
}
|
|
1868
|
+
_generateApi(openapiTypescript, ast, apiName, nodeApi) {
|
|
1869
|
+
const apiNameLower = toLowerCaseFirstChar(apiName);
|
|
1870
|
+
const contentTypes = [];
|
|
1871
|
+
const contentSignatures = [];
|
|
1872
|
+
const contentActions = [];
|
|
1873
|
+
const contentApiPaths = [];
|
|
1874
|
+
const contentApiMethods = [];
|
|
1875
|
+
for (const actionName in nodeApi) {
|
|
1876
|
+
const nodeActionInfo = nodeApi[actionName];
|
|
1877
|
+
const contentAction = this._generateAction(openapiTypescript, ast, nodeActionInfo);
|
|
1878
|
+
const [_contentType, _contentSignature, _action, _apiPath, _apiMethod] = contentAction;
|
|
1879
|
+
contentTypes.push(_contentType);
|
|
1880
|
+
contentSignatures.push(_contentSignature);
|
|
1881
|
+
contentActions.push(_action);
|
|
1882
|
+
contentApiPaths.push(_apiPath);
|
|
1883
|
+
contentApiMethods.push(_apiMethod);
|
|
1884
|
+
}
|
|
1885
|
+
//
|
|
1886
|
+
const contentTypes2 = contentTypes.join('\n');
|
|
1887
|
+
const importsType = [];
|
|
1888
|
+
if (contentSignatures.length > 0) importsType.push('OpenApiBaseURL');
|
|
1889
|
+
if (contentTypes2.includes('components["schemas"]')) importsType.push('type components');
|
|
1890
|
+
if (contentTypes2.includes('paths[')) importsType.push('type paths');
|
|
1891
|
+
const contentImportsType = importsType.length > 0 ? `import { ${importsType.join(', ')} } from './openapi/index.js';` : '';
|
|
1892
|
+
// apiContent
|
|
1893
|
+
const apiContent = `import { Api, BeanApiBase, IApiActionOptions } from 'zova-module-a-api';
|
|
1894
|
+
${contentImportsType}
|
|
1895
|
+
|
|
1896
|
+
${contentTypes2}
|
|
1897
|
+
|
|
1898
|
+
@Api()
|
|
1899
|
+
export class Api${apiName} extends BeanApiBase {
|
|
1900
|
+
${contentSignatures.join('\n')}
|
|
1901
|
+
}
|
|
1902
|
+
`;
|
|
1903
|
+
// apiMetaContent/apiSchemaContent
|
|
1904
|
+
const importsApiPath = [];
|
|
1905
|
+
const contentMetaSignatures = [];
|
|
1906
|
+
const contentSchemaSignatures = [];
|
|
1907
|
+
for (let i = 0; i < contentActions.length; i++) {
|
|
1908
|
+
importsApiPath.push(contentApiPaths[i]);
|
|
1909
|
+
contentMetaSignatures.push(`get ${contentActions[i]}() {
|
|
1910
|
+
return [${contentApiPaths[i]}, '${contentApiMethods[i]}'];
|
|
1911
|
+
}
|
|
1912
|
+
`);
|
|
1913
|
+
contentSchemaSignatures.push(`${contentActions[i]}(options?: IApiSchemaOptions) {
|
|
1914
|
+
return this.$sdk.createApiSchemas(${contentApiPaths[i]}, '${contentApiMethods[i]}', options);
|
|
1915
|
+
}
|
|
1916
|
+
`);
|
|
1917
|
+
}
|
|
1918
|
+
const contentImportsApiPath = importsApiPath.length > 0 ? `import { ${importsApiPath.join(', ')} } from '../api/${apiNameLower}.js';` : '';
|
|
1919
|
+
const apiMetaContent = `import { BeanBase } from 'zova';
|
|
1920
|
+
import { ApiMeta } from 'zova-module-a-api';
|
|
1921
|
+
${contentImportsApiPath}
|
|
1922
|
+
|
|
1923
|
+
@ApiMeta()
|
|
1924
|
+
export class ApiMeta${apiName} extends BeanBase {
|
|
1925
|
+
${contentMetaSignatures.join('\n')}
|
|
1926
|
+
}
|
|
1927
|
+
`;
|
|
1928
|
+
const apiSchemaContent = `import { BeanBase } from 'zova';
|
|
1929
|
+
import { ApiSchema, IApiSchemaOptions } from 'zova-module-a-api';
|
|
1930
|
+
${contentImportsApiPath}
|
|
1931
|
+
|
|
1932
|
+
@ApiSchema()
|
|
1933
|
+
export class ApiSchema${apiName} extends BeanBase {
|
|
1934
|
+
${contentSchemaSignatures.join('\n')}
|
|
1935
|
+
}
|
|
1936
|
+
`;
|
|
1937
|
+
return {
|
|
1938
|
+
apiContent,
|
|
1939
|
+
apiMetaContent,
|
|
1940
|
+
apiSchemaContent
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
_getNodeApis(ast, moduleConfig) {
|
|
1944
|
+
const nodeOperations = ast.find(node => ts.isInterfaceDeclaration(node) && node.name.text === 'operations');
|
|
1945
|
+
if (!nodeOperations) return;
|
|
1946
|
+
const apis = {};
|
|
1947
|
+
for (let index = 0; index < nodeOperations.members.length; index++) {
|
|
1948
|
+
const node = nodeOperations.members[index];
|
|
1949
|
+
if (!ts.isPropertySignature(node)) continue;
|
|
1950
|
+
const operationId = node.name.text;
|
|
1951
|
+
if (!_checkOperationIdEnabled(moduleConfig, operationId)) continue;
|
|
1952
|
+
let [api, action] = operationId.toString().split('_');
|
|
1953
|
+
if (!action) {
|
|
1954
|
+
action = api;
|
|
1955
|
+
api = 'default';
|
|
1956
|
+
}
|
|
1957
|
+
if (!apis[api]) {
|
|
1958
|
+
apis[api] = {};
|
|
1959
|
+
}
|
|
1960
|
+
apis[api][action] = {
|
|
1961
|
+
api,
|
|
1962
|
+
apiLower: toLowerCaseFirstChar(api),
|
|
1963
|
+
action,
|
|
1964
|
+
operationId,
|
|
1965
|
+
node,
|
|
1966
|
+
nodeTypeInfo: _parseNodeType(node.type)
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
return apis;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
function _getRequestPathInfo(ast, nodeActionInfo) {
|
|
1973
|
+
const nodePaths = ast.find(node => ts.isInterfaceDeclaration(node) && node.name.text === 'paths');
|
|
1974
|
+
if (!nodePaths) throw new Error('paths not found');
|
|
1975
|
+
let path;
|
|
1976
|
+
let method;
|
|
1977
|
+
let comments;
|
|
1978
|
+
const nodePath = nodePaths.members.find(node => {
|
|
1979
|
+
if (!ts.isPropertySignature(node)) return false;
|
|
1980
|
+
if (!node.type || !ts.isTypeLiteralNode(node.type)) return false;
|
|
1981
|
+
path = node.name.text;
|
|
1982
|
+
const nodeMethod = node.type.members.find(item => {
|
|
1983
|
+
if (!ts.isPropertySignature(item)) return false;
|
|
1984
|
+
if (!item.type || !ts.isIndexedAccessTypeNode(item.type)) return false;
|
|
1985
|
+
const operationId = item.type.indexType.literal.text;
|
|
1986
|
+
if (operationId !== nodeActionInfo.operationId) return false;
|
|
1987
|
+
method = item.name.text;
|
|
1988
|
+
// comment
|
|
1989
|
+
const nodeComments = item.emitNode?.leadingComments;
|
|
1990
|
+
if (nodeComments) {
|
|
1991
|
+
comments = nodeComments.map(nodeComment => nodeComment.text);
|
|
1992
|
+
}
|
|
1993
|
+
return true;
|
|
1994
|
+
});
|
|
1995
|
+
return !!nodeMethod;
|
|
1996
|
+
});
|
|
1997
|
+
if (!nodePath) throw new Error('path not found');
|
|
1998
|
+
return {
|
|
1999
|
+
path,
|
|
2000
|
+
method,
|
|
2001
|
+
comments,
|
|
2002
|
+
nodePath
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
function _parseNodeType(nodeType) {
|
|
2006
|
+
if (!nodeType || !nodeType.members) return;
|
|
2007
|
+
const nodeTypeInfo = {};
|
|
2008
|
+
nodeType.members.forEach(node => {
|
|
2009
|
+
if (!ts.isPropertySignature(node)) return;
|
|
2010
|
+
const name = node.name.text;
|
|
2011
|
+
const value = node.type;
|
|
2012
|
+
nodeTypeInfo[name] = {
|
|
2013
|
+
question: !!node.questionToken,
|
|
2014
|
+
nodeType: value
|
|
2015
|
+
};
|
|
2016
|
+
});
|
|
2017
|
+
return nodeTypeInfo;
|
|
2018
|
+
}
|
|
2019
|
+
function _isNodeNever(node) {
|
|
2020
|
+
return node.kind === ts.SyntaxKind.NeverKeyword;
|
|
2021
|
+
}
|
|
2022
|
+
function _q(question) {
|
|
2023
|
+
return question ? '?' : '';
|
|
2024
|
+
}
|
|
2025
|
+
function _checkOperationIdEnabled(moduleConfig, selector) {
|
|
2026
|
+
if (!selector) return false;
|
|
2027
|
+
if (!moduleConfig.operations?.match && !moduleConfig.operations?.ignore) return true;
|
|
2028
|
+
return moduleConfig.operations?.match && matchSelector(moduleConfig.operations?.match, selector) || moduleConfig.operations?.ignore && !matchSelector(moduleConfig.operations?.ignore, selector);
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
/**
|
|
2032
|
+
* https://github.com/openapi-ts/openapi-typescript/issues/1214
|
|
2033
|
+
* https://openapi-ts.dev/node#example-blob-types
|
|
2034
|
+
*/
|
|
2035
|
+
const BLOB = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Blob')); // `Blob`
|
|
2036
|
+
const DATE = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Date')); // `Date`
|
|
2037
|
+
// const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); // `null`
|
|
2038
|
+
const UNDEFINED = ts.factory.createKeywordTypeNode(ts.SyntaxKind.UndefinedKeyword);
|
|
2039
|
+
function _patchOpenapiTSOptions(options) {
|
|
2040
|
+
const transformCustom = options?.transform;
|
|
2041
|
+
const postTransformCustom = options?.postTransform;
|
|
2042
|
+
return Object.assign({
|
|
2043
|
+
defaultNonNullable: false
|
|
2044
|
+
}, options, {
|
|
2045
|
+
transform(schemaObject, options) {
|
|
2046
|
+
if (transformCustom) {
|
|
2047
|
+
const res = transformCustom(schemaObject, options);
|
|
2048
|
+
if (res !== undefined) return res;
|
|
2049
|
+
}
|
|
2050
|
+
// multipart
|
|
2051
|
+
if (schemaObject.format === 'binary') {
|
|
2052
|
+
if (options.path?.includes('multipart~1form-data') || options.path?.includes('application~1octet-stream')) {
|
|
2053
|
+
return {
|
|
2054
|
+
// schema: schemaObject.nullable
|
|
2055
|
+
// ? ts.factory.createUnionTypeNode([BLOB, NULL])
|
|
2056
|
+
// : BLOB,
|
|
2057
|
+
schema: BLOB,
|
|
2058
|
+
questionToken: schemaObject.nullable
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
} else if (schemaObject.format === 'date') {
|
|
2062
|
+
return {
|
|
2063
|
+
schema: DATE,
|
|
2064
|
+
questionToken: schemaObject.nullable
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
// default
|
|
2068
|
+
return undefined;
|
|
2069
|
+
},
|
|
2070
|
+
postTransform(type, options) {
|
|
2071
|
+
if (postTransformCustom) {
|
|
2072
|
+
const res = postTransformCustom(type, options);
|
|
2073
|
+
if (res !== undefined) return res;
|
|
2074
|
+
}
|
|
2075
|
+
// path param
|
|
2076
|
+
const paramMatched = options.path?.match(/parameters\/path\/([^/]+)$/);
|
|
2077
|
+
if (paramMatched) {
|
|
2078
|
+
const paramName = paramMatched[1];
|
|
2079
|
+
if (options.path?.includes(`{${paramName}?}`)) {
|
|
2080
|
+
return ts.factory.createUnionTypeNode([type, UNDEFINED]);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
class CliRefactorAnotherRender extends BeanCliBase {
|
|
2088
|
+
async execute() {
|
|
2089
|
+
const {
|
|
2090
|
+
argv
|
|
2091
|
+
} = this.context;
|
|
2092
|
+
// super
|
|
2093
|
+
await super.execute();
|
|
2094
|
+
// module name/info
|
|
2095
|
+
const moduleName = argv.module;
|
|
2096
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2097
|
+
// check if exists
|
|
2098
|
+
const _module = this.helper.findModule(moduleName);
|
|
2099
|
+
if (!_module) {
|
|
2100
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2101
|
+
}
|
|
2102
|
+
// target dir
|
|
2103
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2104
|
+
// componentName
|
|
2105
|
+
const componentName = argv.componentName;
|
|
2106
|
+
// nameMeta
|
|
2107
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component', 'page']);
|
|
2108
|
+
argv.renderNameCapitalize = this.helper.firstCharToUpperCase(argv.renderName);
|
|
2109
|
+
argv.renderClassName = `Render${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.renderNameCapitalize}`;
|
|
2110
|
+
// directory
|
|
2111
|
+
const componentDir = path.join(targetDir, 'src', argv.nameMeta.original);
|
|
2112
|
+
if (!fs.existsSync(componentDir)) {
|
|
2113
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2114
|
+
}
|
|
2115
|
+
const renderFile = path.join(componentDir, `render.${argv.renderName}.tsx`);
|
|
2116
|
+
if (fs.existsSync(renderFile)) {
|
|
2117
|
+
throw new Error(`render exists: ${renderFile}`);
|
|
2118
|
+
}
|
|
2119
|
+
// render file must exists
|
|
2120
|
+
const renderFileFirst = path.join(componentDir, 'render.tsx');
|
|
2121
|
+
if (!fs.existsSync(renderFileFirst)) {
|
|
2122
|
+
await this.helper.invokeCli([':refactor:firstRender', argv.componentName, `--module=${moduleName}`], {
|
|
2123
|
+
cwd: argv.projectPath
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
// render boilerplate
|
|
2127
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2128
|
+
targetDir: componentDir,
|
|
2129
|
+
setName: __ThisSetName__,
|
|
2130
|
+
snippetsPath: 'refactor/anotherRender/snippets',
|
|
2131
|
+
boilerplatePath: 'refactor/anotherRender/boilerplate'
|
|
2132
|
+
});
|
|
2133
|
+
// tools.metadata
|
|
2134
|
+
if (!argv.nometadata) {
|
|
2135
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2136
|
+
cwd: argv.projectPath
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
class CliRefactorAnotherStyle extends BeanCliBase {
|
|
2143
|
+
async execute() {
|
|
2144
|
+
const {
|
|
2145
|
+
argv
|
|
2146
|
+
} = this.context;
|
|
2147
|
+
// super
|
|
2148
|
+
await super.execute();
|
|
2149
|
+
// module name/info
|
|
2150
|
+
const moduleName = argv.module;
|
|
2151
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2152
|
+
// check if exists
|
|
2153
|
+
const _module = this.helper.findModule(moduleName);
|
|
2154
|
+
if (!_module) {
|
|
2155
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2156
|
+
}
|
|
2157
|
+
// target dir
|
|
2158
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2159
|
+
// componentName
|
|
2160
|
+
const componentName = argv.componentName;
|
|
2161
|
+
// nameMeta
|
|
2162
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component', 'page']);
|
|
2163
|
+
argv.styleNameCapitalize = this.helper.firstCharToUpperCase(argv.styleName);
|
|
2164
|
+
argv.styleClassName = `Style${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.styleNameCapitalize}`;
|
|
2165
|
+
argv.controllerClassName = `Controller${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.nameMeta.shortCapitalize}`;
|
|
2166
|
+
// directory
|
|
2167
|
+
const componentDir = path.join(targetDir, 'src', argv.nameMeta.original);
|
|
2168
|
+
if (!fs.existsSync(componentDir)) {
|
|
2169
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2170
|
+
}
|
|
2171
|
+
const styleFile = path.join(componentDir, `style.${argv.styleName}.ts`);
|
|
2172
|
+
if (fs.existsSync(styleFile)) {
|
|
2173
|
+
throw new Error(`style exists: ${styleFile}`);
|
|
2174
|
+
}
|
|
2175
|
+
// style file must exists
|
|
2176
|
+
const styleFileFirst = path.join(componentDir, 'style.ts');
|
|
2177
|
+
if (!fs.existsSync(styleFileFirst)) {
|
|
2178
|
+
await this.helper.invokeCli([':refactor:firstStyle', argv.componentName, `--module=${moduleName}`], {
|
|
2179
|
+
cwd: argv.projectPath
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
// render boilerplate
|
|
2183
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2184
|
+
targetDir: componentDir,
|
|
2185
|
+
setName: __ThisSetName__,
|
|
2186
|
+
snippetsPath: 'refactor/anotherStyle/snippets',
|
|
2187
|
+
boilerplatePath: 'refactor/anotherStyle/boilerplate'
|
|
2188
|
+
});
|
|
2189
|
+
// tools.metadata
|
|
2190
|
+
if (!argv.nometadata) {
|
|
2191
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2192
|
+
cwd: argv.projectPath
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
function getControllerFileName(module, type, beanName) {
|
|
2199
|
+
const controllerFile = path.join(module.root, `src/${type}/${beanName}/controller.ts`);
|
|
2200
|
+
if (fs.existsSync(controllerFile)) {
|
|
2201
|
+
return 'controller.ts';
|
|
2202
|
+
}
|
|
2203
|
+
return 'controller.tsx';
|
|
2204
|
+
}
|
|
2205
|
+
async function loadJSONFile(fileName) {
|
|
2206
|
+
const pkgContent = (await fse.readFile(fileName)).toString();
|
|
2207
|
+
return JSON.parse(pkgContent);
|
|
2208
|
+
}
|
|
2209
|
+
async function saveJSONFile(fileName, json) {
|
|
2210
|
+
await fse.writeFile(fileName, `${JSON.stringify(json, null, 2)}\n`);
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
class CliRefactorComponentEmits extends BeanCliBase {
|
|
2214
|
+
async execute() {
|
|
2215
|
+
const {
|
|
2216
|
+
argv
|
|
2217
|
+
} = this.context;
|
|
2218
|
+
// super
|
|
2219
|
+
await super.execute();
|
|
2220
|
+
// module name/info
|
|
2221
|
+
const moduleName = argv.module;
|
|
2222
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2223
|
+
// check if exists
|
|
2224
|
+
const _module = this.helper.findModule(moduleName);
|
|
2225
|
+
if (!_module) {
|
|
2226
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2227
|
+
}
|
|
2228
|
+
// target dir
|
|
2229
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2230
|
+
// componentName
|
|
2231
|
+
const componentName = argv.componentName;
|
|
2232
|
+
// nameMeta
|
|
2233
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component']);
|
|
2234
|
+
argv.controllerClassName = `Controller${argv.nameMeta.shortCapitalize}`;
|
|
2235
|
+
argv.controllerFileName = getControllerFileName(_module, 'component', argv.nameMeta.short);
|
|
2236
|
+
// directory
|
|
2237
|
+
const componentDir = path.join(targetDir, 'src/component', argv.nameMeta.short);
|
|
2238
|
+
if (!fs.existsSync(componentDir)) {
|
|
2239
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2240
|
+
}
|
|
2241
|
+
// render boilerplate
|
|
2242
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2243
|
+
targetDir: componentDir,
|
|
2244
|
+
setName: __ThisSetName__,
|
|
2245
|
+
snippetsPath: 'refactor/componentEmits/snippets',
|
|
2246
|
+
boilerplatePath: null
|
|
2247
|
+
});
|
|
2248
|
+
// tools.metadata
|
|
2249
|
+
if (!argv.nometadata) {
|
|
2250
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2251
|
+
cwd: argv.projectPath
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
class CliRefactorComponentGeneric extends BeanCliBase {
|
|
2258
|
+
async execute() {
|
|
2259
|
+
const {
|
|
2260
|
+
argv
|
|
2261
|
+
} = this.context;
|
|
2262
|
+
// super
|
|
2263
|
+
await super.execute();
|
|
2264
|
+
// module name/info
|
|
2265
|
+
const moduleName = argv.module;
|
|
2266
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2267
|
+
// check if exists
|
|
2268
|
+
const _module = this.helper.findModule(moduleName);
|
|
2269
|
+
if (!_module) {
|
|
2270
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2271
|
+
}
|
|
2272
|
+
// target dir
|
|
2273
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2274
|
+
// componentName
|
|
2275
|
+
const componentName = argv.componentName;
|
|
2276
|
+
// nameMeta
|
|
2277
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component']);
|
|
2278
|
+
argv.controllerClassName = `Controller${argv.nameMeta.shortCapitalize}`;
|
|
2279
|
+
argv.controllerFileName = getControllerFileName(_module, 'component', argv.nameMeta.short);
|
|
2280
|
+
// directory
|
|
2281
|
+
const componentDir = path.join(targetDir, 'src/component', argv.nameMeta.short);
|
|
2282
|
+
if (!fs.existsSync(componentDir)) {
|
|
2283
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2284
|
+
}
|
|
2285
|
+
// render boilerplate
|
|
2286
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2287
|
+
targetDir: componentDir,
|
|
2288
|
+
setName: __ThisSetName__,
|
|
2289
|
+
snippetsPath: 'refactor/componentGeneric/snippets',
|
|
2290
|
+
boilerplatePath: null
|
|
2291
|
+
});
|
|
2292
|
+
// tools.metadata
|
|
2293
|
+
if (!argv.nometadata) {
|
|
2294
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2295
|
+
cwd: argv.projectPath
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
class CliRefactorComponentModel extends BeanCliBase {
|
|
2302
|
+
async execute() {
|
|
2303
|
+
const {
|
|
2304
|
+
argv
|
|
2305
|
+
} = this.context;
|
|
2306
|
+
// super
|
|
2307
|
+
await super.execute();
|
|
2308
|
+
// module name/info
|
|
2309
|
+
const moduleName = argv.module;
|
|
2310
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2311
|
+
// check if exists
|
|
2312
|
+
const _module = this.helper.findModule(moduleName);
|
|
2313
|
+
if (!_module) {
|
|
2314
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2315
|
+
}
|
|
2316
|
+
// target dir
|
|
2317
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2318
|
+
// componentName
|
|
2319
|
+
const componentName = argv.componentName;
|
|
2320
|
+
// nameMeta
|
|
2321
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component']);
|
|
2322
|
+
argv.controllerClassName = `Controller${argv.nameMeta.shortCapitalize}`;
|
|
2323
|
+
argv.controllerFileName = getControllerFileName(_module, 'component', argv.nameMeta.short);
|
|
2324
|
+
// directory
|
|
2325
|
+
const componentDir = path.join(targetDir, 'src/component', argv.nameMeta.short);
|
|
2326
|
+
if (!fs.existsSync(componentDir)) {
|
|
2327
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2328
|
+
}
|
|
2329
|
+
// props
|
|
2330
|
+
for (const cmd of ['componentProps']) {
|
|
2331
|
+
try {
|
|
2332
|
+
await this.helper.invokeCli([`:refactor:${cmd}`, componentName, `--module=${moduleName}`], {
|
|
2333
|
+
cwd: argv.projectPath
|
|
2334
|
+
});
|
|
2335
|
+
} catch (_) {}
|
|
2336
|
+
}
|
|
2337
|
+
// render boilerplate
|
|
2338
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2339
|
+
targetDir: componentDir,
|
|
2340
|
+
setName: __ThisSetName__,
|
|
2341
|
+
snippetsPath: 'refactor/componentModel/snippets',
|
|
2342
|
+
boilerplatePath: null
|
|
2343
|
+
});
|
|
2344
|
+
// tools.metadata
|
|
2345
|
+
if (!argv.nometadata) {
|
|
2346
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2347
|
+
cwd: argv.projectPath
|
|
2348
|
+
});
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
class CliRefactorComponentProps extends BeanCliBase {
|
|
2354
|
+
async execute() {
|
|
2355
|
+
const {
|
|
2356
|
+
argv
|
|
2357
|
+
} = this.context;
|
|
2358
|
+
// super
|
|
2359
|
+
await super.execute();
|
|
2360
|
+
// module name/info
|
|
2361
|
+
const moduleName = argv.module;
|
|
2362
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2363
|
+
// check if exists
|
|
2364
|
+
const _module = this.helper.findModule(moduleName);
|
|
2365
|
+
if (!_module) {
|
|
2366
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2367
|
+
}
|
|
2368
|
+
// target dir
|
|
2369
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2370
|
+
// componentName
|
|
2371
|
+
const componentName = argv.componentName;
|
|
2372
|
+
// nameMeta
|
|
2373
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component']);
|
|
2374
|
+
argv.controllerClassName = `Controller${argv.nameMeta.shortCapitalize}`;
|
|
2375
|
+
argv.controllerFileName = getControllerFileName(_module, 'component', argv.nameMeta.short);
|
|
2376
|
+
// directory
|
|
2377
|
+
const componentDir = path.join(targetDir, 'src/component', argv.nameMeta.short);
|
|
2378
|
+
if (!fs.existsSync(componentDir)) {
|
|
2379
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2380
|
+
}
|
|
2381
|
+
// render boilerplate
|
|
2382
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2383
|
+
targetDir: componentDir,
|
|
2384
|
+
setName: __ThisSetName__,
|
|
2385
|
+
snippetsPath: 'refactor/componentProps/snippets',
|
|
2386
|
+
boilerplatePath: null
|
|
2387
|
+
});
|
|
2388
|
+
// tools.metadata
|
|
2389
|
+
if (!argv.nometadata) {
|
|
2390
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2391
|
+
cwd: argv.projectPath
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
class CliRefactorComponentSlots extends BeanCliBase {
|
|
2398
|
+
async execute() {
|
|
2399
|
+
const {
|
|
2400
|
+
argv
|
|
2401
|
+
} = this.context;
|
|
2402
|
+
// super
|
|
2403
|
+
await super.execute();
|
|
2404
|
+
// module name/info
|
|
2405
|
+
const moduleName = argv.module;
|
|
2406
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2407
|
+
// check if exists
|
|
2408
|
+
const _module = this.helper.findModule(moduleName);
|
|
2409
|
+
if (!_module) {
|
|
2410
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2411
|
+
}
|
|
2412
|
+
// target dir
|
|
2413
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2414
|
+
// componentName
|
|
2415
|
+
const componentName = argv.componentName;
|
|
2416
|
+
// nameMeta
|
|
2417
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component']);
|
|
2418
|
+
argv.controllerClassName = `Controller${argv.nameMeta.shortCapitalize}`;
|
|
2419
|
+
argv.controllerFileName = getControllerFileName(_module, 'component', argv.nameMeta.short);
|
|
2420
|
+
// directory
|
|
2421
|
+
const componentDir = path.join(targetDir, 'src/component', argv.nameMeta.short);
|
|
2422
|
+
if (!fs.existsSync(componentDir)) {
|
|
2423
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2424
|
+
}
|
|
2425
|
+
// render boilerplate
|
|
2426
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2427
|
+
targetDir: componentDir,
|
|
2428
|
+
setName: __ThisSetName__,
|
|
2429
|
+
snippetsPath: 'refactor/componentSlots/snippets',
|
|
2430
|
+
boilerplatePath: null
|
|
2431
|
+
});
|
|
2432
|
+
// tools.metadata
|
|
2433
|
+
if (!argv.nometadata) {
|
|
2434
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2435
|
+
cwd: argv.projectPath
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
class CliRefactorFirstRender extends BeanCliBase {
|
|
2442
|
+
async execute() {
|
|
2443
|
+
const {
|
|
2444
|
+
argv
|
|
2445
|
+
} = this.context;
|
|
2446
|
+
// super
|
|
2447
|
+
await super.execute();
|
|
2448
|
+
// module name/info
|
|
2449
|
+
const moduleName = argv.module;
|
|
2450
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2451
|
+
// check if exists
|
|
2452
|
+
const _module = this.helper.findModule(moduleName);
|
|
2453
|
+
if (!_module) {
|
|
2454
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2455
|
+
}
|
|
2456
|
+
// target dir
|
|
2457
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2458
|
+
// componentName
|
|
2459
|
+
const componentName = argv.componentName;
|
|
2460
|
+
// nameMeta
|
|
2461
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component', 'page']);
|
|
2462
|
+
argv.renderName = 'render';
|
|
2463
|
+
argv.renderNameCapitalize = this.helper.firstCharToUpperCase(argv.renderName);
|
|
2464
|
+
argv.renderClassName = `Render${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.nameMeta.shortCapitalize}`;
|
|
2465
|
+
// directory
|
|
2466
|
+
const componentDir = path.join(targetDir, 'src', argv.nameMeta.original);
|
|
2467
|
+
if (!fs.existsSync(componentDir)) {
|
|
2468
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2469
|
+
}
|
|
2470
|
+
const renderFile = path.join(componentDir, `${argv.renderName}.tsx`);
|
|
2471
|
+
if (fs.existsSync(renderFile)) {
|
|
2472
|
+
throw new Error(`render exists: ${renderFile}`);
|
|
2473
|
+
}
|
|
2474
|
+
// render boilerplate
|
|
2475
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2476
|
+
targetDir: componentDir,
|
|
2477
|
+
setName: __ThisSetName__,
|
|
2478
|
+
snippetsPath: null,
|
|
2479
|
+
boilerplatePath: 'refactor/firstRender/boilerplate'
|
|
2480
|
+
});
|
|
2481
|
+
// controller render
|
|
2482
|
+
let controllerFile = path.join(componentDir, 'controller.tsx');
|
|
2483
|
+
if (!fs.existsSync(controllerFile)) {
|
|
2484
|
+
controllerFile = path.join(componentDir, 'controller.ts');
|
|
2485
|
+
}
|
|
2486
|
+
let controllerContent = (await fse.readFile(controllerFile)).toString();
|
|
2487
|
+
controllerContent = controllerContent.replace('protected render() {', 'protected _render() {');
|
|
2488
|
+
await fse.writeFile(controllerFile, controllerContent);
|
|
2489
|
+
// tools.metadata
|
|
2490
|
+
if (!argv.nometadata) {
|
|
2491
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2492
|
+
cwd: argv.projectPath
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
class CliRefactorFirstStyle extends BeanCliBase {
|
|
2499
|
+
async execute() {
|
|
2500
|
+
const {
|
|
2501
|
+
argv
|
|
2502
|
+
} = this.context;
|
|
2503
|
+
// super
|
|
2504
|
+
await super.execute();
|
|
2505
|
+
// module name/info
|
|
2506
|
+
const moduleName = argv.module;
|
|
2507
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2508
|
+
// check if exists
|
|
2509
|
+
const _module = this.helper.findModule(moduleName);
|
|
2510
|
+
if (!_module) {
|
|
2511
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2512
|
+
}
|
|
2513
|
+
// target dir
|
|
2514
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2515
|
+
// componentName
|
|
2516
|
+
const componentName = argv.componentName;
|
|
2517
|
+
// nameMeta
|
|
2518
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component', 'page']);
|
|
2519
|
+
argv.styleName = 'style';
|
|
2520
|
+
argv.styleNameCapitalize = this.helper.firstCharToUpperCase(argv.styleName);
|
|
2521
|
+
argv.styleClassName = `Style${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.nameMeta.shortCapitalize}`;
|
|
2522
|
+
argv.controllerClassName = `Controller${argv.nameMeta.directory === 'page' ? 'Page' : ''}${argv.nameMeta.shortCapitalize}`;
|
|
2523
|
+
// directory
|
|
2524
|
+
const componentDir = path.join(targetDir, 'src', argv.nameMeta.original);
|
|
2525
|
+
if (!fs.existsSync(componentDir)) {
|
|
2526
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2527
|
+
}
|
|
2528
|
+
const styleFile = path.join(componentDir, `${argv.styleName}.ts`);
|
|
2529
|
+
if (fs.existsSync(styleFile)) {
|
|
2530
|
+
throw new Error(`style exists: ${styleFile}`);
|
|
2531
|
+
}
|
|
2532
|
+
// render file must exists
|
|
2533
|
+
const renderFile = path.join(componentDir, 'render.tsx');
|
|
2534
|
+
if (!fs.existsSync(renderFile)) {
|
|
2535
|
+
await this.helper.invokeCli([':refactor:firstRender', argv.componentName, `--module=${moduleName}`], {
|
|
2536
|
+
cwd: argv.projectPath
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
// render boilerplate
|
|
2540
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2541
|
+
targetDir: componentDir,
|
|
2542
|
+
setName: __ThisSetName__,
|
|
2543
|
+
snippetsPath: null,
|
|
2544
|
+
boilerplatePath: 'refactor/firstStyle/boilerplate'
|
|
2545
|
+
});
|
|
2546
|
+
// tools.metadata
|
|
2547
|
+
if (!argv.nometadata) {
|
|
2548
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2549
|
+
cwd: argv.projectPath
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
class CliRefactorPageParams extends BeanCliBase {
|
|
2556
|
+
async execute() {
|
|
2557
|
+
const {
|
|
2558
|
+
argv
|
|
2559
|
+
} = this.context;
|
|
2560
|
+
// super
|
|
2561
|
+
await super.execute();
|
|
2562
|
+
// module name/info
|
|
2563
|
+
const moduleName = argv.module;
|
|
2564
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2565
|
+
// check if exists
|
|
2566
|
+
const _module = this.helper.findModule(moduleName);
|
|
2567
|
+
if (!_module) {
|
|
2568
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2569
|
+
}
|
|
2570
|
+
// target dir
|
|
2571
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2572
|
+
// pageName
|
|
2573
|
+
const pageName = argv.pageName;
|
|
2574
|
+
// nameMeta
|
|
2575
|
+
argv.nameMeta = this.helper.parseNameMeta(pageName, ['page']);
|
|
2576
|
+
argv.controllerClassName = `ControllerPage${argv.nameMeta.shortCapitalize}`;
|
|
2577
|
+
argv.controllerFileName = getControllerFileName(_module, 'page', argv.nameMeta.short);
|
|
2578
|
+
// directory
|
|
2579
|
+
const pageDir = path.join(targetDir, 'src/page', argv.nameMeta.short);
|
|
2580
|
+
if (!fs.existsSync(pageDir)) {
|
|
2581
|
+
throw new Error(`page not exists: ${pageDir}`);
|
|
2582
|
+
}
|
|
2583
|
+
// render boilerplate
|
|
2584
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2585
|
+
targetDir: pageDir,
|
|
2586
|
+
setName: __ThisSetName__,
|
|
2587
|
+
snippetsPath: 'refactor/pageParams/snippets',
|
|
2588
|
+
boilerplatePath: null
|
|
2589
|
+
});
|
|
2590
|
+
// tools.metadata
|
|
2591
|
+
if (!argv.nometadata) {
|
|
2592
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2593
|
+
cwd: argv.projectPath
|
|
2594
|
+
});
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
class CliRefactorPageQuery extends BeanCliBase {
|
|
2600
|
+
async execute() {
|
|
2601
|
+
const {
|
|
2602
|
+
argv
|
|
2603
|
+
} = this.context;
|
|
2604
|
+
// super
|
|
2605
|
+
await super.execute();
|
|
2606
|
+
// module name/info
|
|
2607
|
+
const moduleName = argv.module;
|
|
2608
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2609
|
+
// check if exists
|
|
2610
|
+
const _module = this.helper.findModule(moduleName);
|
|
2611
|
+
if (!_module) {
|
|
2612
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2613
|
+
}
|
|
2614
|
+
// target dir
|
|
2615
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2616
|
+
// pageName
|
|
2617
|
+
const pageName = argv.pageName;
|
|
2618
|
+
// nameMeta
|
|
2619
|
+
argv.nameMeta = this.helper.parseNameMeta(pageName, ['page']);
|
|
2620
|
+
argv.controllerClassName = `ControllerPage${argv.nameMeta.shortCapitalize}`;
|
|
2621
|
+
argv.controllerFileName = getControllerFileName(_module, 'page', argv.nameMeta.short);
|
|
2622
|
+
// directory
|
|
2623
|
+
const pageDir = path.join(targetDir, 'src/page', argv.nameMeta.short);
|
|
2624
|
+
if (!fs.existsSync(pageDir)) {
|
|
2625
|
+
throw new Error(`page not exists: ${pageDir}`);
|
|
2626
|
+
}
|
|
2627
|
+
// render boilerplate
|
|
2628
|
+
await this.template.renderBoilerplateAndSnippets({
|
|
2629
|
+
targetDir: pageDir,
|
|
2630
|
+
setName: __ThisSetName__,
|
|
2631
|
+
snippetsPath: 'refactor/pageQuery/snippets',
|
|
2632
|
+
boilerplatePath: null
|
|
2633
|
+
});
|
|
2634
|
+
// tools.metadata
|
|
2635
|
+
if (!argv.nometadata) {
|
|
2636
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2637
|
+
cwd: argv.projectPath
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
class CliRefactorRenameComponent extends BeanCliBase {
|
|
2644
|
+
async execute() {
|
|
2645
|
+
const {
|
|
2646
|
+
argv
|
|
2647
|
+
} = this.context;
|
|
2648
|
+
// super
|
|
2649
|
+
await super.execute();
|
|
2650
|
+
// module name/info
|
|
2651
|
+
const moduleName = argv.module;
|
|
2652
|
+
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
2653
|
+
// check if exists
|
|
2654
|
+
const _module = this.helper.findModule(moduleName);
|
|
2655
|
+
if (!_module) {
|
|
2656
|
+
throw new Error(`module does not exist: ${moduleName}`);
|
|
2657
|
+
}
|
|
2658
|
+
// target dir
|
|
2659
|
+
const targetDir = await this.helper.ensureDir(_module.root);
|
|
2660
|
+
// componentName
|
|
2661
|
+
const componentName = argv.componentName;
|
|
2662
|
+
// nameMeta
|
|
2663
|
+
argv.nameMeta = this.helper.parseNameMeta(componentName, ['component', 'page']);
|
|
2664
|
+
argv.componentNameNewCapitalize = this.helper.firstCharToUpperCase(argv.componentNameNew);
|
|
2665
|
+
// directory
|
|
2666
|
+
const componentDir = path.join(targetDir, 'src', argv.nameMeta.original);
|
|
2667
|
+
if (!fse.existsSync(componentDir)) {
|
|
2668
|
+
throw new Error(`component not exists: ${componentDir}`);
|
|
2669
|
+
}
|
|
2670
|
+
// rename
|
|
2671
|
+
await this._renameRoute(targetDir);
|
|
2672
|
+
await this._renameFiles(componentDir);
|
|
2673
|
+
await this._renameDir(componentDir, targetDir);
|
|
2674
|
+
// tools.metadata
|
|
2675
|
+
if (!argv.nometadata) {
|
|
2676
|
+
await this.helper.invokeCli([':tools:metadata', moduleName], {
|
|
2677
|
+
cwd: argv.projectPath
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
async _renameDir(componentDir, targetDir) {
|
|
2682
|
+
const {
|
|
2683
|
+
argv
|
|
2684
|
+
} = this.context;
|
|
2685
|
+
// delete old vue
|
|
2686
|
+
const componentVueOld = path.join(targetDir, 'src/.metadata', argv.nameMeta.directory === 'page' ? 'page' : 'component', `${argv.nameMeta.short}.ts`);
|
|
2687
|
+
await fse.remove(componentVueOld);
|
|
2688
|
+
// delete rest
|
|
2689
|
+
const restDir = path.join(targetDir, 'rest');
|
|
2690
|
+
await fse.remove(restDir);
|
|
2691
|
+
// rename
|
|
2692
|
+
const componentDirNew = path.join(targetDir, 'src', argv.nameMeta.directory === 'page' ? 'page' : 'component', argv.componentNameNew);
|
|
2693
|
+
await fse.rename(componentDir, componentDirNew);
|
|
2694
|
+
}
|
|
2695
|
+
async _renameRoute(targetDir) {
|
|
2696
|
+
const {
|
|
2697
|
+
argv
|
|
2698
|
+
} = this.context;
|
|
2699
|
+
if (argv.nameMeta.directory !== 'page') return;
|
|
2700
|
+
const routesFile = path.join(targetDir, 'src/routes.ts');
|
|
2701
|
+
let content = (await fse.readFile(routesFile)).toString();
|
|
2702
|
+
//
|
|
2703
|
+
content = content.replace(`import { ZPage${argv.nameMeta.shortCapitalize} } from './.metadata/page/${argv.nameMeta.short}.js';`, `import { ZPage${argv.componentNameNewCapitalize} } from './.metadata/page/${argv.componentNameNew}.js';`);
|
|
2704
|
+
//
|
|
2705
|
+
const ast = gogocode(content);
|
|
2706
|
+
const astNode = ast.find('export const routes: IModuleRoute[] = [$_$]');
|
|
2707
|
+
const astMatches = astNode.match[0];
|
|
2708
|
+
const astMatch = astMatches.find(item => {
|
|
2709
|
+
return item.node.properties.some(prop => {
|
|
2710
|
+
return prop.key.name === 'component' && prop.value.name === `ZPage${argv.nameMeta.shortCapitalize}`;
|
|
2711
|
+
});
|
|
2712
|
+
});
|
|
2713
|
+
if (!astMatch) {
|
|
2714
|
+
throw new Error(`page route not found: ${argv.nameMeta.shortCapitalize}`);
|
|
2715
|
+
}
|
|
2716
|
+
const astPropComponent = astMatch?.node?.properties.find(prop => {
|
|
2717
|
+
return prop.key.name === 'component';
|
|
2718
|
+
});
|
|
2719
|
+
astPropComponent.value.name = `ZPage${argv.componentNameNewCapitalize}`;
|
|
2720
|
+
const astPropPath = astMatch?.node?.properties.find(prop => {
|
|
2721
|
+
return prop.key.name === 'path';
|
|
2722
|
+
});
|
|
2723
|
+
if (astPropPath && astPropPath.value.value) {
|
|
2724
|
+
astPropPath.value.value = astPropPath.value.value.replace(argv.nameMeta.short, argv.componentNameNew);
|
|
2725
|
+
}
|
|
2726
|
+
content = ast.root().generate();
|
|
2727
|
+
await fse.writeFile(routesFile, content);
|
|
2728
|
+
// format
|
|
2729
|
+
await this.helper.formatFile({
|
|
2730
|
+
fileName: routesFile,
|
|
2731
|
+
logPrefix: 'format: '
|
|
2732
|
+
});
|
|
2733
|
+
}
|
|
2734
|
+
async _renameFiles(componentDir) {
|
|
2735
|
+
const {
|
|
2736
|
+
argv
|
|
2737
|
+
} = this.context;
|
|
2738
|
+
//
|
|
2739
|
+
const typeMiddleFix = argv.nameMeta.directory === 'page' ? 'Page' : '';
|
|
2740
|
+
//
|
|
2741
|
+
const replaces = [];
|
|
2742
|
+
replaces.push([`Controller${typeMiddleFix}${argv.nameMeta.shortCapitalize}`, `Controller${typeMiddleFix}${argv.componentNameNewCapitalize}`]);
|
|
2743
|
+
replaces.push([`Render${typeMiddleFix}${argv.nameMeta.shortCapitalize}`, `Render${typeMiddleFix}${argv.componentNameNewCapitalize}`]);
|
|
2744
|
+
replaces.push([`Style${typeMiddleFix}${argv.nameMeta.shortCapitalize}`, `Style${typeMiddleFix}${argv.componentNameNewCapitalize}`]);
|
|
2745
|
+
//
|
|
2746
|
+
const files = globbySync('*', {
|
|
2747
|
+
cwd: componentDir,
|
|
2748
|
+
onlyFiles: true
|
|
2749
|
+
});
|
|
2750
|
+
for (const file of files) {
|
|
2751
|
+
const fileName = path.join(componentDir, file);
|
|
2752
|
+
let content = (await fse.readFile(fileName)).toString();
|
|
2753
|
+
for (const replace of replaces) {
|
|
2754
|
+
content = content.replaceAll(replace[0], replace[1]);
|
|
2755
|
+
}
|
|
2756
|
+
await fse.writeFile(fileName, content);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
class CliToolsDeps extends BeanCliBase {
|
|
2762
|
+
async execute() {
|
|
2763
|
+
const {
|
|
2764
|
+
argv
|
|
2765
|
+
} = this.context;
|
|
2766
|
+
// super
|
|
2767
|
+
await super.execute();
|
|
2768
|
+
const projectPath = argv.projectPath;
|
|
2769
|
+
// const force = argv.force;
|
|
2770
|
+
// generate
|
|
2771
|
+
await this._generate(projectPath);
|
|
2772
|
+
}
|
|
2773
|
+
async _generate(projectPath) {
|
|
2774
|
+
// generate package.json
|
|
2775
|
+
await this.common._generatePackageJson(projectPath);
|
|
2776
|
+
// generate type modules file
|
|
2777
|
+
await this.common._generateTypeModulesFile(projectPath);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
async function generateBeanGenerals(globFiles, sceneName, sceneMeta, moduleName, _modulePath) {
|
|
2782
|
+
if (globFiles.length === 0) return '';
|
|
2783
|
+
//
|
|
2784
|
+
const contentImports = [];
|
|
2785
|
+
const contentRecords = [];
|
|
2786
|
+
for (const globFile of globFiles) {
|
|
2787
|
+
const {
|
|
2788
|
+
fileNameJSRelative,
|
|
2789
|
+
className,
|
|
2790
|
+
beanName,
|
|
2791
|
+
isIgnore
|
|
2792
|
+
} = globFile;
|
|
2793
|
+
const beanFullName = `${moduleName}.${sceneName}.${beanName}`;
|
|
2794
|
+
if (isIgnore) continue;
|
|
2795
|
+
if (!sceneMeta.scopeResource) {
|
|
2796
|
+
contentImports.push(`import { ${className} } from '${fileNameJSRelative}';`);
|
|
2797
|
+
}
|
|
2798
|
+
contentRecords.push(`'${beanFullName}': ${className};`);
|
|
2799
|
+
}
|
|
2800
|
+
if (contentRecords.length === 0) return '';
|
|
2801
|
+
// combine
|
|
2802
|
+
const content = `/** ${sceneName}: begin */
|
|
2803
|
+
${contentImports.join('\n')}
|
|
2804
|
+
import 'zova';
|
|
2805
|
+
declare module 'zova' {
|
|
2806
|
+
export interface ${sceneMeta.beanGeneral ? 'IBeanRecordGeneral' : 'IBeanRecordLocal'} {
|
|
2807
|
+
${contentRecords.join('\n')}
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
/** ${sceneName}: end */
|
|
2811
|
+
`;
|
|
2812
|
+
return content;
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
async function generateConfig(modulePath) {
|
|
2816
|
+
const configFile = path.join(modulePath, 'src/config/config.ts');
|
|
2817
|
+
if (!fse.existsSync(configFile)) return '';
|
|
2818
|
+
// combine
|
|
2819
|
+
const content = `/** config: begin */
|
|
2820
|
+
export * from '../config/config.js';
|
|
2821
|
+
import { config } from '../config/config.js';
|
|
2822
|
+
/** config: end */
|
|
2823
|
+
`;
|
|
2824
|
+
return content;
|
|
2825
|
+
}
|
|
2826
|
+
async function generateConstant(modulePath) {
|
|
2827
|
+
const constantFile = path.join(modulePath, 'src/config/constants.ts');
|
|
2828
|
+
if (!fse.existsSync(constantFile)) return '';
|
|
2829
|
+
// combine
|
|
2830
|
+
const content = `/** constant: begin */
|
|
2831
|
+
export * from '../config/constants.js';
|
|
2832
|
+
import { constants } from '../config/constants.js';
|
|
2833
|
+
/** constant: end */
|
|
2834
|
+
`;
|
|
2835
|
+
return content;
|
|
2836
|
+
}
|
|
2837
|
+
async function generateLocale1(modulePath, moduleName) {
|
|
2838
|
+
const files = await globby('src/config/locale/*.ts', {
|
|
2839
|
+
cwd: modulePath
|
|
2840
|
+
});
|
|
2841
|
+
if (files.length === 0) return '';
|
|
2842
|
+
files.sort();
|
|
2843
|
+
const contentImports = [];
|
|
2844
|
+
const contentLocales = [];
|
|
2845
|
+
for (const file of files) {
|
|
2846
|
+
const localeName = path.basename(file, '.ts');
|
|
2847
|
+
const className = `locale_${localeName.replace('-', '_')}`;
|
|
2848
|
+
contentImports.push(`import ${className} from '../config/locale/${localeName}.js';`);
|
|
2849
|
+
contentLocales.push(` '${localeName}': ${className},`);
|
|
2850
|
+
}
|
|
2851
|
+
// combine
|
|
2852
|
+
const content = `import type { TypeLocaleBase } from 'zova';
|
|
2853
|
+
import { useApp, useComputed } from 'zova';
|
|
2854
|
+
${contentImports.join('\n')}
|
|
2855
|
+
|
|
2856
|
+
export const locales = {
|
|
2857
|
+
${contentLocales.join('\n')}
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
export function $useLocale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K, ...args: any[]) {
|
|
2861
|
+
const app = useApp();
|
|
2862
|
+
const str = \`${moduleName}::\${key}\`;
|
|
2863
|
+
return useComputed(() => {
|
|
2864
|
+
return app.meta.text(str, ...args);
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
`;
|
|
2868
|
+
return content;
|
|
2869
|
+
}
|
|
2870
|
+
async function generateLocale2(contentLocales) {
|
|
2871
|
+
if (!contentLocales) return '';
|
|
2872
|
+
// combine
|
|
2873
|
+
const content = `/** locale: begin */
|
|
2874
|
+
import { locales } from './locales.js';
|
|
2875
|
+
/** locale: end */
|
|
2876
|
+
`;
|
|
2877
|
+
return content;
|
|
2878
|
+
}
|
|
2879
|
+
async function generateError(modulePath) {
|
|
2880
|
+
const errorFile = path.join(modulePath, 'src/config/errors.ts');
|
|
2881
|
+
if (!fse.existsSync(errorFile)) return '';
|
|
2882
|
+
// combine
|
|
2883
|
+
const content = `/** error: begin */
|
|
2884
|
+
export * from '../config/errors.js';
|
|
2885
|
+
import { errors } from '../config/errors.js';
|
|
2886
|
+
/** error: end */
|
|
2887
|
+
`;
|
|
2888
|
+
return content;
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
async function generateIcons(moduleName, modulePath) {
|
|
2892
|
+
const iconsSrc = path.join(modulePath, 'icons');
|
|
2893
|
+
// groups
|
|
2894
|
+
const groups = await _resolveGroups(iconsSrc);
|
|
2895
|
+
for (const group of groups) {
|
|
2896
|
+
group.iconNames = await _generateIconsGroup(modulePath, iconsSrc, moduleName, group.name);
|
|
2897
|
+
}
|
|
2898
|
+
if (groups.length === 0) return '';
|
|
2899
|
+
// src/resource/icons.ts
|
|
2900
|
+
const resourceIcons = await _generateFileResourceIcons(groups, moduleName);
|
|
2901
|
+
const contentResourceIcons = `export interface IIconRecord {
|
|
2902
|
+
${resourceIcons.join('\n ').trim()}
|
|
2903
|
+
}
|
|
2904
|
+
`;
|
|
2905
|
+
// src/config/icons.ts
|
|
2906
|
+
const configIcons = await _generateFileConfigIcons(groups);
|
|
2907
|
+
// combine
|
|
2908
|
+
const content = `/** icons: begin */
|
|
2909
|
+
${configIcons}
|
|
2910
|
+
import 'zova-module-a-icon';
|
|
2911
|
+
declare module 'zova-module-a-icon' {
|
|
2912
|
+
${contentResourceIcons}
|
|
2913
|
+
}
|
|
2914
|
+
/** icons: end */
|
|
2915
|
+
`;
|
|
2916
|
+
// restComponent
|
|
2917
|
+
await generateRestIcon(moduleName, modulePath, resourceIcons);
|
|
2918
|
+
// ok
|
|
2919
|
+
return content;
|
|
2920
|
+
}
|
|
2921
|
+
async function generateRestIcon(_moduleName, modulePath, resourceIcons) {
|
|
2922
|
+
// icons
|
|
2923
|
+
const contentResourceIcons = resourceIcons.join('\n');
|
|
2924
|
+
const fileIcons = path.join(modulePath, 'rest/icons.txt');
|
|
2925
|
+
await fse.outputFile(fileIcons, contentResourceIcons);
|
|
2926
|
+
}
|
|
2927
|
+
async function _generateFileConfigIcons(groups) {
|
|
2928
|
+
const groupsFrontImport = [];
|
|
2929
|
+
const groupsFrontExport = [];
|
|
2930
|
+
for (const group of groups) {
|
|
2931
|
+
groupsFrontImport.push(`import icon_${group.name} from './icons/groups/${group.name}.svg';`);
|
|
2932
|
+
groupsFrontExport.push(`${group.name}: icon_${group.name},`);
|
|
2933
|
+
}
|
|
2934
|
+
const jsContent = `${groupsFrontImport.join('\n')}\n\nexport const icons = {\n ${groupsFrontExport.join('\n ')}\n};\n`;
|
|
2935
|
+
return jsContent;
|
|
2936
|
+
}
|
|
2937
|
+
async function _generateFileResourceIcons(groups, moduleName) {
|
|
2938
|
+
const groupsFrontExport = [];
|
|
2939
|
+
for (const group of groups) {
|
|
2940
|
+
for (const iconName of group.iconNames) {
|
|
2941
|
+
const recordId = _getRecordId(moduleName, group.name, iconName);
|
|
2942
|
+
groupsFrontExport.push(`'${recordId}': true;`);
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
return groupsFrontExport;
|
|
2946
|
+
}
|
|
2947
|
+
async function _resolveGroups(iconsSrc) {
|
|
2948
|
+
const groupPaths = await globby('*', {
|
|
2949
|
+
cwd: iconsSrc,
|
|
2950
|
+
onlyDirectories: true
|
|
2951
|
+
});
|
|
2952
|
+
groupPaths.sort();
|
|
2953
|
+
return groupPaths.map(item => {
|
|
2954
|
+
return {
|
|
2955
|
+
name: item,
|
|
2956
|
+
iconNames: []
|
|
2957
|
+
};
|
|
2958
|
+
});
|
|
2959
|
+
}
|
|
2960
|
+
async function _generateIconsGroup(modulePath, iconsSrc, moduleName, groupName) {
|
|
2961
|
+
// icons
|
|
2962
|
+
const files = await globby(`${groupName}/*.svg`, {
|
|
2963
|
+
cwd: iconsSrc
|
|
2964
|
+
});
|
|
2965
|
+
files.sort();
|
|
2966
|
+
const iconNames = files.map(item => path.basename(item, '.svg'));
|
|
2967
|
+
// symbols
|
|
2968
|
+
const symbols = [];
|
|
2969
|
+
for (let index = 0; index < files.length; index++) {
|
|
2970
|
+
const file = path.join(iconsSrc, files[index]);
|
|
2971
|
+
const iconName = iconNames[index];
|
|
2972
|
+
const symbol = await _combineSymbol(file, moduleName, groupName, iconName);
|
|
2973
|
+
symbols.push(symbol);
|
|
2974
|
+
}
|
|
2975
|
+
// xml
|
|
2976
|
+
const xml = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
2977
|
+
${symbols.join('\n')}
|
|
2978
|
+
</svg>`;
|
|
2979
|
+
// write
|
|
2980
|
+
const pathDest = path.join(modulePath, 'src/.metadata/icons', 'groups');
|
|
2981
|
+
await fse.ensureDir(pathDest);
|
|
2982
|
+
const fileDest = path.join(pathDest, `${groupName}.svg`);
|
|
2983
|
+
await fse.writeFile(fileDest, xml);
|
|
2984
|
+
// ok
|
|
2985
|
+
return iconNames;
|
|
2986
|
+
}
|
|
2987
|
+
async function _combineSymbol(file, moduleName, groupName, iconName) {
|
|
2988
|
+
// load
|
|
2989
|
+
let content = (await fse.readFile(file)).toString();
|
|
2990
|
+
// optimize
|
|
2991
|
+
const {
|
|
2992
|
+
data
|
|
2993
|
+
} = await optimize(content, {});
|
|
2994
|
+
content = data || content;
|
|
2995
|
+
content = content.replace(/<svg(.*?)>/, (_, $1) => {
|
|
2996
|
+
const $2 = $1.replace(/ width=".*?"/, '').replace(/ height=".*?"/, '');
|
|
2997
|
+
return `<symbol id="${_getSymbolId(moduleName, groupName, iconName)}"${$2}>`;
|
|
2998
|
+
}).replace('</svg>', '</symbol>');
|
|
2999
|
+
return content;
|
|
3000
|
+
}
|
|
3001
|
+
function _getSymbolId(moduleName, groupName, iconName) {
|
|
3002
|
+
return `zova-svg-icon-${moduleName}-${groupName}-${iconName}`;
|
|
3003
|
+
}
|
|
3004
|
+
function _getRecordId(moduleName, groupName, iconName) {
|
|
3005
|
+
if (moduleName === 'home-icon') moduleName = '';
|
|
3006
|
+
if (groupName === 'default') groupName = '';
|
|
3007
|
+
return `${moduleName}:${groupName}:${iconName}`;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
// import SVGCompiler from 'svg-baker';
|
|
3011
|
+
// const svgSymbol = await new SVGCompiler().addSymbol({
|
|
3012
|
+
// id: _getSymbolId(moduleName, groupName, iconName),
|
|
3013
|
+
// content,
|
|
3014
|
+
// path: file,
|
|
3015
|
+
// });
|
|
3016
|
+
// content = svgSymbol.render();
|
|
3017
|
+
|
|
3018
|
+
async function generateMetadataCustom(cli, globFiles, sceneName, sceneMeta, moduleName, modulePath) {
|
|
3019
|
+
const sceneNameCapitalize = toUpperCaseFirstChar(sceneName);
|
|
3020
|
+
if (globFiles.length === 0) return '';
|
|
3021
|
+
// custom
|
|
3022
|
+
let jsFile = path.join(sceneMeta.module.root, 'dist-cli', sceneMeta.metadataCustom.replace('.ts', '.js'));
|
|
3023
|
+
if (!fse.existsSync(jsFile)) {
|
|
3024
|
+
jsFile = path.join(sceneMeta.module.root, 'cli', sceneMeta.metadataCustom);
|
|
3025
|
+
}
|
|
3026
|
+
return await cli.helper.importDynamic(jsFile, async instance => {
|
|
3027
|
+
const options = {
|
|
3028
|
+
cli,
|
|
3029
|
+
sceneName,
|
|
3030
|
+
sceneNameCapitalize,
|
|
3031
|
+
sceneMeta,
|
|
3032
|
+
moduleName,
|
|
3033
|
+
modulePath,
|
|
3034
|
+
globFiles
|
|
3035
|
+
};
|
|
3036
|
+
return await instance.default(options);
|
|
3037
|
+
});
|
|
3038
|
+
}
|
|
3039
|
+
|
|
3040
|
+
async function generateMonkey(modulePath) {
|
|
3041
|
+
return generateMonkey_common(modulePath, 'monkey');
|
|
3042
|
+
}
|
|
3043
|
+
async function generateMonkeySys(modulePath) {
|
|
3044
|
+
return generateMonkey_common(modulePath, 'monkeySys');
|
|
3045
|
+
}
|
|
3046
|
+
async function generateMain(modulePath) {
|
|
3047
|
+
return generateMain_common(modulePath, 'main');
|
|
3048
|
+
}
|
|
3049
|
+
async function generateMainSys(modulePath) {
|
|
3050
|
+
return generateMain_common(modulePath, 'mainSys');
|
|
3051
|
+
}
|
|
3052
|
+
async function generateMonkey_common(modulePath, commandName) {
|
|
3053
|
+
const monkeyFile = path.join(modulePath, `src/${commandName}.ts`);
|
|
3054
|
+
if (!fse.existsSync(monkeyFile)) return '';
|
|
3055
|
+
// combine
|
|
3056
|
+
const content = `/** ${commandName}: begin */
|
|
3057
|
+
export * from '../${commandName}.js';
|
|
3058
|
+
/** ${commandName}: end */
|
|
3059
|
+
`;
|
|
3060
|
+
return content;
|
|
3061
|
+
}
|
|
3062
|
+
async function generateMain_common(modulePath, commandName) {
|
|
3063
|
+
const monkeyFile = path.join(modulePath, `src/${commandName}.ts`);
|
|
3064
|
+
if (!fse.existsSync(monkeyFile)) return '';
|
|
3065
|
+
// combine
|
|
3066
|
+
const content = `/** ${commandName}: begin */
|
|
3067
|
+
export * from '../${commandName}.js';
|
|
3068
|
+
/** ${commandName}: end */
|
|
3069
|
+
`;
|
|
3070
|
+
return content;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
function checkIgnoreOfParts(parts) {
|
|
3074
|
+
const indexLast = parts.length - 1;
|
|
3075
|
+
if (parts[indexLast].endsWith('_')) {
|
|
3076
|
+
parts[indexLast] = parts[indexLast].substring(0, parts[indexLast].length - 1);
|
|
3077
|
+
return true;
|
|
3078
|
+
}
|
|
3079
|
+
return false;
|
|
3080
|
+
}
|
|
3081
|
+
function getScopeModuleName(moduleName) {
|
|
3082
|
+
return `ScopeModule${stringToCapitalize(moduleName, '-')}`;
|
|
3083
|
+
}
|
|
3084
|
+
async function globAllTsFiles(moduleName, modulePath) {
|
|
3085
|
+
const result = [];
|
|
3086
|
+
const files = await globby('src/**/*.ts(x)?', {
|
|
3087
|
+
cwd: modulePath
|
|
3088
|
+
});
|
|
3089
|
+
if (files.length === 0) return result;
|
|
3090
|
+
files.sort();
|
|
3091
|
+
const pathMetadata = path.join(modulePath, 'src/.metadata');
|
|
3092
|
+
for (const file of files) {
|
|
3093
|
+
const filePath = path.join(modulePath, file);
|
|
3094
|
+
const fileName = path.basename(file);
|
|
3095
|
+
if (fileName.startsWith('_')) continue;
|
|
3096
|
+
const parts = fileName.split('.').slice(0, -1);
|
|
3097
|
+
const isIgnore = checkIgnoreOfParts(parts);
|
|
3098
|
+
const fileNameJS = fileName.replace('.ts', '.js').replace('.tsx', '.jsx');
|
|
3099
|
+
const fileNameJSRelative = path.relative(pathMetadata, filePath).replace(/\\/g, '/').replace('.ts', '.js').replace('.tsx', '.jsx');
|
|
3100
|
+
const fileContent = fse.readFileSync(filePath).toString();
|
|
3101
|
+
const isVirtual = fileContent.includes('@Virtual()');
|
|
3102
|
+
const isPreload = fileContent.includes('@Preload()');
|
|
3103
|
+
const matches = fileContent.replace('@ProxyDisable()', '').match(/\s@([^\s<]+)\S*?\([\s\S]*?\)\sexport class ([^ \n<]+)/);
|
|
3104
|
+
if (!matches) continue;
|
|
3105
|
+
const className = matches[2];
|
|
3106
|
+
const sceneNameCapitalize = isVirtual ? matches[1] === 'Virtual' ? 'Bean' : matches[1] : matches[1];
|
|
3107
|
+
const sceneName = toLowerCaseFirstChar(sceneNameCapitalize);
|
|
3108
|
+
const beanName = parseBeanName(className, sceneName);
|
|
3109
|
+
const beanNameFull = `${moduleName}:${beanName}`;
|
|
3110
|
+
const beanNameCapitalize = toUpperCaseFirstChar(beanName);
|
|
3111
|
+
const beanFullName = `${moduleName}.${sceneName}.${beanName}`;
|
|
3112
|
+
result.push({
|
|
3113
|
+
sceneName,
|
|
3114
|
+
sceneNameCapitalize,
|
|
3115
|
+
file: filePath,
|
|
3116
|
+
fileContent,
|
|
3117
|
+
fileName,
|
|
3118
|
+
fileNameJS,
|
|
3119
|
+
fileNameJSRelative,
|
|
3120
|
+
className,
|
|
3121
|
+
beanName,
|
|
3122
|
+
beanNameFull,
|
|
3123
|
+
beanNameCapitalize,
|
|
3124
|
+
beanFullName,
|
|
3125
|
+
isIgnore,
|
|
3126
|
+
isVirtual,
|
|
3127
|
+
isPreload
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
return result;
|
|
3131
|
+
}
|
|
3132
|
+
function parseBeanName(className, scene) {
|
|
3133
|
+
return skipPrefix(className, scene, true);
|
|
3134
|
+
}
|
|
3135
|
+
function extractBeanInfo(sceneName, fileContent, sceneMeta) {
|
|
3136
|
+
const sceneNameCapitalize = toUpperCaseFirstChar(sceneName);
|
|
3137
|
+
// optionsCustomInterface
|
|
3138
|
+
let optionsCustomInterface;
|
|
3139
|
+
let optionsCustomInterfaceFrom;
|
|
3140
|
+
let reg = new RegExp(`@${sceneNameCapitalize}<(I${sceneNameCapitalize}Options[^>]*)>`);
|
|
3141
|
+
let matches = fileContent.match(reg);
|
|
3142
|
+
if (matches) {
|
|
3143
|
+
optionsCustomInterface = matches[1];
|
|
3144
|
+
// optionsCustomInterfaceFrom
|
|
3145
|
+
reg = new RegExp(`import {[\\s\\S]*?${optionsCustomInterface}[, ][\\s\\S]*?} from '([^']*)'`);
|
|
3146
|
+
matches = fileContent.match(reg);
|
|
3147
|
+
if (matches) {
|
|
3148
|
+
optionsCustomInterfaceFrom = matches[1];
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
// isGlobal
|
|
3152
|
+
const isGlobal = sceneMeta.hasLocal ? fileContent.match(/@.*?\(\{([\s\S]*?)global: true([\s\S]*?)\}([\s\S]*?)\)\s*export class/) : true;
|
|
3153
|
+
return {
|
|
3154
|
+
optionsCustomInterface,
|
|
3155
|
+
optionsCustomInterfaceFrom,
|
|
3156
|
+
isGlobal
|
|
3157
|
+
};
|
|
3158
|
+
}
|
|
3159
|
+
function beanFullNameFromOnionName(onionName, sceneName) {
|
|
3160
|
+
return onionName.replace(':', `.${sceneName}.`);
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
async function generateOnions(globFiles, sceneName, sceneMeta, moduleName, _modulePath) {
|
|
3164
|
+
const scopeModuleName = getScopeModuleName(moduleName);
|
|
3165
|
+
const sceneNameCapitalize = toUpperCaseFirstChar(sceneName);
|
|
3166
|
+
if (globFiles.length === 0) return '';
|
|
3167
|
+
//
|
|
3168
|
+
const contentExports = [];
|
|
3169
|
+
const contentScopes = [];
|
|
3170
|
+
const contentImports = [];
|
|
3171
|
+
const contentRecordsGlobal = [];
|
|
3172
|
+
const contentRecordsLocal = [];
|
|
3173
|
+
let needImportOptionsGlobalInterface;
|
|
3174
|
+
for (const globFile of globFiles) {
|
|
3175
|
+
const {
|
|
3176
|
+
fileContent,
|
|
3177
|
+
fileNameJSRelative,
|
|
3178
|
+
className,
|
|
3179
|
+
beanNameFull,
|
|
3180
|
+
isIgnore,
|
|
3181
|
+
isVirtual
|
|
3182
|
+
} = globFile;
|
|
3183
|
+
// const beanFullName = `${moduleName}.${sceneName}.${beanName}`;
|
|
3184
|
+
contentExports.push(`export * from '${fileNameJSRelative}';`);
|
|
3185
|
+
if (isIgnore) continue; // get scope() also can be ignored
|
|
3186
|
+
// options
|
|
3187
|
+
let onionOptions;
|
|
3188
|
+
if (!sceneMeta.optionsNone) {
|
|
3189
|
+
// fileInfo
|
|
3190
|
+
const fileInfo = extractBeanInfo(sceneName, fileContent, sceneMeta);
|
|
3191
|
+
// import options
|
|
3192
|
+
if (fileInfo.optionsCustomInterface) {
|
|
3193
|
+
contentImports.push(`import { ${fileInfo.optionsCustomInterface} } from '${fileInfo.optionsCustomInterfaceFrom || fileNameJSRelative}';`);
|
|
3194
|
+
}
|
|
3195
|
+
// valueOptionsCustomInterface
|
|
3196
|
+
let valueOptionsCustomInterface = fileInfo.optionsCustomInterface;
|
|
3197
|
+
if (valueOptionsCustomInterface && sceneMeta.optionsCustomInterfaceTemplate) {
|
|
3198
|
+
valueOptionsCustomInterface = replaceTemplate(sceneMeta.optionsCustomInterfaceTemplate, {
|
|
3199
|
+
optionsCustomInterface: valueOptionsCustomInterface
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
// record
|
|
3203
|
+
if (fileInfo.isGlobal) {
|
|
3204
|
+
if (valueOptionsCustomInterface) {
|
|
3205
|
+
onionOptions = valueOptionsCustomInterface;
|
|
3206
|
+
contentRecordsGlobal.push(`'${beanNameFull}': ${valueOptionsCustomInterface};`);
|
|
3207
|
+
} else {
|
|
3208
|
+
if (sceneMeta.optionsGlobalInterfaceName) {
|
|
3209
|
+
onionOptions = sceneMeta.optionsGlobalInterfaceName;
|
|
3210
|
+
contentRecordsGlobal.push(`'${beanNameFull}': ${sceneMeta.optionsGlobalInterfaceName};`);
|
|
3211
|
+
needImportOptionsGlobalInterface = true;
|
|
3212
|
+
} else {
|
|
3213
|
+
contentRecordsGlobal.push(`'${beanNameFull}': never;`);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
} else {
|
|
3217
|
+
if (valueOptionsCustomInterface) {
|
|
3218
|
+
onionOptions = valueOptionsCustomInterface;
|
|
3219
|
+
contentRecordsLocal.push(`'${beanNameFull}': ${valueOptionsCustomInterface};`);
|
|
3220
|
+
} else {
|
|
3221
|
+
contentRecordsLocal.push(`'${beanNameFull}': never;`);
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
// get scope() also can be ignored
|
|
3226
|
+
if (!['__nothing__'].includes(sceneName) && !isVirtual) {
|
|
3227
|
+
contentScopes.push(`
|
|
3228
|
+
export interface ${className} {
|
|
3229
|
+
/** @internal */
|
|
3230
|
+
get scope(): ${scopeModuleName};
|
|
3231
|
+
}`);
|
|
3232
|
+
// cannot set these types, because controller/render/style extends each other
|
|
3233
|
+
if (!['controller', 'render', 'style'].includes(sceneName)) {
|
|
3234
|
+
const contentOnionOptions = onionOptions ? `get $onionOptions(): ${onionOptions};` : '';
|
|
3235
|
+
contentScopes.push(`
|
|
3236
|
+
export interface ${className} {
|
|
3237
|
+
get $beanFullName(): '${beanFullNameFromOnionName(beanNameFull, sceneName)}';
|
|
3238
|
+
get $onionName(): '${beanNameFull}';
|
|
3239
|
+
${contentOnionOptions}
|
|
3240
|
+
}`);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
// middlewareGlobal
|
|
3245
|
+
const exportRecordsMiddlewareGlobal = `
|
|
3246
|
+
export interface I${sceneNameCapitalize}Record${sceneMeta.hasLocal ? 'Global' : ''} {
|
|
3247
|
+
${contentRecordsGlobal.join('\n')}
|
|
3248
|
+
}
|
|
3249
|
+
`;
|
|
3250
|
+
// middlewareLocal
|
|
3251
|
+
const exportRecordsMiddlewareLocal = `
|
|
3252
|
+
export interface I${sceneNameCapitalize}RecordLocal {
|
|
3253
|
+
${contentRecordsLocal.join('\n')}
|
|
3254
|
+
}
|
|
3255
|
+
`;
|
|
3256
|
+
// combine
|
|
3257
|
+
const content = `/** ${sceneName}: begin */
|
|
3258
|
+
${contentExports.join('\n')}
|
|
3259
|
+
${contentImports.join('\n')}
|
|
3260
|
+
${needImportOptionsGlobalInterface ? `import { ${sceneMeta.optionsGlobalInterfaceName} } from '${sceneMeta.optionsGlobalInterfaceFrom || 'zova'}';` : `import '${sceneMeta.optionsGlobalInterfaceFrom || 'zova'}';`}
|
|
3261
|
+
declare module '${sceneMeta.optionsGlobalInterfaceFrom || 'zova'}' {
|
|
3262
|
+
${contentRecordsGlobal.length > 0 ? exportRecordsMiddlewareGlobal : ''}
|
|
3263
|
+
${contentRecordsLocal.length > 0 ? exportRecordsMiddlewareLocal : ''}
|
|
3264
|
+
}
|
|
3265
|
+
declare module 'zova-module-${moduleName}' {
|
|
3266
|
+
${contentScopes.join('\n')}
|
|
3267
|
+
}
|
|
3268
|
+
/** ${sceneName}: end */
|
|
3269
|
+
`;
|
|
3270
|
+
return content;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
async function generateOptionsPackage(cli, globFiles, onionScenesMeta, _moduleName, modulePath) {
|
|
3274
|
+
let changed = false;
|
|
3275
|
+
const cacheNodeMap = {};
|
|
3276
|
+
const pkgFile = path.join(modulePath, 'package.json');
|
|
3277
|
+
const pkg = await cli.helper.loadJSONFile(pkgFile);
|
|
3278
|
+
const nodeOnionsConfig = getPropertyObject(pkg, 'zovaModule.onionsConfig');
|
|
3279
|
+
function getCacheNodeScene(sceneName) {
|
|
3280
|
+
if (!cacheNodeMap[sceneName]) {
|
|
3281
|
+
cacheNodeMap[sceneName] = nodeOnionsConfig[sceneName] = {};
|
|
3282
|
+
}
|
|
3283
|
+
return cacheNodeMap[sceneName];
|
|
3284
|
+
}
|
|
3285
|
+
for (const {
|
|
3286
|
+
sceneName,
|
|
3287
|
+
sceneNameCapitalize,
|
|
3288
|
+
beanName,
|
|
3289
|
+
beanNameFull,
|
|
3290
|
+
fileContent
|
|
3291
|
+
} of globFiles) {
|
|
3292
|
+
const sceneMeta = onionScenesMeta[sceneName];
|
|
3293
|
+
if (!sceneMeta) throw new Error(`sceneMeta not exists: ${sceneName}`);
|
|
3294
|
+
if (!sceneMeta.optionsPackage) continue;
|
|
3295
|
+
changed = true;
|
|
3296
|
+
const matches = fileContent.match(new RegExp(`@${sceneNameCapitalize}[\\S]*?\\(([\\s\\S]*?)\\)\\s*?export class`));
|
|
3297
|
+
if (!matches) throw new Error(`${sceneName} options parser error: ${beanNameFull}`);
|
|
3298
|
+
const onionOptionsStr = matches[1];
|
|
3299
|
+
const onionOptions = onionOptionsStr ? evaluateSimple(matches[1]) : {};
|
|
3300
|
+
const nodeScene = getCacheNodeScene(sceneName);
|
|
3301
|
+
nodeScene[beanName] = {};
|
|
3302
|
+
for (const key of ['enable', 'meta', 'dependencies', 'dependents', 'type']) {
|
|
3303
|
+
if (onionOptions[key] !== undefined) nodeScene[beanName][key] = onionOptions[key];
|
|
3304
|
+
}
|
|
3305
|
+
for (const key of ['match', 'ignore']) {
|
|
3306
|
+
if (onionOptions[key] !== undefined) {
|
|
3307
|
+
let value = onionOptions[key];
|
|
3308
|
+
if (Array.isArray(value)) {
|
|
3309
|
+
value = value.map(item => __prepareMatchRule(item));
|
|
3310
|
+
} else {
|
|
3311
|
+
value = __prepareMatchRule(value);
|
|
3312
|
+
}
|
|
3313
|
+
nodeScene[beanName][key] = value;
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
if (changed) {
|
|
3318
|
+
await cli.helper.saveJSONFile(pkgFile, pkg);
|
|
3319
|
+
}
|
|
3320
|
+
// ok
|
|
3321
|
+
return '';
|
|
3322
|
+
}
|
|
3323
|
+
function __prepareMatchRule(rule) {
|
|
3324
|
+
if (rule instanceof RegExp) {
|
|
3325
|
+
return StringPrefixRegexp + rule.toString();
|
|
3326
|
+
}
|
|
3327
|
+
return String(rule);
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
async function generateScope(moduleName, relativeNameCapitalize, scopeResources, options) {
|
|
3331
|
+
const contentImports = [];
|
|
3332
|
+
const contentRecords = [];
|
|
3333
|
+
// basic
|
|
3334
|
+
contentImports.push('BeanScopeBase');
|
|
3335
|
+
// util
|
|
3336
|
+
contentImports.push('type BeanScopeUtil');
|
|
3337
|
+
contentRecords.push('util: BeanScopeUtil;');
|
|
3338
|
+
//
|
|
3339
|
+
if (options.config) {
|
|
3340
|
+
contentImports.push('TypeModuleConfig');
|
|
3341
|
+
contentRecords.push('config: TypeModuleConfig<typeof config>;');
|
|
3342
|
+
}
|
|
3343
|
+
if (options.errors) {
|
|
3344
|
+
contentImports.push('TypeModuleErrors');
|
|
3345
|
+
contentRecords.push('error: TypeModuleErrors<typeof errors>;');
|
|
3346
|
+
}
|
|
3347
|
+
if (options.locales) {
|
|
3348
|
+
contentImports.push('TypeModuleLocales');
|
|
3349
|
+
contentImports.push('TypeLocaleBase');
|
|
3350
|
+
contentRecords.push('locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;');
|
|
3351
|
+
}
|
|
3352
|
+
if (options.constants) {
|
|
3353
|
+
contentImports.push('TypeModuleConstants');
|
|
3354
|
+
contentRecords.push('constant: TypeModuleConstants<typeof constants>;');
|
|
3355
|
+
}
|
|
3356
|
+
// loop
|
|
3357
|
+
for (const sceneName in scopeResources) {
|
|
3358
|
+
contentRecords.push(`${sceneName}: ${scopeResources[sceneName]};`);
|
|
3359
|
+
}
|
|
3360
|
+
// combine
|
|
3361
|
+
const content = `/** scope: begin */
|
|
3362
|
+
import { ${contentImports.join(', ')} } from 'zova';
|
|
3363
|
+
import { Scope } from '${moduleName === 'a-bean' ? '../lib/scope.js' : 'zova-module-a-bean'}';
|
|
3364
|
+
|
|
3365
|
+
@Scope()
|
|
3366
|
+
export class ScopeModule${relativeNameCapitalize} extends BeanScopeBase {}
|
|
3367
|
+
|
|
3368
|
+
export interface ScopeModule${relativeNameCapitalize} {
|
|
3369
|
+
${contentRecords.join('\n')}
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3372
|
+
import 'zova';
|
|
3373
|
+
declare module 'zova' {
|
|
3374
|
+
export interface IBeanScopeRecord {
|
|
3375
|
+
'${moduleName}': ScopeModule${relativeNameCapitalize};
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3378
|
+
${options.config ? `export interface IBeanScopeConfig {
|
|
3379
|
+
'${moduleName}': ReturnType<typeof config>;
|
|
3380
|
+
}` : ''}
|
|
3381
|
+
|
|
3382
|
+
${options.locales ? `export interface IBeanScopeLocale {
|
|
3383
|
+
'${moduleName}': (typeof locales)[TypeLocaleBase];
|
|
3384
|
+
}` : ''}
|
|
3385
|
+
|
|
3386
|
+
${options.errors ? `export interface IBeanScopeErrors {
|
|
3387
|
+
'${moduleName}': typeof errors;
|
|
3388
|
+
}` : ''}
|
|
3389
|
+
}
|
|
3390
|
+
${options.locales ? `\nexport function locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): \`${moduleName}::\${K}\` {
|
|
3391
|
+
return \`${moduleName}::\${key}\`;
|
|
3392
|
+
}` : ''}
|
|
3393
|
+
/** scope: end */
|
|
3394
|
+
`;
|
|
3395
|
+
return content;
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
async function generateScopeResources(globFiles, sceneName, _sceneMeta, _moduleName, _modulePath) {
|
|
3399
|
+
const sceneNameCapitalize = toUpperCaseFirstChar(sceneName);
|
|
3400
|
+
if (globFiles.length === 0) return '';
|
|
3401
|
+
//
|
|
3402
|
+
const contentImports = [];
|
|
3403
|
+
const contentRecords = [];
|
|
3404
|
+
for (const globFile of globFiles) {
|
|
3405
|
+
const {
|
|
3406
|
+
fileNameJSRelative,
|
|
3407
|
+
className,
|
|
3408
|
+
beanName,
|
|
3409
|
+
isIgnore
|
|
3410
|
+
} = globFile;
|
|
3411
|
+
if (isIgnore) continue;
|
|
3412
|
+
contentImports.push(`import { ${className} } from '${fileNameJSRelative}';`);
|
|
3413
|
+
contentRecords.push(`'${beanName}': ${className};`);
|
|
3414
|
+
}
|
|
3415
|
+
if (contentImports.length === 0) return '';
|
|
3416
|
+
// combine
|
|
3417
|
+
const content = `/** ${sceneName}: begin */
|
|
3418
|
+
${contentImports.join('\n')}
|
|
3419
|
+
export interface IModule${sceneNameCapitalize} {
|
|
3420
|
+
${contentRecords.join('\n')}
|
|
3421
|
+
}
|
|
3422
|
+
/** ${sceneName}: end */
|
|
3423
|
+
`;
|
|
3424
|
+
return content;
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
async function generateScopeResourcesMeta(globFiles, metaName, _metaMeta, _sceneName, _sceneMeta, _moduleName, _modulePath) {
|
|
3428
|
+
if (globFiles.length === 0) return '';
|
|
3429
|
+
// combine
|
|
3430
|
+
const content = `/** meta ${metaName}: begin */
|
|
3431
|
+
import { Meta${toUpperCaseFirstChar(metaName)} } from '../bean/meta.${metaName}.js';
|
|
3432
|
+
/** meta ${metaName}: end */
|
|
3433
|
+
`;
|
|
3434
|
+
return content;
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
class CliToolsMetadata extends BeanCliBase {
|
|
3438
|
+
async execute() {
|
|
3439
|
+
const {
|
|
3440
|
+
argv
|
|
3441
|
+
} = this.context;
|
|
3442
|
+
// super
|
|
3443
|
+
await super.execute();
|
|
3444
|
+
// noformat: src/index.ts need format
|
|
3445
|
+
// argv.noformat = true;
|
|
3446
|
+
// moduleNames
|
|
3447
|
+
let moduleNames = argv._;
|
|
3448
|
+
const force = argv.force ?? moduleNames.length > 0;
|
|
3449
|
+
if (moduleNames.length === 0) {
|
|
3450
|
+
moduleNames = this.modulesMeta.modulesArray.filter(item => !item.info.node_modules).map(item => item.info.relativeName);
|
|
3451
|
+
}
|
|
3452
|
+
const total = moduleNames.length;
|
|
3453
|
+
for (let index = 0; index < total; index++) {
|
|
3454
|
+
const moduleName = moduleNames[index];
|
|
3455
|
+
// log
|
|
3456
|
+
await this.console.log({
|
|
3457
|
+
total,
|
|
3458
|
+
progress: index,
|
|
3459
|
+
text: moduleName
|
|
3460
|
+
});
|
|
3461
|
+
// generate res
|
|
3462
|
+
await this._generateMetadata(moduleName, force);
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
async _generateMetadata(moduleName, force) {
|
|
3466
|
+
const module = this.helper.findModule(moduleName);
|
|
3467
|
+
if (!module) throw new Error(`module not found: ${moduleName}`);
|
|
3468
|
+
const modulePath = module.root;
|
|
3469
|
+
const metaDir = path.join(modulePath, 'src/.metadata');
|
|
3470
|
+
const metaIndexFile = path.join(metaDir, 'index.ts');
|
|
3471
|
+
if (fse.existsSync(metaIndexFile) && !force) {
|
|
3472
|
+
// do nothing
|
|
3473
|
+
return;
|
|
3474
|
+
}
|
|
3475
|
+
await this.helper.ensureDir(metaDir);
|
|
3476
|
+
// relativeNameCapitalize
|
|
3477
|
+
const relativeNameCapitalize = this.helper.stringToCapitalize(moduleName, '-');
|
|
3478
|
+
// onionScenesMeta
|
|
3479
|
+
const onionScenesMeta = getOnionScenesMeta(this.modulesMeta.modules);
|
|
3480
|
+
// content
|
|
3481
|
+
let content = '';
|
|
3482
|
+
// all files
|
|
3483
|
+
const globFiles = await globAllTsFiles(moduleName, modulePath);
|
|
3484
|
+
const beansPreload = globFiles.filter(item => item.isPreload).map(item => item.beanFullName);
|
|
3485
|
+
// onions
|
|
3486
|
+
const scopeResources = {};
|
|
3487
|
+
for (const sceneName in onionScenesMeta) {
|
|
3488
|
+
const sceneMeta = onionScenesMeta[sceneName];
|
|
3489
|
+
const globFilesScene = globFiles.filter(item => item.sceneName === sceneName);
|
|
3490
|
+
// general
|
|
3491
|
+
content += await generateOnions(globFilesScene, sceneName, sceneMeta, moduleName);
|
|
3492
|
+
// scope resources
|
|
3493
|
+
if (sceneMeta.scopeResource) {
|
|
3494
|
+
const contentScopeResource = await generateScopeResources(globFilesScene, sceneName);
|
|
3495
|
+
if (contentScopeResource) {
|
|
3496
|
+
content += contentScopeResource;
|
|
3497
|
+
scopeResources[sceneName] = `IModule${toUpperCaseFirstChar(sceneName)}`;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
// bean generals
|
|
3501
|
+
content += await generateBeanGenerals(globFilesScene, sceneName, sceneMeta, moduleName);
|
|
3502
|
+
// metas
|
|
3503
|
+
if (sceneName === 'meta') {
|
|
3504
|
+
const onionMetasMeta = getOnionMetasMeta(this.modulesMeta.modules);
|
|
3505
|
+
for (const metaName in onionMetasMeta) {
|
|
3506
|
+
const metaMeta = onionMetasMeta[metaName];
|
|
3507
|
+
const globFilesMeta = globFiles.filter(item => item.sceneName === 'meta' && item.beanName === metaName);
|
|
3508
|
+
if (metaMeta.scopeResource) {
|
|
3509
|
+
const contentScopeResourceMeta = await generateScopeResourcesMeta(globFilesMeta, metaName);
|
|
3510
|
+
if (contentScopeResourceMeta) {
|
|
3511
|
+
content += contentScopeResourceMeta;
|
|
3512
|
+
scopeResources[metaName] = `Meta${toUpperCaseFirstChar(metaName)}`;
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
// metadata custom
|
|
3518
|
+
if (sceneMeta.metadataCustom) {
|
|
3519
|
+
content += await generateMetadataCustom(this, globFilesScene, sceneName, sceneMeta, moduleName, modulePath);
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
// onions: optionsPackage
|
|
3523
|
+
content += await generateOptionsPackage(this, globFiles, onionScenesMeta, moduleName, modulePath);
|
|
3524
|
+
// icons
|
|
3525
|
+
content += await generateIcons(moduleName, modulePath);
|
|
3526
|
+
// config
|
|
3527
|
+
const contentConfig = await generateConfig(modulePath);
|
|
3528
|
+
content += contentConfig;
|
|
3529
|
+
// constant
|
|
3530
|
+
const contentConstants = await generateConstant(modulePath);
|
|
3531
|
+
content += contentConstants;
|
|
3532
|
+
// locale
|
|
3533
|
+
const contentLocales1 = await generateLocale1(modulePath, moduleName);
|
|
3534
|
+
const contentLocales2 = await generateLocale2(contentLocales1);
|
|
3535
|
+
content += contentLocales2;
|
|
3536
|
+
// error
|
|
3537
|
+
const contentErrors = await generateError(modulePath);
|
|
3538
|
+
content += contentErrors;
|
|
3539
|
+
// monkey/monkeySys
|
|
3540
|
+
content += await generateMonkey(modulePath);
|
|
3541
|
+
content += await generateMonkeySys(modulePath);
|
|
3542
|
+
// main/mainSys
|
|
3543
|
+
content += await generateMain(modulePath);
|
|
3544
|
+
content += await generateMainSys(modulePath);
|
|
3545
|
+
// scope
|
|
3546
|
+
content += await generateScope(moduleName, relativeNameCapitalize, scopeResources, {
|
|
3547
|
+
config: contentConfig,
|
|
3548
|
+
errors: contentErrors,
|
|
3549
|
+
locales: contentLocales2,
|
|
3550
|
+
constants: contentConstants
|
|
3551
|
+
});
|
|
3552
|
+
// empty
|
|
3553
|
+
if (!content.trim()) {
|
|
3554
|
+
content = 'export {};';
|
|
3555
|
+
} else {
|
|
3556
|
+
content = `// eslint-disable\n${content}`;
|
|
3557
|
+
}
|
|
3558
|
+
// save
|
|
3559
|
+
await fse.writeFile(metaIndexFile, content);
|
|
3560
|
+
// await this.helper.formatFile({ fileName: metaIndexFile, logPrefix: 'format: ' });
|
|
3561
|
+
// locales
|
|
3562
|
+
await this._generateLocales(modulePath, contentLocales1);
|
|
3563
|
+
// generate this
|
|
3564
|
+
await this._generateThis(moduleName, relativeNameCapitalize, modulePath);
|
|
3565
|
+
// index
|
|
3566
|
+
await this._generateIndex(modulePath);
|
|
3567
|
+
// package
|
|
3568
|
+
await this._generatePackage(modulePath, beansPreload);
|
|
3569
|
+
}
|
|
3570
|
+
async _generateLocales(modulePath, contentLocales) {
|
|
3571
|
+
if (!contentLocales) return;
|
|
3572
|
+
const localesDest = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
3573
|
+
// save
|
|
3574
|
+
await fse.writeFile(localesDest, contentLocales);
|
|
3575
|
+
}
|
|
3576
|
+
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
3577
|
+
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
3578
|
+
if (fse.existsSync(thisDest)) return;
|
|
3579
|
+
const content = `export const __ThisModule__ = '${moduleName}';
|
|
3580
|
+
export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.js';
|
|
3581
|
+
`;
|
|
3582
|
+
// save
|
|
3583
|
+
await fse.writeFile(thisDest, content);
|
|
3584
|
+
}
|
|
3585
|
+
async _generateIndex(modulePath) {
|
|
3586
|
+
let jsContent = '';
|
|
3587
|
+
const jsFile = path.join(modulePath, 'src/index.ts');
|
|
3588
|
+
if (fse.existsSync(jsFile)) {
|
|
3589
|
+
jsContent = (await fse.readFile(jsFile)).toString();
|
|
3590
|
+
}
|
|
3591
|
+
// jsTypes
|
|
3592
|
+
const jsTypes = "export * from './types/index.js';";
|
|
3593
|
+
const jsTypesFile = path.join(modulePath, 'src/types/index.ts');
|
|
3594
|
+
if (fse.existsSync(jsTypesFile) && !jsContent.includes(jsTypes)) {
|
|
3595
|
+
jsContent = `${jsTypes}\n${jsContent}`;
|
|
3596
|
+
}
|
|
3597
|
+
// jsLib
|
|
3598
|
+
const jsLib = "export * from './lib/index.js';";
|
|
3599
|
+
const jsLibFile = path.join(modulePath, 'src/lib/index.ts');
|
|
3600
|
+
if (fse.existsSync(jsLibFile) && !jsContent.includes(jsLib)) {
|
|
3601
|
+
jsContent = `${jsLib}\n${jsContent}`;
|
|
3602
|
+
}
|
|
3603
|
+
// jsLocales
|
|
3604
|
+
const jsLocales = "export * from './.metadata/locales.js';";
|
|
3605
|
+
const jsLocalesFile = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
3606
|
+
if (fse.existsSync(jsLocalesFile) && !jsContent.includes(jsLocales)) {
|
|
3607
|
+
jsContent = `${jsLocales}\n${jsContent}`;
|
|
3608
|
+
}
|
|
3609
|
+
// jsMetadata
|
|
3610
|
+
const jsMetadata = "export * from './.metadata/index.js';";
|
|
3611
|
+
const jsMetadataFile = path.join(modulePath, 'src/.metadata/index.ts');
|
|
3612
|
+
if (fse.existsSync(jsMetadataFile) && !jsContent.includes(jsMetadata)) {
|
|
3613
|
+
jsContent = `${jsMetadata}\n${jsContent}`;
|
|
3614
|
+
}
|
|
3615
|
+
// trim empty
|
|
3616
|
+
jsContent = jsContent.replace('export {};\n', '');
|
|
3617
|
+
// write
|
|
3618
|
+
await fse.writeFile(jsFile, jsContent);
|
|
3619
|
+
await this.helper.formatFile({
|
|
3620
|
+
fileName: jsFile,
|
|
3621
|
+
logPrefix: 'format: '
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
async _generatePackage(modulePath, beansPreload) {
|
|
3625
|
+
let pkgFile;
|
|
3626
|
+
let pkg;
|
|
3627
|
+
let changed;
|
|
3628
|
+
async function _loadPkg() {
|
|
3629
|
+
if (!pkg) {
|
|
3630
|
+
pkgFile = path.join(modulePath, 'package.json');
|
|
3631
|
+
pkg = await loadJSONFile(pkgFile);
|
|
3632
|
+
}
|
|
3633
|
+
return pkg;
|
|
3634
|
+
}
|
|
3635
|
+
// beansPreload
|
|
3636
|
+
if (beansPreload.length > 0) {
|
|
3637
|
+
pkg = await _loadPkg();
|
|
3638
|
+
if (!pkg.zovaModule) pkg.zovaModule = {};
|
|
3639
|
+
if (!pkg.zovaModule.beansPreload || pkg.zovaModule.beansPreload.join(',') !== beansPreload.join(',')) {
|
|
3640
|
+
changed = true;
|
|
3641
|
+
pkg.zovaModule.beansPreload = beansPreload;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
// cli/rest
|
|
3645
|
+
for (const name of ['cli', 'icons', 'rest']) {
|
|
3646
|
+
const cli = path.join(modulePath, name);
|
|
3647
|
+
if (fse.existsSync(cli)) {
|
|
3648
|
+
pkg = await _loadPkg();
|
|
3649
|
+
const index = pkg.files.indexOf(name);
|
|
3650
|
+
if (index === -1) {
|
|
3651
|
+
changed = true;
|
|
3652
|
+
pkg.files.push(name);
|
|
3653
|
+
}
|
|
3654
|
+
if (name === 'cli') {
|
|
3655
|
+
if (pkg.scripts?.['tsc:publish'].includes('tsconfig.cli.json')) {
|
|
3656
|
+
const index = pkg.files.indexOf('dist-cli');
|
|
3657
|
+
if (index === -1) {
|
|
3658
|
+
changed = true;
|
|
3659
|
+
pkg.files.push('dist-cli');
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
}
|
|
3665
|
+
// save
|
|
3666
|
+
if (changed) {
|
|
3667
|
+
await saveJSONFile(pkgFile, pkg);
|
|
3668
|
+
await this.helper.formatFile({
|
|
3669
|
+
fileName: pkgFile
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
const beans = {
|
|
3676
|
+
'default.list': CliDefaultList,
|
|
3677
|
+
'bin.buildModule': CliBinBuildModule,
|
|
3678
|
+
'bin.buildRest': CliBinBuildRest,
|
|
3679
|
+
'create.project': CliCreateProject,
|
|
3680
|
+
'create.suite': CliCreateSuite,
|
|
3681
|
+
'create.module': CliCreateModule,
|
|
3682
|
+
'create.page': CliCreatePage,
|
|
3683
|
+
'create.component': CliCreateComponent,
|
|
3684
|
+
'create.mock': CliCreateMock,
|
|
3685
|
+
'create.bean': CliCreateBean,
|
|
3686
|
+
'init.icon': CliInitIcon,
|
|
3687
|
+
'init.config': CliInitConfig,
|
|
3688
|
+
'init.constant': CliInitConstant,
|
|
3689
|
+
'init.locale': CliInitLocale,
|
|
3690
|
+
'init.error': CliInitError,
|
|
3691
|
+
'init.legacy': CliInitLegacy,
|
|
3692
|
+
'init.appMonkey': CliInitAppMonkey,
|
|
3693
|
+
'init.sysMonkey': CliInitSysMonkey,
|
|
3694
|
+
'init.monkey': CliInitMonkey,
|
|
3695
|
+
'init.monkeySys': CliInitMonkeySys,
|
|
3696
|
+
'init.main': CliInitMain,
|
|
3697
|
+
'init.mainSys': CliInitMainSys,
|
|
3698
|
+
'init.asset': CliInitAsset,
|
|
3699
|
+
'init.lib': CliInitLib,
|
|
3700
|
+
'init.types': CliInitTypes,
|
|
3701
|
+
'refactor.pageQuery': CliRefactorPageQuery,
|
|
3702
|
+
'refactor.pageParams': CliRefactorPageParams,
|
|
3703
|
+
'refactor.componentGeneric': CliRefactorComponentGeneric,
|
|
3704
|
+
'refactor.firstRender': CliRefactorFirstRender,
|
|
3705
|
+
'refactor.firstStyle': CliRefactorFirstStyle,
|
|
3706
|
+
'refactor.anotherRender': CliRefactorAnotherRender,
|
|
3707
|
+
'refactor.anotherStyle': CliRefactorAnotherStyle,
|
|
3708
|
+
'refactor.componentProps': CliRefactorComponentProps,
|
|
3709
|
+
'refactor.componentEmits': CliRefactorComponentEmits,
|
|
3710
|
+
'refactor.componentSlots': CliRefactorComponentSlots,
|
|
3711
|
+
'refactor.componentModel': CliRefactorComponentModel,
|
|
3712
|
+
'refactor.renameComponent': CliRefactorRenameComponent,
|
|
3713
|
+
'tools.metadata': CliToolsMetadata,
|
|
3714
|
+
'tools.deps': CliToolsDeps,
|
|
3715
|
+
'openapi.config': CliOpenapiConfig,
|
|
3716
|
+
'openapi.generate': CliOpenapiGenerate
|
|
3717
|
+
};
|
|
3718
|
+
|
|
3719
|
+
var binBuildModule = {
|
|
3720
|
+
bean: 'bin.buildModule',
|
|
3721
|
+
info: {
|
|
3722
|
+
version: '5.0.0',
|
|
3723
|
+
title: 'Cli: Tools: Bin',
|
|
3724
|
+
usage: 'zova :bin:buildModule [--minify] [--sourcemap] [--dts]'
|
|
3725
|
+
},
|
|
3726
|
+
options: {
|
|
3727
|
+
minify: {
|
|
3728
|
+
description: 'minify',
|
|
3729
|
+
type: 'boolean'
|
|
3730
|
+
},
|
|
3731
|
+
sourcemap: {
|
|
3732
|
+
description: 'sourcemap',
|
|
3733
|
+
type: 'boolean'
|
|
3734
|
+
},
|
|
3735
|
+
dts: {
|
|
3736
|
+
description: 'dts',
|
|
3737
|
+
type: 'boolean'
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
};
|
|
3741
|
+
|
|
3742
|
+
var binBuildRest = {
|
|
3743
|
+
bean: 'bin.buildRest',
|
|
3744
|
+
info: {
|
|
3745
|
+
version: '5.0.0',
|
|
3746
|
+
title: 'Cli: Tools: Bin',
|
|
3747
|
+
usage: 'zova :bin:buildRest [--flavor=]'
|
|
3748
|
+
},
|
|
3749
|
+
options: {
|
|
3750
|
+
flavor: {
|
|
3751
|
+
description: 'flavor',
|
|
3752
|
+
type: 'string'
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
var createBean = {
|
|
3758
|
+
bean: 'create.bean',
|
|
3759
|
+
info: {
|
|
3760
|
+
version: '5.0.0',
|
|
3761
|
+
title: 'Cli: Create Bean',
|
|
3762
|
+
usage: 'zova :create:bean sceneName beanName [--module=]'
|
|
3763
|
+
},
|
|
3764
|
+
options: {
|
|
3765
|
+
module: {
|
|
3766
|
+
description: 'module name',
|
|
3767
|
+
type: 'string'
|
|
3768
|
+
}
|
|
3769
|
+
},
|
|
3770
|
+
groups: {
|
|
3771
|
+
default: {
|
|
3772
|
+
questions: {
|
|
3773
|
+
sceneName: {
|
|
3774
|
+
type: 'input',
|
|
3775
|
+
message: 'sceneName',
|
|
3776
|
+
initial: {
|
|
3777
|
+
expression: 'context.argv._[0]'
|
|
3778
|
+
},
|
|
3779
|
+
required: true
|
|
3780
|
+
},
|
|
3781
|
+
beanName: {
|
|
3782
|
+
type: 'input',
|
|
3783
|
+
message: 'beanName',
|
|
3784
|
+
initial: {
|
|
3785
|
+
expression: 'context.argv._[1]'
|
|
3786
|
+
},
|
|
3787
|
+
required: true
|
|
3788
|
+
},
|
|
3789
|
+
module: {
|
|
3790
|
+
type: 'input',
|
|
3791
|
+
message: 'module name',
|
|
3792
|
+
required: true
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
};
|
|
3798
|
+
|
|
3799
|
+
var createComponent = {
|
|
3800
|
+
bean: 'create.component',
|
|
3801
|
+
info: {
|
|
3802
|
+
version: '5.0.0',
|
|
3803
|
+
title: 'Cli: Create Component',
|
|
3804
|
+
usage: 'zova :create:component componentName [--module=] [--boilerplate=]'
|
|
3805
|
+
},
|
|
3806
|
+
options: {
|
|
3807
|
+
module: {
|
|
3808
|
+
description: 'module name',
|
|
3809
|
+
type: 'string'
|
|
3810
|
+
},
|
|
3811
|
+
boilerplate: {
|
|
3812
|
+
description: 'boilerplate',
|
|
3813
|
+
type: 'string'
|
|
3814
|
+
}
|
|
3815
|
+
},
|
|
3816
|
+
groups: {
|
|
3817
|
+
default: {
|
|
3818
|
+
questions: {
|
|
3819
|
+
componentName: {
|
|
3820
|
+
type: 'input',
|
|
3821
|
+
message: 'componentName',
|
|
3822
|
+
initial: {
|
|
3823
|
+
expression: 'context.argv._[0]'
|
|
3824
|
+
},
|
|
3825
|
+
required: true
|
|
3826
|
+
},
|
|
3827
|
+
module: {
|
|
3828
|
+
type: 'input',
|
|
3829
|
+
message: 'module name',
|
|
3830
|
+
required: true
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
};
|
|
3836
|
+
|
|
3837
|
+
var createMock = {
|
|
3838
|
+
bean: 'create.mock',
|
|
3839
|
+
info: {
|
|
3840
|
+
version: '5.0.0',
|
|
3841
|
+
title: 'Cli: Create Mock',
|
|
3842
|
+
usage: 'zova :create:mock mockName [--module=]'
|
|
3843
|
+
},
|
|
3844
|
+
options: {
|
|
3845
|
+
module: {
|
|
3846
|
+
description: 'module name',
|
|
3847
|
+
type: 'string'
|
|
3848
|
+
}
|
|
3849
|
+
},
|
|
3850
|
+
groups: {
|
|
3851
|
+
default: {
|
|
3852
|
+
questions: {
|
|
3853
|
+
mockName: {
|
|
3854
|
+
type: 'input',
|
|
3855
|
+
message: 'mockName',
|
|
3856
|
+
initial: {
|
|
3857
|
+
expression: 'context.argv._[0]'
|
|
3858
|
+
},
|
|
3859
|
+
required: true
|
|
3860
|
+
},
|
|
3861
|
+
module: {
|
|
3862
|
+
type: 'input',
|
|
3863
|
+
message: 'module name',
|
|
3864
|
+
required: true
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
};
|
|
3870
|
+
|
|
3871
|
+
var createModule = {
|
|
3872
|
+
bean: 'create.module',
|
|
3873
|
+
info: {
|
|
3874
|
+
version: '5.0.0',
|
|
3875
|
+
title: 'Cli: Create Module',
|
|
3876
|
+
usage: 'zova :create:module moduleName [--suite=] [--force]'
|
|
3877
|
+
},
|
|
3878
|
+
options: {
|
|
3879
|
+
suite: {
|
|
3880
|
+
description: 'suite name',
|
|
3881
|
+
type: 'string'
|
|
3882
|
+
},
|
|
3883
|
+
force: {
|
|
3884
|
+
description: 'force',
|
|
3885
|
+
type: 'boolean'
|
|
3886
|
+
}
|
|
3887
|
+
},
|
|
3888
|
+
groups: {
|
|
3889
|
+
default: {
|
|
3890
|
+
questions: {
|
|
3891
|
+
name: {
|
|
3892
|
+
type: 'input',
|
|
3893
|
+
message: 'module name',
|
|
3894
|
+
initial: {
|
|
3895
|
+
expression: 'context.argv._[0]'
|
|
3896
|
+
},
|
|
3897
|
+
required: true
|
|
3898
|
+
},
|
|
3899
|
+
suite: {
|
|
3900
|
+
type: 'input',
|
|
3901
|
+
message: 'suite name'
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3906
|
+
};
|
|
3907
|
+
|
|
3908
|
+
var createPage = {
|
|
3909
|
+
bean: 'create.page',
|
|
3910
|
+
info: {
|
|
3911
|
+
version: '5.0.0',
|
|
3912
|
+
title: 'Cli: Create Page TSX Component',
|
|
3913
|
+
usage: 'zova :create:page pageName [--module=]'
|
|
3914
|
+
},
|
|
3915
|
+
options: {
|
|
3916
|
+
module: {
|
|
3917
|
+
description: 'module name',
|
|
3918
|
+
type: 'string'
|
|
3919
|
+
}
|
|
3920
|
+
},
|
|
3921
|
+
groups: {
|
|
3922
|
+
default: {
|
|
3923
|
+
questions: {
|
|
3924
|
+
pageName: {
|
|
3925
|
+
type: 'input',
|
|
3926
|
+
message: 'pageName',
|
|
3927
|
+
initial: {
|
|
3928
|
+
expression: 'context.argv._[0]'
|
|
3929
|
+
},
|
|
3930
|
+
required: true
|
|
3931
|
+
},
|
|
3932
|
+
module: {
|
|
3933
|
+
type: 'input',
|
|
3934
|
+
message: 'module name',
|
|
3935
|
+
required: true
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
};
|
|
3941
|
+
|
|
3942
|
+
var createProject = {
|
|
3943
|
+
bean: 'create.project',
|
|
3944
|
+
info: {
|
|
3945
|
+
version: '5.0.0',
|
|
3946
|
+
title: 'Cli: Create Project',
|
|
3947
|
+
usage: 'zova :create:project projectName [--template=] [--force]'
|
|
3948
|
+
},
|
|
3949
|
+
options: {
|
|
3950
|
+
template: {
|
|
3951
|
+
description: 'template',
|
|
3952
|
+
type: 'string'
|
|
3953
|
+
},
|
|
3954
|
+
force: {
|
|
3955
|
+
description: 'force',
|
|
3956
|
+
type: 'boolean'
|
|
3957
|
+
}
|
|
3958
|
+
},
|
|
3959
|
+
groups: {
|
|
3960
|
+
default: {
|
|
3961
|
+
questions: {
|
|
3962
|
+
template: {
|
|
3963
|
+
type: 'select',
|
|
3964
|
+
message: 'Specify the project template',
|
|
3965
|
+
choices: [{
|
|
3966
|
+
name: 'quasar',
|
|
3967
|
+
message: 'zova + quasar'
|
|
3968
|
+
}, {
|
|
3969
|
+
name: 'vuetify',
|
|
3970
|
+
message: 'zova + vuetify'
|
|
3971
|
+
}, {
|
|
3972
|
+
name: 'empty',
|
|
3973
|
+
message: 'zova only'
|
|
3974
|
+
}]
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
},
|
|
3978
|
+
moduleInfo: {
|
|
3979
|
+
questions: {
|
|
3980
|
+
name: {
|
|
3981
|
+
type: 'input',
|
|
3982
|
+
message: 'project name',
|
|
3983
|
+
initial: {
|
|
3984
|
+
expression: 'context.argv._[0]'
|
|
3985
|
+
},
|
|
3986
|
+
required: true
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
};
|
|
3992
|
+
|
|
3993
|
+
var createSuite = {
|
|
3994
|
+
bean: 'create.suite',
|
|
3995
|
+
info: {
|
|
3996
|
+
version: '5.0.0',
|
|
3997
|
+
title: 'Cli: Create Suite',
|
|
3998
|
+
usage: 'zova :create:suite suiteName'
|
|
3999
|
+
},
|
|
4000
|
+
options: {},
|
|
4001
|
+
groups: {
|
|
4002
|
+
suiteInfo: {
|
|
4003
|
+
questions: {
|
|
4004
|
+
name: {
|
|
4005
|
+
type: 'input',
|
|
4006
|
+
message: 'suite name',
|
|
4007
|
+
initial: {
|
|
4008
|
+
expression: 'context.argv._[0]'
|
|
4009
|
+
},
|
|
4010
|
+
required: true
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
};
|
|
4016
|
+
|
|
4017
|
+
var defaultList = {
|
|
4018
|
+
bean: 'default.list',
|
|
4019
|
+
info: {
|
|
4020
|
+
version: '5.0.0',
|
|
4021
|
+
title: 'Cli: Command List'
|
|
4022
|
+
},
|
|
4023
|
+
options: {
|
|
4024
|
+
module: {
|
|
4025
|
+
description: 'module',
|
|
4026
|
+
type: 'string'
|
|
4027
|
+
},
|
|
4028
|
+
group: {
|
|
4029
|
+
description: 'group',
|
|
4030
|
+
type: 'string'
|
|
4031
|
+
}
|
|
4032
|
+
},
|
|
4033
|
+
groups: null
|
|
4034
|
+
};
|
|
4035
|
+
|
|
4036
|
+
var initAppMonkey = {
|
|
4037
|
+
bean: 'init.appMonkey',
|
|
4038
|
+
info: {
|
|
4039
|
+
version: '5.0.0',
|
|
4040
|
+
title: 'Cli: Init: App Monkey',
|
|
4041
|
+
usage: 'zova :init:appMonkey'
|
|
4042
|
+
}
|
|
4043
|
+
// options: null,
|
|
4044
|
+
// groups: null,
|
|
4045
|
+
};
|
|
4046
|
+
|
|
4047
|
+
var initAsset = {
|
|
4048
|
+
bean: 'init.asset',
|
|
4049
|
+
info: {
|
|
4050
|
+
version: '5.0.0',
|
|
4051
|
+
title: 'Cli: Init: Asset Resources',
|
|
4052
|
+
usage: 'zova :init:asset scene [--module=]'
|
|
4053
|
+
},
|
|
4054
|
+
options: {
|
|
4055
|
+
module: {
|
|
4056
|
+
description: 'module name',
|
|
4057
|
+
type: 'string'
|
|
4058
|
+
}
|
|
4059
|
+
},
|
|
4060
|
+
groups: {
|
|
4061
|
+
default: {
|
|
4062
|
+
questions: {
|
|
4063
|
+
scene: {
|
|
4064
|
+
type: 'input',
|
|
4065
|
+
message: 'scene',
|
|
4066
|
+
initial: {
|
|
4067
|
+
expression: 'context.argv._[0]'
|
|
4068
|
+
},
|
|
4069
|
+
required: true
|
|
4070
|
+
},
|
|
4071
|
+
module: {
|
|
4072
|
+
type: 'input',
|
|
4073
|
+
message: 'module name',
|
|
4074
|
+
required: true
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
};
|
|
4080
|
+
|
|
4081
|
+
var initConfig = {
|
|
4082
|
+
bean: 'init.config',
|
|
4083
|
+
info: {
|
|
4084
|
+
version: '5.0.0',
|
|
4085
|
+
title: 'Cli: Init: Config',
|
|
4086
|
+
usage: 'zova :init:config module'
|
|
4087
|
+
}
|
|
4088
|
+
// options: null,
|
|
4089
|
+
// groups: null,
|
|
4090
|
+
};
|
|
4091
|
+
|
|
4092
|
+
var initConstant = {
|
|
4093
|
+
bean: 'init.constant',
|
|
4094
|
+
info: {
|
|
4095
|
+
version: '5.0.0',
|
|
4096
|
+
title: 'Cli: Init: Constant',
|
|
4097
|
+
usage: 'zova :init:constant module'
|
|
4098
|
+
}
|
|
4099
|
+
// options: null,
|
|
4100
|
+
// groups: null,
|
|
4101
|
+
};
|
|
4102
|
+
|
|
4103
|
+
var initError = {
|
|
4104
|
+
bean: 'init.error',
|
|
4105
|
+
info: {
|
|
4106
|
+
version: '5.0.0',
|
|
4107
|
+
title: 'Cli: Init: Error',
|
|
4108
|
+
usage: 'zova :init:error module'
|
|
4109
|
+
}
|
|
4110
|
+
// options: null,
|
|
4111
|
+
// groups: null,
|
|
4112
|
+
};
|
|
4113
|
+
|
|
4114
|
+
var initIcon = {
|
|
4115
|
+
bean: 'init.icon',
|
|
4116
|
+
info: {
|
|
4117
|
+
version: '5.0.0',
|
|
4118
|
+
title: 'Cli: Init: Icon',
|
|
4119
|
+
usage: 'zova :init:icon module'
|
|
4120
|
+
}
|
|
4121
|
+
// options: null,
|
|
4122
|
+
// groups: null,
|
|
4123
|
+
};
|
|
4124
|
+
|
|
4125
|
+
var initLegacy = {
|
|
4126
|
+
bean: 'init.legacy',
|
|
4127
|
+
info: {
|
|
4128
|
+
version: '5.0.0',
|
|
4129
|
+
title: 'Cli: Init: Legacy',
|
|
4130
|
+
usage: 'zova :init:legacy'
|
|
4131
|
+
}
|
|
4132
|
+
// options: null,
|
|
4133
|
+
// groups: null,
|
|
4134
|
+
};
|
|
4135
|
+
|
|
4136
|
+
var initLib = {
|
|
4137
|
+
bean: 'init.lib',
|
|
4138
|
+
info: {
|
|
4139
|
+
version: '5.0.0',
|
|
4140
|
+
title: 'Cli: Init: Lib',
|
|
4141
|
+
usage: 'zova :init:lib module'
|
|
4142
|
+
}
|
|
4143
|
+
// options: null,
|
|
4144
|
+
// groups: null,
|
|
4145
|
+
};
|
|
4146
|
+
|
|
4147
|
+
var initLocale = {
|
|
4148
|
+
bean: 'init.locale',
|
|
4149
|
+
info: {
|
|
4150
|
+
version: '5.0.0',
|
|
4151
|
+
title: 'Cli: Init: Locale',
|
|
4152
|
+
usage: 'zova :init:locale module'
|
|
4153
|
+
}
|
|
4154
|
+
// options: null,
|
|
4155
|
+
// groups: null,
|
|
4156
|
+
};
|
|
4157
|
+
|
|
4158
|
+
var initMain = {
|
|
4159
|
+
bean: 'init.main',
|
|
4160
|
+
info: {
|
|
4161
|
+
version: '5.0.0',
|
|
4162
|
+
title: 'Cli: Init: Main',
|
|
4163
|
+
usage: 'zova :init:main module'
|
|
4164
|
+
}
|
|
4165
|
+
// options: null,
|
|
4166
|
+
// groups: null,
|
|
4167
|
+
};
|
|
4168
|
+
|
|
4169
|
+
var initMainSys = {
|
|
4170
|
+
bean: 'init.mainSys',
|
|
4171
|
+
info: {
|
|
4172
|
+
version: '5.0.0',
|
|
4173
|
+
title: 'Cli: Init: Main Sys',
|
|
4174
|
+
usage: 'zova :init:mainSys module'
|
|
4175
|
+
}
|
|
4176
|
+
// options: null,
|
|
4177
|
+
// groups: null,
|
|
4178
|
+
};
|
|
4179
|
+
|
|
4180
|
+
var initMonkey = {
|
|
4181
|
+
bean: 'init.monkey',
|
|
4182
|
+
info: {
|
|
4183
|
+
version: '5.0.0',
|
|
4184
|
+
title: 'Cli: Init: Monkey',
|
|
4185
|
+
usage: 'zova :init:monkey module'
|
|
4186
|
+
}
|
|
4187
|
+
// options: null,
|
|
4188
|
+
// groups: null,
|
|
4189
|
+
};
|
|
4190
|
+
|
|
4191
|
+
var initMonkeySys = {
|
|
4192
|
+
bean: 'init.monkeySys',
|
|
4193
|
+
info: {
|
|
4194
|
+
version: '5.0.0',
|
|
4195
|
+
title: 'Cli: Init: Monkey Sys',
|
|
4196
|
+
usage: 'zova :init:monkeySys module'
|
|
4197
|
+
}
|
|
4198
|
+
// options: null,
|
|
4199
|
+
// groups: null,
|
|
4200
|
+
};
|
|
4201
|
+
|
|
4202
|
+
var initSysMonkey = {
|
|
4203
|
+
bean: 'init.sysMonkey',
|
|
4204
|
+
info: {
|
|
4205
|
+
version: '5.0.0',
|
|
4206
|
+
title: 'Cli: Init: Sys Monkey',
|
|
4207
|
+
usage: 'zova :init:sysMonkey'
|
|
4208
|
+
}
|
|
4209
|
+
// options: null,
|
|
4210
|
+
// groups: null,
|
|
4211
|
+
};
|
|
4212
|
+
|
|
4213
|
+
var initTypes = {
|
|
4214
|
+
bean: 'init.types',
|
|
4215
|
+
info: {
|
|
4216
|
+
version: '5.0.0',
|
|
4217
|
+
title: 'Cli: Init: Types',
|
|
4218
|
+
usage: 'zova :init:types module'
|
|
4219
|
+
}
|
|
4220
|
+
// options: null,
|
|
4221
|
+
// groups: null,
|
|
4222
|
+
};
|
|
4223
|
+
|
|
4224
|
+
var openapiConfig = {
|
|
4225
|
+
bean: 'openapi.config',
|
|
4226
|
+
info: {
|
|
4227
|
+
version: '5.0.0',
|
|
4228
|
+
title: 'Cli: Openapi: Config',
|
|
4229
|
+
usage: 'zova :openapi:config module1 [module2]'
|
|
4230
|
+
}
|
|
4231
|
+
// options: null,
|
|
4232
|
+
// groups: null,
|
|
4233
|
+
};
|
|
4234
|
+
|
|
4235
|
+
var openapiGenerate = {
|
|
4236
|
+
bean: 'openapi.generate',
|
|
4237
|
+
info: {
|
|
4238
|
+
version: '5.0.0',
|
|
4239
|
+
title: 'Cli: Openapi: Generate',
|
|
4240
|
+
usage: 'zova :openapi:generate module1 [module2]'
|
|
4241
|
+
}
|
|
4242
|
+
// options: null,
|
|
4243
|
+
// groups: null,
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4246
|
+
var refactorAnotherRender = {
|
|
4247
|
+
bean: 'refactor.anotherRender',
|
|
4248
|
+
info: {
|
|
4249
|
+
version: '5.0.0',
|
|
4250
|
+
title: 'Cli: Refactor: Another Render',
|
|
4251
|
+
usage: 'zova :refactor:anotherRender componentName renderName [--module=]'
|
|
4252
|
+
},
|
|
4253
|
+
options: {
|
|
4254
|
+
module: {
|
|
4255
|
+
description: 'module name',
|
|
4256
|
+
type: 'string'
|
|
4257
|
+
}
|
|
4258
|
+
},
|
|
4259
|
+
groups: {
|
|
4260
|
+
default: {
|
|
4261
|
+
questions: {
|
|
4262
|
+
componentName: {
|
|
4263
|
+
type: 'input',
|
|
4264
|
+
message: 'componentName',
|
|
4265
|
+
initial: {
|
|
4266
|
+
expression: 'context.argv._[0]'
|
|
4267
|
+
},
|
|
4268
|
+
required: true
|
|
4269
|
+
},
|
|
4270
|
+
renderName: {
|
|
4271
|
+
type: 'input',
|
|
4272
|
+
message: 'renderName',
|
|
4273
|
+
initial: {
|
|
4274
|
+
expression: 'context.argv._[1]'
|
|
4275
|
+
},
|
|
4276
|
+
required: true
|
|
4277
|
+
},
|
|
4278
|
+
module: {
|
|
4279
|
+
type: 'input',
|
|
4280
|
+
message: 'module name',
|
|
4281
|
+
required: true
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
4285
|
+
}
|
|
4286
|
+
};
|
|
4287
|
+
|
|
4288
|
+
var refactorAnotherStyle = {
|
|
4289
|
+
bean: 'refactor.anotherStyle',
|
|
4290
|
+
info: {
|
|
4291
|
+
version: '5.0.0',
|
|
4292
|
+
title: 'Cli: Refactor: Another Style',
|
|
4293
|
+
usage: 'zova :refactor:anotherStyle componentName styleName [--module=]'
|
|
4294
|
+
},
|
|
4295
|
+
options: {
|
|
4296
|
+
module: {
|
|
4297
|
+
description: 'module name',
|
|
4298
|
+
type: 'string'
|
|
4299
|
+
}
|
|
4300
|
+
},
|
|
4301
|
+
groups: {
|
|
4302
|
+
default: {
|
|
4303
|
+
questions: {
|
|
4304
|
+
componentName: {
|
|
4305
|
+
type: 'input',
|
|
4306
|
+
message: 'componentName',
|
|
4307
|
+
initial: {
|
|
4308
|
+
expression: 'context.argv._[0]'
|
|
4309
|
+
},
|
|
4310
|
+
required: true
|
|
4311
|
+
},
|
|
4312
|
+
styleName: {
|
|
4313
|
+
type: 'input',
|
|
4314
|
+
message: 'styleName',
|
|
4315
|
+
initial: {
|
|
4316
|
+
expression: 'context.argv._[1]'
|
|
4317
|
+
},
|
|
4318
|
+
required: true
|
|
4319
|
+
},
|
|
4320
|
+
module: {
|
|
4321
|
+
type: 'input',
|
|
4322
|
+
message: 'module name',
|
|
4323
|
+
required: true
|
|
4324
|
+
}
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
};
|
|
4329
|
+
|
|
4330
|
+
var refactorComponentGeneric = {
|
|
4331
|
+
bean: 'refactor.componentGeneric',
|
|
4332
|
+
info: {
|
|
4333
|
+
version: '5.0.0',
|
|
4334
|
+
title: 'Cli: Refactor: ComponentGeneric',
|
|
4335
|
+
usage: 'zova :refactor:componentGeneric componentName [--module=]'
|
|
4336
|
+
},
|
|
4337
|
+
options: {
|
|
4338
|
+
module: {
|
|
4339
|
+
description: 'module name',
|
|
4340
|
+
type: 'string'
|
|
4341
|
+
}
|
|
4342
|
+
},
|
|
4343
|
+
groups: {
|
|
4344
|
+
default: {
|
|
4345
|
+
questions: {
|
|
4346
|
+
componentName: {
|
|
4347
|
+
type: 'input',
|
|
4348
|
+
message: 'componentName',
|
|
4349
|
+
initial: {
|
|
4350
|
+
expression: 'context.argv._[0]'
|
|
4351
|
+
},
|
|
4352
|
+
required: true
|
|
4353
|
+
},
|
|
4354
|
+
module: {
|
|
4355
|
+
type: 'input',
|
|
4356
|
+
message: 'module name',
|
|
4357
|
+
required: true
|
|
4358
|
+
}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
};
|
|
4363
|
+
|
|
4364
|
+
var refactorComponentModel = {
|
|
4365
|
+
bean: 'refactor.componentModel',
|
|
4366
|
+
info: {
|
|
4367
|
+
version: '5.0.0',
|
|
4368
|
+
title: 'Cli: Refactor: ComponentModel',
|
|
4369
|
+
usage: 'zova :refactor:componentModel componentName modelName [--module=]'
|
|
4370
|
+
},
|
|
4371
|
+
options: {
|
|
4372
|
+
module: {
|
|
4373
|
+
description: 'module name',
|
|
4374
|
+
type: 'string'
|
|
4375
|
+
}
|
|
4376
|
+
},
|
|
4377
|
+
groups: {
|
|
4378
|
+
default: {
|
|
4379
|
+
questions: {
|
|
4380
|
+
componentName: {
|
|
4381
|
+
type: 'input',
|
|
4382
|
+
message: 'componentName',
|
|
4383
|
+
initial: {
|
|
4384
|
+
expression: 'context.argv._[0]'
|
|
4385
|
+
},
|
|
4386
|
+
required: true
|
|
4387
|
+
},
|
|
4388
|
+
modelName: {
|
|
4389
|
+
type: 'input',
|
|
4390
|
+
message: 'modelName',
|
|
4391
|
+
initial: {
|
|
4392
|
+
expression: 'context.argv._[1]'
|
|
4393
|
+
},
|
|
4394
|
+
required: true
|
|
4395
|
+
},
|
|
4396
|
+
module: {
|
|
4397
|
+
type: 'input',
|
|
4398
|
+
message: 'module name',
|
|
4399
|
+
required: true
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
};
|
|
4405
|
+
|
|
4406
|
+
var refactorComponentProps = {
|
|
4407
|
+
bean: 'refactor.componentProps',
|
|
4408
|
+
info: {
|
|
4409
|
+
version: '5.0.0',
|
|
4410
|
+
title: 'Cli: Refactor: ComponentProps',
|
|
4411
|
+
usage: 'zova :refactor:componentProps componentName [--module=]'
|
|
4412
|
+
},
|
|
4413
|
+
options: {
|
|
4414
|
+
module: {
|
|
4415
|
+
description: 'module name',
|
|
4416
|
+
type: 'string'
|
|
4417
|
+
}
|
|
4418
|
+
},
|
|
4419
|
+
groups: {
|
|
4420
|
+
default: {
|
|
4421
|
+
questions: {
|
|
4422
|
+
componentName: {
|
|
4423
|
+
type: 'input',
|
|
4424
|
+
message: 'componentName',
|
|
4425
|
+
initial: {
|
|
4426
|
+
expression: 'context.argv._[0]'
|
|
4427
|
+
},
|
|
4428
|
+
required: true
|
|
4429
|
+
},
|
|
4430
|
+
module: {
|
|
4431
|
+
type: 'input',
|
|
4432
|
+
message: 'module name',
|
|
4433
|
+
required: true
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
};
|
|
4439
|
+
|
|
4440
|
+
var refactorFirstRender = {
|
|
4441
|
+
bean: 'refactor.firstRender',
|
|
4442
|
+
info: {
|
|
4443
|
+
version: '5.0.0',
|
|
4444
|
+
title: 'Cli: Refactor: First Render',
|
|
4445
|
+
usage: 'zova :refactor:firstRender componentName [--module=]'
|
|
4446
|
+
},
|
|
4447
|
+
options: {
|
|
4448
|
+
module: {
|
|
4449
|
+
description: 'module name',
|
|
4450
|
+
type: 'string'
|
|
4451
|
+
}
|
|
4452
|
+
},
|
|
4453
|
+
groups: {
|
|
4454
|
+
default: {
|
|
4455
|
+
questions: {
|
|
4456
|
+
componentName: {
|
|
4457
|
+
type: 'input',
|
|
4458
|
+
message: 'componentName',
|
|
4459
|
+
initial: {
|
|
4460
|
+
expression: 'context.argv._[0]'
|
|
4461
|
+
},
|
|
4462
|
+
required: true
|
|
4463
|
+
},
|
|
4464
|
+
module: {
|
|
4465
|
+
type: 'input',
|
|
4466
|
+
message: 'module name',
|
|
4467
|
+
required: true
|
|
4468
|
+
}
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
};
|
|
4473
|
+
|
|
4474
|
+
var refactorFirstStyle = {
|
|
4475
|
+
bean: 'refactor.firstStyle',
|
|
4476
|
+
info: {
|
|
4477
|
+
version: '5.0.0',
|
|
4478
|
+
title: 'Cli: Refactor: First Style',
|
|
4479
|
+
usage: 'zova :refactor:firstStyle componentName [--module=]'
|
|
4480
|
+
},
|
|
4481
|
+
options: {
|
|
4482
|
+
module: {
|
|
4483
|
+
description: 'module name',
|
|
4484
|
+
type: 'string'
|
|
4485
|
+
}
|
|
4486
|
+
},
|
|
4487
|
+
groups: {
|
|
4488
|
+
default: {
|
|
4489
|
+
questions: {
|
|
4490
|
+
componentName: {
|
|
4491
|
+
type: 'input',
|
|
4492
|
+
message: 'componentName',
|
|
4493
|
+
initial: {
|
|
4494
|
+
expression: 'context.argv._[0]'
|
|
4495
|
+
},
|
|
4496
|
+
required: true
|
|
4497
|
+
},
|
|
4498
|
+
module: {
|
|
4499
|
+
type: 'input',
|
|
4500
|
+
message: 'module name',
|
|
4501
|
+
required: true
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4506
|
+
};
|
|
4507
|
+
|
|
4508
|
+
var refactorPageParams = {
|
|
4509
|
+
bean: 'refactor.pageParams',
|
|
4510
|
+
info: {
|
|
4511
|
+
version: '5.0.0',
|
|
4512
|
+
title: 'Cli: Refactor: PageParams',
|
|
4513
|
+
usage: 'zova :refactor:pageParams pageName [--module=]'
|
|
4514
|
+
},
|
|
4515
|
+
options: {
|
|
4516
|
+
module: {
|
|
4517
|
+
description: 'module name',
|
|
4518
|
+
type: 'string'
|
|
4519
|
+
}
|
|
4520
|
+
},
|
|
4521
|
+
groups: {
|
|
4522
|
+
default: {
|
|
4523
|
+
questions: {
|
|
4524
|
+
pageName: {
|
|
4525
|
+
type: 'input',
|
|
4526
|
+
message: 'pageName',
|
|
4527
|
+
initial: {
|
|
4528
|
+
expression: 'context.argv._[0]'
|
|
4529
|
+
},
|
|
4530
|
+
required: true
|
|
4531
|
+
},
|
|
4532
|
+
module: {
|
|
4533
|
+
type: 'input',
|
|
4534
|
+
message: 'module name',
|
|
4535
|
+
required: true
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
}
|
|
4540
|
+
};
|
|
4541
|
+
|
|
4542
|
+
var refactorPageQuery = {
|
|
4543
|
+
bean: 'refactor.pageQuery',
|
|
4544
|
+
info: {
|
|
4545
|
+
version: '5.0.0',
|
|
4546
|
+
title: 'Cli: Refactor: PageQuery',
|
|
4547
|
+
usage: 'zova :refactor:pageQuery pageName [--module=]'
|
|
4548
|
+
},
|
|
4549
|
+
options: {
|
|
4550
|
+
module: {
|
|
4551
|
+
description: 'module name',
|
|
4552
|
+
type: 'string'
|
|
4553
|
+
}
|
|
4554
|
+
},
|
|
4555
|
+
groups: {
|
|
4556
|
+
default: {
|
|
4557
|
+
questions: {
|
|
4558
|
+
pageName: {
|
|
4559
|
+
type: 'input',
|
|
4560
|
+
message: 'pageName',
|
|
4561
|
+
initial: {
|
|
4562
|
+
expression: 'context.argv._[0]'
|
|
4563
|
+
},
|
|
4564
|
+
required: true
|
|
4565
|
+
},
|
|
4566
|
+
module: {
|
|
4567
|
+
type: 'input',
|
|
4568
|
+
message: 'module name',
|
|
4569
|
+
required: true
|
|
4570
|
+
}
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
}
|
|
4574
|
+
};
|
|
4575
|
+
|
|
4576
|
+
var refactorRenameComponent = {
|
|
4577
|
+
bean: 'refactor.renameComponent',
|
|
4578
|
+
info: {
|
|
4579
|
+
version: '5.0.0',
|
|
4580
|
+
title: 'Cli: Refactor: Rename Component',
|
|
4581
|
+
usage: 'zova :refactor:renameComponent componentName componentNameNew [--module=]'
|
|
4582
|
+
},
|
|
4583
|
+
options: {
|
|
4584
|
+
module: {
|
|
4585
|
+
description: 'module name',
|
|
4586
|
+
type: 'string'
|
|
4587
|
+
}
|
|
4588
|
+
},
|
|
4589
|
+
groups: {
|
|
4590
|
+
default: {
|
|
4591
|
+
questions: {
|
|
4592
|
+
componentName: {
|
|
4593
|
+
type: 'input',
|
|
4594
|
+
message: 'componentName',
|
|
4595
|
+
initial: {
|
|
4596
|
+
expression: 'context.argv._[0]'
|
|
4597
|
+
},
|
|
4598
|
+
required: true
|
|
4599
|
+
},
|
|
4600
|
+
componentNameNew: {
|
|
4601
|
+
type: 'input',
|
|
4602
|
+
message: 'componentNameNew',
|
|
4603
|
+
initial: {
|
|
4604
|
+
expression: 'context.argv._[1]'
|
|
4605
|
+
},
|
|
4606
|
+
required: true
|
|
4607
|
+
},
|
|
4608
|
+
module: {
|
|
4609
|
+
type: 'input',
|
|
4610
|
+
message: 'module name',
|
|
4611
|
+
required: true
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
};
|
|
4617
|
+
|
|
4618
|
+
var toolsDeps = {
|
|
4619
|
+
bean: 'tools.deps',
|
|
4620
|
+
info: {
|
|
4621
|
+
version: '5.0.0',
|
|
4622
|
+
title: 'Cli: Tools: Deps',
|
|
4623
|
+
usage: 'zova :tools:deps [--force]'
|
|
4624
|
+
},
|
|
4625
|
+
options: {
|
|
4626
|
+
force: {
|
|
4627
|
+
description: 'force',
|
|
4628
|
+
type: 'boolean'
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
};
|
|
4632
|
+
|
|
4633
|
+
var toolsMetadata = {
|
|
4634
|
+
bean: 'tools.metadata',
|
|
4635
|
+
info: {
|
|
4636
|
+
version: '5.0.0',
|
|
4637
|
+
title: 'Cli: Tools: Metadata',
|
|
4638
|
+
usage: 'zova :tools:metadata module1 [module2] [--force]'
|
|
4639
|
+
},
|
|
4640
|
+
options: {
|
|
4641
|
+
force: {
|
|
4642
|
+
description: 'force',
|
|
4643
|
+
type: 'boolean'
|
|
4644
|
+
}
|
|
4645
|
+
}
|
|
4646
|
+
};
|
|
4647
|
+
|
|
4648
|
+
const commands = {
|
|
4649
|
+
default: {
|
|
4650
|
+
list: defaultList
|
|
4651
|
+
},
|
|
4652
|
+
bin: {
|
|
4653
|
+
buildModule: binBuildModule,
|
|
4654
|
+
buildRest: binBuildRest
|
|
4655
|
+
},
|
|
4656
|
+
create: {
|
|
4657
|
+
project: createProject,
|
|
4658
|
+
suite: createSuite,
|
|
4659
|
+
module: createModule,
|
|
4660
|
+
page: createPage,
|
|
4661
|
+
component: createComponent,
|
|
4662
|
+
mock: createMock,
|
|
4663
|
+
bean: createBean
|
|
4664
|
+
},
|
|
4665
|
+
init: {
|
|
4666
|
+
icon: initIcon,
|
|
4667
|
+
config: initConfig,
|
|
4668
|
+
constant: initConstant,
|
|
4669
|
+
locale: initLocale,
|
|
4670
|
+
error: initError,
|
|
4671
|
+
legacy: initLegacy,
|
|
4672
|
+
appMonkey: initAppMonkey,
|
|
4673
|
+
sysMonkey: initSysMonkey,
|
|
4674
|
+
monkey: initMonkey,
|
|
4675
|
+
monkeySys: initMonkeySys,
|
|
4676
|
+
main: initMain,
|
|
4677
|
+
mainSys: initMainSys,
|
|
4678
|
+
asset: initAsset,
|
|
4679
|
+
lib: initLib,
|
|
4680
|
+
types: initTypes
|
|
4681
|
+
},
|
|
4682
|
+
refactor: {
|
|
4683
|
+
pageQuery: refactorPageQuery,
|
|
4684
|
+
pageParams: refactorPageParams,
|
|
4685
|
+
componentGeneric: refactorComponentGeneric,
|
|
4686
|
+
firstRender: refactorFirstRender,
|
|
4687
|
+
firstStyle: refactorFirstStyle,
|
|
4688
|
+
anotherRender: refactorAnotherRender,
|
|
4689
|
+
anotherStyle: refactorAnotherStyle,
|
|
4690
|
+
componentProps: refactorComponentProps,
|
|
4691
|
+
// componentEmits: refactorComponentEmits,
|
|
4692
|
+
// componentSlots: refactorComponentSlots,
|
|
4693
|
+
componentModel: refactorComponentModel,
|
|
4694
|
+
renameComponent: refactorRenameComponent
|
|
4695
|
+
},
|
|
4696
|
+
tools: {
|
|
4697
|
+
// icon: toolsIcon,
|
|
4698
|
+
metadata: toolsMetadata,
|
|
4699
|
+
deps: toolsDeps
|
|
4700
|
+
},
|
|
4701
|
+
openapi: {
|
|
4702
|
+
config: openapiConfig,
|
|
4703
|
+
generate: openapiGenerate
|
|
4704
|
+
}
|
|
4705
|
+
};
|
|
4706
|
+
|
|
4707
|
+
export { beans, commands, getAbsolutePathOfModule };
|