allure 3.0.0-beta.2 → 3.0.0-beta.21

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 (70) hide show
  1. package/README.md +148 -16
  2. package/dist/commands/allure2.d.ts +15 -0
  3. package/dist/commands/allure2.js +77 -0
  4. package/dist/commands/awesome.d.ts +18 -12
  5. package/dist/commands/awesome.js +83 -75
  6. package/dist/commands/classic.d.ts +15 -11
  7. package/dist/commands/classic.js +71 -63
  8. package/dist/commands/csv.d.ts +13 -9
  9. package/dist/commands/csv.js +63 -45
  10. package/dist/commands/dashboard.d.ts +15 -0
  11. package/dist/commands/dashboard.js +77 -0
  12. package/dist/commands/generate.d.ts +12 -9
  13. package/dist/commands/generate.js +98 -26
  14. package/dist/commands/history.d.ts +9 -7
  15. package/dist/commands/history.js +32 -29
  16. package/dist/commands/index.d.ts +8 -0
  17. package/dist/commands/index.js +8 -0
  18. package/dist/commands/jira/clear.d.ts +16 -0
  19. package/dist/commands/jira/clear.js +113 -0
  20. package/dist/commands/jira/index.d.ts +1 -0
  21. package/dist/commands/jira/index.js +1 -0
  22. package/dist/commands/knownIssue.d.ts +8 -6
  23. package/dist/commands/knownIssue.js +31 -20
  24. package/dist/commands/log.d.ts +12 -7
  25. package/dist/commands/log.js +58 -40
  26. package/dist/commands/login.d.ts +8 -0
  27. package/dist/commands/login.js +50 -0
  28. package/dist/commands/logout.d.ts +8 -0
  29. package/dist/commands/logout.js +50 -0
  30. package/dist/commands/open.d.ts +11 -8
  31. package/dist/commands/open.js +36 -36
  32. package/dist/commands/projects/create.d.ts +9 -0
  33. package/dist/commands/projects/create.js +83 -0
  34. package/dist/commands/projects/delete.d.ts +10 -0
  35. package/dist/commands/projects/delete.js +68 -0
  36. package/dist/commands/projects/index.d.ts +3 -0
  37. package/dist/commands/projects/index.js +3 -0
  38. package/dist/commands/projects/list.d.ts +8 -0
  39. package/dist/commands/projects/list.js +75 -0
  40. package/dist/commands/qualityGate.d.ts +14 -6
  41. package/dist/commands/qualityGate.js +125 -39
  42. package/dist/commands/results/index.d.ts +2 -0
  43. package/dist/commands/results/index.js +2 -0
  44. package/dist/commands/results/pack.d.ts +10 -0
  45. package/dist/commands/results/pack.js +106 -0
  46. package/dist/commands/results/unpack.d.ts +9 -0
  47. package/dist/commands/results/unpack.js +79 -0
  48. package/dist/commands/run.d.ts +24 -10
  49. package/dist/commands/run.js +279 -109
  50. package/dist/commands/slack.d.ts +9 -5
  51. package/dist/commands/slack.js +55 -31
  52. package/dist/commands/testplan.d.ts +8 -6
  53. package/dist/commands/testplan.js +38 -30
  54. package/dist/commands/watch.d.ts +12 -10
  55. package/dist/commands/watch.js +110 -106
  56. package/dist/commands/whoami.d.ts +8 -0
  57. package/dist/commands/whoami.js +57 -0
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.js +36 -28
  60. package/dist/utils/index.d.ts +1 -0
  61. package/dist/utils/index.js +1 -0
  62. package/dist/utils/logs.d.ts +3 -0
  63. package/dist/utils/logs.js +32 -0
  64. package/dist/utils/process.d.ts +8 -2
  65. package/dist/utils/process.js +17 -6
  66. package/dist/utils/terminal.d.ts +1 -1
  67. package/dist/utils/terminal.js +1 -1
  68. package/package.json +35 -15
  69. package/dist/utils/commands.d.ts +0 -16
  70. package/dist/utils/commands.js +0 -14
