askui 0.14.0 → 0.16.0

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 (31) hide show
  1. package/README.md +1 -2
  2. package/dist/cjs/execution/read-credentials.d.ts +3 -0
  3. package/dist/cjs/execution/read-credentials.js +24 -0
  4. package/dist/cjs/execution/read-environment-credentials.js +1 -1
  5. package/dist/cjs/execution/ui-control-client-dependency-builder.js +3 -3
  6. package/dist/cjs/execution/ui-control-client.d.ts +0 -16
  7. package/dist/cjs/execution/ui-control-client.js +0 -24
  8. package/dist/cjs/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
  9. package/dist/cjs/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +21 -2
  10. package/dist/cjs/lib/interactive_cli/cli-options-interface.d.ts +2 -2
  11. package/dist/cjs/lib/interactive_cli/cli.js +35 -38
  12. package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +2 -5
  13. package/dist/cjs/lib/interactive_cli/create-example-project.js +51 -78
  14. package/dist/cjs/lib/logger.d.ts +1 -7
  15. package/dist/esm/execution/read-credentials.d.ts +3 -0
  16. package/dist/esm/execution/read-credentials.js +20 -0
  17. package/dist/esm/execution/read-environment-credentials.js +1 -1
  18. package/dist/esm/execution/ui-control-client-dependency-builder.js +3 -3
  19. package/dist/esm/execution/ui-control-client.d.ts +0 -16
  20. package/dist/esm/execution/ui-control-client.js +0 -24
  21. package/dist/esm/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
  22. package/dist/esm/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +19 -1
  23. package/dist/esm/lib/interactive_cli/cli-options-interface.d.ts +2 -2
  24. package/dist/esm/lib/interactive_cli/cli.js +35 -38
  25. package/dist/esm/lib/interactive_cli/create-example-project.d.ts +2 -5
  26. package/dist/esm/lib/interactive_cli/create-example-project.js +50 -77
  27. package/dist/esm/lib/logger.d.ts +1 -7
  28. package/dist/example_projects_templates/templates/askui-helper-windows.nj +1 -4
  29. package/dist/example_projects_templates/templates/askui-helper.nj +1 -4
  30. package/package.json +10 -10
  31. package/dist/example_projects_templates/configs/jasmine.config.json +0 -12
package/README.md CHANGED
@@ -1,9 +1,8 @@
1
- # AskUI - Humanizing UI Automation
1
+ # AskUI - What Can Be Said Can Be Solved
2
2
 
3
3
  **AskUI** allows you to automate the interaction with an application, multiple applications or even the entire operating system.
4
4
  You can use this to write end-to-end tests or automate any kind of application.
5
5
 
6
-
7
6
  ## Start
8
7
 
9
8
  To use **AskUI** follow these steps:
