allure 3.0.0-beta.16 → 3.0.0-beta.17

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 (46) hide show
  1. package/dist/commands/allure2.d.ts +15 -13
  2. package/dist/commands/allure2.js +67 -79
  3. package/dist/commands/awesome.d.ts +18 -15
  4. package/dist/commands/awesome.js +79 -99
  5. package/dist/commands/classic.d.ts +15 -13
  6. package/dist/commands/classic.js +67 -79
  7. package/dist/commands/csv.d.ts +13 -11
  8. package/dist/commands/csv.js +59 -65
  9. package/dist/commands/dashboard.d.ts +15 -13
  10. package/dist/commands/dashboard.js +67 -78
  11. package/dist/commands/generate.d.ts +11 -9
  12. package/dist/commands/generate.js +44 -36
  13. package/dist/commands/history.d.ts +9 -7
  14. package/dist/commands/history.js +31 -28
  15. package/dist/commands/knownIssue.d.ts +8 -6
  16. package/dist/commands/knownIssue.js +30 -23
  17. package/dist/commands/log.d.ts +12 -9
  18. package/dist/commands/log.js +54 -58
  19. package/dist/commands/login.d.ts +8 -7
  20. package/dist/commands/login.js +39 -36
  21. package/dist/commands/logout.d.ts +8 -7
  22. package/dist/commands/logout.js +39 -36
  23. package/dist/commands/open.d.ts +11 -9
  24. package/dist/commands/open.js +34 -40
  25. package/dist/commands/projects/create.d.ts +9 -7
  26. package/dist/commands/projects/create.js +70 -66
  27. package/dist/commands/projects/delete.d.ts +10 -7
  28. package/dist/commands/projects/delete.js +55 -61
  29. package/dist/commands/projects/list.d.ts +8 -7
  30. package/dist/commands/projects/list.js +62 -62
  31. package/dist/commands/qualityGate.d.ts +9 -7
  32. package/dist/commands/qualityGate.js +46 -42
  33. package/dist/commands/run.d.ts +13 -10
  34. package/dist/commands/run.js +102 -111
  35. package/dist/commands/slack.d.ts +9 -7
  36. package/dist/commands/slack.js +51 -48
  37. package/dist/commands/testplan.d.ts +8 -6
  38. package/dist/commands/testplan.js +36 -29
  39. package/dist/commands/watch.d.ts +12 -10
  40. package/dist/commands/watch.js +103 -99
  41. package/dist/commands/whoami.d.ts +8 -7
  42. package/dist/commands/whoami.js +44 -38
  43. package/dist/index.js +31 -35
  44. package/package.json +19 -19
  45. package/dist/utils/commands.d.ts +0 -16
  46. package/dist/utils/commands.js +0 -16
@@ -1,74 +1,68 @@
1
1
  import { readConfig } from "@allurereport/core";
2
2
  import { AllureServiceClient, KnownError } from "@allurereport/service";
3
+ import { Command, Option } from "clipanion";
4
+ import * as console from "node:console";
5
+ import { exit } from "node:process";
3
6
  import prompts from "prompts";
4
7
  import { green, red } from "yoctocolors";
5
- import { createCommand } from "../../utils/commands.js";
6
8
  import { logError } from "../../utils/logs.js";
