allure 3.0.0-beta.20 → 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.
@@ -3,7 +3,6 @@ import { KnownError } from "@allurereport/service";
3
3
  import { Command, Option } from "clipanion";
4
4
  import { glob } from "glob";
5
5
  import * as console from "node:console";
6
- import { sep } from "node:path";
7
6
  import { exit, cwd as processCwd } from "node:process";
8
7
  import { red } from "yoctocolors";
9
8
  import { logError } from "../utils/logs.js";
@@ -59,7 +58,7 @@ export class GenerateCommand extends Command {
59
58
  dot: true,
60
59
  windowsPathsNoEscape: true,
61
60
  cwd,
62
- })).filter((p) => p.endsWith(sep));
61
+ })).filter((p) => /(\/|\\)$/.test(p));
63
62
  resultsDirectories.push(...matchedDirs);
64
63
  }
65
64
  if (resultsDirectories.length === 0 && stageDumpFiles.length === 0) {
@@ -20,3 +20,4 @@ export * from "./logout.js";
20
20
  export * from "./whoami.js";
21
21
  export * from "./projects/index.js";
22
22
  export * from "./results/index.js";
23
+ export * from "./jira/index.js";
@@ -20,3 +20,4 @@ export * from "./logout.js";
20
20
  export * from "./whoami.js";
21
21
  export * from "./projects/index.js";
22
22
  export * from "./results/index.js";
23
+ export * from "./jira/index.js";
@@ -0,0 +1,16 @@
1
+ import { Command } from "clipanion";
2
+ declare abstract class BaseJiraCommand extends Command {
3
+ config: string | undefined;
4
+ cwd: string | undefined;
5
+ token: string | undefined;
6
+ webhook: string | undefined;
7
+ }
8
+ export declare class JiraClearCommand extends BaseJiraCommand {
9
+ static paths: string[][];
10
+ static usage: import("clipanion").Usage;
11
+ issues: string[];
12
+ clearReports: boolean | undefined;
13
+ clearResults: boolean | undefined;
14
+ execute(): Promise<void>;
15
+ }
16
+ export {};
@@ -0,0 +1,113 @@
1
+ import { getPluginInstance, readConfig } from "@allurereport/core";
2
+ import JiraPlugin from "@allurereport/plugin-jira";
3
+ import { Command, Option, UsageError } from "clipanion";
4
+ import { realpath } from "node:fs/promises";
5
+ import process, { exit } from "node:process";
6
+ import { green, red } from "yoctocolors";
7
+ class BaseJiraCommand extends Command {
8
+ constructor() {
9
+ super(...arguments);
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
+ this.token = Option.String("--token,-t", {
17
+ description: "Atlassian User OAuth Token (default: ALLURE_JIRA_TOKEN environment variable)",
18
+ required: false,
19
+ });
20
+ this.webhook = Option.String("--webhook", {
21
+ description: "Allure Jira Integration Webhook URL (default: ALLURE_JIRA_WEBHOOK environment variable)",
22
+ required: false,
23
+ });
24
+ }
25
+ }
26
+ export class JiraClearCommand extends BaseJiraCommand {
27
+ constructor() {
28
+ super(...arguments);
29
+ this.issues = Option.Array("--issue", {
30
+ description: "Jira issue key(s)",
31
+ required: true,
32
+ arity: 1,
33
+ });
34
+ this.clearReports = Option.Boolean("--reports", {
35
+ description: "Unlink reports from the specified Jira issue",
36
+ required: false,
37
+ });
38
+ this.clearResults = Option.Boolean("--results", {
39
+ description: "Unlink results from the specified Jira issue",
40
+ required: false,
41
+ });
42
+ }
43
+ async execute() {
44
+ const cwd = await realpath(this.cwd ?? process.cwd());
45
+ const config = await readConfig(cwd, this.config);
46
+ const pluginFromConfig = getPluginInstance(config, ({ plugin }) => plugin instanceof JiraPlugin);
47
+ const jiraPlugin = new JiraPlugin({
48
+ token: this.token ?? pluginFromConfig?.options?.token,
49
+ webhook: this.webhook ?? pluginFromConfig?.options?.webhook,
50
+ });
51
+ if (!jiraPlugin.options.token) {
52
+ throw new UsageError("Token is not provided");
53
+ }
54
+ if (!jiraPlugin.options.webhook) {
55
+ throw new UsageError("Webhook url is not provided");
56
+ }
57
+ if (!this.clearReports && !this.clearResults) {
58
+ throw new UsageError("Either --reports or --results must be provided");
59
+ }
60
+ const operation = this.clearReports && this.clearResults ? "clearAll" : this.clearReports ? "clearReports" : "clearResults";
61
+ if (operation === "clearAll") {
62
+ try {
63
+ await jiraPlugin.clearAll(this.issues);
64
+ this.context.stdout.write(green("All reports and test results have been unlinked from the specified Jira issue"));
65
+ }
66
+ catch (error) {
67
+ this.context.stderr.write(red("Failed to unlink reports and test results from the specified Jira issue"));
68
+ exit(1);
69
+ }
70
+ }
71
+ if (operation === "clearReports") {
72
+ try {
73
+ await jiraPlugin.clearReports(this.issues);
74
+ this.context.stdout.write(green("All reports have been unlinked from the specified Jira issue"));
75
+ }
76
+ catch (error) {
77
+ this.context.stderr.write(red("Failed to unlink reports from the specified Jira issue"));
78
+ exit(1);
79
+ }
80
+ }
81
+ if (operation === "clearResults") {
82
+ try {
83
+ await jiraPlugin.clearResults(this.issues);
84
+ this.context.stdout.write(green("All test results have been unlinked from the specified Jira issue"));
85
+ }
86
+ catch (error) {
87
+ this.context.stderr.write(red("Failed to unlink test results from the specified Jira issue"));
88
+ exit(1);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ JiraClearCommand.paths = [["jira", "clear"]];
94
+ JiraClearCommand.usage = Command.Usage({
95
+ category: "Integrations",
96
+ description: "Unlink test results or reports in Jira",
97
+ details: "This command posts test results from the provided Allure Results directory to a Jira.",
98
+ examples: [
99
+ [
100
+ "Clear linked test results for the specified Jira issue",
101
+ "jira clear --token xoxb-token --webhook C12345 --issue JIRA-123 --results",
102
+ ],
103
+ [
104
+ "Clear linked reports for the specified Jira issue",
105
+ "jira clear --token xoxb-token --webhook C12345 --issue JIRA-123 --reports",
106
+ ],
107
+ [
108
+ "Clear linked test results and reports for the specified Jira issue",
109
+ "jira clear --token xoxb-token --webhook C12345 --issue JIRA-123 --results --reports",
110
+ ],
111
+ ["Clear from multiple Jira issues", "jira clear --issue JIRA-123 --issue JIRA-456 ..."],
112
+ ],
113
+ });
@@ -0,0 +1 @@
1
+ export * from "./clear.js";
@@ -0,0 +1 @@
1
+ export * from "./clear.js";
@@ -3,7 +3,6 @@ import { Command, Option } from "clipanion";
3
3
  import { glob } from "glob";
4
4
  import * as console from "node:console";
5
5
  import { realpath } from "node:fs/promises";
6
- import { sep } from "node:path";
7
6
  import { exit, cwd as processCwd } from "node:process";
8
7
  import * as typanion from "typanion";
9
8
  import { red } from "yoctocolors";
@@ -79,7 +78,7 @@ export class QualityGateCommand extends Command {
79
78
  dot: true,
80
79
  windowsPathsNoEscape: true,
81
80
  cwd,
82
- })).filter((p) => p.endsWith(sep));
81
+ })).filter((p) => /(\/|\\)$/.test(p));
83
82
  if (resultsDirectories.length === 0) {
84
83
  console.error("No Allure results directories found");
85
84
  exit(0);
@@ -10,7 +10,7 @@ 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, sep } from "node:path";
13
+ import { basename, join, resolve } from "node:path";
14
14
  import { green, red } from "yoctocolors";
