@autifyhq/autify-cli 0.3.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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +512 -0
  3. package/bin/dev +22 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +10 -0
  6. package/bin/run.cmd +3 -0
  7. package/dist/autify/web/getTestResultUrl.d.ts +1 -0
  8. package/dist/autify/web/getTestResultUrl.js +16 -0
  9. package/dist/autify/web/parseTestResultUrl.d.ts +4 -0
  10. package/dist/autify/web/parseTestResultUrl.js +17 -0
  11. package/dist/autify/web/runTest.d.ts +14 -0
  12. package/dist/autify/web/runTest.js +97 -0
  13. package/dist/autify/web/waitTestResult.d.ts +8 -0
  14. package/dist/autify/web/waitTestResult.js +71 -0
  15. package/dist/commands/mobile/api/run-test-plan.d.ts +10 -0
  16. package/dist/commands/mobile/api/run-test-plan.js +29 -0
  17. package/dist/commands/mobile/api/upload-build.d.ts +10 -0
  18. package/dist/commands/mobile/api/upload-build.js +26 -0
  19. package/dist/commands/mobile/auth/login.d.ts +7 -0
  20. package/dist/commands/mobile/auth/login.js +30 -0
  21. package/dist/commands/web/api/create-url-replacement.d.ts +10 -0
  22. package/dist/commands/web/api/create-url-replacement.js +29 -0
  23. package/dist/commands/web/api/delete-url-replacement.d.ts +10 -0
  24. package/dist/commands/web/api/delete-url-replacement.js +29 -0
  25. package/dist/commands/web/api/describe-result.d.ts +10 -0
  26. package/dist/commands/web/api/describe-result.js +29 -0
  27. package/dist/commands/web/api/describe-scenario.d.ts +10 -0
  28. package/dist/commands/web/api/describe-scenario.js +29 -0
  29. package/dist/commands/web/api/execute-scenarios.d.ts +10 -0
  30. package/dist/commands/web/api/execute-scenarios.js +29 -0
  31. package/dist/commands/web/api/execute-schedule.d.ts +9 -0
  32. package/dist/commands/web/api/execute-schedule.js +25 -0
  33. package/dist/commands/web/api/list-capabilities.d.ts +12 -0
  34. package/dist/commands/web/api/list-capabilities.js +34 -0
  35. package/dist/commands/web/api/list-results.d.ts +12 -0
  36. package/dist/commands/web/api/list-results.js +37 -0
  37. package/dist/commands/web/api/list-scenarios.d.ts +10 -0
  38. package/dist/commands/web/api/list-scenarios.js +29 -0
  39. package/dist/commands/web/api/list-url-replacements.d.ts +9 -0
  40. package/dist/commands/web/api/list-url-replacements.js +25 -0
  41. package/dist/commands/web/api/update-url-replacement.d.ts +11 -0
  42. package/dist/commands/web/api/update-url-replacement.js +33 -0
  43. package/dist/commands/web/auth/login.d.ts +7 -0
  44. package/dist/commands/web/auth/login.js +30 -0
  45. package/dist/commands/web/test/run.d.ts +23 -0
  46. package/dist/commands/web/test/run.js +114 -0
  47. package/dist/commands/web/test/wait.d.ts +15 -0
  48. package/dist/commands/web/test/wait.js +54 -0
  49. package/dist/config.d.ts +5 -0
  50. package/dist/config.js +38 -0
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.js +5 -0
  53. package/oclif.manifest.json +1 -0
  54. package/package.json +141 -0
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runTest = void 0;
4
+ /* eslint-disable unicorn/filename-case */
5
+ const errors_1 = require("@oclif/errors");
6
+ const parseScenarioUrl = (url) => {
7
+ var _a, _b, _c, _d;
8
+ const { pathname } = new URL(url);
9
+ const scenarioUrlPathRegExp = /\/projects\/(?<workspaceId>\d+)\/scenarios\/(?<scenarioId>\d+)/;
10
+ const match = scenarioUrlPathRegExp.exec(pathname);
11
+ const workspaceId = Number.parseInt((_b = (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.workspaceId) !== null && _b !== void 0 ? _b : "", 10);
12
+ const scenarioId = Number.parseInt((_d = (_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.scenarioId) !== null && _d !== void 0 ? _d : "", 10);
13
+ if (!workspaceId || !scenarioId)
14
+ return;
15
+ return { workspaceId, scenarioId };
16
+ };
17
+ const parseTestPlanUrl = (url) => {
18
+ var _a, _b, _c, _d;
19
+ const { pathname } = new URL(url);
20
+ const testPlanUrlPathRegExp = /\/projects\/(?<workspaceId>\d+)\/test_plans\/(?<testPlanId>\d+)/;
21
+ const match = testPlanUrlPathRegExp.exec(pathname);
22
+ const workspaceId = Number.parseInt((_b = (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.workspaceId) !== null && _b !== void 0 ? _b : "", 10);
23
+ const testPlanId = Number.parseInt((_d = (_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.testPlanId) !== null && _d !== void 0 ? _d : "", 10);
24
+ if (!workspaceId || !testPlanId)
25
+ return;
26
+ return { workspaceId, testPlanId };
27
+ };
28
+ const isCapabilitySpecified = (option) => {
29
+ return Object.values(option).some(Boolean);
30
+ };
31
+ const getCapability = async (client, workspaceId, option) => {
32
+ if (!isCapabilitySpecified(option)) {
33
+ option.os = "Linux";
34
+ option.browser = "Chrome";
35
+ }
36
+ const capabilities = await client.listCapabilities(workspaceId);
37
+ const candidates = capabilities.data
38
+ .filter((c) => !option.os || c.os === option.os)
39
+ .filter((c) => !option.os_version || c.os_version === option.os_version)
40
+ .filter((c) => option.device_type || !option.browser || c.browser === option.browser)
41
+ .filter((c) => !option.device || c.device === option.device)
42
+ .filter((c) => !option.device_type || c.device_type === option.device_type);
43
+ if (candidates.length === 0)
44
+ throw new errors_1.CLIError(`No capability is available for: ${JSON.stringify(option)}`);
45
+ if (candidates.length > 1)
46
+ throw new errors_1.CLIError(`Multiple capabilities are available for: ${JSON.stringify(option)} => ${JSON.stringify(candidates)}`);
47
+ return candidates[0];
48
+ };
49
+ /* eslint-disable camelcase */
50
+ const capabilityToString = ({ os, os_version, browser, browser_version, device, device_type, }) => {
51
+ return [os, os_version, browser, browser_version, device, device_type]
52
+ .filter((s) => Boolean(s))
53
+ .join(" ");
54
+ };
55
+ const runTest = async (client, url, { option, name, urlReplacements }) => {
56
+ const scenario = parseScenarioUrl(url);
57
+ const testPlan = parseTestPlanUrl(url);
58
+ if (scenario) {
59
+ const { workspaceId, scenarioId } = scenario;
60
+ const capability = await getCapability(client, workspaceId, option);
61
+ const res = await client.executeScenarios(workspaceId, {
62
+ name,
63
+ capabilities: [capability],
64
+ scenarios: [{ id: scenarioId }],
65
+ // eslint-disable-next-line camelcase
66
+ url_replacements: urlReplacements,
67
+ });
68
+ return {
69
+ workspaceId,
70
+ resultId: res.data.result_id,
71
+ capability: capabilityToString(capability),
72
+ };
73
+ }
74
+ if (testPlan) {
75
+ if (isCapabilitySpecified(option))
76
+ throw new errors_1.CLIError(`Running TestPlan doesn't support capability override: ${JSON.stringify(option)}`);
77
+ if (name)
78
+ throw new errors_1.CLIError(`Running TestPlan doesn't support --name: ${name}`);
79
+ const { workspaceId, testPlanId } = testPlan;
80
+ const urlReplacementIds = [];
81
+ for await (const urlReplacement of urlReplacements !== null && urlReplacements !== void 0 ? urlReplacements : []) {
82
+ const res = await client.createUrlReplacement(testPlanId, urlReplacement);
83
+ urlReplacementIds.push(res.data.id);
84
+ }
85
+ const res = await client.executeSchedule(testPlanId);
86
+ for await (const urlReplacementId of urlReplacementIds) {
87
+ await client.deleteUrlReplacement(testPlanId, urlReplacementId);
88
+ }
89
+ return {
90
+ workspaceId,
91
+ resultId: res.data.data.id,
92
+ capability: "configured by test plan",
93
+ };
94
+ }
95
+ throw new errors_1.CLIError(`Invalid URL: ${url}`);
96
+ };
97
+ exports.runTest = runTest;
@@ -0,0 +1,8 @@
1
+ import { WebClient } from "@autifyhq/autify-sdk";
2
+ export declare const waitTestResult: (client: WebClient, workspaceId: number, resultId: number, options: {
3
+ timeoutSecond: number;
4
+ verbose: boolean;
5
+ }) => Promise<{
6
+ isPassed: boolean;
7
+ data: any;
8
+ }>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitTestResult = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /* eslint-disable unicorn/filename-case */
6
+ const errors_1 = require("@oclif/errors");
7
+ const listr_1 = tslib_1.__importDefault(require("listr"));
8
+ const promises_1 = require("node:timers/promises");
9
+ const node_emoji_1 = tslib_1.__importDefault(require("node-emoji"));
10
+ const waitUntil = async (callback, timeoutSecond, intervalSecond, verbose) => {
11
+ const task = new listr_1.default([
12
+ {
13
+ title: `Waiting... (timeout: ${timeoutSecond} s)`,
14
+ task: async (ctx, task) => {
15
+ for await (const startTime of (0, promises_1.setInterval)(intervalSecond * 1000, Date.now())) {
16
+ const now = Date.now();
17
+ if (now - startTime > timeoutSecond * 1000) {
18
+ throw new errors_1.CLIError(`Timeout after ${timeoutSecond} seconds.`);
19
+ }
20
+ const result = await callback(task);
21
+ if (result) {
22
+ ctx.result = result;
23
+ return;
24
+ }
25
+ }
26
+ },
27
+ },
28
+ ], {
29
+ renderer: verbose ? "verbose" : "default",
30
+ nonTTYRenderer: "verbose",
31
+ });
32
+ return (await task.run()).result;
33
+ };
34
+ const emojiStatus = (status) => {
35
+ if (status === "queuing")
36
+ return node_emoji_1.default.get("cyclone") + " Queuing";
37
+ if (status === "waiting")
38
+ return node_emoji_1.default.get("hourglass_flowing_sand") + " Waiting";
39
+ if (status === "running")
40
+ return node_emoji_1.default.get("car") + " Running";
41
+ if (status === "passed")
42
+ return node_emoji_1.default.get("+1") + " Passed ";
43
+ if (status === "failed")
44
+ return node_emoji_1.default.get("rotating_light") + " Failed ";
45
+ if (status === "skipped")
46
+ return node_emoji_1.default.get("zzz") + " Skipped";
47
+ return node_emoji_1.default.get("grey_question") + " None ";
48
+ };
49
+ const describeResult = (client, workspaceId, resultId) => async (task) => {
50
+ var _a, _b;
51
+ const { data } = await client.describeResult(workspaceId, resultId);
52
+ const testPlanStatus = emojiStatus(data.status);
53
+ const testCaseStatus = [];
54
+ for (const testPlanCapabilityResult of (_a = data.test_plan_capability_results) !== null && _a !== void 0 ? _a : []) {
55
+ for (const testCaseResult of (_b = testPlanCapabilityResult.test_case_results) !== null && _b !== void 0 ? _b : []) {
56
+ testCaseStatus.push(emojiStatus(testCaseResult.status));
57
+ }
58
+ }
59
+ task.output = `TestPlan: ${testPlanStatus}, TestCases: ${testCaseStatus.join(" / ")}`;
60
+ if (data.finished_at)
61
+ return data;
62
+ };
63
+ const waitTestResult = async (client, workspaceId, resultId, options) => {
64
+ const data = await waitUntil(describeResult(client, workspaceId, resultId), options.timeoutSecond, 1, options.verbose);
65
+ const isPassed = (data === null || data === void 0 ? void 0 : data.status) === "passed";
66
+ return {
67
+ isPassed,
68
+ data,
69
+ };
70
+ };
71
+ exports.waitTestResult = waitTestResult;
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class MobileApiRunTestPlan extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "test-plan-id": import("@oclif/core/lib/interfaces").OptionFlag<string>;
7
+ "run-test-plan-request": import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class MobileApiRunTestPlan extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(MobileApiRunTestPlan);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
+ const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
13
+ const res = await client.runTestPlan(flags["test-plan-id"], JSON.parse(flags["run-test-plan-request"]));
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = MobileApiRunTestPlan;
18
+ MobileApiRunTestPlan.description = "Run a test plan";
19
+ MobileApiRunTestPlan.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ MobileApiRunTestPlan.flags = {
21
+ "test-plan-id": core_1.Flags.string({
22
+ description: "The ID of the test plan to run.",
23
+ required: true,
24
+ }),
25
+ "run-test-plan-request": core_1.Flags.string({
26
+ description: "The build_id to execute the test plan.",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class MobileApiUploadBuild extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<string>;
7
+ file: import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class MobileApiUploadBuild extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(MobileApiUploadBuild);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_MOBILE_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_MOBILE_BASE_PATH");
12
+ const client = new autify_sdk_1.MobileClient(accessToken, { basePath, userAgent });
13
+ const res = await client.uploadBuild(flags["project-id"], flags.file);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = MobileApiUploadBuild;
18
+ MobileApiUploadBuild.description = "Upload the build file.";
19
+ MobileApiUploadBuild.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ MobileApiUploadBuild.flags = {
21
+ "project-id": core_1.Flags.string({
22
+ description: "The ID of the project to upload the build file to.",
23
+ required: true,
24
+ }),
25
+ file: core_1.Flags.string({ description: "Build file.", required: true }),
26
+ };
@@ -0,0 +1,7 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class MobileAuthLogin extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ private readTokenFromStdin;
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const inquirer = tslib_1.__importStar(require("inquirer"));
6
+ const config_1 = require("../../../config");
7
+ class MobileAuthLogin extends core_1.Command {
8
+ async run() {
9
+ await this.parse(MobileAuthLogin);
10
+ const token = await this.readTokenFromStdin();
11
+ (0, config_1.set)(this.config.configDir, "AUTIFY_MOBILE_ACCESS_TOKEN", token);
12
+ }
13
+ async readTokenFromStdin() {
14
+ const res = await inquirer.prompt([
15
+ {
16
+ name: "token",
17
+ message: "Enter Access Token",
18
+ type: "password",
19
+ mask: true,
20
+ },
21
+ ]);
22
+ return res.token;
23
+ }
24
+ }
25
+ exports.default = MobileAuthLogin;
26
+ MobileAuthLogin.description = "Login to Autify for Mobile";
27
+ MobileAuthLogin.examples = [
28
+ "Start interactive setup:\n<%= config.bin %> <%= command.id %>",
29
+ "Reading the token from file:\n<%= config.bin %> <%= command.id %> < token.txt",
30
+ ];
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiCreateUrlReplacement extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "test-plan-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "create-url-replacement-request": import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiCreateUrlReplacement extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiCreateUrlReplacement);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.createUrlReplacement(flags["test-plan-id"], JSON.parse(flags["create-url-replacement-request"]));
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiCreateUrlReplacement;
18
+ WebApiCreateUrlReplacement.description = "Create a new url replacement for the test plan";
19
+ WebApiCreateUrlReplacement.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiCreateUrlReplacement.flags = {
21
+ "test-plan-id": core_1.Flags.integer({
22
+ description: "For example, 15 for the following URL: https://app.autify.com/projects/1/test_plans/15",
23
+ required: true,
24
+ }),
25
+ "create-url-replacement-request": core_1.Flags.string({
26
+ description: "The url to replace",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiDeleteUrlReplacement extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "test-plan-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "url-replacement-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiDeleteUrlReplacement extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiDeleteUrlReplacement);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.deleteUrlReplacement(flags["test-plan-id"], flags["url-replacement-id"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiDeleteUrlReplacement;
18
+ WebApiDeleteUrlReplacement.description = "Delete a url replacement for the test plan";
19
+ WebApiDeleteUrlReplacement.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiDeleteUrlReplacement.flags = {
21
+ "test-plan-id": core_1.Flags.integer({
22
+ description: "For example, 15 for the following URL: https://app.autify.com/projects/1/test_plans/15",
23
+ required: true,
24
+ }),
25
+ "url-replacement-id": core_1.Flags.integer({
26
+ description: "url_replacement id",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiDescribeResult extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "result-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiDescribeResult extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiDescribeResult);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.describeResult(flags["project-id"], flags["result-id"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiDescribeResult;
18
+ WebApiDescribeResult.description = "Get a result.";
19
+ WebApiDescribeResult.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiDescribeResult.flags = {
21
+ "project-id": core_1.Flags.integer({
22
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/results/4",
23
+ required: true,
24
+ }),
25
+ "result-id": core_1.Flags.integer({
26
+ description: "For example, 4 for the following URL: https://app.autify.com/projects/1/results/4",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiDescribeScenario extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "scenario-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiDescribeScenario extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiDescribeScenario);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.describeScenario(flags["project-id"], flags["scenario-id"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiDescribeScenario;
18
+ WebApiDescribeScenario.description = "Get a scenario.";
19
+ WebApiDescribeScenario.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiDescribeScenario.flags = {
21
+ "project-id": core_1.Flags.integer({
22
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/scenarios/2",
23
+ required: true,
24
+ }),
25
+ "scenario-id": core_1.Flags.integer({
26
+ description: "For example, 2 for the following URL: https://app.autify.com/projects/1/scenarios/2",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,10 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiExecuteScenarios extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ "execute-scenarios-request": import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ };
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiExecuteScenarios extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiExecuteScenarios);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.executeScenarios(flags["project-id"], JSON.parse(flags["execute-scenarios-request"]));
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiExecuteScenarios;
18
+ WebApiExecuteScenarios.description = 'You can execute any scenarios in your workspace using any execution environments (which is called "capabilities" here).';
19
+ WebApiExecuteScenarios.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiExecuteScenarios.flags = {
21
+ "project-id": core_1.Flags.integer({
22
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/scenarios",
23
+ required: true,
24
+ }),
25
+ "execute-scenarios-request": core_1.Flags.string({
26
+ description: "The scenarios and settings to execute",
27
+ required: true,
28
+ }),
29
+ };
@@ -0,0 +1,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiExecuteSchedule extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "schedule-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiExecuteSchedule extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiExecuteSchedule);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.executeSchedule(flags["schedule-id"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiExecuteSchedule;
18
+ WebApiExecuteSchedule.description = 'Run a test plan. (Note: "Schedule" is called as "TestPlan" now.)';
19
+ WebApiExecuteSchedule.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiExecuteSchedule.flags = {
21
+ "schedule-id": core_1.Flags.integer({
22
+ description: "For example, 3 for the following URL: https://app.autify.com/projects/1/test_plans/3",
23
+ required: true,
24
+ }),
25
+ };
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiListCapabilities extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ os: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
8
+ browser: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ "device-type": import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiListCapabilities extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiListCapabilities);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.listCapabilities(flags["project-id"], flags.os, flags.browser, flags["device-type"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiListCapabilities;
18
+ WebApiListCapabilities.description = "List available Capabilities.";
19
+ WebApiListCapabilities.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiListCapabilities.flags = {
21
+ "project-id": core_1.Flags.integer({
22
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/capabilities",
23
+ required: true,
24
+ }),
25
+ os: core_1.Flags.string({ description: "os name to filter", required: false }),
26
+ browser: core_1.Flags.string({
27
+ description: "browser name to filter",
28
+ required: false,
29
+ }),
30
+ "device-type": core_1.Flags.string({
31
+ description: "device_type name to filter",
32
+ required: false,
33
+ }),
34
+ };
@@ -0,0 +1,12 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WebApiListResults extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "project-id": import("@oclif/core/lib/interfaces").OptionFlag<number>;
7
+ page: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
8
+ "per-page": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
9
+ "test-plan-id": import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const autify_sdk_1 = require("@autifyhq/autify-sdk");
5
+ const config_1 = require("../../../config");
6
+ class WebApiListResults extends core_1.Command {
7
+ async run() {
8
+ const { flags } = await this.parse(WebApiListResults);
9
+ const { configDir, userAgent } = this.config;
10
+ const accessToken = (0, config_1.getOrThrow)(configDir, "AUTIFY_WEB_ACCESS_TOKEN");
11
+ const basePath = (0, config_1.get)(configDir, "AUTIFY_WEB_BASE_PATH");
12
+ const client = new autify_sdk_1.WebClient(accessToken, { basePath, userAgent });
13
+ const res = await client.listResults(flags["project-id"], flags.page, flags["per-page"], flags["test-plan-id"]);
14
+ console.log(JSON.stringify(res.data, null, 2));
15
+ }
16
+ }
17
+ exports.default = WebApiListResults;
18
+ WebApiListResults.description = "List results.";
19
+ WebApiListResults.examples = ["<%= config.bin %> <%= command.id %>"];
20
+ WebApiListResults.flags = {
21
+ "project-id": core_1.Flags.integer({
22
+ description: "For example, 1 for the following URL: https://app.autify.com/projects/1/results",
23
+ required: true,
24
+ }),
25
+ page: core_1.Flags.integer({
26
+ description: "The number of page returns.",
27
+ required: false,
28
+ }),
29
+ "per-page": core_1.Flags.integer({
30
+ description: "The number of items returns. Default number is 30 and up to a maximum of 100",
31
+ required: false,
32
+ }),
33
+ "test-plan-id": core_1.Flags.integer({
34
+ description: "Test plan ID used to filter results.",
35
+ required: false,
36
+ }),
37
+ };