@@ -0,0 +1,3 @@
1
+ import { CredentialArgs } from './credentials-args';
2
+ import { ClientArgs } from './ui-controller-client-interface';
3
+ export declare function readCredentials(clientArgs: ClientArgs): CredentialArgs;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCredentials = void 0;
4
+ const lib_1 = require("../lib");
5
+ const read_environment_credentials_1 = require("./read-environment-credentials");
6
+ function readCredentials(clientArgs) {
7
+ const environmentCredentials = (0, read_environment_credentials_1.envCredentials)();
8
+ const inCodeCredentials = clientArgs.credentials;
9
+ const credentials = inCodeCredentials !== null && inCodeCredentials !== void 0 ? inCodeCredentials : environmentCredentials;
10
+ if (!credentials) {
11
+ throw new Error('No credentials are defined! Please define a token and a Workspace ID in the environment variables ASKUI_TOKEN and ASKUI_WORKSPACE_ID or define them in the UiControlClient.build.');
12
+ }
13
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.token)) {
14
+ throw new Error('No Token is defined! Please define a token in the environment variable ASKUI_TOKEN or define a token in the UiControlClient.');
15
+ }
16
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.workspaceId)) {
17
+ throw new Error('No Workspace ID is defined! Please define a workspace ID in the environment variable ASKUI_WORKSPACE_ID or define a workspace ID in the UiControlClient.');
18
+ }
19
+ if (environmentCredentials && inCodeCredentials) {
20
+ lib_1.logger.warn('In-code credentials in UiControlClient.build and ENV variables(ASKUI_WORKSPACE_ID und ASKUI_TOKEN) are defined! We recommend to remove the in-code credentials for security reason! In-code credentials will be used for this execution.');
21
+ }
22
+ return credentials;
23
+ }
24
+ exports.readCredentials = readCredentials;
@@ -6,7 +6,7 @@ function envCredentials() {
6
6
  const envToken = process.env['ASKUI_TOKEN'];
7
7
  const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
8
8
  if (envToken && envWorkspaceId) {
9
- lib_1.logger.info('Credentials are used from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
9
+ lib_1.logger.debug('AskUI credentials are being read from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
10
10
  return {
11
11
  workspaceId: envWorkspaceId,
12
12
  token: envToken,
@@ -13,11 +13,11 @@ exports.UiControlClientDependencyBuilder = void 0;
13
13
  const http_client_got_1 = require("../utils/http/http-client-got");
14
14
  const ui_controller_client_1 = require("./ui-controller-client");
15
15
  const inference_client_1 = require("./inference-client");
16
- const read_environment_credentials_1 = require("./read-environment-credentials");
17
16
  const analytics_1 = require("../utils/analytics");
18
17
  const proxy_builder_1 = require("../utils/proxy/proxy-builder");
19
18
  const execution_runtime_1 = require("./execution-runtime");
20
19
  const reporting_1 = require("../core/reporting");
20
+ const read_credentials_1 = require("./read-credentials");
21
21
  class UiControlClientDependencyBuilder {
22
22
  static buildHttpClient(clientArgs) {
23
23
  var _a;
@@ -50,9 +50,9 @@ class UiControlClientDependencyBuilder {
50
50
  });
51
51
  }
52
52
  static getClientArgsWithDefaults(clientArgs) {
53
- var _a, _b, _c, _d;
53
+ var _a, _b, _c;
54
54
  return __awaiter(this, void 0, void 0, function* () {
55
- return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: (_c = clientArgs.credentials) !== null && _c !== void 0 ? _c : (0, read_environment_credentials_1.envCredentials)(), proxyAgents: (_d = clientArgs.proxyAgents) !== null && _d !== void 0 ? _d : yield (0, proxy_builder_1.envProxyAgents)() });
55
+ return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: (0, read_credentials_1.readCredentials)(clientArgs), proxyAgents: (_c = clientArgs.proxyAgents) !== null && _c !== void 0 ? _c : (yield (0, proxy_builder_1.envProxyAgents)()) });
56
56
  });
57
57
  }
58
58
  }
