@intuned/runtime-dev 0.1.0-test.10 → 0.1.0-test.12
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/.babelrc +1 -2
- package/dist/commands/api/run.js +170 -105
- package/dist/commands/api/run.ts +105 -0
- package/dist/commands/auth-sessions/load.js +26 -28
- package/dist/commands/auth-sessions/load.ts +30 -0
- package/dist/commands/auth-sessions/run-check.js +53 -52
- package/dist/commands/auth-sessions/run-check.ts +51 -0
- package/dist/commands/auth-sessions/run-create.js +96 -91
- package/dist/commands/auth-sessions/run-create.ts +91 -0
- package/dist/commands/browser/save-state.js +16 -14
- package/dist/commands/browser/save-state.ts +14 -0
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/browser/start-browser.ts +11 -0
- package/dist/commands/build.js +108 -75
- package/dist/commands/build.ts +78 -0
- package/dist/commands/common/browserUtils.js +51 -53
- package/dist/commands/common/browserUtils.ts +45 -0
- package/dist/commands/common/getDefaultExportFromFile.js +12 -17
- package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
- package/dist/commands/common/getFirstLineNumber.ts +96 -0
- package/dist/commands/common/sendMessageToClient.js +4 -9
- package/dist/commands/common/sendMessageToClient.ts +3 -0
- package/dist/commands/common/utils/fileUtils.js +22 -32
- package/dist/commands/common/utils/fileUtils.ts +23 -0
- package/dist/commands/common/utils/settings.js +19 -27
- package/dist/commands/common/utils/settings.ts +22 -0
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/unixSocket.ts +38 -0
- package/dist/commands/common/utils/webTemplate.js +27 -29
- package/dist/commands/common/utils/webTemplate.ts +22 -0
- package/dist/commands/interface/run.js +151 -150
- package/dist/commands/interface/run.ts +156 -0
- package/dist/commands/ts-check.js +49 -49
- package/dist/commands/ts-check.ts +50 -0
- package/dist/common/Logger/Logger/index.d.ts +1 -1
- package/dist/common/Logger/Logger/index.js +42 -55
- package/dist/common/Logger/Logger/index.ts +53 -0
- package/dist/common/Logger/Logger/types.js +1 -5
- package/dist/common/Logger/Logger/types.ts +1 -0
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.js +42 -55
- package/dist/common/Logger/index.ts +53 -0
- package/dist/common/Logger/types.js +1 -5
- package/dist/common/Logger/types.ts +1 -0
- package/dist/common/asyncLocalStorage/index.js +8 -16
- package/dist/common/asyncLocalStorage/index.ts +9 -0
- package/dist/common/cleanEnvironmentVariables.js +12 -16
- package/dist/common/cleanEnvironmentVariables.ts +10 -0
- package/dist/common/constants.js +1 -7
- package/dist/common/constants.ts +1 -0
- package/dist/common/contextStorageStateHelpers.js +38 -47
- package/dist/common/contextStorageStateHelpers.ts +43 -0
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +196 -177
- package/dist/common/getPlaywrightConstructs.ts +181 -0
- package/dist/common/jwtTokenManager.js +79 -76
- package/dist/common/jwtTokenManager.ts +71 -0
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +150 -159
- package/dist/common/runApi/errors.ts +154 -0
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +220 -269
- package/dist/common/runApi/index.ts +253 -0
- package/dist/common/runApi/types.d.ts +1 -1
- package/dist/common/runApi/types.js +56 -49
- package/dist/common/runApi/types.ts +43 -0
- package/dist/common/settingsSchema.js +10 -15
- package/dist/common/settingsSchema.ts +9 -0
- package/dist/common/telemetry.js +30 -28
- package/dist/common/telemetry.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -69
- package/dist/index.ts +4 -0
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/RunError.js +11 -18
- package/dist/runtime/RunError.ts +12 -0
- package/dist/runtime/downloadDirectory.js +13 -19
- package/dist/runtime/downloadDirectory.ts +13 -0
- package/dist/runtime/enums.d.ts +1 -11
- package/dist/runtime/enums.js +12 -18
- package/dist/runtime/enums.ts +12 -0
- package/dist/runtime/executionHelpers.test.ts +51 -0
- package/dist/runtime/export.d.ts +1 -202
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +15 -21
- package/dist/runtime/extendPayload.ts +15 -0
- package/dist/runtime/extendTimeout.js +21 -28
- package/dist/runtime/extendTimeout.ts +24 -0
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -53
- package/dist/runtime/index.ts +6 -0
- package/dist/runtime/requestMoreInfo.js +16 -23
- package/dist/runtime/requestMoreInfo.ts +18 -0
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +14 -21
- package/dist/runtime/runInfo.ts +15 -0
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/executionHelpers.test.js +0 -53
- package/dist/runtime/export.d.js +0 -5
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Argument, program } from "commander";
|
|
3
|
+
import * as fs from "fs-extra";
|
|
4
|
+
import { getFullPathInProject } from "../common/utils/fileUtils";
|
|
5
|
+
import { getSettings } from "../common/utils/settings";
|
|
6
|
+
import dotenv from "dotenv";
|
|
7
|
+
import { AUTH_SESSIONS_FOLDER_NAME } from "../../common/constants";
|
|
8
|
+
import { runApi } from "../../common/runApi";
|
|
9
|
+
dotenv.config({
|
|
10
|
+
path: `.env`
|
|
11
|
+
});
|
|
12
|
+
program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").allowUnknownOption().addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
13
|
+
cdpAddress,
|
|
14
|
+
authSessionPath
|
|
15
|
+
}) => {
|
|
16
|
+
const setting = await getSettings();
|
|
17
|
+
if (!setting.authSessions.enabled) {
|
|
18
|
+
throw new Error("auth session is not enabled");
|
|
19
|
+
}
|
|
20
|
+
const checkFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
21
|
+
if (!fs.exists(checkFilePath)) {
|
|
22
|
+
throw new Error("auth session check file not found");
|
|
23
|
+
}
|
|
24
|
+
const runApiResult = await runApi({
|
|
25
|
+
automationFunction: {
|
|
26
|
+
name: `${AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
27
|
+
},
|
|
28
|
+
runOptions: {
|
|
29
|
+
environment: "ide",
|
|
30
|
+
mode,
|
|
31
|
+
cdpAddress
|
|
32
|
+
},
|
|
33
|
+
auth: {
|
|
34
|
+
session: {
|
|
35
|
+
type: "file",
|
|
36
|
+
path: authSessionPath
|
|
37
|
+
},
|
|
38
|
+
runCheck: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (runApiResult.isErr()) {
|
|
42
|
+
throw new Error(runApiResult.error);
|
|
43
|
+
}
|
|
44
|
+
const result = runApiResult.value.result;
|
|
45
|
+
console.log("check result", result);
|
|
46
|
+
if (!result) {
|
|
47
|
+
throw new Error("auth session check failed");
|
|
48
|
+
}
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
program.parse(process.argv);
|
|
@@ -1,96 +1,101 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
_dotenv.default.config({
|
|
19
|
-
path: `.env`
|
|
2
|
+
import { Argument, program } from "commander";
|
|
3
|
+
import * as fs from "fs-extra";
|
|
4
|
+
import { prompt } from "promptly";
|
|
5
|
+
import { getFullPathInProject } from "../common/utils/fileUtils";
|
|
6
|
+
import { getSettings } from "../common/utils/settings";
|
|
7
|
+
import dotenv from "dotenv";
|
|
8
|
+
import { AUTH_SESSIONS_FOLDER_NAME } from "../../common/constants";
|
|
9
|
+
import { runApiGenerator } from "../../common/runApi";
|
|
10
|
+
import { runWithContext } from "../../common/asyncLocalStorage";
|
|
11
|
+
import { nanoid } from "nanoid";
|
|
12
|
+
import { RunEnvironment } from "../../runtime/enums";
|
|
13
|
+
dotenv.config({
|
|
14
|
+
path: `.env`,
|
|
20
15
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(value.error);
|
|
65
|
-
throw new Error(value.error);
|
|
66
|
-
}
|
|
67
|
-
const fullState = value.value.session;
|
|
68
|
-
if (pathToSave) {
|
|
69
|
-
const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
|
|
70
|
-
fs.ensureFileSync(fullPath);
|
|
71
|
-
await fs.writeJSON(fullPath, fullState);
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
|
|
76
|
-
nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
|
|
77
|
-
validator: input => {
|
|
78
|
-
if (!value.choices.includes(input)) {
|
|
79
|
-
throw new Error("Please type on of the allowed choices");
|
|
80
|
-
}
|
|
81
|
-
return input;
|
|
82
|
-
}
|
|
16
|
+
program
|
|
17
|
+
.description("run auth session create")
|
|
18
|
+
.option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222")
|
|
19
|
+
.option("-i, --input [file]", "input json file")
|
|
20
|
+
.option("-j, --json [json]", "input json string")
|
|
21
|
+
.option("--authSessionPath <authSession>", "auth session to use when executing the api")
|
|
22
|
+
.option("--pathToSave <pathToSave>", "path to save the auth session, if not provided, will discard the auth session")
|
|
23
|
+
.allowUnknownOption()
|
|
24
|
+
.addArgument(new Argument("<mode>", "mode of execution")
|
|
25
|
+
.choices(["vanilla", "playwright", "playwright-standalone"])
|
|
26
|
+
.default("playwright-standalone")
|
|
27
|
+
.argOptional())
|
|
28
|
+
.action(async (mode, { cdpAddress, pathToSave, input, json, }) => {
|
|
29
|
+
let inputData = null;
|
|
30
|
+
if (input) {
|
|
31
|
+
inputData = await fs.readJSON(input);
|
|
32
|
+
}
|
|
33
|
+
else if (json) {
|
|
34
|
+
inputData = JSON.parse(json);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
inputData = {};
|
|
38
|
+
}
|
|
39
|
+
const setting = await getSettings();
|
|
40
|
+
if (!setting.authSessions.enabled) {
|
|
41
|
+
throw new Error("auth sessions feature is not enabled");
|
|
42
|
+
}
|
|
43
|
+
const createFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "create.ts");
|
|
44
|
+
if (!fs.exists(createFilePath)) {
|
|
45
|
+
throw new Error("auth session create file not found");
|
|
46
|
+
}
|
|
47
|
+
async function runCreate() {
|
|
48
|
+
const generator = runApiGenerator({
|
|
49
|
+
automationFunction: {
|
|
50
|
+
name: "auth-sessions/create",
|
|
51
|
+
params: inputData ?? {},
|
|
52
|
+
},
|
|
53
|
+
runOptions: {
|
|
54
|
+
environment: "ide",
|
|
55
|
+
mode,
|
|
56
|
+
cdpAddress,
|
|
57
|
+
},
|
|
58
|
+
retrieveSession: true,
|
|
83
59
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
60
|
+
let nextGeneratorParam = undefined;
|
|
61
|
+
// eslint-disable-next-line no-constant-condition
|
|
62
|
+
while (true) {
|
|
63
|
+
const { value, done } = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
|
|
64
|
+
if (done) {
|
|
65
|
+
if (value.isErr()) {
|
|
66
|
+
console.log(value.error);
|
|
67
|
+
throw new Error(value.error);
|
|
68
|
+
}
|
|
69
|
+
const fullState = value.value.session;
|
|
70
|
+
if (pathToSave) {
|
|
71
|
+
const fullPath = getFullPathInProject(pathToSave);
|
|
72
|
+
fs.ensureFileSync(fullPath);
|
|
73
|
+
await fs.writeJSON(fullPath, fullState);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (value.action === "request_more_info" &&
|
|
78
|
+
value.requestType == "multiple_choice") {
|
|
79
|
+
nextGeneratorParam = await prompt(value.messageToUser + `, choices: ${value.choices}`, {
|
|
80
|
+
validator: (input) => {
|
|
81
|
+
if (!value.choices.includes(input)) {
|
|
82
|
+
throw new Error("Please type on of the allowed choices");
|
|
83
|
+
}
|
|
84
|
+
return input;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (value.action === "request_more_info" &&
|
|
89
|
+
value.requestType == "otp") {
|
|
90
|
+
nextGeneratorParam = await prompt(value.messageToUser, {});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
87
93
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
process.exit(0);
|
|
94
|
+
await runWithContext({
|
|
95
|
+
runEnvironment: RunEnvironment.IDE,
|
|
96
|
+
extendedPayloads: [],
|
|
97
|
+
runId: nanoid(),
|
|
98
|
+
}, runCreate);
|
|
99
|
+
process.exit(0);
|
|
95
100
|
});
|
|
96
|
-
|
|
101
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Argument, program } from "commander";
|
|
3
|
+
import * as fs from "fs-extra";
|
|
4
|
+
import { prompt } from "promptly";
|
|
5
|
+
import { getFullPathInProject } from "../common/utils/fileUtils";
|
|
6
|
+
import { getSettings } from "../common/utils/settings";
|
|
7
|
+
import dotenv from "dotenv";
|
|
8
|
+
import { AUTH_SESSIONS_FOLDER_NAME } from "../../common/constants";
|
|
9
|
+
import { runApiGenerator } from "../../common/runApi";
|
|
10
|
+
import { runWithContext } from "../../common/asyncLocalStorage";
|
|
11
|
+
import { nanoid } from "nanoid";
|
|
12
|
+
import { RunEnvironment } from "../../runtime/enums";
|
|
13
|
+
dotenv.config({
|
|
14
|
+
path: `.env`
|
|
15
|
+
});
|
|
16
|
+
program.description("run auth session create").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--pathToSave <pathToSave>", "path to save the auth session, if not provided, will discard the auth session").allowUnknownOption().addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
17
|
+
cdpAddress,
|
|
18
|
+
pathToSave,
|
|
19
|
+
input,
|
|
20
|
+
json
|
|
21
|
+
}) => {
|
|
22
|
+
let inputData = null;
|
|
23
|
+
if (input) {
|
|
24
|
+
inputData = await fs.readJSON(input);
|
|
25
|
+
} else if (json) {
|
|
26
|
+
inputData = JSON.parse(json);
|
|
27
|
+
} else {
|
|
28
|
+
inputData = {};
|
|
29
|
+
}
|
|
30
|
+
const setting = await getSettings();
|
|
31
|
+
if (!setting.authSessions.enabled) {
|
|
32
|
+
throw new Error("auth sessions feature is not enabled");
|
|
33
|
+
}
|
|
34
|
+
const createFilePath = getFullPathInProject(AUTH_SESSIONS_FOLDER_NAME, "create.ts");
|
|
35
|
+
if (!fs.exists(createFilePath)) {
|
|
36
|
+
throw new Error("auth session create file not found");
|
|
37
|
+
}
|
|
38
|
+
async function runCreate() {
|
|
39
|
+
const generator = runApiGenerator({
|
|
40
|
+
automationFunction: {
|
|
41
|
+
name: "auth-sessions/create",
|
|
42
|
+
params: inputData ?? {}
|
|
43
|
+
},
|
|
44
|
+
runOptions: {
|
|
45
|
+
environment: "ide",
|
|
46
|
+
mode,
|
|
47
|
+
cdpAddress
|
|
48
|
+
},
|
|
49
|
+
retrieveSession: true
|
|
50
|
+
});
|
|
51
|
+
let nextGeneratorParam = undefined;
|
|
52
|
+
while (true) {
|
|
53
|
+
const {
|
|
54
|
+
value,
|
|
55
|
+
done
|
|
56
|
+
} = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
|
|
57
|
+
if (done) {
|
|
58
|
+
if (value.isErr()) {
|
|
59
|
+
console.log(value.error);
|
|
60
|
+
throw new Error(value.error);
|
|
61
|
+
}
|
|
62
|
+
const fullState = value.value.session;
|
|
63
|
+
if (pathToSave) {
|
|
64
|
+
const fullPath = getFullPathInProject(pathToSave);
|
|
65
|
+
fs.ensureFileSync(fullPath);
|
|
66
|
+
await fs.writeJSON(fullPath, fullState);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
|
|
71
|
+
nextGeneratorParam = await prompt(value.messageToUser + `, choices: ${value.choices}`, {
|
|
72
|
+
validator: input => {
|
|
73
|
+
if (!value.choices.includes(input)) {
|
|
74
|
+
throw new Error("Please type on of the allowed choices");
|
|
75
|
+
}
|
|
76
|
+
return input;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
} else if (value.action === "request_more_info" && value.requestType == "otp") {
|
|
80
|
+
nextGeneratorParam = await prompt(value.messageToUser, {});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await runWithContext({
|
|
85
|
+
runEnvironment: RunEnvironment.IDE,
|
|
86
|
+
extendedPayloads: [],
|
|
87
|
+
runId: nanoid()
|
|
88
|
+
}, runCreate);
|
|
89
|
+
process.exit(0);
|
|
90
|
+
});
|
|
91
|
+
program.parse(process.argv);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
_dotenv.default.config({
|
|
9
|
-
path: `.env`
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { saveSessionFromOpenedBrowser } from "../common/browserUtils";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: `.env`,
|
|
10
7
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
program
|
|
9
|
+
.description("save browser state to file storage.json")
|
|
10
|
+
.option("-p, --path [file]", "path for file", "./localSessions/default.json")
|
|
11
|
+
.allowUnknownOption()
|
|
12
|
+
.action(async ({ path }) => {
|
|
13
|
+
await saveSessionFromOpenedBrowser(path);
|
|
14
|
+
// playwright keeps an open handle to the connected browser and it stops the process from exiting
|
|
15
|
+
// there is no way to close the connection gracefully without destroying the context/browser
|
|
16
|
+
// https://github.com/microsoft/playwright/issues/4956
|
|
17
|
+
process.exit(0);
|
|
16
18
|
});
|
|
17
|
-
|
|
19
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { saveSessionFromOpenedBrowser } from "../common/browserUtils";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: `.env`
|
|
7
|
+
});
|
|
8
|
+
program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
|
|
9
|
+
path
|
|
10
|
+
}) => {
|
|
11
|
+
await saveSessionFromOpenedBrowser(path);
|
|
12
|
+
process.exit(0);
|
|
13
|
+
});
|
|
14
|
+
program.parse(process.argv);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
-
_dotenv.default.config({
|
|
9
|
-
path: `.env`
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { startOrRestartBrowser } from "../common/browserUtils";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: `.env`,
|
|
10
7
|
});
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
program
|
|
9
|
+
.description("start browser testing purposes")
|
|
10
|
+
.allowUnknownOption()
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await startOrRestartBrowser();
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { startOrRestartBrowser } from "../common/browserUtils";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
dotenv.config({
|
|
6
|
+
path: `.env`
|
|
7
|
+
});
|
|
8
|
+
program.description("start browser testing purposes").allowUnknownOption().action(async () => {
|
|
9
|
+
await startOrRestartBrowser();
|
|
10
|
+
});
|
|
11
|
+
program.parse(process.argv);
|
package/dist/commands/build.js
CHANGED
|
@@ -1,81 +1,114 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var path = _interopRequireWildcard(require("path"));
|
|
13
|
-
var _webTemplate = require("./common/utils/webTemplate");
|
|
14
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
15
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
import { program, Argument } from "commander";
|
|
3
|
+
import { rollup } from "rollup";
|
|
4
|
+
import typescript from "@rollup/plugin-typescript";
|
|
5
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
6
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
7
|
+
import dynamicImportVars from "@rollup/plugin-dynamic-import-vars";
|
|
8
|
+
import json from "@rollup/plugin-json";
|
|
9
|
+
import * as fs from "fs-extra";
|
|
10
|
+
import * as path from "path";
|
|
11
|
+
import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
|
|
18
12
|
function isThirdPartyWarning(warning) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
if (warning.id && /node_modules/.test(warning.id))
|
|
14
|
+
return true;
|
|
15
|
+
if (warning.ids && warning.ids.every((id) => /node_modules/.test(id)))
|
|
16
|
+
return true;
|
|
17
|
+
return false;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
import dotenv from "dotenv";
|
|
20
|
+
dotenv.config();
|
|
21
|
+
program
|
|
22
|
+
.description("build the intuned server")
|
|
23
|
+
.addArgument(new Argument("<mode>", "mode of execution")
|
|
24
|
+
.choices(["vanilla", "playwright"])
|
|
25
|
+
.default("playwright")
|
|
26
|
+
.argOptional())
|
|
27
|
+
.argument("[outfile]", "output bundle", "./output/bundle_v2.js")
|
|
28
|
+
.allowUnknownOption()
|
|
29
|
+
.action(async (mode, outfile) => {
|
|
30
|
+
await moveWebTemplateFiles();
|
|
31
|
+
const currentTemplateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
|
|
32
|
+
await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
33
|
+
await build(outfile, mode);
|
|
29
34
|
});
|
|
30
35
|
async function build(outfile, mode) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
36
|
+
let bundle = null;
|
|
37
|
+
let buildFailed = false;
|
|
38
|
+
try {
|
|
39
|
+
// create a bundle
|
|
40
|
+
bundle = await rollup({
|
|
41
|
+
input: `./intuned/WebTemplate/index.${mode}.ts`,
|
|
42
|
+
output: {
|
|
43
|
+
globals: { crypto: "crypto" },
|
|
44
|
+
},
|
|
45
|
+
plugins: [
|
|
46
|
+
json(),
|
|
47
|
+
nodeResolve({ exportConditions: ["node"], preferBuiltins: true }),
|
|
48
|
+
typescript({ tsconfig: "./intuned/WebTemplate/tsconfig.json" }),
|
|
49
|
+
commonjs({
|
|
50
|
+
include: [
|
|
51
|
+
"node_modules/**",
|
|
52
|
+
"intuned/WebTemplate/**",
|
|
53
|
+
"dist",
|
|
54
|
+
"../typescript-sdk/**",
|
|
55
|
+
"../typescript-runtime/**",
|
|
56
|
+
],
|
|
57
|
+
extensions: [".js"],
|
|
58
|
+
ignoreGlobal: false,
|
|
59
|
+
sourceMap: false,
|
|
60
|
+
dynamicRequireTargets: [
|
|
61
|
+
// "api/**/*.ts",
|
|
62
|
+
// "auth-sessions/**/*.ts",
|
|
63
|
+
"api/**/*.js",
|
|
64
|
+
"auth-sessions/**/*.js",
|
|
65
|
+
],
|
|
66
|
+
requireReturnsDefault: "auto",
|
|
67
|
+
transformMixedEsModules: true,
|
|
68
|
+
}),
|
|
69
|
+
dynamicImportVars({
|
|
70
|
+
include: ["**/*.js", "**/*.ts"],
|
|
71
|
+
exclude: ["**/*.d.ts", "**/*.js.map"],
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
onwarn: (warning, warn) => {
|
|
75
|
+
if (isThirdPartyWarning(warning))
|
|
76
|
+
return;
|
|
77
|
+
warn(warning);
|
|
78
|
+
},
|
|
79
|
+
external: [
|
|
80
|
+
"@intuned/playwright",
|
|
81
|
+
"@intuned/playwright-core",
|
|
82
|
+
"@intuned/runtime",
|
|
83
|
+
"jsdom",
|
|
84
|
+
"canvas",
|
|
85
|
+
"pdfjs-dist",
|
|
86
|
+
"pdf-to-png-converter",
|
|
87
|
+
"crypto",
|
|
88
|
+
"applicationinsights",
|
|
89
|
+
"fingerprint-generator",
|
|
90
|
+
"fingerprint-injector",
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
console.log(`📦 Building ${outfile}`);
|
|
94
|
+
const outfileFolder = path.dirname(outfile);
|
|
95
|
+
// copy assets to outfile folder
|
|
96
|
+
const assetsDir = path.resolve(__dirname, "..", "common", "assets");
|
|
97
|
+
await fs.copy(assetsDir, `${outfileFolder}/assets`);
|
|
98
|
+
await bundle.write({
|
|
99
|
+
format: "cjs",
|
|
100
|
+
file: outfile,
|
|
101
|
+
inlineDynamicImports: true,
|
|
102
|
+
});
|
|
103
|
+
console.log(`✨ Build succeeded: ${outfile}`);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
buildFailed = true;
|
|
107
|
+
console.error("error", error);
|
|
108
|
+
}
|
|
109
|
+
if (buildFailed) {
|
|
110
|
+
console.error("build failed");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
80
113
|
}
|
|
81
|
-
|
|
114
|
+
program.parse(process.argv);
|