@lark-apaas/fullstack-cli 1.1.66-alpha.20260904133055 → 1.1.66-alpha.20260908191831

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/dist/index.js CHANGED
@@ -6009,7 +6009,7 @@ function addInjection(sourceFile) {
6009
6009
  type: PARAM_TYPE,
6010
6010
  scope: Scope.Private,
6011
6011
  isReadonly: true,
6012
- decorators: [{ name: "Inject", arguments: [] }]
6012
+ decorators: [{ name: "Inject", arguments: ["CapabilityService"] }]
6013
6013
  });
6014
6014
  } else {
6015
6015
  classDecl.addConstructor({
@@ -6018,7 +6018,7 @@ function addInjection(sourceFile) {
6018
6018
  type: PARAM_TYPE,
6019
6019
  scope: Scope.Private,
6020
6020
  isReadonly: true,
6021
- decorators: [{ name: "Inject", arguments: [] }]
6021
+ decorators: [{ name: "Inject", arguments: ["CapabilityService"] }]
6022
6022
  }]
6023
6023
  });
6024
6024
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.66-alpha.20260904133055",
3
+ "version": "1.1.66-alpha.20260908191831",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -5,7 +5,6 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const { spawn, execSync } = require('child_process');
7
7
  const readline = require('readline');
8
- const { buildNestServerArgs } = require('./nest-type-check.cjs');
9
8
 
10
9
  // ── Project root ──────────────────────────────────────────────────────────────
11
10
  const PROJECT_ROOT = path.resolve(__dirname, '..');
@@ -32,10 +31,9 @@ loadEnv();
32
31
 
33
32
  // ── Configuration ─────────────────────────────────────────────────────────────
34
33
  const LOG_DIR = process.env.LOG_DIR || 'logs';
35
- const MAX_RESTART_COUNT =
36
- process.env.MAX_RESTART_COUNT != null && process.env.MAX_RESTART_COUNT !== ''
37
- ? parseInt(process.env.MAX_RESTART_COUNT, 10)
38
- : Infinity;
34
+ const MAX_RESTART_COUNT = process.env.MAX_RESTART_COUNT != null && process.env.MAX_RESTART_COUNT !== ''
35
+ ? parseInt(process.env.MAX_RESTART_COUNT, 10)
36
+ : Infinity;
39
37
  const RESTART_DELAY = parseInt(process.env.RESTART_DELAY, 10) || 2;
40
38
  const MAX_DELAY = 8;
41
39
  const SERVER_PORT = process.env.SERVER_PORT || '3000';
@@ -52,16 +50,11 @@ const devLogFd = fs.openSync(devLogPath, 'a');
52
50
  function timestamp() {
53
51
  const now = new Date();
54
52
  return (
55
- now.getFullYear() +
56
- '-' +
57
- String(now.getMonth() + 1).padStart(2, '0') +
58
- '-' +
59
- String(now.getDate()).padStart(2, '0') +
60
- ' ' +
61
- String(now.getHours()).padStart(2, '0') +
62
- ':' +
63
- String(now.getMinutes()).padStart(2, '0') +
64
- ':' +
53
+ now.getFullYear() + '-' +
54
+ String(now.getMonth() + 1).padStart(2, '0') + '-' +
55
+ String(now.getDate()).padStart(2, '0') + ' ' +
56
+ String(now.getHours()).padStart(2, '0') + ':' +
57
+ String(now.getMinutes()).padStart(2, '0') + ':' +
65
58
  String(now.getSeconds()).padStart(2, '0')
66
59
  );
67
60
  }
