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>
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
"use strict";
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { fetchAccessToken } = require("../lib/lineworksAuth");
|
|
const lineworksClient = require("../lib/lineworksClient");
|
|
|
|
async function buildSnapshot(auth, deps = {}) {
|
|
const {
|
|
fetchAccessToken: fetchToken = fetchAccessToken,
|
|
fetchUsers = lineworksClient.fetchUsers,
|
|
fetchOrgUnits = lineworksClient.fetchOrgUnits,
|
|
fetchPositions = lineworksClient.fetchPositions,
|
|
fetchLevels = lineworksClient.fetchLevels,
|
|
fetchUserTypes = lineworksClient.fetchUserTypes,
|
|
now = () => new Date(),
|
|
} = deps;
|
|
|
|
const accessToken = await fetchToken(auth);
|
|
const [users, orgUnits, positions, levels, userTypes] = await Promise.all([
|
|
fetchUsers({ accessToken }),
|
|
fetchOrgUnits({ accessToken }),
|
|
fetchPositions({ accessToken }),
|
|
fetchLevels({ accessToken }),
|
|
fetchUserTypes({ accessToken }),
|
|
]);
|
|
|
|
return { fetchedAt: now().toISOString(), users, orgUnits, positions, levels, userTypes };
|
|
}
|
|
|
|
async function main() {
|
|
const privateKey = fs.readFileSync(process.env.LW_PRIVATE_KEY_FILE, "utf8");
|
|
const snapshot = await buildSnapshot({
|
|
clientId: process.env.LW_CLIENT_ID,
|
|
clientSecret: process.env.LW_CLIENT_SECRET,
|
|
serviceAccount: process.env.LW_SERVICE_ACCOUNT,
|
|
privateKey,
|
|
scope: process.env.LW_SCOPE,
|
|
});
|
|
|
|
const outDir = path.join(__dirname, "..", "..", "data", "master-source");
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
const outPath = path.join(outDir, "lineworks-snapshot.json");
|
|
fs.writeFileSync(outPath, JSON.stringify(snapshot, null, 2));
|
|
|
|
console.log(`[OK] ${outPath}`);
|
|
console.log(`users=${snapshot.users.length} orgUnits=${snapshot.orgUnits.length} positions=${snapshot.positions.length} levels=${snapshot.levels.length} userTypes=${snapshot.userTypes.length}`);
|
|
}
|
|
|
|
module.exports = { buildSnapshot };
|
|
|
|
if (require.main === module) {
|
|
main().catch((e) => { console.error(e); process.exit(1); });
|
|
}
|