@lark-apaas/fullstack-cli 1.1.67 → 1.1.68-alpha.20260920222123

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.67",
3
+ "version": "1.1.68-alpha.20260920222123",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,9 +17,35 @@ function failAndExit(step, body) {
17
17
  process.exit(1);
18
18
  }
19
19
 
20
+ function getStagedFiles() {
21
+ const res = spawnSync(
22
+ 'git',
23
+ ['diff', '--cached', '--name-only', '--diff-filter=ACMR', '-z'],
24
+ {
25
+ cwd: process.cwd(),
26
+ stdio: ['ignore', 'pipe', 'pipe'],
27
+ encoding: 'utf8',
28
+ },
29
+ );
30
+ if (res.error) {
31
+ failAndExit('staged files', String(res.error.message || res.error));
32
+ }
33
+ if (res.status !== 0) {
34
+ failAndExit('staged files', `${res.stdout || ''}\n${res.stderr || ''}`);
35
+ }
36
+
37
+ return (res.stdout || '').split('\0').filter(Boolean);
38
+ }
39
+
20
40
  function runLint() {
21
41
  const cwd = process.cwd();
22
- const res = spawnSync('npm', ['run', 'lint'], {
42
+ const stagedFiles = getStagedFiles();
43
+ if (stagedFiles.length === 0) {
44
+ process.stdout.write('[pre-commit] No staged files to lint\n');
45
+ return;
46
+ }
47
+
48
+ const res = spawnSync('npm', ['run', 'lint', '--', '--files', ...stagedFiles], {
23
49
  cwd,
24
50
  stdio: ['ignore', 'pipe', 'pipe'],
25
51
  env: process.env,
@@ -64,6 +64,15 @@ function parseFilesArg(argv) {
64
64
  return argv.slice(filesIndex + 1).filter(Boolean);
65
65
  }
66
66
 
67
+ function parseMode(argv) {
68
+ if (argv.length === 0) return { type: 'default' };
69
+ if (argv.length === 1 && argv[0] === '--typecheck') return { type: 'typecheck' };
70
+ if (argv[0] === '--files' && argv.length > 1 && argv.slice(1).every(arg => !arg.startsWith('--'))) {
71
+ return { type: 'files', files: argv.slice(1) };
72
+ }
73
+ throw new Error('Usage: lint.js [--typecheck | --files <paths...>]');
74
+ }
75
+
67
76
  function isEslintTarget(filePath) {
68
77
  return /\.(c|m)?(j|t)sx?$/.test(filePath);
69
78
  }
@@ -107,6 +116,14 @@ function canRunStylelint() {
107
116
  return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
108
117
  }
109
118
 
119
+ function packageScripts() {
120
+ try {
121
+ return JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8')).scripts || {};
122
+ } catch {
123
+ return {};
124
+ }
125
+ }
126
+
110
127
  async function runDefaultLint() {
111
128
  const taskSpecs = [
112
129
  [getBinName('npm'), ['run', 'eslint']],
@@ -122,6 +139,19 @@ async function runDefaultLint() {
122
139
  process.exit(await runTasksSerially(taskSpecs));
123
140
  }
124
141
 
142
+ async function runTypeCheck() {
143
+ const scripts = packageScripts();
144
+ const names = ['type:check:server', 'type:check:client'];
145
+ const missing = names.filter(name => !scripts[name]);
146
+ if (missing.length > 0) {
147
+ throw new Error(`Missing required npm scripts: ${missing.join(', ')}`);
148
+ }
149
+
150
+ process.exit(await runTasksSerially(
151
+ names.map(name => [getBinName('npm'), ['run', name]]),
152
+ ));
153
+ }
154
+
125
155
  async function runSelectiveLint(inputFiles) {
126
156
  const normalizedFiles = Array.from(
127
157
  new Set(inputFiles.map(normalizeProjectFile).filter(Boolean)),
@@ -179,18 +209,19 @@ async function runSelectiveLint(inputFiles) {
179
209
  }
180
210
 
181
211
  async function main() {
182
- const files = parseFilesArg(process.argv.slice(2));
183
- if (files === null) {
184
- await runDefaultLint();
212
+ const args = process.argv.slice(2);
213
+ const mode = parseMode(args);
214
+ if (mode.type === 'typecheck') {
215
+ await runTypeCheck();
185
216
  return;
186
217
  }
187
218
 
188
- if (files.length === 0) {
189
- console.error('[lint] --files requires at least one file path');
190
- process.exit(1);
219
+ if (mode.type === 'default') {
220
+ await runDefaultLint();
221
+ return;
191
222
  }
192
223
 
193
- await runSelectiveLint(files);
224
+ await runSelectiveLint(mode.files);
194
225
  }
195
226
 
196
227
  main().catch((error) => {