7
- export const ProjectsDeleteCommandAction = async (projectName, options) => {
8
- const { force = false } = options ?? {};
9
- const { config: configPath, cwd } = options ?? {};
10
- const config = await readConfig(cwd, configPath);
11
- if (!config?.allureService?.url) {
12
- console.error(red("No Allure Service URL is provided. Please provide it in the `allureService.url` field in the `allure.config.js` file"));
13
- process.exit(1);
14
- return;
15
- }
16
- const serviceClient = new AllureServiceClient(config.allureService);
17
- if (!projectName) {
18
- console.error(red("No project name is provided"));
19
- process.exit(1);
20
- return;
21
- }
22
- if (!force) {
23
- const res = await prompts({
24
- type: "confirm",
25
- name: "value",
26
- message: `Are you sure you want to delete project "${projectName}"?`,
9
+ export class ProjectsDeleteCommand extends Command {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.projectName = Option.String({ required: true, name: "Project name" });
13
+ this.force = Option.Boolean("--force", {
14
+ description: "Delete project with no confirmation",
27
15
  });
28
- if (!res.value) {
29
- process.exit(0);
30
- return;
31
- }
32
- }
33
- try {
34
- await serviceClient.deleteProject({
35
- name: projectName,
16
+ this.config = Option.String("--config,-c", {
17
+ description: "The path Allure config file",
18
+ });
19
+ this.cwd = Option.String("--cwd", {
20
+ description: "The working directory for the command to run (default: current working directory)",
36
21
  });
37
- console.info(green("Project has been deleted"));
38
22
  }
39
- catch (error) {
40
- if (error instanceof KnownError) {
41
- console.error(red(error.message));
42
- process.exit(1);
23
+ async execute() {
24
+ const config = await readConfig(this.cwd, this.config);
25
+ if (!config?.allureService?.url) {
26
+ console.error(red("No Allure Service URL is provided. Please provide it in the `allureService.url` field in the `allure.config.js` file"));
27
+ exit(1);
43
28
  return;
44
29
  }
45
- await logError("Failed to delete project due to unexpected error", error);
46
- process.exit(1);
30
+ const serviceClient = new AllureServiceClient(config.allureService);
31
+ if (!this.force) {
32
+ const res = await prompts({
33
+ type: "confirm",
34
+ name: "value",
35
+ message: `Are you sure you want to delete project "${this.projectName}"?`,
36
+ });
37
+ if (!res.value) {
38
+ exit(0);
39
+ return;
40
+ }
41
+ }
42
+ try {
43
+ await serviceClient.deleteProject({
44
+ name: this.projectName,
45
+ });
46
+ console.info(green("Project has been deleted"));
47
+ }
48
+ catch (error) {
49
+ if (error instanceof KnownError) {
50
+ console.error(red(error.message));
51
+ exit(1);
52
+ return;
53
+ }
54
+ await logError("Failed to delete project due to unexpected error", error);
55
+ exit(1);
56
+ }
47
57
  }
48
- };
49
- export const ProjectsDeleteCommand = createCommand({
50
- name: "project-delete <name>",
51
- description: "",
52
- options: [
53
- [
54
- "--force",
55
- {
56
- description: "Delete project with no confirmation",
57
- default: false,
58
- },
59
- ],
60
- [
61
- "--config, -c <file>",
62
- {
63
- description: "The path Allure config file",
64
- },
65
- ],
66
- [
67
- "--cwd <cwd>",
68
- {
69
- description: "The working directory for the command to run (default: current working directory)",
70
- },
71
- ],
58
+ }
59
+ ProjectsDeleteCommand.paths = [["projects", "delete"]];
60
+ ProjectsDeleteCommand.usage = Command.Usage({
61
+ category: "Allure Service Projects",
62
+ description: "Deletes a project",
63
+ details: "This command deletes a project from the Allure Service.",
64
+ examples: [
65
+ ["project-delete my-project", "Delete the project named 'my-project' (with confirmation)"],
66
+ ["project-delete my-project --force", "Delete the project named 'my-project' without confirmation"],
72
67
  ],
73
- action: ProjectsDeleteCommandAction,
74
68
  });
@@ -1,7 +1,8 @@
1
- type CommandOptions = {
2
- config?: string;
3
- cwd?: string;
4
- };
5
- export declare const ProjectsListCommandAction: (options?: CommandOptions) => Promise<void>;
6
- export declare const ProjectsListCommand: (cli: import("cac").CAC) => void;
7
- export {};
1
+ import { Command } from "clipanion";
2
+ export declare class ProjectsListCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ config: string | undefined;
6
+ cwd: string | undefined;
7
+ execute(): Promise<void>;
8
+ }
@@ -1,75 +1,75 @@
1
1
  import { readConfig } from "@allurereport/core";
2
2
  import { AllureServiceClient, KnownError } from "@allurereport/service";
3
+ import { Command, Option } from "clipanion";
4
+ import * as console from "node:console";
5
+ import { exit } from "node:process";
3
6
  import prompts from "prompts";
4
7
  import { green, red, yellow } from "yoctocolors";
5
- import { createCommand } from "../../utils/commands.js";
6
8
  import { logError } from "../../utils/logs.js";
7
- export const ProjectsListCommandAction = async (options) => {
8
- const { config: configPath, cwd } = options ?? {};
9
- const config = await readConfig(cwd, configPath);
10
- if (!config?.allureService?.url) {
11
- console.error(red("No Allure Service URL is provided. Please provide it in the `allureService.url` field in the `allure.config.js` file"));
12
- process.exit(1);
13
- return;
9
+ export class ProjectsListCommand extends Command {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.config = Option.String("--config,-c", {
13
+ description: "The path Allure config file",
14
+ });
15
+ this.cwd = Option.String("--cwd", {
16
+ description: "The working directory for the command to run (default: current working directory)",
17
+ });
14
18
  }
15
- const serviceClient = new AllureServiceClient(config.allureService);
16
- try {
17
- const projects = await serviceClient.projects();
18
- if (projects.length === 0) {
19
- console.info(yellow("No projects found. Create a new one with `allure project-create` command"));
19
+ async execute() {
20
+ const config = await readConfig(this.cwd, this.config);
21
+ if (!config?.allureService?.url) {
22
+ console.error(red("No Allure Service URL is provided. Please provide it in the `allureService.url` field in the `allure.config.js` file"));
23
+ exit(1);
20
24
  return;
21
25
  }
22
- const res = await prompts({
23
- type: "select",
24
- name: "project",
25
- message: "Select a project",
26
- choices: projects.map((project) => ({
27
- title: project.name,
28
- value: project.name,
29
- })),
30
- });
31
- if (!res?.project) {
32
- console.error(red("No project selected"));
33
- process.exit(1);
34
- return;
26
+ const serviceClient = new AllureServiceClient(config.allureService);
27
+ try {
28
+ const projects = await serviceClient.projects();
29
+ if (projects.length === 0) {
30
+ console.info(yellow("No projects found. Create a new one with `allure project-create` command"));
31
+ return;
32
+ }
33
+ const res = await prompts({
34
+ type: "select",
35
+ name: "project",
36
+ message: "Select a project",
37
+ choices: projects.map((project) => ({
38
+ title: project.name,
39
+ value: project.name,
40
+ })),
41
+ });
42
+ if (!res?.project) {
43
+ console.error(red("No project selected"));
44
+ exit(1);
45
+ return;
46
+ }
47
+ const lines = [
48
+ "Insert following code into your Allure Config file, to enable Allure Service features for the project:",
49
+ "",
50
+ green("{"),
51
+ green(" allureService: {"),
52
+ green(` project: "${res.project}"`),
53
+ green(" }"),
54
+ green("}"),
55
+ ];
56
+ console.info(lines.join("\n"));
35
57
  }
36
- const lines = [
37
- "Insert following code into your Allure Config file, to enable Allure Service features for the project:",
38
- "",
39
- green("{"),
40
- green(" allureService: {"),
41
- green(` project: "${res.project}"`),
42
- green(" }"),
43
- green("}"),
44
- ];
45
- console.info(lines.join("\n"));
46
- }
47
- catch (error) {
48
- if (error instanceof KnownError) {
49
- console.error(red(error.message));
50
- process.exit(1);
51
- return;
58
+ catch (error) {
59
+ if (error instanceof KnownError) {
60
+ console.error(red(error.message));
61
+ exit(1);
62
+ return;
63
+ }
64
+ await logError("Failed to get projects due to unexpected error", error);
65
+ exit(1);
52
66
  }
53
- await logError("Failed to get projects due to unexpected error", error);
54
- process.exit(1);
55
67
  }
56
- };
57
- export const ProjectsListCommand = createCommand({
58
- name: "projects",
68
+ }
69
+ ProjectsListCommand.paths = [["projects", "list"]];
70
+ ProjectsListCommand.usage = Command.Usage({
71
+ category: "Allure Service Projects",
59
72
  description: "Shows list of all available projects for current user",
60
- options: [
61
- [
62
- "--config, -c <file>",
63
- {
64
- description: "The path Allure config file",
65
- },
66
- ],
67
- [
68
- "--cwd <cwd>",
69
- {
70
- description: "The working directory for the command to run (default: current working directory)",
71
- },
72
- ],
73
- ],
74
- action: ProjectsListCommandAction,
73
+ details: "This command lists all available projects for the current user and allows selecting one to get configuration information.",
74
+ examples: [["projects", "List all available projects"]],
75
75
  });
@@ -1,7 +1,9 @@
1
- type QualityGateCommandOptions = {
2
- config?: string;
3
- cwd?: string;
4
- };
5
- export declare const QualityGateCommandAction: (resultsDir: string, options: QualityGateCommandOptions) => Promise<void>;
6
- export declare const QualityGateCommand: (cli: import("cac").CAC) => void;
7
- export {};
1
+ import { Command } from "clipanion";
2
+ export declare class QualityGateCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ resultsDir: string;
6
+ config: string | undefined;
7
+ cwd: string | undefined;
8
+ execute(): Promise<void>;
9
+ }
@@ -1,52 +1,56 @@
1
1
  import { AllureReport, readConfig } from "@allurereport/core";
2
- import console from "node:console";
3
- import process from "node:process";
2
+ import { Command, Option } from "clipanion";
3
+ import * as console from "node:console";
4
+ import { exit } from "node:process";
4
5
  import { bold, red } from "yoctocolors";
5
- import { createCommand } from "../utils/commands.js";
6
- export const QualityGateCommandAction = async (resultsDir, options) => {
7
- const { cwd, config: configPath } = options;
8
- const fullConfig = await readConfig(cwd, configPath);
9
- const allureReport = new AllureReport(fullConfig);
10
- await allureReport.start();
11
- await allureReport.readDirectory(resultsDir);
12
- await allureReport.done();
13
- await allureReport.validate();
14
- if (allureReport.exitCode === 0) {
15
- return;
6
+ export class QualityGateCommand extends Command {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
10
+ this.config = Option.String("--config,-c", {
11
+ description: "The path Allure config file",
12
+ });
13
+ this.cwd = Option.String("--cwd", {
14
+ description: "The working directory for the command to run (default: current working directory)",
15
+ });
16
16
  }
17
- const failedResults = allureReport.validationResults.filter((result) => !result.success);
18
- console.error(red(`Quality gate has failed with ${bold(failedResults.length.toString())} errors:\n`));
19
- for (const result of failedResults) {
20
- let scope = "";
21
- switch (result.meta?.type) {
22
- case "label":
23
- scope = `(label[${result.meta.name}="${result.meta.value}"])`;
24
- break;
25
- case "parameter":
26
- scope = `(parameter[${result.meta.name}="${result.meta.value}"])`;
27
- break;
17
+ async execute() {
18
+ const fullConfig = await readConfig(this.cwd, this.config);
19
+ const allureReport = new AllureReport(fullConfig);
20
+ await allureReport.start();
21
+ await allureReport.readDirectory(this.resultsDir);
22
+ await allureReport.done();
23
+ await allureReport.validate();
24
+ if (allureReport.exitCode === 0) {
25
+ return;
28
26
  }
29
- console.error(red(`⨯ ${bold(`${result.rule}${scope}`)}: expected ${result.expected}, actual ${result.actual}`));
27
+ const failedResults = allureReport.validationResults.filter((result) => !result.success);
28
+ console.error(red(`Quality gate has failed with ${bold(failedResults.length.toString())} errors:\n`));
29
+ for (const result of failedResults) {
30
+ let scope = "";
31
+ switch (result.meta?.type) {
32
+ case "label":
33
+ scope = `(label[${result.meta.name}="${result.meta.value}"])`;
34
+ break;
35
+ case "parameter":
36
+ scope = `(parameter[${result.meta.name}="${result.meta.value}"])`;
37
+ break;
38
+ }
39
+ console.error(red(`⨯ ${bold(`${result.rule}${scope}`)}: expected ${result.expected}, actual ${result.actual}`));
40
+ }
41
+ console.error(red("\nThe process has been exited with code 1"));
42
+ exit(allureReport.exitCode);
30
43
  }
31
- console.error(red("\nThe process has been exited with code 1"));
32
- process.exit(allureReport.exitCode);
33
- };
34
- export const QualityGateCommand = createCommand({
35
- name: "quality-gate <resultsDir>",
44
+ }
45
+ QualityGateCommand.paths = [["quality-gate"]];
46
+ QualityGateCommand.usage = Command.Usage({
36
47
  description: "Returns status code 1 if there any test failure above specified success rate",
37
- options: [
38
- [
39
- "--config, -c <file>",
40
- {
41
- description: "The path Allure config file",
42
- },
43
- ],
48
+ details: "This command validates the test results against quality gates defined in the configuration.",
49
+ examples: [
50
+ ["quality-gate ./allure-results", "Validate the test results in the ./allure-results directory"],
44
51
  [
45
- "--cwd <cwd>",
46
- {
47
- description: "The working directory for the command to run (Default: current working directory)",
48
- },
52
+ "quality-gate ./allure-results --config custom-config.js",
53
+ "Validate the test results using a custom configuration file",
49
54
  ],
50
55
  ],
51
- action: QualityGateCommandAction,
52
56
  });
@@ -1,10 +1,13 @@
1
- export type RunCommandOptions = {
2
- config?: string;
3
- cwd?: string;
4
- output?: string;
5
- reportName?: string;
6
- rerun?: number;
7
- silent?: boolean;
8
- } & Record<"--", string[]>;
9
- export declare const RunCommandAction: (options: RunCommandOptions) => Promise<void>;
10
- export declare const RunCommand: (cli: import("cac").CAC) => void;
1
+ import { Command } from "clipanion";
2
+ export declare class RunCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ config: string | undefined;
6
+ cwd: string | undefined;
7
+ output: string | undefined;
8
+ reportName: string | undefined;
9
+ rerun: string | undefined;
10
+ silent: boolean | undefined;
11
+ commandToRun: string[];
12
+ execute(): Promise<void>;
13
+ }