vona-cli-set-api 1.0.407 → 1.0.409
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/package.original.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/package.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-base/src/.metadata/index.ts +0 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/package.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/src/.metadata/index.ts +1 -10
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/src/.metadata/locales.ts +12 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/src/controller/home.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-index/src/index.ts +1 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/package.json +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/index.ts +1 -10
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/locales.ts +12 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/role.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/entity/user.ts +1 -1
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/modules/home-user/src/index.ts +1 -0
- package/cli/templates/create/project/basic/boilerplate/src/suite/a-home/package.json +1 -1
- package/cli/templates/tools/crud/boilerplate/src/entity/{{resourceName}}.ts_ +1 -1
- package/dist/index.js +38 -12
- package/dist/lib/bean/cli.tools.metadata.d.ts +1 -0
- package/dist/lib/bean/toolsMetadata/generateConfig.d.ts +2 -1
- package/package.json +1 -1
|
@@ -69,12 +69,7 @@ declare module 'vona-module-a-web' {
|
|
|
69
69
|
}
|
|
70
70
|
/** controller: end */
|
|
71
71
|
/** locale: begin */
|
|
72
|
-
import
|
|
73
|
-
import locale_zh_cn from '../config/locale/zh-cn.ts';
|
|
74
|
-
export const locales = {
|
|
75
|
-
'en-us': locale_en_us,
|
|
76
|
-
'zh-cn': locale_zh_cn,
|
|
77
|
-
};
|
|
72
|
+
import { locales } from './locales.ts'
|
|
78
73
|
/** locale: end */
|
|
79
74
|
/** scope: begin */
|
|
80
75
|
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleLocales, type TypeLocaleBase } from 'vona';
|
|
@@ -106,8 +101,4 @@ declare module 'vona' {
|
|
|
106
101
|
|
|
107
102
|
|
|
108
103
|
}
|
|
109
|
-
|
|
110
|
-
export function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `home-index::${K}` {
|
|
111
|
-
return `home-index::${key}`;
|
|
112
|
-
}
|
|
113
104
|
/** scope: end */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TypeLocaleBase } from 'vona';
|
|
2
|
+
import locale_en_us from '../config/locale/en-us.ts';
|
|
3
|
+
import locale_zh_cn from '../config/locale/zh-cn.ts';
|
|
4
|
+
|
|
5
|
+
export const locales = {
|
|
6
|
+
'en-us': locale_en_us,
|
|
7
|
+
'zh-cn': locale_zh_cn,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `home-index::${K}` {
|
|
11
|
+
return `home-index::${key}`;
|
|
12
|
+
}
|
|
@@ -3,7 +3,7 @@ import { BeanBase } from 'vona';
|
|
|
3
3
|
import { Api } from 'vona-module-a-openapiutils';
|
|
4
4
|
import { Passport } from 'vona-module-a-user';
|
|
5
5
|
import { Controller, Web } from 'vona-module-a-web';
|
|
6
|
-
import { $locale } from '../.metadata/
|
|
6
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
7
7
|
|
|
8
8
|
export interface IControllerOptionsHome extends IDecoratorControllerOptions {}
|
|
9
9
|
|
|
@@ -571,12 +571,7 @@ export * from '../config/config.ts';
|
|
|
571
571
|
import type { config } from '../config/config.ts';
|
|
572
572
|
/** config: end */
|
|
573
573
|
/** locale: begin */
|
|
574
|
-
import
|
|
575
|
-
import locale_zh_cn from '../config/locale/zh-cn.ts';
|
|
576
|
-
export const locales = {
|
|
577
|
-
'en-us': locale_en_us,
|
|
578
|
-
'zh-cn': locale_zh_cn,
|
|
579
|
-
};
|
|
574
|
+
import { locales } from './locales.ts'
|
|
580
575
|
/** locale: end */
|
|
581
576
|
/** scope: begin */
|
|
582
577
|
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig, type TypeModuleLocales, type TypeLocaleBase } from 'vona';
|
|
@@ -614,8 +609,4 @@ declare module 'vona' {
|
|
|
614
609
|
|
|
615
610
|
|
|
616
611
|
}
|
|
617
|
-
|
|
618
|
-
export function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `home-user::${K}` {
|
|
619
|
-
return `home-user::${key}`;
|
|
620
|
-
}
|
|
621
612
|
/** scope: end */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TypeLocaleBase } from 'vona';
|
|
2
|
+
import locale_en_us from '../config/locale/en-us.ts';
|
|
3
|
+
import locale_zh_cn from '../config/locale/zh-cn.ts';
|
|
4
|
+
|
|
5
|
+
export const locales = {
|
|
6
|
+
'en-us': locale_en_us,
|
|
7
|
+
'zh-cn': locale_zh_cn,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `home-user::${K}` {
|
|
11
|
+
return `home-user::${key}`;
|
|
12
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
|
2
2
|
import type { IRole } from 'vona-module-a-user';
|
|
3
3
|
import { Api, v } from 'vona-module-a-openapiutils';
|
|
4
4
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
5
|
-
import { $locale } from '../.metadata/
|
|
5
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
6
6
|
|
|
7
7
|
export interface IEntityOptionsRole extends IDecoratorEntityOptions {}
|
|
8
8
|
|
|
@@ -4,7 +4,7 @@ import type { IUser } from 'vona-module-a-user';
|
|
|
4
4
|
import { Api, v } from 'vona-module-a-openapiutils';
|
|
5
5
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { $locale } from '../.metadata/
|
|
7
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
8
8
|
|
|
9
9
|
export interface IEntityOptionsUser extends IDecoratorEntityOptions {}
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
2
|
import { Api, v } from 'vona-module-a-openapiutils';
|
|
3
3
|
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
4
|
-
import { $locale } from '../.metadata/
|
|
4
|
+
import { $locale } from '../.metadata/locales.ts';
|
|
5
5
|
|
|
6
6
|
export interface IEntityOptions<%=argv.resourceNameCapitalize%> extends IDecoratorEntityOptions {}
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -2151,7 +2151,7 @@ import { constants } from '../config/constants.ts';
|
|
|
2151
2151
|
`;
|
|
2152
2152
|
return content;
|
|
2153
2153
|
}
|
|
2154
|
-
async function
|
|
2154
|
+
async function generateLocale1(modulePath, moduleName) {
|
|
2155
2155
|
const files = await globby('src/config/locale/*.ts', {
|
|
2156
2156
|
cwd: modulePath
|
|
2157
2157
|
});
|
|
@@ -2163,14 +2163,27 @@ async function generateLocale(modulePath) {
|
|
|
2163
2163
|
const localeName = path.basename(file, '.ts');
|
|
2164
2164
|
const className = `locale_${localeName.replace('-', '_')}`;
|
|
2165
2165
|
contentImports.push(`import ${className} from '../config/locale/${localeName}.ts';`);
|
|
2166
|
-
contentLocales.push(`'${localeName}': ${className},`);
|
|
2166
|
+
contentLocales.push(` '${localeName}': ${className},`);
|
|
2167
2167
|
}
|
|
2168
2168
|
// combine
|
|
2169
|
-
const content =
|
|
2169
|
+
const content = `import type { TypeLocaleBase } from 'vona';
|
|
2170
2170
|
${contentImports.join('\n')}
|
|
2171
|
+
|
|
2171
2172
|
export const locales = {
|
|
2172
|
-
|
|
2173
|
+
${contentLocales.join('\n')}
|
|
2173
2174
|
};
|
|
2175
|
+
|
|
2176
|
+
export function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): \`${moduleName}::\${K}\` {
|
|
2177
|
+
return \`${moduleName}::\${key}\`;
|
|
2178
|
+
}
|
|
2179
|
+
`;
|
|
2180
|
+
return content;
|
|
2181
|
+
}
|
|
2182
|
+
async function generateLocale2(contentLocales) {
|
|
2183
|
+
if (!contentLocales) return '';
|
|
2184
|
+
// combine
|
|
2185
|
+
const content = `/** locale: begin */
|
|
2186
|
+
import { locales } from './locales.ts'
|
|
2174
2187
|
/** locale: end */
|
|
2175
2188
|
`;
|
|
2176
2189
|
return content;
|
|
@@ -2406,9 +2419,6 @@ declare module 'vona' {
|
|
|
2406
2419
|
'${moduleName}': typeof errors;
|
|
2407
2420
|
}` : ''}
|
|
2408
2421
|
}
|
|
2409
|
-
${options.locales ? `\nexport function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): \`${moduleName}::\${K}\` {
|
|
2410
|
-
return \`${moduleName}::\${key}\`;
|
|
2411
|
-
}` : ''}
|
|
2412
2422
|
/** scope: end */
|
|
2413
2423
|
`;
|
|
2414
2424
|
return content;
|
|
@@ -2552,8 +2562,9 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2552
2562
|
const contentConstants = await generateConstant(modulePath);
|
|
2553
2563
|
content += contentConstants;
|
|
2554
2564
|
// locale
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2565
|
+
const contentLocales1 = await generateLocale1(modulePath, moduleName);
|
|
2566
|
+
const contentLocales2 = await generateLocale2(contentLocales1);
|
|
2567
|
+
content += contentLocales2;
|
|
2557
2568
|
// error
|
|
2558
2569
|
const contentErrors = await generateError(modulePath);
|
|
2559
2570
|
content += contentErrors;
|
|
@@ -2562,12 +2573,13 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2562
2573
|
// main
|
|
2563
2574
|
content += await generateMain(modulePath);
|
|
2564
2575
|
// scope
|
|
2565
|
-
|
|
2576
|
+
const generateScopeOptions = {
|
|
2566
2577
|
config: contentConfig,
|
|
2567
2578
|
errors: contentErrors,
|
|
2568
|
-
locales:
|
|
2579
|
+
locales: contentLocales2,
|
|
2569
2580
|
constants: contentConstants
|
|
2570
|
-
}
|
|
2581
|
+
};
|
|
2582
|
+
content += await generateScope(moduleName, relativeNameCapitalize, scopeResources, generateScopeOptions);
|
|
2571
2583
|
// patch
|
|
2572
2584
|
content = this._generatePatch(content);
|
|
2573
2585
|
// empty
|
|
@@ -2579,6 +2591,8 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2579
2591
|
// save
|
|
2580
2592
|
await fse.writeFile(metaIndexFile, content);
|
|
2581
2593
|
// await this.helper.formatFile({ fileName: metaIndexFile, logPrefix: 'format: ' });
|
|
2594
|
+
// locales
|
|
2595
|
+
await this._generateLocales(modulePath, contentLocales1);
|
|
2582
2596
|
// generate this
|
|
2583
2597
|
await this._generateThis(moduleName, relativeNameCapitalize, modulePath);
|
|
2584
2598
|
// index
|
|
@@ -2603,6 +2617,12 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2603
2617
|
const importContent = `import ${type ? 'type ' : ''}{ ${items.join(',')} } from '${packageName}';`;
|
|
2604
2618
|
return `${importContent}\n${content}`;
|
|
2605
2619
|
}
|
|
2620
|
+
async _generateLocales(modulePath, contentLocales) {
|
|
2621
|
+
if (!contentLocales) return;
|
|
2622
|
+
const localesDest = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
2623
|
+
// save
|
|
2624
|
+
await fse.writeFile(localesDest, contentLocales);
|
|
2625
|
+
}
|
|
2606
2626
|
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
2607
2627
|
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
2608
2628
|
if (fse.existsSync(thisDest)) return;
|
|
@@ -2630,6 +2650,12 @@ export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts'
|
|
|
2630
2650
|
if (fse.existsSync(jsLibFile) && !jsContent.includes(jsLib)) {
|
|
2631
2651
|
jsContent = `${jsLib}\n${jsContent}`;
|
|
2632
2652
|
}
|
|
2653
|
+
// jsLocales
|
|
2654
|
+
const jsLocales = "export * from './.metadata/locales.ts';";
|
|
2655
|
+
const jsLocalesFile = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
2656
|
+
if (fse.existsSync(jsLocalesFile) && !jsContent.includes(jsLocales)) {
|
|
2657
|
+
jsContent = `${jsLocales}\n${jsContent}`;
|
|
2658
|
+
}
|
|
2633
2659
|
// jsMetadata
|
|
2634
2660
|
const jsMetadata = "export * from './.metadata/index.ts';";
|
|
2635
2661
|
const jsMetadataFile = path.join(modulePath, 'src/.metadata/index.ts');
|
|
@@ -9,6 +9,7 @@ export declare class CliToolsMetadata extends BeanCliBase {
|
|
|
9
9
|
_generateMetadata(moduleName: string, force: boolean): Promise<void>;
|
|
10
10
|
_generatePatch(content: string): string;
|
|
11
11
|
_generatePatch_resources(content: string, packageName: string, resources: string[], type: boolean): string;
|
|
12
|
+
_generateLocales(modulePath: any, contentLocales: any): Promise<void>;
|
|
12
13
|
_generateThis(moduleName: string, relativeNameCapitalize: string, modulePath: string): Promise<void>;
|
|
13
14
|
_generateIndex(modulePath: string): Promise<void>;
|
|
14
15
|
_generatePackage(modulePath: string): Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function generateConfig(modulePath: string): Promise<"" | "/** config: begin */\nexport * from '../config/config.ts';\nimport type { config } from '../config/config.ts';\n/** config: end */\n">;
|
|
2
2
|
export declare function generateConstant(modulePath: string): Promise<"" | "/** constant: begin */\nexport * from '../config/constants.ts';\nimport { constants } from '../config/constants.ts';\n/** constant: end */\n">;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function generateLocale1(modulePath: string, moduleName: string): Promise<string>;
|
|
4
|
+
export declare function generateLocale2(contentLocales: string): Promise<"" | "/** locale: begin */\nimport { locales } from './locales.ts'\n/** locale: end */\n">;
|
|
4
5
|
export declare function generateError(modulePath: string): Promise<"" | "/** error: begin */\nexport * from '../config/errors.ts';\nimport type { errors } from '../config/errors.ts';\n/** error: end */\n">;
|