@opul/cli 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +42 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1091,23 +1091,52 @@ import { join as join5, resolve as resolve2, relative as relative2 } from "path"
1091
1091
  async function demoCommand(opts) {
1092
1092
  const stepsPath = resolve2(process.cwd(), opts.steps);
1093
1093
  const outDir = resolve2(process.cwd(), opts.out);
1094
- let raw;
1094
+ let raw = null;
1095
1095
  try {
1096
1096
  raw = await readFile(stepsPath, "utf8");
1097
1097
  } catch {
1098
- fail(
1099
- `no steps file at ${ink.bold(opts.steps)}
1100
- run ${ink.bold("opul init")} to create one.`
1101
- );
1102
- return;
1098
+ raw = null;
1103
1099
  }
1104
1100
  let steps;
1105
- try {
1106
- steps = parseSteps(JSON.parse(raw));
1107
- } catch (e) {
1108
- if (e instanceof StepsValidationError) fail(`invalid steps: ${e.message}`);
1109
- else fail(`steps file is not valid JSON: ${e.message}`);
1110
- return;
1101
+ if (raw === null) {
1102
+ if (!opts.url) {
1103
+ fail(
1104
+ `no steps file at ${ink.bold(opts.steps)} and no ${ink.bold("--url")}.
1105
+ run ${ink.bold("opul record --url <url>")} first, or ${ink.bold("opul init")}.`
1106
+ );
1107
+ return;
1108
+ }
1109
+ console.error(
1110
+ `${ink.dim("no steps file \u2014 let's capture your click-through first.")}
1111
+ `
1112
+ );
1113
+ try {
1114
+ steps = await recordSteps({
1115
+ url: opts.url,
1116
+ outPath: stepsPath,
1117
+ chromePath: opts.chrome
1118
+ });
1119
+ } catch (e) {
1120
+ if (e instanceof ChromeNotFoundError) fail(e.message);
1121
+ else fail(e.message);
1122
+ return;
1123
+ }
1124
+ if (steps.steps.length === 0) {
1125
+ fail("no steps captured \u2014 click or type in the window before saving, then re-run.");
1126
+ return;
1127
+ }
1128
+ console.error(
1129
+ `${ink.green("\u2713")} captured ${steps.steps.length} step${steps.steps.length === 1 ? "" : "s"} \u2192 ${ink.bold(opts.steps)}. rendering the video\u2026
1130
+ `
1131
+ );
1132
+ } else {
1133
+ try {
1134
+ steps = parseSteps(JSON.parse(raw));
1135
+ } catch (e) {
1136
+ if (e instanceof StepsValidationError) fail(`invalid steps: ${e.message}`);
1137
+ else fail(`steps file is not valid JSON: ${e.message}`);
1138
+ return;
1139
+ }
1111
1140
  }
1112
1141
  if (opts.url) steps.startUrl = opts.url;
1113
1142
  if (opts.profile) {
@@ -1378,7 +1407,7 @@ program.name("opul").description("Record a product demo from your running web ap
1378
1407
  program.command("init").description("Create an opul.steps.json stub").option("--out <file>", "output path", "opul.steps.json").action(initCommand);
1379
1408
  program.command("doctor").description("Check that Chrome and ffmpeg are installed").action(doctorCommand);
1380
1409
  program.command("record").description("Click through your app to generate a steps file").option("--url <url>", "app URL to open").option("--out <file>", "steps file to write", "opul.steps.json").option("--name <name>", "product/demo name").option("--chrome <path>", "path to Chrome executable").action(recordCommand);
1381
- program.command("demo").description("Record a demo MP4 from your app").option("--url <url>", "app URL to open first (overrides startUrl)").option("--steps <file>", "steps file", "opul.steps.json").option("--out <dir>", "output directory", "opul-out").option("--headed", "run Chrome headed with a 3s pre-roll").option("--height <px>", "output height (width derived to 16:9)").option("--profile <dir>", "use an existing Chrome profile (prints a warning)").option("--chrome <path>", "path to Chrome executable").action(demoCommand);
1410
+ program.command("demo").description("Record a demo MP4 (captures a click-through first if no steps file)").option("--url <url>", "app URL to open first (overrides startUrl)").option("--steps <file>", "steps file", "opul.steps.json").option("--out <dir>", "output directory", "opul-out").option("--headed", "run Chrome headed with a 3s pre-roll").option("--height <px>", "output height (width derived to 16:9)").option("--profile <dir>", "use an existing Chrome profile (prints a warning)").option("--chrome <path>", "path to Chrome executable").action(demoCommand);
1382
1411
  program.command("publish <file>").description("Publish an MP4 and get a shareable link").option("--title <title>", "demo title").option("--replace <slug>", "replace an existing demo, keeping its URL").option("--poster <file>", "poster image (defaults to ./poster.jpg)").action(publishCommand);
1383
1412
  program.command("ls").description("List your published demos").action(lsCommand);
1384
1413
  program.command("rm <slug>").description("Delete a published demo").action(rmCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opul/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Record a polished product-demo video from your running web app — from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {