allure 3.0.0-beta.18 → 3.0.0-beta.19

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.
@@ -7,5 +7,6 @@ export declare class GenerateCommand extends Command {
7
7
  output: string | undefined;
8
8
  cwd: string | undefined;
9
9
  reportName: string | undefined;
10
+ stage: string[] | undefined;
10
11
  execute(): Promise<void>;
11
12
  }
@@ -1,10 +1,10 @@
1
1
  import { AllureReport, readConfig } from "@allurereport/core";
2
- import { findMatching } from "@allurereport/directory-watcher";
3
2
  import { KnownError } from "@allurereport/service";
4
3
  import { Command, Option } from "clipanion";
5
- import { join } from "node:path";
6
- import process from "node:process";
7
- import pm from "picomatch";
4
+ import { glob } from "glob";
5
+ import * as console from "node:console";
6
+ import { sep } from "node:path";
7
+ import { exit, cwd as processCwd } from "node:process";
8
8
  import { red } from "yoctocolors";
9
9
  import { logError } from "../utils/logs.js";
10
10
  export class GenerateCommand extends Command {
@@ -24,34 +24,51 @@ export class GenerateCommand extends Command {
24
24
  description: "The working directory for the command to run (default: current working directory)",
25
25
  });
26
26
  this.reportName = Option.String("--report-name,--name", {
27
- description: "The report name",
27
+ description: "The report name (default: Allure Report)",
28
+ });
29
+ this.stage = Option.Array("--stage", {
30
+ description: "Stages archives to restore state from (default: empty string)",
28
31
  });
29
32
  }
