askui 0.12.2 → 0.13.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 (83) hide show
  1. package/README.md +13 -19
  2. package/bin/askui +1 -1
  3. package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +75 -0
  4. package/dist/cjs/core/model/test-case-dto/custom-element-json.js +2 -0
  5. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +21 -0
  6. package/dist/cjs/core/model/test-case-dto/custom-element.js +54 -0
  7. package/dist/cjs/core/model/test-case-dto/index.d.ts +3 -0
  8. package/dist/cjs/core/model/test-case-dto/index.js +5 -0
  9. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +6 -0
  10. package/dist/cjs/core/model/test-case-dto/test-step.js +2 -0
  11. package/dist/cjs/core/model/test-case-result-dto/index.d.ts +2 -0
  12. package/dist/cjs/core/model/test-case-result-dto/index.js +7 -0
  13. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +9 -0
  14. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +16 -0
  15. package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +4 -0
  16. package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +8 -0
  17. package/dist/cjs/core/reporting/default-reporter.d.ts +10 -0
  18. package/dist/cjs/core/reporting/default-reporter.js +12 -0
  19. package/dist/cjs/execution/annotation-level.d.ts +5 -0
  20. package/dist/cjs/execution/annotation-level.js +9 -0
  21. package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
  22. package/dist/cjs/execution/ui-control-client-error.js +6 -0
  23. package/dist/cjs/lib/index.d.ts +1 -0
  24. package/dist/cjs/lib/index.js +3 -1
  25. package/dist/cjs/lib/interactive_cli/add-script-package-json.d.ts +1 -0
  26. package/dist/cjs/lib/interactive_cli/add-script-package-json.js +38 -0
  27. package/dist/cjs/lib/interactive_cli/cli-options-interface.d.ts +8 -0
  28. package/dist/cjs/lib/interactive_cli/cli-options-interface.js +2 -0
  29. package/dist/cjs/lib/interactive_cli/cli.d.ts +2 -0
  30. package/dist/cjs/lib/interactive_cli/cli.js +115 -0
  31. package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +26 -0
  32. package/dist/cjs/lib/interactive_cli/create-example-project.js +295 -0
  33. package/dist/cjs/lib/interactive_cli/index.d.ts +1 -0
  34. package/dist/cjs/lib/interactive_cli/index.js +5 -0
  35. package/dist/cjs/lib/interactive_cli/replace-string-in-file.d.ts +1 -0
  36. package/dist/cjs/lib/interactive_cli/replace-string-in-file.js +31 -0
  37. package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +75 -0
  38. package/dist/esm/core/model/test-case-dto/custom-element-json.js +1 -0
  39. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +21 -0
  40. package/dist/esm/core/model/test-case-dto/custom-element.js +50 -0
  41. package/dist/esm/core/model/test-case-dto/index.d.ts +3 -0
  42. package/dist/esm/core/model/test-case-dto/index.js +1 -0
  43. package/dist/esm/core/model/test-case-dto/test-step.d.ts +6 -0
  44. package/dist/esm/core/model/test-case-dto/test-step.js +1 -0
  45. package/dist/esm/core/model/test-case-result-dto/index.d.ts +2 -0
  46. package/dist/esm/core/model/test-case-result-dto/index.js +2 -0
  47. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +9 -0
  48. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +12 -0
  49. package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +4 -0
  50. package/dist/esm/core/model/test-case-result-dto/test-step-state.js +5 -0
  51. package/dist/esm/core/reporting/default-reporter.d.ts +10 -0
  52. package/dist/esm/core/reporting/default-reporter.js +9 -0
  53. package/dist/esm/execution/annotation-level.d.ts +5 -0
  54. package/dist/esm/execution/annotation-level.js +6 -0
  55. package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
  56. package/dist/esm/execution/ui-control-client-error.js +2 -0
  57. package/dist/esm/lib/index.d.ts +1 -0
  58. package/dist/esm/lib/index.js +1 -0
  59. package/dist/esm/lib/interactive_cli/add-script-package-json.d.ts +1 -0
  60. package/dist/esm/lib/interactive_cli/add-script-package-json.js +31 -0
  61. package/dist/esm/lib/interactive_cli/cli-options-interface.d.ts +8 -0
  62. package/dist/esm/lib/interactive_cli/cli-options-interface.js +1 -0
  63. package/dist/esm/lib/interactive_cli/cli.d.ts +2 -0
  64. package/dist/esm/lib/interactive_cli/cli.js +108 -0
  65. package/dist/esm/lib/interactive_cli/create-example-project.d.ts +26 -0
  66. package/dist/esm/lib/interactive_cli/create-example-project.js +288 -0
  67. package/dist/esm/lib/interactive_cli/index.d.ts +1 -0
  68. package/dist/esm/lib/interactive_cli/index.js +1 -0
  69. package/dist/esm/lib/interactive_cli/replace-string-in-file.d.ts +1 -0
  70. package/dist/esm/lib/interactive_cli/replace-string-in-file.js +24 -0
  71. package/dist/example_projects_templates/configs/jasmine.config.json +12 -0
  72. package/dist/example_projects_templates/configs/jest.config.ts +13 -0
  73. package/dist/example_projects_templates/configs/tsconfig.json +7 -0
  74. package/dist/example_projects_templates/templates/askui-helper-windows.nj +35 -0
  75. package/dist/example_projects_templates/templates/askui-helper.nj +49 -0
  76. package/dist/example_projects_templates/typescript/.eslintignore +1 -0
  77. package/dist/example_projects_templates/typescript/.eslintignore-template +1 -0
  78. package/dist/example_projects_templates/typescript/.eslintrc.json +20 -0
  79. package/dist/example_projects_templates/typescript/.eslintrc.json-template +20 -0
  80. package/dist/example_projects_templates/typescript/askui_example/helpers/askui-helper.ts +39 -0
  81. package/dist/example_projects_templates/typescript/askui_example/my-first-askui-test-suite.test.ts +21 -0
  82. package/dist/example_projects_templates/typescript/tsconfig.json +7 -0
  83. package/package.json +8 -1
