Files
agent/scripts/verify-private-cms.mjs

19 lines
923 B
JavaScript

import { createInterface } from "node:readline";
import { CmsConnection } from "../packages/harness/dist/index.js";
console.log("Provide CMS email, password and publishableKey as one JSON line on hidden stdin.");
const reader = createInterface({ input: process.stdin });
let cms;
try {
const input = JSON.parse((await reader[Symbol.asyncIterator]().next()).value);
reader.close();
cms = new CmsConnection({ publishableKey: input.publishableKey });
const result = await cms.login(input.email, input.password);
input.password = "";
const catalog = await cms.listDramas("", 0);
console.log(JSON.stringify({ connected: result.connected, project: result.project, firstPageCount: catalog.dramas.length, credentialOutput: false }));
} catch (error) {
console.error(JSON.stringify({ status: "failed", code: error?.code ?? "CMS_PROBE_FAILED" }));
process.exitCode = 1;
} finally { reader.close(); cms?.clear(); }