@agent-scope/cli 1.20.2 → 1.20.3

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/dist/index.cjs CHANGED
@@ -4083,6 +4083,39 @@ function formatAggregateRenderFailureJson(componentName, failures, scenarioCount
4083
4083
  }
4084
4084
  var MANIFEST_PATH6 = ".reactscope/manifest.json";
4085
4085
  var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
4086
+ function renderArtifactBaseName(componentName, scenarioName) {
4087
+ return scenarioName === void 0 ? componentName : `${componentName}-${scenarioName}`;
4088
+ }
4089
+ function removeStaleRenderError(outputDir, componentName, scenarioName) {
4090
+ const errorPath = path.resolve(
4091
+ outputDir,
4092
+ `${renderArtifactBaseName(componentName, scenarioName)}.error.json`
4093
+ );
4094
+ if (fs.existsSync(errorPath)) {
4095
+ fs.rmSync(errorPath, { force: true });
4096
+ }
4097
+ }
4098
+ function writeRenderErrorArtifact(outputDir, failure) {
4099
+ const errPath = path.resolve(
4100
+ outputDir,
4101
+ `${renderArtifactBaseName(failure.component, failure.scenario)}.error.json`
4102
+ );
4103
+ fs.writeFileSync(
4104
+ errPath,
4105
+ JSON.stringify(
4106
+ {
4107
+ component: failure.component,
4108
+ scenario: failure.scenario,
4109
+ errorMessage: failure.errorMessage,
4110
+ heuristicFlags: failure.heuristicFlags,
4111
+ propsAtCrash: failure.propsAtCrash
4112
+ },
4113
+ null,
4114
+ 2
4115
+ )
4116
+ );
4117
+ return errPath;
4118
+ }
4086
4119
  var _pool3 = null;
4087
4120
  async function getPool3(viewportWidth, viewportHeight) {
4088
4121
  if (_pool3 === null) {
@@ -4767,20 +4800,12 @@ function registerRenderAll(renderCmd) {
4767
4800
  success: false,
4768
4801
  errorMessage: outcome.error.message
4769
4802
  });
4770
- const errPath = path.resolve(outputDir, `${name}.error.json`);
4771
- fs.writeFileSync(
4772
- errPath,
4773
- JSON.stringify(
4774
- {
4775
- component: name,
4776
- errorMessage: outcome.error.message,
4777
- heuristicFlags: outcome.error.heuristicFlags,
4778
- propsAtCrash: outcome.error.propsAtCrash
4779
- },
4780
- null,
4781
- 2
4782
- )
4783
- );
4803
+ const errPath = writeRenderErrorArtifact(outputDir, {
4804
+ component: name,
4805
+ errorMessage: outcome.error.message,
4806
+ heuristicFlags: outcome.error.heuristicFlags,
4807
+ propsAtCrash: outcome.error.propsAtCrash
4808
+ });
4784
4809
  failures.push({
4785
4810
  component: name,
4786
4811
  stage: "render",
@@ -4793,13 +4818,14 @@ function registerRenderAll(renderCmd) {
4793
4818
  }
4794
4819
  const result = outcome.result;
4795
4820
  results.push({ name, renderTimeMs: result.renderTimeMs, success: true });
4821
+ removeStaleRenderError(outputDir, name);
4796
4822
  if (!isIcon) {
4797
4823
  const pngPath = path.resolve(outputDir, `${name}.png`);
4798
4824
  fs.writeFileSync(pngPath, result.screenshot);
4799
4825
  outputPaths.push(pngPath);
4800
4826
  }
4801
4827
  const jsonPath = path.resolve(outputDir, `${name}.json`);
4802
- const renderJson = formatRenderJson(name, {}, result);
4828
+ const renderJson = formatRenderJson(name, renderProps, result);
4803
4829
  const extResult = result;
4804
4830
  if (isIcon && extResult.svgContent) {
4805
4831
  renderJson.svgContent = extResult.svgContent;
@@ -4860,13 +4886,34 @@ function registerRenderAll(renderCmd) {
4860
4886
  concurrency: 2
4861
4887
  });
4862
4888
  const matrixResult = await matrix.render();
4863
- const matrixCells = matrixResult.cells.map((cell) => ({
4864
- axisValues: [scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? ""],
4865
- screenshot: cell.result.screenshot.toString("base64"),
4866
- width: cell.result.width,
4867
- height: cell.result.height,
4868
- renderTimeMs: cell.result.renderTimeMs
4869
- }));
4889
+ const matrixCells = matrixResult.cells.map((cell) => {
4890
+ const scenarioName = scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? "";
4891
+ const artifactBaseName = renderArtifactBaseName(name, scenarioName);
4892
+ const scenarioPngPath = path.resolve(outputDir, `${artifactBaseName}.png`);
4893
+ const scenarioJsonPath = path.resolve(outputDir, `${artifactBaseName}.json`);
4894
+ if (!isIcon) {
4895
+ fs.writeFileSync(scenarioPngPath, cell.result.screenshot);
4896
+ outputPaths.push(scenarioPngPath);
4897
+ }
4898
+ const scenarioJson = formatRenderJson(
4899
+ `${name}:${scenarioName}`,
4900
+ scenarioPropsMap[scenarioName] ?? {},
4901
+ cell.result
4902
+ );
4903
+ fs.writeFileSync(scenarioJsonPath, JSON.stringify(scenarioJson, null, 2));
4904
+ outputPaths.push(scenarioJsonPath);
4905
+ removeStaleRenderError(outputDir, name, scenarioName);
4906
+ return {
4907
+ axisValues: [scenarioName],
4908
+ scenario: scenarioName,
4909
+ outputPath: scenarioJsonPath,
4910
+ screenshotPath: isIcon ? void 0 : scenarioPngPath,
4911
+ screenshot: cell.result.screenshot.toString("base64"),
4912
+ width: cell.result.width,
4913
+ height: cell.result.height,
4914
+ renderTimeMs: cell.result.renderTimeMs
4915
+ };
4916
+ });
4870
4917
  const existingJson = JSON.parse(fs.readFileSync(jsonPath, "utf-8"));
4871
4918
  existingJson.cells = matrixCells;
4872
4919
  existingJson.axisLabels = [scenarioAxis.values];