@lark-apaas/fullstack-cli 1.1.72-alpha.20261123084437 → 1.1.72-alpha.20261124095038

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/fullstack-cli",
3
- "version": "1.1.72-alpha.20261123084437",
3
+ "version": "1.1.72-alpha.20261124095038",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,15 +10,28 @@ function getBinName(name) {
10
10
  return process.platform === 'win32' ? `${name}.cmd` : name;
11
11
  }
12
12
 
13
+ function getLinter() {
14
+ const pkg = JSON.parse(
15
+ fs.readFileSync(path.join(cwd, 'package.json'), 'utf8')
16
+ );
17
+ // 优先沿用已有 eslint 入口,避免对照脚本意外切换检查器。
18
+ const script =
19
+ pkg.scripts?.oxlint && !pkg.scripts?.eslint ? 'oxlint' : 'eslint';
20
+ const engine = /\boxlint\b/.test(pkg.scripts?.[script] || '')
21
+ ? 'oxlint'
22
+ : script;
23
+ return { script, engine };
24
+ }
25
+
13
26
  function runCommand(command, args) {
14
- return new Promise((resolve) => {
27
+ return new Promise(resolve => {
15
28
  const child = spawn(command, args, {
16
29
  cwd,
17
30
  stdio: 'inherit',
18
31
  shell: false,
19
32
  });
20
33
 
21
- child.on('close', (code) => resolve(code || 0));
34
+ child.on('close', code => resolve(code || 0));
22
35
  child.on('error', () => resolve(1));
23
36
  });
24
37
  }
@@ -64,7 +77,7 @@ function parseFilesArg(argv) {
64
77
  return argv.slice(filesIndex + 1).filter(Boolean);
65
78
  }
66
79
 
67
- function isEslintTarget(filePath) {
80
+ function isLintTarget(filePath) {
68
81
  return /\.(c|m)?(j|t)sx?$/.test(filePath);
69
82
  }
70
83
 
@@ -104,19 +117,24 @@ function canRunStylelint() {
104
117
 
105
118
  if (!pkg.scripts || !pkg.scripts.stylelint) return false;
106
119
 
107
- return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
120
+ return STYLELINT_CONFIG_FILES.some(file =>
121
+ fs.existsSync(path.join(cwd, file))
122
+ );
108
123
  }
109
124
 
110
125
  async function runDefaultLint() {
126
+ const { script: lintScript } = getLinter();
111
127
  const taskSpecs = [
112
- [getBinName('npm'), ['run', 'eslint']],
128
+ [getBinName('npm'), ['run', lintScript]],
113
129
  [getBinName('npm'), ['run', 'type:check']],
114
130
  ];
115
131
 
116
132
  if (canRunStylelint()) {
117
133
  taskSpecs.push([getBinName('npm'), ['run', 'stylelint']]);
118
134
  } else {
119
- console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
135
+ console.warn(
136
+ '[lint] Skip stylelint: missing scripts.stylelint or stylelint config'
137
+ );
120
138
  }
121
139
 
122
140
  process.exit(await runTasksSerially(taskSpecs));
@@ -124,7 +142,7 @@ async function runDefaultLint() {
124
142
 
125
143
  async function runSelectiveLint(inputFiles) {
126
144
  const normalizedFiles = Array.from(
127
- new Set(inputFiles.map(normalizeProjectFile).filter(Boolean)),
145
+ new Set(inputFiles.map(normalizeProjectFile).filter(Boolean))
128
146
  );
129
147
 
130
148
  if (normalizedFiles.length === 0) {
@@ -132,7 +150,7 @@ async function runSelectiveLint(inputFiles) {
132
150
  process.exit(0);
133
151
  }
134
152
 
135
- const eslintFiles = normalizedFiles.filter(isEslintTarget);
153
+ const lintFiles = normalizedFiles.filter(isLintTarget);
136
154
  const stylelintFiles = normalizedFiles.filter(isStylelintTarget);
137
155
  const typeCheckFiles = normalizedFiles.filter(isTypeCheckTarget);
138
156
 
@@ -152,14 +170,20 @@ async function runSelectiveLint(inputFiles) {
152
170
 
153
171
  const taskSpecs = [];
154
172
 
155
- if (eslintFiles.length > 0) {
156
- taskSpecs.push([getBinName('npx'), ['eslint', '--quiet', ...eslintFiles]]);
173
+ if (lintFiles.length > 0) {
174
+ const { engine: lintEngine } = getLinter();
175
+ taskSpecs.push([getBinName('npx'), [lintEngine, '--quiet', ...lintFiles]]);
157
176
  }
158
177
 
159
178
  if (stylelintFiles.length > 0 && !canRunStylelint()) {
160
- console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
179
+ console.warn(
180
+ '[lint] Skip stylelint: missing scripts.stylelint or stylelint config'
181
+ );
161
182
  } else if (stylelintFiles.length > 0) {
162
- taskSpecs.push([getBinName('npx'), ['stylelint', '--quiet', ...stylelintFiles]]);
183
+ taskSpecs.push([
184
+ getBinName('npx'),
185
+ ['stylelint', '--quiet', ...stylelintFiles],
186
+ ]);
163
187
  }
164
188
 
165
189
  if (clientTypeFiles.length > 0) {
@@ -193,7 +217,7 @@ async function main() {
193
217
  await runSelectiveLint(files);
194
218
  }
195
219
 
196
- main().catch((error) => {
220
+ main().catch(error => {
197
221
  const message = error instanceof Error ? error.message : String(error);
198
222
  console.error(`[lint] Failed to run lint: ${message}`);
199
223
  process.exit(1);