@gaonjs/cli 0.41.7 → 0.42.0
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/commands/check.js +6 -4
- package/dist/commands/test.d.ts +8 -0
- package/dist/commands/test.js +48 -15
- package/dist/db/journal.d.ts +8 -1
- package/dist/db/journal.js +9 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.js +49 -11
- package/dist/mcp/tools.d.ts +9 -5
- package/dist/mcp/tools.js +18 -35
- package/dist/templates/project/agents/data.md.tpl +1 -1
- package/package.json +4 -4
package/dist/commands/check.js
CHANGED
|
@@ -30,7 +30,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
30
30
|
import { join } from 'node:path';
|
|
31
31
|
import { generateTablesDts } from '@gaonjs/data';
|
|
32
32
|
import { generateRoutesDts } from '@gaonjs/web';
|
|
33
|
-
import {
|
|
33
|
+
import { computeDoctorResult } from '../doctor.js';
|
|
34
34
|
import { regenerateGaonOnce, resolveDevLayout } from '../dev.js';
|
|
35
35
|
import { registerTsResolve } from '../tsResolve.js';
|
|
36
36
|
import { listFrontendApps, verifyAppDist } from '../dev/build.js';
|
|
@@ -209,9 +209,11 @@ async function verifyBuildOutput(cwd) {
|
|
|
209
209
|
/** doctor 는 이미 있는 명령을 재사용 — cwd 만 넘긴다. json 은 상위에서. */
|
|
210
210
|
async function runDoctorStep(cwd) {
|
|
211
211
|
try {
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
|
|
212
|
+
// computeDoctorResult 는 stdout 에 아무것도 쓰지 않고 결과만 돌려준다.
|
|
213
|
+
// runDoctorCommand 는 사람용 리포트를 stdout 에 직접 찍어 `gaon check --json`
|
|
214
|
+
// 의 순수 JSON 출력을 오염시켰다(mcp 의 parseJsonTail 우회가 방증). check 는
|
|
215
|
+
// 결과 객체만 필요하므로 무출력 경로를 쓴다(결정 269 · "--json = 파싱 안전").
|
|
216
|
+
const result = await computeDoctorResult({ cwd });
|
|
215
217
|
const failed = !!result.fatal || result.errors.length > 0;
|
|
216
218
|
return {
|
|
217
219
|
step: 'doctor',
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ export interface TestCommandOptions {
|
|
|
3
3
|
readonly cwd?: string;
|
|
4
4
|
readonly json?: boolean;
|
|
5
5
|
readonly scope?: TestScope;
|
|
6
|
+
/**
|
|
7
|
+
* 프로그램 호출(MCP run_tests)용 출력 싱크. 지정되면 자식(vitest·test 스크립트)
|
|
8
|
+
* stdout/stderr 를 상속(inherit) 대신 파이프로 이 콜백에 흘린다 — 결과를 도구
|
|
9
|
+
* 응답에 담기 위함. CLI 경로(미지정)는 종전대로 `stdio:'inherit'`. 이 옵션으로
|
|
10
|
+
* MCP 가 `gaon test` 하네스(테스트 DB 프로비저닝·GAON_STREAM_PREFIX 격리·사용자
|
|
11
|
+
* test 스크립트 우선)를 그대로 거치게 한다(결정 270 · vitest 직접 spawn 우회 제거).
|
|
12
|
+
*/
|
|
13
|
+
readonly onOutput?: (chunk: string) => void;
|
|
6
14
|
}
|
|
7
15
|
/**
|
|
8
16
|
* `gaon test` 진입점. args 는 사용자가 넘긴 잔여 인자(필터 문자열 등).
|
package/dist/commands/test.js
CHANGED
|
@@ -67,7 +67,21 @@ function scopeArgs(scope) {
|
|
|
67
67
|
* scope='unit' 은 실 인프라가 필요 없으므로 건너뛴다. config 가 없거나 db 커넥션이
|
|
68
68
|
* 없으면 조용히 스킵(순수 vitest 위임). DB 접속 실패는 수리 안내와 함께 실패한다.
|
|
69
69
|
*/
|
|
70
|
-
async function provisionTestDatabases(cwd, json) {
|
|
70
|
+
async function provisionTestDatabases(cwd, json, onOutput) {
|
|
71
|
+
// capture(MCP) 모드는 stdio JSON-RPC 를 오염시키지 않도록 모든 출력을 싱크로
|
|
72
|
+
// 돌린다 — process.stdout 직접 쓰기 0(결정 270).
|
|
73
|
+
const writeOut = (s) => {
|
|
74
|
+
if (onOutput)
|
|
75
|
+
onOutput(s);
|
|
76
|
+
else
|
|
77
|
+
process.stdout.write(s);
|
|
78
|
+
};
|
|
79
|
+
const writeErr = (s) => {
|
|
80
|
+
if (onOutput)
|
|
81
|
+
onOutput(s);
|
|
82
|
+
else
|
|
83
|
+
process.stderr.write(s);
|
|
84
|
+
};
|
|
71
85
|
registerTsResolve();
|
|
72
86
|
let config;
|
|
73
87
|
try {
|
|
@@ -93,7 +107,7 @@ async function provisionTestDatabases(cwd, json) {
|
|
|
93
107
|
});
|
|
94
108
|
if (res.exitCode !== 0) {
|
|
95
109
|
if (!json)
|
|
96
|
-
|
|
110
|
+
writeErr(` ✗ 테스트 DB '${key}' 마이그레이션 실패\n${res.text}\n`);
|
|
97
111
|
return false;
|
|
98
112
|
}
|
|
99
113
|
prepared.push(key);
|
|
@@ -104,18 +118,18 @@ async function provisionTestDatabases(cwd, json) {
|
|
|
104
118
|
const hint = ` ✗ 테스트 DB 준비 실패: ${msg}\n` +
|
|
105
119
|
` → DB 가 떠 있는지 확인하세요(docker compose up -d db). 테스트는 실 인프라가 필요합니다(§9).\n`;
|
|
106
120
|
if (json)
|
|
107
|
-
|
|
121
|
+
writeOut(JSON.stringify({ ok: false, kind: 'provision', error: msg }) + '\n');
|
|
108
122
|
else
|
|
109
|
-
|
|
123
|
+
writeErr(hint);
|
|
110
124
|
return false;
|
|
111
125
|
}
|
|
112
126
|
finally {
|
|
113
127
|
await destroyAllConnections();
|
|
114
128
|
}
|
|
115
129
|
if (json)
|
|
116
|
-
|
|
130
|
+
writeOut(JSON.stringify({ kind: 'provisioned', dbs: prepared }) + '\n');
|
|
117
131
|
else
|
|
118
|
-
|
|
132
|
+
writeOut(` gaon test · 테스트 DB 준비 완료 (${prepared.join(', ')}) — <db>_test\n`);
|
|
119
133
|
return true;
|
|
120
134
|
}
|
|
121
135
|
/**
|
|
@@ -127,9 +141,23 @@ export async function runTestCommand(args = [], opts = {}) {
|
|
|
127
141
|
const cwd = opts.cwd ?? process.cwd();
|
|
128
142
|
const scope = opts.scope ?? 'all';
|
|
129
143
|
const json = opts.json ?? false;
|
|
144
|
+
const capture = typeof opts.onOutput === 'function';
|
|
145
|
+
// capture(MCP) 모드: 모든 출력을 싱크로. 미지정: 종전대로 process.std*.
|
|
146
|
+
const writeOut = (s) => {
|
|
147
|
+
if (opts.onOutput)
|
|
148
|
+
opts.onOutput(s);
|
|
149
|
+
else
|
|
150
|
+
process.stdout.write(s);
|
|
151
|
+
};
|
|
152
|
+
const writeErr = (s) => {
|
|
153
|
+
if (opts.onOutput)
|
|
154
|
+
opts.onOutput(s);
|
|
155
|
+
else
|
|
156
|
+
process.stderr.write(s);
|
|
157
|
+
};
|
|
130
158
|
// 결정 111: unit 이 아니면 실행 전 테스트 DB 를 준비한다(생성 + 마이그레이션).
|
|
131
159
|
if (scope !== 'unit') {
|
|
132
|
-
const ok = await provisionTestDatabases(cwd, json);
|
|
160
|
+
const ok = await provisionTestDatabases(cwd, json, opts.onOutput);
|
|
133
161
|
if (!ok)
|
|
134
162
|
return 1;
|
|
135
163
|
}
|
|
@@ -151,10 +179,10 @@ export async function runTestCommand(args = [], opts = {}) {
|
|
|
151
179
|
const msg = `vitest 가 설치돼 있지 않고 package.json 에 "test" 스크립트도 없습니다.\n` +
|
|
152
180
|
`→ pnpm add -D vitest 후 다시 실행하거나, package.json 에 "test": "vitest run" 을 추가하세요.`;
|
|
153
181
|
if (json) {
|
|
154
|
-
|
|
182
|
+
writeOut(JSON.stringify({ ok: false, error: msg }) + '\n');
|
|
155
183
|
}
|
|
156
184
|
else {
|
|
157
|
-
|
|
185
|
+
writeErr(` ✗ ${msg}\n`);
|
|
158
186
|
}
|
|
159
187
|
return 127;
|
|
160
188
|
}
|
|
@@ -168,20 +196,25 @@ export async function runTestCommand(args = [], opts = {}) {
|
|
|
168
196
|
// 값을 세팅했으면 존중한다(고급 · 다중 테스트 컨텍스트 분리).
|
|
169
197
|
const testEnv = { ...process.env, GAON_STREAM_PREFIX: process.env.GAON_STREAM_PREFIX ?? 'test' };
|
|
170
198
|
if (json) {
|
|
171
|
-
|
|
199
|
+
writeOut(JSON.stringify({ kind: 'starting', cmd, args: spawnArgs, scope, streamPrefix: testEnv.GAON_STREAM_PREFIX }) + '\n');
|
|
172
200
|
}
|
|
173
201
|
else {
|
|
174
|
-
|
|
202
|
+
writeOut(` gaon test · ${cmd} ${spawnArgs.join(' ')} (scope=${scope})\n`);
|
|
175
203
|
}
|
|
176
204
|
const exitCode = await new Promise((resolvePromise) => {
|
|
205
|
+
// capture(MCP) 모드는 자식 출력을 파이프로 모아 싱크로 흘린다(도구 응답에 담기).
|
|
206
|
+
// CLI 경로(미지정)는 vitest 컬러 출력·리포터를 그대로 보이게 stdio 를 상속한다.
|
|
177
207
|
const child = spawn(cmd, spawnArgs, {
|
|
178
208
|
cwd,
|
|
179
209
|
env: testEnv,
|
|
180
|
-
|
|
181
|
-
stdio: 'inherit',
|
|
210
|
+
stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit',
|
|
182
211
|
});
|
|
212
|
+
if (capture) {
|
|
213
|
+
child.stdout?.on('data', (d) => opts.onOutput(d.toString('utf8')));
|
|
214
|
+
child.stderr?.on('data', (d) => opts.onOutput(d.toString('utf8')));
|
|
215
|
+
}
|
|
183
216
|
child.on('error', (err) => {
|
|
184
|
-
|
|
217
|
+
writeErr(` ✗ gaon test spawn 실패: ${String(err)}\n`);
|
|
185
218
|
resolvePromise(127);
|
|
186
219
|
});
|
|
187
220
|
child.on('close', (code, signal) => {
|
|
@@ -195,7 +228,7 @@ export async function runTestCommand(args = [], opts = {}) {
|
|
|
195
228
|
});
|
|
196
229
|
});
|
|
197
230
|
if (json) {
|
|
198
|
-
|
|
231
|
+
writeOut(JSON.stringify({ kind: 'exited', exitCode }) + '\n');
|
|
199
232
|
}
|
|
200
233
|
return exitCode;
|
|
201
234
|
}
|
package/dist/db/journal.d.ts
CHANGED
|
@@ -9,7 +9,14 @@ export interface JournalEntry {
|
|
|
9
9
|
readonly down_sql: string | null;
|
|
10
10
|
readonly applied_at: Date;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* _gaon_migrations 존재 여부. information_schema 조회로 방언 무관.
|
|
14
|
+
*
|
|
15
|
+
* count 는 캐스트 없이 뽑는다 — 이전 `count(*)::text` 는 postgres 전용 문법이라
|
|
16
|
+
* mysql/mariadb 에서 문법 에러를 내며 `gaon db migrate/status/down/reset` 을 전멸시켰다.
|
|
17
|
+
* pg 는 count 를 bigint(문자열)로, mysql 은 number 로 돌려주므로 `Number()` 로 통일한다
|
|
18
|
+
* (양 방언 공통 · 결정 268).
|
|
19
|
+
*/
|
|
13
20
|
export declare function journalExists(db: Kysely<any>): Promise<boolean>;
|
|
14
21
|
/**
|
|
15
22
|
* _gaon_migrations 를 만든다(존재하면 no-op). id/kind/applied_at/db_key/
|
package/dist/db/journal.js
CHANGED
|
@@ -9,10 +9,17 @@
|
|
|
9
9
|
// 마이그레이션은 커넥션별로 돈다(§4.5) — 원장도 커넥션 DB 마다 따로 존재한다.
|
|
10
10
|
import { sql } from 'kysely';
|
|
11
11
|
import { MIGRATIONS_TABLE } from '@gaonjs/data';
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* _gaon_migrations 존재 여부. information_schema 조회로 방언 무관.
|
|
14
|
+
*
|
|
15
|
+
* count 는 캐스트 없이 뽑는다 — 이전 `count(*)::text` 는 postgres 전용 문법이라
|
|
16
|
+
* mysql/mariadb 에서 문법 에러를 내며 `gaon db migrate/status/down/reset` 을 전멸시켰다.
|
|
17
|
+
* pg 는 count 를 bigint(문자열)로, mysql 은 number 로 돌려주므로 `Number()` 로 통일한다
|
|
18
|
+
* (양 방언 공통 · 결정 268).
|
|
19
|
+
*/
|
|
13
20
|
export async function journalExists(db) {
|
|
14
21
|
const rows = await sql `
|
|
15
|
-
select count(*)
|
|
22
|
+
select count(*) as n
|
|
16
23
|
from information_schema.tables
|
|
17
24
|
where table_name = ${MIGRATIONS_TABLE}
|
|
18
25
|
`.execute(db);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DevCommandOptions } from "./commands/dev.js";
|
|
2
2
|
import { type ServeCommandOptions } from "./serve.js";
|
|
3
|
+
import { type DbSubcommand, type DbCommandOptions } from "./commands/db.js";
|
|
3
4
|
import { type DoctorRule } from "./doctor.js";
|
|
4
5
|
export { startDev, resolveDevLayout, regenerateGaonOnce, type DevDeps, type DevLayout, type DevApp, type DevEvent, type DevHandle, type RegenDeps, type RegenResult, } from "./dev.js";
|
|
5
6
|
export { runDevCommand, type DevCommandOptions } from "./commands/dev.js";
|
|
@@ -72,6 +73,16 @@ export interface ParsedNewArgs {
|
|
|
72
73
|
* npm 이 프로젝트 이름으로 오인되지 않도록(결정 167 · O-1 근본 fix).
|
|
73
74
|
*/
|
|
74
75
|
export declare function parseNewArgs(rest: readonly string[]): ParsedNewArgs;
|
|
76
|
+
/**
|
|
77
|
+
* `gaon db <sub>` 의 인자를 파싱한다(argv = 전체 · argv[0]='db', argv[1]=sub).
|
|
78
|
+
*
|
|
79
|
+
* 방향 토큰 `down` 은 **위치 인자**다 — 값 플래그(`--db`/`--config <값>`)와 불리언
|
|
80
|
+
* 플래그를 건너뛰고 판별한다. 이전엔 `argv[2] === 'down'` 고정 위치로만 봐서
|
|
81
|
+
* `gaon db migrate --db X down` 처럼 플래그가 앞서면 down 을 놓치고 정방향 migrate 로
|
|
82
|
+
* 조용히 반전됐다(파괴 방향 오동작 · 결정 267). 위치로 훑어 순서와 무관하게
|
|
83
|
+
* 정확히 롤백으로 인식한다.
|
|
84
|
+
*/
|
|
85
|
+
export declare function parseDbArgs(sub: DbSubcommand, argv: readonly string[]): DbCommandOptions;
|
|
75
86
|
/**
|
|
76
87
|
* `--port <값>` 플래그를 읽어 검증한다(serve·dev 공용). 플래그가 없으면
|
|
77
88
|
* undefined(기본 포트 폴백). 플래그는 있는데 값이 없거나(마지막 토큰) 다른
|
package/dist/index.js
CHANGED
|
@@ -197,6 +197,42 @@ export function parseNewArgs(rest) {
|
|
|
197
197
|
}
|
|
198
198
|
return { name, unknownPm: pmRaw === undefined || pmRaw === "" ? undefined : pmRaw };
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* `gaon db <sub>` 의 인자를 파싱한다(argv = 전체 · argv[0]='db', argv[1]=sub).
|
|
202
|
+
*
|
|
203
|
+
* 방향 토큰 `down` 은 **위치 인자**다 — 값 플래그(`--db`/`--config <값>`)와 불리언
|
|
204
|
+
* 플래그를 건너뛰고 판별한다. 이전엔 `argv[2] === 'down'` 고정 위치로만 봐서
|
|
205
|
+
* `gaon db migrate --db X down` 처럼 플래그가 앞서면 down 을 놓치고 정방향 migrate 로
|
|
206
|
+
* 조용히 반전됐다(파괴 방향 오동작 · 결정 267). 위치로 훑어 순서와 무관하게
|
|
207
|
+
* 정확히 롤백으로 인식한다.
|
|
208
|
+
*/
|
|
209
|
+
export function parseDbArgs(sub, argv) {
|
|
210
|
+
const dbIdx = argv.indexOf("--db");
|
|
211
|
+
const cfgIdx = argv.indexOf("--config");
|
|
212
|
+
const valueFlags = new Set(["--db", "--config"]);
|
|
213
|
+
const positionals = [];
|
|
214
|
+
for (let i = 2; i < argv.length; i++) {
|
|
215
|
+
const a = argv[i];
|
|
216
|
+
if (a === undefined)
|
|
217
|
+
continue;
|
|
218
|
+
if (valueFlags.has(a)) {
|
|
219
|
+
i++; // 플래그 값 스킵
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (a.startsWith("--"))
|
|
223
|
+
continue; // 불리언 플래그
|
|
224
|
+
positionals.push(a);
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
json: argv.includes("--json"),
|
|
228
|
+
db: dbIdx >= 0 ? argv[dbIdx + 1] : undefined,
|
|
229
|
+
config: cfgIdx >= 0 ? argv[cfgIdx + 1] : undefined,
|
|
230
|
+
yes: argv.includes("--yes"),
|
|
231
|
+
dryRun: argv.includes("--dry-run"),
|
|
232
|
+
// `gaon db migrate down` — 위치 인자로 롤백 지시(순서 무관).
|
|
233
|
+
down: sub === "migrate" && positionals.includes("down"),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
200
236
|
/**
|
|
201
237
|
* `--port <값>` 플래그를 읽어 검증한다(serve·dev 공용). 플래그가 없으면
|
|
202
238
|
* undefined(기본 포트 폴백). 플래그는 있는데 값이 없거나(마지막 토큰) 다른
|
|
@@ -447,17 +483,7 @@ export function runCli(argv, opts = {}) {
|
|
|
447
483
|
process.exitCode = 1;
|
|
448
484
|
return;
|
|
449
485
|
}
|
|
450
|
-
const
|
|
451
|
-
const cfgIdx = argv.indexOf("--config");
|
|
452
|
-
const dbOpts = {
|
|
453
|
-
json: argv.includes("--json"),
|
|
454
|
-
db: dbIdx >= 0 ? argv[dbIdx + 1] : undefined,
|
|
455
|
-
config: cfgIdx >= 0 ? argv[cfgIdx + 1] : undefined,
|
|
456
|
-
yes: argv.includes("--yes"),
|
|
457
|
-
dryRun: argv.includes("--dry-run"),
|
|
458
|
-
// `gaon db migrate down` — 위치 인자로 롤백 지시.
|
|
459
|
-
down: sub === "migrate" && argv[2] === "down",
|
|
460
|
-
};
|
|
486
|
+
const dbOpts = parseDbArgs(sub, argv);
|
|
461
487
|
void runDbCommand(sub, dbOpts)
|
|
462
488
|
.then((code) => {
|
|
463
489
|
process.exitCode = code;
|
|
@@ -616,6 +642,18 @@ export function runCli(argv, opts = {}) {
|
|
|
616
642
|
});
|
|
617
643
|
return;
|
|
618
644
|
}
|
|
645
|
+
// 결정 266: 미지 명령은 로드맵 배너로 조용히 성공(exit 0)하지 않는다 — `gaon serv`·
|
|
646
|
+
// `gaon migrate` 같은 오타가 성공 종료로 오판되면 CI·AI 가 실패를 못 본다.
|
|
647
|
+
// argv[0] 가 있으면서 어떤 명령·플래그와도 안 맞으면(플래그는 `-` 접두라
|
|
648
|
+
// help/version/json 폴백이 처리) 여기서 fail-loud(§7.5.3). 인자 없는 `gaon`
|
|
649
|
+
// (argv[0] 미존재)은 종전대로 로드맵 배너를 낸다.
|
|
650
|
+
if (argv[0] !== undefined && !argv[0].startsWith("-")) {
|
|
651
|
+
process.stderr.write(` ✗ 알 수 없는 명령: ${argv[0]}\n` +
|
|
652
|
+
` → 지원 명령: dev · serve · check · gen · build · doctor · mcp · hub · work · jobs · db · g · new · console · test\n` +
|
|
653
|
+
` → 전체 사용법: gaon --help\n`);
|
|
654
|
+
process.exitCode = 1;
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
619
657
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
620
658
|
process.stdout.write(renderHelp(version) + "\n");
|
|
621
659
|
return;
|
package/dist/mcp/tools.d.ts
CHANGED
|
@@ -54,10 +54,14 @@ export declare function getSchemaTool(args: ToolArgs, cwd: string): Promise<Tool
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function runMigrationTool(args: ToolArgs, cwd: string): Promise<ToolResult>;
|
|
56
56
|
/**
|
|
57
|
-
* `run_tests` — 프로젝트 테스트를
|
|
57
|
+
* `run_tests` — 프로젝트 테스트를 정본 `gaon test` 하네스로 실행한다(§9).
|
|
58
58
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
59
|
+
* 결정 270: 이전엔 여기서 `vitest run` 을 **직접 spawn** 해 `gaon test`(runTestCommand)의
|
|
60
|
+
* 세 가지 필수 거동을 전부 우회했다 — ① `<db>_test` 프로비저닝(결정 111) ② NATS
|
|
61
|
+
* `GAON_STREAM_PREFIX` 격리(결정 130) ③ 사용자 `test` 스크립트 우선(결정 170). 주석은
|
|
62
|
+
* "같은 경로" 라 주장했으나 거짓이었다. 이제 runTestCommand 에 위임하고, MCP(stdio
|
|
63
|
+
* JSON-RPC) 컨텍스트라 자식·프로비저닝 출력을 `onOutput` 싱크로 모아 도구 응답에
|
|
64
|
+
* 담는다(process.stdout 오염 0 — 트랜스포트 보호).
|
|
61
65
|
*
|
|
62
66
|
* 인자:
|
|
63
67
|
* { scope?: 'unit'|'integration'|'all', filter?: string }
|
|
@@ -65,8 +69,8 @@ export declare function runMigrationTool(args: ToolArgs, cwd: string): Promise<T
|
|
|
65
69
|
* filter — vitest 위치 인자(파일 패턴 substring)
|
|
66
70
|
*
|
|
67
71
|
* 반환:
|
|
68
|
-
* data: { exitCode, scope, filter, output }
|
|
69
|
-
* text:
|
|
72
|
+
* data: { ok, exitCode, scope, filter, output }
|
|
73
|
+
* text: gaon test 출력(프로비저닝 + vitest · 사람 UI 그대로)
|
|
70
74
|
*/
|
|
71
75
|
export declare function runTestsTool(args: ToolArgs, cwd: string): Promise<ToolResult>;
|
|
72
76
|
/**
|
package/dist/mcp/tools.js
CHANGED
|
@@ -32,6 +32,7 @@ import { join, resolve as resolvePath } from 'node:path';
|
|
|
32
32
|
import { pathToFileURL } from 'node:url';
|
|
33
33
|
import { registerTsResolve } from '../tsResolve.js';
|
|
34
34
|
import { runDbMigrate } from '../db/migrate.js';
|
|
35
|
+
import { runTestCommand } from '../commands/test.js';
|
|
35
36
|
import { scanSchemaDir, columns } from '@gaonjs/data';
|
|
36
37
|
// ── 유틸 ────────────────────────────────────────────────────
|
|
37
38
|
/** 문자열 옵션 안전 추출. */
|
|
@@ -276,10 +277,14 @@ export async function runMigrationTool(args, cwd) {
|
|
|
276
277
|
}
|
|
277
278
|
// ── 도구 4: run_tests ────────────────────────────────────────
|
|
278
279
|
/**
|
|
279
|
-
* `run_tests` — 프로젝트 테스트를
|
|
280
|
+
* `run_tests` — 프로젝트 테스트를 정본 `gaon test` 하네스로 실행한다(§9).
|
|
280
281
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
282
|
+
* 결정 270: 이전엔 여기서 `vitest run` 을 **직접 spawn** 해 `gaon test`(runTestCommand)의
|
|
283
|
+
* 세 가지 필수 거동을 전부 우회했다 — ① `<db>_test` 프로비저닝(결정 111) ② NATS
|
|
284
|
+
* `GAON_STREAM_PREFIX` 격리(결정 130) ③ 사용자 `test` 스크립트 우선(결정 170). 주석은
|
|
285
|
+
* "같은 경로" 라 주장했으나 거짓이었다. 이제 runTestCommand 에 위임하고, MCP(stdio
|
|
286
|
+
* JSON-RPC) 컨텍스트라 자식·프로비저닝 출력을 `onOutput` 싱크로 모아 도구 응답에
|
|
287
|
+
* 담는다(process.stdout 오염 0 — 트랜스포트 보호).
|
|
283
288
|
*
|
|
284
289
|
* 인자:
|
|
285
290
|
* { scope?: 'unit'|'integration'|'all', filter?: string }
|
|
@@ -287,8 +292,8 @@ export async function runMigrationTool(args, cwd) {
|
|
|
287
292
|
* filter — vitest 위치 인자(파일 패턴 substring)
|
|
288
293
|
*
|
|
289
294
|
* 반환:
|
|
290
|
-
* data: { exitCode, scope, filter, output }
|
|
291
|
-
* text:
|
|
295
|
+
* data: { ok, exitCode, scope, filter, output }
|
|
296
|
+
* text: gaon test 출력(프로비저닝 + vitest · 사람 UI 그대로)
|
|
292
297
|
*/
|
|
293
298
|
export async function runTestsTool(args, cwd) {
|
|
294
299
|
const scope = (stringOpt(args, 'scope') ?? 'all');
|
|
@@ -296,39 +301,17 @@ export async function runTestsTool(args, cwd) {
|
|
|
296
301
|
if (!['unit', 'integration', 'all'].includes(scope)) {
|
|
297
302
|
return errorResult(`scope 는 'unit' | 'integration' | 'all' 중 하나여야 합니다. 입력값: '${scope}'`);
|
|
298
303
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const scopeExtras = scope === 'unit'
|
|
302
|
-
? ['--exclude', '**/*.integration.test.ts']
|
|
303
|
-
: scope === 'integration'
|
|
304
|
-
? ['integration.test']
|
|
305
|
-
: [];
|
|
306
|
-
const passthrough = [...scopeExtras, ...(filter ? [filter] : [])];
|
|
307
|
-
// 실행 경로: 로컬 vitest 바이너리 우선. 없으면 에러 안내.
|
|
308
|
-
const vitestBin = join(resolvePath(cwd), 'node_modules', '.bin', 'vitest');
|
|
309
|
-
if (!existsSync(vitestBin)) {
|
|
310
|
-
return errorResult(`vitest 가 설치돼 있지 않습니다: ${vitestBin}\n` +
|
|
311
|
-
`→ 프로젝트에서 \`pnpm add -D vitest\` 후 다시 시도하세요.`);
|
|
312
|
-
}
|
|
313
|
-
const child = spawn(vitestBin, ['run', ...passthrough], {
|
|
304
|
+
let output = '';
|
|
305
|
+
const exitCode = await runTestCommand(filter ? [filter] : [], {
|
|
314
306
|
cwd,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
child.stdout.on('data', (d) => {
|
|
321
|
-
stdout += d.toString('utf8');
|
|
322
|
-
});
|
|
323
|
-
child.stderr.on('data', (d) => {
|
|
324
|
-
stderr += d.toString('utf8');
|
|
325
|
-
});
|
|
326
|
-
const exitCode = await new Promise((resolveExit) => {
|
|
327
|
-
child.on('close', (code) => resolveExit(code ?? 1));
|
|
307
|
+
scope,
|
|
308
|
+
json: false,
|
|
309
|
+
onOutput: (chunk) => {
|
|
310
|
+
output += chunk;
|
|
311
|
+
},
|
|
328
312
|
});
|
|
329
|
-
const output = stdout + (stderr ? `\n[stderr]\n${stderr}` : '');
|
|
330
313
|
return {
|
|
331
|
-
text: output || `(
|
|
314
|
+
text: output || `(gaon test 출력 없음 · exit ${exitCode})`,
|
|
332
315
|
data: {
|
|
333
316
|
ok: exitCode === 0,
|
|
334
317
|
exitCode,
|
|
@@ -216,7 +216,7 @@ export const posts = table('posts', {
|
|
|
216
216
|
| `having` | `('count', op, val)` · `('sum'\|'avg'\|'min'\|'max', col, op, val)` | `GroupChain` | groupBy 뒤 **집계값** 필터 (그룹 키 필터는 `where`). `.having('count', '>', 2)` · `.having('sum', 'price', '>=', 1000)` |
|
|
217
217
|
| `distinct` | `()` · `(col \| col[])` | `Chain` · `SelectChain` | 인자 없으면 `SELECT DISTINCT` 전체 행(집계·벌크 쓰기 이어짐), 컬럼을 주면 그 컬럼만 뽑는 `SelectChain`. `distinct().count()` 는 `count(distinct id)` |
|
|
218
218
|
| `withCount` | `(...rels)` | `IncludedChain` | 관계별 개수를 **상관 서브쿼리**로 얹는다 — `withCount('comments')` → 각 Rec 에 `commentsCount: bigint`. 조인이 아니라 행이 안 늘어 `limit` 과 함께 써도 개수가 정확. **hasMany·hasOne·belongsToMany 만**(belongsTo 는 항상 0/1 이라 throw). `include` 와 같은 체인에 실린다(`include('author').withCount('comments')`) |
|
|
219
|
-
| `join` | `(table, 'table.col', 'self.col')` | `JoinChain` | INNER JOIN — **필터·정렬 수단**이고 반환은 **자기 테이블의 Rec**(조인 테이블 컬럼은 안 실림 → 뽑아야 하면 §5 `Post.query()`).
|
|
219
|
+
| `join` | `(table, 'table.col', 'self.col')` | `JoinChain` | INNER JOIN — **필터·정렬 수단**이고 반환은 **자기 테이블의 Rec**(조인 테이블 컬럼은 안 실림 → 뽑아야 하면 §5 `Post.query()`). **자기 테이블 컬럼은 한정 없이 그대로** 쓴다 — `t.timestamps()`·`t.id()` 로 양 테이블이 `createdAt`·`id` 를 공유해도 조인 시 자기 테이블로 자동 한정돼 `where('createdAt', ..)` 가 안전하다(ambiguous column 방지). **조인 테이블** 조건만 한정 이름(`where('users.name', '=', ...)`)으로 쓴다. 1:N 부풀림은 `distinct()` 로 접는다. `join`/`leftJoin`·`where`·`orderBy`·`distinct`·`select`·`pluck`·`count`·`exists`·`first`·`all` 이어짐 |
|
|
220
220
|
| `leftJoin` | `(table, 'table.col', 'self.col')` | `JoinChain` | LEFT OUTER JOIN — 짝 없는 자기 행도 남는다. "짝 없는 것만" = `.where('posts.id', 'is null')` |
|
|
221
221
|
|
|
222
222
|
> 조인 노출은 정본 결정 28 게이트 (f)(원안 = 기각·`Post.query()` 로만)를
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaonjs/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "Gaon CLI — 스캐폴딩·제너레이터·마이그레이션·dev/serve/work/hub·doctor·check (bin: gaon)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"typescript": "^5.9.0",
|
|
29
29
|
"vite": "^7.0.0",
|
|
30
30
|
"@gaonjs/async": "0.15.2",
|
|
31
|
-
"@gaonjs/config": "0.17.
|
|
31
|
+
"@gaonjs/config": "0.17.7",
|
|
32
32
|
"@gaonjs/core": "0.2.4",
|
|
33
|
-
"@gaonjs/data": "0.17.
|
|
33
|
+
"@gaonjs/data": "0.17.2",
|
|
34
34
|
"@gaonjs/i18n": "0.2.3",
|
|
35
35
|
"@gaonjs/mail": "0.3.1",
|
|
36
|
-
"@gaonjs/web": "0.20.
|
|
36
|
+
"@gaonjs/web": "0.20.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json && node -e \"require('fs').cpSync('src/templates','dist/templates',{recursive:true})\""
|