Releases: heyMP/scratchpad
Releases · heyMP/scratchpad
v1.0.0-next.11
Minor Changes
-
708f25e: Support ts config files
scratchpad.config.ts
import { Config } from "@heymp/scratchpad/src/config.js"; export function hi(name: string) { console.log(`Hi there ${name}`); } declare global { interface Window { hi: typeof hi; } } export default { playwright: async (args) => { const { context } = args; await context.exposeFunction("hi", hi); }, } satisfies Config;
test.ts
/// <reference path="./scratchpad.config.ts" /> window.hi('Bob');
v1.0.0-next.10
Patch Changes
- e628851: Fix cannot find package '@commander-js/extra-typings error.
v1.0.0-next.9
Patch Changes
- 556669b: Update Readme
v1.0.0-next.8
Major Changes
-
4aa2817: Add
generate config
command #38npx @heymp/scratchpad generate --help Usage: scratchpad generate [options] [command] Generate files from templates. Options: -h, --help display help for command Commands: config Generates an example config file. help [command] display help for command
-
4aa2817: Add
run
commandnpx @heymp/scratchpad run --help Usage: cli run [options] <file> Execute a file in a browser. Arguments: file file to execute in the browser. Options: --headless [boolean] specify running the browser in headless mode. --devtools [boolean] open browser devtools automatically. --ts-write [boolean] write the js output of the target ts file. --url [string] specify a specific url to execute the code in. -h, --help display help for command
Minor Changes
-
ea5b50d: Add
writeFile
,appendFile
exposed functions. (#44)[https://github.com//issues/44]await writeFile('./log.txt', 'hello'); await appendFile('./log.txt', '\n'); await appendFile('./log.txt', 'world');
Include custom exposed functions example.
import { join } from 'node:path' import fs from 'node:fs/promises'; function loadFile(path) { return fs.readFile(join(process.cwd(), path), 'utf8'); } export default /** @type {import('@heymp/scratchpad/src/config').Config} */ ({ playwright: async (args) => { const { context, page } = args; await context.exposeFunction('loadFile', loadFile) } });
-
a242c0f:
⚠️ Change config types directory.export default /** @type {import('@heymp/scratchpad/src/config').Config} */ ({});
v1.0.0-next.7
Minor Changes
-
c31a8f9: Expose Playwright runtime context to scratchpad.config.js #40
scratchpad.config.js
export default /** @type {import('@heymp/scratchpad/config').Config} */ ({ devtools: true, playwright: async (args) => { const { context, page } = args; // block esmodule shims await context.route(/es-module-shims\.js/, async (route) => { await route.abort(); }); await page.goto("https://ux.redhat.com"); }, });
-
f6fb1f2: Add option for writing the js output to a file based on the compiled
ts target. Use--ts-write
as a boolean flag in the cli.
Patch Changes
v1.0.0-next.6
Minor Changes
-
2bcb56e: Add
scratchpad.config.js
file as an alternative to specifying scratchpad options
using the CLI flags.export default { devtools: true, headless: false, url: "https://www.google.com", };
NOTE: CLI flags will take precidence over config file options.
v1.0.0-next.5
Minor Changes
- db0f2af: Open devtools automatically with cli flag. Use the
--devtools
flag
to enable the devtools in the browser.
v1.0.0-next.4
Minor Changes
- 7b6410e: Migrate from tsc to esbuild for TS compilation
v1.0.0-next.3
Major Changes
- f5c9bc4: Migrate to Playwright
v1.0.0-next.2
Patch Changes
- 68ec5fb: Fix bin entrypoint