/ clis / doubao-app / dump.js
dump.js
 1  import * as fs from 'node:fs';
 2  import { cli, Strategy } from '@jackwener/opencli/registry';
 3  export const dumpCommand = cli({
 4      site: 'doubao-app',
 5      name: 'dump',
 6      description: 'Dump Doubao desktop app DOM and snapshot to /tmp for debugging',
 7      domain: 'doubao-app',
 8      strategy: Strategy.UI,
 9      browser: true,
10      args: [],
11      columns: ['Status', 'File'],
12      func: async (page) => {
13          const htmlPath = '/tmp/doubao-dom.html';
14          const snapPath = '/tmp/doubao-snapshot.json';
15          const html = await page.evaluate('document.documentElement.outerHTML');
16          const snap = await page.snapshot({ compact: true });
17          fs.writeFileSync(htmlPath, html);
18          fs.writeFileSync(snapPath, typeof snap === 'string' ? snap : JSON.stringify(snap, null, 2));
19          return [
20              { Status: 'Success', File: htmlPath },
21              { Status: 'Success', File: snapPath },
22          ];
23      },
24  });