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
package/README.md
CHANGED
|
@@ -15,8 +15,9 @@ tazuna では AI はあなたの PC に一切触れません。コードを渡
|
|
|
15
15
|
`.tazuna/history/` に自動保存される
|
|
16
16
|
3. **直す** (`tazuna build`): MSBuild でビルドし、失敗したらエラーと今のファイルの周辺行をクリップボードへ入れる
|
|
17
17
|
|
|
18
|
-
レガシー VB.NET (`.sln` / `.vbproj`、Shift_JIS) を出発点にしていますが、
|
|
19
|
-
|
|
18
|
+
レガシー VB.NET (`.sln` / `.vbproj`、Shift_JIS) を出発点にしていますが、C# の `.csproj` も同じように
|
|
19
|
+
`.sln` の構成で扱えます (0.17.0。旧スタイル / SDK スタイル、WinForms の Designer.cs の要約)。TypeScript・Python・
|
|
20
|
+
Go などのプロジェクトでも使えます (git が管理しているファイルをまとめる)。実行時依存はゼロで、通信もしません
|
|
20
21
|
(導入審査向けの説明は [docs/SECURITY-REVIEW.md](docs/SECURITY-REVIEW.md))。
|
|
21
22
|
|
|
22
23
|
0.15.0 で、変更を当てる側だった petari と、パックを作る側だった [slnmix](https://www.npmjs.com/package/slnmix) を
|
|
@@ -39,7 +40,7 @@ npx tazuna pack # パックを作り、Copilot Chat に貼るものを
|
|
|
39
40
|
# → AI から changes.md をダウンロード
|
|
40
41
|
npx tazuna # Downloads の changes.md を自動検出して適用
|
|
41
42
|
git diff # VS Code で差分レビュー・手修正
|
|
42
|
-
npx tazuna build # (VB.NET) ビルドし、失敗ならエラーと周辺のコードをクリップボードへ → チャットに貼る
|
|
43
|
+
npx tazuna build # (VB.NET / C#) ビルドし、失敗ならエラーと周辺のコードをクリップボードへ → チャットに貼る
|
|
43
44
|
npx tazuna undo # 直近の適用を巻き戻す
|
|
44
45
|
```
|
|
45
46
|
|
|
@@ -86,24 +87,26 @@ RDP 越しに受け渡す運用では従来どおり `tazuna` / `tazuna --clip`
|
|
|
86
87
|
- `npx petari` と `npx slnmix` もしばらくは動きます (tazuna を呼ぶだけの互換パッケージ。実行のたびに
|
|
87
88
|
移行を知らせる 1 行が出ます)
|
|
88
89
|
|
|
89
|
-
### レガシー VB.NET プロジェクトでの適用
|
|
90
|
+
### レガシー VB.NET / C# プロジェクトでの適用
|
|
90
91
|
|
|
91
|
-
#### 新規 .vb ファイルの作成
|
|
92
|
+
#### 新規 .vb / .cs ファイルの作成
|
|
92
93
|
|
|
93
|
-
AI が `create` で `.vb` を新規作成すると、tazuna が次を自動で行います (Visual Studio での
|
|
94
|
+
AI が `create` で `.vb` / `.cs` を新規作成すると、tazuna が次を自動で行います (Visual Studio での
|
|
94
95
|
手作業をなくすため)。いずれも失敗しても create 自体は成功し、理由を結果表示に出します。
|
|
95
96
|
|
|
96
|
-
- **旧スタイル .vbproj
|
|
97
|
-
|
|
98
|
-
`X
|
|
99
|
-
|
|
97
|
+
- **旧スタイル .vbproj / .csproj への登録**: 作成先から上へ辿って最寄りのプロジェクトファイルを探し
|
|
98
|
+
(`.vb` は `.vbproj`、`.cs` は `.csproj`。最寄りのプロジェクトが別の言語なら登録しません)、
|
|
99
|
+
`<Compile Include="...">` を追加します (`Inherits Form` / `class X : Form` なら `<SubType>Form</SubType>`、
|
|
100
|
+
`X.Designer.vb` / `X.Designer.cs` なら `<DependentUpon>X.vb</DependentUpon>` などが付きます)。追加行以外のバイト列は
|
|
101
|
+
変えません (Shift_JIS / CRLF / BOM そのまま)。SDK スタイルのプロジェクトは登録不要のため
|
|
100
102
|
触りません。登録は履歴に含まれ `tazuna undo` で戻ります。無効化は `--no-vbproj` か
|
|
101
103
|
`.tazuna/config.json` (旧版から使っているリポジトリでは `.petari/config.json`。以下同じ) の
|
|
102
|
-
`"vbproj": { "register": false }`
|
|
104
|
+
`"vbproj": { "register": false }` (名前は vbproj のままで、.csproj への登録も止まります)
|
|
103
105
|
- **エンコーディングの推定**: `.tazuna/config.json` の `"newFile": { "encoding": "auto" }`
|
|
104
106
|
(`tazuna init` の雛形の既定) で、同じディレクトリの既存ファイルの多数決で
|
|
105
107
|
文字コード / BOM / 改行を決めます。`.vb` を BOM なし UTF-8 で作ることはありません
|
|
106
|
-
(vbc / VS で日本語が化けるため)
|
|
108
|
+
(vbc / VS で日本語が化けるため)。手本が無いときの `.vb` / `.cs` は Visual Studio と同じ UTF-8 (BOM あり) / CRLF です。
|
|
109
|
+
従来どおり `"utf8"` / `"shift_jis"` の明示指定も使えます
|
|
107
110
|
|
|
108
111
|
### 適用が繰り返し失敗するとき
|
|
109
112
|
|
|
@@ -135,7 +138,7 @@ repomix の出力) が実ファイルとずれている**可能性が高いで
|
|
|
135
138
|
|
|
136
139
|
適用の主なオプション: `--dry-run` (検証と差分プレビューのみ) / `--partial` (成功分のみ適用) /
|
|
137
140
|
`--root <dir>` / `--yes` / `--clip-report` (失敗レポートをクリップボードへ。v0.5.0 から既定で自動コピーされるため、config で無効化した場合の個別指定用) /
|
|
138
|
-
`--no-vbproj` (create した .vb の .vbproj 自動登録を今回だけ無効化) /
|
|
141
|
+
`--no-vbproj` (create した .vb / .cs の .vbproj / .csproj 自動登録を今回だけ無効化) /
|
|
139
142
|
`--force` (適用済みの changes.md でも再適用する。下記「二重適用の防止」を今回だけ解除) /
|
|
140
143
|
`--literal-masked` (元の値に戻せない `[MASKED]` をその文字のまま書く。伏せ字を扱うコードそのものを書くとき用。下記「伏せ字 [MASKED] の扱い」)
|
|
141
144
|
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/commands/apply.js
CHANGED
|
@@ -12,7 +12,7 @@ import { changeSetFingerprint } from "../core/fingerprint.js";
|
|
|
12
12
|
import { PRESENCE_STAGE_LABEL } from "../core/matcher.js";
|
|
13
13
|
import { fixedNewFile, resolveNewFileStyle } from "../core/new-file-style.js";
|
|
14
14
|
import { parseChangesRecovering } from "../core/parser.js";
|
|
15
|
-
import { buildBlankInsensitiveNote, buildMaskRestoreNote, buildFailureReport, buildParseErrorReport, } from "../core/report.js";
|
|
15
|
+
import { buildBlankInsensitiveNote, buildMaskRestoreNote, buildSjisFoldNote, buildFailureReport, buildParseErrorReport, } from "../core/report.js";
|
|
16
16
|
import { readClipboard, writeClipboard } from "../infra/clipboard.js";
|
|
17
17
|
import { loadConfig } from "../infra/config.js";
|
|
18
18
|
import { findRecentChangesFiles, resolveDownloadsDir, } from "../infra/downloads.js";
|
|
@@ -85,7 +85,7 @@ export async function applyCommand(argv, detected) {
|
|
|
85
85
|
yes: { type: "boolean", short: "y", default: false },
|
|
86
86
|
clip: { type: "boolean", default: false },
|
|
87
87
|
"clip-report": { type: "boolean", default: false },
|
|
88
|
-
// create した .vb の .vbproj 自動登録を今回だけ無効化 (config vbproj.register の一時上書き)
|
|
88
|
+
// create した .vb / .cs の .vbproj / .csproj 自動登録を今回だけ無効化 (config vbproj.register の一時上書き)
|
|
89
89
|
"no-vbproj": { type: "boolean", default: false },
|
|
90
90
|
// 履歴で適用済みの changes.md でも再適用する (二重適用防止の解除・§6.1)
|
|
91
91
|
force: { type: "boolean", default: false },
|
|
@@ -276,7 +276,7 @@ export async function applyCommand(argv, detected) {
|
|
|
276
276
|
return 1;
|
|
277
277
|
}
|
|
278
278
|
const applicable = plan.outcomes.filter(isApplicable);
|
|
279
|
-
// create した .vb の旧スタイル .vbproj への登録計画 (設計書 §11.1)。失敗しても create は成功扱い
|
|
279
|
+
// create した .vb / .cs の旧スタイル .vbproj / .csproj への登録計画 (設計書 §11.1)。失敗しても create は成功扱い
|
|
280
280
|
const vbprojEnabled = config.vbproj.register && !values["no-vbproj"];
|
|
281
281
|
const vbprojPlan = vbprojEnabled
|
|
282
282
|
? planVbprojRegistrations(root, applicable)
|
|
@@ -334,6 +334,9 @@ export async function applyCommand(argv, detected) {
|
|
|
334
334
|
const dryRunMaskNote = buildMaskRestoreNote(plan.outcomes, false);
|
|
335
335
|
if (dryRunMaskNote !== null)
|
|
336
336
|
out(dryRunMaskNote);
|
|
337
|
+
const dryRunSjisNote = buildSjisFoldNote(plan.outcomes, false);
|
|
338
|
+
if (dryRunSjisNote !== null)
|
|
339
|
+
out(dryRunSjisNote);
|
|
337
340
|
if (plan.failures.length > 0) {
|
|
338
341
|
out("");
|
|
339
342
|
await emitReport(buildFailureReport(plan.failures, { outcomes: plan.outcomes, nothingWritten: true }));
|
|
@@ -461,6 +464,9 @@ export async function applyCommand(argv, detected) {
|
|
|
461
464
|
const maskNote = buildMaskRestoreNote(plan.outcomes, true);
|
|
462
465
|
if (maskNote !== null)
|
|
463
466
|
out(maskNote);
|
|
467
|
+
const sjisNote = buildSjisFoldNote(plan.outcomes, true);
|
|
468
|
+
if (sjisNote !== null)
|
|
469
|
+
out(sjisNote);
|
|
464
470
|
if (plan.failures.length > 0) {
|
|
465
471
|
out(`スキップした失敗 ${plan.failures.length} 件のレポート:`);
|
|
466
472
|
out("");
|
package/dist/commands/build.js
CHANGED
|
@@ -42,7 +42,7 @@ export function buildCommand(argv) {
|
|
|
42
42
|
return 1;
|
|
43
43
|
}
|
|
44
44
|
if (resolved.targetPath === undefined) {
|
|
45
|
-
err(`${BUILD_COMMAND} は .sln / .vbproj の構成でのみ使えます(kind: "generic" のプロジェクトは、そのプロジェクトのビルド・テストのコマンドを使ってください)。`);
|
|
45
|
+
err(`${BUILD_COMMAND} は .sln / .vbproj / .csproj の構成でのみ使えます(kind: "generic" のプロジェクトは、そのプロジェクトのビルド・テストのコマンドを使ってください)。`);
|
|
46
46
|
return 1;
|
|
47
47
|
}
|
|
48
48
|
return runBuild(resolved.targetPath, resolved.rootDir, {
|
package/dist/commands/pack-io.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pack / build / init が共有するファイル I/O と、入力(.sln / .vbproj / generic 構成)とルートの決め方。
|
|
2
|
+
* pack / build / init が共有するファイル I/O と、入力(.sln / .vbproj / .csproj / generic 構成)とルートの決め方。
|
|
3
3
|
* src/pack/ の解析コアは deps 注入で I/O を持たないため、実際のファイルシステムをここでつなぐ。
|
|
4
4
|
*/
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
@@ -155,7 +155,7 @@ export function printDiagnostics(label, diagnostics) {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
* 入力(.sln / .vbproj / ディレクトリ / 省略)とルートを決める(パックとビルドで同じ)。
|
|
158
|
+
* 入力(.sln / .vbproj / .csproj / ディレクトリ / 省略)とルートを決める(パックとビルドで同じ)。
|
|
159
159
|
* solution: --root > 上位の設定ファイルの場所 > 上位の .git の場所 > 入力と同じ場所(rootResolver.ts)
|
|
160
160
|
* generic: 設定ファイルの場所に固定(--root は使えない。基準が設定と食い違うため)
|
|
161
161
|
*/
|
|
@@ -166,6 +166,20 @@ function withConfigCheck(result) {
|
|
|
166
166
|
}
|
|
167
167
|
return result;
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* 入力(省略時は自動検出)の .sln / .vbproj / .csproj を、何も出力せずに求める(--print-procedure で
|
|
171
|
+
* プロジェクトの言語を知るため)。見つからない・generic 構成なら undefined
|
|
172
|
+
*/
|
|
173
|
+
export function findTargetQuietly(inputArg) {
|
|
174
|
+
const resolution = resolveTarget(inputArg, process.cwd(), {
|
|
175
|
+
isDirectory: isDirectoryPath,
|
|
176
|
+
isFile: isFilePath,
|
|
177
|
+
listFileNames: FS_DEPS.listFileNames,
|
|
178
|
+
readConfigTarget: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.target,
|
|
179
|
+
isGenericConfig: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.kind === "generic",
|
|
180
|
+
});
|
|
181
|
+
return resolution.kind === "file" ? resolution.path : undefined;
|
|
182
|
+
}
|
|
169
183
|
export function resolveTargetAndRoot(inputArg, rootArg, options) {
|
|
170
184
|
const resolution = resolveTarget(inputArg, process.cwd(), {
|
|
171
185
|
isDirectory: isDirectoryPath,
|
|
@@ -173,7 +187,7 @@ export function resolveTargetAndRoot(inputArg, rootArg, options) {
|
|
|
173
187
|
listFileNames: FS_DEPS.listFileNames,
|
|
174
188
|
// 引数なし(またはディレクトリ指定)のとき、その場所の設定ファイルの target を使う
|
|
175
189
|
readConfigTarget: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.target,
|
|
176
|
-
// 同じ場所の設定が kind: "generic" なら .sln / .vbproj を探さない
|
|
190
|
+
// 同じ場所の設定が kind: "generic" なら .sln / .vbproj / .csproj を探さない
|
|
177
191
|
isGenericConfig: (directory) => loadSlnmixConfig(directory, { readTextFile: readSourceTextFile }).config.kind === "generic",
|
|
178
192
|
});
|
|
179
193
|
if (resolution.kind === "error") {
|
|
@@ -195,7 +209,7 @@ export function resolveTargetAndRoot(inputArg, rootArg, options) {
|
|
|
195
209
|
usageHint: false,
|
|
196
210
|
};
|
|
197
211
|
}
|
|
198
|
-
err(`対象: generic 構成(${configName} の kind。.sln / .vbproj は使いません)`);
|
|
212
|
+
err(`対象: generic 構成(${configName} の kind。.sln / .vbproj / .csproj は使いません)`);
|
|
199
213
|
err(`ルート: ${resolution.rootDir}`);
|
|
200
214
|
return withConfigCheck({ kind: "ok", targetPath: undefined, rootDir: resolution.rootDir });
|
|
201
215
|
}
|
package/dist/commands/pack.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* tazuna pack — コードベースを AI チャットに渡す 1 ファイル(repomix 互換のパック)と、
|
|
3
3
|
* チャット本文に貼る指示テキスト(.prompt.md)を作る(旧 slnmix)。
|
|
4
4
|
*
|
|
5
|
-
* .sln / .vbproj の論理構成(Link・DependentUpon 解決済み)か、設定ファイルの extraRoots に宣言した
|
|
5
|
+
* .sln / .vbproj / .csproj の論理構成(Link・DependentUpon 解決済み)か、設定ファイルの extraRoots に宣言した
|
|
6
6
|
* ディレクトリ(kind: "generic")に基づく。解析・出力は src/pack/ のコアが担い、ここは引数処理とファイル I/O。
|
|
7
7
|
*/
|
|
8
8
|
import * as fs from "node:fs";
|
|
@@ -26,18 +26,19 @@ import { assembleOutput, buildPromptText, resolvePlan, resolveProcedure, resolve
|
|
|
26
26
|
import { DOC_TEMPLATES_DIR } from "../pack/assets/docTemplates.js";
|
|
27
27
|
import { buildRepomixOutput } from "../pack/services/repomixExporter.js";
|
|
28
28
|
import { CONFIG_FILE_NAME, configFileNameIn, LEGACY_CONFIG_FILE_NAME, loadSlnmixConfig } from "../pack/slnmixConfig.js";
|
|
29
|
+
import { projectLanguageOf } from "../pack/projectLanguage.js";
|
|
29
30
|
import { parseSln } from "../pack/slnParser.js";
|
|
30
31
|
import { parseVbproj } from "../pack/vbprojParser.js";
|
|
31
|
-
import { createGitignoreEvaluator, fileSizeOf, FS_DEPS, isDirectoryPath, isFilePath, listGitFiles, printDiagnostics, readSourceTextFile, resolveTargetAndRoot, } from "./pack-io.js";
|
|
32
|
+
import { createGitignoreEvaluator, fileSizeOf, findTargetQuietly, FS_DEPS, isDirectoryPath, isFilePath, listGitFiles, printDiagnostics, readSourceTextFile, resolveTargetAndRoot, } from "./pack-io.js";
|
|
32
33
|
export const PACK_USAGE = `使い方:
|
|
33
|
-
${PACK_COMMAND} [<solution.sln | project.vbproj | ディレクトリ>] [オプション]
|
|
34
|
+
${PACK_COMMAND} [<solution.sln | project.vbproj | project.csproj | ディレクトリ>] [オプション]
|
|
34
35
|
|
|
35
36
|
入力を省略するとカレントディレクトリ(ディレクトリ指定ならその直下)の
|
|
36
|
-
*.sln を自動検出します(なければ *.vbproj。複数ある場合は候補を表示)。
|
|
37
|
+
*.sln を自動検出します(なければ *.vbproj / *.csproj。複数ある場合は候補を表示)。
|
|
37
38
|
その場所の設定ファイル(${CONFIG_FILE_NAME}。旧名の ${LEGACY_CONFIG_FILE_NAME} も読みます)に
|
|
38
39
|
"target": "dotnet/App.sln" があればそれを使います。同じ設定が "kind": "generic" なら
|
|
39
|
-
.sln / .vbproj を探さず、git が管理しているファイル(extraRoots を書けば、宣言した
|
|
40
|
-
ディレクトリだけ)でパックします(
|
|
40
|
+
.sln / .vbproj / .csproj を探さず、git が管理しているファイル(extraRoots を書けば、宣言した
|
|
41
|
+
ディレクトリだけ)でパックします(.sln の無いプロジェクト。${INIT_COMMAND} で作成)。
|
|
41
42
|
|
|
42
43
|
ルート(<file path> の基準。設定ファイル・protocol.md・docs/・出力先もここ)は
|
|
43
44
|
--root > 入力のディレクトリから上に向かって最初に見つかる設定ファイルの場所
|
|
@@ -48,12 +49,12 @@ export const PACK_USAGE = `使い方:
|
|
|
48
49
|
-o, --output <file> 出力先(既定: ルートの repomix-output.xml)
|
|
49
50
|
--root <dir> ルートを明示する(入力はその配下にあること)
|
|
50
51
|
--stdout ファイルではなく標準出力へ書く(BOM なし)
|
|
51
|
-
--include-designer Designer 関連ファイル(*.Designer.vb 等)を原文のまま含める
|
|
52
|
+
--include-designer Designer 関連ファイル(*.Designer.vb / *.Designer.cs 等)を原文のまま含める
|
|
52
53
|
--include-designer-file <名前|パターン>
|
|
53
54
|
指定した Designer 関連ファイルだけ原文のまま含める
|
|
54
55
|
(複数指定可。* をワイルドカードに使える。ファイル名
|
|
55
56
|
または論理パスに全体一致)
|
|
56
|
-
--no-ui-summary Designer.vb からの UI サマリー(<ui_summary>)生成を無効化
|
|
57
|
+
--no-ui-summary Designer.vb / Designer.cs からの UI サマリー(<ui_summary>)生成を無効化
|
|
57
58
|
--no-mask 認証情報の自動マスク([MASKED] 置換)を無効化
|
|
58
59
|
--no-strict-mask 高エントロピー文字列(ランダム英数字列)の機械的マスクを無効化
|
|
59
60
|
--no-gitignore .gitignore / .repomixignore による除外を無効化
|
|
@@ -73,7 +74,7 @@ export const PACK_USAGE = `使い方:
|
|
|
73
74
|
--design <名前|file>
|
|
74
75
|
design モードで対象の設計書を指定
|
|
75
76
|
--init-docs docs/ 連携だけを設定する(${INIT_COMMAND} に含まれる)
|
|
76
|
-
--init-config
|
|
77
|
+
--init-config .sln の無いプロジェクト向けの ${CONFIG_FILE_NAME}
|
|
77
78
|
(kind: "generic")だけを作る(${INIT_COMMAND} に含まれる)
|
|
78
79
|
--plan <file> implement モードで承認済みの方針を <plan> として同梱する
|
|
79
80
|
--procedure-file <path>
|
|
@@ -105,7 +106,26 @@ function defaultPromptPath(outputPath) {
|
|
|
105
106
|
const base = ext === "" ? outputPath : outputPath.slice(0, -ext.length);
|
|
106
107
|
return `${base}.prompt.md`;
|
|
107
108
|
}
|
|
108
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* --print-procedure 用: 入力(省略時は自動検出)のプロジェクトの言語。診断は出さない
|
|
111
|
+
* (手順文を標準出力に書くだけのため)。入力が見つからなければ undefined(Visual Basic の文面)
|
|
112
|
+
*/
|
|
113
|
+
function languagesForPrint(input) {
|
|
114
|
+
const targetPath = findTargetQuietly(input);
|
|
115
|
+
if (targetPath === undefined) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
if (!/\.sln$/i.test(targetPath)) {
|
|
119
|
+
const language = projectLanguageOf(targetPath);
|
|
120
|
+
return language === undefined ? undefined : [language];
|
|
121
|
+
}
|
|
122
|
+
const content = readSourceTextFile(targetPath);
|
|
123
|
+
if (content === undefined) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
return parseSln(content, targetPath, FS_DEPS).projects.map((project) => project.language);
|
|
127
|
+
}
|
|
128
|
+
/** 入力(.sln / .vbproj / .csproj)から RepomixSource[] を組み立てる */
|
|
109
129
|
function collectSources(targetPath) {
|
|
110
130
|
const content = readSourceTextFile(targetPath);
|
|
111
131
|
if (content === undefined) {
|
|
@@ -132,7 +152,7 @@ function collectSources(targetPath) {
|
|
|
132
152
|
return sources;
|
|
133
153
|
}
|
|
134
154
|
const parseResult = parseVbproj(content, targetPath, FS_DEPS);
|
|
135
|
-
const label = path.basename(targetPath).replace(/\.vbproj$/i, "");
|
|
155
|
+
const label = path.basename(targetPath).replace(/\.(vbproj|csproj)$/i, "");
|
|
136
156
|
printDiagnostics(label, parseResult.diagnostics);
|
|
137
157
|
return [{ label, parseResult }];
|
|
138
158
|
}
|
|
@@ -188,6 +208,8 @@ export function packCommand(argv) {
|
|
|
188
208
|
tests: "placeholder",
|
|
189
209
|
db: "placeholder",
|
|
190
210
|
layout: printConfig.config.kind,
|
|
211
|
+
// C# のプロジェクトがあれば C# の語句にする(入力が見つからなければ Visual Basic)
|
|
212
|
+
languages: printConfig.config.kind === "generic" ? undefined : languagesForPrint(positionals[0]),
|
|
191
213
|
}));
|
|
192
214
|
return 0;
|
|
193
215
|
}
|
|
@@ -199,7 +221,7 @@ export function packCommand(argv) {
|
|
|
199
221
|
err("--plan は --mode implement でのみ使えます。");
|
|
200
222
|
return 1;
|
|
201
223
|
}
|
|
202
|
-
//
|
|
224
|
+
// .sln の無いプロジェクト向けの設定ファイルを作る(入力の解決より前。.sln は無い前提)
|
|
203
225
|
if (values["init-config"]) {
|
|
204
226
|
const initRoot = path.resolve(process.cwd(), values.root ?? positionals[0] ?? ".");
|
|
205
227
|
const result = initConfig(initRoot, {
|
|
@@ -319,7 +341,7 @@ export function packCommand(argv) {
|
|
|
319
341
|
});
|
|
320
342
|
}
|
|
321
343
|
if (layout === "solution" && config.kind === "generic") {
|
|
322
|
-
err(`[warning] ${configName} は kind: "generic" ですが、入力に .sln / .vbproj が指定されたため従来どおり論理構成で出力します`);
|
|
344
|
+
err(`[warning] ${configName} は kind: "generic" ですが、入力に .sln / .vbproj / .csproj が指定されたため従来どおり論理構成で出力します`);
|
|
323
345
|
}
|
|
324
346
|
if (config.sources.length > 0) {
|
|
325
347
|
const parts = [gitFiles !== undefined ? "git が管理しているファイル" : `extraRoots ${config.extraRoots.length} 件`];
|
|
@@ -457,6 +479,7 @@ export function packCommand(argv) {
|
|
|
457
479
|
tests: autoTests.present,
|
|
458
480
|
db: dbSchema !== undefined,
|
|
459
481
|
layout,
|
|
482
|
+
languages: sources.map((source) => source.parseResult.language),
|
|
460
483
|
}, rootDir, process.cwd(), textDeps);
|
|
461
484
|
if (procedure.kind === "error") {
|
|
462
485
|
err(procedure.message);
|
|
@@ -469,6 +492,7 @@ export function packCommand(argv) {
|
|
|
469
492
|
plan,
|
|
470
493
|
procedure,
|
|
471
494
|
instruction,
|
|
495
|
+
...(output.environmentBlock === undefined ? {} : { environment: output.environmentBlock }),
|
|
472
496
|
...(docsTail === undefined ? {} : { docs: docsTail }),
|
|
473
497
|
...(dbSchema === undefined
|
|
474
498
|
? {}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* create した .vb の旧スタイル .vbproj への自動登録 (設計書 §11.1 P1-a
|
|
3
|
-
*
|
|
2
|
+
* create した .vb / .cs の旧スタイル .vbproj / .csproj への自動登録 (設計書 §11.1 P1-a。C# は
|
|
3
|
+
* tazuna 0.17.0 から) — apply の結線部。判定・挿入は core/vbproj.ts、探索は infra/vbproj.ts。
|
|
4
|
+
* .vb は最寄りの .vbproj、.cs は最寄りの .csproj に登録する (最寄りのプロジェクトが別の言語なら登録しない)。
|
|
4
5
|
*
|
|
5
6
|
* - 登録の失敗は create 自体の成否に影響しない (レポートに載せるだけ)
|
|
6
7
|
* - 同じ changes.md が .vbproj 自体を変更する場合は、その変更後の内容に対して登録する
|
|
@@ -9,21 +10,32 @@
|
|
|
9
10
|
import { existsSync } from "node:fs";
|
|
10
11
|
import { basename, dirname, join } from "node:path";
|
|
11
12
|
import { EncodingError, decodeFile, encodeDocument, findUnencodable, } from "../core/encoding.js";
|
|
13
|
+
import { describeChars } from "../core/sjis.js";
|
|
12
14
|
import { designerParentName, detectSubType, registerCompileItem, toIncludePath, } from "../core/vbproj.js";
|
|
13
15
|
import { isInsideRoot, readFileState } from "../infra/files.js";
|
|
14
16
|
import { findNearestVbproj } from "../infra/vbproj.js";
|
|
15
17
|
const EMPTY = { writes: new Map(), registrations: [], notes: [] };
|
|
18
|
+
/** 作ったファイルの言語に対応するプロジェクトファイル */
|
|
19
|
+
function projectKindOf(file) {
|
|
20
|
+
return /\.cs$/i.test(file)
|
|
21
|
+
? { language: "cs", extension: ".csproj", label: "csproj" }
|
|
22
|
+
: { language: "vb", extension: ".vbproj", label: "vbproj" };
|
|
23
|
+
}
|
|
24
|
+
/** プロジェクトファイルのパスの見出し ("vbproj" / "csproj") */
|
|
25
|
+
function labelOfProject(path) {
|
|
26
|
+
return /\.csproj$/i.test(path) ? "csproj" : "vbproj";
|
|
27
|
+
}
|
|
16
28
|
function relDirOf(path) {
|
|
17
29
|
const d = dirname(path);
|
|
18
30
|
return d === "." ? "" : d;
|
|
19
31
|
}
|
|
20
32
|
/**
|
|
21
|
-
* 書き込み対象 (applicable) の outcomes から create された .vb を拾い、登録計画を立てる。
|
|
33
|
+
* 書き込み対象 (applicable) の outcomes から create された .vb / .cs を拾い、登録計画を立てる。
|
|
22
34
|
* 書き込みは行わない。
|
|
23
35
|
*/
|
|
24
36
|
export function planVbprojRegistrations(root, applicable) {
|
|
25
37
|
const creates = applicable
|
|
26
|
-
.filter((o) => o.change.op === "create" && /\.vb$/i.test(o.change.path))
|
|
38
|
+
.filter((o) => o.change.op === "create" && /\.(vb|cs)$/i.test(o.change.path))
|
|
27
39
|
// X.vb を X.Designer.vb より先に登録する (VS の並びに合わせる。安定ソート)
|
|
28
40
|
.map((o, i) => ({ o, i, designer: designerParentName(basename(o.change.path)) !== null }))
|
|
29
41
|
.sort((a, b) => Number(a.designer) - Number(b.designer) || a.i - b.i)
|
|
@@ -43,21 +55,26 @@ export function planVbprojRegistrations(root, applicable) {
|
|
|
43
55
|
};
|
|
44
56
|
for (const o of creates) {
|
|
45
57
|
const file = o.change.path;
|
|
46
|
-
const
|
|
58
|
+
const kind = projectKindOf(file);
|
|
59
|
+
const note = (message) => {
|
|
60
|
+
plan.notes.push({ file, message, label: kind.label });
|
|
61
|
+
};
|
|
62
|
+
const lookup = findNearestVbproj(root, relDirOf(file), kind.extension);
|
|
47
63
|
if (lookup.kind === "none") {
|
|
48
|
-
|
|
64
|
+
note(`${kind.label} が見つからないため未登録`);
|
|
49
65
|
continue;
|
|
50
66
|
}
|
|
51
67
|
if (lookup.kind === "multiple") {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
note(`${lookup.dir} に複数の ${kind.extension} があるため未登録 (${lookup.names.join(", ")})。手動で登録してください`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (lookup.kind === "other-language") {
|
|
72
|
+
note(`最寄りのプロジェクト ${lookup.path} は ${kind.extension} ではないため未登録`);
|
|
56
73
|
continue;
|
|
57
74
|
}
|
|
58
75
|
const target = load(lookup.path);
|
|
59
76
|
if ("error" in target) {
|
|
60
|
-
|
|
77
|
+
note(`${lookup.path} に未登録 (${target.error})`);
|
|
61
78
|
continue;
|
|
62
79
|
}
|
|
63
80
|
const include = toIncludePath(relDirOf(lookup.path), file);
|
|
@@ -71,32 +88,26 @@ export function planVbprojRegistrations(root, applicable) {
|
|
|
71
88
|
}
|
|
72
89
|
}
|
|
73
90
|
else if (o.change.op === "create") {
|
|
74
|
-
const subType = detectSubType(o.change.content);
|
|
91
|
+
const subType = detectSubType(o.change.content, kind.language);
|
|
75
92
|
if (subType !== undefined)
|
|
76
93
|
opts.subType = subType;
|
|
77
94
|
}
|
|
78
95
|
const r = registerCompileItem(target.lines.map((l) => l.text), include, opts);
|
|
79
96
|
if (r.status === "registered") {
|
|
80
|
-
|
|
97
|
+
note(`${lookup.path} に登録済み (変更なし)`);
|
|
81
98
|
continue;
|
|
82
99
|
}
|
|
83
100
|
if (r.status === "sdk-style") {
|
|
84
|
-
|
|
101
|
+
note(`${lookup.path} は SDK スタイルのため登録不要`);
|
|
85
102
|
continue;
|
|
86
103
|
}
|
|
87
104
|
if (r.status === "unsupported") {
|
|
88
|
-
|
|
89
|
-
file,
|
|
90
|
-
message: `${lookup.path} は登録できない形式のため未登録 (${r.reason})。手動で登録してください`,
|
|
91
|
-
});
|
|
105
|
+
note(`${lookup.path} は登録できない形式のため未登録 (${r.reason})。手動で登録してください`);
|
|
92
106
|
continue;
|
|
93
107
|
}
|
|
94
108
|
const bad = findUnencodable(r.inserted.join("\n"), target.doc.encoding);
|
|
95
109
|
if (bad.length > 0) {
|
|
96
|
-
|
|
97
|
-
file,
|
|
98
|
-
message: `${lookup.path} (Shift_JIS) に変換できない文字がパスに含まれるため未登録: ${bad.join(" ")}`,
|
|
99
|
-
});
|
|
110
|
+
note(`${lookup.path} (Shift_JIS) に変換できない文字がパスに含まれるため未登録: ${describeChars(bad)}`);
|
|
100
111
|
continue;
|
|
101
112
|
}
|
|
102
113
|
const inserted = r.inserted.map((text) => ({ text, raw: null, eol: null }));
|
|
@@ -115,13 +126,14 @@ export function planVbprojRegistrations(root, applicable) {
|
|
|
115
126
|
}
|
|
116
127
|
return plan;
|
|
117
128
|
}
|
|
118
|
-
/**
|
|
129
|
+
/** プロジェクトファイルの現在の内容 (changes.md が同じファイルを変更するならその変更後) を読む */
|
|
119
130
|
function loadVbproj(root, vbproj, applicable) {
|
|
120
131
|
const own = applicable.find((o) => o.change.path === vbproj);
|
|
121
132
|
let bytes;
|
|
122
133
|
if (own !== undefined) {
|
|
123
|
-
if (own.change.op === "delete")
|
|
124
|
-
return { error:
|
|
134
|
+
if (own.change.op === "delete") {
|
|
135
|
+
return { error: `changes.md がこの ${/\.csproj$/i.test(vbproj) ? ".csproj" : ".vbproj"} を削除するため` };
|
|
136
|
+
}
|
|
125
137
|
bytes = own.afterBytes;
|
|
126
138
|
}
|
|
127
139
|
else {
|
|
@@ -151,9 +163,9 @@ export function formatVbprojPlan(plan) {
|
|
|
151
163
|
r.subType !== undefined ? `SubType: ${r.subType}` : null,
|
|
152
164
|
r.dependentUpon !== undefined ? `DependentUpon: ${r.dependentUpon}` : null,
|
|
153
165
|
].filter((x) => x !== null);
|
|
154
|
-
lines.push(` vbproj に登録: ${r.vbproj} ← ${r.file}${extra.length > 0 ? ` (${extra.join(", ")})` : ""}`);
|
|
166
|
+
lines.push(` ${labelOfProject(r.vbproj)} に登録: ${r.vbproj} ← ${r.file}${extra.length > 0 ? ` (${extra.join(", ")})` : ""}`);
|
|
155
167
|
}
|
|
156
168
|
for (const n of plan.notes)
|
|
157
|
-
lines.push(`
|
|
169
|
+
lines.push(` ${n.label}: ${n.file} — ${n.message}`);
|
|
158
170
|
return lines;
|
|
159
171
|
}
|
package/dist/core/applier.js
CHANGED
|
@@ -8,6 +8,7 @@ import { EncodingError, decodeFile, encodeDocument, findUnencodable, makeDocumen
|
|
|
8
8
|
import { STAGE_LABEL, contentEqualsStage, findContentStage, findInsertionPresenceStage, matchBlock, } from "./matcher.js";
|
|
9
9
|
import { MASK_TOKEN, hasMaskToken, maskLinesForDisplay, maskedValueCounts, maskedViews, restoreMaskedLines, } from "./mask.js";
|
|
10
10
|
import { analyzeNearest } from "./nearest.js";
|
|
11
|
+
import { describeChars, foldToCp932 } from "./sjis.js";
|
|
11
12
|
/** Windows の予約デバイス名 (拡張子付きも不可) */
|
|
12
13
|
const WINDOWS_RESERVED = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..+)?$/i;
|
|
13
14
|
/** §9: プロジェクトルート相対のみ。絶対パス・`..`・`~`・Windows 特殊パスを拒否 */
|
|
@@ -75,6 +76,21 @@ function maskFailureMessage(prefix, r, options = {}) {
|
|
|
75
76
|
`伏せ字を含む行は SEARCH にも REPLACE にもそのまま写してください。${move}伏せ字を含む行を書き換える・新しく足す・` +
|
|
76
77
|
`コメントなどに ${MASK_TOKEN} と書く変更はできません (その行は変えずに残し、利用者に手で直してもらうよう説明してください)`);
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Shift_JIS のファイルに当てる行の「〜」(U+301C) などを、Windows の Shift_JIS (CP932) の対応する文字
|
|
81
|
+
* (「~」U+FF5E など。sjis.ts の CP932_EQUIVALENTS) にそろえる。Shift_JIS のファイルをデコードした行には
|
|
82
|
+
* キーの側の文字は現れず、書くときもキーの側の文字は変換できないため、そろえても一致・書き込みの結果が
|
|
83
|
+
* 悪くなることはない (そろえなければ SEARCH は一致せず、REPLACE は変換できないエラーになる)
|
|
84
|
+
*/
|
|
85
|
+
function foldLinesToCp932(lines) {
|
|
86
|
+
const folded = [];
|
|
87
|
+
const out = lines.map((line) => {
|
|
88
|
+
const r = foldToCp932(line);
|
|
89
|
+
folded.push(...r.folded);
|
|
90
|
+
return r.text;
|
|
91
|
+
});
|
|
92
|
+
return { lines: out, folded };
|
|
93
|
+
}
|
|
78
94
|
/**
|
|
79
95
|
* 抜粋の行のうち「複数行にまたがる値を伏せた範囲にかかる行」に印を付ける。伏せ字のある SEARCH は伏せた
|
|
80
96
|
* 表示で照合し、その範囲の行を含む一致は採らない (伏せ字のない SEARCH は実ファイルで照合するので一致する)。
|
|
@@ -151,6 +167,17 @@ function planReplace(change, state, fallbackEol, options) {
|
|
|
151
167
|
const failures = [];
|
|
152
168
|
const applied = [];
|
|
153
169
|
const already = [];
|
|
170
|
+
// Shift_JIS のファイルでは SEARCH / REPLACE の「〜」などを CP932 の文字にそろえる (照合・書き込みとも)
|
|
171
|
+
const sjisTarget = doc.encoding === "shift_jis";
|
|
172
|
+
const blocks = change.blocks.map((original) => {
|
|
173
|
+
if (!sjisTarget)
|
|
174
|
+
return { block: original, folded: [] };
|
|
175
|
+
const search = foldLinesToCp932(original.search);
|
|
176
|
+
const replace = foldLinesToCp932(original.replace);
|
|
177
|
+
if (search.folded.length === 0 && replace.folded.length === 0)
|
|
178
|
+
return { block: original, folded: [] };
|
|
179
|
+
return { block: { ...original, search: search.lines, replace: replace.lines }, folded: replace.folded };
|
|
180
|
+
});
|
|
154
181
|
let docLines = doc.lines;
|
|
155
182
|
let textLines = docLines.map((l) => l.text);
|
|
156
183
|
const original = textLines;
|
|
@@ -203,7 +230,7 @@ function planReplace(change, state, fallbackEol, options) {
|
|
|
203
230
|
}
|
|
204
231
|
return sets.size;
|
|
205
232
|
};
|
|
206
|
-
for (const block of
|
|
233
|
+
for (const { block, folded } of blocks) {
|
|
207
234
|
let m = matchBlock(textLines, block);
|
|
208
235
|
if (block.search.some(hasMaskToken) && (m.ok || m.reason === "not-found")) {
|
|
209
236
|
// SEARCH の [MASKED] は伏せた表示となら一致する (パックから写した行)。実ファイルで
|
|
@@ -338,7 +365,7 @@ function planReplace(change, state, fallbackEol, options) {
|
|
|
338
365
|
failures.push({
|
|
339
366
|
path: change.path,
|
|
340
367
|
kind: "unencodable",
|
|
341
|
-
message: `ブロック ${block.index}: REPLACE 側に Shift_JIS へ変換できない文字が含まれています: ${bad
|
|
368
|
+
message: `ブロック ${block.index}: REPLACE 側に Shift_JIS へ変換できない文字が含まれています: ${describeChars(bad)}`,
|
|
342
369
|
block,
|
|
343
370
|
});
|
|
344
371
|
continue;
|
|
@@ -351,6 +378,7 @@ function planReplace(change, state, fallbackEol, options) {
|
|
|
351
378
|
inserted: replacement,
|
|
352
379
|
...(restoredMasks > 0 ? { restoredMasks } : {}),
|
|
353
380
|
...(literalMasks > 0 ? { literalMasks } : {}),
|
|
381
|
+
...(folded.length > 0 ? { sjisFolded: folded } : {}),
|
|
354
382
|
});
|
|
355
383
|
// 書いた行の provenance: 元の値に戻した行は戻す元の行、SEARCH の範囲の行を (インデント以外)
|
|
356
384
|
// そのまま残した行はその行。どちらでもなければ新しい行
|
|
@@ -406,7 +434,8 @@ function planFile(change, state, newFile, options) {
|
|
|
406
434
|
if (state.bytes !== null) {
|
|
407
435
|
try {
|
|
408
436
|
const doc = decodeFile(state.bytes);
|
|
409
|
-
|
|
437
|
+
const expected = doc.encoding === "shift_jis" ? foldLinesToCp932(change.content).lines : change.content;
|
|
438
|
+
if (contentEqualsStage(doc.lines.map((l) => l.text), expected) !== null) {
|
|
410
439
|
return fileAlreadyApplied(change);
|
|
411
440
|
}
|
|
412
441
|
}
|
|
@@ -429,11 +458,12 @@ function planFile(change, state, newFile, options) {
|
|
|
429
458
|
return outcome;
|
|
430
459
|
}
|
|
431
460
|
const createLiteral = maskedContent.reduce((n, line) => n + line.split(MASK_TOKEN).length - 1, 0);
|
|
432
|
-
const
|
|
461
|
+
const created = newFile.encoding === "shift_jis" ? foldLinesToCp932(change.content) : { lines: change.content, folded: [] };
|
|
462
|
+
const bad = findUnencodable(created.lines.join("\n"), newFile.encoding);
|
|
433
463
|
if (bad.length > 0) {
|
|
434
|
-
return fileFailure(change, "unencodable", `新規ファイルの既定エンコーディング (${newFile.encoding}) に変換できない文字: ${bad
|
|
464
|
+
return fileFailure(change, "unencodable", `新規ファイルの既定エンコーディング (${newFile.encoding}) に変換できない文字: ${describeChars(bad)}`);
|
|
435
465
|
}
|
|
436
|
-
const doc = makeDocument(
|
|
466
|
+
const doc = makeDocument(created.lines, newFile);
|
|
437
467
|
return {
|
|
438
468
|
change,
|
|
439
469
|
failures: [],
|
|
@@ -443,6 +473,7 @@ function planFile(change, state, newFile, options) {
|
|
|
443
473
|
alreadyApplied: false,
|
|
444
474
|
totalBlocks: 0,
|
|
445
475
|
...(createLiteral > 0 ? { literalMasks: createLiteral } : {}),
|
|
476
|
+
...(created.folded.length > 0 ? { sjisFolded: created.folded } : {}),
|
|
446
477
|
};
|
|
447
478
|
}
|
|
448
479
|
case "rewrite": {
|
|
@@ -457,7 +488,9 @@ function planFile(change, state, newFile, options) {
|
|
|
457
488
|
return fileFailure(change, "undecodable", e instanceof EncodingError ? e.message : String(e));
|
|
458
489
|
}
|
|
459
490
|
const current = doc.lines.map((l) => l.text);
|
|
460
|
-
|
|
491
|
+
// Shift_JIS のファイルでは「〜」などを CP932 の文字にそろえる (planReplace と同じ)
|
|
492
|
+
const rewritten = doc.encoding === "shift_jis" ? foldLinesToCp932(change.content) : { lines: change.content, folded: [] };
|
|
493
|
+
let content = rewritten.lines;
|
|
461
494
|
let restoredMasks = 0;
|
|
462
495
|
let literalMasks = 0;
|
|
463
496
|
if (content.some(hasMaskToken)) {
|
|
@@ -484,7 +517,7 @@ function planFile(change, state, newFile, options) {
|
|
|
484
517
|
}
|
|
485
518
|
const bad = findUnencodable(content.join("\n"), doc.encoding);
|
|
486
519
|
if (bad.length > 0) {
|
|
487
|
-
return fileFailure(change, "unencodable", `Shift_JIS へ変換できない文字が含まれています: ${bad
|
|
520
|
+
return fileFailure(change, "unencodable", `Shift_JIS へ変換できない文字が含まれています: ${describeChars(bad)}`);
|
|
488
521
|
}
|
|
489
522
|
// 既存のエンコーディング・BOM・支配的 EOL・末尾改行の有無を維持して全文を差し替える (§8)
|
|
490
523
|
const lines = content.map((text) => ({ text, raw: null, eol: null }));
|
|
@@ -499,6 +532,7 @@ function planFile(change, state, newFile, options) {
|
|
|
499
532
|
totalBlocks: 0,
|
|
500
533
|
...(restoredMasks > 0 ? { restoredMasks } : {}),
|
|
501
534
|
...(literalMasks > 0 ? { literalMasks } : {}),
|
|
535
|
+
...(rewritten.folded.length > 0 ? { sjisFolded: rewritten.folded } : {}),
|
|
502
536
|
};
|
|
503
537
|
}
|
|
504
538
|
case "delete": {
|
package/dist/core/encoding.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* これにより Shift_JIS の重複マッピング (NEC/IBM 拡張等) があっても、
|
|
7
7
|
* 触っていない行のバイト列は原理的に変わらない。再エンコードは変更行のみ。
|
|
8
8
|
*/
|
|
9
|
-
import { sjisEncode } from "./sjis.js";
|
|
9
|
+
import { describeChars, sjisEncode } from "./sjis.js";
|
|
10
10
|
export class EncodingError extends Error {
|
|
11
11
|
}
|
|
12
12
|
const BOM = Uint8Array.of(0xef, 0xbb, 0xbf);
|
|
@@ -120,7 +120,7 @@ function encodeText(text, encoding) {
|
|
|
120
120
|
return new TextEncoder().encode(text);
|
|
121
121
|
const { bytes, unencodable } = sjisEncode(text);
|
|
122
122
|
if (unencodable.length > 0) {
|
|
123
|
-
throw new EncodingError(`Shift_JIS に変換できない文字が含まれています: ${unencodable
|
|
123
|
+
throw new EncodingError(`Shift_JIS に変換できない文字が含まれています: ${describeChars(unencodable)}`);
|
|
124
124
|
}
|
|
125
125
|
return bytes;
|
|
126
126
|
}
|