tazuna 0.16.0 → 0.18.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 +17 -13
- package/dist/commands/apply.js +9 -3
- package/dist/commands/build.js +1 -1
- package/dist/commands/init.js +6 -2
- package/dist/commands/pack-io.js +125 -4
- package/dist/commands/pack.js +71 -39
- 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 +80 -7
- package/dist/pack/handoff.js +10 -0
- package/dist/pack/includePlanner.js +610 -0
- package/dist/pack/initConfig.js +131 -12
- package/dist/pack/initProject.js +51 -22
- package/dist/pack/logicalTreeBuilder.js +1 -1
- package/dist/pack/procedureFile.js +1 -0
- package/dist/pack/projectLanguage.js +67 -0
- package/dist/pack/services/designerSummary.js +270 -2
- package/dist/pack/services/environmentSummary.js +146 -3
- package/dist/pack/services/extraRootsCollector.js +46 -2
- package/dist/pack/services/repomixExporter.js +66 -18
- package/dist/pack/slnParser.js +12 -8
- package/dist/pack/slnmixConfig.js +49 -6
- package/dist/pack/targetResolver.js +17 -13
- package/dist/pack/types.js +0 -5
- package/dist/pack/vbprojParser.js +52 -18
- package/package.json +1 -1
|
@@ -27,7 +27,8 @@ import { renderEnvironmentBlock } from "./environmentSummary.js";
|
|
|
27
27
|
import { decodeShiftJis } from "../../core/encoding.js";
|
|
28
28
|
import { maskCredentials } from "../../core/mask.js";
|
|
29
29
|
import { sourceLanguageOf } from "../../core/source-lexer.js";
|
|
30
|
-
import { parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
|
|
30
|
+
import { formatDesignerEvents, parseDesignerCs, parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
|
|
31
|
+
import { LANGUAGES, designerLanguageOf, projectFilesLabel } from "../projectLanguage.js";
|
|
31
32
|
import { collectExtraRoots, collectGitFiles, GIT_FILE_MAX_BYTES, GIT_FILES_KIND, } from "./extraRootsCollector.js";
|
|
32
33
|
/**
|
|
33
34
|
* ソースファイルのバイト列を文字列へデコードする。
|
|
@@ -136,7 +137,7 @@ function escapeAttribute(value) {
|
|
|
136
137
|
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
137
138
|
}
|
|
138
139
|
/**
|
|
139
|
-
* 除外した *.Designer.vb から <ui_summary> エントリを生成する。
|
|
140
|
+
* 除外した *.Designer.vb / *.Designer.cs から <ui_summary> エントリを生成する。
|
|
140
141
|
* 対象外・読めない・コントロールが取れない場合は undefined
|
|
141
142
|
* (呼び出し側は通常のスキップ扱いにする)。
|
|
142
143
|
* maskEnabled 時は要約前の Designer ソースにマスクを適用する
|
|
@@ -144,10 +145,12 @@ function escapeAttribute(value) {
|
|
|
144
145
|
*/
|
|
145
146
|
function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
|
|
146
147
|
const item = node.item;
|
|
148
|
+
const fileName = item.logicalPath.split("\\").pop() ?? item.logicalPath;
|
|
149
|
+
const language = designerLanguageOf(fileName);
|
|
147
150
|
if (!item.isSensitive ||
|
|
148
151
|
item.sourcePath === undefined ||
|
|
149
152
|
!item.exists ||
|
|
150
|
-
|
|
153
|
+
language === undefined) {
|
|
151
154
|
return undefined;
|
|
152
155
|
}
|
|
153
156
|
if (deps.ignoreReasonFor?.(item.sourcePath) !== undefined) {
|
|
@@ -159,26 +162,30 @@ function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
|
|
|
159
162
|
}
|
|
160
163
|
let findings = [];
|
|
161
164
|
if (maskEnabled) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
strict: strictMask
|
|
165
|
-
|
|
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 });
|
|
166
169
|
source = masked.content;
|
|
167
170
|
findings = masked.findings;
|
|
168
171
|
}
|
|
169
|
-
const summary = parseDesignerVb(source);
|
|
172
|
+
const summary = language === "vb" ? parseDesignerVb(source) : parseDesignerCs(source);
|
|
170
173
|
if (summary.controlCount === 0) {
|
|
171
174
|
return undefined;
|
|
172
175
|
}
|
|
173
|
-
const
|
|
174
|
-
const formName = summary.className ?? fileName.replace(/\.designer\.vb$/i, "");
|
|
176
|
+
const formName = summary.className ?? fileName.slice(0, fileName.length - LANGUAGES[language].designerSuffix.length);
|
|
175
177
|
const lines = [
|
|
176
178
|
`<ui_summary path="${escapeAttribute(displayPath)}" form="${escapeAttribute(formName)}">`,
|
|
177
|
-
|
|
179
|
+
language === "vb"
|
|
180
|
+
? "Designer 自動生成コードからの要約(コントロール名: 型 — Text。座標・サイズ等のレイアウトは省略):"
|
|
181
|
+
: "Designer 自動生成コードからの要約(コントロール名: 型 — Text — イベント イベント名 → ハンドラー。座標・サイズ等のレイアウトは省略):",
|
|
178
182
|
];
|
|
179
183
|
if (summary.formText !== undefined) {
|
|
180
184
|
lines.push(`フォームタイトル: "${summary.formText}"`);
|
|
181
185
|
}
|
|
186
|
+
if (summary.formEvents !== undefined && summary.formEvents.length > 0) {
|
|
187
|
+
lines.push(`フォームのイベント: ${formatDesignerEvents(summary.formEvents)}`);
|
|
188
|
+
}
|
|
182
189
|
lines.push(...renderDesignerControlLines(summary.rootControls));
|
|
183
190
|
lines.push("</ui_summary>");
|
|
184
191
|
return { entry: lines.join("\n"), findings };
|
|
@@ -240,6 +247,18 @@ function describePath(source, node, rootDir) {
|
|
|
240
247
|
treeNote: ` → ${physical}`,
|
|
241
248
|
};
|
|
242
249
|
}
|
|
250
|
+
/** 「.csv 2 件 / .ipynb 1 件」(先頭 5 種類 + 残りの種類の数) */
|
|
251
|
+
function formatLabelCounts(entries) {
|
|
252
|
+
const shown = entries.slice(0, 5).map((entry) => `${entry.label} ${entry.count} 件`);
|
|
253
|
+
const rest = entries.length - shown.length;
|
|
254
|
+
return [...shown, ...(rest > 0 ? [`ほか ${rest} 種類`] : [])].join(" / ");
|
|
255
|
+
}
|
|
256
|
+
/** グロブの一覧(先頭 5 件 + 残りの数) */
|
|
257
|
+
function formatPatterns(patterns) {
|
|
258
|
+
const shown = patterns.slice(0, 5);
|
|
259
|
+
const rest = patterns.length - shown.length;
|
|
260
|
+
return [...shown, ...(rest > 0 ? [`ほか ${rest} 件`] : [])].join(" / ");
|
|
261
|
+
}
|
|
243
262
|
/** relativePosix が generatedDirs のいずれかの配下なら、そのディレクトリを返す */
|
|
244
263
|
function generatedDirOf(relativePosix, generatedDirs) {
|
|
245
264
|
if (relativePosix === undefined) {
|
|
@@ -436,7 +455,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
436
455
|
fileSize: deps.fileSize,
|
|
437
456
|
ignoreReasonFor: deps.ignoreReasonFor,
|
|
438
457
|
shownElsewhere: options.gitFilesShownElsewhere,
|
|
439
|
-
});
|
|
458
|
+
}, { include: options.gitInclude, exclude: options.gitExclude });
|
|
440
459
|
diagnostics.push(...extra.diagnostics);
|
|
441
460
|
skipped.push(...extra.skipped.map((s) => ({ path: s.relativePath, reason: s.reason })));
|
|
442
461
|
}
|
|
@@ -548,6 +567,14 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
548
567
|
const sdkExpandedLabels = sources
|
|
549
568
|
.filter((source) => source.parseResult.defaultCompileGlobExpanded)
|
|
550
569
|
.map((source) => source.label);
|
|
570
|
+
// 既定の Compile グロブ(**/*.vb、C# は **/*.cs)。VB だけなら C# 対応の前と同じ表記
|
|
571
|
+
const sdkExpandedGlobs = [
|
|
572
|
+
...new Set(sources
|
|
573
|
+
.filter((source) => source.parseResult.defaultCompileGlobExpanded)
|
|
574
|
+
.map((source) => LANGUAGES[source.parseResult.language].defaultCompileGlob)),
|
|
575
|
+
];
|
|
576
|
+
const projectLanguages = sources.map((source) => source.parseResult.language);
|
|
577
|
+
const projectFiles = projectFilesLabel(projectLanguages);
|
|
551
578
|
const rootName = rootDir === undefined ? undefined : path.basename(rootDir);
|
|
552
579
|
const generic = options.layout === "generic";
|
|
553
580
|
const configFileName = options.configFileName ?? CONFIG_FILE_NAME;
|
|
@@ -557,6 +584,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
557
584
|
label: source.label,
|
|
558
585
|
projectPath: (rootDir === undefined ? undefined : relativeWithinRoot(rootDir, source.parseResult.projectPath)) ??
|
|
559
586
|
path.basename(source.parseResult.projectPath),
|
|
587
|
+
language: source.parseResult.language,
|
|
560
588
|
style: source.parseResult.projectStyle,
|
|
561
589
|
environment: source.parseResult.environment,
|
|
562
590
|
})));
|
|
@@ -565,7 +593,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
565
593
|
? `このファイルは ${TOOL_NAME} が「${title}」の git が管理しているファイル(git ls-files)に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
|
|
566
594
|
: generic
|
|
567
595
|
? `このファイルは ${TOOL_NAME} が「${title}」の ${configFileName}(extraRoots)に宣言されたディレクトリに基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
|
|
568
|
-
: `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln /
|
|
596
|
+
: `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln / ${projectFiles})に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`,
|
|
569
597
|
"",
|
|
570
598
|
"<file_summary>",
|
|
571
599
|
"<purpose>",
|
|
@@ -626,19 +654,37 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
626
654
|
: "- .gitignore は考慮していない(設定 exportRespectGitignore で無効化されている)",
|
|
627
655
|
...(sdkExpandedLabels.length > 0
|
|
628
656
|
? [
|
|
629
|
-
`- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(
|
|
657
|
+
`- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(${sdkExpandedGlobs.join(" / ")})を展開した(bin/ obj/ ドットフォルダ・*.user・<Compile Remove> は除外)。MSBuild の完全評価ではない`,
|
|
630
658
|
]
|
|
631
659
|
: []),
|
|
632
660
|
...(extra !== undefined && gitFiles !== undefined
|
|
633
|
-
?
|
|
634
|
-
|
|
635
|
-
|
|
661
|
+
? extra.filtered === undefined
|
|
662
|
+
? [
|
|
663
|
+
`- 対象は git が管理しているファイル(追跡中のものと、.gitignore に一致しない未追跡のもの)。バイナリ・ロックファイル・${GIT_FILE_MAX_BYTES / 1024}KB を超えるもの・node_modules / dist / build / .env などは除外(<skipped_files> に理由)。対象を絞るときは .repomixignore に書く`,
|
|
664
|
+
]
|
|
665
|
+
: [
|
|
666
|
+
`- 対象は git が管理しているファイル(追跡中のものと、.gitignore に一致しない未追跡のもの)のうち、${configFileName} の include に一致し exclude に一致しないもの。バイナリ・ロックファイル・${GIT_FILE_MAX_BYTES / 1024}KB を超えるもの・node_modules / dist / build / .env なども除外(<skipped_files> に理由)`,
|
|
667
|
+
...(extra.filtered.notIncluded > 0 || extra.filtered.excluded > 0
|
|
668
|
+
? [
|
|
669
|
+
`- 設定で入れていないファイル: ${[
|
|
670
|
+
...(extra.filtered.notIncluded > 0
|
|
671
|
+
? [
|
|
672
|
+
`include に一致しない ${extra.filtered.notIncluded} 件(${formatLabelCounts(extra.filtered.notIncludedByLabel)})`,
|
|
673
|
+
]
|
|
674
|
+
: []),
|
|
675
|
+
...(extra.filtered.excluded > 0
|
|
676
|
+
? [`exclude(${formatPatterns(options.gitExclude ?? [])})に一致する ${extra.filtered.excluded} 件`]
|
|
677
|
+
: []),
|
|
678
|
+
].join("、")}。中身が必要なら、推測せずに共有を依頼すること`,
|
|
679
|
+
]
|
|
680
|
+
: []),
|
|
681
|
+
]
|
|
636
682
|
: []),
|
|
637
683
|
...(extra !== undefined && gitFiles === undefined
|
|
638
684
|
? [
|
|
639
685
|
generic
|
|
640
686
|
? `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${configFileName} の extraRoots に宣言されたディレクトリ(<file> の root 属性)。宣言されていないディレクトリは含まれない`
|
|
641
|
-
: `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは
|
|
687
|
+
: `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${projectFiles} に乗らない追加ディレクトリ(${configFileName} の extraRoots。<file> の root 属性)。認証情報マスクは ${projectLanguages.includes("cs") ? "プロジェクトのファイル" : "VB 側"}と同様に適用済み`,
|
|
642
688
|
]
|
|
643
689
|
: []),
|
|
644
690
|
...(generatedDirs.length > 0
|
|
@@ -681,8 +727,10 @@ export function buildRepomixOutput(title, sources, deps, options) {
|
|
|
681
727
|
uiSummaryCount,
|
|
682
728
|
extraRootFileCount,
|
|
683
729
|
contractSummaryIncluded: contractPlaced,
|
|
730
|
+
gitFilesFiltered: gitFiles !== undefined ? extra?.filtered : undefined,
|
|
684
731
|
diagnostics,
|
|
685
732
|
filePaths,
|
|
686
733
|
environmentBlock,
|
|
687
734
|
};
|
|
688
735
|
}
|
|
736
|
+
export { formatLabelCounts };
|
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)
|
|
@@ -242,6 +242,32 @@ function parseDocsConfig(value, fileName, diagnostics) {
|
|
|
242
242
|
};
|
|
243
243
|
return { design: pick("design"), spec: pick("spec"), handoff: pick("handoff") };
|
|
244
244
|
}
|
|
245
|
+
/** トップレベルの include / exclude(git が管理しているファイルの絞り込み) */
|
|
246
|
+
function parseGitFilters(parsed, fileName, diagnostics) {
|
|
247
|
+
const read = (key) => {
|
|
248
|
+
const value = parsed[key];
|
|
249
|
+
if (value === undefined) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
const list = asStringArray(value);
|
|
253
|
+
if (list === undefined) {
|
|
254
|
+
diagnostics.push({
|
|
255
|
+
severity: "warning",
|
|
256
|
+
message: `${fileName}: ${key} は文字列の配列で指定してください(無視します)`,
|
|
257
|
+
});
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
return list.map((glob) => normalizeGlobPath(glob.trim())).filter((glob) => glob !== "");
|
|
261
|
+
};
|
|
262
|
+
const include = read("include");
|
|
263
|
+
const exclude = read("exclude");
|
|
264
|
+
return {
|
|
265
|
+
present: parsed["include"] !== undefined || parsed["exclude"] !== undefined,
|
|
266
|
+
// 空の include は「何も入れない」ではなく指定なしとみなす(extraRoots の include と同じ)
|
|
267
|
+
include: include !== undefined && include.length > 0 ? include : undefined,
|
|
268
|
+
exclude: exclude ?? [],
|
|
269
|
+
};
|
|
270
|
+
}
|
|
245
271
|
/** `kind`: "solution" / "generic"。それ以外は警告して既定の "solution" */
|
|
246
272
|
function parseKind(value, fileName, diagnostics) {
|
|
247
273
|
if (value === undefined) {
|
|
@@ -257,8 +283,8 @@ function parseKind(value, fileName, diagnostics) {
|
|
|
257
283
|
});
|
|
258
284
|
return "solution";
|
|
259
285
|
}
|
|
260
|
-
const TARGET_EXTENSION = /\.(sln|vbproj)$/i;
|
|
261
|
-
/** `target`: ルート配下の相対パスで .sln / .vbproj を指す。それ以外は警告して無視 */
|
|
286
|
+
const TARGET_EXTENSION = /\.(sln|vbproj|csproj)$/i;
|
|
287
|
+
/** `target`: ルート配下の相対パスで .sln / .vbproj / .csproj を指す。それ以外は警告して無視 */
|
|
262
288
|
function parseTarget(value, fileName, diagnostics) {
|
|
263
289
|
if (value === undefined) {
|
|
264
290
|
return undefined;
|
|
@@ -282,7 +308,7 @@ function parseTarget(value, fileName, diagnostics) {
|
|
|
282
308
|
if (!TARGET_EXTENSION.test(normalized)) {
|
|
283
309
|
diagnostics.push({
|
|
284
310
|
severity: "warning",
|
|
285
|
-
message: `${fileName}: target は .sln / .vbproj を指定してください: ${text}(無視します)`,
|
|
311
|
+
message: `${fileName}: target は .sln / .vbproj / .csproj を指定してください: ${text}(無視します)`,
|
|
286
312
|
});
|
|
287
313
|
return undefined;
|
|
288
314
|
}
|
|
@@ -296,6 +322,7 @@ export function loadSlnmixConfig(rootDir, deps) {
|
|
|
296
322
|
const config = {
|
|
297
323
|
kind: "solution",
|
|
298
324
|
extraRoots: [],
|
|
325
|
+
exclude: [],
|
|
299
326
|
generatedDirs: [],
|
|
300
327
|
sources: [],
|
|
301
328
|
};
|
|
@@ -343,7 +370,23 @@ export function loadSlnmixConfig(rootDir, deps) {
|
|
|
343
370
|
}
|
|
344
371
|
}
|
|
345
372
|
config.extraRoots = parseExtraRoots(parsed["extraRoots"], fileName, diagnostics);
|
|
346
|
-
// generic で extraRoots が無ければ、git が管理しているファイルを対象にする(設計書 §25.7)
|
|
373
|
+
// generic で extraRoots が無ければ、git が管理しているファイルを対象にする(設計書 §25.7)。
|
|
374
|
+
// include / exclude はそのときだけ使う
|
|
375
|
+
const filters = parseGitFilters(parsed, fileName, diagnostics);
|
|
376
|
+
if (filters.present) {
|
|
377
|
+
if (config.kind === "generic" && config.extraRoots.length === 0) {
|
|
378
|
+
config.include = filters.include;
|
|
379
|
+
config.exclude = filters.exclude;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
diagnostics.push({
|
|
383
|
+
severity: "warning",
|
|
384
|
+
message: config.kind === "generic"
|
|
385
|
+
? `${fileName}: include / exclude は extraRoots が無いとき(git が管理しているファイルを対象にするとき)だけ使います。extraRoots では各要素の include / exclude に書いてください(無視します)`
|
|
386
|
+
: `${fileName}: include / exclude は kind: "generic" のときだけ使います(無視します)`,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}
|
|
347
390
|
config.docs = parseDocsConfig(parsed["docs"], fileName, diagnostics);
|
|
348
391
|
const schema = asString(parsed["contractSchema"]);
|
|
349
392
|
if (schema !== undefined && schema.trim() !== "") {
|
|
@@ -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
|
}
|
|
@@ -325,8 +327,25 @@ const ENVIRONMENT_PROPERTIES = {
|
|
|
325
327
|
optionexplicit: "optionExplicit",
|
|
326
328
|
optioninfer: "optionInfer",
|
|
327
329
|
optioncompare: "optionCompare",
|
|
330
|
+
nullable: "nullable",
|
|
331
|
+
implicitusings: "implicitUsings",
|
|
328
332
|
rootnamespace: "rootNamespaces",
|
|
329
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
|
+
}
|
|
330
349
|
/** 子要素か属性の値(PackageReference の Version は両方の書き方がある) */
|
|
331
350
|
function childOrAttribute(entry, name) {
|
|
332
351
|
for (const [key, value] of Object.entries(entry)) {
|
|
@@ -369,7 +388,7 @@ function describeReference(tag, entry) {
|
|
|
369
388
|
* ビルド環境を読む(手順文 v10 の <environment>)。言語の版・Option・参照など、AI が使える構文と API を
|
|
370
389
|
* 決めるのに要る値だけ。Condition は評価せず、値が分かれていれば出現順にすべて残す
|
|
371
390
|
*/
|
|
372
|
-
function readEnvironment(project) {
|
|
391
|
+
function readEnvironment(project, language) {
|
|
373
392
|
const environment = {
|
|
374
393
|
toolsVersion: asString(project["@_ToolsVersion"])?.trim() || undefined,
|
|
375
394
|
targetFrameworks: [],
|
|
@@ -378,6 +397,8 @@ function readEnvironment(project) {
|
|
|
378
397
|
optionExplicit: [],
|
|
379
398
|
optionInfer: [],
|
|
380
399
|
optionCompare: [],
|
|
400
|
+
nullable: [],
|
|
401
|
+
implicitUsings: [],
|
|
381
402
|
rootNamespaces: [],
|
|
382
403
|
imports: [],
|
|
383
404
|
references: [],
|
|
@@ -415,7 +436,7 @@ function readEnvironment(project) {
|
|
|
415
436
|
continue;
|
|
416
437
|
}
|
|
417
438
|
for (const [tag, value] of Object.entries(group)) {
|
|
418
|
-
if (equalsIgnoreCase(tag, "Import")) {
|
|
439
|
+
if (language === "vb" && equalsIgnoreCase(tag, "Import")) {
|
|
419
440
|
for (const entry of toArray(value)) {
|
|
420
441
|
const include = isRecord(entry) ? asString(entry["@_Include"])?.trim() : undefined;
|
|
421
442
|
if (include !== undefined && include !== "") {
|
|
@@ -424,6 +445,16 @@ function readEnvironment(project) {
|
|
|
424
445
|
}
|
|
425
446
|
continue;
|
|
426
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
|
+
}
|
|
427
458
|
if (!["Reference", "ProjectReference", "PackageReference", "COMReference"].some((kind) => equalsIgnoreCase(kind, tag))) {
|
|
428
459
|
continue;
|
|
429
460
|
}
|
|
@@ -438,10 +469,10 @@ function readEnvironment(project) {
|
|
|
438
469
|
return environment;
|
|
439
470
|
}
|
|
440
471
|
/**
|
|
441
|
-
* SDK スタイルの既定 Compile グロブ(`**\/*.vb`)を展開し、既存の項目と
|
|
472
|
+
* SDK スタイルの既定 Compile グロブ(`**\/*.vb`、C# は `**\/*.cs`)を展開し、既存の項目と
|
|
442
473
|
* 重複しないものを resolved の ProjectItem として返す。
|
|
443
474
|
*/
|
|
444
|
-
function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, extraExcludes, deps, diagnostics) {
|
|
475
|
+
function expandDefaultCompileGlob(language, projectDir, existingItems, removePatterns, extraExcludes, deps, diagnostics) {
|
|
445
476
|
if (deps.listFilesRecursive === undefined) {
|
|
446
477
|
diagnostics.push({
|
|
447
478
|
severity: "warning",
|
|
@@ -457,7 +488,8 @@ function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, ext
|
|
|
457
488
|
});
|
|
458
489
|
return undefined;
|
|
459
490
|
}
|
|
460
|
-
const
|
|
491
|
+
const defaultCompileGlob = LANGUAGES[language].defaultCompileGlob;
|
|
492
|
+
const includeRegExp = globToRegExp(defaultCompileGlob);
|
|
461
493
|
const excludeRegExps = [
|
|
462
494
|
...DEFAULT_ITEM_EXCLUDES,
|
|
463
495
|
...extraExcludes,
|
|
@@ -503,7 +535,7 @@ function expandDefaultCompileGlob(projectDir, existingItems, removePatterns, ext
|
|
|
503
535
|
}
|
|
504
536
|
diagnostics.push({
|
|
505
537
|
severity: "info",
|
|
506
|
-
message: `SDK スタイルのため既定の Compile グロブ(${
|
|
538
|
+
message: `SDK スタイルのため既定の Compile グロブ(${defaultCompileGlob})を展開しました: ${expanded.length} 件(${details.join("、")})。MSBuild の完全評価ではありません`,
|
|
507
539
|
});
|
|
508
540
|
return expanded;
|
|
509
541
|
}
|
|
@@ -543,25 +575,27 @@ function applyUpdates(items, updates, diagnostics) {
|
|
|
543
575
|
}
|
|
544
576
|
}
|
|
545
577
|
/**
|
|
546
|
-
* .vbproj の XML 文字列を解析し、正規化した ProjectItem 配列と診断を返す。
|
|
578
|
+
* .vbproj / .csproj の XML 文字列を解析し、正規化した ProjectItem 配列と診断を返す。
|
|
547
579
|
*
|
|
548
|
-
* @param xmlContent .vbproj の内容(BOM 付き可)
|
|
549
|
-
* @param projectPath .vbproj の絶対パス(
|
|
580
|
+
* @param xmlContent .vbproj / .csproj の内容(BOM 付き可)
|
|
581
|
+
* @param projectPath .vbproj / .csproj の絶対パス(相対パス解決の基準に使用。拡張子で言語を決める)
|
|
550
582
|
* @param deps ファイルシステム依存の注入
|
|
551
583
|
*/
|
|
552
584
|
export function parseVbproj(xmlContent, projectPath, deps) {
|
|
553
585
|
const projectDir = path.dirname(projectPath);
|
|
586
|
+
const language = projectLanguageOf(projectPath) ?? "vb";
|
|
554
587
|
const diagnostics = [];
|
|
555
588
|
const items = [];
|
|
556
589
|
const result = {
|
|
557
590
|
projectPath,
|
|
591
|
+
language,
|
|
558
592
|
projectDir,
|
|
559
593
|
projectStyle: "legacy",
|
|
560
594
|
defaultCompileGlobExpanded: false,
|
|
561
595
|
items,
|
|
562
596
|
diagnostics,
|
|
563
597
|
};
|
|
564
|
-
// BOM 除去(VS が保存する .vbproj は UTF-8 BOM 付きが多い)
|
|
598
|
+
// BOM 除去(VS が保存する .vbproj / .csproj は UTF-8 BOM 付きが多い)
|
|
565
599
|
const xml = xmlContent.replace(/^\uFEFF/, "");
|
|
566
600
|
const read = parseXml(xml);
|
|
567
601
|
if (!read.ok) {
|
|
@@ -580,11 +614,11 @@ export function parseVbproj(xmlContent, projectPath, deps) {
|
|
|
580
614
|
if (!isRecord(project)) {
|
|
581
615
|
diagnostics.push({
|
|
582
616
|
severity: "error",
|
|
583
|
-
message:
|
|
617
|
+
message: `<Project> 要素が見つかりません(${LANGUAGES[language].projectExtension} ではない可能性があります)`,
|
|
584
618
|
});
|
|
585
619
|
return result;
|
|
586
620
|
}
|
|
587
|
-
result.environment = readEnvironment(project);
|
|
621
|
+
result.environment = readEnvironment(project, language);
|
|
588
622
|
const toolsVersion = asString(project["@_ToolsVersion"]);
|
|
589
623
|
if (toolsVersion !== undefined) {
|
|
590
624
|
diagnostics.push({ severity: "info", message: `ToolsVersion: ${toolsVersion}` });
|
|
@@ -673,7 +707,7 @@ export function parseVbproj(xmlContent, projectPath, deps) {
|
|
|
673
707
|
});
|
|
674
708
|
}
|
|
675
709
|
else {
|
|
676
|
-
const expanded = expandDefaultCompileGlob(projectDir, items, removePatterns, properties.defaultItemExcludes, deps, diagnostics);
|
|
710
|
+
const expanded = expandDefaultCompileGlob(language, projectDir, items, removePatterns, properties.defaultItemExcludes, deps, diagnostics);
|
|
677
711
|
if (expanded !== undefined) {
|
|
678
712
|
items.push(...expanded);
|
|
679
713
|
result.defaultCompileGlobExpanded = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tazuna",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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",
|