@@ -141,22 +141,6 @@ export declare class UiControlClient extends ApiCommands {
141
141
  * @param {string} description
142
142
  */
143
143
  clickIcon(description: string): Promise<void>;
144
- /**
145
- * Drags element1 to element2.
146
- *
147
- * Both must be a `moveMouse()` or `moveMouseTo()`
148
- * instruction as in the example below.
149
- *
150
- * Usage example:
151
- * dragTo(
152
- * aui.moveMouseTo().text('AskUI'),
153
- * aui.moveMouseTo().text('UI Automation')
154
- * )
155
- *
156
- * @param {Executable} element1
157
- * @param {Executable} element2
158
- */
159
- dragTo(element1: Executable, element2: Executable): Promise<void>;
160
144
  /**
161
145
  * Wait until an AskUICommand does not fail.
162
146
  *
@@ -307,30 +307,6 @@ class UiControlClient extends dsl_1.ApiCommands {
307
307
  yield this.click().icon().matching(description).exec();
308
308
  });
309
309
  }
310
- /**
311
- * Drags element1 to element2.
312
- *
313
- * Both must be a `moveMouse()` or `moveMouseTo()`
314
- * instruction as in the example below.
315
- *
316
- * Usage example:
317
- * dragTo(
318
- * aui.moveMouseTo().text('AskUI'),
319
- * aui.moveMouseTo().text('UI Automation')
320
- * )
321
- *
322
- * @param {Executable} element1
323
- * @param {Executable} element2
324
- */
325
- dragTo(element1, element2) {
326
- return __awaiter(this, void 0, void 0, function* () {
327
- yield element1.exec();
328
- yield this.mouseLeftClick().exec();
329
- yield this.mouseToggleDown().exec();
330
- yield element2.exec();
331
- yield this.mouseToggleUp().exec();
332
- });
333
- }
334
310
  /**
335
311
  * Wait until an AskUICommand does not fail.
336
312
  *
@@ -1 +1,2 @@
1
1
  export declare function addScript(filePath: string, name: string, command: string): Promise<void>;
2
+ export declare function removeScript(filePath: string, name: string): Promise<void>;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.addScript = void 0;
15
+ exports.removeScript = exports.addScript = void 0;
16
16
  const fs_extra_1 = __importDefault(require("fs-extra"));
17
17
  const logger_1 = require("../logger");
18
18
  function addScript(filePath, name, command) {
@@ -30,9 +30,28 @@ function addScript(filePath, name, command) {
30
30
  yield fs_extra_1.default.writeFile(filePath, jsonString, 'utf8');
31
31
  }
32
32
  catch (error) {
33
- logger_1.logger.error(`Could write script '${command}' in file '${filePath}'`);
33
+ logger_1.logger.error(`Could not write script '${command}' in file '${filePath}'`);
34
34
  logger_1.logger.error(error.message);
35
35
  }
36
36
  });
37
37
  }
38
38
  exports.addScript = addScript;
39
+ function removeScript(filePath, name) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const data = yield fs_extra_1.default.readFile(filePath, 'utf8');
43
+ const jsonData = JSON.parse(data);
44
+ if (jsonData.scripts === undefined) {
45
+ return;
46
+ }
47
+ delete jsonData.scripts[name];
48
+ const jsonString = JSON.stringify(jsonData, null, 2);
49
+ yield fs_extra_1.default.writeFile(filePath, jsonString, 'utf8');
50
+ }
51
+ catch (error) {
52
+ logger_1.logger.error(`Could not remove script '${name}' in file '${filePath}'`);
53
+ logger_1.logger.error(error.message);
54
+ }
55
+ });
56
+ }
57
+ exports.removeScript = removeScript;
@@ -1,8 +1,8 @@
1
1
  export interface CliOptions {
2
+ skipCredentials: boolean;
2
3
  operatingSystem: 'windows' | 'linux' | 'macos';
3
4
  workspaceId: string;
4
5
  accessToken: string;
5
- testFramework: 'jasmine' | 'jest';
6
- usingProxy: boolean;
6
+ testFramework: 'jest';
7
7
  typescriptConfig: boolean;
8
8
  }
@@ -15,65 +15,65 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.init = void 0;
16
16
  const inquirer_1 = __importDefault(require("inquirer"));
17
17
  const commander_1 = require("commander");
18
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
19
  const create_example_project_1 = require("./create-example-project");
19
- const nonEmpty = (subject) => (input) => (input.trim().length > 0) || `${subject} is required.`;
20
+ const nonEmpty = (subject) => (input) => input.trim().length > 0 || `${subject} is required.`;
20
21
  const questions = [
21
22
  {
22
23
  type: 'list',
23
24
  name: 'testFramework',
24
- message: 'Which framework do you prefer',
25
- choices: ['jest', 'jasmine'],
25
+ message: 'Which framework do you prefer?:',
26
+ choices: ['jest'],
26
27
  },
27
28
  {
28
29
  type: 'input',
29
30
  name: 'workspaceId',
30
- message: 'Your workspace id',
31
+ message: 'Your workspace id:',
31
32
  validate: nonEmpty('workspace id'),
33
+ when: (answers) => !answers.skipCredentials,
32
34
  },
33
35
  {
34
36
  type: 'password',
35
37
  name: 'accessToken',
36
- message: 'Your access token',
38
+ message: 'Your access token:',
37
39
  mask: '*',
38
40
  validate: nonEmpty('access token'),
39
- },
40
- {
41
- type: 'confirm',
42
- name: 'usingProxy',
43
- message: 'Are you using a proxy?',
44
- default: false,
41
+ when: (answers) => !answers.skipCredentials,
45
42
  },
46
43
  {
47
44
  type: 'confirm',
48
45
  name: 'typescriptConfig',
49
- message: 'Do you want to add the tsconfig.json file? This action will overwrite the file if it exists. Default True ',
50
- default: true,
46
+ message: 'Do you want to overwrite the tsconfig.json file? Default No:',
47
+ default: false,
48
+ when: (_answers) => fs_extra_1.default.existsSync('tsconfig.json'),
51
49
  },
52
50
  ];
53
51
  const options = [
54
52
  {
55
53
  option: '-f, --test-framework <value>',
56
- choices: ['jasmine', 'jest'],
57
- description: 'the test framework to use',
54
+ choices: ['jest'],
55
+ description: 'the test framework to use.',
56
+ default: 'jest',
58
57
  },
59
58
  {
60
- option: '-w, --workspace-id <value>',
59
+ option: '-sc, --skip-credentials',
61
60
  choices: [],
62
- description: 'a workspace id',
61
+ description: 'skip the credentials setup.',
62
+ default: false,
63
63
  },
64
64
  {
65
- option: '-a, --access-token <value>',
65
+ option: '-w, --workspace-id <value>',
66
66
  choices: [],
67
- description: 'an access token for the workspace with the id',
67
+ description: 'a workspace id.',
68
68
  },
69
69
  {
70
- option: '-p, --using-proxy <value>',
71
- choices: ['true', 'false'],
72
- description: 'use a proxy',
70
+ option: '-a, --access-token <value>',
71
+ choices: [],
72
+ description: 'an access token for the workspace with the id.',
73
73
  },
74
74
  {
75
- option: '-t, --typescript-config <value>',
76
- choices: ['true', 'false'],
75
+ option: '-t, --typescript-config',
76
+ choices: [],
77
77
  description: 'overwrite tsconfig.json flag',
78
78
  },
79
79
  ];
@@ -86,29 +86,26 @@ function init(argv) {
86
86
  const args = argv || process.argv;
87
87
  const program = createProgram();
88
88
  const programInit = program.command('init');
89
- programInit.description('Creates a askui example project');
89
+ // To Ensure Backwards Compatibility
90
+ programInit.allowUnknownOption(true);
91
+ programInit.description('Creates an AskUI example project:');
90
92
  // Loop through the options object and register each option with the program
91
93
  options.forEach((opt) => {
92
94
  const tempOption = new commander_1.Option(opt.option, opt.description);
93
95
  if (opt.choices.length > 0) {
94
96
  tempOption.choices(opt.choices);
95
97
  }
98
+ if (opt.default) {
99
+ tempOption.default(opt.default);
100
+ }
96
101
  programInit.addOption(tempOption);
97
102
  });
98
- programInit.usage('[-f test_framework] [-w workspace_id] [-a access_token] [-p boolean] [-t boolean]');
99
- programInit
100
- .action((_opts) => __awaiter(this, void 0, void 0, function* () {
103
+ programInit.usage('[options]');
104
+ programInit.action((_opts) => __awaiter(this, void 0, void 0, function* () {
101
105
  const userAnswers = programInit.opts();
102
- // Check which options are missing and prompt the user for them
103
- const missingOptions = questions.filter((entry) => !(entry.name in userAnswers));
104
- if (missingOptions.length > 0) {
105
- inquirer_1.default.prompt(missingOptions).then((answers) => __awaiter(this, void 0, void 0, function* () {
106
- yield new create_example_project_1.CreateExampleProject(Object.assign(Object.assign({}, userAnswers), answers)).createExampleProject();
107
- }));
108
- }
109
- else {
110
- yield new create_example_project_1.CreateExampleProject(userAnswers).createExampleProject();
111
- }
106
+ inquirer_1.default.prompt(questions, userAnswers).then((answers) => __awaiter(this, void 0, void 0, function* () {
107
+ yield new create_example_project_1.CreateExampleProject(Object.assign(Object.assign({}, userAnswers), answers)).createExampleProject();
108
+ }));
112
109
  }));
113
110
  return program.parse(args);
114
111
  }
@@ -4,8 +4,7 @@ export declare class CreateExampleProject {
4
4
  private distexampleFolderPath;
5
5
  private exampleFolderName;
6
6
  private baseDirPath;
7
- private proxyDocUrl;
8
- private remoteDeviceControllerUrl;
7
+ private askUIControllerUrl;
9
8
  private helperTemplateConfig;
10
9
  constructor(cliOptions: CliOptions);
11
10
  private copyTemplateProject;
@@ -16,11 +15,9 @@ export declare class CreateExampleProject {
16
15
  private addESLintRunCommand;
17
16
  private createAskUIHelperFromTemplate;
18
17
  private setupTestFrameWork;
19
- private installTestFrameworkPackages;
18
+ private static installTestFrameworkPackages;
20
19
  private addUserCredentials;
21
20
  private copyESLintConfigFiles;
22
21
  private copyTsConfigFile;
23
- private installProxy;
24
- private normalizeCliOptions;
25
22
  createExampleProject(): Promise<void>;
26
23
  }
@@ -21,15 +21,14 @@ const listr_1 = __importDefault(require("listr"));
21
21
  const chalk_1 = __importDefault(require("chalk"));
22
22
  const nunjucks_1 = __importDefault(require("nunjucks"));
23
23
  const path_2 = require("../../utils/path");
24
- const add_script_package_json_1 = require("./add-script-package-json");
24
+ const add_remove_script_package_json_1 = require("./add-remove-script-package-json");
25
25
  class CreateExampleProject {
26
26
  constructor(cliOptions) {
27
27
  this.cliOptions = cliOptions;
28
28
  this.baseDirPath = process.cwd();
29
29
  this.exampleFolderName = 'askui_example';
30
30
  this.distexampleFolderPath = path_1.default.join(this.baseDirPath, this.exampleFolderName);
31
- this.proxyDocUrl = 'https://docs.askui.com/docs/general/Troubleshooting/proxy';
32
- this.remoteDeviceControllerUrl = 'https://docs.askui.com/docs/api/Remote-Device-Controller';
31
+ this.askUIControllerUrl = 'https://docs.askui.com/docs/general/Components/AskUI-Controller';
33
32
  this.helperTemplateConfig = {};
34
33
  }
35
34
  copyTemplateProject() {
@@ -64,7 +63,11 @@ class CreateExampleProject {
64
63
  },
65
64
  {
66
65
  title: 'Install askui dependency',
67
- task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm i -D askui '); }),
66
+ task: () => __awaiter(this, void 0, void 0, function* () {
67
+ yield runCommand('npm init -y');
68
+ yield (0, add_remove_script_package_json_1.removeScript)(`${this.baseDirPath}/package.json`, 'test');
69
+ yield runCommand('npm i -D askui ');
70
+ }),
68
71
  },
69
72
  ];
70
73
  });
@@ -73,43 +76,38 @@ class CreateExampleProject {
73
76
  return __awaiter(this, void 0, void 0, function* () {
74
77
  const frameworkConfigs = {
75
78
  jest: 'jest.config.ts',
76
- jasmine: 'jasmine.config.json',
77
79
  };
78
- const configFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'configs', frameworkConfigs[this.cliOptions.testFramework]);
79
- yield fs_extra_1.default.copyFile(configFilePath, path_1.default.join(this.distexampleFolderPath, frameworkConfigs[this.cliOptions.testFramework]));
80
+ const configFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'configs', frameworkConfigs.jest);
81
+ yield fs_extra_1.default.copyFile(configFilePath, path_1.default.join(this.distexampleFolderPath, frameworkConfigs.jest));
80
82
  });
81
83
  }
82
84
  addTestFrameWorkTimeout() {
83
85
  return __awaiter(this, void 0, void 0, function* () {
84
86
  const frameworkTimeoutstring = {
85
87
  jest: 'jest.setTimeout(60 * 1000 * 60);',
86
- jasmine: 'jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000 * 60;',
87
88
  };
88
- this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring[this.cliOptions.testFramework];
89
+ this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring.jest;
89
90
  });
90
91
  }
91
92
  addReporterConfig() {
92
93
  return __awaiter(this, void 0, void 0, function* () {
93
- if (this.cliOptions.testFramework === 'jest') {
94
- this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
95
- this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
96
- this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
94
+ this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
95
+ this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
96
+ this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
97
97
  await AskUIAllureStepReporter.attachVideo(video);`;
98
- }
99
98
  });
100
99
  }
101
100
  addAskuiRunCommand() {
102
101
  return __awaiter(this, void 0, void 0, function* () {
103
102
  const frameworkExecutionCommand = {
104
103
  jest: `jest --config ./${this.exampleFolderName}/jest.config.ts --runInBand`,
105
- jasmine: `jasmine --config=${this.exampleFolderName}/jasmine.config.json`,
106
104
  };
107
- yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand[this.cliOptions.testFramework]);
105
+ yield (0, add_remove_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand.jest);
108
106
  });
109
107
  }
110
108
  addESLintRunCommand() {
111
109
  return __awaiter(this, void 0, void 0, function* () {
112
- yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
110
+ yield (0, add_remove_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
113
111
  });
114
112
  }
115
113
  createAskUIHelperFromTemplate() {
@@ -147,8 +145,8 @@ class CreateExampleProject {
147
145
  task: () => __awaiter(this, void 0, void 0, function* () {
148
146
  return new listr_1.default([
149
147
  {
150
- title: `Install ${this.cliOptions.testFramework}`,
151
- task: () => __awaiter(this, void 0, void 0, function* () { return this.installTestFrameworkPackages(); }),
148
+ title: 'Install jest',
149
+ task: () => __awaiter(this, void 0, void 0, function* () { return CreateExampleProject.installTestFrameworkPackages(); }),
152
150
  },
153
151
  {
154
152
  title: 'Copy config file',
@@ -159,7 +157,7 @@ class CreateExampleProject {
159
157
  task: () => __awaiter(this, void 0, void 0, function* () { return this.addTestFrameWorkTimeout(); }),
160
158
  },
161
159
  {
162
- title: 'Add reporter (only Jest)',
160
+ title: 'Add reporter',
163
161
  task: () => __awaiter(this, void 0, void 0, function* () { return this.addReporterConfig(); }),
164
162
  },
165
163
  {
@@ -175,33 +173,29 @@ class CreateExampleProject {
175
173
  }];
176
174
  });
177
175
  }
178
- installTestFrameworkPackages() {
176
+ static installTestFrameworkPackages() {
179
177
  return __awaiter(this, void 0, void 0, function* () {
180
178
  const runCommand = (0, util_1.promisify)(child_process_1.exec);
181
- const frameworkDepencies = {
182
- 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',
183
- 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',
179
+ const frameworkDependencies = {
180
+ 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 hpagent',
184
181
  };
185
- yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
182
+ yield runCommand(frameworkDependencies.jest);
186
183
  });
187
184
  }
188
185
  addUserCredentials() {
189
186
  return __awaiter(this, void 0, void 0, function* () {
190
- return [{
187
+ return [
188
+ {
191
189
  title: 'Add user credentials',
190
+ enabled: () => !this.cliOptions.skipCredentials,
192
191
  task: () => __awaiter(this, void 0, void 0, function* () {
193
- return new listr_1.default([
194
- {
195
- title: 'Add workspace id ',
196
- task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['workspace_id'] = this.cliOptions.workspaceId; }),
197
- },
198
- {
199
- title: 'Add access token',
200
- task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['access_token'] = this.cliOptions.accessToken; }),
201
- },
202
- ]);
192
+ this.helperTemplateConfig['credentials'] = ` credentials: {
193
+ workspaceId: '${this.cliOptions.workspaceId}',
194
+ token: '${this.cliOptions.accessToken}',
195
+ },`;
203
196
  }),
204
- }];
197
+ },
198
+ ];
205
199
  });
206
200
  }
207
201
  copyESLintConfigFiles() {
@@ -226,68 +220,47 @@ class CreateExampleProject {
226
220
  },
227
221
  ]);
228
222
  }),
229
- }];
223
+ },
224
+ ];
230
225
  });
231
226
  }
232
227
  copyTsConfigFile() {
233
228
  return __awaiter(this, void 0, void 0, function* () {
234
229
  const tsConfigFilePath = path_1.default.join('example_projects_templates', 'typescript', 'tsconfig.json');
235
- return [{
230
+ const tsConfigTargetFilePath = path_1.default.join(this.baseDirPath, 'tsconfig.json');
231
+ return [
232
+ {
236
233
  title: 'Copy ts config file',
237
- enabled: () => this.cliOptions.typescriptConfig,
234
+ enabled: () => this.cliOptions.typescriptConfig || !fs_extra_1.default.existsSync(tsConfigTargetFilePath),
238
235
  task: () => __awaiter(this, void 0, void 0, function* () {
239
- return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), tsConfigFilePath), path_1.default.join(this.baseDirPath, 'tsconfig.json'));
236
+ return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), tsConfigFilePath), tsConfigTargetFilePath);
240
237
  }),
241
- }];
242
- });
243
- }
244
- installProxy() {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- const runCommand = (0, util_1.promisify)(child_process_1.exec);
247
- return [{
248
- title: 'Install Proxy',
249
- enabled: () => this.cliOptions.usingProxy,
250
- task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm install --save-dev hpagent '); }),
251
- }];
238
+ },
239
+ ];
252
240
  });
253
241
  }
254
- normalizeCliOptions() {
255
- let useProxy = this.cliOptions.usingProxy;
256
- if (typeof useProxy !== 'boolean') {
257
- useProxy = (useProxy === 'true');
258
- }
259
- this.cliOptions.usingProxy = useProxy;
260
- let { typescriptConfig } = this.cliOptions;
261
- if (typeof typescriptConfig !== 'boolean') {
262
- typescriptConfig = (typescriptConfig === 'true');
263
- }
264
- this.cliOptions.typescriptConfig = typescriptConfig;
265
- }
266
242
  createExampleProject() {
267
243
  return __awaiter(this, void 0, void 0, function* () {
268
244
  const tasks = new listr_1.default();
269
- this.normalizeCliOptions();
270
245
  tasks.add([
271
- ...yield this.copyTemplateProject(),
272
- ...yield this.setupTestFrameWork(),
273
- ...yield this.copyESLintConfigFiles(),
274
- ...yield this.copyTsConfigFile(),
275
- ...yield this.addUserCredentials(),
276
- ...yield this.createAskUIHelperFromTemplate(),
277
- ...yield this.installProxy(),
246
+ ...(yield this.copyTemplateProject()),
247
+ ...(yield this.setupTestFrameWork()),
248
+ ...(yield this.copyESLintConfigFiles()),
249
+ ...(yield this.copyTsConfigFile()),
250
+ ...(yield this.addUserCredentials()),
251
+ ...(yield this.createAskUIHelperFromTemplate()),
278
252
  ]);
279
253
  yield tasks.run();
280
254
  /* eslint-disable no-console */
281
- if (this.cliOptions.usingProxy) {
282
- console.log(chalk_1.default.redBright('Since you are using a Proxy. Please don\'t forget to configure it!'));
283
- console.log(chalk_1.default.gray(`You can find more information under ${this.proxyDocUrl}`));
284
- }
285
255
  console.log(chalk_1.default.greenBright('\nCongratulations!'));
286
256
  console.log(`askui example was created under ${chalk_1.default.gray(this.distexampleFolderPath)}`);
287
257
  if (this.cliOptions.operatingSystem === 'windows') {
288
- console.log(chalk_1.default.redBright(`\nPlease install and start the Remote Device Controller: ${this.remoteDeviceControllerUrl}\n`));
258
+ console.log(chalk_1.default.redBright(`\nPlease make sure the AskUI Controller is running: ${this.askUIControllerUrl}\n`));
259
+ console.log(`You can start your automation with this command ${chalk_1.default.green('AskUI-RunProject')}`);
260
+ }
261
+ else {
262
+ console.log(`You can start your automation with this command ${chalk_1.default.green('npm run askui')}`);
289
263
  }
290
- console.log(`You can start your automation with this command ${chalk_1.default.green('npm run askui')}`);
291
264
  /* eslint-enable no-console */
292
265
  });
