@pecot/visual-mcp 1.1.0 → 1.2.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/.claude-plugin/plugin.json +1 -1
- package/assets/slidev/package.json +6 -6
- package/assets/slidev/runtime/package.json +11 -11
- package/assets/slidev/scripts/eslint/_shared/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/slidev-pages-lint/package.json +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/text-constraints/package.json +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/lib/schema-validator.js +1 -1
- package/assets/slidev/scripts/eslint/validate-references/dist/tsconfig.tsbuildinfo +1 -1
- package/assets/slidev/scripts/eslint/validate-references/lib/schema-validator.ts +2 -2
- package/assets/slidev/scripts/eslint/validate-references/package.json +1 -1
- package/cli/dist/cli.js +3 -2
- package/cli/dist/commands/chromium/host-dependencies.js +12 -5
- package/cli/dist/commands/drawio/export.js +14 -11
- package/cli/dist/commands/drawio/theme.js +1 -1
- package/cli/dist/commands/drawio/url.js +27 -19
- package/cli/dist/commands/evidence-xlsx/create.js +11 -10
- package/cli/dist/commands/pptx-ooxml/preview.js +13 -17
- package/cli/dist/commands/slidev-project/create.js +19 -18
- package/cli/dist/commands/slidev-project/lint.js +24 -22
- package/cli/dist/commands/slidev-project/sync.js +25 -24
- package/cli/dist/commands/slidev-project/theme.js +14 -13
- package/cli/dist/commands/slidev-to-pptx/convert.d.ts +4 -0
- package/cli/dist/commands/slidev-to-pptx/convert.js +45 -32
- package/cli/dist/diagnostics.d.ts +38 -0
- package/cli/dist/diagnostics.js +46 -0
- package/cli/dist/domain/_shared/ports.d.ts +0 -1
- package/cli/dist/domain/drawio/url.d.ts +11 -7
- package/cli/dist/domain/drawio/url.js +47 -25
- package/cli/dist/domain/pptx-ooxml/prerender-replace.d.ts +1 -0
- package/cli/dist/domain/pptx-ooxml/prerender-replace.js +3 -3
- package/cli/dist/domain/slidev-project/generated-files.js +3 -3
- package/cli/dist/infra/_shared/runtime-install.d.ts +12 -84
- package/cli/dist/infra/_shared/runtime-install.js +72 -107
- package/cli/dist/infra/slidev-to-pptx/console-logger.d.ts +5 -5
- package/cli/dist/infra/slidev-to-pptx/console-logger.js +19 -20
- package/cli/dist/infra/slidev-to-pptx/dom-converter.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/dom-converter.js +1 -1
- package/cli/dist/infra/slidev-to-pptx/index.js +1 -9
- package/cli/dist/infra/slidev-to-pptx/pipeline.d.ts +1 -1
- package/cli/dist/infra/slidev-to-pptx/pipeline.js +2 -2
- package/cli/dist/infra/slidev-to-pptx/server.d.ts +2 -1
- package/cli/dist/infra/slidev-to-pptx/server.js +2 -2
- package/cli/dist/mcp/serve.js +5 -3
- package/cli/dist/mcp/tools/_shared.js +11 -1
- package/cli/dist/mcp/tools/drawio.js +2 -1
- package/cli/dist/mcp/tools/slide-page.js +3 -1
- package/cli/dist/mcp/tools/slide.js +3 -1
- package/npm-shrinkwrap.json +45 -51
- package/package.json +5 -5
- package/vendor/text-rules/dist/source-hash +1 -1
|
@@ -24,6 +24,7 @@ import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
|
24
24
|
import path from 'node:path';
|
|
25
25
|
import { Command } from 'commander';
|
|
26
26
|
import { collectIconReferences, computeSourceHash, embedSourceHash, forceLightColorScheme, resolveIconsForExport, siblingPath } from '../../domain/drawio/export.js';
|
|
27
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
27
28
|
import { createIconResolver } from '../../infra/drawio/icons.js';
|
|
28
29
|
import { exportPdf } from '../../infra/drawio/pdf.js';
|
|
29
30
|
import { exportViaEmbed } from '../../infra/drawio/screenshot.js';
|
|
@@ -151,7 +152,7 @@ dependencies) {
|
|
|
151
152
|
return { pdfFile: pdfPath, pdfFailed: false };
|
|
152
153
|
}
|
|
153
154
|
catch (error) {
|
|
154
|
-
dependencies.stderr.
|
|
155
|
+
createDiagnostics(dependencies.stderr).warning(`PDF 生成失敗: ${formatError(error)}`);
|
|
155
156
|
// 古い PDF の削除失敗は独立した警告として数えない。今回の PDF 失敗 1 件(pdfFailed /
|
|
156
157
|
// warnings: 1 / exit 3)に集約し、JSON と exit code には出さず stderr の行だけで知らせる。
|
|
157
158
|
// 呼び出し側は `pdf: null` を見て隣の PDF を今回の出力として扱わない前提にする。
|
|
@@ -159,7 +160,7 @@ dependencies) {
|
|
|
159
160
|
await dependencies.removeFile(pdfPath);
|
|
160
161
|
}
|
|
161
162
|
catch (removeError) {
|
|
162
|
-
dependencies.stderr.
|
|
163
|
+
createDiagnostics(dependencies.stderr).warning(`前回の PDF を削除できません: ${pdfPath} (${formatError(removeError)})`);
|
|
163
164
|
}
|
|
164
165
|
return { pdfFile: undefined, pdfFailed: true };
|
|
165
166
|
}
|
|
@@ -259,16 +260,17 @@ export function createDrawioExportCommand(buildDependencies) {
|
|
|
259
260
|
writeErr: (string_) => {
|
|
260
261
|
const dependencies = buildDependencies();
|
|
261
262
|
if (doesArgvWantJson(process.argv)) {
|
|
262
|
-
dependencies.stdout
|
|
263
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
263
264
|
event: 'drawio.export.error',
|
|
264
265
|
reason: 'invalid-option',
|
|
265
266
|
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
266
|
-
})
|
|
267
|
+
}));
|
|
267
268
|
}
|
|
268
269
|
else {
|
|
269
|
-
dependencies.stderr
|
|
270
|
+
passthrough(dependencies.stderr, string_);
|
|
270
271
|
}
|
|
271
272
|
},
|
|
273
|
+
writeOut: (string_) => { writeData(buildDependencies().stdout, string_); },
|
|
272
274
|
})
|
|
273
275
|
.action(async (input, raw) => {
|
|
274
276
|
const dependencies = buildDependencies();
|
|
@@ -290,17 +292,18 @@ export function createDrawioExportCommand(buildDependencies) {
|
|
|
290
292
|
try {
|
|
291
293
|
const execution = await executeDrawioExport(input, options, dependencies);
|
|
292
294
|
if (isJson) {
|
|
293
|
-
dependencies.stdout
|
|
295
|
+
writeData(dependencies.stdout, JSON.stringify(execution.data));
|
|
294
296
|
}
|
|
295
297
|
else if (execution.outputFile === undefined) {
|
|
296
298
|
// 呼び出し側(公開フック)が値をそのまま変数に取れるよう、素の出力は
|
|
297
299
|
// ハッシュ 1 行だけにする。
|
|
298
|
-
dependencies.stdout
|
|
300
|
+
writeData(dependencies.stdout, execution.sourceSha256);
|
|
299
301
|
}
|
|
300
302
|
else {
|
|
301
|
-
|
|
303
|
+
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
304
|
+
diagnostics.done({ verb: 'create', target: execution.outputFile });
|
|
302
305
|
if (execution.pdfFile !== undefined) {
|
|
303
|
-
|
|
306
|
+
diagnostics.done({ verb: 'create', target: execution.pdfFile });
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
309
|
if (execution.exitCode !== 0) {
|
|
@@ -319,10 +322,10 @@ function writeFailure(
|
|
|
319
322
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
320
323
|
dependencies, isJson, reason, detail) {
|
|
321
324
|
if (isJson) {
|
|
322
|
-
dependencies.stdout
|
|
325
|
+
writeData(dependencies.stdout, JSON.stringify({ event: 'drawio.export.error', reason, detail }));
|
|
323
326
|
}
|
|
324
327
|
else {
|
|
325
|
-
dependencies.stderr.
|
|
328
|
+
createDiagnostics(dependencies.stderr).error(detail);
|
|
326
329
|
}
|
|
327
330
|
}
|
|
328
331
|
export function drawioExportDefaultDependencies() {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// - talk-dir: 祖先 D が slides.md を持ち、図が D/public/ の下にあるときだけ。
|
|
8
8
|
// 書体は常に確かめる。5 段のサイズは、talk-dir の中か `--theme` 指定のときだけ確かめる。
|
|
9
9
|
// 移行前の talk-dir(theme-none)は既定値で続ける。解けないテーマ(theme-unlinked・取得や宣言の失敗)は止める。
|
|
10
|
-
// 宣言の欠落や schema の違いの警告は、図の作者には直せない。
|
|
10
|
+
// 宣言の欠落や schema の違いの警告は、図の作者には直せない。note で出し、exit 3 の件数に数えない。
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { isRecord } from '../../domain/_shared/json.js';
|
|
13
13
|
import { THEME_DECLARATION_FILE_NAME, readThemeDeclaration } from '../../domain/slidev-theme/declaration.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// 0 = success (warnings なし)。
|
|
6
6
|
// 1 = RuntimeError (input/output IO failure、文面の違反、文章規則の判定の失敗、解けないテーマ)。
|
|
7
7
|
// 2 = UsageError (invalid option / -o の拡張子が .html でない / テーマの指定の誤り)。
|
|
8
|
-
// 3 = warnings present (validateHtml
|
|
8
|
+
// 3 = warnings present (validateHtml の warning or icon resolver warn が 1 件以上)。
|
|
9
9
|
/* eslint-disable security/detect-non-literal-fs-filename -- input は CLI 引数として受理する想定。信頼境界外だが open API 仕様 */
|
|
10
10
|
import { performance } from 'node:perf_hooks';
|
|
11
11
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
@@ -21,6 +21,7 @@ import { pluginDependencyRoot } from '../../infra/_shared/dependency-root.js';
|
|
|
21
21
|
import { createIconResolver, defaultIconRoot } from '../../infra/drawio/icons.js';
|
|
22
22
|
import { capturePng } from '../../infra/drawio/screenshot.js';
|
|
23
23
|
import { defaultLintText } from '../../infra/text-lint.js';
|
|
24
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
24
25
|
import { DrawioUrlRuntimeError, DrawioUrlUsageError } from './errors.js';
|
|
25
26
|
import { resolveDrawioTheme, themeData, themeFontNames } from './theme.js';
|
|
26
27
|
export { DrawioUrlRuntimeError, DrawioUrlUsageError } from './errors.js';
|
|
@@ -29,6 +30,7 @@ export async function runDrawioUrl(inputFile, options,
|
|
|
29
30
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- write は可変。DI 経由の write は mutate メソッド
|
|
30
31
|
dependencies) {
|
|
31
32
|
const start = dependencies.now();
|
|
33
|
+
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
32
34
|
const absolute = path.resolve(inputFile);
|
|
33
35
|
let xml;
|
|
34
36
|
try {
|
|
@@ -39,12 +41,12 @@ dependencies) {
|
|
|
39
41
|
}
|
|
40
42
|
const trimmed = xml.trim();
|
|
41
43
|
// 書体・文字サイズを確かめる宣言を決める。解けないテーマは、成果物を作る前にここで止める。
|
|
42
|
-
const theme = await resolveDrawioTheme(absolute, options.theme, dependencies, (message) => {
|
|
44
|
+
const theme = await resolveDrawioTheme(absolute, options.theme, dependencies, (message) => { diagnostics.note(message); });
|
|
43
45
|
// 文面の違反があれば、警告の確認や成果物の生成より前に止める
|
|
44
46
|
await assertLabelsClean(trimmed, dependencies.lintText);
|
|
45
47
|
let warningCount = 0;
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
+
// 診断のうち、exit code に反映するのは warning だけ。
|
|
49
|
+
// note (fontColor 二重指定など) は stderr に流すが、exit code には影響させない。
|
|
48
50
|
// 書体は常に確かめる。5 段のサイズは、テーマが決まったとき(talk-dir の中か --theme 指定)だけ確かめる。
|
|
49
51
|
const { fontSizes } = theme;
|
|
50
52
|
const validators = [
|
|
@@ -54,10 +56,14 @@ dependencies) {
|
|
|
54
56
|
...(fontSizes === undefined ? [] : [(value) => validateSlideFontSizes(value, fontSizes)]),
|
|
55
57
|
];
|
|
56
58
|
for (const validate of validators) {
|
|
57
|
-
for (const
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
for (const finding of validate(trimmed)) {
|
|
60
|
+
if (finding.severity === 'warning') {
|
|
61
|
+
diagnostics.warning(finding.message);
|
|
60
62
|
warningCount += 1;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
diagnostics.note(finding.message);
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
// pluginRoot は env 必須の deps のまま据え置く。
|
|
@@ -74,7 +80,7 @@ dependencies) {
|
|
|
74
80
|
if (reportedIconWarnings.has(message))
|
|
75
81
|
return;
|
|
76
82
|
reportedIconWarnings.add(message);
|
|
77
|
-
|
|
83
|
+
diagnostics.warning(message);
|
|
78
84
|
warningCount += 1;
|
|
79
85
|
},
|
|
80
86
|
});
|
|
@@ -126,6 +132,7 @@ dependencies) {
|
|
|
126
132
|
throw new DrawioUrlUsageError(`-o は拡張子 .html のみ受理します (got: ${outputFile})`, 'invalid-output-extension');
|
|
127
133
|
}
|
|
128
134
|
const summary = await runDrawioUrl(inputFile, options, dependencies);
|
|
135
|
+
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
129
136
|
let warningCount = summary.warningCount;
|
|
130
137
|
const artifacts = [];
|
|
131
138
|
let payload;
|
|
@@ -150,7 +157,7 @@ dependencies) {
|
|
|
150
157
|
artifacts.push(pngPath);
|
|
151
158
|
}
|
|
152
159
|
catch (error) {
|
|
153
|
-
|
|
160
|
+
diagnostics.warning(`PNG 生成失敗: ${formatError(error)}`);
|
|
154
161
|
warningCount += 1;
|
|
155
162
|
isPngFailed = true;
|
|
156
163
|
}
|
|
@@ -236,16 +243,17 @@ export function createDrawioUrlCommand(buildDependencies) {
|
|
|
236
243
|
writeErr: (string_) => {
|
|
237
244
|
const dependencies = buildDependencies();
|
|
238
245
|
if (doesArgvWantJson(process.argv)) {
|
|
239
|
-
dependencies.stdout
|
|
246
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
240
247
|
event: 'drawio.url.error',
|
|
241
248
|
reason: 'invalid-option',
|
|
242
249
|
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
243
|
-
})
|
|
250
|
+
}));
|
|
244
251
|
}
|
|
245
252
|
else {
|
|
246
|
-
dependencies.stderr
|
|
253
|
+
passthrough(dependencies.stderr, string_);
|
|
247
254
|
}
|
|
248
255
|
},
|
|
256
|
+
writeOut: (string_) => { writeData(buildDependencies().stdout, string_); },
|
|
249
257
|
})
|
|
250
258
|
.action(async (input, raw) => {
|
|
251
259
|
const dependencies = buildDependencies();
|
|
@@ -261,10 +269,10 @@ export function createDrawioUrlCommand(buildDependencies) {
|
|
|
261
269
|
}
|
|
262
270
|
catch (error) {
|
|
263
271
|
if (raw['json'] === true) {
|
|
264
|
-
dependencies.stdout
|
|
272
|
+
writeData(dependencies.stdout, JSON.stringify(errorData(error)));
|
|
265
273
|
}
|
|
266
274
|
else {
|
|
267
|
-
dependencies.stderr.
|
|
275
|
+
createDiagnostics(dependencies.stderr).error(formatError(error));
|
|
268
276
|
}
|
|
269
277
|
process.exitCode = 2;
|
|
270
278
|
return;
|
|
@@ -272,13 +280,13 @@ export function createDrawioUrlCommand(buildDependencies) {
|
|
|
272
280
|
try {
|
|
273
281
|
const execution = await executeDrawioUrl(input, options, dependencies);
|
|
274
282
|
if (options.json) {
|
|
275
|
-
dependencies.stdout
|
|
283
|
+
writeData(dependencies.stdout, JSON.stringify(execution.data));
|
|
276
284
|
}
|
|
277
285
|
else if (execution.outputFile === undefined) {
|
|
278
|
-
dependencies.stdout
|
|
286
|
+
writeData(dependencies.stdout, execution.url);
|
|
279
287
|
}
|
|
280
288
|
else {
|
|
281
|
-
dependencies.stderr.
|
|
289
|
+
createDiagnostics(dependencies.stderr).done({ verb: 'create', target: execution.outputFile });
|
|
282
290
|
}
|
|
283
291
|
if (execution.exitCode !== 0) {
|
|
284
292
|
process.exitCode = execution.exitCode;
|
|
@@ -286,10 +294,10 @@ export function createDrawioUrlCommand(buildDependencies) {
|
|
|
286
294
|
}
|
|
287
295
|
catch (error) {
|
|
288
296
|
if (options.json) {
|
|
289
|
-
dependencies.stdout
|
|
297
|
+
writeData(dependencies.stdout, JSON.stringify(errorData(error)));
|
|
290
298
|
}
|
|
291
299
|
else {
|
|
292
|
-
dependencies.stderr.
|
|
300
|
+
createDiagnostics(dependencies.stderr).error(formatError(error));
|
|
293
301
|
}
|
|
294
302
|
process.exitCode = toExitCode(error);
|
|
295
303
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { readFile } from 'node:fs/promises';
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { Command } from 'commander';
|
|
15
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
15
16
|
import { collectTextViolations, formatTextViolations } from '../../domain/_shared/text-check.js';
|
|
16
17
|
import { parseEvidenceSpec } from '../../domain/evidence-xlsx/spec-schema.js';
|
|
17
18
|
import { specTexts } from '../../domain/evidence-xlsx/spec-text.js';
|
|
@@ -112,14 +113,14 @@ export function createEvidenceCreateCommand(buildDependencies) {
|
|
|
112
113
|
writeErr: (string_) => {
|
|
113
114
|
const dependencies = buildDependencies();
|
|
114
115
|
if (doesArgvWantJson(process.argv)) {
|
|
115
|
-
dependencies.stdout
|
|
116
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
116
117
|
event: ERROR_EVENT,
|
|
117
118
|
reason: 'invalid-option',
|
|
118
119
|
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
119
|
-
})
|
|
120
|
+
}));
|
|
120
121
|
}
|
|
121
122
|
else {
|
|
122
|
-
dependencies.stderr
|
|
123
|
+
passthrough(dependencies.stderr, string_);
|
|
123
124
|
}
|
|
124
125
|
},
|
|
125
126
|
})
|
|
@@ -132,7 +133,7 @@ export function createEvidenceCreateCommand(buildDependencies) {
|
|
|
132
133
|
out: optionString(raw['out'], DEFAULT_OUT),
|
|
133
134
|
}, dependencies);
|
|
134
135
|
if (isJson) {
|
|
135
|
-
dependencies.stdout
|
|
136
|
+
writeData(dependencies.stdout, JSON.stringify(data));
|
|
136
137
|
}
|
|
137
138
|
else {
|
|
138
139
|
writeHumanSummary(dependencies.stdout, data);
|
|
@@ -140,10 +141,10 @@ export function createEvidenceCreateCommand(buildDependencies) {
|
|
|
140
141
|
}
|
|
141
142
|
catch (error) {
|
|
142
143
|
if (isJson) {
|
|
143
|
-
dependencies.stdout
|
|
144
|
+
writeData(dependencies.stdout, JSON.stringify(errorData(error)));
|
|
144
145
|
}
|
|
145
146
|
else {
|
|
146
|
-
dependencies.stderr.
|
|
147
|
+
createDiagnostics(dependencies.stderr).error(`evidence create: ${formatError(error)}`);
|
|
147
148
|
}
|
|
148
149
|
process.exitCode = EVIDENCE_CREATE_FAILURE_EXIT_CODE;
|
|
149
150
|
}
|
|
@@ -164,14 +165,14 @@ export function evidenceCreateDefaultDependencies() {
|
|
|
164
165
|
function writeHumanSummary(
|
|
165
166
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- write は mutate メソッド
|
|
166
167
|
stdout, data) {
|
|
167
|
-
stdout
|
|
168
|
-
stdout
|
|
168
|
+
writeData(stdout, `生成しました: ${data.outPath}`);
|
|
169
|
+
writeData(stdout, `項目数: ${data.items.toString()} / 注記数: ${data.annotations.toString()}`);
|
|
169
170
|
if (data.skipped.length === 0) {
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
|
-
stdout
|
|
173
|
+
writeData(stdout, `除外: ${data.skipped.length.toString()} 件`);
|
|
173
174
|
for (const entry of data.skipped) {
|
|
174
|
-
stdout
|
|
175
|
+
writeData(stdout, ` - ${entry.path} (${entry.reason})`);
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
/**
|
|
@@ -17,6 +17,7 @@ import path from 'node:path';
|
|
|
17
17
|
import { Readable } from 'node:stream';
|
|
18
18
|
import { Command } from 'commander';
|
|
19
19
|
import { applyPreviewNormalization, detectPreviewDivergence, } from '../../domain/pptx-ooxml/preview-normalize.js';
|
|
20
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
20
21
|
import { XmldomXmlEngine } from '../../infra/pptx-ooxml/xml-engine.js';
|
|
21
22
|
import { YauzlYazlPptxArchive } from '../../infra/pptx-ooxml/archive.js';
|
|
22
23
|
import { SofficePdfConverter, SofficeSpawnError, SofficeTimeoutError, } from '../../infra/pptx-ooxml/soffice.js';
|
|
@@ -332,14 +333,14 @@ export function createPptxPreviewCommand(buildDependencies) {
|
|
|
332
333
|
writeErr: (string_) => {
|
|
333
334
|
const dependencies = buildDependencies();
|
|
334
335
|
if (doesArgvWantJson(process.argv)) {
|
|
335
|
-
dependencies.stdout
|
|
336
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
336
337
|
event: 'pptx.preview.error',
|
|
337
338
|
reason: 'invalid-option',
|
|
338
339
|
detail: string_.replace(/^error:\s*/i, '').trim(),
|
|
339
|
-
})
|
|
340
|
+
}));
|
|
340
341
|
}
|
|
341
342
|
else {
|
|
342
|
-
dependencies.stderr
|
|
343
|
+
passthrough(dependencies.stderr, string_);
|
|
343
344
|
}
|
|
344
345
|
},
|
|
345
346
|
})
|
|
@@ -358,14 +359,14 @@ export function createPptxPreviewCommand(buildDependencies) {
|
|
|
358
359
|
catch (error) {
|
|
359
360
|
const detail = formatError(error);
|
|
360
361
|
if (isJson) {
|
|
361
|
-
dependencies.stdout
|
|
362
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
362
363
|
event: 'pptx.preview.error',
|
|
363
364
|
reason: errorToReason(error),
|
|
364
365
|
detail,
|
|
365
|
-
})
|
|
366
|
+
}));
|
|
366
367
|
}
|
|
367
368
|
else {
|
|
368
|
-
dependencies.stderr.
|
|
369
|
+
createDiagnostics(dependencies.stderr).error(`pptx preview: ${detail}`);
|
|
369
370
|
}
|
|
370
371
|
process.exitCode = PPTX_PREVIEW_FAILURE_EXIT_CODE;
|
|
371
372
|
}
|
|
@@ -377,21 +378,16 @@ function emitSuccess(
|
|
|
377
378
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
378
379
|
dependencies, isJson, data) {
|
|
379
380
|
if (isJson) {
|
|
380
|
-
dependencies.stdout
|
|
381
|
+
writeData(dependencies.stdout, JSON.stringify(data));
|
|
381
382
|
return;
|
|
382
383
|
}
|
|
383
384
|
for (const finding of data.findings) {
|
|
384
|
-
dependencies.stdout
|
|
385
|
-
}
|
|
386
|
-
if (data.detectOnly) {
|
|
387
|
-
dependencies.stdout.write(`pptx preview (detect-only): ${data.input}`
|
|
388
|
-
+ ` (${String(data.findings.length)} findings)\n`);
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
dependencies.stdout.write(`pptx preview: ${data.input} -> ${data.output ?? ''}`
|
|
392
|
-
+ ` (${String(data.findings.length)} findings,`
|
|
393
|
-
+ ` ${String(data.normalized)} normalized)\n`);
|
|
385
|
+
writeData(dependencies.stdout, formatFindingLine(finding));
|
|
394
386
|
}
|
|
387
|
+
writeData(dependencies.stdout, data.detectOnly
|
|
388
|
+
? `pptx preview (detect-only): ${data.input} (${String(data.findings.length)} findings)`
|
|
389
|
+
: `pptx preview: ${data.input} -> ${data.output ?? ''}`
|
|
390
|
+
+ ` (${String(data.findings.length)} findings, ${String(data.normalized)} normalized)`);
|
|
395
391
|
}
|
|
396
392
|
export function pptxPreviewDefaultDependencies() {
|
|
397
393
|
return {
|
|
@@ -10,6 +10,7 @@ import { performance } from 'node:perf_hooks';
|
|
|
10
10
|
import { mkdir, rename, rm, writeFile } from 'node:fs/promises';
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { Command } from 'commander';
|
|
13
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
13
14
|
import { SlideCreateRuntimeError, SlideCreateUsageError } from '../../domain/slidev-project/errors.js';
|
|
14
15
|
import { buildInitialPages, nameToTitle } from '../../domain/slidev-project/initial-pages.js';
|
|
15
16
|
import { talkPackageJsonSource } from '../../domain/slidev-project/package-json.js';
|
|
@@ -44,7 +45,7 @@ dependencies) {
|
|
|
44
45
|
catch (error) {
|
|
45
46
|
// 成功したときの警告は executeSlideCreate が流す。失敗したときは、ここで流さないと捨てられる。
|
|
46
47
|
for (const warning of warnings)
|
|
47
|
-
dependencies.stderr.
|
|
48
|
+
createDiagnostics(dependencies.stderr).warning(warning);
|
|
48
49
|
throw error;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -136,7 +137,7 @@ export async function executeSlideCreate(projectDirectory, options,
|
|
|
136
137
|
dependencies, onCreated) {
|
|
137
138
|
const { catalog, warnings, ...summary } = await runSlideCreate(projectDirectory, options, dependencies);
|
|
138
139
|
for (const warning of warnings)
|
|
139
|
-
dependencies.stderr.
|
|
140
|
+
createDiagnostics(dependencies.stderr).warning(warning);
|
|
140
141
|
if (options.emitCatalog)
|
|
141
142
|
emitLayoutCatalog(catalog, dependencies.stdout);
|
|
142
143
|
onCreated?.(summary);
|
|
@@ -166,20 +167,20 @@ export function emitLayoutCatalog(catalog,
|
|
|
166
167
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
167
168
|
stdout) {
|
|
168
169
|
const { categories, layouts } = catalog;
|
|
169
|
-
stdout
|
|
170
|
-
stdout
|
|
171
|
-
stdout
|
|
170
|
+
writeData(stdout, '='.repeat(60));
|
|
171
|
+
writeData(stdout, 'Layout Catalog (Step 2 のプランモード前に必ず読み切ること)');
|
|
172
|
+
writeData(stdout, `${'='.repeat(60)}\n\n`);
|
|
172
173
|
for (const category of categories) {
|
|
173
|
-
stdout
|
|
174
|
+
writeData(stdout, `--- ${category.label}: ${category.question} ---\n\n`);
|
|
174
175
|
const members = layouts.filter(entry => entry.category === category.id);
|
|
175
176
|
if (members.length === 0) {
|
|
176
|
-
stdout
|
|
177
|
+
writeData(stdout, '(該当レイアウトなし)\n\n');
|
|
177
178
|
continue;
|
|
178
179
|
}
|
|
179
180
|
for (const { layout, description, deprecated } of members) {
|
|
180
|
-
stdout
|
|
181
|
+
writeData(stdout, `- ${deprecated ? '[deprecated] ' : ''}${layout}: ${description}`);
|
|
181
182
|
}
|
|
182
|
-
stdout
|
|
183
|
+
writeData(stdout, '');
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
/* c8 ignore start -- 非 Error 例外 (string throw 等) は本実装範囲では未発生、防御網のみ */
|
|
@@ -218,14 +219,14 @@ export function createSlideCreateCommand(buildDependencies) {
|
|
|
218
219
|
writeErr: (string_) => {
|
|
219
220
|
const dependencies = buildDependencies();
|
|
220
221
|
if (doesArgvWantJson(process.argv)) {
|
|
221
|
-
dependencies.stdout
|
|
222
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
222
223
|
event: 'slide.create.error',
|
|
223
224
|
reason: 'invalid-option',
|
|
224
225
|
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
225
|
-
})
|
|
226
|
+
}));
|
|
226
227
|
}
|
|
227
228
|
else {
|
|
228
|
-
dependencies.stderr
|
|
229
|
+
passthrough(dependencies.stderr, string_);
|
|
229
230
|
}
|
|
230
231
|
},
|
|
231
232
|
})
|
|
@@ -241,11 +242,11 @@ export function createSlideCreateCommand(buildDependencies) {
|
|
|
241
242
|
const execution = await executeSlideCreate(projectDirectory, options, dependencies, (summary) => {
|
|
242
243
|
if (isWantsJson)
|
|
243
244
|
return;
|
|
244
|
-
dependencies.stdout
|
|
245
|
-
dependencies.stdout
|
|
245
|
+
writeData(dependencies.stdout, `slide create: 成功 (${summary.projectDirectory})`);
|
|
246
|
+
writeData(dependencies.stdout, ` theme=${summary.theme.name}, ${String(Math.round(summary.durationMs))}ms`);
|
|
246
247
|
});
|
|
247
248
|
if (isWantsJson) {
|
|
248
|
-
dependencies.stdout
|
|
249
|
+
writeData(dependencies.stdout, JSON.stringify(execution.data));
|
|
249
250
|
}
|
|
250
251
|
else {
|
|
251
252
|
writeAutoDeckLintReport(execution.lint, execution.summary.projectDirectory, dependencies);
|
|
@@ -255,14 +256,14 @@ export function createSlideCreateCommand(buildDependencies) {
|
|
|
255
256
|
const reason = errorToReason(error);
|
|
256
257
|
const detail = formatError(error);
|
|
257
258
|
if (isWantsJson) {
|
|
258
|
-
dependencies.stdout
|
|
259
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
259
260
|
event: 'slide.create.error',
|
|
260
261
|
reason,
|
|
261
262
|
detail,
|
|
262
|
-
})
|
|
263
|
+
}));
|
|
263
264
|
}
|
|
264
265
|
else {
|
|
265
|
-
dependencies.stderr.
|
|
266
|
+
createDiagnostics(dependencies.stderr).error(`slide create 失敗: ${detail}`);
|
|
266
267
|
}
|
|
267
268
|
process.exitCode = toExitCode(error);
|
|
268
269
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// 対象は `runAutoDeckLint` と `writeAutoDeckLintReport`。
|
|
11
11
|
import path from 'node:path';
|
|
12
12
|
import { Command } from 'commander';
|
|
13
|
+
import { createDiagnostics, passthrough, writeData } from '../../diagnostics.js';
|
|
13
14
|
import { SlideLintRuntimeError, SlideLintUsageError, runSlideLint, } from '../../domain/slidev-project/lint.js';
|
|
14
15
|
import { SlideCreateRuntimeError, SlideCreateUsageError, } from '../../domain/slidev-project/errors.js';
|
|
15
16
|
import { themeErrorReason } from '../../domain/slidev-theme/error-reason.js';
|
|
@@ -39,14 +40,14 @@ export function createSlideLintCommand(buildDependencies) {
|
|
|
39
40
|
writeErr: (string_) => {
|
|
40
41
|
const dependencies = buildDependencies();
|
|
41
42
|
if (doesArgvWantJson(process.argv)) {
|
|
42
|
-
dependencies.stdout
|
|
43
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
43
44
|
event: 'slide.lint.error',
|
|
44
45
|
reason: 'invalid-option',
|
|
45
46
|
detail: string_.replace(/^error:[ \t]*/i, '').trim(),
|
|
46
|
-
})
|
|
47
|
+
}));
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
|
-
dependencies.stderr
|
|
50
|
+
passthrough(dependencies.stderr, string_);
|
|
50
51
|
}
|
|
51
52
|
},
|
|
52
53
|
})
|
|
@@ -57,13 +58,13 @@ export function createSlideLintCommand(buildDependencies) {
|
|
|
57
58
|
try {
|
|
58
59
|
const { summary, data } = await executeSlideLint(options, dependencies);
|
|
59
60
|
if (isWantsJson) {
|
|
60
|
-
dependencies.stdout
|
|
61
|
+
writeData(dependencies.stdout, JSON.stringify(data));
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
64
|
// 件数行を読まずに成否が分かるよう見出し行に結果を載せる(no-target は exit 0 側)。
|
|
64
65
|
const outcomeLabel = summary.outcome === 'violations' ? '違反あり' : '成功';
|
|
65
|
-
dependencies.stdout
|
|
66
|
-
writeSummaryLines(summary, dependencies
|
|
66
|
+
writeData(dependencies.stdout, `slide lint: ${outcomeLabel} (${summary.directory})`);
|
|
67
|
+
writeSummaryLines(summary, dependencies);
|
|
67
68
|
}
|
|
68
69
|
if (summary.outcome === 'violations') {
|
|
69
70
|
process.exitCode = 1;
|
|
@@ -73,14 +74,14 @@ export function createSlideLintCommand(buildDependencies) {
|
|
|
73
74
|
const reason = errorToReason(error);
|
|
74
75
|
const detail = formatError(error);
|
|
75
76
|
if (isWantsJson) {
|
|
76
|
-
dependencies.stdout
|
|
77
|
+
writeData(dependencies.stdout, JSON.stringify({
|
|
77
78
|
event: 'slide.lint.error',
|
|
78
79
|
reason,
|
|
79
80
|
detail,
|
|
80
|
-
})
|
|
81
|
+
}));
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
|
-
dependencies.stderr.
|
|
84
|
+
createDiagnostics(dependencies.stderr).error(`slide lint 失敗: ${detail}`);
|
|
84
85
|
}
|
|
85
86
|
process.exitCode = toExitCode(error);
|
|
86
87
|
}
|
|
@@ -131,23 +132,24 @@ dependencies) {
|
|
|
131
132
|
同じ体裁にするため共有する。
|
|
132
133
|
*/
|
|
133
134
|
function writeSummaryLines(summary,
|
|
134
|
-
//
|
|
135
|
+
// DI 経由の write は mutate メソッド。
|
|
135
136
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
136
|
-
|
|
137
|
+
dependencies) {
|
|
137
138
|
// 走査抜けの警告は lint 対象 0 件でも出す必要があるため no-target の早期 return より前に置く。
|
|
139
|
+
const diagnostics = createDiagnostics(dependencies.stderr);
|
|
138
140
|
for (const skipped of summary.skippedSymlinkDirectories) {
|
|
139
|
-
|
|
140
|
-
+ '(配下は lint
|
|
141
|
+
diagnostics.warning(`${skipped} は symlink のため eslint の走査対象になりません`
|
|
142
|
+
+ '(配下は lint されていない可能性があります)');
|
|
141
143
|
}
|
|
142
144
|
if (summary.outcome === 'no-target') {
|
|
143
|
-
stdout
|
|
145
|
+
writeData(dependencies.stdout, ` lint 対象 0 件(pages/**/*.md と slides.md が見つかりません)`);
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
|
-
stdout
|
|
147
|
-
+ ` / 警告 ${String(summary.warningCount)}
|
|
148
|
+
writeData(dependencies.stdout, ` lint 対象 ${String(summary.lintedFileCount)} 件 / エラー ${String(summary.errorCount)} 件`
|
|
149
|
+
+ ` / 警告 ${String(summary.warningCount)} 件`);
|
|
148
150
|
for (const violation of summary.violations) {
|
|
149
|
-
stdout
|
|
150
|
-
+ ` ${violation.rule} ${violation.message}
|
|
151
|
+
writeData(dependencies.stdout, ` ${violation.file}:${String(violation.line)}:${String(violation.column)}`
|
|
152
|
+
+ ` ${violation.rule} ${violation.message}`);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
/**
|
|
@@ -177,13 +179,13 @@ export function writeAutoDeckLintReport(report, talkDirectory,
|
|
|
177
179
|
dependencies) {
|
|
178
180
|
const { summary } = report;
|
|
179
181
|
if (summary === undefined) {
|
|
180
|
-
dependencies.stderr.
|
|
182
|
+
createDiagnostics(dependencies.stderr).warning(`deck lint をスキップしました: ${report.failure ?? ''}`);
|
|
181
183
|
return;
|
|
182
184
|
}
|
|
183
|
-
dependencies.stdout
|
|
184
|
-
writeSummaryLines(summary, dependencies
|
|
185
|
+
writeData(dependencies.stdout, 'deck lint:');
|
|
186
|
+
writeSummaryLines(summary, dependencies);
|
|
185
187
|
if (summary.outcome === 'violations') {
|
|
186
|
-
dependencies.stdout
|
|
188
|
+
writeData(dependencies.stdout, ` 上記の違反はこのコマンドの成否には影響しません。修正後 pecotv slide lint --dir ${talkDirectory} で再確認してください。`);
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
191
|
/**
|