@alwaysmeticulous/cli 2.278.0 → 2.279.0
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.
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9277f775-c52a-556c-99d0-389c4257c25c")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.imageFilesCommand = void 0;
|
|
6
6
|
const promises_1 = require("fs/promises");
|
|
7
|
-
const os_1 = require("os");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const client_1 = require("@alwaysmeticulous/client");
|
|
10
9
|
const common_1 = require("@alwaysmeticulous/common");
|
|
11
10
|
const downloading_helpers_1 = require("@alwaysmeticulous/downloading-helpers");
|
|
12
11
|
const sentry_utils_1 = require("../../command-utils/sentry.utils");
|
|
13
|
-
const
|
|
14
|
-
|
|
12
|
+
const AGENT_IMAGES_SUBDIR = "agent-images";
|
|
13
|
+
const MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
14
|
+
const getAgentImagesDir = () => (0, path_1.join)((0, common_1.getMeticulousLocalDataDir)(), AGENT_IMAGES_SUBDIR);
|
|
15
|
+
const cleanupOldImages = async (dir) => {
|
|
16
|
+
const logger = (0, common_1.initLogger)();
|
|
17
|
+
let entries;
|
|
18
|
+
try {
|
|
19
|
+
entries = await (0, promises_1.readdir)(dir);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const cutoff = Date.now() - MAX_AGE_MS;
|
|
25
|
+
await Promise.all(entries.map(async (entry) => {
|
|
26
|
+
const entryPath = (0, path_1.join)(dir, entry);
|
|
27
|
+
try {
|
|
28
|
+
const stats = await (0, promises_1.stat)(entryPath);
|
|
29
|
+
if (stats.isFile() && stats.mtimeMs < cutoff) {
|
|
30
|
+
await (0, promises_1.unlink)(entryPath);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
logger.debug(`Failed to inspect/remove ${entryPath}: ${error}`);
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
const downloadImage = async (dir, fileName, url) => {
|
|
39
|
+
const filePath = (0, path_1.join)(dir, fileName);
|
|
15
40
|
await (0, downloading_helpers_1.downloadFile)(url, filePath);
|
|
16
41
|
return filePath;
|
|
17
42
|
};
|
|
@@ -19,8 +44,9 @@ const handler = async ({ apiToken, replayDiffId, screenshotName, }) => {
|
|
|
19
44
|
(0, common_1.initLogger)();
|
|
20
45
|
const client = (0, client_1.createClient)({ apiToken });
|
|
21
46
|
const urls = await (0, client_1.getScreenshotUrls)(client, replayDiffId, screenshotName);
|
|
22
|
-
const
|
|
23
|
-
await (0, promises_1.mkdir)(
|
|
47
|
+
const dir = getAgentImagesDir();
|
|
48
|
+
await (0, promises_1.mkdir)(dir, { recursive: true });
|
|
49
|
+
await cleanupOldImages(dir);
|
|
24
50
|
console.log(`outcome: ${urls.outcome}`);
|
|
25
51
|
const downloads = [];
|
|
26
52
|
if (urls.screenshot) {
|
|
@@ -35,14 +61,16 @@ const handler = async ({ apiToken, replayDiffId, screenshotName, }) => {
|
|
|
35
61
|
if (urls.diffImage) {
|
|
36
62
|
downloads.push({ label: "diffImage", url: urls.diffImage });
|
|
37
63
|
}
|
|
38
|
-
const
|
|
64
|
+
const timestamp = Date.now();
|
|
65
|
+
const prefix = `${timestamp}_${replayDiffId}_${screenshotName}`;
|
|
66
|
+
const results = await Promise.all(downloads.map(({ label, url }) => downloadImage(dir, `${prefix}_${label}.png`, url)));
|
|
39
67
|
for (let i = 0; i < downloads.length; i++) {
|
|
40
68
|
console.log(`${downloads[i].label}: ${results[i]}`);
|
|
41
69
|
}
|
|
42
70
|
};
|
|
43
71
|
exports.imageFilesCommand = {
|
|
44
72
|
command: "image-files",
|
|
45
|
-
describe: "Download screenshot images for a replay diff screenshot to local
|
|
73
|
+
describe: "Download screenshot images for a replay diff screenshot to local files under ~/.meticulous/agent-images",
|
|
46
74
|
builder: {
|
|
47
75
|
apiToken: { string: true, description: "Meticulous API token" },
|
|
48
76
|
replayDiffId: {
|
|
@@ -59,4 +87,4 @@ exports.imageFilesCommand = {
|
|
|
59
87
|
handler: (0, sentry_utils_1.wrapHandler)(handler),
|
|
60
88
|
};
|
|
61
89
|
//# sourceMappingURL=screenshot-image-files.command.js.map
|
|
62
|
-
//# debugId=
|
|
90
|
+
//# debugId=9277f775-c52a-556c-99d0-389c4257c25c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot-image-files.command.js","sources":["../../../src/commands/agent/screenshot-image-files.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"screenshot-image-files.command.js","sources":["../../../src/commands/agent/screenshot-image-files.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,0CAA2D;AAC3D,+BAA4B;AAC5B,qDAA2E;AAC3E,qDAGkC;AAClC,+EAAqE;AAErE,mEAA+D;AAQ/D,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAC3C,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,iBAAiB,GAAG,GAAW,EAAE,CACrC,IAAA,WAAI,EAAC,IAAA,kCAAyB,GAAE,EAAE,mBAAmB,CAAC,CAAC;AAEzD,MAAM,gBAAgB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AAI,cAAc,EAAE,CAAC;IAEhE,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAC/B,aAAa,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,KAAK,MAAM,EAAE,GAAG,CAAC,CAClD,CACF,CAAC;IAEF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,iBAAiB,GAAoC;IAChE,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,yGAAyG;IAC3G,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE;QAC/D,YAAY,EAAE;YACZ,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,oBAAoB;YACjC,YAAY,EAAE,IAAI;SACnB;QACD,cAAc,EAAE;YACd,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,uDAAuD;YACpE,YAAY,EAAE,IAAI;SACnB;KACF;IACD,OAAO,EAAE,IAAA,0BAAW,EAAC,OAAO,CAAC;CAC9B,CAAC","debugId":"9277f775-c52a-556c-99d0-389c4257c25c"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysmeticulous/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.279.0",
|
|
4
4
|
"description": "The Meticulous CLI",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"bugs": {
|
|
76
76
|
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "45f95ba2250c5e71034a848bc8031cddb5cf105c"
|
|
79
79
|
}
|