@@ -75,33 +68,21 @@ const STDOUT_MAX_INFLIGHT = 1000;
75
68
  function writeOutput(msg) {
76
69
  // File first and synchronously — read-logs reads this file; it must never be gated
77
70
  // by the terminal consumer.
78
- try {
79
- fs.writeSync(devStdLogFd, msg);
80
- } catch {}
71
+ try { fs.writeSync(devStdLogFd, msg); } catch {}
81
72
  // stdout mirror via async fs.write: if process.stdout is a pty/pipe whose consumer
82
73
  // stalls, the block happens on the libuv threadpool, NOT the event loop — so the
83
74
  // synchronous log-FILE writes above (and subsequent readline callbacks) keep running.
84
75
  // Drop overflow when too many writes are already pending (best-effort mirror).
85
- if (_stdoutInFlight >= STDOUT_MAX_INFLIGHT) {
86
- return;
87
- }
76
+ if (_stdoutInFlight >= STDOUT_MAX_INFLIGHT) { return; }
88
77
  _stdoutInFlight++;
89
- try {
90
- fs.write(1, msg, () => {
91
- _stdoutInFlight--;
92
- });
93
- } catch {
94
- _stdoutInFlight--;
95
- }
78
+ try { fs.write(1, msg, () => { _stdoutInFlight--; }); } catch { _stdoutInFlight--; }
96
79
  }
97
80
 
98
81
  /** Structured event log → terminal + dev.std.log + dev.log */
99
82
  function logEvent(level, name, message) {
100
83
  const msg = `[${timestamp()}] [${level}] [${name}] ${message}\n`;
101
84
  writeOutput(msg);
102
- try {
103
- fs.writeSync(devLogFd, msg);
104
- } catch {}
85
+ try { fs.writeSync(devLogFd, msg); } catch {}
105
86
  }
106
87
 
107
88
  // ── Process group management ──────────────────────────────────────────────────