30
33
  async execute() {
31
- const cwd = this.cwd ?? process.cwd();
34
+ const cwd = this.cwd ?? processCwd();
32
35
  const resultsDir = (this.resultsDir ?? "./**/allure-results").replace(/[\\/]$/, "");
33
36
  const config = await readConfig(cwd, this.config, {
34
37
  name: this.reportName,
35
38
  output: this.output ?? "allure-report",
36
39
  });
37
- const matcher = pm(resultsDir, {
38
- dot: true,
39
- contains: true,
40
- });
41
- const resultsDirectories = new Set();
42
- await findMatching(cwd, resultsDirectories, (dirent) => {
43
- if (dirent.isDirectory()) {
44
- const fullPath = join(dirent?.parentPath ?? dirent?.path, dirent.name);
45
- return matcher(fullPath);
40
+ const stageDumpFiles = [];
41
+ const resultsDirectories = [];
42
+ if (this.stage?.length) {
43
+ for (const stage of this.stage) {
44
+ const matchedFiles = await glob(stage, {
45
+ nodir: true,
46
+ dot: true,
47
+ absolute: true,
48
+ windowsPathsNoEscape: true,
49
+ cwd,
50
+ });
51
+ stageDumpFiles.push(...matchedFiles);
46
52
  }
47
- return false;
48
- });
49
- if (resultsDirectories.size === 0) {
53
+ }
54
+ if (!!this.resultsDir || stageDumpFiles.length === 0) {
55
+ const matchedDirs = (await glob(resultsDir, {
56
+ mark: true,
57
+ nodir: false,
58
+ absolute: true,
59
+ dot: true,
60
+ windowsPathsNoEscape: true,
61
+ cwd,
62
+ })).filter((p) => p.endsWith(sep));
63
+ resultsDirectories.push(...matchedDirs);
64
+ }
65
+ if (resultsDirectories.length === 0 && stageDumpFiles.length === 0) {
50
66
  console.log(red(`No test results directories found matching pattern: ${resultsDir}`));
51
67
  return;
52
68
  }
53
69
  try {
54
70
  const allureReport = new AllureReport(config);
71
+ await allureReport.restoreState(Array.from(stageDumpFiles));
55
72
  await allureReport.start();
56
73
  for (const dir of resultsDirectories) {
57
74
  await allureReport.readDirectory(dir);
@@ -61,11 +78,11 @@ export class GenerateCommand extends Command {
61
78
  catch (error) {
62
79
  if (error instanceof KnownError) {
63
80
  console.error(red(error.message));
64
- process.exit(1);
81
+ exit(1);
65
82
  return;
66
83
  }
67
84
  await logError("Failed to generate report due to unexpected error", error);
68
- process.exit(1);
85
+ exit(1);
69
86
  }
70
87
  }
71
88
  }
@@ -79,5 +96,13 @@ GenerateCommand.usage = Command.Usage({
79
96
  "generate ./allure-results --output custom-report",
80
97
  "Generate a report from the ./allure-results directory to the custom-report directory",
81
98
  ],
99
+ [
100
+ "generate --stage=windows.zip --stage=macos.zip ./allure-results",
101
+ "Generate a report using data from windows.zip and macos.zip archives and using results from the ./allure-results directory",
102
+ ],
103
+ [
104
+ "generate --stage=allure-*.zip",
105
+ "Generate a report using data from any stage archive that matches the given pattern only (ignoring results directories)",
106
+ ],
82
107
  ],
83
108
  });
@@ -1,11 +1,10 @@
1
1
  import { AllureReport, QualityGateState, readConfig, stringifyQualityGateResults } from "@allurereport/core";
2
- import { findMatching } from "@allurereport/directory-watcher";
3
2
  import { Command, Option } from "clipanion";
3
+ import { glob } from "glob";
4
4
  import * as console from "node:console";
5
5
  import { realpath } from "node:fs/promises";
6
- import { join } from "node:path";
6
+ import { sep } from "node:path";
7
7
  import { exit, cwd as processCwd } from "node:process";
8
- import pm from "picomatch";
9
8
  import * as typanion from "typanion";
10
9
  import { red } from "yoctocolors";
11
10
  export class QualityGateCommand extends Command {
@@ -48,11 +47,6 @@ export class QualityGateCommand extends Command {
48
47
  knownIssuesPath,
49
48
  });
50
49
  const rules = {};
51
- const resultsDirectories = new Set();
52
- const matcher = pm(resultsDir, {
53
- dot: true,
54
- contains: true,
55
- });
56
50
  if (maxFailures !== undefined) {
57
51
  rules.maxFailures = maxFailures;
58
52
  }
@@ -78,14 +72,15 @@ export class QualityGateCommand extends Command {
78
72
  exit(-1);
79
73
  return;
80
74
  }
81
- await findMatching(cwd, resultsDirectories, (dirent) => {
82
- if (dirent.isDirectory()) {
83
- const fullPath = join(dirent?.parentPath ?? dirent?.path, dirent.name);
84
- return matcher(fullPath);
85
- }
86
- return false;
87
- });
88
- if (resultsDirectories.size === 0) {
75
+ const resultsDirectories = (await glob(resultsDir, {
76
+ mark: true,
77
+ nodir: false,
78
+ absolute: true,
79
+ dot: true,
80
+ windowsPathsNoEscape: true,
81
+ cwd,
82
+ })).filter((p) => p.endsWith(sep));
83
+ if (resultsDirectories.length === 0) {
89
84
  console.error("No Allure results directories found");
90
85
  exit(0);
91
86
  return;
@@ -4,14 +4,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _ResultsPackCommand_instances, _ResultsPackCommand_formatSize;
7
- import { findMatching } from "@allurereport/directory-watcher";
8
7
  import AdmZip from "adm-zip";
9
8
  import { Command, Option } from "clipanion";
9
+ import { glob } from "glob";
10
10
  import * as console from "node:console";
11
11
  import * as fs from "node:fs/promises";
12
12
  import { realpath } from "node:fs/promises";
13
- import { basename, join, resolve } from "node:path";
14
- import pm from "picomatch";
13
+ import { basename, join, resolve, sep } from "node:path";
15
14
  import { green, red } from "yoctocolors";
16
15
  export class ResultsPackCommand extends Command {
17
16
  constructor() {
@@ -32,20 +31,16 @@ export class ResultsPackCommand extends Command {
32
31
  const cwd = await realpath(this.cwd ?? process.cwd());
33
32
  const resultsDir = (this.resultsDir ?? "./**/allure-results").replace(/[\\/]$/, "");
34
33
  const archiveName = this.name ?? "allure-results.zip";
35
- const resultsDirectories = new Set();
36
- const resultsFiles = new Set();
37
- const matcher = pm(resultsDir, {
34
+ const resultsDirectories = (await glob(resultsDir, {
35
+ mark: true,
36
+ nodir: false,
38
37
  dot: true,
39
- contains: true,
40
- });
41
- await findMatching(cwd, resultsDirectories, (dirent) => {
42
- if (dirent.isDirectory()) {
43
- const fullPath = join(dirent?.parentPath ?? dirent?.path, dirent.name);
44
- return matcher(fullPath);
45
- }
46
- return false;
47
- });
48
- if (resultsDirectories.size === 0) {
38
+ absolute: true,
39
+ windowsPathsNoEscape: true,
40
+ cwd,
41
+ })).filter((p) => p.endsWith(sep));
42
+ const resultsFiles = new Set();
43
+ if (resultsDirectories.length === 0) {
49
44
  console.log(red(`No test results directories found matching pattern: ${resultsDir}`));
50
45
  return;
51
46
  }
@@ -16,7 +16,9 @@ export declare class RunCommand extends Command {
16
16
  rerun: string | undefined;
17
17
  silent: boolean | undefined;
18
18
  ignoreLogs: boolean | undefined;
19
+ stage: string | undefined;
20
+ environment: string | undefined;
19
21
  commandToRun: string[];
20
- get logs(): "pipe" | "ignore" | "inherit";
22
+ get logs(): "pipe" | "inherit" | "ignore";
21
23
  execute(): Promise<void>;
22
24
  }
@@ -151,6 +151,12 @@ export class RunCommand extends Command {
151
151
  this.ignoreLogs = Option.Boolean("--ignore-logs", {
152
152
  description: "Prevent logs attaching to the report (default: false)",
153
153
  });
154
+ this.stage = Option.String("--stage", {
155
+ description: "Runs tests in stage mode to collect results to a stage archive with the provided name (default: empty string)",
156
+ });
157
+ this.environment = Option.String("--environment", {
158
+ description: "Force specific environment to all tests in the run. Given environment has higher priority than the one defined in the config file (default: empty string)",
159
+ });
154
160
  this.commandToRun = Option.Rest();
155
161
  }
156
162
  get logs() {
@@ -192,6 +198,8 @@ export class RunCommand extends Command {
192
198
  }
193
199
  const allureReport = new AllureReport({
194
200
  ...config,
201
+ environment: this.environment,
202
+ stage: this.stage,
195
203
  realTime: false,
196
204
  plugins: [
197
205
  ...(config.plugins?.length
@@ -321,5 +329,9 @@ RunCommand.usage = Command.Usage({
321
329
  examples: [
322
330
  ["run -- npm run test", "Run npm run test and collect Allure results"],
323
331
  ["run --rerun 3 -- npm run test", "Run npm run test and rerun failed tests up to 3 times"],
332
+ [
333
+ "run --stage=my-stage -- npm run test",
334
+ "Run npm run test and pack inner report state into my-stage.zip archive to restore the state in the next run",
335
+ ],
324
336
  ],
325
337
  });
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { defineConfig } from "@allurereport/plugin-api";
1
+ export { defineConfig, defaultChartsConfig } from "@allurereport/plugin-api";
package/dist/index.js CHANGED
@@ -36,4 +36,4 @@ cli.register(ResultsUnpackCommand);
36
36
  cli.register(Builtins.HelpCommand);
37
37
  cli.runExit(args);
38
38
  console.log(cwd());
39
- export { defineConfig } from "@allurereport/plugin-api";
39
+ export { defineConfig, defaultChartsConfig } from "@allurereport/plugin-api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allure",
3
- "version": "3.0.0-beta.18",
3
+ "version": "3.0.0-beta.19",
4
4
  "description": "Allure Commandline Tool",
5
5
  "keywords": [
6
6
  "allure",
@@ -31,26 +31,26 @@
31
31
  "test": "vitest run"
32
32
  },
33
33
  "dependencies": {
34
- "@allurereport/core": "3.0.0-beta.18",
35
- "@allurereport/core-api": "3.0.0-beta.18",
36
- "@allurereport/directory-watcher": "3.0.0-beta.18",
37
- "@allurereport/plugin-allure2": "3.0.0-beta.18",
38
- "@allurereport/plugin-api": "3.0.0-beta.18",
39
- "@allurereport/plugin-awesome": "3.0.0-beta.18",
40
- "@allurereport/plugin-classic": "3.0.0-beta.18",
41
- "@allurereport/plugin-csv": "3.0.0-beta.18",
42
- "@allurereport/plugin-dashboard": "3.0.0-beta.18",
43
- "@allurereport/plugin-log": "3.0.0-beta.18",
44
- "@allurereport/plugin-progress": "3.0.0-beta.18",
45
- "@allurereport/plugin-server-reload": "3.0.0-beta.18",
46
- "@allurereport/plugin-slack": "3.0.0-beta.18",
47
- "@allurereport/reader-api": "3.0.0-beta.18",
48
- "@allurereport/service": "3.0.0-beta.18",
49
- "@allurereport/static-server": "3.0.0-beta.18",
34
+ "@allurereport/core": "3.0.0-beta.19",
35
+ "@allurereport/core-api": "3.0.0-beta.19",
36
+ "@allurereport/directory-watcher": "3.0.0-beta.19",
37
+ "@allurereport/plugin-allure2": "3.0.0-beta.19",
38
+ "@allurereport/plugin-api": "3.0.0-beta.19",
39
+ "@allurereport/plugin-awesome": "3.0.0-beta.19",
40
+ "@allurereport/plugin-classic": "3.0.0-beta.19",
41
+ "@allurereport/plugin-csv": "3.0.0-beta.19",
42
+ "@allurereport/plugin-dashboard": "3.0.0-beta.19",
43
+ "@allurereport/plugin-log": "3.0.0-beta.19",
44
+ "@allurereport/plugin-progress": "3.0.0-beta.19",
45
+ "@allurereport/plugin-server-reload": "3.0.0-beta.19",
46
+ "@allurereport/plugin-slack": "3.0.0-beta.19",
47
+ "@allurereport/reader-api": "3.0.0-beta.19",
48
+ "@allurereport/service": "3.0.0-beta.19",
49
+ "@allurereport/static-server": "3.0.0-beta.19",
50
50
  "adm-zip": "^0.5.16",
51
51
  "clipanion": "^4.0.0-rc.4",
52
+ "glob": "^11.0.3",
52
53
  "lodash.omit": "^4.5.0",
53
- "picomatch": "^4.0.3",
54
54
  "prompts": "^2.4.2",
55
55
  "terminate": "^2.8.0",
56
56
  "typanion": "^3.14.0",
@@ -62,7 +62,6 @@
62
62
  "@types/eslint": "^8.56.11",
63
63
  "@types/lodash.omit": "^4.5.9",
64
64
  "@types/node": "^20.17.9",
65
- "@types/picomatch": "^4",
66
65
  "@types/prompts": "^2",
67
66
  "@typescript-eslint/eslint-plugin": "^8.0.0",
68
67
  "@typescript-eslint/parser": "^8.0.0",