@flun/node-mobile-app 3.1.5 → 4.0.1

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/src/config.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
3
  import { pathToFileURL } from 'url';
4
+ import chalk from 'chalk';
4
5
 
5
6
  const DEFAULT_CONFIG = {
6
7
  serverPath: './server.js',
@@ -69,12 +70,12 @@ const DEFAULT_CONFIG = {
69
70
  for (const name of ['mobileAppConfig.js', 'mobileAppConfig.mjs', 'mobileAppConfig.cjs']) {
70
71
  const p = path.join(userProjectDir, name);
71
72
  if (fs.existsSync(p)) {
72
- console.log('读取配置:', name);
73
+ console.log(chalk.gray(' 读取配置: ' + name));
73
74
  const mod = await import(pathToFileURL(p).href);
74
75
  return merge(DEFAULT_CONFIG, mod.default || mod);
75
76
  }
76
77
  }
77
- console.log('未找到 mobileAppConfig.js,使用默认配置');
78
+ console.log(chalk.yellow('未找到 mobileAppConfig.js,使用默认配置'));
78
79
  return DEFAULT_CONFIG;
79
80
  },
80
81
  validateConfig = (config, userProjectDir) => {
@@ -93,10 +94,10 @@ const DEFAULT_CONFIG = {
93
94
  if (!Number.isInteger(config.versionCode) || config.versionCode < 1) errors.push('versionCode 必须是正整数');
94
95
  if (!config.android.abiFilters?.length) errors.push('android.abiFilters 不能为空');
95
96
  if (errors.length) {
96
- errors.forEach((e) => console.error(' - ' + e));
97
+ errors.forEach((e) => console.error(chalk.red(' - ' + e)));
97
98
  throw new Error('配置校验失败');
98
99
  }
99
- console.log('配置校验通过');
100
+ console.log(chalk.green(' ✓ 配置校验通过'));
100
101
  },
101
102
  resolveSdkPath = (config) => {
102
103
  if (config.android && config.android.sdkPath) return config.android.sdkPath;
@@ -112,4 +113,4 @@ const DEFAULT_CONFIG = {
112
113
  return null;
113
114
  };
114
115
 
115
- export { DEFAULT_CONFIG, loadConfig, validateConfig, resolveSdkPath };
116
+ export { DEFAULT_CONFIG, loadConfig, validateConfig, resolveSdkPath };