tazuna 0.15.0 → 0.17.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/README.md +16 -13
- package/dist/cli.js +0 -0
- package/dist/commands/apply.js +9 -3
- package/dist/commands/build.js +1 -1
- package/dist/commands/pack-io.js +18 -4
- package/dist/commands/pack.js +37 -13
- package/dist/commands/vbproj-register.js +39 -27
- package/dist/core/applier.js +42 -8
- package/dist/core/encoding.js +2 -2
- package/dist/core/new-file-style.js +9 -5
- package/dist/core/report.js +26 -0
- package/dist/core/sjis.js +34 -0
- package/dist/core/vbproj.js +22 -6
- package/dist/infra/vbproj.js +19 -11
- package/dist/pack/assets/procedure.js +113 -15
- package/dist/pack/initConfig.js +4 -4
- package/dist/pack/initProject.js +11 -11
- package/dist/pack/logicalTreeBuilder.js +1 -1
- package/dist/pack/procedureFile.js +5 -0
- package/dist/pack/projectLanguage.js +67 -0
- package/dist/pack/services/designerSummary.js +270 -2
- package/dist/pack/services/environmentSummary.js +297 -0
- package/dist/pack/services/repomixExporter.js +42 -14
- package/dist/pack/slnParser.js +12 -8
- package/dist/pack/slnmixConfig.js +5 -5
- package/dist/pack/targetResolver.js +17 -13
- package/dist/pack/types.js +0 -5
- package/dist/pack/vbprojParser.js +172 -15
- package/package.json +8 -7
|
@@ -23,10 +23,12 @@ import { TOOL_NAME } from "../../brand.js";
|
|
|
23
23
|
import { CONFIG_FILE_NAME } from "../slnmixConfig.js";
|
|
24
24
|
import { isBinaryExtension } from "./binaryExtensions.js";
|
|
25
25
|
import { summarizeContractSchema } from "./contractSummary.js";
|
|
26
|
+
import { renderEnvironmentBlock } from "./environmentSummary.js";
|
|
26
27
|
import { decodeShiftJis } from "../../core/encoding.js";
|
|
27
28
|
import { maskCredentials } from "../../core/mask.js";
|
|
28
29
|
import { sourceLanguageOf } from "../../core/source-lexer.js";
|
|
29
|
-
import { parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
|
|
30
|
+
import { formatDesignerEvents, parseDesignerCs, parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
|
|
31
|
+
import { LANGUAGES, designerLanguageOf, projectFilesLabel } from "../projectLanguage.js";
|
|
30
32
|
import { collectExtraRoots, collectGitFiles, GIT_FILE_MAX_BYTES, GIT_FILES_KIND, } from "./extraRootsCollector.js";
|
|
31
33
|
/**
|
|
32
34
|
* ソースファイルのバイト列を文字列へデコードする。
|
|
@@ -135,7 +137,7 @@ function escapeAttribute(value) {
|
|
|
135
137
|
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
136
138
|
}
|
|
137
139
|
/**
|
|
138
|
-
* 除外した *.Designer.vb から <ui_summary> エントリを生成する。
|
|
140
|
+
* 除外した *.Designer.vb / *.Designer.cs から <ui_summary> エントリを生成する。
|
|
139
141
|
* 対象外・読めない・コントロールが取れない場合は undefined
|
|
140
142
|
* (呼び出し側は通常のスキップ扱いにする)。
|
|
141
143
|
* maskEnabled 時は要約前の Designer ソースにマスクを適用する
|
|
@@ -143,10 +145,12 @@ function escapeAttribute(value) {
|
|
|
143
145
|
*/
|
|
144
146
|
function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
|
|
145
147
|
const item = node.item;
|
|
148
|
+
const fileName = item.logicalPath.split("\\").pop() ?? item.logicalPath;
|
|
149
|
+
const language = designerLanguageOf(fileName);
|
|
146
150
|
if (!item.isSensitive ||
|
|
147
151
|
item.sourcePath === undefined ||
|
|
148
152
|
!item.exists ||
|
|
149
|
-
|
|
153
|
+
language === undefined) {
|
|
150
154
|
return undefined;
|
|
151
155
|
}
|
|
152
156
|
if (deps.ignoreReasonFor?.(item.sourcePath) !== undefined) {
|
|
@@ -158,26 +162,30 @@ function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
|
|
|
158
162
|
}
|
|
159
163
|
let findings = [];
|
|
160
164
|
if (maskEnabled) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
strict: strictMask
|
|
164
|
-
|
|
165
|
+
// C# の Designer.cs はパックの .cs と同じく、文字列・コメントの中だけを伏せる
|
|
166
|
+
const masked = language === "vb"
|
|
167
|
+
? maskCredentials(source, { vbSource: true, strict: strictMask })
|
|
168
|
+
: maskCredentials(source, { vbSource: false, language: sourceLanguageOf(fileName), strict: strictMask });
|
|
165
169
|
source = masked.content;
|
|
166
170
|
findings = masked.findings;
|
|
167
171
|
}
|
|
168
|
-
const summary = parseDesignerVb(source);
|
|
172
|
+
const summary = language === "vb" ? parseDesignerVb(source) : parseDesignerCs(source);
|
|
169
173
|
if (summary.controlCount === 0) {
|
|
170
174
|
return undefined;
|
|
171
175
|
}
|
|
172
|
-
const
|
|
173
|
-
const formName = summary.className ?? fileName.replace(/\.designer\.vb$/i, "");
|
|
176
|
+
const formName = summary.className ?? fileName.slice(0, fileName.length - LANGUAGES[language].designerSuffix.length);
|
|
174
177
|
const lines = [
|
|
175
178
|
`<ui_summary path="${escapeAttribute(displayPath)}" form="${escapeAttribute(formName)}">`,
|
|
176
|
-
|
|
179
|
+
language === "vb"
|
|
180
|
+
? "Designer 自動生成コードからの要約(コントロール名: 型 — Text。座標・サイズ等のレイアウトは省略):"
|
|
181
|
+
: "Designer 自動生成コードからの要約(コントロール名: 型 — Text — イベント イベント名 → ハンドラー。座標・サイズ等のレイアウトは省略):",
|
|
177
182
|
];
|
|
178
183
|
if (summary.formText !== undefined) {
|
|
179
184
|
lines.push(`フォームタイトル: "${summary.formText}"`);
|
|
180
185
|
}
|
|
186
|
+
if (summary.formEvents !== undefined && summary.formEvents.length > 0) {
|
|
187
|
+
lines.push(`フォームのイベント: ${formatDesignerEvents(summary.formEvents)}`);
|
|
188
|
+
}
|
|
181
189
|
lines.push(...renderDesignerControlLines(summary.rootControls));
|
|
182
190
|
lines.push("</ui_summary>");
|
|
183
191
|
return { entry: lines.join("\n"), findings };
|
|
@@ -547,15 +555,33 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
547
555
|
const sdkExpandedLabels = sources
|
|
548
556
|
.filter((source) => source.parseResult.defaultCompileGlobExpanded)
|
|
549
557
|
.map((source) => source.label);
|
|
558
|
+
// 既定の Compile グロブ(**/*.vb、C# は **/*.cs)。VB だけなら C# 対応の前と同じ表記
|
|
559
|
+
const sdkExpandedGlobs = [
|
|
560
|
+
...new Set(sources
|
|
561
|
+
.filter((source) => source.parseResult.defaultCompileGlobExpanded)
|
|
562
|
+
.map((source) => LANGUAGES[source.parseResult.language].defaultCompileGlob)),
|
|
563
|
+
];
|
|
564
|
+
const projectLanguages = sources.map((source) => source.parseResult.language);
|
|
565
|
+
const projectFiles = projectFilesLabel(projectLanguages);
|
|
550
566
|
const rootName = rootDir === undefined ? undefined : path.basename(rootDir);
|
|
551
567
|
const generic = options.layout === "generic";
|
|
552
568
|
const configFileName = options.configFileName ?? CONFIG_FILE_NAME;
|
|
569
|
+
const environmentBlock = generic
|
|
570
|
+
? undefined
|
|
571
|
+
: renderEnvironmentBlock(sources.map((source) => ({
|
|
572
|
+
label: source.label,
|
|
573
|
+
projectPath: (rootDir === undefined ? undefined : relativeWithinRoot(rootDir, source.parseResult.projectPath)) ??
|
|
574
|
+
path.basename(source.parseResult.projectPath),
|
|
575
|
+
language: source.parseResult.language,
|
|
576
|
+
style: source.parseResult.projectStyle,
|
|
577
|
+
environment: source.parseResult.environment,
|
|
578
|
+
})));
|
|
553
579
|
const content = [
|
|
554
580
|
generic && gitFiles !== undefined
|
|
555
581
|
? `このファイルは ${TOOL_NAME} が「${title}」の git が管理しているファイル(git ls-files)に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
|
|
556
582
|
: generic
|
|
557
583
|
? `このファイルは ${TOOL_NAME} が「${title}」の ${configFileName}(extraRoots)に宣言されたディレクトリに基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
|
|
558
|
-
: `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln /
|
|
584
|
+
: `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln / ${projectFiles})に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`,
|
|
559
585
|
"",
|
|
560
586
|
"<file_summary>",
|
|
561
587
|
"<purpose>",
|
|
@@ -616,7 +642,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
616
642
|
: "- .gitignore は考慮していない(設定 exportRespectGitignore で無効化されている)",
|
|
617
643
|
...(sdkExpandedLabels.length > 0
|
|
618
644
|
? [
|
|
619
|
-
`- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(
|
|
645
|
+
`- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(${sdkExpandedGlobs.join(" / ")})を展開した(bin/ obj/ ドットフォルダ・*.user・<Compile Remove> は除外)。MSBuild の完全評価ではない`,
|
|
620
646
|
]
|
|
621
647
|
: []),
|
|
622
648
|
...(extra !== undefined && gitFiles !== undefined
|
|
@@ -628,7 +654,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
628
654
|
? [
|
|
629
655
|
generic
|
|
630
656
|
? `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${configFileName} の extraRoots に宣言されたディレクトリ(<file> の root 属性)。宣言されていないディレクトリは含まれない`
|
|
631
|
-
: `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは
|
|
657
|
+
: `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${projectFiles} に乗らない追加ディレクトリ(${configFileName} の extraRoots。<file> の root 属性)。認証情報マスクは ${projectLanguages.includes("cs") ? "プロジェクトのファイル" : "VB 側"}と同様に適用済み`,
|
|
632
658
|
]
|
|
633
659
|
: []),
|
|
634
660
|
...(generatedDirs.length > 0
|
|
@@ -643,6 +669,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
643
669
|
"</notes>",
|
|
644
670
|
"</file_summary>",
|
|
645
671
|
"",
|
|
672
|
+
...(environmentBlock === undefined ? [] : [environmentBlock, ""]),
|
|
646
673
|
"<directory_structure>",
|
|
647
674
|
treeLines.join("\n"),
|
|
648
675
|
"</directory_structure>",
|
|
@@ -672,5 +699,6 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
672
699
|
contractSummaryIncluded: contractPlaced,
|
|
673
700
|
diagnostics,
|
|
674
701
|
filePaths,
|
|
702
|
+
environmentBlock,
|
|
675
703
|
};
|
|
676
704
|
}
|
package/dist/pack/slnParser.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* .sln の最小解析(引き継ぎ仕様書 §18)。
|
|
3
3
|
*
|
|
4
4
|
* Project("{TYPE-GUID}") = "名前", "相対パス", "{GUID}" 行の抽出のみを行い、
|
|
5
|
-
* 対象は .vbproj に限定する。Solution Folder・他言語プロジェクトは
|
|
5
|
+
* 対象は .vbproj と .csproj(.csproj は tazuna 0.17.0〜)に限定する。Solution Folder・他言語プロジェクトは
|
|
6
6
|
* スキップして診断に残す。Global セクション等は読まない。
|
|
7
7
|
* vscode モジュールに依存しない純粋関数(単体テスト対象)。
|
|
8
8
|
*/
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { resolveWindowsPath } from "./paths.js";
|
|
11
|
+
import { PROJECT_FILE, projectFilesLabel, projectLanguageOf } from "./projectLanguage.js";
|
|
11
12
|
/** Solution Folder のプロジェクト種別 GUID(大文字で比較) */
|
|
12
13
|
const SOLUTION_FOLDER_TYPE_GUID = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
|
|
13
14
|
/**
|
|
@@ -43,10 +44,11 @@ export function parseSln(content, solutionPath, deps) {
|
|
|
43
44
|
});
|
|
44
45
|
continue;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
const language = projectLanguageOf(relativePath);
|
|
48
|
+
if (language === undefined) {
|
|
47
49
|
diagnostics.push({
|
|
48
50
|
severity: "info",
|
|
49
|
-
message: `.vbproj 以外のプロジェクトはスキップしました: "${name}"(${relativePath})`,
|
|
51
|
+
message: `.vbproj / .csproj 以外のプロジェクトはスキップしました: "${name}"(${relativePath})`,
|
|
50
52
|
});
|
|
51
53
|
continue;
|
|
52
54
|
}
|
|
@@ -57,20 +59,21 @@ export function parseSln(content, solutionPath, deps) {
|
|
|
57
59
|
absolutePath,
|
|
58
60
|
projectGuid,
|
|
59
61
|
projectTypeGuid,
|
|
62
|
+
language,
|
|
60
63
|
exists: deps.fileExists(absolutePath),
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
if (projects.length === 0) {
|
|
64
67
|
diagnostics.push({
|
|
65
68
|
severity: "warning",
|
|
66
|
-
message: "この .sln に VB
|
|
69
|
+
message: "この .sln に VB / C# のプロジェクト(.vbproj / .csproj)の定義が見つかりませんでした",
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
appendUnreferencedSiblingWarnings(solutionDir, projects, diagnostics, deps);
|
|
70
73
|
return { solutionPath, solutionDir, projects, diagnostics };
|
|
71
74
|
}
|
|
72
75
|
/**
|
|
73
|
-
* .sln と同じフォルダにあるのに .sln から参照されていない .vbproj を警告する。
|
|
76
|
+
* .sln と同じフォルダにあるのに .sln から参照されていない .vbproj / .csproj を警告する。
|
|
74
77
|
* プロジェクトの作り直しや VCS の部分コミットで .sln だけが古い場合、
|
|
75
78
|
* その .vbproj が解析・エクスポート対象から漏れていることに気付けるようにする。
|
|
76
79
|
*/
|
|
@@ -82,14 +85,15 @@ function appendUnreferencedSiblingWarnings(solutionDir, projects, diagnostics, d
|
|
|
82
85
|
// Windows 前提のため大文字小文字は区別しない
|
|
83
86
|
const referenced = new Set(projects.map((project) => project.absolutePath.toLowerCase()));
|
|
84
87
|
const unreferenced = names
|
|
85
|
-
.filter((name) =>
|
|
88
|
+
.filter((name) => PROJECT_FILE.test(name))
|
|
86
89
|
.filter((name) => !referenced.has(resolveWindowsPath(name, solutionDir).toLowerCase()))
|
|
87
90
|
.sort((a, b) => a.localeCompare(b));
|
|
88
91
|
for (const name of unreferenced) {
|
|
92
|
+
const label = projectFilesLabel([projectLanguageOf(name)]);
|
|
89
93
|
diagnostics.push({
|
|
90
94
|
severity: "warning",
|
|
91
|
-
message: `同じフォルダに .sln から参照されていない
|
|
92
|
-
|
|
95
|
+
message: `同じフォルダに .sln から参照されていない ${label} があります: ${name}` +
|
|
96
|
+
`(.sln が古いか別プロジェクトの可能性があります。こちらを対象にする場合は ${label} を直接指定してください)`,
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -55,8 +55,8 @@ export function describeConfigConflict(directory) {
|
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* プロジェクトの構成の種類。
|
|
58
|
-
* - "solution": .sln / .vbproj の論理構成に基づく(既定。従来どおり)
|
|
59
|
-
* - "generic": .sln / .vbproj を使わず、extraRoots に宣言されたディレクトリだけで
|
|
58
|
+
* - "solution": .sln / .vbproj / .csproj の論理構成に基づく(既定。従来どおり)
|
|
59
|
+
* - "generic": .sln / .vbproj / .csproj を使わず、extraRoots に宣言されたディレクトリだけで
|
|
60
60
|
* パックする(VB.NET 以外のプロジェクト向け。v0.17.0〜)。引数なしの `tazuna pack`
|
|
61
61
|
* がこの設定を見て .sln の探索を省く。明示フラグにしたのは「.sln を探さなかった」
|
|
62
62
|
* 理由をログで示すため(決定ログ 2026-10-10)
|
|
@@ -257,8 +257,8 @@ function parseKind(value, fileName, diagnostics) {
|
|
|
257
257
|
});
|
|
258
258
|
return "solution";
|
|
259
259
|
}
|
|
260
|
-
const TARGET_EXTENSION = /\.(sln|vbproj)$/i;
|
|
261
|
-
/** `target`: ルート配下の相対パスで .sln / .vbproj を指す。それ以外は警告して無視 */
|
|
260
|
+
const TARGET_EXTENSION = /\.(sln|vbproj|csproj)$/i;
|
|
261
|
+
/** `target`: ルート配下の相対パスで .sln / .vbproj / .csproj を指す。それ以外は警告して無視 */
|
|
262
262
|
function parseTarget(value, fileName, diagnostics) {
|
|
263
263
|
if (value === undefined) {
|
|
264
264
|
return undefined;
|
|
@@ -282,7 +282,7 @@ function parseTarget(value, fileName, diagnostics) {
|
|
|
282
282
|
if (!TARGET_EXTENSION.test(normalized)) {
|
|
283
283
|
diagnostics.push({
|
|
284
284
|
severity: "warning",
|
|
285
|
-
message: `${fileName}: target は .sln / .vbproj を指定してください: ${text}(無視します)`,
|
|
285
|
+
message: `${fileName}: target は .sln / .vbproj / .csproj を指定してください: ${text}(無視します)`,
|
|
286
286
|
});
|
|
287
287
|
return undefined;
|
|
288
288
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 入力(.sln / .vbproj / ディレクトリ / 省略)から対象ファイルを決める。
|
|
2
|
+
* 入力(.sln / .vbproj / .csproj / ディレクトリ / 省略)から対象ファイルを決める。
|
|
3
3
|
*
|
|
4
|
-
* - ファイル指定: 拡張子が .sln / .vbproj ならそのまま採用
|
|
4
|
+
* - ファイル指定: 拡張子が .sln / .vbproj / .csproj ならそのまま採用
|
|
5
5
|
* - ディレクトリ指定・省略(カレント): 直下の *.sln を探し、1 件ならそれを
|
|
6
|
-
* 採用。0 件なら *.vbproj
|
|
6
|
+
* 採用。0 件なら *.vbproj と *.csproj を合わせて同じことを行う(.sln 優先)
|
|
7
7
|
* - 複数見つかった場合は候補を並べてエラー(勝手に選ばない)
|
|
8
8
|
* - ディレクトリ指定・省略で、その場所の slnmix.config.json が kind: "generic" なら
|
|
9
|
-
* .sln / .vbproj を探さず「generic 構成」を返す(
|
|
9
|
+
* .sln / .vbproj / .csproj を探さず「generic 構成」を返す(.sln の無いプロジェクト。
|
|
10
10
|
* v0.17.0〜)。ファイルを明示したときは従来どおりそのファイルを採用する
|
|
11
11
|
*
|
|
12
12
|
* ファイルシステムは deps 注入とし、単体テスト可能に保つ(CLI 固有機能の
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import * as path from "node:path";
|
|
16
16
|
import { INIT_COMMAND } from "../brand.js";
|
|
17
|
+
import { PROJECT_FILE, TARGET_FILE, projectFilesLabel, projectLanguageOf } from "./projectLanguage.js";
|
|
17
18
|
import { CONFIG_FILE_NAME, configFileNameIn } from "./slnmixConfig.js";
|
|
18
|
-
const TARGET_EXTENSION =
|
|
19
|
+
const TARGET_EXTENSION = TARGET_FILE;
|
|
19
20
|
/**
|
|
20
21
|
* @param input CLI の位置引数(省略時 undefined)
|
|
21
22
|
* @param cwd 実行時のカレントディレクトリ(省略時の探索基準)
|
|
@@ -34,7 +35,7 @@ export function resolveTarget(input, cwd, deps) {
|
|
|
34
35
|
}
|
|
35
36
|
return {
|
|
36
37
|
kind: "error",
|
|
37
|
-
message: `対応していない入力です(.sln / .vbproj のみ): ${absolutePath}`,
|
|
38
|
+
message: `対応していない入力です(.sln / .vbproj / .csproj のみ): ${absolutePath}`,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
return {
|
|
@@ -43,7 +44,7 @@ export function resolveTarget(input, cwd, deps) {
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
function detectInDirectory(directory, displayName, deps) {
|
|
46
|
-
// kind: "generic"(
|
|
47
|
+
// kind: "generic"(.sln の無いプロジェクト)なら .sln / .vbproj / .csproj を探さない。
|
|
47
48
|
// 設定を置いた人だけが変わる明示の形(設定の無い既存プロジェクトの挙動は不変)
|
|
48
49
|
if (deps.isGenericConfig?.(directory) === true) {
|
|
49
50
|
return { kind: "generic", rootDir: directory };
|
|
@@ -62,7 +63,7 @@ function detectInDirectory(directory, displayName, deps) {
|
|
|
62
63
|
if (!TARGET_EXTENSION.test(absolutePath)) {
|
|
63
64
|
return {
|
|
64
65
|
kind: "error",
|
|
65
|
-
message: `${configFileNameIn(directory, deps.isFile)} の target は .sln / .vbproj を指定してください: ${configured}`,
|
|
66
|
+
message: `${configFileNameIn(directory, deps.isFile)} の target は .sln / .vbproj / .csproj を指定してください: ${configured}`,
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
return { kind: "file", path: absolutePath, autoDetected: true, source: "config" };
|
|
@@ -74,11 +75,14 @@ function detectInDirectory(directory, displayName, deps) {
|
|
|
74
75
|
message: `ディレクトリを読み取れません: ${directory}`,
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
// .sln 優先、なければ .vbproj(ソリューションがあればそちらが全体を表すため)
|
|
78
|
-
for (const
|
|
78
|
+
// .sln 優先、なければ .vbproj / .csproj(ソリューションがあればそちらが全体を表すため)
|
|
79
|
+
for (const pattern of [/\.sln$/i, PROJECT_FILE]) {
|
|
79
80
|
const candidates = names
|
|
80
|
-
.filter((name) =>
|
|
81
|
+
.filter((name) => pattern.test(name))
|
|
81
82
|
.sort((a, b) => a.localeCompare(b));
|
|
83
|
+
const extension = pattern === PROJECT_FILE
|
|
84
|
+
? projectFilesLabel(candidates.map((name) => projectLanguageOf(name)))
|
|
85
|
+
: ".sln";
|
|
82
86
|
if (candidates.length === 1) {
|
|
83
87
|
return {
|
|
84
88
|
kind: "file",
|
|
@@ -99,8 +103,8 @@ function detectInDirectory(directory, displayName, deps) {
|
|
|
99
103
|
return {
|
|
100
104
|
kind: "error",
|
|
101
105
|
message: [
|
|
102
|
-
`${displayName} に .sln / .vbproj が見つかりません: ${directory}`,
|
|
103
|
-
`初めてなら npx ${INIT_COMMAND} でセットアップしてください(
|
|
106
|
+
`${displayName} に .sln / .vbproj / .csproj が見つかりません: ${directory}`,
|
|
107
|
+
`初めてなら npx ${INIT_COMMAND} でセットアップしてください(.sln の無いプロジェクトは ${CONFIG_FILE_NAME} の kind: "generic" で動きます)。`,
|
|
104
108
|
].join("\n"),
|
|
105
109
|
};
|
|
106
110
|
}
|
package/dist/pack/types.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* .vbproj の静的 XML 解析(旧スタイル / SDK スタイル)。
|
|
2
|
+
* .vbproj / .csproj の静的 XML 解析(旧スタイル / SDK スタイル)。
|
|
3
|
+
* 形式は言語によらず同じ。言語(拡張子で決める。projectLanguage.ts)で変わるのは、SDK スタイルの
|
|
4
|
+
* 既定の Compile グロブ・言語ごとのプロパティ(VB の Option、C# の Nullable / ImplicitUsings)・
|
|
5
|
+
* プロジェクト全体の名前空間の取り込み(VB の <Import>、C# の <Using>)だけ。
|
|
3
6
|
*
|
|
4
7
|
* MSBuild 評価は行わない。$()/@()/%()・Condition は展開せず、status として
|
|
5
8
|
* 保持するだけに留める。旧スタイルの Include に書かれたワイルドカードも
|
|
6
9
|
* 未解決(wildcard)のまま。
|
|
7
10
|
*
|
|
8
11
|
* 例外は SDK スタイル(`<Project Sdk="...">`)の既定 Compile グロブ
|
|
9
|
-
* (`**\/*.vb`)で、これは Compile を書かない前提の形式のため展開しないと
|
|
12
|
+
* (`**\/*.vb`、C# は `**\/*.cs`)で、これは Compile を書かない前提の形式のため展開しないと
|
|
10
13
|
* 何も出せない。展開したことは診断(info)と結果の
|
|
11
14
|
* defaultCompileGlobExpanded に明記し、出力側で「MSBuild の完全評価では
|
|
12
15
|
* ない」と宣言する。`Remove` / `Update` / `DefaultItemExcludes` の
|
|
@@ -17,9 +20,8 @@
|
|
|
17
20
|
import * as path from "node:path";
|
|
18
21
|
import { globToRegExp, normalizeGlobPath } from "./globMatcher.js";
|
|
19
22
|
import { resolveWindowsPath } from "./paths.js";
|
|
23
|
+
import { LANGUAGES, projectLanguageOf } from "./projectLanguage.js";
|
|
20
24
|
import { parseXml } from "./xmlReader.js";
|
|
21
|
-
/** SDK スタイルの既定 Compile グロブ(Microsoft.NET.Sdk の既定) */
|
|
22
|
-
const DEFAULT_COMPILE_GLOB = "**/*.vb";
|
|
23
25
|
/**
|
|
24
26
|
* SDK の既定除外(Microsoft.NET.Sdk.DefaultItems.props 相当のうち .vb に関係
|
|
25
27
|
* するもの)。bin / obj は BaseOutputPath / BaseIntermediateOutputPath の
|
|
@@ -43,7 +45,7 @@ const SENSITIVE_FLAG_METADATA = ["AutoGen", "DesignTime", "DesignTimeSharedInput
|
|
|
43
45
|
/** 存在するだけで Designer 関連とみなすメタデータ */
|
|
44
46
|
const SENSITIVE_PRESENCE_METADATA = ["Generator", "LastGenOutput"];
|
|
45
47
|
/** 拡張子による Designer 関連判定(小文字で比較) */
|
|
46
|
-
const SENSITIVE_SUFFIXES = [".designer.vb", ".resx", ".settings"];
|
|
48
|
+
const SENSITIVE_SUFFIXES = [".designer.vb", ".designer.cs", ".resx", ".settings"];
|
|
47
49
|
function isRecord(value) {
|
|
48
50
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49
51
|
}
|
|
@@ -315,11 +317,162 @@ function readSdkProperties(project, diagnostics) {
|
|
|
315
317
|
}
|
|
316
318
|
return result;
|
|
317
319
|
}
|
|
320
|
+
/** <environment> に載せるプロパティ(要素名は大文字小文字を区別しない) */
|
|
321
|
+
const ENVIRONMENT_PROPERTIES = {
|
|
322
|
+
targetframeworkversion: "targetFrameworks",
|
|
323
|
+
targetframework: "targetFrameworks",
|
|
324
|
+
targetframeworks: "targetFrameworks",
|
|
325
|
+
langversion: "langVersions",
|
|
326
|
+
optionstrict: "optionStrict",
|
|
327
|
+
optionexplicit: "optionExplicit",
|
|
328
|
+
optioninfer: "optionInfer",
|
|
329
|
+
optioncompare: "optionCompare",
|
|
330
|
+
nullable: "nullable",
|
|
331
|
+
implicitusings: "implicitUsings",
|
|
332
|
+
rootnamespace: "rootNamespaces",
|
|
333
|
+
};
|
|
334
|
+
/** C# の <Using Include="X" Static="true" /> / <Using Include="X" Alias="A" /> を表示用に整える */
|
|
335
|
+
function describeUsing(entry) {
|
|
336
|
+
if (!isRecord(entry)) {
|
|
337
|
+
return undefined;
|
|
338
|
+
}
|
|
339
|
+
const include = asString(entry["@_Include"])?.trim();
|
|
340
|
+
if (include === undefined || include === "") {
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
const alias = childOrAttribute(entry, "Alias");
|
|
344
|
+
if (alias !== undefined) {
|
|
345
|
+
return `${alias} = ${include}`;
|
|
346
|
+
}
|
|
347
|
+
return childOrAttribute(entry, "Static")?.toLowerCase() === "true" ? `static ${include}` : include;
|
|
348
|
+
}
|
|
349
|
+
/** 子要素か属性の値(PackageReference の Version は両方の書き方がある) */
|
|
350
|
+
function childOrAttribute(entry, name) {
|
|
351
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
352
|
+
const bare = key.startsWith("@_") ? key.slice(2) : key;
|
|
353
|
+
if (!equalsIgnoreCase(bare, name)) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
const text = asString(value) ?? (isRecord(value) ? asString(value["#text"]) : undefined);
|
|
357
|
+
if (text !== undefined && text.trim() !== "") {
|
|
358
|
+
return text.trim();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
/** 参照 1 件を表示用に整える(厳密名のうち名前と版だけを残す。HintPath は載せない) */
|
|
364
|
+
function describeReference(tag, entry) {
|
|
365
|
+
const record = isRecord(entry) ? entry : undefined;
|
|
366
|
+
const include = (record === undefined ? undefined : asString(record["@_Include"]))?.trim();
|
|
367
|
+
if (include === undefined || include === "") {
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
if (equalsIgnoreCase(tag, "Reference")) {
|
|
371
|
+
const [name, ...parts] = include.split(",").map((part) => part.trim());
|
|
372
|
+
const version = parts.find((part) => /^version\s*=/i.test(part))?.replace(/^version\s*=\s*/i, "");
|
|
373
|
+
return version === undefined || version === "" ? name : `${name} ${version}`;
|
|
374
|
+
}
|
|
375
|
+
if (equalsIgnoreCase(tag, "ProjectReference")) {
|
|
376
|
+
const name = (record === undefined ? undefined : childOrAttribute(record, "Name")) ??
|
|
377
|
+
include.split(/[\\/]/).pop()?.replace(/\.[^.]+$/, "") ??
|
|
378
|
+
include;
|
|
379
|
+
return `${name}(プロジェクト参照)`;
|
|
380
|
+
}
|
|
381
|
+
if (equalsIgnoreCase(tag, "PackageReference")) {
|
|
382
|
+
const version = record === undefined ? undefined : childOrAttribute(record, "Version");
|
|
383
|
+
return version === undefined ? `${include}(NuGet)` : `${include} ${version}(NuGet)`;
|
|
384
|
+
}
|
|
385
|
+
return `${include}(COM)`;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* ビルド環境を読む(手順文 v10 の <environment>)。言語の版・Option・参照など、AI が使える構文と API を
|
|
389
|
+
* 決めるのに要る値だけ。Condition は評価せず、値が分かれていれば出現順にすべて残す
|
|
390
|
+
*/
|
|
391
|
+
function readEnvironment(project, language) {
|
|
392
|
+
const environment = {
|
|
393
|
+
toolsVersion: asString(project["@_ToolsVersion"])?.trim() || undefined,
|
|
394
|
+
targetFrameworks: [],
|
|
395
|
+
langVersions: [],
|
|
396
|
+
optionStrict: [],
|
|
397
|
+
optionExplicit: [],
|
|
398
|
+
optionInfer: [],
|
|
399
|
+
optionCompare: [],
|
|
400
|
+
nullable: [],
|
|
401
|
+
implicitUsings: [],
|
|
402
|
+
rootNamespaces: [],
|
|
403
|
+
imports: [],
|
|
404
|
+
references: [],
|
|
405
|
+
};
|
|
406
|
+
const push = (list, value) => {
|
|
407
|
+
if (!list.some((existing) => equalsIgnoreCase(existing, value))) {
|
|
408
|
+
list.push(value);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
for (const group of toArray(project["PropertyGroup"])) {
|
|
412
|
+
if (!isRecord(group)) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
for (const [tag, value] of Object.entries(group)) {
|
|
416
|
+
const key = ENVIRONMENT_PROPERTIES[tag.toLowerCase()];
|
|
417
|
+
if (key === undefined) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
for (const element of toArray(value)) {
|
|
421
|
+
const text = asString(element) ?? (isRecord(element) ? asString(element["#text"]) : undefined);
|
|
422
|
+
if (text === undefined) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
const values = key === "targetFrameworks" ? text.split(";") : [text];
|
|
426
|
+
for (const raw of values) {
|
|
427
|
+
if (raw.trim() !== "") {
|
|
428
|
+
push(environment[key], raw.trim());
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
for (const group of toArray(project["ItemGroup"])) {
|
|
435
|
+
if (!isRecord(group)) {
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
for (const [tag, value] of Object.entries(group)) {
|
|
439
|
+
if (language === "vb" && equalsIgnoreCase(tag, "Import")) {
|
|
440
|
+
for (const entry of toArray(value)) {
|
|
441
|
+
const include = isRecord(entry) ? asString(entry["@_Include"])?.trim() : undefined;
|
|
442
|
+
if (include !== undefined && include !== "") {
|
|
443
|
+
push(environment.imports, include);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
if (language === "cs" && equalsIgnoreCase(tag, "Using")) {
|
|
449
|
+
for (const entry of toArray(value)) {
|
|
450
|
+
const described = describeUsing(entry);
|
|
451
|
+
// <Using Remove="..."> は暗黙の using を外す指定。一覧には載せない
|
|
452
|
+
if (described !== undefined) {
|
|
453
|
+
push(environment.imports, described);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (!["Reference", "ProjectReference", "PackageReference", "COMReference"].some((kind) => equalsIgnoreCase(kind, tag))) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
for (const entry of toArray(value)) {
|
|
462
|
+
const described = describeReference(tag, entry);
|
|
463
|
+
if (described !== undefined) {
|
|
464
|
+
push(environment.references, described);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return environment;
|
|
470
|
+
}
|
|
318
471
|
/**
|
|
319
|
-
* SDK スタイルの既定 Compile グロブ(`**\/*.vb`)を展開し、既存の項目と
|
|
472
|
+
* SDK スタイルの既定 Compile グロブ(`**\/*.vb`、C# は `**\/*.cs`)を展開し、既存の項目と
|
|
320
473
|
* 重複しないものを resolved の ProjectItem として返す。
|
|
321
474
|
*/
|
|
322
|
-
function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, extraExcludes, deps, diagnostics) {
|
|
475
|
+
function expandDefaultCompileGlob(language, projectDir, existingItems, removePatterns, extraExcludes, deps, diagnostics) {
|
|
323
476
|
if (deps.listFilesRecursive === undefined) {
|
|
324
477
|
diagnostics.push({
|
|
325
478
|
severity: "warning",
|
|
@@ -335,7 +488,8 @@ function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, ext
|
|
|
335
488
|
});
|
|
336
489
|
return undefined;
|
|
337
490
|
}
|
|
338
|
-
const
|
|
491
|
+
const defaultCompileGlob = LANGUAGES[language].defaultCompileGlob;
|
|
492
|
+
const includeRegExp = globToRegExp(defaultCompileGlob);
|
|
339
493
|
const excludeRegExps = [
|
|
340
494
|
...DEFAULT_ITEM_EXCLUDES,
|
|
341
495
|
...extraExcludes,
|
|
@@ -381,7 +535,7 @@ function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, ext
|
|
|
381
535
|
}
|
|
382
536
|
diagnostics.push({
|
|
383
537
|
severity: "info",
|
|
384
|
-
message: `SDK スタイルのため既定の Compile グロブ(${
|
|
538
|
+
message: `SDK スタイルのため既定の Compile グロブ(${defaultCompileGlob})を展開しました: ${expanded.length} 件(${details.join("、")})。MSBuild の完全評価ではありません`,
|
|
385
539
|
});
|
|
386
540
|
return expanded;
|
|
387
541
|
}
|
|
@@ -421,25 +575,27 @@ function applyUpdates(items, updates, diagnostics) {
|
|
|
421
575
|
}
|
|
422
576
|
}
|
|
423
577
|
/**
|
|
424
|
-
* .vbproj の XML 文字列を解析し、正規化した ProjectItem 配列と診断を返す。
|
|
578
|
+
* .vbproj / .csproj の XML 文字列を解析し、正規化した ProjectItem 配列と診断を返す。
|
|
425
579
|
*
|
|
426
|
-
* @param xmlContent .vbproj の内容(BOM 付き可)
|
|
427
|
-
* @param projectPath .vbproj の絶対パス(
|
|
580
|
+
* @param xmlContent .vbproj / .csproj の内容(BOM 付き可)
|
|
581
|
+
* @param projectPath .vbproj / .csproj の絶対パス(相対パス解決の基準に使用。拡張子で言語を決める)
|
|
428
582
|
* @param deps ファイルシステム依存の注入
|
|
429
583
|
*/
|
|
430
584
|
export function parseVbproj(xmlContent, projectPath, deps) {
|
|
431
585
|
const projectDir = path.dirname(projectPath);
|
|
586
|
+
const language = projectLanguageOf(projectPath) ?? "vb";
|
|
432
587
|
const diagnostics = [];
|
|
433
588
|
const items = [];
|
|
434
589
|
const result = {
|
|
435
590
|
projectPath,
|
|
591
|
+
language,
|
|
436
592
|
projectDir,
|
|
437
593
|
projectStyle: "legacy",
|
|
438
594
|
defaultCompileGlobExpanded: false,
|
|
439
595
|
items,
|
|
440
596
|
diagnostics,
|
|
441
597
|
};
|
|
442
|
-
// BOM 除去(VS が保存する .vbproj は UTF-8 BOM 付きが多い)
|
|
598
|
+
// BOM 除去(VS が保存する .vbproj / .csproj は UTF-8 BOM 付きが多い)
|
|
443
599
|
const xml = xmlContent.replace(/^\uFEFF/, "");
|
|
444
600
|
const read = parseXml(xml);
|
|
445
601
|
if (!read.ok) {
|
|
@@ -458,10 +614,11 @@ export function parseVbproj(xmlContent, projectPath, deps) {
|
|
|
458
614
|
if (!isRecord(project)) {
|
|
459
615
|
diagnostics.push({
|
|
460
616
|
severity: "error",
|
|
461
|
-
message:
|
|
617
|
+
message: `<Project> 要素が見つかりません(${LANGUAGES[language].projectExtension} ではない可能性があります)`,
|
|
462
618
|
});
|
|
463
619
|
return result;
|
|
464
620
|
}
|
|
621
|
+
result.environment = readEnvironment(project, language);
|
|
465
622
|
const toolsVersion = asString(project["@_ToolsVersion"]);
|
|
466
623
|
if (toolsVersion !== undefined) {
|
|
467
624
|
diagnostics.push({ severity: "info", message: `ToolsVersion: ${toolsVersion}` });
|
|
@@ -550,7 +707,7 @@ export function parseVbproj(xmlContent, projectPath, deps) {
|
|
|
550
707
|
});
|
|
551
708
|
}
|
|
552
709
|
else {
|
|
553
|
-
const expanded = expandDefaultCompileGlob(projectDir, items, removePatterns, properties.defaultItemExcludes, deps, diagnostics);
|
|
710
|
+
const expanded = expandDefaultCompileGlob(language, projectDir, items, removePatterns, properties.defaultItemExcludes, deps, diagnostics);
|
|
554
711
|
if (expanded !== undefined) {
|
|
555
712
|
items.push(...expanded);
|
|
556
713
|
result.defaultCompileGlobExpanded = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tazuna",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Build with AI chat, without handing over the reins: pack your codebase for the chat, then verify and apply its patches locally (zero dependencies; formerly petari and slnmix)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -37,17 +37,18 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=20.19.0"
|
|
39
39
|
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/node": "^24.3.0",
|
|
42
|
-
"typescript": "^5.9.2",
|
|
43
|
-
"vitest": "^3.2.4"
|
|
44
|
-
},
|
|
45
40
|
"scripts": {
|
|
46
41
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
47
42
|
"typecheck": "tsc --noEmit",
|
|
48
43
|
"test": "vitest run",
|
|
49
44
|
"test:watch": "vitest",
|
|
50
45
|
"dev": "node src/cli.ts",
|
|
46
|
+
"prepublishOnly": "pnpm typecheck && pnpm test && pnpm build",
|
|
51
47
|
"gen:sjis": "node scripts/generate-sjis-table.ts"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^24.3.0",
|
|
51
|
+
"typescript": "^5.9.2",
|
|
52
|
+
"vitest": "^3.2.4"
|
|
52
53
|
}
|
|
53
|
-
}
|
|
54
|
+
}
|