ken_nogi/Pleasanter/.claude/js/site-scripts/MSS回覧板システム/hide-datea-dated-492045.js
Kenichiro NOGI ce58cb4be4 初回コミット: dev配下(NodeSrv/Pleasanter等)をGitea管理下に統合
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>
2026-09-04 15:37:06 +09:00

114 lines
4.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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.

/**
* hide-datea-dated-492045.js
* ------------------------------------------------------------
* site-492045四者MTG回覧専用の一回限りスクリプト。
* 「日程回覧発行」プロセス削除に伴い使用しなくなった DateA回覧発行日
* DateD四者日程を Columns の Hide フラグを立てて非表示化する。
* updatesite全体更新で送信する。EditorColumnHash / GridColumns等
* それ以外のSiteSettingsは取得した生JSONの値をそのまま維持する。
*
* 使い方:
* node hide-datea-dated-492045.js --project="MSS回覧板システム" --env=production … プレビューのみ
* node hide-datea-dated-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 TARGET_COLUMNS = ["DateA", "DateD"];
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));
console.log("========================================");
console.log(` DateA/DateD 非表示化updatesite全体更新${execute ? "(実行)" : "(プレビューのみ)"}`);
console.log("========================================");
for (const name of TARGET_COLUMNS) {
const col = siteSettings.Columns.find((c) => c.ColumnName === name);
if (!col) {
console.error(`[エラー] 列が見つかりません: ${name}`);
process.exit(1);
}
console.log(`--- ${name}${col.LabelText} ---`);
console.log(`変更前: ${JSON.stringify(col)}`);
col.Hide = true;
console.log(`変更後: ${JSON.stringify(col)}`);
}
console.log("EditorColumnHash / GridColumns / Processes / Scripts等は一切変更しません。");
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, "hide-datea-dated");
const ts = timestamp();
const maskedBody = { ...body, ApiKey: maskApiKey(body.ApiKey) };
const previewPath = path.join(modifyDir, `site-${SITE_ID}_hide_datea_dated_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 hide-datea-dated-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}_hide_datea_dated_result_${ts}.json`);
fs.writeFileSync(resultOutPath, text, "utf-8");
console.log(`HTTP ${res.status} ${res.statusText}`);
console.log(`[OK] 応答を保存しました: ${resultOutPath}`);
console.log(text);
})();