21 lines
812 B
TypeScript
21 lines
812 B
TypeScript
|
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||
|
|
|
||
|
|
import { readDraftsFile, exportDrafts } from "../src/index.js";
|
||
|
|
|
||
|
|
const args = process.argv.slice(2);
|
||
|
|
const draftsFile = args.find(a => a.startsWith("--drafts="))?.split("=")[1];
|
||
|
|
const workflowId = args.find(a => a.startsWith("--workflow-id="))?.split("=")[1] || "unknown";
|
||
|
|
const from = args.find(a => a.startsWith("--from="))?.split("=")[1];
|
||
|
|
const dryRun = args.includes("--dry-run");
|
||
|
|
|
||
|
|
if (!draftsFile) {
|
||
|
|
console.error("Usage: bun run export -- --drafts=<path.json> --workflow-id=<id> [--from=<email>] [--dry-run]");
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
const drafts = await readDraftsFile(draftsFile);
|
||
|
|
console.log(`Exporting ${drafts.length} drafts...`);
|
||
|
|
|
||
|
|
const result = await exportDrafts(drafts, workflowId, { from, dryRun });
|
||
|
|
console.log(JSON.stringify(result, null, 2));
|