@lark-apaas/miaoda-cli 0.1.32 → 0.1.33-alpha.155f17e

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.32",
3
+ "version": "0.1.33-alpha.155f17e",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -63,13 +63,47 @@ function isStylelintTarget(filePath) {
63
63
  return filePath.endsWith('.css');
64
64
  }
65
65
 
66
+ const STYLELINT_CONFIG_FILES = [
67
+ '.stylelintrc',
68
+ '.stylelintrc.js',
69
+ '.stylelintrc.cjs',
70
+ '.stylelintrc.json',
71
+ 'stylelint.config.js',
72
+ ];
73
+
74
+ /**
75
+ * 老模板(fullstack-nestjs-template 1.x 时代)的应用跑不了 stylelint,跑了就挂、把 pre-commit
76
+ * 卡死。两种形态都实测过:
77
+ *
78
+ * - 缺 scripts.stylelint → `npm error Missing script: "stylelint"`
79
+ * - 缺 .stylelintrc.* → `ConfigurationError: No configuration provided`
80
+ *
81
+ * 注意光判断 stylelint 装没装拦不住:@lark-apaas/fullstack-presets 的 dependencies 里有
82
+ * stylelint,只要 dep 了 presets 二进制就在。缺任一件就跳过这一步。
83
+ */
84
+ function canRunStylelint() {
85
+ let pkg;
86
+ try {
87
+ pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
88
+ } catch {
89
+ return false;
90
+ }
91
+
92
+ if (!pkg.scripts || !pkg.scripts.stylelint) return false;
93
+
94
+ return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
95
+ }
96
+
66
97
  async function runDefaultLint() {
67
- const code = await runCommand(getBinName('npx'), [
68
- 'concurrently',
69
- 'npm run eslint',
70
- 'npm run type:check',
71
- 'npm run stylelint',
72
- ]);
98
+ const commands = ['npm run eslint', 'npm run type:check'];
99
+
100
+ if (canRunStylelint()) {
101
+ commands.push('npm run stylelint');
102
+ } else {
103
+ console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
104
+ }
105
+
106
+ const code = await runCommand(getBinName('npx'), ['concurrently', ...commands]);
73
107
  process.exit(code);
74
108
  }
75
109
 
@@ -107,7 +141,9 @@ async function runSelectiveLint(inputFiles) {
107
141
  tasks.push(runCommand(getBinName('npx'), ['eslint', '--quiet', ...eslintFiles]));
108
142
  }
109
143
 
110
- if (stylelintFiles.length > 0) {
144
+ if (stylelintFiles.length > 0 && !canRunStylelint()) {
145
+ console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
146
+ } else if (stylelintFiles.length > 0) {
111
147
  tasks.push(runCommand(getBinName('npx'), ['stylelint', '--quiet', ...stylelintFiles]));
112
148
  }
113
149