@lark-apaas/fullstack-cli 1.1.45-alpha.1 → 1.1.45-alpha.2

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.45-alpha.1",
3
+ "version": "1.1.45-alpha.2",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@lark-apaas/http-client": "^0.1.5",
34
+ "@lark-apaas/http-client": "0.1.6-alpha.0",
35
35
  "@lydell/node-pty": "1.1.0",
36
36
  "@vercel/nft": "^0.30.3",
37
37
  "commander": "^13.0.0",
@@ -1 +0,0 @@
1
- npm run precommit
@@ -1,5 +0,0 @@
1
- {
2
- "devDependencies": {
3
- "husky": "^9.1.7"
4
- }
5
- }
@@ -1,86 +0,0 @@
1
- #!/usr/bin/env node
2
- // FULLSTACK_PRECOMMIT_V1
3
- 'use strict';
4
-
5
- const { spawnSync } = require('node:child_process');
6
- const path = require('node:path');
7
-
8
- const SEP = ' ' + '─'.repeat(36);
9
- const LOG_DIR = process.env.FULLSTACK_LOG_DIR || '/tmp';
10
- const READ_LOG_TYPES = ['server-std', 'client-std'];
11
-
12
- function logFileFor(type) {
13
- return type.endsWith('-std') ? type.slice(0, -4) + '.std.log' : type + '.log';
14
- }
15
-
16
- function failAndExit(step, body, extraTip) {
17
- process.stderr.write('\n✗ pre-commit failed: ' + step + '\n');
18
- process.stderr.write(SEP + '\n');
19
- if (body && body.length > 0) {
20
- process.stderr.write(body.replace(/\s+$/, '') + '\n');
21
- }
22
- process.stderr.write(SEP + '\n');
23
- if (extraTip) {
24
- process.stderr.write(' tip: ' + extraTip + '\n');
25
- }
26
- process.stderr.write(' bypass: git commit --no-verify\n');
27
- process.exit(1);
28
- }
29
-
30
- function runLint() {
31
- const cwd = process.cwd();
32
- const res = spawnSync('npm', ['run', 'lint'], {
33
- cwd,
34
- stdio: ['ignore', 'pipe', 'pipe'],
35
- env: process.env,
36
- });
37
- if (res.error) {
38
- failAndExit('lint', String(res.error.message || res.error));
39
- }
40
- if (res.status !== 0) {
41
- const stdout = res.stdout ? res.stdout.toString() : '';
42
- const stderr = res.stderr ? res.stderr.toString() : '';
43
- failAndExit('lint', stdout + '\n' + stderr);
44
- }
45
- }
46
-
47
- function runReadLogsCheck() {
48
- for (const type of READ_LOG_TYPES) {
49
- const res = spawnSync(
50
- 'npx',
51
- ['--no-install', 'fullstack-cli', 'read-logs', '--dir', LOG_DIR, '--type', type, '--max-lines', '200'],
52
- { stdio: ['ignore', 'pipe', 'pipe'], env: process.env }
53
- );
54
-
55
- // 读不到日志文件、CLI 不存在或其他执行错误都不阻断 commit
56
- if (res.error) continue;
57
- if (res.status !== 0) continue;
58
-
59
- const stdout = res.stdout ? res.stdout.toString() : '';
60
- const lines = stdout.split('\n').map((s) => s.trim()).filter(Boolean);
61
- if (lines.length === 0) continue;
62
-
63
- let parsed;
64
- try {
65
- parsed = JSON.parse(lines[lines.length - 1]);
66
- } catch (_) {
67
- continue;
68
- }
69
-
70
- if (parsed && parsed.hasError === true) {
71
- const logs = Array.isArray(parsed.logs) ? parsed.logs : [];
72
- const preview = logs
73
- .slice(-10)
74
- .map((entry) => (typeof entry === 'string' ? entry : JSON.stringify(entry)))
75
- .join('\n');
76
- failAndExit(
77
- 'read-logs[' + type + ']',
78
- preview,
79
- '若为历史 session 残留,可 rm ' + path.join(LOG_DIR, logFileFor(type)) + ' 后重试'
80
- );
81
- }
82
- }
83
- }
84
-
85
- runLint();
86
- runReadLogsCheck();