@loadmap/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  ```bash
4
4
  npx @loadmap/cli check shop.loadmap # exit 1 when an expect line fails; GitHub annotations under Actions
5
+ npx @loadmap/cli fmt shop.loadmap # lays it out the one way; --check exits 1 instead (for CI)
5
6
  npx @loadmap/cli record shop.loadmap --out shop.gif --caption
6
7
  npx @loadmap/cli record http://localhost:5173/ --out poster.png --poster
7
8
  ```
8
9
 
9
10
  `loadmap check` compiles each `.loadmap` and tests its `expect` lines on the pessimistic edge (every capacity at its
10
- low bound). `loadmap record` draws a `.loadmap` (or opens a page that calls `expose()` from `@loadmap/export`) in
11
+ low bound). `loadmap fmt` rewrites each file laid out the one way (two spaces a block, a statement a line, one space
12
+ around operators; numbers, texts and formulas as written), `--check` only names the ones that are not, `-` reads
13
+ standard input. `loadmap record` draws a `.loadmap` (or opens a page that calls `expose()` from `@loadmap/export`) in
11
14
  headless Chromium and records it on a fixed clock: the same options give the same file. Recording needs Chromium
12
15
  once: `npx playwright install chromium`. `loadmap --help` lists every option.
13
16
  Docs: https://jaim3r0jas.github.io/loadmap/ · MIT
package/dist/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as main } from "./src-IlCf12IX.js";
2
+ import { n as main } from "./src-CCAswkjM.js";
3
3
  // src/bin.ts
4
4
  main(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
5
5
  console.error(err instanceof Error ? err.message : err);
package/dist/index.d.ts CHANGED
@@ -27,7 +27,20 @@ export declare function check(argv: string[], o?: CheckOptions): Promise<number>
27
27
  * https://docs.github.com/actions/reference/workflow-commands-for-github-actions
28
28
  */
29
29
  export declare function github(d: Diagnostic, file: string, source: string): string;
30
- export declare const USAGE = "loadmap check <file.loadmap>… [--format text|github]\nloadmap record <url | file.loadmap> --out <file.gif|.webm|.mp4|.png|.svg> [options]\n\ncheck compiles each definition and tests its expect lines on the pessimistic edge (every capacity at its low\nbound). It exits 1 when a definition has an error or an expectation fails, 0 when everything holds.\n\n --format <f> text, or github to add annotations on the lines (the default under GitHub Actions)\n\nrecord opens the page in headless Chromium, finds the loadmap it exposes (expose() from @loadmap/export) and\nrecords it on a fixed clock, so the same options give the same file. A .loadmap file is drawn by the viewer that\ncomes with the command.\n\n --out <file> the extension picks the format: gif, webm, mp4, png or svg\n --script <file.json> [{ \"at\": 0, \"set\": { \"load\": 5 } }, { \"at\": 3, \"scenario\": \"Proposed\" }, …]\n or { \"seconds\", \"fps\", \"script\": […] }\n --scenario <label> start from a scenario's values (--set goes on top)\n --set <key=value> a value before recording starts; repeatable (--set load=30 --set pods=6)\n --caption the title, scenario and load above the board, the verdict below it\n --story play the definition's story, a step at a time (with --caption, its text below the board)\n --poster with .png: the board, the verdict, the limits and the scenarios compared\n --seconds <n> length of a video or GIF (default 8, or the script's)\n --fps <n> frames per second (default 30; GIF 15, at most 50)\n --scale <n> pixels per diagram unit (default 1, PNG 2)\n --seed <n> the sim's seed (default 1)\n --name <name> which exposed loadmap, when the page has several (default \"default\")\n --width <px> the browser window (default 1280; below 640 the diagram runs top to bottom)\n --color-scheme <s> light or dark, for a page that follows the system theme (default light)";
30
+ interface FmtOptions {
31
+ log?: (s: string) => void;
32
+ /** Where `-` reads the definition from. Default: standard input. */
33
+ read?: () => Promise<string>;
34
+ /** Where `-` writes it to. Default: standard output. */
35
+ write?: (s: string) => void;
36
+ }
37
+ /**
38
+ * `loadmap fmt`: lays each definition out the one way (`format()` of @loadmap/dsl), in place. With `--check` it only
39
+ * names the files that are not laid out so. `-` reads standard input and writes standard output. Resolves to 1 when a
40
+ * file has a syntax error, cannot be read, or (with --check) needs formatting; 2 for a usage mistake.
41
+ */
42
+ export declare function fmt(argv: string[], o?: FmtOptions): Promise<number>;
43
+ export declare const USAGE = "loadmap check <file.loadmap>… [--format text|github]\nloadmap fmt <file.loadmap>… [--check] | loadmap fmt -\nloadmap record <url | file.loadmap> --out <file.gif|.webm|.mp4|.png|.svg> [options]\n\ncheck compiles each definition and tests its expect lines on the pessimistic edge (every capacity at its low\nbound). It exits 1 when a definition has an error or an expectation fails, 0 when everything holds.\n\n --format <f> text, or github to add annotations on the lines (the default under GitHub Actions)\n\nfmt lays each definition out the one way, in place: two spaces a block, a statement a line, one space around\noperators; numbers, texts and formulas stay as written. A file with a syntax error is left alone (exit 1).\n\n --check change nothing; exit 1 when a file is not laid out so (for CI)\n - read standard input, write standard output\n\nrecord opens the page in headless Chromium, finds the loadmap it exposes (expose() from @loadmap/export) and\nrecords it on a fixed clock, so the same options give the same file. A .loadmap file is drawn by the viewer that\ncomes with the command.\n\n --out <file> the extension picks the format: gif, webm, mp4, png or svg\n --script <file.json> [{ \"at\": 0, \"set\": { \"load\": 5 } }, { \"at\": 3, \"scenario\": \"Proposed\" }, …]\n or { \"seconds\", \"fps\", \"script\": […] }\n --scenario <label> start from a scenario's values (--set goes on top)\n --set <key=value> a value before recording starts; repeatable (--set load=30 --set pods=6)\n --caption the title, scenario and load above the board, the verdict below it\n --story play the definition's story, a step at a time (with --caption, its text below the board)\n --poster with .png: the board, the verdict, the limits and the scenarios compared\n --seconds <n> length of a video or GIF (default 8, or the script's)\n --fps <n> frames per second (default 30; GIF 15, at most 50)\n --scale <n> pixels per diagram unit (default 1, PNG 2)\n --seed <n> the sim's seed (default 1)\n --name <name> which exposed loadmap, when the page has several (default \"default\")\n --width <px> the browser window (default 1280; below 640 the diagram runs top to bottom)\n --color-scheme <s> light or dark, for a page that follows the system theme (default light)";
31
44
  export interface RecordArgs {
32
45
  /** A page that calls expose(); empty with `file`. */
33
46
  url: string;
@@ -63,4 +76,4 @@ export declare function parseRecord(argv: string[]): Promise<RecordArgs>;
63
76
  export declare function record(a: RecordArgs, o?: {
64
77
  viewer?: string;
65
78
  }): Promise<Buffer>;
66
- export type { CheckOptions };
79
+ export type { CheckOptions, FmtOptions };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as USAGE, a as check, o as github, n as main, r as parseRecord, i as record } from "./src-IlCf12IX.js";
1
+ export { t as USAGE, o as check, a as fmt, s as github, n as main, r as parseRecord, i as record } from "./src-CCAswkjM.js";