@thinkwise/testwise 0.1.63 → 0.1.66
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 +39 -0
- package/components/grid/Grid.ts +23 -0
- package/components/grid/GridObjects.ts +3 -1
- package/config.json +9 -9
- package/dist/components/grid/Grid.d.ts +19 -0
- package/dist/components/grid/Grid.js +21 -0
- package/dist/components/grid/Grid.js.map +1 -1
- package/dist/components/grid/GridObjects.d.ts +1 -0
- package/dist/components/grid/GridObjects.js +2 -1
- package/dist/components/grid/GridObjects.js.map +1 -1
- package/dist/package-lock.json +223 -254
- package/dist/package.json +4 -3
- package/dist/scripts/tsconfig.template.json +12 -0
- package/dist/services/ConfigBuilder.js +4 -3
- package/dist/services/ConfigBuilder.js.map +1 -1
- package/package.json +58 -57
- package/promptCredentials.js +124 -124
- package/scripts/Testwise.template.json +24 -24
- package/scripts/main.js +11 -0
- package/scripts/setup.js +34 -0
- package/scripts/tsconfig.template.json +12 -0
- package/services/ConfigBuilder.ts +4 -3
- package/tsconfig.json +19 -19
- package/scripts/add-config.js +0 -23
package/dist/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thinkwise/testwise",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.65",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"testwise": "./scripts/
|
|
7
|
+
"testwise": "./scripts/main.js",
|
|
8
8
|
"testwise-credentials": "./promptCredentials.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"prompts": "^2.4.2"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@playwright/test": "^1.52.0"
|
|
28
|
+
"@playwright/test": "^1.52.0",
|
|
29
|
+
"typescript": "^5.8.3"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@biomejs/biome": "^2.1.2",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2016",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"typeRoots": ["./node_modules/@types", "./types"],
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -3,11 +3,12 @@ import path from 'node:path';
|
|
|
3
3
|
import dotenv from 'dotenv';
|
|
4
4
|
class ConfigBuilder {
|
|
5
5
|
constructor() {
|
|
6
|
-
const
|
|
6
|
+
const baseDir = process.env.INIT_CWD || process.cwd();
|
|
7
|
+
const configFilePath = path.resolve(baseDir, 'Testwise.json');
|
|
7
8
|
// Find all env files in the consuming project and apply them to process.env
|
|
8
|
-
const envFiles = fs.readdirSync(
|
|
9
|
+
const envFiles = fs.readdirSync(baseDir).filter((file) => file.endsWith('.env'));
|
|
9
10
|
for (const envFile of envFiles) {
|
|
10
|
-
const envConfig = dotenv.parse(fs.readFileSync(path.resolve(
|
|
11
|
+
const envConfig = dotenv.parse(fs.readFileSync(path.resolve(baseDir, envFile)));
|
|
11
12
|
Object.assign(process.env, envConfig);
|
|
12
13
|
}
|
|
13
14
|
if (!fs.existsSync(configFilePath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigBuilder.js","sourceRoot":"","sources":["../../services/ConfigBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,aAAa;IAGjB;QACE,MAAM,
|
|
1
|
+
{"version":3,"file":"ConfigBuilder.js","sourceRoot":"","sources":["../../services/ConfigBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,aAAa;IAGjB;QACE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACtD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAE9D,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAChF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,kCAAkC,cAAc,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAI,GAAW;QACvB,MAAM,MAAM,GAAG,GAAG;aACf,KAAK,CAAC,GAAG,CAAC;aACV,MAAM,CACL,CAAC,GAAwC,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAA4B,EAChG,IAAI,CAAC,MAAM,CACP,CAAC;QAET,+GAA+G;QAC/G,IAAI,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QAE9B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAY,CAAC;YAChD,oEAAoE;YACpE,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAkB,CAAM,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,QAAa,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,IAAI,QAAQ,GAAyB,IAAI,CAAC;AAE1C,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@thinkwise/testwise",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"testwise": "./scripts/
|
|
8
|
-
"testwise-credentials": "./promptCredentials.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
|
12
|
-
"format:fix": "run-s \"lint --fix\" && biome check --fix --unsafe",
|
|
13
|
-
"format:check": "run-s \"lint \" && biome check"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [],
|
|
16
|
-
"author": "",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"description": "",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"@types/node": "^22.15.29",
|
|
21
|
-
"axios": "^1.9.0",
|
|
22
|
-
"chalk": "^5.4.1",
|
|
23
|
-
"csv-parse": "^5.6.0",
|
|
24
|
-
"dotenv": "^17.2.2",
|
|
25
|
-
"prompts": "^2.4.2"
|
|
26
|
-
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"@playwright/test": "^1.52.0"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"eslint
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"page-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@thinkwise/testwise",
|
|
3
|
+
"version": "0.1.66",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"testwise": "./scripts/main.js",
|
|
8
|
+
"testwise-credentials": "./promptCredentials.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
|
12
|
+
"format:fix": "run-s \"lint --fix\" && biome check --fix --unsafe",
|
|
13
|
+
"format:check": "run-s \"lint \" && biome check"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"description": "",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@types/node": "^22.15.29",
|
|
21
|
+
"axios": "^1.9.0",
|
|
22
|
+
"chalk": "^5.4.1",
|
|
23
|
+
"csv-parse": "^5.6.0",
|
|
24
|
+
"dotenv": "^17.2.2",
|
|
25
|
+
"prompts": "^2.4.2"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@playwright/test": "^1.52.0",
|
|
29
|
+
"typescript": "^5.8.3"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@biomejs/biome": "^2.1.2",
|
|
33
|
+
"@eslint/js": "^9.28.0",
|
|
34
|
+
"@playwright/test": "^1.52.0",
|
|
35
|
+
"eslint": "^9.28.0",
|
|
36
|
+
"eslint-plugin-playwright": "^2.2.0",
|
|
37
|
+
"npm-run-all": "^4.1.5",
|
|
38
|
+
"typescript-eslint": "^8.34.0"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist/",
|
|
42
|
+
"scripts/",
|
|
43
|
+
"components/",
|
|
44
|
+
"services/",
|
|
45
|
+
"controls/",
|
|
46
|
+
"helpers/",
|
|
47
|
+
"page-extensions/",
|
|
48
|
+
"page-overrides/",
|
|
49
|
+
"index.ts",
|
|
50
|
+
"Testwise.ts",
|
|
51
|
+
"types/",
|
|
52
|
+
"enums/",
|
|
53
|
+
"tsconfig.json",
|
|
54
|
+
"example-code/",
|
|
55
|
+
"interfaces/",
|
|
56
|
+
"**/config.json"
|
|
57
|
+
]
|
|
58
|
+
}
|
package/promptCredentials.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import prompts from 'prompts';
|
|
7
|
-
|
|
8
|
-
const packageScripts = JSON.parse(readFileSync('./package.json')).scripts;
|
|
9
|
-
|
|
10
|
-
function exitWithError(error) {
|
|
11
|
-
console.log(chalk.red(error));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function startTestSolution() {
|
|
16
|
-
console.log('Now starting test solution...');
|
|
17
|
-
spawnSync(`yarn --cwd ../ ${args.join(' ')}`, {
|
|
18
|
-
shell: true,
|
|
19
|
-
stdio: 'inherit'
|
|
20
|
-
});
|
|
21
|
-
process.exit();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const args = process.argv.slice(2);
|
|
25
|
-
|
|
26
|
-
if (!args.length) {
|
|
27
|
-
exitWithError('Error: Got too few parameters. Usage: yarn test:credentials test');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const yarnScriptToExec = args[0];
|
|
31
|
-
|
|
32
|
-
if (!packageScripts[yarnScriptToExec]) {
|
|
33
|
-
exitWithError(`Error: Given script "${yarnScriptToExec}" doesn't exist in package.json.`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// INCOMING HACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
-
// temp fix to be reworked when converting this file to TS
|
|
38
|
-
import fs from 'node:fs';
|
|
39
|
-
import path from 'node:path';
|
|
40
|
-
|
|
41
|
-
const indiciumURL = (() => {
|
|
42
|
-
try {
|
|
43
|
-
const configPath = path.resolve(process.cwd(), './Testwise.json');
|
|
44
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
45
|
-
return config.environmentSettings?.serviceUrl || '';
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error('Error reading Testwise.json:', error);
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
})();
|
|
51
|
-
|
|
52
|
-
// END OF HACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
53
|
-
|
|
54
|
-
if (process.env.SF_TEST_USERNAME && process.env.SF_TEST_PASSWORD) {
|
|
55
|
-
console.log('Using SF_TEST_USERNAME and SF_TEST_PASSWORD environment variables.');
|
|
56
|
-
startTestSolution();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const questions = [
|
|
60
|
-
{
|
|
61
|
-
type: 'text',
|
|
62
|
-
name: 'username',
|
|
63
|
-
message: 'Username:',
|
|
64
|
-
validate: (value) => {
|
|
65
|
-
if (!value?.length) {
|
|
66
|
-
return 'Username is required';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (value.toLowerCase() === 'demo') {
|
|
70
|
-
return 'Running tests locally with demo is forbidden as it results in dataset concurrency problems';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
type: 'invisible',
|
|
78
|
-
name: 'password',
|
|
79
|
-
message: 'Password:',
|
|
80
|
-
validate: (value) => (!value?.length ? 'Password is required' : true)
|
|
81
|
-
}
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
(async () => {
|
|
85
|
-
const credentialsResponse = await prompts(questions);
|
|
86
|
-
|
|
87
|
-
if (!credentialsResponse || !credentialsResponse.username || !credentialsResponse.password) {
|
|
88
|
-
exitWithError('Username or password was not given');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const { password, username } = credentialsResponse;
|
|
92
|
-
const params = new URLSearchParams();
|
|
93
|
-
|
|
94
|
-
params.append('UserName', username);
|
|
95
|
-
params.append('Password', password);
|
|
96
|
-
|
|
97
|
-
const fetch = (await import('node-fetch')).default;
|
|
98
|
-
const authResponse = await fetch(`${indiciumURL}/account/api/login`, {
|
|
99
|
-
method: 'POST',
|
|
100
|
-
body: params
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
if (authResponse.status === 204) {
|
|
104
|
-
console.log('Confirmed credentials work @', indiciumURL);
|
|
105
|
-
} else {
|
|
106
|
-
const confirmResponse = await prompts([
|
|
107
|
-
{
|
|
108
|
-
type: 'confirm',
|
|
109
|
-
name: 'value',
|
|
110
|
-
message: `Can't login to ${indiciumURL} with the given credentials. Continue anyways?`,
|
|
111
|
-
initial: true
|
|
112
|
-
}
|
|
113
|
-
]);
|
|
114
|
-
|
|
115
|
-
if (!confirmResponse.value) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
process.env.SF_TEST_USERNAME = username;
|
|
121
|
-
process.env.SF_TEST_PASSWORD = password;
|
|
122
|
-
|
|
123
|
-
startTestSolution();
|
|
124
|
-
})();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import prompts from 'prompts';
|
|
7
|
+
|
|
8
|
+
const packageScripts = JSON.parse(readFileSync('./package.json')).scripts;
|
|
9
|
+
|
|
10
|
+
function exitWithError(error) {
|
|
11
|
+
console.log(chalk.red(error));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function startTestSolution() {
|
|
16
|
+
console.log('Now starting test solution...');
|
|
17
|
+
spawnSync(`yarn --cwd ../ ${args.join(' ')}`, {
|
|
18
|
+
shell: true,
|
|
19
|
+
stdio: 'inherit'
|
|
20
|
+
});
|
|
21
|
+
process.exit();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const args = process.argv.slice(2);
|
|
25
|
+
|
|
26
|
+
if (!args.length) {
|
|
27
|
+
exitWithError('Error: Got too few parameters. Usage: yarn test:credentials test');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const yarnScriptToExec = args[0];
|
|
31
|
+
|
|
32
|
+
if (!packageScripts[yarnScriptToExec]) {
|
|
33
|
+
exitWithError(`Error: Given script "${yarnScriptToExec}" doesn't exist in package.json.`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// INCOMING HACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
37
|
+
// temp fix to be reworked when converting this file to TS
|
|
38
|
+
import fs from 'node:fs';
|
|
39
|
+
import path from 'node:path';
|
|
40
|
+
|
|
41
|
+
const indiciumURL = (() => {
|
|
42
|
+
try {
|
|
43
|
+
const configPath = path.resolve(process.cwd(), './Testwise.json');
|
|
44
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
45
|
+
return config.environmentSettings?.serviceUrl || '';
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Error reading Testwise.json:', error);
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
})();
|
|
51
|
+
|
|
52
|
+
// END OF HACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
53
|
+
|
|
54
|
+
if (process.env.SF_TEST_USERNAME && process.env.SF_TEST_PASSWORD) {
|
|
55
|
+
console.log('Using SF_TEST_USERNAME and SF_TEST_PASSWORD environment variables.');
|
|
56
|
+
startTestSolution();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const questions = [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
name: 'username',
|
|
63
|
+
message: 'Username:',
|
|
64
|
+
validate: (value) => {
|
|
65
|
+
if (!value?.length) {
|
|
66
|
+
return 'Username is required';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (value.toLowerCase() === 'demo') {
|
|
70
|
+
return 'Running tests locally with demo is forbidden as it results in dataset concurrency problems';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'invisible',
|
|
78
|
+
name: 'password',
|
|
79
|
+
message: 'Password:',
|
|
80
|
+
validate: (value) => (!value?.length ? 'Password is required' : true)
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
(async () => {
|
|
85
|
+
const credentialsResponse = await prompts(questions);
|
|
86
|
+
|
|
87
|
+
if (!credentialsResponse || !credentialsResponse.username || !credentialsResponse.password) {
|
|
88
|
+
exitWithError('Username or password was not given');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { password, username } = credentialsResponse;
|
|
92
|
+
const params = new URLSearchParams();
|
|
93
|
+
|
|
94
|
+
params.append('UserName', username);
|
|
95
|
+
params.append('Password', password);
|
|
96
|
+
|
|
97
|
+
const fetch = (await import('node-fetch')).default;
|
|
98
|
+
const authResponse = await fetch(`${indiciumURL}/account/api/login`, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
body: params
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (authResponse.status === 204) {
|
|
104
|
+
console.log('Confirmed credentials work @', indiciumURL);
|
|
105
|
+
} else {
|
|
106
|
+
const confirmResponse = await prompts([
|
|
107
|
+
{
|
|
108
|
+
type: 'confirm',
|
|
109
|
+
name: 'value',
|
|
110
|
+
message: `Can't login to ${indiciumURL} with the given credentials. Continue anyways?`,
|
|
111
|
+
initial: true
|
|
112
|
+
}
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
if (!confirmResponse.value) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
process.env.SF_TEST_USERNAME = username;
|
|
121
|
+
process.env.SF_TEST_PASSWORD = password;
|
|
122
|
+
|
|
123
|
+
startTestSolution();
|
|
124
|
+
})();
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"environmentSettings" :{
|
|
3
|
-
"baseUrl" : "https://develop.example.app",
|
|
4
|
-
"serviceUrl" : "https://develop.example.app/service",
|
|
5
|
-
"metaEndpoint" : "iam"
|
|
6
|
-
},
|
|
7
|
-
"featureSettings" :{
|
|
8
|
-
"logger" : {
|
|
9
|
-
"logDir" : "logs",
|
|
10
|
-
"logLevel" : "info",
|
|
11
|
-
"applyLogLevelToConsoleOutput" : false,
|
|
12
|
-
"logByDay" : true,
|
|
13
|
-
"bufferSizeLimit" : -1
|
|
14
|
-
},
|
|
15
|
-
"InflightRequests" : {
|
|
16
|
-
"waitForRequestsToComplete" : true,
|
|
17
|
-
"waitTimeout" : 5000,
|
|
18
|
-
"continueOnError" : true,
|
|
19
|
-
"paths" : ["/stage", "/layout()", "/context()"]
|
|
20
|
-
},
|
|
21
|
-
"other" : {
|
|
22
|
-
"loginTimeout" : 30000
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"environmentSettings" :{
|
|
3
|
+
"baseUrl" : "https://develop.example.app",
|
|
4
|
+
"serviceUrl" : "https://develop.example.app/service",
|
|
5
|
+
"metaEndpoint" : "iam"
|
|
6
|
+
},
|
|
7
|
+
"featureSettings" :{
|
|
8
|
+
"logger" : {
|
|
9
|
+
"logDir" : "logs",
|
|
10
|
+
"logLevel" : "info",
|
|
11
|
+
"applyLogLevelToConsoleOutput" : false,
|
|
12
|
+
"logByDay" : true,
|
|
13
|
+
"bufferSizeLimit" : -1
|
|
14
|
+
},
|
|
15
|
+
"InflightRequests" : {
|
|
16
|
+
"waitForRequestsToComplete" : true,
|
|
17
|
+
"waitTimeout" : 5000,
|
|
18
|
+
"continueOnError" : true,
|
|
19
|
+
"paths" : ["/stage", "/layout()", "/context()"]
|
|
20
|
+
},
|
|
21
|
+
"other" : {
|
|
22
|
+
"loginTimeout" : 30000
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
25
|
}
|
package/scripts/main.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { setup } from './setup.js';
|
|
4
|
+
|
|
5
|
+
if (process.argv[2] === 'install') {
|
|
6
|
+
setup();
|
|
7
|
+
} else if (process.argv[2] === 'sync') {
|
|
8
|
+
console.log('This feature is coming soon!');
|
|
9
|
+
} else {
|
|
10
|
+
console.warn('Command unknown. Use "install" or "sync".');
|
|
11
|
+
}
|
package/scripts/setup.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
export function setup() {
|
|
11
|
+
try {
|
|
12
|
+
const testwiseConfigFile = path.resolve(process.cwd(), 'Testwise.json');
|
|
13
|
+
const testwiseConfigTemplateFile = path.join(__dirname, 'Testwise.template.json');
|
|
14
|
+
const tsConfigFile = path.resolve(process.cwd(), 'tsconfig.json');
|
|
15
|
+
const tsConfigTemplateFile = path.join(__dirname, 'tsconfig.template.json');
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(testwiseConfigFile)) {
|
|
18
|
+
fs.copyFileSync(testwiseConfigTemplateFile, testwiseConfigFile);
|
|
19
|
+
console.info('Testwise.json config file created.');
|
|
20
|
+
} else {
|
|
21
|
+
console.info('Testwise.json already exists, skipping creation.');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!fs.existsSync(tsConfigFile)) {
|
|
25
|
+
fs.copyFileSync(tsConfigTemplateFile, tsConfigFile);
|
|
26
|
+
console.info('tsconfig.json config file created.');
|
|
27
|
+
} else {
|
|
28
|
+
console.info('tsconfig.json already exists, skipping creation.');
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('Error during installation:', error.message);
|
|
32
|
+
process.exit(1); // Exit with an error code if something goes wrong
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2016",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"typeRoots": ["./node_modules/@types", "./types"],
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -6,13 +6,14 @@ class ConfigBuilder {
|
|
|
6
6
|
private config: Record<string, unknown>;
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
|
-
const
|
|
9
|
+
const baseDir = process.env.INIT_CWD || process.cwd();
|
|
10
|
+
const configFilePath = path.resolve(baseDir, 'Testwise.json');
|
|
10
11
|
|
|
11
12
|
// Find all env files in the consuming project and apply them to process.env
|
|
12
|
-
const envFiles = fs.readdirSync(
|
|
13
|
+
const envFiles = fs.readdirSync(baseDir).filter((file) => file.endsWith('.env'));
|
|
13
14
|
|
|
14
15
|
for (const envFile of envFiles) {
|
|
15
|
-
const envConfig = dotenv.parse(fs.readFileSync(path.resolve(
|
|
16
|
+
const envConfig = dotenv.parse(fs.readFileSync(path.resolve(baseDir, envFile)));
|
|
16
17
|
Object.assign(process.env, envConfig);
|
|
17
18
|
}
|
|
18
19
|
|
package/tsconfig.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "nodenext",
|
|
5
|
-
"moduleResolution": "nodenext",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"outDir": "dist",
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"strict": true
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"**/*.ts",
|
|
17
|
-
"**/*.json"
|
|
18
|
-
],
|
|
19
|
-
"exclude": ["dist", "node_modules"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"moduleResolution": "nodenext",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"strict": true
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"**/*.ts",
|
|
17
|
+
"**/*.json"
|
|
18
|
+
],
|
|
19
|
+
"exclude": ["dist", "node_modules"]
|
|
20
20
|
}
|
package/scripts/add-config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
4
|
-
|
|
5
|
-
import fs from 'node:fs';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
|
|
9
|
-
if (process.argv[2] === 'install') {
|
|
10
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
-
const __dirname = path.dirname(__filename);
|
|
12
|
-
const configFile = path.resolve(process.cwd(), 'Testwise.json');
|
|
13
|
-
const templateFile = path.join(__dirname, 'Testwise.template.json');
|
|
14
|
-
|
|
15
|
-
if (!fs.existsSync(configFile)) {
|
|
16
|
-
fs.copyFileSync(templateFile, configFile);
|
|
17
|
-
console.log('Testwise.json config file created.');
|
|
18
|
-
} else {
|
|
19
|
-
console.log('Testwise.json already exists, skipping creation.');
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
console.log('Unknown or missing command. Usage: npx testwise install');
|
|
23
|
-
}
|