ken_nogi/Pleasanter/.claude/js/xwiki/upload-189112-spec.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

82 lines
3.0 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.

const fs = require("fs");
const ENV_PATH = "c:/Users/k.nogi/#GitHub/NodeSrv/apps/xwiki/.env";
function loadEnv(p) {
const text = fs.readFileSync(p, "utf8");
const env = {};
for (const line of text.split(/\r?\n/)) {
const m = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
if (!m) continue;
let v = m[2];
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
v = v.slice(1, -1);
}
env[m[1]] = v;
}
return env;
}
const env = loadEnv(ENV_PATH);
const BASE_URL = env.XWIKI_BASE_URL;
const AUTH = "Basic " + Buffer.from(`${env.XWIKI_ADMIN_USER}:${env.XWIKI_ADMIN_PASSWORD}`).toString("base64");
const WIKI_ID = "admin";
function xmlEscape(s) {
return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function buildUrl(spacePath) {
const segs = spacePath.map((s) => "spaces/" + encodeURIComponent(s));
return `${BASE_URL}/rest/wikis/${WIKI_ID}/${segs.join("/")}/pages/WebHome`;
}
async function putPage(spacePath, title, content) {
const url = buildUrl(spacePath);
const body = `<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://www.xwiki.org">
<title>${xmlEscape(title)}</title>
<syntax>markdown/1.2</syntax>
<content>${xmlEscape(content)}</content>
</page>`;
const res = await fetch(url, {
method: "PUT",
headers: { "Content-Type": "application/xml; charset=utf-8", Authorization: AUTH },
body,
});
const text = await res.text();
return { status: res.status, ok: res.status === 201 || res.status === 202, url, text };
}
const SPEC_PATH =
"c:/Users/k.nogi/#GitHub/ken_nogi/ClaudePleasanter/★マスターシート/configs/site-189112_★マスターシート/docs/site-189112_spec.md";
const PARENT_SPACE = ["プリザンター", "nextoffice", "96230_【新版】注文住宅MSS", "189112_★マスターシート"];
async function main() {
const specContent = fs.readFileSync(SPEC_PATH, "utf8");
// 1. 子ページとして仕様書を投入
const specSpace = PARENT_SPACE.concat("仕様書");
const r1 = await putPage(specSpace, "仕様書★マスターシートSiteId: 189112", specContent);
console.log(`[${r1.ok ? "OK" : "NG"} ${r1.status}] ${specSpace.join(" / ")}`);
if (!r1.ok) console.log(r1.text.slice(0, 500));
// 2. 親ページ(WebHome)を更新して子ページへのリンクを追記
const parentContent = [
"# ★マスターシートSiteId:189112",
"",
"- SiteId: 189112",
"- Pleasanter環境: https://nextoffice.next-hd.co.jp/pleasanter/",
"- リポジトリ内パス: `★マスターシート/configs/site-189112_★マスターシート`",
"",
"## 保存済みファイル",
"- [[仕様書]] : サイト仕様書(項目定義・権限・スクリプト等)。2026-08-16投入。",
].join("\n");
const r2 = await putPage(PARENT_SPACE, "★マスターシートSiteId:189112", parentContent);
console.log(`[${r2.ok ? "OK" : "NG"} ${r2.status}] ${PARENT_SPACE.join(" / ")}`);
if (!r2.ok) console.log(r2.text.slice(0, 500));
}
main();