vona-cli-set-api 1.0.333 → 1.0.339

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.
@@ -9,7 +9,6 @@ APP_VERSION = 5.0.0
9
9
  SERVER_KEYS = <%=argv.SERVER_KEYS%>
10
10
  SERVER_GLOBALPREFIX = /api
11
11
  SERVER_PUBLICDIR =
12
- SERVER_LOGGERDIR =
13
12
  SERVER_SUBDOMAINOFFSET = 1
14
13
  SERVER_WORKERS =
15
14
  SERVER_LISTEN_HOSTNAME = 0.0.0.0
@@ -23,6 +22,7 @@ PROJECT_DISABLED_SUITES =
23
22
 
24
23
  # logger
25
24
 
25
+ LOGGER_DIR =
26
26
  LOGGER_CLIENT_DEFAULT =
27
27
  LOGGER_DUMMY =
28
28
  LOGGER_ROTATE_ENABLE = true
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "vona": "^5.0.194"
49
+ "vona": "^5.0.197"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@cabloy/lint": "^5.0.16",
@@ -3,6 +3,11 @@ import type { VonaAppInfo, VonaConfigOptional } from 'vona';
3
3
  export default function (_appInfo: VonaAppInfo) {
4
4
  const config = {} as VonaConfigOptional;
5
5
 
6
+ // proxy
7
+ config.proxy = {
8
+ enable: false,
9
+ };
10
+
6
11
  // instances
7
12
  config.instances = [
8
13
  { name: '', password: '', title: '' },
@@ -2,7 +2,7 @@ import type { ILoggerOptionsClientInfo, VonaAppInfo, VonaApplication, VonaConfig
2
2
  import type { IDatabaseClientRecord } from 'vona-module-a-orm';
3
3
  import type * as Winston from 'winston';
4
4
  import { replaceTemplate } from '@cabloy/utils';
5
- import { formatLoggerAxiosError, formatLoggerCtx } from 'vona';
5
+ import { formatLoggerAxiosError, formatLoggerCtx, getLoggerPathPhysicalRoot, getPublicPathPhysicalRoot } from 'vona';
6
6
 
7
7
  declare module 'vona' {
8
8
  export interface IInstanceRecord {
@@ -20,8 +20,44 @@ declare module 'vona-module-a-orm' {
20
20
  export default function (appInfo: VonaAppInfo, env: VonaConfigEnv) {
21
21
  const config = {} as VonaConfigOptional;
22
22
 
23
+ // meta
24
+ config.meta = {
25
+ flavor: appInfo.configMeta.flavor,
26
+ mode: appInfo.configMeta.mode,
27
+ };
28
+
29
+ // server
30
+ const publicDir = env.SERVER_PUBLICDIR || getPublicPathPhysicalRoot(appInfo);
31
+ const subdomainOffset = Number.parseInt(env.SERVER_SUBDOMAINOFFSET || '1');
32
+ const workers = Number.parseInt(env.SERVER_WORKERS!);
33
+ config.server = {
34
+ keys: (env.SERVER_KEYS || '').split(','),
35
+ globalPrefix: env.SERVER_GLOBALPREFIX || '/api',
36
+ publicDir,
37
+ subdomainOffset,
38
+ workers,
39
+ listen: {
40
+ hostname: env.SERVER_LISTEN_HOSTNAME,
41
+ port: Number.parseInt(env.SERVER_LISTEN_PORT!),
42
+ disable: env.SERVER_LISTEN_DISABLE === 'true',
43
+ },
44
+ serve: {},
45
+ };
46
+
47
+ // proxy
48
+ config.proxy = {
49
+ enable: true,
50
+ ipHeaders: 'x-real-ip,x-forwarded-for',
51
+ hostHeaders: 'x-forwarded-host,host',
52
+ protocolHeaders: 'x-forwarded-proto',
53
+ maxProxyCount: 1,
54
+ maxIpsCount: 15,
55
+ };
56
+
23
57
  // logger
58
+ const loggerDir = env.LOGGER_DIR || getLoggerPathPhysicalRoot(appInfo);
24
59
  config.logger = {
60
+ baseDir: loggerDir,
25
61
  rotate: {
26
62
  enable: env.LOGGER_ROTATE_ENABLE === 'true',
27
63
  options(filename: string) {
@@ -0,0 +1,13 @@
1
+ import type { IModuleInfo } from '@cabloy/module-info';
2
+ import { BeanCliBase } from '@cabloy/cli';
3
+ declare module '@cabloy/cli' {
4
+ interface ICommandArgv {
5
+ module: string;
6
+ moduleInfo: IModuleInfo;
7
+ scene: string;
8
+ }
9
+ }
10
+ export declare class CliInitAsset extends BeanCliBase {
11
+ execute(): Promise<void>;
12
+ _setPackageInfo(modulePath: string, scene: string): Promise<void>;
13
+ }
@@ -0,0 +1,46 @@
1
+ import path from 'node:path';
2
+ import { BeanCliBase } from '@cabloy/cli';
3
+ import fse from 'fs-extra';
4
+ export class CliInitAsset extends BeanCliBase {
5
+ async execute() {
6
+ const { argv } = this.context;
7
+ // super
8
+ await super.execute();
9
+ // module name/info
10
+ const moduleName = argv.module;
11
+ argv.moduleInfo = this.helper.parseModuleInfo(moduleName);
12
+ // check if exists
13
+ const _module = this.helper.findModule(moduleName);
14
+ if (!_module) {
15
+ throw new Error(`module does not exist: ${moduleName}`);
16
+ }
17
+ // target dir
18
+ const targetDir = await this.helper.ensureDir(_module.root);
19
+ // scene
20
+ const scene = argv.scene;
21
+ // directory
22
+ const assetDir = path.join(targetDir, scene);
23
+ if (fse.existsSync(assetDir)) {
24
+ throw new Error(`asset exists: ${moduleName}/${scene}`);
25
+ }
26
+ await this.helper.ensureDir(assetDir);
27
+ // package.json
28
+ await this._setPackageInfo(targetDir, scene);
29
+ }
30
+ async _setPackageInfo(modulePath, scene) {
31
+ const pkgFile = path.join(modulePath, 'package.json');
32
+ const pkg = await this.helper.loadJSONFile(pkgFile);
33
+ if (!pkg.files)
34
+ pkg.files = [];
35
+ let changed;
36
+ // files
37
+ if (!pkg.files.includes(scene)) {
38
+ pkg.files.push(scene);
39
+ changed = true;
40
+ }
41
+ // save
42
+ if (changed) {
43
+ await this.helper.saveJSONFile(pkgFile, pkg);
44
+ }
45
+ }
46
+ }
@@ -12,6 +12,7 @@ import { CliCreateSuite } from './bean/cli.create.suite.ts';
12
12
  import { CliCreateTest } from './bean/cli.create.test.ts';
13
13
  import { CliDefaultList } from './bean/cli.default.list.ts';
14
14
  import { CliInitAppMonkey } from './bean/cli.init.appMonkey.ts';
15
+ import { CliInitAsset } from './bean/cli.init.asset.ts';
15
16
  import { CliInitConfig } from './bean/cli.init.config.ts';
16
17
  import { CliInitConstant } from './bean/cli.init.constant.ts';
17
18
  import { CliInitError } from './bean/cli.init.error.ts';
@@ -45,6 +46,7 @@ export declare const beans: {
45
46
  'init.monkey': typeof CliInitMonkey;
46
47
  'init.main': typeof CliInitMain;
47
48
  'init.static': typeof CliInitStatic;
49
+ 'init.asset': typeof CliInitAsset;
48
50
  'init.lib': typeof CliInitLib;
49
51
  'init.types': typeof CliInitTypes;
50
52
  'init.appMonkey': typeof CliInitAppMonkey;
package/dist/lib/beans.js CHANGED
@@ -12,6 +12,7 @@ import { CliCreateSuite } from "./bean/cli.create.suite.js";
12
12
  import { CliCreateTest } from "./bean/cli.create.test.js";
13
13
  import { CliDefaultList } from "./bean/cli.default.list.js";
14
14
  import { CliInitAppMonkey } from "./bean/cli.init.appMonkey.js";
15
+ import { CliInitAsset } from "./bean/cli.init.asset.js";
15
16
  import { CliInitConfig } from "./bean/cli.init.config.js";
16
17
  import { CliInitConstant } from "./bean/cli.init.constant.js";
17
18
  import { CliInitError } from "./bean/cli.init.error.js";
@@ -45,6 +46,7 @@ export const beans = {
45
46
  'init.monkey': CliInitMonkey,
46
47
  'init.main': CliInitMain,
47
48
  'init.static': CliInitStatic,
49
+ 'init.asset': CliInitAsset,
48
50
  'init.lib': CliInitLib,
49
51
  'init.types': CliInitTypes,
50
52
  'init.appMonkey': CliInitAppMonkey,
@@ -0,0 +1,34 @@
1
+ declare const _default: {
2
+ bean: string;
3
+ info: {
4
+ version: string;
5
+ title: string;
6
+ usage: string;
7
+ };
8
+ options: {
9
+ module: {
10
+ description: string;
11
+ type: string;
12
+ };
13
+ };
14
+ groups: {
15
+ default: {
16
+ questions: {
17
+ scene: {
18
+ type: string;
19
+ message: string;
20
+ initial: {
21
+ expression: string;
22
+ };
23
+ required: boolean;
24
+ };
25
+ module: {
26
+ type: string;
27
+ message: string;
28
+ required: boolean;
29
+ };
30
+ };
31
+ };
32
+ };
33
+ };
34
+ export default _default;
@@ -0,0 +1,33 @@
1
+ export default {
2
+ bean: 'init.asset',
3
+ info: {
4
+ version: '5.0.0',
5
+ title: 'Cli: Init: Asset Resources',
6
+ usage: 'vona :init:asset scene [--module=]',
7
+ },
8
+ options: {
9
+ module: {
10
+ description: 'module name',
11
+ type: 'string',
12
+ },
13
+ },
14
+ groups: {
15
+ default: {
16
+ questions: {
17
+ scene: {
18
+ type: 'input',
19
+ message: 'scene',
20
+ initial: {
21
+ expression: 'context.argv._[0]',
22
+ },
23
+ required: true,
24
+ },
25
+ module: {
26
+ type: 'input',
27
+ message: 'module name',
28
+ required: true,
29
+ },
30
+ },
31
+ },
32
+ },
33
+ };
@@ -399,6 +399,39 @@ export declare const commands: {
399
399
  usage: string;
400
400
  };
401
401
  };
402
+ asset: {
403
+ bean: string;
404
+ info: {
405
+ version: string;
406
+ title: string;
407
+ usage: string;
408
+ };
409
+ options: {
410
+ module: {
411
+ description: string;
412
+ type: string;
413
+ };
414
+ };
415
+ groups: {
416
+ default: {
417
+ questions: {
418
+ scene: {
419
+ type: string;
420
+ message: string;
421
+ initial: {
422
+ expression: string;
423
+ };
424
+ required: boolean;
425
+ };
426
+ module: {
427
+ type: string;
428
+ message: string;
429
+ required: boolean;
430
+ };
431
+ };
432
+ };
433
+ };
434
+ };
402
435
  lib: {
403
436
  bean: string;
404
437
  info: {
@@ -12,6 +12,7 @@ import createSuite from "./command/create.suite.js";
12
12
  import createTest from "./command/create.test.js";
13
13
  import defaultList from "./command/default.list.js";
14
14
  import initAppMonkey from "./command/init.appMonkey.js";
15
+ import initAsset from "./command/init.asset.js";
15
16
  import initConfig from "./command/init.config.js";
16
17
  import initConstant from "./command/init.constant.js";
17
18
  import initError from "./command/init.error.js";
@@ -52,6 +53,7 @@ export const commands = {
52
53
  monkey: initMonkey,
53
54
  main: initMain,
54
55
  static: initStatic,
56
+ asset: initAsset,
55
57
  lib: initLib,
56
58
  types: initTypes,
57
59
  appMonkey: initAppMonkey,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
3
  "type": "module",
4
- "version": "1.0.333",
4
+ "version": "1.0.339",
5
5
  "description": "vona cli-set-api",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -61,7 +61,7 @@
61
61
  "ts-node-maintained": "^10.9.6",
62
62
  "urllib": "^4.6.11",
63
63
  "uuid": "^11.1.0",
64
- "vona-core": "^5.0.89",
64
+ "vona-core": "^5.0.92",
65
65
  "why-is-node-running": "^3.2.2",
66
66
  "yargs-parser": "^21.1.1"
67
67
  },