@@ -113,16 +94,11 @@ function killProcessGroup(pid, signal) {
113
94
 
114
95
  function killOrphansByPort(port) {
115
96
  try {
116
- const pids = execSync(`lsof -ti :${port}`, {
117
- encoding: 'utf8',
118
- timeout: 5000,
119
- }).trim();
97
+ const pids = execSync(`lsof -ti :${port}`, { encoding: 'utf8', timeout: 5000 }).trim();
120
98
  if (pids) {
121
99
  const pidList = pids.split('\n').filter(Boolean);
122
100
  for (const p of pidList) {
123
- try {
124
- process.kill(parseInt(p, 10), 'SIGKILL');
125
- } catch {}
101
+ try { process.kill(parseInt(p, 10), 'SIGKILL'); } catch {}
126
102
  }
127
103
  return pidList;
128
104
  }
@@ -135,7 +111,7 @@ let stopping = false;
135
111
  const managedProcesses = []; // { name, pid, child }
136
112
 
137
113
  function sleep(ms) {
138
- return new Promise(resolve => setTimeout(resolve, ms));
114
+ return new Promise((resolve) => setTimeout(resolve, ms));
139
115
  }
140
116
 
141
117
  /**
@@ -165,23 +141,14 @@ function startProcess({ name, command, args, cleanupPort }) {
165
141
  entry.child = child;
166
142
 
167
143
  const startTime = Date.now();
168
- logEvent(
169
- 'INFO',
170
- name,
171
- `Process started (PGID: ${child.pid}): ${command} ${args.join(' ')}`
172
- );
144
+ logEvent('INFO', name, `Process started (PGID: ${child.pid}): ${command} ${args.join(' ')}`);
173
145
 
174
146
  // Pipe stdout and stderr through readline for timestamped logging
175
- const pipeLines = stream => {
176
- const rl = readline.createInterface({
177
- input: stream,
178
- crlfDelay: Infinity,
179
- });
180
- rl.on('line', line => {
147
+ const pipeLines = (stream) => {
148
+ const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
149
+ rl.on('line', (line) => {
181
150
  const msg = `[${timestamp()}] [${name}] ${line}\n`;
182
- try {
183
- fs.writeSync(logFd, msg);
184
- } catch {}
151
+ try { fs.writeSync(logFd, msg); } catch {}
185
152
  writeOutput(msg);
186
153
  });
187
154
  };
@@ -192,8 +159,8 @@ function startProcess({ name, command, args, cleanupPort }) {
192
159
  // NOTE: must use 'exit', not 'close'. With shell:true, grandchild processes
193
160
  // (e.g. nest's server) inherit stdout pipes. 'close' won't fire until ALL
194
161
  // pipe holders exit, causing dev.js to hang when npm/nest dies but server survives.
195
- const exitCode = await new Promise(resolve => {
196
- child.on('exit', code => resolve(code ?? 1));
162
+ const exitCode = await new Promise((resolve) => {
163
+ child.on('exit', (code) => resolve(code ?? 1));
197
164
  child.on('error', () => resolve(1));
198
165
  });
199
166
 
@@ -210,11 +177,7 @@ function startProcess({ name, command, args, cleanupPort }) {
210
177
  if (cleanupPort) {
211
178
  const orphans = killOrphansByPort(cleanupPort);
212
179
  if (orphans.length > 0) {
213
- logEvent(
214
- 'WARN',
215
- name,
216
- `Killed orphan processes on port ${cleanupPort}: ${orphans.join(' ')}`
217
- );
180
+ logEvent('WARN', name, `Killed orphan processes on port ${cleanupPort}: ${orphans.join(' ')}`);
218
181
  await sleep(500);
219
182
  }
220
183
  }
@@ -224,38 +187,21 @@ function startProcess({ name, command, args, cleanupPort }) {
224
187
  const runDuration = (Date.now() - startTime) / 1000;
225
188
  if (runDuration >= 60) {
226
189
  restartCount = 0;
227
- logEvent(
228
- 'INFO',
229
- name,
230
- `Ran for ${Math.round(runDuration)}s, resetting restart counter`
231
- );
190
+ logEvent('INFO', name, `Ran for ${Math.round(runDuration)}s, resetting restart counter`);
232
191
  } else {
233
192
  restartCount++;
234
193
  }
235
194
  if (restartCount >= MAX_RESTART_COUNT) {
236
- logEvent(
237
- 'ERROR',
238
- name,
239
- `Max restart count (${MAX_RESTART_COUNT}) reached, giving up`
240
- );
195
+ logEvent('ERROR', name, `Max restart count (${MAX_RESTART_COUNT}) reached, giving up`);
241
196
  break;
242
197
  }
243
198
 
244
- const delay = Math.min(
245
- RESTART_DELAY * (1 << Math.max(0, restartCount - 1)),
246
- MAX_DELAY
247
- );
248
- logEvent(
249
- 'WARN',
250
- name,
251
- `Process exited with code ${exitCode}, restarting (${restartCount}/${MAX_RESTART_COUNT}) in ${delay}s...`
252
- );
199
+ const delay = Math.min(RESTART_DELAY * (1 << Math.max(0, restartCount - 1)), MAX_DELAY);
200
+ logEvent('WARN', name, `Process exited with code ${exitCode}, restarting (${restartCount}/${MAX_RESTART_COUNT}) in ${delay}s...`);
253
201
  await sleep(delay * 1000);
254
202
  }
255
203
 
256
- try {
257
- fs.closeSync(logFd);
258
- } catch {}
204
+ try { fs.closeSync(logFd); } catch {}
259
205
  };
260
206
 
261
207
  return run();
@@ -285,11 +231,7 @@ async function cleanup() {
285
231
  // Force kill any remaining
286
232
  for (const entry of managedProcesses) {
287
233
  if (entry.pid) {
288
- logEvent(
289
- 'WARN',
290
- 'main',
291
- `Force killing process group (PGID: ${entry.pid})`
292
- );
234
+ logEvent('WARN', 'main', `Force killing process group (PGID: ${entry.pid})`);
293
235
  killProcessGroup(entry.pid, 'SIGKILL');
294
236
  }
295
237
  }
@@ -300,12 +242,8 @@ async function cleanup() {
300
242
 
301
243
  logEvent('INFO', 'main', 'All processes stopped');
302
244
 
303
- try {
304
- fs.closeSync(devStdLogFd);
305
- } catch {}
306
- try {
307
- fs.closeSync(devLogFd);
308
- } catch {}
245
+ try { fs.closeSync(devStdLogFd); } catch {}
246
+ try { fs.closeSync(devLogFd); } catch {}
309
247
 
310
248
  process.exit(0);
311
249
  }
@@ -332,22 +270,17 @@ async function main() {
332
270
  // Initialize action plugins
333
271
  writeOutput('\n🔌 Initializing action plugins...\n');
334
272
  try {
335
- execSync('fullstack-cli action-plugin init', {
336
- cwd: PROJECT_ROOT,
337
- stdio: 'inherit',
338
- });
273
+ execSync('fullstack-cli action-plugin init', { cwd: PROJECT_ROOT, stdio: 'inherit' });
339
274
  writeOutput('✅ Action plugins initialized\n\n');
340
275
  } catch {
341
- writeOutput(
342
- '⚠️ Action plugin initialization failed, continuing anyway...\n\n'
343
- );
276
+ writeOutput('⚠️ Action plugin initialization failed, continuing anyway...\n\n');
344
277
  }
345
278
 
346
279
  // Start server and client
347
280
  const serverPromise = startProcess({
348
281
  name: 'server',
349
282
  command: 'npm',
350
- args: buildNestServerArgs({ projectRoot: PROJECT_ROOT, env: process.env }),
283
+ args: ['run', 'dev:server'],
351
284
  cleanupPort: SERVER_PORT,
352
285
  });
353
286
 
@@ -369,7 +302,7 @@ async function main() {
369
302
  }
370
303
  }
371
304
 
372
- main().catch(err => {
305
+ main().catch((err) => {
373
306
  console.error('Fatal error:', err);
374
307
  process.exit(1);
375
308
  });
@@ -1,53 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- const TYPE_CHECK_ENV = 'MIAODA_NEST_TYPE_CHECK_ENABLED';
7
- const DISABLED_CONFIG_RELATIVE_PATH = 'logs/nest-cli.type-check-disabled.json';
8
-
9
- /**
10
- * Build the npm arguments used to launch Nest in development.
11
- *
12
- * Missing or malformed values deliberately preserve the project's existing
13
- * nest-cli.json behavior. The platform injects an exact true/false value;
14
- * exact true forces the checker on, while exact false writes a narrow runtime
15
- * config override so the checked-in project config is never mutated.
16
- */
17
- function buildNestServerArgs({ projectRoot, env = process.env }) {
18
- const enabled = env[TYPE_CHECK_ENV];
19
- if (enabled === 'true') {
20
- return ['run', 'dev:server', '--', '--type-check'];
21
- }
22
- if (enabled !== 'false') {
23
- return ['run', 'dev:server'];
24
- }
25
-
26
- const sourcePath = path.join(projectRoot, 'nest-cli.json');
27
- const sourceConfig = JSON.parse(fs.readFileSync(sourcePath, 'utf8'));
28
- const runtimeConfig = {
29
- ...sourceConfig,
30
- compilerOptions: {
31
- ...(sourceConfig.compilerOptions || {}),
32
- typeCheck: false,
33
- },
34
- };
35
- const runtimePath = path.join(
36
- projectRoot,
37
- ...DISABLED_CONFIG_RELATIVE_PATH.split('/')
38
- );
39
- fs.mkdirSync(path.dirname(runtimePath), { recursive: true });
40
- const temporaryPath = `${runtimePath}.${process.pid}.tmp`;
41
- fs.writeFileSync(
42
- temporaryPath,
43
- `${JSON.stringify(runtimeConfig, null, 2)}\n`,
44
- {
45
- mode: 0o600,
46
- }
47
- );
48
- fs.renameSync(temporaryPath, runtimePath);
49
-
50
- return ['run', 'dev:server', '--', '--config', DISABLED_CONFIG_RELATIVE_PATH];
51
- }
52
-
53
- module.exports = { buildNestServerArgs };