vona-cli-set-api 1.0.401 → 1.0.405
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/templates/create/project/basic/boilerplate/env/.env +1 -1
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod +1 -1
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod.ci +0 -3
- package/cli/templates/create/project/basic/boilerplate/env/.env.prod.docker +0 -3
- package/cli/templates/create/project/basic/boilerplate/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/backend/config/config/config.ts +1 -0
- package/cli/templates/tools/crud/snippets/2-meta.index.ts +10 -5
- package/cli/templates/tools/crud/snippets/2-meta.version.ts +11 -9
- package/cli/templates/tools/crud/snippets/3-en-us.ts +1 -1
- package/cli/templates/tools/crud/snippets/4-zh-cn.ts +1 -1
- package/cli/templates/tools/crud/utils.ts +15 -15
- package/dist/index.js +3313 -3
- package/dist/lib/bean/cli.bin.buildGeneral.d.ts +12 -0
- package/dist/lib/beans.d.ts +2 -0
- package/dist/lib/command/bin.buildGeneral.d.ts +19 -0
- package/dist/lib/commands.d.ts +18 -0
- package/package.json +9 -9
- package/dist/lib/bean/cli.bin.build.js +0 -185
- package/dist/lib/bean/cli.bin.buildModule.js +0 -106
- package/dist/lib/bean/cli.bin.dbReset.js +0 -48
- package/dist/lib/bean/cli.bin.dev.js +0 -66
- package/dist/lib/bean/cli.bin.play.js +0 -92
- package/dist/lib/bean/cli.bin.test.js +0 -93
- package/dist/lib/bean/cli.bin.tsc.js +0 -48
- package/dist/lib/bean/cli.create.bean.js +0 -81
- package/dist/lib/bean/cli.create.module.js +0 -73
- package/dist/lib/bean/cli.create.project.js +0 -119
- package/dist/lib/bean/cli.create.suite.js +0 -35
- package/dist/lib/bean/cli.create.test.js +0 -39
- package/dist/lib/bean/cli.default.list.js +0 -93
- package/dist/lib/bean/cli.init.appMonkey.js +0 -24
- package/dist/lib/bean/cli.init.asset.js +0 -28
- package/dist/lib/bean/cli.init.config.js +0 -38
- package/dist/lib/bean/cli.init.constant.js +0 -38
- package/dist/lib/bean/cli.init.error.js +0 -49
- package/dist/lib/bean/cli.init.lib.js +0 -38
- package/dist/lib/bean/cli.init.locale.js +0 -38
- package/dist/lib/bean/cli.init.main.js +0 -38
- package/dist/lib/bean/cli.init.monkey.js +0 -64
- package/dist/lib/bean/cli.init.static.js +0 -38
- package/dist/lib/bean/cli.init.types.js +0 -38
- package/dist/lib/bean/cli.tools.crud.js +0 -46
- package/dist/lib/bean/cli.tools.deps.js +0 -42
- package/dist/lib/bean/cli.tools.metadata.js +0 -234
- package/dist/lib/bean/toolsBin/configUtils.js +0 -56
- package/dist/lib/bean/toolsBin/dbReset.js +0 -8
- package/dist/lib/bean/toolsBin/generateEntryFiles.js +0 -90
- package/dist/lib/bean/toolsBin/generateVonaMeta.js +0 -17
- package/dist/lib/bean/toolsBin/generateZod.js +0 -48
- package/dist/lib/bean/toolsBin/play.js +0 -59
- package/dist/lib/bean/toolsBin/test.js +0 -137
- package/dist/lib/bean/toolsBin/types.js +0 -1
- package/dist/lib/bean/toolsMetadata/generateBeanGenerals.js +0 -33
- package/dist/lib/bean/toolsMetadata/generateConfig.js +0 -62
- package/dist/lib/bean/toolsMetadata/generateMetadataCustom.js +0 -23
- package/dist/lib/bean/toolsMetadata/generateMonkey.js +0 -24
- package/dist/lib/bean/toolsMetadata/generateOnions.js +0 -112
- package/dist/lib/bean/toolsMetadata/generateScope.js +0 -83
- package/dist/lib/bean/toolsMetadata/generateScopeResources.js +0 -33
- package/dist/lib/bean/toolsMetadata/generateScopeResourcesMeta.js +0 -13
- package/dist/lib/bean/toolsMetadata/utils.js +0 -84
- package/dist/lib/beans.js +0 -56
- package/dist/lib/command/bin.build.js +0 -18
- package/dist/lib/command/bin.buildModule.js +0 -18
- package/dist/lib/command/bin.dbReset.js +0 -14
- package/dist/lib/command/bin.dev.js +0 -18
- package/dist/lib/command/bin.play.js +0 -27
- package/dist/lib/command/bin.test.js +0 -18
- package/dist/lib/command/bin.tsc.js +0 -14
- package/dist/lib/command/create.bean.js +0 -46
- package/dist/lib/command/create.module.js +0 -36
- package/dist/lib/command/create.project.js +0 -43
- package/dist/lib/command/create.suite.js +0 -23
- package/dist/lib/command/create.test.js +0 -33
- package/dist/lib/command/default.list.js +0 -18
- package/dist/lib/command/init.appMonkey.js +0 -10
- package/dist/lib/command/init.asset.js +0 -33
- package/dist/lib/command/init.config.js +0 -10
- package/dist/lib/command/init.constant.js +0 -10
- package/dist/lib/command/init.error.js +0 -10
- package/dist/lib/command/init.lib.js +0 -10
- package/dist/lib/command/init.locale.js +0 -10
- package/dist/lib/command/init.main.js +0 -10
- package/dist/lib/command/init.monkey.js +0 -10
- package/dist/lib/command/init.static.js +0 -10
- package/dist/lib/command/init.types.js +0 -10
- package/dist/lib/command/tools.crud.js +0 -33
- package/dist/lib/command/tools.deps.js +0 -9
- package/dist/lib/command/tools.metadata.js +0 -14
- package/dist/lib/commands.js +0 -67
- package/dist/lib/this.js +0 -1
- package/dist/lib/utils.js +0 -80
- package/dist/typings.js +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitConstant extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const constantFile = path.join(targetDir, 'src/config/constants.ts');
|
|
23
|
-
if (fse.existsSync(constantFile)) {
|
|
24
|
-
throw new Error(`constant exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/constant/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// tools.metadata
|
|
34
|
-
if (!argv.nometadata) {
|
|
35
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitError extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const errorFile = path.join(targetDir, 'src/config/errors.ts');
|
|
23
|
-
if (fse.existsSync(errorFile)) {
|
|
24
|
-
throw new Error(`error exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/error/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// special for locale
|
|
34
|
-
const localeFile = path.join(targetDir, 'src/config/locale');
|
|
35
|
-
if (!fse.existsSync(localeFile)) {
|
|
36
|
-
// render boilerplate
|
|
37
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
38
|
-
targetDir: path.join(targetDir, 'src'),
|
|
39
|
-
setName: __ThisSetName__,
|
|
40
|
-
snippetsPath: null,
|
|
41
|
-
boilerplatePath: 'init/locale/boilerplate',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// tools.metadata
|
|
45
|
-
if (!argv.nometadata) {
|
|
46
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitLib extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const mainFile = path.join(targetDir, 'src/lib/index.ts');
|
|
23
|
-
if (fse.existsSync(mainFile)) {
|
|
24
|
-
throw new Error(`lib exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/lib/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// tools.metadata
|
|
34
|
-
if (!argv.nometadata) {
|
|
35
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitLocale extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const localeFile = path.join(targetDir, 'src/config/locale');
|
|
23
|
-
if (fse.existsSync(localeFile)) {
|
|
24
|
-
throw new Error(`locale exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/locale/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// tools.metadata
|
|
34
|
-
if (!argv.nometadata) {
|
|
35
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitMain extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const mainFile = path.join(targetDir, 'src/main.ts');
|
|
23
|
-
if (fse.existsSync(mainFile)) {
|
|
24
|
-
throw new Error(`main exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/main/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// tools.metadata
|
|
34
|
-
if (!argv.nometadata) {
|
|
35
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitMonkey extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const monkeyFile = path.join(targetDir, 'src/monkey.ts');
|
|
23
|
-
if (fse.existsSync(monkeyFile)) {
|
|
24
|
-
throw new Error(`monkey exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/monkey/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// set vonaModule.capabilities.monkey: true
|
|
34
|
-
await this._setPackageInfo(targetDir);
|
|
35
|
-
// tools.metadata
|
|
36
|
-
if (!argv.nometadata) {
|
|
37
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async _setPackageInfo(modulePath) {
|
|
41
|
-
const pkgFile = path.join(modulePath, 'package.json');
|
|
42
|
-
const pkg = await this.helper.loadJSONFile(pkgFile);
|
|
43
|
-
if (!pkg.vonaModule)
|
|
44
|
-
pkg.vonaModule = {};
|
|
45
|
-
if (!pkg.vonaModule.capabilities)
|
|
46
|
-
pkg.vonaModule.capabilities = {};
|
|
47
|
-
let changed;
|
|
48
|
-
// monkey
|
|
49
|
-
if (!pkg.vonaModule.capabilities.monkey) {
|
|
50
|
-
pkg.vonaModule.capabilities.monkey = true;
|
|
51
|
-
changed = true;
|
|
52
|
-
}
|
|
53
|
-
// // dependencies
|
|
54
|
-
// if (!pkg.vonaModule.dependencies) pkg.vonaModule.dependencies = {};
|
|
55
|
-
// if (!pkg.vonaModule.dependencies['a-vona']) {
|
|
56
|
-
// pkg.vonaModule.dependencies['a-vona'] = '5.0.0';
|
|
57
|
-
// changed = true;
|
|
58
|
-
// }
|
|
59
|
-
// save
|
|
60
|
-
if (changed) {
|
|
61
|
-
await this.helper.saveJSONFile(pkgFile, pkg);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitStatic extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const staticDir = path.join(targetDir, 'assets/static');
|
|
23
|
-
if (fse.existsSync(staticDir)) {
|
|
24
|
-
throw new Error(`static exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir,
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/static/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// // tools.metadata
|
|
34
|
-
// if (!argv.nometadata) {
|
|
35
|
-
// await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
// }
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { __ThisSetName__ } from "../this.js";
|
|
5
|
-
export class CliInitTypes extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
// module name/info
|
|
11
|
-
const moduleName = argv._[0];
|
|
12
|
-
if (!moduleName)
|
|
13
|
-
return;
|
|
14
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
15
|
-
// check if exists
|
|
16
|
-
const _module = this.helper.findModule(moduleName);
|
|
17
|
-
if (!_module) {
|
|
18
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
19
|
-
}
|
|
20
|
-
// target dir
|
|
21
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
22
|
-
const mainFile = path.join(targetDir, 'src/types/index.ts');
|
|
23
|
-
if (fse.existsSync(mainFile)) {
|
|
24
|
-
throw new Error(`types exists: ${moduleName}`);
|
|
25
|
-
}
|
|
26
|
-
// render boilerplate
|
|
27
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
28
|
-
targetDir: path.join(targetDir, 'src'),
|
|
29
|
-
setName: __ThisSetName__,
|
|
30
|
-
snippetsPath: null,
|
|
31
|
-
boilerplatePath: 'init/types/boilerplate',
|
|
32
|
-
});
|
|
33
|
-
// tools.metadata
|
|
34
|
-
if (!argv.nometadata) {
|
|
35
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
4
|
-
import { combineApiPathControllerAndActionRaw } from '@cabloy/utils';
|
|
5
|
-
import { __ThisSetName__ } from "../this.js";
|
|
6
|
-
export class CliToolsCrud extends BeanCliBase {
|
|
7
|
-
async execute() {
|
|
8
|
-
const { argv } = this.context;
|
|
9
|
-
// super
|
|
10
|
-
await super.execute();
|
|
11
|
-
// noformat
|
|
12
|
-
argv.noformat = true;
|
|
13
|
-
// module name/info
|
|
14
|
-
const moduleName = argv.module;
|
|
15
|
-
argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
|
|
16
|
-
// check if exists
|
|
17
|
-
const _module = this.helper.findModule(moduleName);
|
|
18
|
-
if (!_module) {
|
|
19
|
-
throw new Error(`module does not exist: ${moduleName}`);
|
|
20
|
-
}
|
|
21
|
-
// target dir
|
|
22
|
-
const targetDir = await this.helper.ensureDir(_module.root);
|
|
23
|
-
// resourceName
|
|
24
|
-
const resourceName = argv.resourceName;
|
|
25
|
-
argv.resourceNameCapitalize = this.helper.firstCharToUpperCase(resourceName);
|
|
26
|
-
// moduleResourceName
|
|
27
|
-
argv.moduleResourceName = this.helper.combineModuleNameAndResource(argv.moduleInfo.relativeName, argv.resourceName);
|
|
28
|
-
argv.moduleActionPathRaw = combineApiPathControllerAndActionRaw(moduleName, resourceName, '', true);
|
|
29
|
-
// controller
|
|
30
|
-
const controllerFile = path.join(targetDir, 'src/controller', `${resourceName}.ts`);
|
|
31
|
-
if (fs.existsSync(controllerFile)) {
|
|
32
|
-
throw new Error(`resource exists: ${resourceName}`);
|
|
33
|
-
}
|
|
34
|
-
// render
|
|
35
|
-
await this.template.renderBoilerplateAndSnippets({
|
|
36
|
-
targetDir,
|
|
37
|
-
setName: __ThisSetName__,
|
|
38
|
-
snippetsPath: 'tools/crud/snippets',
|
|
39
|
-
boilerplatePath: 'tools/crud/boilerplate',
|
|
40
|
-
});
|
|
41
|
-
// tools.metadata
|
|
42
|
-
if (!argv.nometadata) {
|
|
43
|
-
await this.helper.invokeCli([':tools:metadata', moduleName], { cwd: argv.projectPath });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import fse from 'fs-extra';
|
|
4
|
-
import { resolveTemplatePath } from "../utils.js";
|
|
5
|
-
export class CliToolsDeps extends BeanCliBase {
|
|
6
|
-
async execute() {
|
|
7
|
-
const { argv } = this.context;
|
|
8
|
-
// super
|
|
9
|
-
await super.execute();
|
|
10
|
-
const projectPath = argv.projectPath;
|
|
11
|
-
// generate
|
|
12
|
-
await this._generate(projectPath);
|
|
13
|
-
}
|
|
14
|
-
async _generate(projectPath) {
|
|
15
|
-
// generate package.json
|
|
16
|
-
await this.common._generatePackageJson(projectPath);
|
|
17
|
-
// generate type modules file
|
|
18
|
-
await this.common._generateTypeModulesFile(projectPath);
|
|
19
|
-
// generate type project file
|
|
20
|
-
await this._generateTypeProjectFile(projectPath);
|
|
21
|
-
}
|
|
22
|
-
_getProjectMode(projectPath) {
|
|
23
|
-
const vonaPath = this._getVonaPath(projectPath);
|
|
24
|
-
return vonaPath.includes('packages-vona') ? 'source' : 'project';
|
|
25
|
-
}
|
|
26
|
-
_getVonaPath(projectPath) {
|
|
27
|
-
let vonaPath = path.join(projectPath, 'packages-vona/vona');
|
|
28
|
-
if (fse.existsSync(vonaPath))
|
|
29
|
-
return vonaPath;
|
|
30
|
-
vonaPath = path.join(projectPath, 'node_modules/vona');
|
|
31
|
-
if (fse.existsSync(vonaPath))
|
|
32
|
-
return vonaPath;
|
|
33
|
-
}
|
|
34
|
-
async _generateTypeProjectFile(projectPath) {
|
|
35
|
-
const projectMode = this._getProjectMode(projectPath);
|
|
36
|
-
const fileTemplate = resolveTemplatePath(`config/_tsconfig_${projectMode}.json`);
|
|
37
|
-
const fileConfig = path.join(projectPath, 'tsconfig.json');
|
|
38
|
-
if (!fse.existsSync(fileConfig)) {
|
|
39
|
-
await fse.copyFile(fileTemplate, fileConfig);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { BeanCliBase } from '@cabloy/cli';
|
|
3
|
-
import { getOnionMetasMeta, getOnionScenesMeta } from '@cabloy/module-info';
|
|
4
|
-
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
5
|
-
import fse from 'fs-extra';
|
|
6
|
-
import { loadJSONFile, saveJSONFile } from "../utils.js";
|
|
7
|
-
import { generateBeanGenerals } from "./toolsMetadata/generateBeanGenerals.js";
|
|
8
|
-
import { generateConfig, generateConstant, generateError, generateLocale } from "./toolsMetadata/generateConfig.js";
|
|
9
|
-
import { generateMetadataCustom } from "./toolsMetadata/generateMetadataCustom.js";
|
|
10
|
-
import { generateMain, generateMonkey } from "./toolsMetadata/generateMonkey.js";
|
|
11
|
-
import { generateOnions } from "./toolsMetadata/generateOnions.js";
|
|
12
|
-
import { generateScope } from "./toolsMetadata/generateScope.js";
|
|
13
|
-
import { generateScopeResources } from "./toolsMetadata/generateScopeResources.js";
|
|
14
|
-
import { generateScopeResourcesMeta } from "./toolsMetadata/generateScopeResourcesMeta.js";
|
|
15
|
-
export class CliToolsMetadata extends BeanCliBase {
|
|
16
|
-
async execute() {
|
|
17
|
-
const { argv } = this.context;
|
|
18
|
-
// super
|
|
19
|
-
await super.execute();
|
|
20
|
-
// noformat: src/index.ts need format
|
|
21
|
-
// argv.noformat = true;
|
|
22
|
-
// moduleNames
|
|
23
|
-
let moduleNames = argv._;
|
|
24
|
-
const force = argv.force ?? moduleNames.length > 0;
|
|
25
|
-
if (moduleNames.length === 0) {
|
|
26
|
-
moduleNames = this.modulesMeta.modulesArray
|
|
27
|
-
.filter(item => !item.info.node_modules)
|
|
28
|
-
.map(item => item.info.relativeName);
|
|
29
|
-
}
|
|
30
|
-
const total = moduleNames.length;
|
|
31
|
-
for (let index = 0; index < total; index++) {
|
|
32
|
-
const moduleName = moduleNames[index];
|
|
33
|
-
// log
|
|
34
|
-
await this.console.log({
|
|
35
|
-
total,
|
|
36
|
-
progress: index,
|
|
37
|
-
text: moduleName,
|
|
38
|
-
});
|
|
39
|
-
// generate res
|
|
40
|
-
await this._generateMetadata(moduleName, force);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async _generateMetadata(moduleName, force) {
|
|
44
|
-
const module = this.helper.findModule(moduleName);
|
|
45
|
-
if (!module)
|
|
46
|
-
throw new Error(`module not found: ${moduleName}`);
|
|
47
|
-
const modulePath = module.root;
|
|
48
|
-
const metaDir = path.join(modulePath, 'src/.metadata');
|
|
49
|
-
const metaIndexFile = path.join(metaDir, 'index.ts');
|
|
50
|
-
if (fse.existsSync(metaIndexFile) && !force) {
|
|
51
|
-
// do nothing
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
await this.helper.ensureDir(metaDir);
|
|
55
|
-
// relativeNameCapitalize
|
|
56
|
-
const relativeNameCapitalize = this.helper.stringToCapitalize(moduleName, '-');
|
|
57
|
-
// onionScenesMeta
|
|
58
|
-
const onionScenesMeta = getOnionScenesMeta(this.modulesMeta.modules);
|
|
59
|
-
// content
|
|
60
|
-
let content = '';
|
|
61
|
-
// onions
|
|
62
|
-
const scopeResources = {};
|
|
63
|
-
for (const sceneName in onionScenesMeta) {
|
|
64
|
-
const sceneMeta = onionScenesMeta[sceneName];
|
|
65
|
-
// general
|
|
66
|
-
content += await generateOnions(sceneName, sceneMeta, moduleName, modulePath);
|
|
67
|
-
// scope resources
|
|
68
|
-
if (sceneMeta.scopeResource) {
|
|
69
|
-
const contentScopeResource = await generateScopeResources(sceneName, sceneMeta, moduleName, modulePath);
|
|
70
|
-
if (contentScopeResource) {
|
|
71
|
-
content += contentScopeResource;
|
|
72
|
-
scopeResources[sceneName] = `IModule${toUpperCaseFirstChar(sceneName)}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// bean generals
|
|
76
|
-
if (sceneMeta.beanGeneral) {
|
|
77
|
-
content += await generateBeanGenerals(sceneName, sceneMeta, moduleName, modulePath);
|
|
78
|
-
}
|
|
79
|
-
// metas
|
|
80
|
-
if (sceneName === 'meta') {
|
|
81
|
-
const onionMetasMeta = getOnionMetasMeta(this.modulesMeta.modules);
|
|
82
|
-
for (const metaName in onionMetasMeta) {
|
|
83
|
-
const metaMeta = onionMetasMeta[metaName];
|
|
84
|
-
if (metaMeta.scopeResource) {
|
|
85
|
-
const contentScopeResourceMeta = await generateScopeResourcesMeta(metaName, metaMeta, sceneName, sceneMeta, moduleName, modulePath);
|
|
86
|
-
if (contentScopeResourceMeta) {
|
|
87
|
-
content += contentScopeResourceMeta;
|
|
88
|
-
scopeResources[metaName] = `Meta${toUpperCaseFirstChar(metaName)}`;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// metadata custom
|
|
94
|
-
if (sceneMeta.metadataCustom) {
|
|
95
|
-
content += await generateMetadataCustom(this, sceneName, sceneMeta, moduleName, modulePath);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// config
|
|
99
|
-
const contentConfig = await generateConfig(modulePath);
|
|
100
|
-
content += contentConfig;
|
|
101
|
-
// constant
|
|
102
|
-
const contentConstants = await generateConstant(modulePath);
|
|
103
|
-
content += contentConstants;
|
|
104
|
-
// locale
|
|
105
|
-
const contentLocales = await generateLocale(modulePath);
|
|
106
|
-
content += contentLocales;
|
|
107
|
-
// error
|
|
108
|
-
const contentErrors = await generateError(modulePath);
|
|
109
|
-
content += contentErrors;
|
|
110
|
-
// monkey
|
|
111
|
-
content += await generateMonkey(modulePath);
|
|
112
|
-
// main
|
|
113
|
-
content += await generateMain(modulePath);
|
|
114
|
-
// scope
|
|
115
|
-
content += await generateScope(moduleName, relativeNameCapitalize, scopeResources, {
|
|
116
|
-
config: contentConfig,
|
|
117
|
-
errors: contentErrors,
|
|
118
|
-
locales: contentLocales,
|
|
119
|
-
constants: contentConstants,
|
|
120
|
-
});
|
|
121
|
-
// patch
|
|
122
|
-
content = this._generatePatch(content);
|
|
123
|
-
// empty
|
|
124
|
-
if (!content.trim()) {
|
|
125
|
-
content = 'export {};';
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
content = `/* eslint-disable */\n${content}`;
|
|
129
|
-
}
|
|
130
|
-
// save
|
|
131
|
-
await fse.writeFile(metaIndexFile, content);
|
|
132
|
-
// await this.helper.formatFile({ fileName: metaIndexFile, logPrefix: 'format: ' });
|
|
133
|
-
// generate this
|
|
134
|
-
await this._generateThis(moduleName, relativeNameCapitalize, modulePath);
|
|
135
|
-
// index
|
|
136
|
-
await this._generateIndex(modulePath);
|
|
137
|
-
// package
|
|
138
|
-
await this._generatePackage(modulePath);
|
|
139
|
-
}
|
|
140
|
-
_generatePatch(content) {
|
|
141
|
-
if (!content)
|
|
142
|
-
return content;
|
|
143
|
-
content = this._generatePatch_resources(content, 'table-identity', ['TableIdentity'], true);
|
|
144
|
-
content = this._generatePatch_resources(content, 'vona-module-a-openapi', ['TypeEntityOptionsFields', 'TypeControllerOptionsActions'], true);
|
|
145
|
-
content = this._generatePatch_resources(content, 'vona-module-a-orm', [
|
|
146
|
-
'TypeEntityMeta',
|
|
147
|
-
'TypeModelsClassLikeGeneral',
|
|
148
|
-
'TypeSymbolKeyFieldsMore',
|
|
149
|
-
'IModelRelationHasOne',
|
|
150
|
-
'IModelRelationBelongsTo',
|
|
151
|
-
'IModelRelationHasMany',
|
|
152
|
-
'IModelRelationBelongsToMany',
|
|
153
|
-
], true);
|
|
154
|
-
content = this._generatePatch_resources(content, 'vona', ['PowerPartial'], true);
|
|
155
|
-
return content;
|
|
156
|
-
}
|
|
157
|
-
_generatePatch_resources(content, packageName, resources, type) {
|
|
158
|
-
const items = resources.filter(item => {
|
|
159
|
-
const regexp = new RegExp(`${item}[\\[\\]<,;?:\\s]`);
|
|
160
|
-
return !!regexp.exec(content);
|
|
161
|
-
});
|
|
162
|
-
if (items.length === 0)
|
|
163
|
-
return content;
|
|
164
|
-
const importContent = `import ${type ? 'type ' : ''}{ ${items.join(',')} } from '${packageName}';`;
|
|
165
|
-
return `${importContent}\n${content}`;
|
|
166
|
-
}
|
|
167
|
-
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
168
|
-
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
169
|
-
if (fse.existsSync(thisDest))
|
|
170
|
-
return;
|
|
171
|
-
const content = `export const __ThisModule__ = '${moduleName}';
|
|
172
|
-
export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts';
|
|
173
|
-
`;
|
|
174
|
-
// save
|
|
175
|
-
await fse.writeFile(thisDest, content);
|
|
176
|
-
}
|
|
177
|
-
async _generateIndex(modulePath) {
|
|
178
|
-
let jsContent = '';
|
|
179
|
-
const jsFile = path.join(modulePath, 'src/index.ts');
|
|
180
|
-
if (fse.existsSync(jsFile)) {
|
|
181
|
-
jsContent = (await fse.readFile(jsFile)).toString();
|
|
182
|
-
}
|
|
183
|
-
// jsTypes
|
|
184
|
-
const jsTypes = "export * from './types/index.ts';";
|
|
185
|
-
const jsTypesFile = path.join(modulePath, 'src/types/index.ts');
|
|
186
|
-
if (fse.existsSync(jsTypesFile) && !jsContent.includes(jsTypes)) {
|
|
187
|
-
jsContent = `${jsTypes}\n${jsContent}`;
|
|
188
|
-
}
|
|
189
|
-
// jsLib
|
|
190
|
-
const jsLib = "export * from './lib/index.ts';";
|
|
191
|
-
const jsLibFile = path.join(modulePath, 'src/lib/index.ts');
|
|
192
|
-
if (fse.existsSync(jsLibFile) && !jsContent.includes(jsLib)) {
|
|
193
|
-
jsContent = `${jsLib}\n${jsContent}`;
|
|
194
|
-
}
|
|
195
|
-
// jsMetadata
|
|
196
|
-
const jsMetadata = "export * from './.metadata/index.ts';";
|
|
197
|
-
const jsMetadataFile = path.join(modulePath, 'src/.metadata/index.ts');
|
|
198
|
-
if (fse.existsSync(jsMetadataFile) && !jsContent.includes(jsMetadata)) {
|
|
199
|
-
jsContent = `${jsMetadata}\n${jsContent}`;
|
|
200
|
-
}
|
|
201
|
-
// trim empty
|
|
202
|
-
jsContent = jsContent.replace('export {};\n', '');
|
|
203
|
-
// write
|
|
204
|
-
await fse.writeFile(jsFile, jsContent);
|
|
205
|
-
await this.helper.formatFile({ fileName: jsFile, logPrefix: 'format: ' });
|
|
206
|
-
}
|
|
207
|
-
async _generatePackage(modulePath) {
|
|
208
|
-
let pkgFile;
|
|
209
|
-
let pkg;
|
|
210
|
-
let changed;
|
|
211
|
-
async function _loadPkg() {
|
|
212
|
-
if (!pkg) {
|
|
213
|
-
pkgFile = path.join(modulePath, 'package.json');
|
|
214
|
-
pkg = await loadJSONFile(pkgFile);
|
|
215
|
-
}
|
|
216
|
-
return pkg;
|
|
217
|
-
}
|
|
218
|
-
// cli
|
|
219
|
-
const cli = path.join(modulePath, 'cli');
|
|
220
|
-
if (fse.existsSync(cli)) {
|
|
221
|
-
pkg = await _loadPkg();
|
|
222
|
-
const index = pkg.files.indexOf('cli');
|
|
223
|
-
if (index === -1) {
|
|
224
|
-
changed = true;
|
|
225
|
-
pkg.files.push('cli');
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
// save
|
|
229
|
-
if (changed) {
|
|
230
|
-
await saveJSONFile(pkgFile, pkg);
|
|
231
|
-
await this.helper.formatFile({ fileName: pkgFile });
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|