@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/cli.js
CHANGED
|
@@ -3899,7 +3899,7 @@ Examples:
|
|
|
3899
3899
|
}
|
|
3900
3900
|
|
|
3901
3901
|
// src/render-commands.ts
|
|
3902
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "fs";
|
|
3902
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync9, rmSync as rmSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
3903
3903
|
import { resolve as resolve11 } from "path";
|
|
3904
3904
|
import {
|
|
3905
3905
|
ALL_CONTEXT_IDS,
|
|
@@ -4157,6 +4157,39 @@ function formatAggregateRenderFailureJson(componentName, failures, scenarioCount
|
|
|
4157
4157
|
}
|
|
4158
4158
|
var MANIFEST_PATH6 = ".reactscope/manifest.json";
|
|
4159
4159
|
var DEFAULT_OUTPUT_DIR = ".reactscope/renders";
|
|
4160
|
+
function renderArtifactBaseName(componentName, scenarioName) {
|
|
4161
|
+
return scenarioName === void 0 ? componentName : `${componentName}-${scenarioName}`;
|
|
4162
|
+
}
|
|
4163
|
+
function removeStaleRenderError(outputDir, componentName, scenarioName) {
|
|
4164
|
+
const errorPath = resolve11(
|
|
4165
|
+
outputDir,
|
|
4166
|
+
`${renderArtifactBaseName(componentName, scenarioName)}.error.json`
|
|
4167
|
+
);
|
|
4168
|
+
if (existsSync9(errorPath)) {
|
|
4169
|
+
rmSync2(errorPath, { force: true });
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
function writeRenderErrorArtifact(outputDir, failure) {
|
|
4173
|
+
const errPath = resolve11(
|
|
4174
|
+
outputDir,
|
|
4175
|
+
`${renderArtifactBaseName(failure.component, failure.scenario)}.error.json`
|
|
4176
|
+
);
|
|
4177
|
+
writeFileSync6(
|
|
4178
|
+
errPath,
|
|
4179
|
+
JSON.stringify(
|
|
4180
|
+
{
|
|
4181
|
+
component: failure.component,
|
|
4182
|
+
scenario: failure.scenario,
|
|
4183
|
+
errorMessage: failure.errorMessage,
|
|
4184
|
+
heuristicFlags: failure.heuristicFlags,
|
|
4185
|
+
propsAtCrash: failure.propsAtCrash
|
|
4186
|
+
},
|
|
4187
|
+
null,
|
|
4188
|
+
2
|
|
4189
|
+
)
|
|
4190
|
+
);
|
|
4191
|
+
return errPath;
|
|
4192
|
+
}
|
|
4160
4193
|
var _pool3 = null;
|
|
4161
4194
|
async function getPool3(viewportWidth, viewportHeight) {
|
|
4162
4195
|
if (_pool3 === null) {
|
|
@@ -4841,20 +4874,12 @@ function registerRenderAll(renderCmd) {
|
|
|
4841
4874
|
success: false,
|
|
4842
4875
|
errorMessage: outcome.error.message
|
|
4843
4876
|
});
|
|
4844
|
-
const errPath =
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
errorMessage: outcome.error.message,
|
|
4851
|
-
heuristicFlags: outcome.error.heuristicFlags,
|
|
4852
|
-
propsAtCrash: outcome.error.propsAtCrash
|
|
4853
|
-
},
|
|
4854
|
-
null,
|
|
4855
|
-
2
|
|
4856
|
-
)
|
|
4857
|
-
);
|
|
4877
|
+
const errPath = writeRenderErrorArtifact(outputDir, {
|
|
4878
|
+
component: name,
|
|
4879
|
+
errorMessage: outcome.error.message,
|
|
4880
|
+
heuristicFlags: outcome.error.heuristicFlags,
|
|
4881
|
+
propsAtCrash: outcome.error.propsAtCrash
|
|
4882
|
+
});
|
|
4858
4883
|
failures.push({
|
|
4859
4884
|
component: name,
|
|
4860
4885
|
stage: "render",
|
|
@@ -4867,13 +4892,14 @@ function registerRenderAll(renderCmd) {
|
|
|
4867
4892
|
}
|
|
4868
4893
|
const result = outcome.result;
|
|
4869
4894
|
results.push({ name, renderTimeMs: result.renderTimeMs, success: true });
|
|
4895
|
+
removeStaleRenderError(outputDir, name);
|
|
4870
4896
|
if (!isIcon) {
|
|
4871
4897
|
const pngPath = resolve11(outputDir, `${name}.png`);
|
|
4872
4898
|
writeFileSync6(pngPath, result.screenshot);
|
|
4873
4899
|
outputPaths.push(pngPath);
|
|
4874
4900
|
}
|
|
4875
4901
|
const jsonPath = resolve11(outputDir, `${name}.json`);
|
|
4876
|
-
const renderJson = formatRenderJson(name,
|
|
4902
|
+
const renderJson = formatRenderJson(name, renderProps, result);
|
|
4877
4903
|
const extResult = result;
|
|
4878
4904
|
if (isIcon && extResult.svgContent) {
|
|
4879
4905
|
renderJson.svgContent = extResult.svgContent;
|
|
@@ -4934,13 +4960,34 @@ function registerRenderAll(renderCmd) {
|
|
|
4934
4960
|
concurrency: 2
|
|
4935
4961
|
});
|
|
4936
4962
|
const matrixResult = await matrix.render();
|
|
4937
|
-
const matrixCells = matrixResult.cells.map((cell) =>
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4963
|
+
const matrixCells = matrixResult.cells.map((cell) => {
|
|
4964
|
+
const scenarioName = scenarioEntries2[cell.axisIndices[0] ?? 0]?.[0] ?? "";
|
|
4965
|
+
const artifactBaseName = renderArtifactBaseName(name, scenarioName);
|
|
4966
|
+
const scenarioPngPath = resolve11(outputDir, `${artifactBaseName}.png`);
|
|
4967
|
+
const scenarioJsonPath = resolve11(outputDir, `${artifactBaseName}.json`);
|
|
4968
|
+
if (!isIcon) {
|
|
4969
|
+
writeFileSync6(scenarioPngPath, cell.result.screenshot);
|
|
4970
|
+
outputPaths.push(scenarioPngPath);
|
|
4971
|
+
}
|
|
4972
|
+
const scenarioJson = formatRenderJson(
|
|
4973
|
+
`${name}:${scenarioName}`,
|
|
4974
|
+
scenarioPropsMap[scenarioName] ?? {},
|
|
4975
|
+
cell.result
|
|
4976
|
+
);
|
|
4977
|
+
writeFileSync6(scenarioJsonPath, JSON.stringify(scenarioJson, null, 2));
|
|
4978
|
+
outputPaths.push(scenarioJsonPath);
|
|
4979
|
+
removeStaleRenderError(outputDir, name, scenarioName);
|
|
4980
|
+
return {
|
|
4981
|
+
axisValues: [scenarioName],
|
|
4982
|
+
scenario: scenarioName,
|
|
4983
|
+
outputPath: scenarioJsonPath,
|
|
4984
|
+
screenshotPath: isIcon ? void 0 : scenarioPngPath,
|
|
4985
|
+
screenshot: cell.result.screenshot.toString("base64"),
|
|
4986
|
+
width: cell.result.width,
|
|
4987
|
+
height: cell.result.height,
|
|
4988
|
+
renderTimeMs: cell.result.renderTimeMs
|
|
4989
|
+
};
|
|
4990
|
+
});
|
|
4944
4991
|
const existingJson = JSON.parse(readFileSync9(jsonPath, "utf-8"));
|
|
4945
4992
|
existingJson.cells = matrixCells;
|
|
4946
4993
|
existingJson.axisLabels = [scenarioAxis.values];
|
|
@@ -5047,7 +5094,7 @@ function createRenderCommand() {
|
|
|
5047
5094
|
}
|
|
5048
5095
|
|
|
5049
5096
|
// src/report/baseline.ts
|
|
5050
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync6, rmSync as
|
|
5097
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync6, rmSync as rmSync3, writeFileSync as writeFileSync7 } from "fs";
|
|
5051
5098
|
import { resolve as resolve12 } from "path";
|
|
5052
5099
|
import { generateManifest as generateManifest4 } from "@agent-scope/manifest";
|
|
5053
5100
|
import { BrowserPool as BrowserPool4, safeRender as safeRender3 } from "@agent-scope/render";
|
|
@@ -5208,7 +5255,7 @@ async function runBaseline(options = {}) {
|
|
|
5208
5255
|
const baselineDir = resolve12(rootDir, outputDir);
|
|
5209
5256
|
const rendersDir = resolve12(baselineDir, "renders");
|
|
5210
5257
|
if (existsSync10(baselineDir)) {
|
|
5211
|
-
|
|
5258
|
+
rmSync3(baselineDir, { recursive: true, force: true });
|
|
5212
5259
|
}
|
|
5213
5260
|
mkdirSync6(rendersDir, { recursive: true });
|
|
5214
5261
|
let manifest;
|