@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/cli.js +72 -25
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +69 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -22
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -4059,6 +4059,39 @@ function formatAggregateRenderFailureJson(componentName, failures, scenarioCount
|
|
|
4059
4059
|
}
|
|
4060
4060
|
var MANIFEST_PATH6 = ".reactscope/manifest.json";
|
|
4061
4061
|
var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
|
|
4062
|
+
function renderArtifactBaseName(componentName, scenarioName) {
|
|
4063
|
+
return scenarioName === void 0 ? componentName : `${componentName}-${scenarioName}`;
|
|
4064
|
+
}
|
|
4065
|
+
function removeStaleRenderError(outputDir, componentName, scenarioName) {
|
|
4066
|
+
const errorPath = resolve(
|
|
4067
|
+
outputDir,
|
|
4068
|
+
`${renderArtifactBaseName(componentName, scenarioName)}.error.json`
|
|
4069
|
+
);
|
|
4070
|
+
if (existsSync(errorPath)) {
|
|
4071
|
+
rmSync(errorPath, { force: true });
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
function writeRenderErrorArtifact(outputDir, failure) {
|
|
4075
|
+
const errPath = resolve(
|
|
4076
|
+
outputDir,
|
|
4077
|
+
`${renderArtifactBaseName(failure.component, failure.scenario)}.error.json`
|
|
4078
|
+
);
|
|
4079
|
+
writeFileSync(
|
|
4080
|
+
errPath,
|
|
4081
|
+
JSON.stringify(
|
|
4082
|
+
{
|
|
4083
|
+
component: failure.component,
|
|
4084
|
+
scenario: failure.scenario,
|
|
4085
|
+
errorMessage: failure.errorMessage,
|
|
4086
|
+
heuristicFlags: failure.heuristicFlags,
|
|
4087
|
+
propsAtCrash: failure.propsAtCrash
|
|
4088
|
+
},
|
|
4089
|
+
null,
|
|
4090
|
+
2
|
|
4091
|
+
)
|
|
4092
|
+
);
|
|
4093
|
+
return errPath;
|
|
4094
|
+
}
|
|
4062
4095
|
var _pool3 = null;
|
|
4063
4096
|
async function getPool3(viewportWidth, viewportHeight) {
|
|
4064
4097
|
if (_pool3 === null) {
|
|
@@ -4743,20 +4776,12 @@ function registerRenderAll(renderCmd) {
|
|
|
4743
4776
|
success: false,
|
|
4744
4777
|
errorMessage: outcome.error.message
|
|
4745
4778
|
});
|
|
4746
|
-
const errPath =
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
errorMessage: outcome.error.message,
|
|
4753
|
-
heuristicFlags: outcome.error.heuristicFlags,
|
|
4754
|
-
propsAtCrash: outcome.error.propsAtCrash
|
|
4755
|
-
},
|
|
4756
|
-
null,
|
|
4757
|
-
2
|
|
4758
|
-
)
|
|
4759
|
-
);
|
|
4779
|
+
const errPath = writeRenderErrorArtifact(outputDir, {
|
|
4780
|
+
component: name,
|
|
4781
|
+
errorMessage: outcome.error.message,
|
|
4782
|
+
heuristicFlags: outcome.error.heuristicFlags,
|
|
4783
|
+
propsAtCrash: outcome.error.propsAtCrash
|
|
4784
|
+
});
|
|
4760
4785
|
failures.push({
|
|
4761
4786
|
component: name,
|
|
4762
4787
|
stage: "render",
|
|
@@ -4769,13 +4794,14 @@ function registerRenderAll(renderCmd) {
|
|
|
4769
4794
|
}
|
|
4770
4795
|
const result = outcome.result;
|
|
4771
4796
|
results.push({ name, renderTimeMs: result.renderTimeMs, success: true });
|
|
4797
|
+
removeStaleRenderError(outputDir, name);
|
|
4772
4798
|
if (!isIcon) {
|
|
4773
4799
|
const pngPath = resolve(outputDir, `${name}.png`);
|
|
4774
4800
|
writeFileSync(pngPath, result.screenshot);
|
|
4775
4801
|
outputPaths.push(pngPath);
|
|
4776
4802
|
}
|
|
4777
4803
|
const jsonPath = resolve(outputDir, `${name}.json`);
|
|
4778
|
-
const renderJson = formatRenderJson(name,
|
|
4804
|
+
const renderJson = formatRenderJson(name, renderProps, result);
|
|
4779
4805
|
const extResult = result;
|
|
4780
4806
|
if (isIcon && extResult.svgContent) {
|
|
4781
4807
|
renderJson.svgContent = extResult.svgContent;
|
|
@@ -4836,13 +4862,34 @@ function registerRenderAll(renderCmd) {
|
|
|
4836
4862
|
concurrency: 2
|
|
4837
4863
|
});
|
|
4838
4864
|
const matrixResult = await matrix.render();
|
|
4839
|
-
const matrixCells = matrixResult.cells.map((cell) =>
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4865
|
+
const matrixCells = matrixResult.cells.map((cell) => {
|
|
4866
|
+
const scenarioName = scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? "";
|
|
4867
|
+
const artifactBaseName = renderArtifactBaseName(name, scenarioName);
|
|
4868
|
+
const scenarioPngPath = resolve(outputDir, `${artifactBaseName}.png`);
|
|
4869
|
+
const scenarioJsonPath = resolve(outputDir, `${artifactBaseName}.json`);
|
|
4870
|
+
if (!isIcon) {
|
|
4871
|
+
writeFileSync(scenarioPngPath, cell.result.screenshot);
|
|
4872
|
+
outputPaths.push(scenarioPngPath);
|
|
4873
|
+
}
|
|
4874
|
+
const scenarioJson = formatRenderJson(
|
|
4875
|
+
`${name}:${scenarioName}`,
|
|
4876
|
+
scenarioPropsMap[scenarioName] ?? {},
|
|
4877
|
+
cell.result
|
|
4878
|
+
);
|
|
4879
|
+
writeFileSync(scenarioJsonPath, JSON.stringify(scenarioJson, null, 2));
|
|
4880
|
+
outputPaths.push(scenarioJsonPath);
|
|
4881
|
+
removeStaleRenderError(outputDir, name, scenarioName);
|
|
4882
|
+
return {
|
|
4883
|
+
axisValues: [scenarioName],
|
|
4884
|
+
scenario: scenarioName,
|
|
4885
|
+
outputPath: scenarioJsonPath,
|
|
4886
|
+
screenshotPath: isIcon ? void 0 : scenarioPngPath,
|
|
4887
|
+
screenshot: cell.result.screenshot.toString("base64"),
|
|
4888
|
+
width: cell.result.width,
|
|
4889
|
+
height: cell.result.height,
|
|
4890
|
+
renderTimeMs: cell.result.renderTimeMs
|
|
4891
|
+
};
|
|
4892
|
+
});
|
|
4846
4893
|
const existingJson = JSON.parse(readFileSync(jsonPath, "utf-8"));
|
|
4847
4894
|
existingJson.cells = matrixCells;
|
|
4848
4895
|
existingJson.axisLabels = [scenarioAxis.values];
|