@airiot/cli 1.0.4 → 1.0.5

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.
@@ -59,10 +59,59 @@ switch (script) {
59
59
  }
60
60
  case 'deploy': {
61
61
  await runScript('build');
62
- await runScript('upload');
62
+ await runScript('install');
63
63
  break;
64
64
  }
65
+ case 'help':
65
66
  default:
66
- console.log(`未知的脚本 "${script}"。`);
67
+ // 使用 chalk 打印美观的使用说明
68
+ const chalk = (await import('chalk')).default;
69
+
70
+ console.log();
71
+ console.log(chalk.bold.cyan('Airiot CLI — 使用说明\n'));
72
+ console.log(`${chalk.green('用法:')} ${chalk.white.bold('air <command> [options]')}`);
73
+ console.log(`${chalk.green('说明:')} 在命令名前传入 Node 参数(例如调试参数),在命令名后传入脚本参数。\n`);
74
+
75
+ const pad = (s, w = 12) => s + ' '.repeat(Math.max(0, w - s.length));
76
+
77
+ const commands = [
78
+ ['build', '构建项目,生成可部署包'],
79
+ ['start', '本地启动开发服务器(开发模式)'],
80
+ ['preview', '预览构建后的产物(静态预览)'],
81
+ ['test', '运行测试用例'],
82
+ ['upload', '(不推荐)使用老的接口将构建产物上传到目标平台/服务器'],
83
+ ['install', '将构建产物安装到目标平台/服务器)'],
84
+ ['pack', '打包为发布包'],
85
+ ['deploy', '先构建再上传(内部等价于 build -> install'],
86
+ ['i18n-scanner', '扫描并提取国际化文本'],
87
+ ['i18n-translate', '对提取的文本进行翻译处理'],
88
+ ['eslint', '运行 ESLint 检查代码'],
89
+ ['bugfix', '使用AI修复Bug'],
90
+ ['help', '显示此帮助信息']
91
+ ];
92
+
93
+ console.log(chalk.yellow('可用命令:'));
94
+ for (const [cmd, desc] of commands) {
95
+ console.log(' ' + chalk.cyan(pad(cmd)) + ' ' + chalk.dim(desc));
96
+ }
97
+
98
+ console.log();
99
+ console.log(chalk.yellow('示例:'));
100
+ console.log(' ' + chalk.cyan('air build') + ' ' + chalk.gray('# 生产构建'));
101
+ console.log(' ' + chalk.cyan('air start') + ' ' + chalk.gray('# 本地开发并热重载'));
102
+ console.log(' ' + chalk.cyan('air deploy') + ' ' + chalk.gray('# 构建并上传'));
103
+ console.log();
104
+ console.log(chalk.yellow('Node 参数:'));
105
+ console.log(' ' + chalk.white('如果需要传递 Node 参数(例如 --fix),请将它们放在命令前面:'));
106
+ console.log(' ' + chalk.cyan('air --fix eslint') + ' ' + chalk.gray('# 启用调试'));
107
+ console.log();
108
+
109
+ if (script) {
110
+ console.log(
111
+ chalk.red('未知的脚本') + ' ' +
112
+ chalk.bold(`"${script}"`) + '。' +
113
+ ' ' + chalk.gray('运行') + ' ' + chalk.cyan('air help') + ' ' + chalk.gray('以查看可用命令。')
114
+ );
115
+ }
67
116
  break;
68
117
  }
@@ -6,6 +6,17 @@ import reactPlugin from 'eslint-plugin-react';
6
6
  import importPlugin from 'eslint-plugin-import';
7
7
  import paths from './paths.js';
8
8
 
9
+ let appEsLintConfig = [];
10
+
11
+ try {
12
+ const module = await import(new URL(`file://${paths.appPath}/eslint.config.js`));
13
+ appEsLintConfig = Array.isArray(module.default) ? module.default : [ module.default ];
14
+ } catch (err) {
15
+ if (err.code !== 'ERR_MODULE_NOT_FOUND') {
16
+ throw err;
17
+ }
18
+ }
19
+
9
20
  export default defineConfig([
10
21
  // 基础 JS 配置
11
22
  {
@@ -88,5 +99,6 @@ export default defineConfig([
88
99
  {
89
100
  ignores: ['**/node_modules/**', '**/dist/**'],
90
101
  rules: {}
91
- }
102
+ },
103
+ ...appEsLintConfig
92
104
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airiot/cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "AIRIOT平台前端包管理工具",
5
5
  "type": "module",
6
6
  "scripts": {},
package/scripts/bugfix.js CHANGED
@@ -9,7 +9,7 @@ const execP = promisify(exec);
9
9
 
10
10
  try {
11
11
  // 检查 cline 是否可用
12
- await execP('cline --version', { maxBuffer: 1024 * 1024 });
12
+ await execP('cline version', { maxBuffer: 1024 * 1024 });
13
13
  } catch (err) {
14
14
  console.error(chalk.red('未检测到 cline CLI,脚本需要 cline 才能运行。'));
15
15
  console.log('请按下面任一方式安装并重试:');