15
15
  export class ResultsPackCommand extends Command {
16
16
  constructor() {
@@ -38,7 +38,7 @@ export class ResultsPackCommand extends Command {
38
38
  absolute: true,
39
39
  windowsPathsNoEscape: true,
40
40
  cwd,
41
- })).filter((p) => p.endsWith(sep));
41
+ })).filter((p) => /(\/|\\)$/.test(p));
42
42
  const resultsFiles = new Set();
43
43
  if (resultsDirectories.length === 0) {
44
44
  console.log(red(`No test results directories found matching pattern: ${resultsDir}`));
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { defineConfig, defaultChartsConfig } from "@allurereport/plugin-api";
1
+ export { defineConfig } from "@allurereport/plugin-api";
2
+ export { defaultChartsConfig } from "@allurereport/charts-api";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { Builtins, Cli } from "clipanion";
2
2
  import console from "node:console";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { argv, cwd } from "node:process";
5
- import { Allure2Command, AwesomeCommand, ClassicCommand, CsvCommand, DashboardCommand, GenerateCommand, HistoryCommand, KnownIssueCommand, LogCommand, LoginCommand, LogoutCommand, OpenCommand, ProjectsCreateCommand, ProjectsDeleteCommand, ProjectsListCommand, QualityGateCommand, ResultsPackCommand, ResultsUnpackCommand, RunCommand, SlackCommand, TestPlanCommand, WatchCommand, WhoamiCommand, } from "./commands/index.js";
5
+ import { Allure2Command, AwesomeCommand, ClassicCommand, CsvCommand, DashboardCommand, GenerateCommand, HistoryCommand, JiraClearCommand, KnownIssueCommand, LogCommand, LoginCommand, LogoutCommand, OpenCommand, ProjectsCreateCommand, ProjectsDeleteCommand, ProjectsListCommand, QualityGateCommand, ResultsPackCommand, ResultsUnpackCommand, RunCommand, SlackCommand, TestPlanCommand, WatchCommand, WhoamiCommand, } from "./commands/index.js";
6
6
  const [node, app, ...args] = argv;
7
7
  const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
8
8
  const cli = new Cli({
@@ -17,6 +17,7 @@ cli.register(CsvCommand);
17
17
  cli.register(DashboardCommand);
18
18
  cli.register(GenerateCommand);
19
19
  cli.register(HistoryCommand);
20
+ cli.register(JiraClearCommand);
20
21
  cli.register(KnownIssueCommand);
21
22
  cli.register(LogCommand);
22
23
  cli.register(LoginCommand);
@@ -36,4 +37,5 @@ cli.register(ResultsUnpackCommand);
36
37
  cli.register(Builtins.HelpCommand);
37
38
  cli.runExit(args);
38
39
  console.log(cwd());
39
- export { defineConfig, defaultChartsConfig } from "@allurereport/plugin-api";
40
+ export { defineConfig } from "@allurereport/plugin-api";
41
+ export { defaultChartsConfig } from "@allurereport/charts-api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allure",
3
- "version": "3.0.0-beta.20",
3
+ "version": "3.0.0-beta.21",
4
4
  "description": "Allure Commandline Tool",
5
5
  "keywords": [
6
6
  "allure",
@@ -31,22 +31,24 @@
31
31
  "test": "vitest run"
32
32
  },
33
33
  "dependencies": {
34
- "@allurereport/core": "3.0.0-beta.20",
35
- "@allurereport/core-api": "3.0.0-beta.20",
36
- "@allurereport/directory-watcher": "3.0.0-beta.20",
37
- "@allurereport/plugin-allure2": "3.0.0-beta.20",
38
- "@allurereport/plugin-api": "3.0.0-beta.20",
39
- "@allurereport/plugin-awesome": "3.0.0-beta.20",
40
- "@allurereport/plugin-classic": "3.0.0-beta.20",
41
- "@allurereport/plugin-csv": "3.0.0-beta.20",
42
- "@allurereport/plugin-dashboard": "3.0.0-beta.20",
43
- "@allurereport/plugin-log": "3.0.0-beta.20",
44
- "@allurereport/plugin-progress": "3.0.0-beta.20",
45
- "@allurereport/plugin-server-reload": "3.0.0-beta.20",
46
- "@allurereport/plugin-slack": "3.0.0-beta.20",
47
- "@allurereport/reader-api": "3.0.0-beta.20",
48
- "@allurereport/service": "3.0.0-beta.20",
49
- "@allurereport/static-server": "3.0.0-beta.20",
34
+ "@allurereport/charts-api": "3.0.0-beta.21",
35
+ "@allurereport/core": "3.0.0-beta.21",
36
+ "@allurereport/core-api": "3.0.0-beta.21",
37
+ "@allurereport/directory-watcher": "3.0.0-beta.21",
38
+ "@allurereport/plugin-allure2": "3.0.0-beta.21",
39
+ "@allurereport/plugin-api": "3.0.0-beta.21",
40
+ "@allurereport/plugin-awesome": "3.0.0-beta.21",
41
+ "@allurereport/plugin-classic": "3.0.0-beta.21",
42
+ "@allurereport/plugin-csv": "3.0.0-beta.21",
43
+ "@allurereport/plugin-dashboard": "3.0.0-beta.21",
44
+ "@allurereport/plugin-jira": "3.0.0-beta.21",
45
+ "@allurereport/plugin-log": "3.0.0-beta.21",
46
+ "@allurereport/plugin-progress": "3.0.0-beta.21",
47
+ "@allurereport/plugin-server-reload": "3.0.0-beta.21",
48
+ "@allurereport/plugin-slack": "3.0.0-beta.21",
49
+ "@allurereport/reader-api": "3.0.0-beta.21",
50
+ "@allurereport/service": "3.0.0-beta.21",
51
+ "@allurereport/static-server": "3.0.0-beta.21",
50
52
  "adm-zip": "^0.5.16",
51
53
  "clipanion": "^4.0.0-rc.4",
52
54
  "glob": "^11.0.3",