GitHub(nextgroup2706/ken_nogi)は今後使わず自社Gitea運用に切替え。 NodeSrvは旧リポジトリの履歴を破棄しファイルのみ統合(Dokploy用サービスアカウントは 別途mygit-admin/NodeSrv.gitに履歴あり)。notepmエクスポート(12GB)とPleasanter インストーラzip(208MB)はサイズが大きいため.gitignoreで除外。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
123 lines
5.3 KiB
JavaScript
123 lines
5.3 KiB
JavaScript
/**
|
||
* restructure-site-335603.js
|
||
* ------------------------------------------------------------
|
||
* SiteId 335603(問い合わせ不要理由テンプレ管理)は遅延理由テンプレ管理(335450)の
|
||
* コピーとして発行済みだが、ClassAのLabelText/ChoicesTextが「遅延理由」のまま残っている。
|
||
* これを「不要理由」用に書き換える(Task1)。
|
||
* ChoicesText(遅延理由固有の5選択肢)は意味が変わるためクリアし、
|
||
* 実際の不要理由分類はユーザーがレコード投入時に決める運用とする。
|
||
*
|
||
* 使い方:
|
||
* node restructure-site-335603.js … 差分表示のみ(送信なし)
|
||
* node restructure-site-335603.js --execute … 実際に送信する
|
||
* ------------------------------------------------------------
|
||
*/
|
||
|
||
const fs = require("fs");
|
||
const path = require("path");
|
||
const { findSiteDir, newModifyDir } = require("../../site-paths");
|
||
const { REPO_ROOT, loadServerConfig } = require("../../resolve-project");
|
||
|
||
const PROJECT_NAME = "営業積算システム";
|
||
const ENV = "development"; // このサイトはテストサーバー(neo999.next-hd.net)専用
|
||
const baseDir = path.join(REPO_ROOT, PROJECT_NAME);
|
||
const execute = process.argv.includes("--execute");
|
||
const SITE_ID = 335603;
|
||
|
||
function loadJson(p) {
|
||
return JSON.parse(fs.readFileSync(p, "utf-8"));
|
||
}
|
||
|
||
function maskApiKey(key) {
|
||
if (!key) return key;
|
||
return key.length > 8 ? key.slice(0, 4) + "****" + key.slice(-4) : "****";
|
||
}
|
||
|
||
function timestamp() {
|
||
return new Date().toISOString().replace(/[:.]/g, "-");
|
||
}
|
||
|
||
const config = loadServerConfig(ENV);
|
||
const siteDir = findSiteDir(path.join(baseDir, "configs", ENV), SITE_ID);
|
||
|
||
(async () => {
|
||
console.log("[INFO] 現在のサイト情報を取得しています...");
|
||
const getUrl = `${config.BaseUrl.replace(/\/+$/, "")}/api/items/${SITE_ID}/getsite`;
|
||
const getRes = await fetch(getUrl, {
|
||
method: "POST",
|
||
headers: { "Content-Type": "application/json" },
|
||
body: JSON.stringify({ ApiVersion: config.ApiVersion || "1.1", ApiKey: config.ApiKey }),
|
||
});
|
||
const getJson = await getRes.json();
|
||
if (getJson.StatusCode !== 200) {
|
||
console.error("[エラー] getsiteに失敗しました:", JSON.stringify(getJson).slice(0, 500));
|
||
process.exit(1);
|
||
}
|
||
const data = getJson.Response.Data;
|
||
console.log(`[OK] 取得しました(現在のVer: ${data.Ver}, UpdatedTime: ${data.UpdatedTime})`);
|
||
|
||
const siteSettings = JSON.parse(JSON.stringify(data.SiteSettings));
|
||
|
||
const classA = (siteSettings.Columns || []).find((c) => c.ColumnName === "ClassA");
|
||
if (!classA) {
|
||
console.error("[エラー] ClassAが見つかりません。サイト構造が想定と異なります。");
|
||
process.exit(1);
|
||
}
|
||
|
||
console.log("========================================");
|
||
console.log(` ClassA LabelText/ChoicesText 差し替え(updatesite全体更新)${execute ? "(実行)" : "(プレビューのみ)"}`);
|
||
console.log("========================================");
|
||
console.log(` 変更前 LabelText : ${classA.LabelText}`);
|
||
console.log(` 変更前 ChoicesText : ${classA.ChoicesText}`);
|
||
|
||
classA.LabelText = "不要理由";
|
||
classA.ChoicesText = "";
|
||
|
||
console.log(` 変更後 LabelText : ${classA.LabelText}`);
|
||
console.log(` 変更後 ChoicesText : (クリア。実際の分類はユーザーが今後入力)`);
|
||
|
||
const body = {
|
||
ApiVersion: config.ApiVersion || "1.1",
|
||
ApiKey: config.ApiKey,
|
||
SiteId: SITE_ID,
|
||
Title: data.Title,
|
||
ReferenceType: data.ReferenceType,
|
||
ParentId: data.ParentId,
|
||
InheritPermission: data.InheritPermission,
|
||
Permissions: data.Permissions,
|
||
SiteSettings: siteSettings,
|
||
};
|
||
|
||
const modifyDir = newModifyDir(siteDir, `2026-08-11T${new Date().toTimeString().slice(0, 5).replace(":", "")}_ClassAラベル不要理由化`);
|
||
const ts = timestamp();
|
||
const maskedBody = { ...body, ApiKey: maskApiKey(body.ApiKey) };
|
||
const previewPath = path.join(modifyDir, `site-${SITE_ID}_full_update_preview_${ts}.json`);
|
||
fs.writeFileSync(previewPath, JSON.stringify(maskedBody, null, 2), "utf-8");
|
||
console.log(`\n[OK] 送信予定内容を保存しました: ${previewPath}`);
|
||
|
||
const beforePath = path.join(modifyDir, `before_site-${SITE_ID}_latest.json`);
|
||
fs.writeFileSync(beforePath, JSON.stringify(getJson, null, 2), "utf-8");
|
||
console.log(`[OK] 変更前スナップショットを保存しました: ${beforePath}`);
|
||
|
||
if (!execute) {
|
||
console.log("\n[注意] --execute が指定されていないため、送信は行っていません。");
|
||
console.log("内容を確認の上、問題なければ次を実行してください: node restructure-site-335603.js --execute");
|
||
process.exit(0);
|
||
}
|
||
|
||
console.log("\n実際に送信します(updatesite)...");
|
||
const url = `${config.BaseUrl.replace(/\/+$/, "")}/api/items/${SITE_ID}/updatesite`;
|
||
const res = await fetch(url, {
|
||
method: "POST",
|
||
headers: { "Content-Type": "application/json" },
|
||
body: JSON.stringify(body),
|
||
});
|
||
const text = await res.text();
|
||
const resultOutPath = path.join(modifyDir, `site-${SITE_ID}_full_update_result_${ts}.json`);
|
||
fs.writeFileSync(resultOutPath, text, "utf-8");
|
||
|
||
console.log(`HTTP ${res.status} ${res.statusText}`);
|
||
console.log(`[OK] 応答を保存しました: ${resultOutPath}`);
|
||
console.log(text);
|
||
})();
|