293
266
  }
@@ -1,8 +1,2 @@
1
- declare const logger: import("pino").Logger<{
2
- name: string;
3
- level: string;
4
- customLevels: {
5
- verbose: number;
6
- };
7
- }>;
1
+ declare const logger: import("pino").Logger<"verbose">;
8
2
  export { logger };
@@ -0,0 +1,3 @@
1
+ import { CredentialArgs } from './credentials-args';
2
+ import { ClientArgs } from './ui-controller-client-interface';
3
+ export declare function readCredentials(clientArgs: ClientArgs): CredentialArgs;
@@ -0,0 +1,20 @@
1
+ import { logger } from '../lib';
2
+ import { envCredentials } from './read-environment-credentials';
3
+ export function readCredentials(clientArgs) {
4
+ const environmentCredentials = envCredentials();
5
+ const inCodeCredentials = clientArgs.credentials;
6
+ const credentials = inCodeCredentials !== null && inCodeCredentials !== void 0 ? inCodeCredentials : environmentCredentials;
7
+ if (!credentials) {
8
+ throw new Error('No credentials are defined! Please define a token and a Workspace ID in the environment variables ASKUI_TOKEN and ASKUI_WORKSPACE_ID or define them in the UiControlClient.build.');
9
+ }
10
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.token)) {
11
+ throw new Error('No Token is defined! Please define a token in the environment variable ASKUI_TOKEN or define a token in the UiControlClient.');
12
+ }
13
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.workspaceId)) {
14
+ throw new Error('No Workspace ID is defined! Please define a workspace ID in the environment variable ASKUI_WORKSPACE_ID or define a workspace ID in the UiControlClient.');
15
+ }
16
+ if (environmentCredentials && inCodeCredentials) {
17
+ logger.warn('In-code credentials in UiControlClient.build and ENV variables(ASKUI_WORKSPACE_ID und ASKUI_TOKEN) are defined! We recommend to remove the in-code credentials for security reason! In-code credentials will be used for this execution.');
18
+ }
19
+ return credentials;
20
+ }
@@ -3,7 +3,7 @@ export function envCredentials() {
3
3
  const envToken = process.env['ASKUI_TOKEN'];
4
4
  const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
5
5
  if (envToken && envWorkspaceId) {
6
- logger.info('Credentials are used from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
6
+ logger.debug('AskUI credentials are being read from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
7
7
  return {
8
8
  workspaceId: envWorkspaceId,
9
9
  token: envToken,