@@ -0,0 +1,8 @@
1
+ export interface CliOptions {
2
+ operatingSystem: 'windows' | 'linux' | 'macos';
3
+ workspaceId: string;
4
+ accessToken: string;
5
+ testFramework: 'jasmine' | 'jest';
6
+ usingProxy: boolean;
7
+ typescriptConfig: boolean;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function init(argv: string[]): Command;
@@ -0,0 +1,108 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import inquirer from 'inquirer';
11
+ import { Command, Option } from 'commander';
12
+ import { CreateExampleProject } from './create-example-project';
13
+ const nonEmpty = (subject) => (input) => (input.trim().length > 0) || `${subject} is required.`;
14
+ const questions = [
15
+ {
16
+ type: 'list',
17
+ name: 'testFramework',
18
+ message: 'Which framework do you prefer',
19
+ choices: ['jest', 'jasmine'],
20
+ },
21
+ {
22
+ type: 'input',
23
+ name: 'workspaceId',
24
+ message: 'Your workspace id',
25
+ validate: nonEmpty('workspace id'),
26
+ },
27
+ {
28
+ type: 'password',
29
+ name: 'accessToken',
30
+ message: 'Your access token',
31
+ mask: '*',
32
+ validate: nonEmpty('access token'),
33
+ },
34
+ {
35
+ type: 'confirm',
36
+ name: 'usingProxy',
37
+ message: 'Are you using a proxy?',
38
+ default: false,
39
+ },
40
+ {
41
+ type: 'confirm',
42
+ name: 'typescriptConfig',
43
+ message: 'Do you want to add the tsconfig.json file? This action will overwrite the file if it exists. Default True ',
44
+ default: true,
45
+ },
46
+ ];
47
+ const options = [
48
+ {
49
+ option: '-f, --test-framework <value>',
50
+ choices: ['jasmine', 'jest'],
51
+ description: 'the test framework to use',
52
+ },
53
+ {
54
+ option: '-w, --workspace-id <value>',
55
+ choices: [],
56
+ description: 'a workspace id',
57
+ },
58
+ {
59
+ option: '-a, --access-token <value>',
60
+ choices: [],
61
+ description: 'an access token for the workspace with the id',
62
+ },
63
+ {
64
+ option: '-p, --using-proxy <value>',
65
+ choices: ['true', 'false'],
66
+ description: 'use a proxy',
67
+ },
68
+ {
69
+ option: '-t, --typescript-config <value>',
70
+ choices: ['true', 'false'],
71
+ description: 'overwrite tsconfig.json flag',
72
+ },
73
+ ];
74
+ const createProgram = () => {
75
+ const program = new Command('askui');
76
+ program.usage('<command> [options]');
77
+ return program;
78
+ };
79
+ export function init(argv) {
80
+ const args = argv || process.argv;
81
+ const program = createProgram();
82
+ const programInit = program.command('init');
83
+ programInit.description('Creates a askui example project');
84
+ // Loop through the options object and register each option with the program
85
+ options.forEach((opt) => {
86
+ const tempOption = new Option(opt.option, opt.description);
87
+ if (opt.choices.length > 0) {
88
+ tempOption.choices(opt.choices);
89
+ }
90
+ programInit.addOption(tempOption);
91
+ });
92
+ programInit.usage('[-f test_framework] [-w workspace_id] [-a access_token] [-p boolean] [-t boolean]');
93
+ programInit
94
+ .action((_opts) => __awaiter(this, void 0, void 0, function* () {
95
+ const userAnswers = programInit.opts();
96
+ // Check which options are missing and prompt the user for them
97
+ const missingOptions = questions.filter((entry) => !(entry.name in userAnswers));
98
+ if (missingOptions.length > 0) {
99
+ inquirer.prompt(missingOptions).then((answers) => __awaiter(this, void 0, void 0, function* () {
100
+ yield new CreateExampleProject(Object.assign(Object.assign({}, userAnswers), answers)).createExampleProject();
101
+ }));
102
+ }
103
+ else {
104
+ yield new CreateExampleProject(userAnswers).createExampleProject();
105
+ }
106
+ }));
107
+ return program.parse(args);
108
+ }
@@ -0,0 +1,26 @@
1
+ import { CliOptions } from './cli-options-interface';
2
+ export declare class CreateExampleProject {
3
+ readonly cliOptions: CliOptions;
4
+ private distexampleFolderPath;
5
+ private exampleFolderName;
6
+ private baseDirPath;
7
+ private proxyDocUrl;
8
+ private remoteDeviceControllerUrl;
9
+ private helperTemplateConfig;
10
+ constructor(cliOptions: CliOptions);
11
+ private copyTemplateProject;
12
+ private copyTestFrameworkConfig;
13
+ private addTestFrameWorkTimeout;
14
+ private addReporterConfig;
15
+ private addAskuiRunCommand;
16
+ private addESLintRunCommand;
17
+ private createAskUIHelperFromTemplate;
18
+ private setupTestFrameWork;
19
+ private installTestFrameworkPackages;
20
+ private addUserCredentails;
21
+ private copyESLintConfigFiles;
22
+ private copyTsConfigFile;
23
+ private installProxy;
24
+ private normalizeCliOptions;
25
+ createExampleProject(): Promise<void>;
26
+ }
@@ -0,0 +1,288 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import path from 'path';
11
+ import fs from 'fs-extra';
12
+ import { promisify } from 'util';
13
+ import { exec } from 'child_process';
14
+ import Listr from 'listr';
15
+ import chalk from 'chalk';
16
+ import nunjucks from 'nunjucks';
17
+ import { getPathToNodeModulesRoot } from '../../utils/path';
18
+ import { addScript } from './add-script-package-json';
19
+ export class CreateExampleProject {
20
+ constructor(cliOptions) {
21
+ this.cliOptions = cliOptions;
22
+ this.baseDirPath = process.cwd();
23
+ this.exampleFolderName = 'askui_example';
24
+ this.distexampleFolderPath = path.join(this.baseDirPath, this.exampleFolderName);
25
+ this.proxyDocUrl = 'https://docs.askui.com/docs/general/Troubleshooting/proxy';
26
+ this.remoteDeviceControllerUrl = 'https://docs.askui.com/docs/api/Remote-Device-Controller';
27
+ this.helperTemplateConfig = {};
28
+ }
29
+ copyTemplateProject() {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const exampleProjectPath = path.join('example_projects_templates', 'typescript', this.exampleFolderName);
32
+ const runCommand = promisify(exec);
33
+ return [
34
+ {
35
+ title: 'Detect Operating System',
36
+ task: () => __awaiter(this, void 0, void 0, function* () {
37
+ if (process.platform === 'win32') {
38
+ this.cliOptions.operatingSystem = 'windows';
39
+ }
40
+ else if (process.platform === 'darwin') {
41
+ this.cliOptions.operatingSystem = 'macos';
42
+ }
43
+ else if (process.platform === 'linux'
44
+ || process.platform === 'freebsd'
45
+ || process.platform === 'openbsd') {
46
+ this.cliOptions.operatingSystem = 'linux';
47
+ }
48
+ else {
49
+ throw new Error(`The detected operating system is ${process.platform}. We only support 'windows', 'macos' and 'linux'`);
50
+ }
51
+ }),
52
+ },
53
+ {
54
+ title: 'Copy project files',
55
+ task: () => __awaiter(this, void 0, void 0, function* () {
56
+ return fs.copy(path.join(getPathToNodeModulesRoot(), exampleProjectPath), this.distexampleFolderPath);
57
+ }),
58
+ },
59
+ {
60
+ title: 'Install askui dependency',
61
+ task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm i -D askui '); }),
62
+ },
63
+ ];
64
+ });
65
+ }
66
+ copyTestFrameworkConfig() {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const frameworkConfigs = {
69
+ jest: 'jest.config.ts',
70
+ jasmine: 'jasmine.config.json',
71
+ };
72
+ const configFilePath = path.join(getPathToNodeModulesRoot(), 'example_projects_templates', 'configs', frameworkConfigs[this.cliOptions.testFramework]);
73
+ yield fs.copyFile(configFilePath, path.join(this.distexampleFolderPath, frameworkConfigs[this.cliOptions.testFramework]));
74
+ });
75
+ }
76
+ addTestFrameWorkTimeout() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ const frameworkTimeoutstring = {
79
+ jest: 'jest.setTimeout(60 * 1000 * 60);',
80
+ jasmine: 'jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000 * 60;',
81
+ };
82
+ this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring[this.cliOptions.testFramework];
83
+ });
84
+ }
85
+ addReporterConfig() {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ if (this.cliOptions.testFramework === 'jest') {
88
+ this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
89
+ this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
90
+ this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
91
+ await AskUIAllureStepReporter.attachVideo(video);`;
92
+ }
93
+ });
94
+ }
95
+ addAskuiRunCommand() {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const frameworkExecutionCommand = {
98
+ jest: `jest --config ./${this.exampleFolderName}/jest.config.ts --runInBand`,
99
+ jasmine: `jasmine --config=${this.exampleFolderName}/jasmine.config.json`,
100
+ };
101
+ yield addScript(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand[this.cliOptions.testFramework]);
102
+ });
103
+ }
104
+ addESLintRunCommand() {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ yield addScript(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
107
+ });
108
+ }
109
+ createAskUIHelperFromTemplate() {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ return [{
112
+ title: 'Write askui config',
113
+ task: () => __awaiter(this, void 0, void 0, function* () {
114
+ return new Listr([
115
+ {
116
+ title: 'Create askui-helper.ts ',
117
+ task: () => __awaiter(this, void 0, void 0, function* () {
118
+ const askuiHelperTemplateFilePath = path.join(getPathToNodeModulesRoot(), 'example_projects_templates', 'templates');
119
+ let templateFileName = 'askui-helper.nj';
120
+ if (this.cliOptions.operatingSystem === 'windows') {
121
+ templateFileName = 'askui-helper-windows.nj';
122
+ }
123
+ nunjucks.configure(askuiHelperTemplateFilePath, { autoescape: false });
124
+ const result = nunjucks.render(templateFileName, this.helperTemplateConfig);
125
+ const filePath = path.join(this.distexampleFolderPath, 'helpers', 'askui-helper.ts');
126
+ if (!fs.existsSync(path.join(this.distexampleFolderPath, 'helpers'))) {
127
+ yield fs.mkdir(path.join(this.distexampleFolderPath, 'helpers'));
128
+ }
129
+ yield fs.writeFile(filePath, result, 'utf8');
130
+ }),
131
+ },
132
+ ]);
133
+ }),
134
+ }];
135
+ });
136
+ }
137
+ setupTestFrameWork() {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ return [{
140
+ title: 'Setup Test framework',
141
+ task: () => __awaiter(this, void 0, void 0, function* () {
142
+ return new Listr([
143
+ {
144
+ title: `Install ${this.cliOptions.testFramework}`,
145
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.installTestFrameworkPackages(); }),
146
+ },
147
+ {
148
+ title: 'Copy config file',
149
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.copyTestFrameworkConfig(); }),
150
+ },
151
+ {
152
+ title: 'Add timeout',
153
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.addTestFrameWorkTimeout(); }),
154
+ },
155
+ {
156
+ title: 'Add reporter (only Jest)',
157
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.addReporterConfig(); }),
158
+ },
159
+ {
160
+ title: 'Add askui run command',
161
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.addAskuiRunCommand(); }),
162
+ },
163
+ {
164
+ title: 'Add eslint run command',
165
+ task: () => __awaiter(this, void 0, void 0, function* () { return this.addESLintRunCommand(); }),
166
+ },
167
+ ]);
168
+ }),
169
+ }];
170
+ });
171
+ }
172
+ installTestFrameworkPackages() {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const runCommand = promisify(exec);
175
+ const frameworkDepencies = {
176
+ jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
177
+ jasmine: 'npm i -D @askui/askui-reporters typescript ts-node @types/jasmine jasmine @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
178
+ };
179
+ yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
180
+ });
181
+ }
182
+ addUserCredentails() {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ return [{
185
+ title: 'Add user credentails',
186
+ task: () => __awaiter(this, void 0, void 0, function* () {
187
+ return new Listr([
188
+ {
189
+ title: 'Add workspace id ',
190
+ task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['workspace_id'] = this.cliOptions.workspaceId; }),
191
+ },
192
+ {
193
+ title: 'Add access token',
194
+ task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['access_token'] = this.cliOptions.accessToken; }),
195
+ },
196
+ ]);
197
+ }),
198
+ }];
199
+ });
200
+ }
201
+ copyESLintConfigFiles() {
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ const esLintRcFilePath = path.join('example_projects_templates', 'typescript', '.eslintrc.json-template');
204
+ const esLintIgnoreFilePath = path.join('example_projects_templates', 'typescript', '.eslintignore-template');
205
+ return [{
206
+ title: 'Copy ESLint config files',
207
+ task: () => __awaiter(this, void 0, void 0, function* () {
208
+ return new Listr([
209
+ {
210
+ title: 'Add eslintrc.json',
211
+ task: () => __awaiter(this, void 0, void 0, function* () {
212
+ return fs.copyFile(path.join(getPathToNodeModulesRoot(), esLintRcFilePath), path.join(this.baseDirPath, '.eslintrc.json'));
213
+ }),
214
+ },
215
+ {
216
+ title: 'Add .eslintignore',
217
+ task: () => __awaiter(this, void 0, void 0, function* () {
218
+ return fs.copyFile(path.join(getPathToNodeModulesRoot(), esLintIgnoreFilePath), path.join(this.baseDirPath, '.eslintignore'));
219
+ }),
220
+ },
221
+ ]);
222
+ }),
223
+ }];
224
+ });
225
+ }
226
+ copyTsConfigFile() {
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ const tsConfigFilePath = path.join('example_projects_templates', 'typescript', 'tsconfig.json');
229
+ return [{
230
+ title: 'Copy ts config file',
231
+ enabled: () => this.cliOptions.typescriptConfig,
232
+ task: () => __awaiter(this, void 0, void 0, function* () {
233
+ return fs.copyFile(path.join(getPathToNodeModulesRoot(), tsConfigFilePath), path.join(this.baseDirPath, 'tsconfig.json'));
234
+ }),
235
+ }];
236
+ });
237
+ }
238
+ installProxy() {
239
+ return __awaiter(this, void 0, void 0, function* () {
240
+ const runCommand = promisify(exec);
241
+ return [{
242
+ title: 'Install Proxy',
243
+ enabled: () => this.cliOptions.usingProxy,
244
+ task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm install --save-dev hpagent '); }),
245
+ }];
246
+ });
247
+ }
248
+ normalizeCliOptions() {
249
+ let useProxy = this.cliOptions.usingProxy;
250
+ if (typeof useProxy !== 'boolean') {
251
+ useProxy = (useProxy === 'true');
252
+ }
253
+ this.cliOptions.usingProxy = useProxy;
254
+ let { typescriptConfig } = this.cliOptions;
255
+ if (typeof typescriptConfig !== 'boolean') {
256
+ typescriptConfig = (typescriptConfig === 'true');
257
+ }
258
+ this.cliOptions.typescriptConfig = typescriptConfig;
259
+ }
260
+ createExampleProject() {
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ const tasks = new Listr();
263
+ this.normalizeCliOptions();
264
+ tasks.add([
265
+ ...yield this.copyTemplateProject(),
266
+ ...yield this.setupTestFrameWork(),
267
+ ...yield this.copyESLintConfigFiles(),
268
+ ...yield this.copyTsConfigFile(),
269
+ ...yield this.addUserCredentails(),
270
+ ...yield this.createAskUIHelperFromTemplate(),
271
+ ...yield this.installProxy(),
272
+ ]);
273
+ yield tasks.run();
274
+ /* eslint-disable no-console */
275
+ if (this.cliOptions.usingProxy) {
276
+ console.log(chalk.redBright('Since you are using a Proxy. Please don\'t forget to configure it!'));
277
+ console.log(chalk.gray(`You can find more information under ${this.proxyDocUrl}`));
278
+ }
279
+ console.log(chalk.greenBright('\nCongratulations!'));
280
+ console.log(`askui example was created under ${chalk.gray(this.distexampleFolderPath)}`);
281
+ if (this.cliOptions.operatingSystem === 'windows') {
282
+ console.log(chalk.redBright(`\nPlease install and start the Remote Device Controller: ${this.remoteDeviceControllerUrl}\n`));
283
+ }
284
+ console.log(`You can start your automation with this command ${chalk.green('npm run askui')}`);
285
+ /* eslint-enable no-console */
286
+ });
287
+ }
288
+ }
@@ -0,0 +1 @@
1
+ export { init } from './cli';
@@ -0,0 +1 @@
1
+ export { init } from './cli';
@@ -0,0 +1 @@
1
+ export declare function replaceStringInFile(filePath: string, replace: string, replacement: string): Promise<void>;
@@ -0,0 +1,24 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import fs from 'fs-extra';
11
+ import { logger } from '../logger';
12
+ export function replaceStringInFile(filePath, replace, replacement) {
13
+ return __awaiter(this, void 0, void 0, function* () {
14
+ try {
15
+ const data = yield fs.readFile(filePath, 'utf8');
16
+ const result = data.replace(replace, replacement);
17
+ yield fs.writeFile(filePath, result, 'utf8');
18
+ }
19
+ catch (error) {
20
+ logger.error(`Could not replace '${replace}' with '${replacement}' in file '${filePath}'`);
21
+ logger.error(error.message);
22
+ }
23
+ });
24
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "spec_dir": "askui_example",
3
+ "spec_files": [
4
+ "**/*[sS]pec.ts",
5
+ "**/*[tT]est.ts"
6
+ ],
7
+ "helpers": [
8
+ "../node_modules/ts-node/register/type-check.js",
9
+ "./helpers/askui-helper.ts"
10
+ ],
11
+ "random": false
12
+ }
@@ -0,0 +1,13 @@
1
+ import type { Config } from '@jest/types';
2
+
3
+ const config: Config.InitialOptions = {
4
+ preset: 'ts-jest',
5
+ testEnvironment: '@askui/jest-allure-circus',
6
+ setupFilesAfterEnv: ['./helpers/askui-helper.ts'],
7
+ sandboxInjectedGlobals: [
8
+ 'Math',
9
+ ],
10
+ };
11
+
12
+ // eslint-disable-next-line import/no-default-export
13
+ export default config;
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "CommonJS",
4
+ "esModuleInterop": true,
5
+ "moduleResolution": "node"
6
+ }
7
+ }
@@ -0,0 +1,35 @@
1
+ import { UiControlClient } from 'askui';
2
+ {{ allure_stepreporter_import }}
3
+
4
+ // Client is necessary to use the askui API
5
+ // eslint-disable-next-line import/no-mutable-exports
6
+ let aui: UiControlClient;
7
+
8
+ {{ timeout_placeholder }}
9
+
10
+ beforeAll(async () => {
11
+ aui = await UiControlClient.build({
12
+ credentials: {
13
+ workspaceId: '{{ workspace_id}}',
14
+ token: '{{ access_token }}',
15
+ },
16
+ {{ reporter_placeholder }}
17
+ });
18
+
19
+ await aui.connect();
20
+ });
21
+
22
+ beforeEach(async () => {
23
+ await aui.startVideoRecording();
24
+ });
25
+
26
+ afterEach(async () => {
27
+ await aui.stopVideoRecording();
28
+ {{ allure_stepreporter_attach_video }}
29
+ });
30
+
31
+ afterAll(async () => {
32
+ aui.disconnect();
33
+ });
34
+
35
+ export { aui };
@@ -0,0 +1,49 @@
1
+ import { UiControlClient, UiController } from 'askui';
2
+ {{ allure_stepreporter_import }}
3
+
4
+ // Server for controlling the operating system
5
+ let uiController: UiController;
6
+
7
+ // Client is necessary to use the askui API
8
+ let aui: UiControlClient;
9
+
10
+ {{ timeout_placeholder }}
11
+
12
+ beforeAll(async () => {
13
+ uiController = new UiController({
14
+ /**
15
+ * Select the display you want to run your tests on, display 0 is your main display;
16
+ * ignore if you have only one display
17
+ */
18
+ display: 0,
19
+ });
20
+
21
+ await uiController.start();
22
+
23
+ aui = await UiControlClient.build({
24
+ credentials: {
25
+ workspaceId: '{{ workspace_id}}',
26
+ token: '{{ access_token }}',
27
+ },
28
+ {{ reporter_placeholder }}
29
+ });
30
+
31
+ await aui.connect();
32
+ });
33
+
34
+ beforeEach(async () => {
35
+ await aui.startVideoRecording();
36
+ });
37
+
38
+ afterEach(async () => {
39
+ await aui.stopVideoRecording();
40
+ {{ allure_stepreporter_attach_video }}
41
+ });
42
+
43
+ afterAll(async () => {
44
+ aui.disconnect();
45
+
46
+ await uiController.stop();
47
+ });
48
+
49
+ export { aui };
@@ -0,0 +1,20 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": [
7
+ ],
8
+ "parser": "@typescript-eslint/parser",
9
+ "parserOptions": {
10
+ "ecmaVersion": "latest",
11
+ "sourceType": "module"
12
+ },
13
+ "plugins": [
14
+ "import",
15
+ "askui"
16
+ ],
17
+ "rules": {
18
+ "askui/no-missing-askui-exec": "error"
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true
5
+ },
6
+ "extends": [
7
+ ],
8
+ "parser": "@typescript-eslint/parser",
9
+ "parserOptions": {
10
+ "ecmaVersion": "latest",
11
+ "sourceType": "module"
12
+ },
13
+ "plugins": [
14
+ "import",
15
+ "askui"
16
+ ],
17
+ "rules": {
18
+ "askui/no-missing-askui-exec": "error"
19
+ }
20
+ }