ken_nogi/ClaudePleasanter/営業積算システム/build-full-335411-attach061fix.js
Kenichiro NOGI ed33892f08 chore: 作業中の変更を整理しコミット(複数プロジェクト分)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-02 11:09:50 +09:00

81 lines
3.7 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// site-335411向け Attachments061 のCSS適用箇所修復送信はしない・プレビュー専用
// ユーザーが他8項目Date061/Class061/Class062/Date062/Class063/Date063/Class065/Description061
// 管理画面から FieldCss ではなく ExtendedFieldCss に "code-readonly2" を設定する形へ手動で直したが、
// Attachments061だけは管理画面のUIから直せないため、同じパターンをコマンドで適用する。
// - FieldCss: "code-readonly2" を削除(元は未設定だったため)
// - ExtendedFieldCss: "code-readonly2" を新規追加
// Scripts/Styles/ServerScripts/Processesは現状のconfigsフォルダの内容をそのまま使う変更なし
// Attachments061以外のColumnsは一切変更しない。
const fs = require("fs");
const path = require("path");
function main() {
const baseDir = __dirname;
const modifyRel = process.argv[2];
if (!modifyRel) {
console.error("[エラー] 出力先の modify フォルダを指定してください");
process.exit(1);
}
const siteId = 335411;
const siteDir = path.join(baseDir, "configs", "site-335411_②問い合わせ内容管理 Ver0.3");
const outDir = path.isAbsolute(modifyRel) ? modifyRel : path.join(siteDir, modifyRel);
const latest = JSON.parse(
fs.readFileSync(path.join(baseDir, "siteSettingJsons", `site-${siteId}_latest.json`), "utf8")
);
const d = latest.Response.Data;
const manifest = JSON.parse(fs.readFileSync(path.join(siteDir, "manifest.json"), "utf8"));
fs.mkdirSync(outDir, { recursive: true });
fs.writeFileSync(path.join(outDir, `before_site-${siteId}_latest.json`), JSON.stringify(latest, null, 2), "utf-8");
const siteSettings = JSON.parse(JSON.stringify(d.SiteSettings));
function rebuildList(manifestEntries, dir) {
return (manifestEntries || []).map((entry) => {
const { File, ...meta } = entry;
const body = fs.readFileSync(path.join(siteDir, dir, File), "utf-8");
return { ...meta, Body: body };
});
}
siteSettings.Scripts = rebuildList(manifest.Scripts, "scripts");
siteSettings.Styles = rebuildList(manifest.Styles, "styles");
siteSettings.ServerScripts = rebuildList(manifest.ServerScripts, "serverscripts");
const processesPath = path.join(siteDir, manifest.ProcessesFile || "processes.json");
siteSettings.Processes = fs.existsSync(processesPath) ? JSON.parse(fs.readFileSync(processesPath, "utf8")) : [];
let changeLog = null;
siteSettings.Columns = siteSettings.Columns.map((col) => {
if (col.ColumnName !== "Attachments061") return col;
const before = { FieldCss: col.FieldCss, ExtendedFieldCss: col.ExtendedFieldCss };
const { FieldCss, ...rest } = col;
const after = { ...rest, ExtendedFieldCss: "code-readonly2" };
changeLog = { before, after: { FieldCss: after.FieldCss, ExtendedFieldCss: after.ExtendedFieldCss } };
return after;
});
const body = {
ApiVersion: "1.1",
ApiKey: "***(送信時にconfig.jsonから読み込み。プレビューJSONには含めません)***",
TenantId: d.TenantId,
SiteId: d.SiteId,
Title: d.Title,
ReferenceType: d.ReferenceType,
ParentId: d.ParentId,
InheritPermission: d.InheritPermission,
SiteSettings: siteSettings,
};
fs.writeFileSync(path.join(outDir, "desired_body_full.json"), JSON.stringify(body, null, 2), "utf-8");
console.log("[OK] 生成しました:", path.join(outDir, "desired_body_full.json"));
console.log("\n=== Attachments061 変更内容 ===");
console.log("変更前:", JSON.stringify(changeLog.before));
console.log("変更後:", JSON.stringify(changeLog.after));
console.log("\n次のステップ: 内容確認後、send-335411-full.js相当のスクリプトで送信してください。");
}
main();