@reshotdev/screenshot 0.0.1-beta.18 → 0.0.1-beta.19
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/package.json +1 -1
- package/src/commands/pull.js +14 -5
package/package.json
CHANGED
package/src/commands/pull.js
CHANGED
|
@@ -120,7 +120,13 @@ function deriveUsageSample(assets) {
|
|
|
120
120
|
const contexts = Object.keys(assets[group][visualKey] || {});
|
|
121
121
|
if (contexts.length === 0) continue;
|
|
122
122
|
const context = contexts.includes("default") ? "default" : contexts[0];
|
|
123
|
-
|
|
123
|
+
// A capture entry is either flat ({src,width,height}) or step-based
|
|
124
|
+
// ({steps:[{src,...}]}). Tell the caller which, so the printed example
|
|
125
|
+
// references the right path (`.steps[0].src` vs `.src`) and doesn't
|
|
126
|
+
// produce an undefined src (audit run-12 MED-1).
|
|
127
|
+
const entry = assets[group][visualKey][context];
|
|
128
|
+
const stepped = !!(entry && Array.isArray(entry.steps));
|
|
129
|
+
return { group, visualKey, context, stepped };
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
return null;
|
|
@@ -479,6 +485,9 @@ async function pullCommand(options = {}) {
|
|
|
479
485
|
const sGroup = sample?.group ?? "dashboard";
|
|
480
486
|
const sVisual = sample?.visualKey ?? "mainView";
|
|
481
487
|
const sCtx = sample?.context ?? "default";
|
|
488
|
+
// Step-based capture entries nest the fields under `steps[0]`; reference it
|
|
489
|
+
// so the printed example's src/width/height aren't undefined (run-12 MED-1).
|
|
490
|
+
const sStep = sample?.stepped ? ".steps[0]" : "";
|
|
482
491
|
|
|
483
492
|
// Show format-specific usage instructions
|
|
484
493
|
if (format === "ts") {
|
|
@@ -499,10 +508,10 @@ async function pullCommand(options = {}) {
|
|
|
499
508
|
console.log(chalk.cyan(' import assets from "./reshot-assets.json";\n'));
|
|
500
509
|
console.log(chalk.white("Access assets with dot notation:\n"));
|
|
501
510
|
console.log(chalk.cyan(" <img"));
|
|
502
|
-
console.log(chalk.cyan(` src={assets.assets.${sGroup}.${sVisual}.${sCtx}.src}`));
|
|
503
|
-
console.log(chalk.cyan(` width={assets.assets.${sGroup}.${sVisual}.${sCtx}.width}`));
|
|
504
|
-
console.log(chalk.cyan(` height={assets.assets.${sGroup}.${sVisual}.${sCtx}.height}`));
|
|
505
|
-
console.log(chalk.cyan(` alt={assets.assets.${sGroup}.${sVisual}.${sCtx}.alt}`));
|
|
511
|
+
console.log(chalk.cyan(` src={assets.assets.${sGroup}.${sVisual}.${sCtx}${sStep}.src}`));
|
|
512
|
+
console.log(chalk.cyan(` width={assets.assets.${sGroup}.${sVisual}.${sCtx}${sStep}.width}`));
|
|
513
|
+
console.log(chalk.cyan(` height={assets.assets.${sGroup}.${sVisual}.${sCtx}${sStep}.height}`));
|
|
514
|
+
console.log(chalk.cyan(` alt={assets.assets.${sGroup}.${sVisual}.${sCtx}${sStep}.alt}`));
|
|
506
515
|
console.log(chalk.cyan(" />\n"));
|
|
507
516
|
} else if (format === "csv") {
|
|
508
517
|
console.log(chalk.blue("━━━ CSV Usage ━━━\n"));
|