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>
96 lines
3.6 KiB
JavaScript
96 lines
3.6 KiB
JavaScript
// org-master-sync代替マスタ: グループ(504738)へ「無効」フラグ列(CheckA)を追加するワンショットスクリプト。
|
|
// 既存Columns(ClassA/ClassB/Description001/Description002)はそのまま維持し、CheckAのみ末尾に追加する。
|
|
// --execute指定時のみ実際に送信。指定なければプレビュー(送信Body)のみ出力。
|
|
"use strict";
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const PROJECT_NAME = "org-master-sync代替マスタ";
|
|
const ENV = "staging";
|
|
const REPO_ROOT = path.join(__dirname, "..", "..", "..", "..");
|
|
const PROJECT_ROOT = path.join(REPO_ROOT, PROJECT_NAME);
|
|
|
|
function loadServerConfig() {
|
|
const configPath = path.join(REPO_ROOT, `config_${ENV}.json`);
|
|
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
if (!config.BaseUrl || !config.ApiKey) {
|
|
console.error(`[エラー] ${configPath} に BaseUrl / ApiKey を設定してください。`);
|
|
process.exit(1);
|
|
}
|
|
return config;
|
|
}
|
|
|
|
function siteDir(siteId, siteName) {
|
|
return path.join(PROJECT_ROOT, "configs", ENV, `site-${siteId}_${siteName}`);
|
|
}
|
|
|
|
function loadLatest(siteId, siteName) {
|
|
const p = path.join(siteDir(siteId, siteName), "sitesettings", `site-${siteId}_latest.json`);
|
|
const raw = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
return raw.Response.Data;
|
|
}
|
|
|
|
const SITE_ID = 504738;
|
|
const SITE_NAME = "グループ";
|
|
|
|
function buildDesiredSiteSettings(current) {
|
|
const settings = JSON.parse(JSON.stringify(current.SiteSettings));
|
|
const already = settings.Columns.some((c) => c.ColumnName === "CheckA");
|
|
if (!already) {
|
|
settings.Columns.push({ ColumnName: "CheckA", LabelText: "無効" });
|
|
}
|
|
settings.GridColumns = ["ResultId", "ClassA", "ClassB", "CheckA", "Updator", "UpdatedTime"];
|
|
settings.EditorColumnHash = {
|
|
General: ["ResultId", "Ver", "ClassA", "ClassB", "Description001", "Description002", "CheckA"],
|
|
};
|
|
settings.Links = current.SiteSettings.Links || [];
|
|
return settings;
|
|
}
|
|
|
|
function buildUpdateBody(apiKey, siteId, current, desiredSettings) {
|
|
return {
|
|
ApiVersion: "1.1",
|
|
ApiKey: apiKey,
|
|
SiteId: siteId,
|
|
Title: current.Title,
|
|
ReferenceType: current.ReferenceType,
|
|
ParentId: current.ParentId,
|
|
InheritPermission: current.InheritPermission,
|
|
SiteSettings: desiredSettings,
|
|
};
|
|
}
|
|
|
|
const execute = process.argv.includes("--execute");
|
|
const server = loadServerConfig();
|
|
|
|
(async () => {
|
|
const current = loadLatest(SITE_ID, SITE_NAME);
|
|
const desiredSettings = buildDesiredSiteSettings(current);
|
|
const body = buildUpdateBody(server.ApiKey, SITE_ID, current, desiredSettings);
|
|
|
|
const outDir = siteDir(SITE_ID, SITE_NAME);
|
|
const previewPath = path.join(outDir, "add-disabled-column_preview.json");
|
|
fs.writeFileSync(previewPath, JSON.stringify(body, null, 2), "utf-8");
|
|
|
|
console.log(`==== SiteId ${SITE_ID} (${SITE_NAME}) ====`);
|
|
console.log("追加する項目: CheckA: 無効");
|
|
console.log(`プレビュー保存先: ${previewPath}`);
|
|
|
|
if (!execute) {
|
|
console.log("(--execute 未指定のためプレビューのみ。送信していません)");
|
|
return;
|
|
}
|
|
|
|
const url = `${server.BaseUrl}api/items/${SITE_ID}/updatesite`;
|
|
console.log(`送信先: ${url}`);
|
|
const res = await fetch(url, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
});
|
|
const json = await res.json();
|
|
console.log(`[結果] HTTP ${res.status}:`, JSON.stringify(json));
|
|
const resultPath = path.join(outDir, `add-disabled-column_result_${Date.now()}.json`);
|
|
fs.writeFileSync(resultPath, JSON.stringify(json, null, 2), "utf-8");
|
|
})();
|