askui 0.13.1 → 0.15.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.
- package/README.md +1 -2
- package/dist/cjs/execution/read-credentials.d.ts +3 -0
- package/dist/cjs/execution/read-credentials.js +24 -0
- package/dist/cjs/execution/read-environment-credentials.js +1 -1
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +3 -3
- package/dist/cjs/execution/ui-control-client.d.ts +70 -5
- package/dist/cjs/execution/ui-control-client.js +117 -0
- package/dist/cjs/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
- package/dist/cjs/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +21 -2
- package/dist/cjs/lib/interactive_cli/cli-options-interface.d.ts +2 -2
- package/dist/cjs/lib/interactive_cli/cli.js +35 -38
- package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +3 -6
- package/dist/cjs/lib/interactive_cli/create-example-project.js +53 -80
- package/dist/cjs/lib/logger.d.ts +1 -7
- package/dist/esm/execution/read-credentials.d.ts +3 -0
- package/dist/esm/execution/read-credentials.js +20 -0
- package/dist/esm/execution/read-environment-credentials.js +1 -1
- package/dist/esm/execution/ui-control-client-dependency-builder.js +3 -3
- package/dist/esm/execution/ui-control-client.d.ts +70 -5
- package/dist/esm/execution/ui-control-client.js +117 -0
- package/dist/esm/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
- package/dist/esm/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +19 -1
- package/dist/esm/lib/interactive_cli/cli-options-interface.d.ts +2 -2
- package/dist/esm/lib/interactive_cli/cli.js +35 -38
- package/dist/esm/lib/interactive_cli/create-example-project.d.ts +3 -6
- package/dist/esm/lib/interactive_cli/create-example-project.js +52 -79
- package/dist/esm/lib/logger.d.ts +1 -7
- package/dist/example_projects_templates/templates/askui-helper-windows.nj +1 -4
- package/dist/example_projects_templates/templates/askui-helper.nj +1 -4
- package/package.json +13 -14
- package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +0 -75
- package/dist/cjs/core/model/test-case-dto/custom-element-json.js +0 -2
- package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +0 -21
- package/dist/cjs/core/model/test-case-dto/custom-element.js +0 -54
- package/dist/cjs/core/model/test-case-dto/index.d.ts +0 -3
- package/dist/cjs/core/model/test-case-dto/index.js +0 -5
- package/dist/cjs/core/model/test-case-dto/test-step.d.ts +0 -6
- package/dist/cjs/core/model/test-case-dto/test-step.js +0 -2
- package/dist/cjs/core/model/test-case-result-dto/index.d.ts +0 -2
- package/dist/cjs/core/model/test-case-result-dto/index.js +0 -7
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
- package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +0 -16
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
- package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +0 -8
- package/dist/cjs/core/reporting/default-reporter.d.ts +0 -10
- package/dist/cjs/core/reporting/default-reporter.js +0 -12
- package/dist/cjs/execution/annotation-level.d.ts +0 -5
- package/dist/cjs/execution/annotation-level.js +0 -9
- package/dist/cjs/execution/ui-control-client-error.d.ts +0 -2
- package/dist/cjs/execution/ui-control-client-error.js +0 -6
- package/dist/cjs/lib/copy-example-project.d.ts +0 -2
- package/dist/cjs/lib/copy-example-project.js +0 -65
- package/dist/cjs/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
- package/dist/cjs/lib/interactive_cli/replace-string-in-file.js +0 -31
- package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +0 -75
- package/dist/esm/core/model/test-case-dto/custom-element-json.js +0 -1
- package/dist/esm/core/model/test-case-dto/custom-element.d.ts +0 -21
- package/dist/esm/core/model/test-case-dto/custom-element.js +0 -50
- package/dist/esm/core/model/test-case-dto/index.d.ts +0 -3
- package/dist/esm/core/model/test-case-dto/index.js +0 -1
- package/dist/esm/core/model/test-case-dto/test-step.d.ts +0 -6
- package/dist/esm/core/model/test-case-dto/test-step.js +0 -1
- package/dist/esm/core/model/test-case-result-dto/index.d.ts +0 -2
- package/dist/esm/core/model/test-case-result-dto/index.js +0 -2
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
- package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +0 -12
- package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
- package/dist/esm/core/model/test-case-result-dto/test-step-state.js +0 -5
- package/dist/esm/core/reporting/default-reporter.d.ts +0 -10
- package/dist/esm/core/reporting/default-reporter.js +0 -9
- package/dist/esm/execution/annotation-level.d.ts +0 -5
- package/dist/esm/execution/annotation-level.js +0 -6
- package/dist/esm/execution/ui-control-client-error.d.ts +0 -2
- package/dist/esm/execution/ui-control-client-error.js +0 -2
- package/dist/esm/lib/copy-example-project.d.ts +0 -2
- package/dist/esm/lib/copy-example-project.js +0 -58
- package/dist/esm/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
- package/dist/esm/lib/interactive_cli/replace-string-in-file.js +0 -24
- package/dist/example_projects_templates/configs/jasmine.config.json +0 -12
- package/dist/example_projects_templates/typescript/.eslintignore +0 -1
- package/dist/example_projects_templates/typescript/.eslintrc.json +0 -20
- package/dist/example_projects_templates/typescript/askui_example/helpers/askui-helper.ts +0 -39
- package/dist/example_projects_templates/typescript_jest/test/README.md +0 -21
- package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +0 -51
- package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +0 -13
- package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +0 -21
- package/dist/example_projects_templates/typescript_jest/tsconfig.json +0 -7
package/README.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
# AskUI -
|
|
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,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.
|
|
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
|
|
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: (
|
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomElementJson } from '../core/model/custom-element-json';
|
|
2
|
-
import { Exec, Executable, FluentFilters, ApiCommands } from './dsl';
|
|
2
|
+
import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY } from './dsl';
|
|
3
3
|
import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
5
|
import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
|
|
@@ -56,8 +56,8 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
56
56
|
* @return {FluentFilters}
|
|
57
57
|
*/
|
|
58
58
|
typeIn(text: string, { isSecret, secretMask }?: {
|
|
59
|
-
isSecret?: boolean
|
|
60
|
-
secretMask?: string
|
|
59
|
+
isSecret?: boolean;
|
|
60
|
+
secretMask?: string;
|
|
61
61
|
}): FluentFilters;
|
|
62
62
|
/**
|
|
63
63
|
* Types a text at the current position.
|
|
@@ -78,8 +78,8 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
78
78
|
* @return {Exec}
|
|
79
79
|
*/
|
|
80
80
|
type(text: string, { isSecret, secretMask }?: {
|
|
81
|
-
isSecret?: boolean
|
|
82
|
-
secretMask?: string
|
|
81
|
+
isSecret?: boolean;
|
|
82
|
+
secretMask?: string;
|
|
83
83
|
}): Exec;
|
|
84
84
|
/**
|
|
85
85
|
* Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
|
|
@@ -90,4 +90,69 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
90
90
|
* @return {Executable}
|
|
91
91
|
*/
|
|
92
92
|
waitFor(delayInMs: number): Executable;
|
|
93
|
+
/**
|
|
94
|
+
* Press a key multiple times. At least two times.
|
|
95
|
+
*
|
|
96
|
+
* @param {PC_AND_MODIFIER_KEY} key
|
|
97
|
+
*
|
|
98
|
+
* @param {number} times
|
|
99
|
+
*/
|
|
100
|
+
pressKeyNTimes(key: PC_AND_MODIFIER_KEY, times?: number): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Press an array of keys one after another.
|
|
103
|
+
*
|
|
104
|
+
* For example press the following keys: right, left, enter.
|
|
105
|
+
*
|
|
106
|
+
* pressKeys(['right', 'left', 'enter'])
|
|
107
|
+
*
|
|
108
|
+
* @param {PC_AND_MODIFIER_KEY[]} keys
|
|
109
|
+
*/
|
|
110
|
+
pressKeys(keys: PC_AND_MODIFIER_KEY[]): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Searches for a text element and clicks it when found.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} text - A text to be searched.
|
|
115
|
+
*/
|
|
116
|
+
clickText(text: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Searches for text elements and clicks them
|
|
119
|
+
* one after another when found.
|
|
120
|
+
*
|
|
121
|
+
* @param {string[]} texts - An array of texts to be searched.
|
|
122
|
+
*/
|
|
123
|
+
clickTexts(texts: string[]): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Searches for an element of type button
|
|
126
|
+
* with a label and clicks it when found.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} label - The buttons label.
|
|
129
|
+
*/
|
|
130
|
+
clickButton(label: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Searches for an element of type textfield with a specific placeholder text.
|
|
133
|
+
* If found, clicks it.
|
|
134
|
+
*
|
|
135
|
+
* @param {string} placeholder - The textfields placeholder text.
|
|
136
|
+
*/
|
|
137
|
+
clickTextfield(placeholder: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Clicks an icon based on a description.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} description
|
|
142
|
+
*/
|
|
143
|
+
clickIcon(description: string): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Wait until an AskUICommand does not fail.
|
|
146
|
+
*
|
|
147
|
+
* Use it to wait for an element to appear like this:
|
|
148
|
+
*
|
|
149
|
+
* await waitUntil(
|
|
150
|
+
* aui.expect().text('Github').exists()
|
|
151
|
+
* );
|
|
152
|
+
*
|
|
153
|
+
* @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
|
|
154
|
+
* @param {number} maxTry - Number of maximum retries
|
|
155
|
+
* @param {number} waitTime - Time in milliseconds
|
|
156
|
+
*/
|
|
157
|
+
waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
|
|
93
158
|
}
|
|
@@ -217,5 +217,122 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
217
217
|
},
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Press a key multiple times. At least two times.
|
|
222
|
+
*
|
|
223
|
+
* @param {PC_AND_MODIFIER_KEY} key
|
|
224
|
+
*
|
|
225
|
+
* @param {number} times
|
|
226
|
+
*/
|
|
227
|
+
pressKeyNTimes(key, times = 2) {
|
|
228
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
229
|
+
/* eslint-disable no-await-in-loop */
|
|
230
|
+
for (let i = 0; i < times; i += 1) {
|
|
231
|
+
yield this.pressKey(key).exec();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Press an array of keys one after another.
|
|
237
|
+
*
|
|
238
|
+
* For example press the following keys: right, left, enter.
|
|
239
|
+
*
|
|
240
|
+
* pressKeys(['right', 'left', 'enter'])
|
|
241
|
+
*
|
|
242
|
+
* @param {PC_AND_MODIFIER_KEY[]} keys
|
|
243
|
+
*/
|
|
244
|
+
pressKeys(keys) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
/* eslint-disable no-await-in-loop */
|
|
247
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
248
|
+
yield this.pressKey(keys[i]).exec();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Searches for a text element and clicks it when found.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} text - A text to be searched.
|
|
256
|
+
*/
|
|
257
|
+
clickText(text) {
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
yield this.click().text(text).exec();
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Searches for text elements and clicks them
|
|
264
|
+
* one after another when found.
|
|
265
|
+
*
|
|
266
|
+
* @param {string[]} texts - An array of texts to be searched.
|
|
267
|
+
*/
|
|
268
|
+
clickTexts(texts) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
/* eslint-disable no-await-in-loop */
|
|
271
|
+
for (let i = 0; i < texts.length; i += 1) {
|
|
272
|
+
yield this.click().text(texts[i]).exec();
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Searches for an element of type button
|
|
278
|
+
* with a label and clicks it when found.
|
|
279
|
+
*
|
|
280
|
+
* @param {string} label - The buttons label.
|
|
281
|
+
*/
|
|
282
|
+
clickButton(label) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
yield this.click().button().withText(label).exec();
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Searches for an element of type textfield with a specific placeholder text.
|
|
289
|
+
* If found, clicks it.
|
|
290
|
+
*
|
|
291
|
+
* @param {string} placeholder - The textfields placeholder text.
|
|
292
|
+
*/
|
|
293
|
+
clickTextfield(placeholder) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
yield this.click().textfield().contains().text()
|
|
296
|
+
.withText(placeholder)
|
|
297
|
+
.exec();
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Clicks an icon based on a description.
|
|
302
|
+
*
|
|
303
|
+
* @param {string} description
|
|
304
|
+
*/
|
|
305
|
+
clickIcon(description) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
yield this.click().icon().matching(description).exec();
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Wait until an AskUICommand does not fail.
|
|
312
|
+
*
|
|
313
|
+
* Use it to wait for an element to appear like this:
|
|
314
|
+
*
|
|
315
|
+
* await waitUntil(
|
|
316
|
+
* aui.expect().text('Github').exists()
|
|
317
|
+
* );
|
|
318
|
+
*
|
|
319
|
+
* @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
|
|
320
|
+
* @param {number} maxTry - Number of maximum retries
|
|
321
|
+
* @param {number} waitTime - Time in milliseconds
|
|
322
|
+
*/
|
|
323
|
+
waitUntil(AskUICommand, maxTry = 5, waitTime = 2000) {
|
|
324
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
try {
|
|
326
|
+
yield AskUICommand.exec();
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (maxTry === 0) {
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
yield this.waitFor(waitTime).exec();
|
|
333
|
+
yield this.waitUntil(AskUICommand, maxTry - 1);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
220
337
|
}
|
|
221
338
|
exports.UiControlClient = UiControlClient;
|
|
@@ -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: '
|
|
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) =>
|
|
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'
|
|
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
|
|
50
|
-
default:
|
|
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: ['
|
|
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: '-
|
|
59
|
+
option: '-sc, --skip-credentials',
|
|
61
60
|
choices: [],
|
|
62
|
-
description: '
|
|
61
|
+
description: 'skip the credentials setup.',
|
|
62
|
+
default: false,
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
option: '-
|
|
65
|
+
option: '-w, --workspace-id <value>',
|
|
66
66
|
choices: [],
|
|
67
|
-
description: '
|
|
67
|
+
description: 'a workspace id.',
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
option: '-
|
|
71
|
-
choices: [
|
|
72
|
-
description: '
|
|
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
|
|
76
|
-
choices: [
|
|
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
|
-
|
|
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('[
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
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;
|
|
20
|
-
private
|
|
18
|
+
private static installTestFrameworkPackages;
|
|
19
|
+
private addUserCredentials;
|
|
21
20
|
private copyESLintConfigFiles;
|
|
22
21
|
private copyTsConfigFile;
|
|
23
|
-
private installProxy;
|
|
24
|
-
private normalizeCliOptions;
|
|
25
22
|
createExampleProject(): Promise<void>;
|
|
26
23
|
}
|