zova-cli-set-front 1.2.97 → 1.2.99

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.
@@ -1,9 +1,13 @@
1
1
  import type { ZovaOpenapiConfig } from 'zova-openapi';
2
2
 
3
3
  export default function (): ZovaOpenapiConfig {
4
+ const apiBaseURL = process.env.API_BASE_URL;
5
+ if (!apiBaseURL) {
6
+ throw new Error('Missing API_BASE_URL');
7
+ }
4
8
  return {
5
9
  default: {
6
- source: 'http://localhost:7102/swagger/json?version=V31',
10
+ source: `${apiBaseURL.replace(/\/$/, '')}/swagger/json?version=V31`,
7
11
  },
8
12
  modules: {},
9
13
  };
package/dist/index.js CHANGED
@@ -158,6 +158,13 @@ function getControllerFileName(module, type, beanName) {
158
158
  }
159
159
  return 'controller.tsx';
160
160
  }
161
+ function loadZovaEnvs(appDir, configMeta) {
162
+ const configUtils = createConfigUtils(configMeta, {
163
+ appDir,
164
+ runtimeDir: '.zova'
165
+ });
166
+ return configUtils.loadEnvs();
167
+ }
161
168
  async function loadJSONFile(fileName) {
162
169
  const pkgContent = (await fse.readFile(fileName)).toString();
163
170
  return JSON.parse(pkgContent);
@@ -326,8 +333,9 @@ class CliBinBuildRest extends BeanCliBase {
326
333
  plugins: [svgResolverPlugin()],
327
334
  deps: {
328
335
  alwaysBundle: id => {
329
- if (bundleModules.includes(id)) return true;
330
- return false;
336
+ return bundleModules.some(moduleName => {
337
+ return id === moduleName || id.startsWith(`${moduleName}/`);
338
+ });
331
339
  }
332
340
  }
333
341
  // minify: true,
@@ -790,33 +798,17 @@ class CliCreatePageBase extends BeanCliBase {
790
798
  await this.logUrl(argv);
791
799
  }
792
800
  async logUrl(argv) {
793
- const env = await this.loadEnvs();
801
+ const env = loadZovaEnvs(argv.projectPath, {
802
+ flavor: 'admin',
803
+ mode: 'development',
804
+ appMode: 'spa'
805
+ });
794
806
  const host = !env.DEV_SERVER_HOSTNAME || env.DEV_SERVER_HOSTNAME === 'true' ? 'localhost' : env.DEV_SERVER_HOSTNAME;
795
807
  const port = env.DEV_SERVER_PORT;
796
808
  const url = `http://${host}:${port}/${argv.moduleInfo.pid}/${argv.moduleInfo.name}/${argv.pageName}`;
797
809
  const message = `Page URL: ${url}`;
798
810
  await this.console.log(message);
799
811
  }
800
- async loadEnvs() {
801
- const configMeta = {
802
- flavor: 'admin',
803
- mode: 'development',
804
- appMode: 'spa'
805
- };
806
- const configOptions = {
807
- appDir: process.cwd(),
808
- runtimeDir: '.zova',
809
- zovaManualChunk: {
810
- debug: false,
811
- vendors: []
812
- }
813
- };
814
- // config utils
815
- const configUtils = createConfigUtils(configMeta, configOptions);
816
- // env
817
- const env = configUtils.loadEnvs();
818
- return env;
819
- }
820
812
  }
821
813
 
822
814
  class CliCreatePage extends CliCreatePageBase {
@@ -1527,6 +1519,12 @@ class CliOpenapiGenerate extends BeanCliBase {
1527
1519
  } = this.context;
1528
1520
  // super
1529
1521
  await super.execute();
1522
+ // env
1523
+ loadZovaEnvs(argv.projectPath, {
1524
+ flavor: 'admin',
1525
+ mode: 'development',
1526
+ appMode: 'spa'
1527
+ });
1530
1528
  // config file
1531
1529
  const configFile = path.join(argv.projectPath, 'openapi.config.ts');
1532
1530
  if (!fse.existsSync(configFile)) {
@@ -14,7 +14,4 @@ export declare class CliCreatePageBase extends BeanCliBase {
14
14
  constructor(options: CmdOptions, pageMode: any);
15
15
  execute(): Promise<void>;
16
16
  logUrl(argv: any): Promise<void>;
17
- loadEnvs(): Promise<{
18
- [name: string]: string;
19
- }>;
20
17
  }
@@ -1,6 +1,9 @@
1
- import type { IModule } from '@cabloy/module-info';
1
+ import type { IModule, ZovaConfigMeta } from '@cabloy/module-info';
2
2
  export declare function getControllerFileName(module: IModule, type: 'page' | 'component', beanName: any): "controller.ts" | "controller.tsx";
3
3
  export declare function copyTemplateIfNeed(fileSrc: any, fileDest: any): void;
4
4
  export declare function pathToHref(fileName: string): string;
5
+ export declare function loadZovaEnvs(appDir: string, configMeta: ZovaConfigMeta): {
6
+ [name: string]: string;
7
+ };
5
8
  export declare function loadJSONFile(fileName: string): Promise<any>;
6
9
  export declare function saveJSONFile(fileName: string, json: object): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-cli-set-front",
3
- "version": "1.2.97",
4
- "gitHead": "1968aab5fdd054c1c58184e34fed8ea4368b09d2",
3
+ "version": "1.2.99",
4
+ "gitHead": "5afd89dc6f19a6b284b48002636d4b7dd20b662a",
5
5
  "description": "zova cli-set-front",
6
6
  "keywords": [
7
7
  "framework",