@sentinelqa/uploader 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +44 -3
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -73,6 +73,38 @@ const listFilesRecursive = (dirPath) => {
73
73
  }
74
74
  return results;
75
75
  };
76
+ const findLatestMatch = (dirPath, matcher) => {
77
+ if (!fs_1.default.existsSync(dirPath))
78
+ return null;
79
+ if (!fs_1.default.statSync(dirPath).isDirectory())
80
+ return null;
81
+ const entries = fs_1.default.readdirSync(dirPath, { withFileTypes: true });
82
+ const files = entries
83
+ .filter((e) => e.isFile() && matcher(e.name))
84
+ .map((e) => path_1.default.join(dirPath, e.name));
85
+ if (files.length === 0)
86
+ return null;
87
+ files.sort((a, b) => fs_1.default.statSync(b).mtimeMs - fs_1.default.statSync(a).mtimeMs);
88
+ return files[0];
89
+ };
90
+ const detectPlaywrightJson = () => {
91
+ const envPath = readEnv("PLAYWRIGHT_JSON_PATH");
92
+ if (envPath && fs_1.default.existsSync(envPath) && fs_1.default.statSync(envPath).isFile()) {
93
+ return envPath;
94
+ }
95
+ const defaultPath = DEFAULT_JSON_PATH;
96
+ if (fs_1.default.existsSync(defaultPath) && fs_1.default.statSync(defaultPath).isFile()) {
97
+ return defaultPath;
98
+ }
99
+ const reportPattern = (name) => name.startsWith("report-") && name.endsWith(".json");
100
+ const latestReport = findLatestMatch(DEFAULT_TEST_RESULTS_DIR, reportPattern);
101
+ if (latestReport)
102
+ return latestReport;
103
+ const anyJson = findLatestMatch(DEFAULT_TEST_RESULTS_DIR, (name) => name.endsWith(".json"));
104
+ if (anyJson)
105
+ return anyJson;
106
+ return null;
107
+ };
76
108
  const normalizeError = (value) => {
77
109
  if (!value)
78
110
  return null;
@@ -261,9 +293,18 @@ const main = async () => {
261
293
  const ingestToken = readEnv("SENTINEL_TOKEN") || readEnv("PROJECT_INGEST_TOKEN");
262
294
  if (!ingestToken)
263
295
  fail("SENTINEL_TOKEN is required.");
264
- const playwrightJsonPath = getArgValue(args, "--playwright-json-path") ||
265
- readEnv("PLAYWRIGHT_JSON_PATH") ||
266
- DEFAULT_JSON_PATH;
296
+ const cliJsonPath = getArgValue(args, "--playwright-json-path");
297
+ const playwrightJsonPath = cliJsonPath || detectPlaywrightJson();
298
+ if (!playwrightJsonPath) {
299
+ fail([
300
+ "PLAYWRIGHT_JSON_PATH not found.",
301
+ "Checked:",
302
+ `- ${readEnv("PLAYWRIGHT_JSON_PATH") || "(env not set)"}`,
303
+ `- ${DEFAULT_JSON_PATH}`,
304
+ `- ${DEFAULT_TEST_RESULTS_DIR}/report-*.json`,
305
+ `- ${DEFAULT_TEST_RESULTS_DIR}/*.json`
306
+ ].join("\n"));
307
+ }
267
308
  const playwrightReportDir = getArgValue(args, "--playwright-report-dir") ||
268
309
  readEnv("PLAYWRIGHT_REPORT_DIR") ||
269
310
  DEFAULT_PLAYWRIGHT_REPORT_DIR;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentinelqa/uploader",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Sentinel uploader CLI for CI/CD debugging artifacts",
6
6
  "license": "MIT",