@lark-apaas/fullstack-cli 1.1.69 → 1.1.70-alpha.20261026131749

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.
Files changed (2) hide show
  1. package/dist/index.js +122 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7911,6 +7911,101 @@ function hasErrorInStdLines(lines) {
7911
7911
  return lines.some((line) => classifyStdLine(line) === "error");
7912
7912
  }
7913
7913
 
7914
+ // src/commands/read-logs/type-check.ts
7915
+ var TYPE_CHECK_SCAN_LINES = 2e3;
7916
+ var TYPE_CHECK_PREFIX_MAX_LINES = 40;
7917
+ var ANSI_PATTERN2 = /\u001b\[[0-?]*[ -/]*[@-~]/g;
7918
+ var LEADING_TIMESTAMP_PATTERN = /^\[[^\]]*\]\s?/;
7919
+ var SESSION_START_PATTERN = /\bdev:server\b/;
7920
+ var CHECKER_INIT_PATTERN = /\bTSC\s+Initializing type checker/;
7921
+ var RESULT_PATTERN = /\bTSC\s+Found (\d+) (?:errors?|issues)\b|\bFound (\d+) errors?\. Watching for file changes/;
7922
+ var DIAGNOSTIC_PATTERN = /^\S.*\berror TS\d+:/;
7923
+ function contentOf(line) {
7924
+ return line.replace(ANSI_PATTERN2, "").replace(LEADING_TIMESTAMP_PATTERN, "");
7925
+ }
7926
+ function isContinuation(content) {
7927
+ return !content.trim() || /^\s/.test(content) || /^\d+\s/.test(content);
7928
+ }
7929
+ function findLatestTypeCheck(lines) {
7930
+ let sessionStart = 0;
7931
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
7932
+ if (SESSION_START_PATTERN.test(contentOf(lines[index] ?? ""))) {
7933
+ sessionStart = index;
7934
+ break;
7935
+ }
7936
+ }
7937
+ let windowStart = sessionStart;
7938
+ let latest = { status: "none" };
7939
+ let previousContent = "";
7940
+ for (let index = sessionStart; index < lines.length; index += 1) {
7941
+ const content = contentOf(lines[index] ?? "");
7942
+ const match = content.match(RESULT_PATTERN);
7943
+ if (!match) {
7944
+ if (content.trim()) previousContent = content;
7945
+ continue;
7946
+ }
7947
+ const errorCount = Number(match[1] ?? match[2]);
7948
+ const isInitSnapshot = errorCount === 0 && CHECKER_INIT_PATTERN.test(previousContent);
7949
+ previousContent = content;
7950
+ if (isInitSnapshot) continue;
7951
+ const blocks = extractDiagnosticBlocks(lines, windowStart, index);
7952
+ latest = errorCount > 0 && blocks.length > 0 ? {
7953
+ status: "failed",
7954
+ errorCount,
7955
+ blocks: blocks.map((block) => ({
7956
+ level: "error",
7957
+ lines: block.lines
7958
+ })),
7959
+ resultLine: lines[index] ?? "",
7960
+ firstLineIndex: blocks[0]?.startIndex ?? index
7961
+ } : { status: "none" };
7962
+ windowStart = index + 1;
7963
+ }
7964
+ return latest;
7965
+ }
7966
+ function extractDiagnosticBlocks(lines, from, to) {
7967
+ const blocks = [];
7968
+ for (let index = from; index < to; index += 1) {
7969
+ if (!DIAGNOSTIC_PATTERN.test(contentOf(lines[index] ?? ""))) continue;
7970
+ const blockLines = [lines[index] ?? ""];
7971
+ const startIndex = index;
7972
+ while (index + 1 < to) {
7973
+ const next = contentOf(lines[index + 1] ?? "");
7974
+ if (DIAGNOSTIC_PATTERN.test(next) || !isContinuation(next)) break;
7975
+ blockLines.push(lines[index + 1] ?? "");
7976
+ index += 1;
7977
+ }
7978
+ while (blockLines.length > 1 && !contentOf(blockLines[blockLines.length - 1] ?? "").trim()) {
7979
+ blockLines.pop();
7980
+ }
7981
+ blocks.push({ startIndex, lines: blockLines });
7982
+ }
7983
+ return blocks;
7984
+ }
7985
+ function readServerStdTailForTypeCheck(filePath) {
7986
+ const lines = readFileTailLines(filePath, TYPE_CHECK_SCAN_LINES).map(
7987
+ stripPrefixFromStdLine
7988
+ );
7989
+ while (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
7990
+ return lines;
7991
+ }
7992
+ function buildTypeCheckPrefix(state, totalLines, visibleLineCount) {
7993
+ if (state.status !== "failed") return [];
7994
+ const windowStart = totalLines - visibleLineCount;
7995
+ if (state.firstLineIndex >= windowStart) return [];
7996
+ const shown = [];
7997
+ let shownBlocks = 0;
7998
+ for (const block of state.blocks) {
7999
+ const remaining = TYPE_CHECK_PREFIX_MAX_LINES - shown.length;
8000
+ if (remaining <= 0) break;
8001
+ if (block.lines.length > remaining && shownBlocks > 0) break;
8002
+ shown.push(...block.lines.slice(0, remaining));
8003
+ shownBlocks += 1;
8004
+ }
8005
+ const hint = shownBlocks < state.blocks.length ? `[Type check reported ${state.errorCount} error(s), showing the first ${shownBlocks}; fix them and read again to see the rest]` : `[Type check reported ${state.errorCount} error(s)]`;
8006
+ return [hint, ...shown, state.resultLine];
8007
+ }
8008
+
7914
8009
  // src/commands/read-logs/index.ts
7915
8010
  var LOG_TYPES = [
7916
8011
  "server",
@@ -8062,10 +8157,26 @@ async function readLatestLogLinesMeta(options) {
8062
8157
  }
8063
8158
  if (options.type === "server-std") {
8064
8159
  const requestedLevels = normalizeRequestedStdLevels(levels);
8065
- if (!requestedLevels)
8066
- return readServerStdSegment(filePath, maxLines, offset);
8160
+ const tail = readServerStdTailForTypeCheck(filePath);
8161
+ const typeCheck = findLatestTypeCheck(tail);
8162
+ if (!requestedLevels) {
8163
+ const segment2 = readServerStdSegment(filePath, maxLines, offset);
8164
+ if (offset > 0) return segment2;
8165
+ return {
8166
+ ...segment2,
8167
+ prefixLines: buildTypeCheckPrefix(
8168
+ typeCheck,
8169
+ tail.length,
8170
+ Math.min(maxLines, segment2.totalLinesCount)
8171
+ )
8172
+ };
8173
+ }
8067
8174
  const segment = readServerStdSegment(filePath, STD_LEVEL_SCAN_LINES, 0);
8068
8175
  const blocks = extractStdDiagnosticBlocks(segment.lines, requestedLevels);
8176
+ const segmentStart = tail.length - Math.min(segment.totalLinesCount, tail.length);
8177
+ if (requestedLevels.has("error") && typeCheck.status === "failed" && typeCheck.firstLineIndex < segmentStart) {
8178
+ blocks.push(...typeCheck.blocks);
8179
+ }
8069
8180
  return {
8070
8181
  lines: paginateStdDiagnosticBlocks(blocks, maxLines, offset),
8071
8182
  totalLinesCount: blocks.reduce(
@@ -8116,7 +8227,12 @@ async function readLatestLogLinesMeta(options) {
8116
8227
  return { lines: [], totalLinesCount: 0 };
8117
8228
  }
8118
8229
  async function readLogsJsonResult(options) {
8119
- const { lines, totalLinesCount, allLines } = await readLatestLogLinesMeta(options);
8230
+ const {
8231
+ lines,
8232
+ totalLinesCount,
8233
+ allLines,
8234
+ prefixLines = []
8235
+ } = await readLatestLogLinesMeta(options);
8120
8236
  if (options.type === "server-std" || options.type === "client-std" || options.type === "dev" || options.type === "dev-std" || options.type === "install-dep-std") {
8121
8237
  const linesForErrorCheck = allLines ?? lines;
8122
8238
  const stackTracePattern = /\bat\s+\S+\s+\([^)]+:\d+:\d+\)/;
@@ -8129,9 +8245,9 @@ async function readLogsJsonResult(options) {
8129
8245
  const start = Math.max(0, endExclusive - maxLines);
8130
8246
  const paginatedLogs = stdLevelFilteringActive ? lines : filteredLines.slice(start, endExclusive);
8131
8247
  return {
8132
- hasError: hasErrorInStdLines(linesForErrorCheck),
8133
- totalLinesCount: stdLevelFilteringActive ? totalLinesCount : filteredLines.length,
8134
- logs: paginatedLogs
8248
+ hasError: hasErrorInStdLines(linesForErrorCheck) || hasErrorInStdLines(prefixLines),
8249
+ totalLinesCount: (stdLevelFilteringActive ? totalLinesCount : filteredLines.length) + prefixLines.length,
8250
+ logs: [...prefixLines, ...paginatedLogs]
8135
8251
  };
8136
8252
  }
8137
8253
  const logs = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.69",
3
+ "version": "1.1.70-alpha.20261026131749",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",