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>
119 lines
5.1 KiB
JavaScript
119 lines
5.1 KiB
JavaScript
/**
|
||
* remove-status-300-492045.js
|
||
* ------------------------------------------------------------
|
||
* site-492045(四者MTG回覧)専用の一回限りスクリプト。
|
||
* 「日程回覧発行」プロセス削除に伴い使われなくなったStatus選択肢
|
||
* "300,日程回覧,日程,status-green" を Columns の Status 列 ChoicesText から除去し、
|
||
* updatesite(全体更新)で送信する。Processes/Scripts/Styles/ServerScripts/Links等
|
||
* それ以外のSiteSettingsは取得した生JSONの値をそのまま維持する。
|
||
*
|
||
* 使い方:
|
||
* node remove-status-300-492045.js --project="MSS回覧板システム" --env=production … プレビューのみ
|
||
* node remove-status-300-492045.js --project="MSS回覧板システム" --env=production --execute … 実際に送信
|
||
* ------------------------------------------------------------
|
||
*/
|
||
|
||
const fs = require("fs");
|
||
const path = require("path");
|
||
const { findSiteDir, newModifyDir } = require("../../site-paths");
|
||
const { resolveProjectRoot, loadServerConfig } = require("../../resolve-project");
|
||
|
||
const SITE_ID = "492045";
|
||
const REMOVE_LINE = "300,日程回覧,日程,status-green";
|
||
|
||
const { baseDir, env } = resolveProjectRoot();
|
||
const execute = process.argv.includes("--execute");
|
||
|
||
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 statusCol = siteSettings.Columns.find((c) => c.ColumnName === "Status");
|
||
if (!statusCol) {
|
||
console.error("[エラー] Status列が見つかりません。");
|
||
process.exit(1);
|
||
}
|
||
|
||
console.log("========================================");
|
||
console.log(` Status選択肢「300:日程回覧」削除(updatesite全体更新)${execute ? "(実行)" : "(プレビューのみ)"}`);
|
||
console.log("========================================");
|
||
console.log("--- 変更前 ChoicesText ---");
|
||
console.log(statusCol.ChoicesText);
|
||
|
||
const lines = statusCol.ChoicesText.split("\n").filter((l) => l.trim() !== REMOVE_LINE);
|
||
if (lines.length === statusCol.ChoicesText.split("\n").length) {
|
||
console.error(`[エラー] 削除対象の行が見つかりませんでした: ${REMOVE_LINE}`);
|
||
process.exit(1);
|
||
}
|
||
statusCol.ChoicesText = lines.join("\n");
|
||
|
||
console.log("--- 変更後 ChoicesText ---");
|
||
console.log(statusCol.ChoicesText);
|
||
console.log("他のColumns項目・Processes/Scripts/Styles/ServerScripts/Links等は一切変更しません。");
|
||
|
||
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, "remove-status-300");
|
||
const ts = timestamp();
|
||
const maskedBody = { ...body, ApiKey: maskApiKey(body.ApiKey) };
|
||
const previewPath = path.join(modifyDir, `site-${SITE_ID}_status300_removal_preview_${ts}.json`);
|
||
fs.writeFileSync(previewPath, JSON.stringify(maskedBody, null, 2), "utf-8");
|
||
console.log(`\n[OK] 送信予定内容を保存しました: ${previewPath}`);
|
||
|
||
if (!execute) {
|
||
console.log("\n[注意] --execute が指定されていないため、送信は行っていません。");
|
||
console.log("内容を確認の上、問題なければ次を実行してください: node remove-status-300-492045.js --project=... --env=... --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}_status300_removal_result_${ts}.json`);
|
||
fs.writeFileSync(resultOutPath, text, "utf-8");
|
||
|
||
console.log(`HTTP ${res.status} ${res.statusText}`);
|
||
console.log(`[OK] 応答を保存しました: ${resultOutPath}`);
|
||
console.log(text);
|
||
})();
|