package/README.md CHANGED
@@ -1,33 +1,165 @@
1
- # Allure CLI
2
-
1
+ # Allure 3
2
+
3
+ **Allure 3** is the next evolution of the Allure reporting framework, rebuilt from the ground up with a new architecture and expanded capabilities. Unlike its predecessor, **Allure 2**, this version is developed in **TypeScript** and introduces a modular plugin system for greater flexibility. A key addition is the **Awesome** plugin, which delivers an enhanced UI for better report visualization.
4
+
5
+ > 🚧 **Allure 3 is currently in beta and under active development.**
6
+ > Although not production-ready, we encourage users to install, explore, and share feedback with the development team.
7
+
8
+ The **Allure 3 CLI** provides a comprehensive suite of commands designed to streamline the generation, serving, and management of test reports.
9
+
3
10
  [<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")
4
11
 
5
12
  - Learn more about Allure Report at https://allurereport.org
6
13
  - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
7
14
  - ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
8
- - 📢 [Official announcements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
15
+ - 📢 [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
9
16
  - 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community
10
17
 
11
- ---
18
+ ## Key Features
19
+
20
+ Allure 3 introduces several notable improvements. The framework has been entirely rewritten in **TypeScript**, making it more extensible and easier to maintain. Its **plugin system** allows you to customize and extend reporting functionality to fit your specific needs. Configuration has been simplified with a **single file** managing all report settings, making it more convenient to handle multiple reports.
21
+
22
+ One of the standout features is **real-time reporting**, which lets you view live updates during test execution using the `watch` command. The report interface itself has been redesigned to enhance usability and clarity. Moreover, Allure 3 maintains **compatibility with the entire Allure ecosystem**, supporting all major test frameworks.
23
+
24
+ > 🚧 Please note that **official CI/CD integrations and IDE plugins are not yet available** for Allure 3.
25
+
26
+ ## Installation
27
+
28
+ To install Allure 3 globally, you can use [`npm`](https://docs.npmjs.com/downloading-and-installing-packages-globally). Simply run:
29
+
30
+ ```bash
31
+ npm install -g allure
32
+ ```
33
+
34
+ However, we recommend using `npx` for running Allure commands without needing a global installation:
35
+
36
+ ```bash
37
+ npx allure run -- <test_command>
38
+ ```
39
+
40
+ This approach ensures you always use the latest version without managing global dependencies.
12
41
 
13
- ## Overview
42
+ ## Commands
14
43
 
15
- The Allure CLI is a main entry point which includes many sub-commands
44
+ ### Running Tests and Generating Reports
16
45
 
17
- ## Install
46
+ Running tests and generating a report with Allure 3 is straightforward. Using the `run` command, you can execute your test suite and automatically generate a report:
18
47
 
19
- Use your favorite package manager to install the package:
48
+ ```bash
49
+ npx allure run -- <test_command>
50
+ ```
51
+
52
+ For example, if you're using `npm` as your test runner, the command would be:
20
53
 
21
- ```shell
22
- npm add allure
23
- yarn add allure
24
- pnpm add allure
54
+ ```bash
55
+ npx allure run -- npm test
25
56
  ```
26
57
 
27
- ## Usage
58
+ To successfully generate a report, ensure that your test setup outputs results into an `allure-results` directory, which is automatically detected by Allure 3. This directory can be placed at any nested level within your project (e.g., `out/tests/allure-results`), provided it retains the correct name.
59
+
60
+ After the tests complete, the report is generated automatically. Existing results from previous runs are ignored, as Allure 3 focuses solely on new data to ensure accurate and up-to-date reporting.
61
+
62
+ ### Generating Reports Manually
28
63
 
29
- The CLI provides a set of commands to work with Allure Report features. To see the list of available commands, run:
64
+ If you already have test results and wish to generate a report manually, use the `generate` command:
30
65
 
31
- ```shell
32
- allure --help
66
+ ```bash
67
+ npx allure generate <resultsDir>
33
68
  ```
69
+
70
+ By default, this command produces an **Allure 3 Awesome** report. You can customize output settings, such as the destination directory, through the configuration file. If you prefer a **Classic** or **Allure 2-style** report, or need to disable certain plugins, these adjustments can also be made via configuration.
71
+
72
+ ### Viewing Reports
73
+
74
+ To view a previously generated report locally, the `open` command serves it in your default browser:
75
+
76
+ ```bash
77
+ npx allure open <reportDir>
78
+ ```
79
+
80
+ If you’ve defined the output directory in your configuration file, specifying `<reportDir>` is optional. By default, Allure 3 looks for a directory named `allure-report`. To open the Awesome report directly, point to the nested directory:
81
+
82
+ ```bash
83
+ npx allure open allure-report/awesome
84
+ ```
85
+
86
+ ### Real-time Report Monitoring
87
+
88
+ When you need to monitor test execution live, the `watch` command provides dynamic report updates. It continuously monitors the specified results directory for changes and refreshes the report automatically:
89
+
90
+ ```bash
91
+ npx allure watch <allureResultsDir>
92
+ ```
93
+
94
+ This command is ideal for iterative development and debugging, allowing you to see immediate feedback as you modify and rerun tests. The browser tab updates seamlessly whenever new results are detected.
95
+
96
+ ### Command-line Options
97
+
98
+ The Allure CLI includes several helpful global options. Use `--help` to explore available commands or get detailed usage information for a specific command:
99
+
100
+ ```bash
101
+ npx allure run --help
102
+ npx allure watch --help
103
+ ```
104
+
105
+ To check your installed version of Allure 3, use:
106
+
107
+ ```bash
108
+ npx allure --version
109
+ ```
110
+
111
+
112
+ ## Configuration
113
+
114
+ Allure 3 uses an `allurerc.mjs` configuration file to manage report settings, including the report name, output directory, and plugin options.
115
+
116
+ > 💡 **Tip:** We recommend using the **Awesome** plugin for the best experience.
117
+ > Support for Classic and Allure 2-style reports is currently experimental.
118
+
119
+ ### Example Configuration File
120
+
121
+ ```js
122
+ import { defineConfig } from "allure";
123
+
124
+ export default defineConfig({
125
+ name: "Allure Report Example",
126
+ output: "./out/allure-report",
127
+ plugins: {
128
+ awesome: {
129
+ options: {
130
+ singleFile: true,
131
+ reportLanguage: "en",
132
+ },
133
+ },
134
+ },
135
+ });
136
+ ```
137
+
138
+ In this example, the generated report is named *Allure Report Example* and saved to the `./out/allure-report` directory. The **Awesome** plugin is enabled with options to produce a single-file HTML report in English.
139
+
140
+ ### Configuration Options
141
+
142
+ The configuration file allows you to fine-tune report generation. Key options include:
143
+
144
+ - **`name`**: Specifies the report’s display name.
145
+ - **`output`**: Defines the directory where the report will be saved.
146
+ - **`plugins`**: Enables and configures plugins, with each supporting various options.
147
+
148
+ ### Awesome Plugin Options
149
+
150
+ The **Awesome** plugin offers several customizable options:
151
+
152
+ - **`singleFile`** *(boolean)*: If set to `true`, generates the report as a single standalone HTML file.
153
+ - **`reportName`** *(string)*: Overrides the default report name.
154
+ - **`open`** *(boolean)*: Automatically opens the report after generation if enabled.
155
+ - **`reportLanguage`** *(string)*: Sets the UI language of the report. Supported languages include:
156
+
157
+ `az`, `br`, `de`, `en`, `es`, `fr`, `he`, `ja`, `kr`, `nl`, `pl`, `ru`, `sv`, `tr`, `zh`.
158
+
159
+ For example, setting `"reportLanguage": "fr"` will render the report interface in French.
160
+
161
+ ## Final Notes
162
+
163
+ Allure 3 represents a significant step forward in test reporting, offering improved performance, flexibility, and an enhanced user interface. While it remains in beta, the framework is stable enough for exploration and feedback. We encourage you to experiment with the **Awesome** plugin and share your insights to help us refine the experience.
164
+
165
+ Stay updated with the latest features, and don’t hesitate to contribute or report issues. Together, we can make Allure 3 the best it can be!
@@ -0,0 +1,15 @@
1
+ import { Command } from "clipanion";
2
+ export declare class Allure2Command extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ resultsDir: string;
6
+ config: string | undefined;
7
+ cwd: string | undefined;
8
+ output: string | undefined;
9
+ reportName: string | undefined;
10
+ reportLanguage: string | undefined;
11
+ singleFile: boolean | undefined;
12
+ historyPath: string | undefined;
13
+ knownIssues: string | undefined;
14
+ execute(): Promise<void>;
15
+ }
@@ -0,0 +1,77 @@
1
+ import { AllureReport, readConfig } from "@allurereport/core";
2
+ import Allure2Plugin from "@allurereport/plugin-allure2";
3
+ import { Command, Option } from "clipanion";
4
+ import * as console from "node:console";
5
+ import { realpath } from "node:fs/promises";
6
+ import process from "node:process";
7
+ export class Allure2Command extends Command {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
11
+ this.config = Option.String("--config,-c", {
12
+ description: "The path Allure config file",
13
+ });
14
+ this.cwd = Option.String("--cwd", {
15
+ description: "The working directory for the command to run (default: current working directory)",
16
+ });
17
+ this.output = Option.String("--output,-o", {
18
+ description: "The output directory name. Absolute paths are accepted as well",
19
+ });
20
+ this.reportName = Option.String("--report-name,--name", {
21
+ description: "The report name",
22
+ });
23
+ this.reportLanguage = Option.String("--report-language,--lang", {
24
+ description: "Default language of the report (default: OS language)",
25
+ });
26
+ this.singleFile = Option.Boolean("--single-file", {
27
+ description: "Generate single file report",
28
+ });
29
+ this.historyPath = Option.String("--history-path,-h", {
30
+ description: "The path to history file",
31
+ });
32
+ this.knownIssues = Option.String("--known-issues", {
33
+ description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
34
+ });
35
+ }
36
+ async execute() {
37
+ const cwd = await realpath(this.cwd ?? process.cwd());
38
+ const before = new Date().getTime();
39
+ const defaultAllure2Options = {
40
+ singleFile: this.singleFile ?? false,
41
+ reportLanguage: this.reportLanguage,
42
+ };
43
+ const config = await readConfig(cwd, this.config, {
44
+ output: this.output ?? "allure-report",
45
+ name: this.reportName ?? "Allure Report",
46
+ knownIssuesPath: this.knownIssues,
47
+ historyPath: this.historyPath,
48
+ });
49
+ config.plugins = [
50
+ {
51
+ id: "allure2",
52
+ enabled: true,
53
+ options: defaultAllure2Options,
54
+ plugin: new Allure2Plugin(defaultAllure2Options),
55
+ },
56
+ ];
57
+ const allureReport = new AllureReport(config);
58
+ await allureReport.start();
59
+ await allureReport.readDirectory(this.resultsDir);
60
+ await allureReport.done();
61
+ const after = new Date().getTime();
62
+ console.log(`the report successfully generated (${after - before}ms)`);
63
+ }
64
+ }
65
+ Allure2Command.paths = [["allure2"]];
66
+ Allure2Command.usage = Command.Usage({
67
+ category: "Reports",
68
+ description: "Generates Allure Classic report based on provided Allure Results",
69
+ details: "This command generates an Allure Classic report from the provided Allure Results directory.",
70
+ examples: [
71
+ ["allure2 ./allure-results", "Generate a report from the ./allure-results directory"],
72
+ [
73
+ "allure2 ./allure-results --output custom-report",
74
+ "Generate a report from the ./allure-results directory to the custom-report directory",
75
+ ],
76
+ ],
77
+ });
@@ -1,12 +1,18 @@
1
- type AwesomeCommandOptions = {
2
- output?: string;
3
- reportName?: string;
4
- reportLanguage?: string;
5
- logo?: string;
6
- singleFile?: boolean;
7
- historyPath?: string;
8
- knownIssues?: string;
9
- };
10
- export declare const AwesomeCommandAction: (resultsDir: string, options: AwesomeCommandOptions) => Promise<void>;
11
- export declare const AwesomeCommand: (cli: import("cac").CAC) => void;
12
- export {};
1
+ import { Command } from "clipanion";
2
+ export declare class AwesomeCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ resultsDir: string;
6
+ config: string | undefined;
7
+ cwd: string | undefined;
8
+ output: string | undefined;
9
+ reportName: string | undefined;
10
+ singleFile: boolean | undefined;
11
+ logo: string | undefined;
12
+ theme: string | undefined;
13
+ reportLanguage: string | undefined;
14
+ historyPath: string | undefined;
15
+ knownIssues: string | undefined;
16
+ groupBy: string | undefined;
17
+ execute(): Promise<void>;
18
+ }
@@ -1,81 +1,89 @@
1
- import { AllureReport, resolveConfig } from "@allure/core";
2
- import { createCommand } from "../utils/commands.js";
3
- export const AwesomeCommandAction = async (resultsDir, options) => {
4
- const before = new Date().getTime();
5
- const { output, reportName: name, historyPath, knownIssues: knownIssuesPath, ...rest } = options;
6
- const config = await resolveConfig({
7
- output,
8
- name,
9
- historyPath,
10
- knownIssuesPath,
11
- plugins: {
12
- "@allure/plugin-awesome": {
13
- options: rest,
14
- },
15
- },
16
- });
17
- const allureReport = new AllureReport(config);
18
- await allureReport.start();
19
- await allureReport.readDirectory(resultsDir);
20
- await allureReport.done();
21
- const after = new Date().getTime();
22
- console.log(`the report successfully generated (${after - before}ms)`);
23
- };
24
- export const AwesomeCommand = createCommand({
25
- name: "awesome <resultsDir>",
26
- description: "Generates Allure Awesome report based on provided Allure Results",
27
- options: [
28
- [
29
- "--output, -o <file>",
30
- {
31
- description: "The output directory name. Absolute paths are accepted as well",
32
- default: "allure-report",
33
- },
34
- ],
35
- [
36
- "--report-name, --name <string>",
37
- {
38
- description: "The report name",
39
- default: "Allure Report",
40
- },
41
- ],
42
- [
43
- "--single-file",
44
- {
45
- description: "Generate single file report",
46
- default: false,
47
- },
48
- ],
49
- [
50
- "--logo <string>",
1
+ import { AllureReport, readConfig } from "@allurereport/core";
2
+ import { default as AwesomePlugin } from "@allurereport/plugin-awesome";
3
+ import { Command, Option } from "clipanion";
4
+ import * as console from "node:console";
5
+ import { realpath } from "node:fs/promises";
6
+ import process from "node:process";
7
+ export class AwesomeCommand extends Command {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
11
+ this.config = Option.String("--config,-c", {
12
+ description: "The path Allure config file",
13
+ });
14
+ this.cwd = Option.String("--cwd", {
15
+ description: "The working directory for the command to run (default: current working directory)",
16
+ });
17
+ this.output = Option.String("--output,-o", {
18
+ description: "The output directory name. Absolute paths are accepted as well",
19
+ });
20
+ this.reportName = Option.String("--report-name,--name", {
21
+ description: "The report name",
22
+ });
23
+ this.singleFile = Option.Boolean("--single-file", {
24
+ description: "Generate single file report",
25
+ });
26
+ this.logo = Option.String("--logo", {
27
+ description: "Path to the report logo which will be displayed in the header",
28
+ });
29
+ this.theme = Option.String("--theme", {
30
+ description: "Default theme of the report (default: OS theme)",
31
+ });
32
+ this.reportLanguage = Option.String("--report-language,--lang", {
33
+ description: "Default language of the report (default: OS language)",
34
+ });
35
+ this.historyPath = Option.String("--history-path,-h", {
36
+ description: "The path to history file",
37
+ });
38
+ this.knownIssues = Option.String("--known-issues", {
39
+ description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
40
+ });
41
+ this.groupBy = Option.String("--group-by,-g", {
42
+ description: "Group test results by labels. The labels should be separated by commas",
43
+ });
44
+ }
45
+ async execute() {
46
+ const cwd = await realpath(this.cwd ?? process.cwd());
47
+ const before = new Date().getTime();
48
+ const defaultAwesomeOptions = {
49
+ singleFile: this.singleFile ?? false,
50
+ logo: this.logo,
51
+ theme: this.theme,
52
+ reportLanguage: this.reportLanguage,
53
+ groupBy: this.groupBy?.split?.(",") ?? ["parentSuite", "suite", "subSuite"],
54
+ };
55
+ const config = await readConfig(cwd, this.config, {
56
+ output: this.output ?? "allure-report",
57
+ name: this.reportName ?? "Allure Report",
58
+ knownIssuesPath: this.knownIssues,
59
+ historyPath: this.historyPath,
60
+ });
61
+ config.plugins = [
51
62
  {
52
- description: "Path to the report logo which will be displayed in the header",
63
+ id: "awesome",
64
+ enabled: true,
65
+ options: defaultAwesomeOptions,
66
+ plugin: new AwesomePlugin(defaultAwesomeOptions),
53
67
  },
54
- ],
55
- [
56
- "--theme <string>",
57
- {
58
- description: "Default theme of the report (default: OS theme)",
59
- },
60
- ],
61
- [
62
- "--report-language, --lang <string>",
63
- {
64
- description: "Default language of the report (default: OS language)",
65
- },
66
- ],
67
- [
68
- "--history-path, -h <file>",
69
- {
70
- description: "The path to history file",
71
- },
72
- ],
68
+ ];
69
+ const allureReport = new AllureReport(config);
70
+ await allureReport.start();
71
+ await allureReport.readDirectory(this.resultsDir);
72
+ await allureReport.done();
73
+ const after = new Date().getTime();
74
+ console.log(`the report successfully generated (${after - before}ms)`);
75
+ }
76
+ }
77
+ AwesomeCommand.paths = [["awesome"]];
78
+ AwesomeCommand.usage = Command.Usage({
79
+ category: "Reports",
80
+ description: "Generates Allure Awesome report based on provided Allure Results",
81
+ details: "This command generates an Allure Awesome report from the provided Allure Results directory.",
82
+ examples: [
83
+ ["awesome ./allure-results", "Generate a report from the ./allure-results directory"],
73
84
  [
74
- "--known-issues <file>",
75
- {
76
- description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
77
- },
85
+ "awesome ./allure-results --output custom-report",
86
+ "Generate a report from the ./allure-results directory to the custom-report directory",
78
87
  ],
79
88
  ],
80
- action: AwesomeCommandAction,
81
89
  });
@@ -1,11 +1,15 @@
1
- type ClassicCommandOptions = {
2
- output?: string;
3
- reportName?: string;
4
- reportLanguage?: string;
5
- singleFile?: boolean;
6
- historyPath?: string;
7
- knownIssues?: string;
8
- };
9
- export declare const ClassicCommandAction: (resultsDir: string, options: ClassicCommandOptions) => Promise<void>;
10
- export declare const ClassicCommand: (cli: import("cac").CAC) => void;
11
- export {};
1
+ import { Command } from "clipanion";
2
+ export declare class ClassicCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ resultsDir: string;
6
+ config: string | undefined;
7
+ cwd: string | undefined;
8
+ output: string | undefined;
9
+ reportName: string | undefined;
10
+ reportLanguage: string | undefined;
11
+ singleFile: boolean | undefined;
12
+ historyPath: string | undefined;
13
+ knownIssues: string | undefined;
14
+ execute(): Promise<void>;
15
+ }
@@ -1,69 +1,77 @@
1
- import { AllureReport, resolveConfig } from "@allure/core";
2
- import { createCommand } from "../utils/commands.js";
3
- export const ClassicCommandAction = async (resultsDir, options) => {
4
- const before = new Date().getTime();
5
- const { output, reportName: name, historyPath, knownIssues: knownIssuesPath, ...rest } = options;
6
- const config = await resolveConfig({
7
- output,
8
- name,
9
- historyPath,
10
- knownIssuesPath,
11
- plugins: {
12
- "@allure/plugin-classic": {
13
- options: rest,
14
- },
15
- },
16
- });
17
- const allureReport = new AllureReport(config);
18
- await allureReport.start();
19
- await allureReport.readDirectory(resultsDir);
20
- await allureReport.done();
21
- const after = new Date().getTime();
22
- console.log(`the report successfully generated (${after - before}ms)`);
23
- };
24
- export const ClassicCommand = createCommand({
25
- name: "classic <resultsDir>",
26
- description: "Generates Allure Classic report based on provided Allure Results",
27
- options: [
28
- [
29
- "--output, -o <file>",
30
- {
31
- description: "The output directory name. Absolute paths are accepted as well",
32
- default: "allure-report",
33
- },
34
- ],
35
- [
36
- "--report-name, --name <string>",
37
- {
38
- description: "The report name",
39
- default: "Allure Report",
40
- },
41
- ],
42
- [
43
- "--report-language, --lang <string>",
1
+ import { AllureReport, readConfig } from "@allurereport/core";
2
+ import ClassicPlugin from "@allurereport/plugin-classic";
3
+ import { Command, Option } from "clipanion";
4
+ import * as console from "node:console";
5
+ import { realpath } from "node:fs/promises";
6
+ import process from "node:process";
7
+ export class ClassicCommand extends Command {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
11
+ this.config = Option.String("--config,-c", {
12
+ description: "The path Allure config file",
13
+ });
14
+ this.cwd = Option.String("--cwd", {
15
+ description: "The working directory for the command to run (default: current working directory)",
16
+ });
17
+ this.output = Option.String("--output,-o", {
18
+ description: "The output directory name. Absolute paths are accepted as well",
19
+ });
20
+ this.reportName = Option.String("--report-name,--name", {
21
+ description: "The report name",
22
+ });
23
+ this.reportLanguage = Option.String("--report-language,--lang", {
24
+ description: "Default language of the report (default: OS language)",
25
+ });
26
+ this.singleFile = Option.Boolean("--single-file", {
27
+ description: "Generate single file report",
28
+ });
29
+ this.historyPath = Option.String("--history-path,-h", {
30
+ description: "The path to history file",
31
+ });
32
+ this.knownIssues = Option.String("--known-issues", {
33
+ description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
34
+ });
35
+ }
36
+ async execute() {
37
+ const cwd = await realpath(this.cwd ?? process.cwd());
38
+ const before = new Date().getTime();
39
+ const defaultClassicOptions = {
40
+ singleFile: this.singleFile ?? false,
41
+ reportLanguage: this.reportLanguage,
42
+ };
43
+ const config = await readConfig(cwd, this.config, {
44
+ output: this.output ?? "allure-report",
45
+ name: this.reportName ?? "Allure Report",
46
+ knownIssuesPath: this.knownIssues,
47
+ historyPath: this.historyPath,
48
+ });
49
+ config.plugins = [
44
50
  {
45
- description: "Default language of the report (default: OS language)",
51
+ id: "classic",
52
+ enabled: true,
53
+ options: defaultClassicOptions,
54
+ plugin: new ClassicPlugin(defaultClassicOptions),
46
55
  },
47
- ],
48
- [
49
- "--single-file",
50
- {
51
- description: "Generate single file report",
52
- default: false,
53
- },
54
- ],
55
- [
56
- "--history-path, -h <file>",
57
- {
58
- description: "The path to history file",
59
- },
60
- ],
56
+ ];
57
+ const allureReport = new AllureReport(config);
58
+ await allureReport.start();
59
+ await allureReport.readDirectory(this.resultsDir);
60
+ await allureReport.done();
61
+ const after = new Date().getTime();
62
+ console.log(`the report successfully generated (${after - before}ms)`);
63
+ }
64
+ }
65
+ ClassicCommand.paths = [["classic"]];
66
+ ClassicCommand.usage = Command.Usage({
67
+ category: "Reports",
68
+ description: "Generates Allure Classic report based on provided Allure Results",
69
+ details: "This command generates an Allure Classic report from the provided Allure Results directory.",
70
+ examples: [
71
+ ["classic ./allure-results", "Generate a report from the ./allure-results directory"],
61
72
  [
62
- "--known-issues <file>",
63
- {
64
- description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
65
- },
73
+ "classic ./allure-results --output custom-report",
74
+ "Generate a report from the ./allure-results directory to the custom-report directory",
66
75
  ],
67
76
  ],
68
- action: ClassicCommandAction,
69
77
  });