This project allows you to create and test multiple automation scripts using Pluto.
npm run add-script my-script-name
This will:
- Create a
scripts/my-script-name/
directory - Generate a
main.ts
file with a basic template - Add npm commands to your
package.json
# Development mode (builds + watches your script, runs test app)
npm run dev:my-script-name
# Build only
npm run build:my-script-name
├── scripts/ # Your automation scripts
│ ├── my-script/
│ │ ├── main.ts # Your script code
│ │ └── dist/ # Built output
├── test-app/ # React app for testing scripts
├── config/ # Build configuration & tools
│ ├── vite.config.scripts.ts # Vite build config
│ ├── tsconfig.json # TypeScript config
│ ├── add-script.js # Helper to create new scripts
│ └── main.template.ts # Template for new scripts
└── package.json # Project configuration
npm run add-script <name>
- Create a new scriptnpm run dev:<script-name>
- Develop a specific scriptnpm run build:<script-name>
- Build a specific script
Your scripts should be written in TypeScript and export automation logic using Pluto's APIs. See main.ts
for a basic template.
Example:
import { createSession } from "@plutoxyz/automation";
import { chromium } from "playwright-core";
import { createPlutoPage } from "@plutoxyz/automation-utils";
const session = await createSession();
const browser = await chromium.connectOverCDP(await session.cdp());
const context = browser.contexts()[0];
const page = createPlutoPage(context);
// Your automation logic here...
await session.prove("my-data", [{ result: "success" }]);
await browser.close();