@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16
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/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +14 -12
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +53 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +109 -170
- package/dist/commands/auth-sessions/load.js +28 -26
- package/dist/commands/auth-sessions/run-check.js +54 -53
- package/dist/commands/auth-sessions/run-create.js +93 -96
- package/dist/commands/browser/save-state.js +14 -16
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/build.js +79 -109
- package/dist/commands/common/browserUtils.js +53 -51
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
- package/dist/commands/common/sendMessageToClient.js +9 -4
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +18 -0
- package/dist/commands/common/utils/fileUtils.js +32 -22
- package/dist/commands/common/utils/settings.js +27 -19
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/webTemplate.js +30 -28
- package/dist/commands/interface/run.js +162 -139
- package/dist/commands/ts-check.js +50 -50
- package/dist/common/Logger/Logger/index.js +55 -42
- package/dist/common/Logger/Logger/types.js +5 -1
- package/dist/common/Logger/index.js +55 -42
- package/dist/common/Logger/types.js +5 -1
- package/dist/common/asyncLocalStorage/index.js +16 -8
- package/dist/common/cleanEnvironmentVariables.js +16 -12
- package/dist/common/constants.js +7 -1
- package/dist/common/contextStorageStateHelpers.js +47 -38
- package/dist/common/getPlaywrightConstructs.js +178 -197
- package/dist/common/jwtTokenManager.js +76 -79
- package/dist/common/runApi/errors.js +159 -150
- package/dist/common/runApi/index.js +240 -232
- package/dist/common/runApi/types.d.ts +19 -5
- package/dist/common/runApi/types.js +53 -56
- package/dist/common/settingsSchema.js +15 -10
- package/dist/common/telemetry.js +28 -30
- package/dist/index.js +69 -4
- package/dist/runtime/RunError.js +18 -11
- package/dist/runtime/downloadDirectory.js +19 -13
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +18 -12
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +21 -15
- package/dist/runtime/extendTimeout.js +28 -21
- package/dist/runtime/index.js +53 -6
- package/dist/runtime/requestMoreInfo.js +23 -16
- package/dist/runtime/runInfo.js +21 -14
- package/package.json +4 -7
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -79
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -23
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -51
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/Logger/types.ts +0 -1
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/Logger/types.ts +0 -1
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -182
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/executionHelpers.test.ts +0 -51
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
|
@@ -1,101 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
6
|
+
var _promptly = require("promptly");
|
|
7
|
+
var _fileUtils = require("../common/utils/fileUtils");
|
|
8
|
+
var _settings = require("../common/utils/settings");
|
|
9
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
10
|
+
var _constants = require("../../common/constants");
|
|
11
|
+
var _runApi = require("../../common/runApi");
|
|
12
|
+
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
13
|
+
var _nanoid = require("nanoid");
|
|
14
|
+
var _enums = require("../../runtime/enums");
|
|
15
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
_dotenv.default.config({
|
|
20
|
+
path: `.env`
|
|
15
21
|
});
|
|
16
|
-
program
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
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
|
-
}
|
|
22
|
+
_commander.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 _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
23
|
+
cdpAddress,
|
|
24
|
+
pathToSave,
|
|
25
|
+
input,
|
|
26
|
+
json
|
|
27
|
+
}) => {
|
|
28
|
+
let inputData = null;
|
|
29
|
+
if (input) {
|
|
30
|
+
inputData = await fs.readJSON(input);
|
|
31
|
+
} else if (json) {
|
|
32
|
+
inputData = JSON.parse(json);
|
|
33
|
+
} else {
|
|
34
|
+
inputData = {};
|
|
35
|
+
}
|
|
36
|
+
const setting = await (0, _settings.getSettings)();
|
|
37
|
+
if (!setting.authSessions.enabled) {
|
|
38
|
+
throw new Error("auth sessions feature is not enabled");
|
|
39
|
+
}
|
|
40
|
+
const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
|
|
41
|
+
if (!fs.exists(createFilePath)) {
|
|
42
|
+
throw new Error("auth session create file not found");
|
|
43
|
+
}
|
|
44
|
+
const createModule = await (0, _tsNodeImport.tsNodeImport)(createFilePath);
|
|
45
|
+
async function runCreate() {
|
|
46
|
+
const generator = (0, _runApi.runApiGenerator)({
|
|
47
|
+
automationFunction: {
|
|
48
|
+
module: createModule,
|
|
49
|
+
params: inputData
|
|
50
|
+
},
|
|
51
|
+
runOptions: {
|
|
52
|
+
environment: "ide",
|
|
53
|
+
mode,
|
|
54
|
+
cdpAddress
|
|
55
|
+
},
|
|
56
|
+
retrieveSession: true
|
|
57
|
+
});
|
|
58
|
+
let nextGeneratorParam = undefined;
|
|
59
|
+
while (true) {
|
|
60
|
+
const {
|
|
61
|
+
value,
|
|
62
|
+
done
|
|
63
|
+
} = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
|
|
64
|
+
if (done) {
|
|
65
|
+
if (value.isErr()) {
|
|
66
|
+
console.log(value.error);
|
|
67
|
+
throw new Error(value.error);
|
|
92
68
|
}
|
|
69
|
+
const fullState = value.value.session;
|
|
70
|
+
if (pathToSave) {
|
|
71
|
+
const fullPath = (0, _fileUtils.getFullPathInProject)(pathToSave);
|
|
72
|
+
fs.ensureFileSync(fullPath);
|
|
73
|
+
await fs.writeJSON(fullPath, fullState);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
|
|
78
|
+
nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
|
|
79
|
+
validator: input => {
|
|
80
|
+
if (!value.choices.includes(input)) {
|
|
81
|
+
throw new Error("Please type on of the allowed choices");
|
|
82
|
+
}
|
|
83
|
+
return input;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} else if (value.action === "request_more_info" && value.requestType == "otp") {
|
|
87
|
+
nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
|
|
88
|
+
}
|
|
93
89
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
}
|
|
91
|
+
await (0, _asyncLocalStorage.runWithContext)({
|
|
92
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
93
|
+
extendedPayloads: [],
|
|
94
|
+
runId: (0, _nanoid.nanoid)()
|
|
95
|
+
}, runCreate);
|
|
96
|
+
process.exit(0);
|
|
100
97
|
});
|
|
101
|
-
program.parse(process.argv);
|
|
98
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _browserUtils = require("../common/browserUtils");
|
|
6
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
_dotenv.default.config({
|
|
9
|
+
path: `.env`
|
|
7
10
|
});
|
|
8
|
-
program
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
11
|
+
_commander.program.description("save browser state to file storage.json").option("-p, --path [file]", "path for file", "./localSessions/default.json").allowUnknownOption().action(async ({
|
|
12
|
+
path
|
|
13
|
+
}) => {
|
|
14
|
+
await (0, _browserUtils.saveSessionFromOpenedBrowser)(path);
|
|
15
|
+
process.exit(0);
|
|
18
16
|
});
|
|
19
|
-
program.parse(process.argv);
|
|
17
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _browserUtils = require("../common/browserUtils");
|
|
6
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
_dotenv.default.config({
|
|
9
|
+
path: `.env`
|
|
7
10
|
});
|
|
8
|
-
program
|
|
9
|
-
|
|
10
|
-
.allowUnknownOption()
|
|
11
|
-
.action(async () => {
|
|
12
|
-
await startOrRestartBrowser();
|
|
11
|
+
_commander.program.description("start browser testing purposes").allowUnknownOption().action(async () => {
|
|
12
|
+
await (0, _browserUtils.startOrRestartBrowser)();
|
|
13
13
|
});
|
|
14
|
-
program.parse(process.argv);
|
|
14
|
+
_commander.program.parse(process.argv);
|
package/dist/commands/build.js
CHANGED
|
@@ -1,115 +1,85 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _rollup = require("rollup");
|
|
6
|
+
var _pluginTypescript = _interopRequireDefault(require("@rollup/plugin-typescript"));
|
|
7
|
+
var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
|
|
8
|
+
var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
|
|
9
|
+
var _pluginDynamicImportVars = _interopRequireDefault(require("@rollup/plugin-dynamic-import-vars"));
|
|
10
|
+
var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
11
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
+
var path = _interopRequireWildcard(require("path"));
|
|
13
|
+
var _webTemplate = require("./common/utils/webTemplate.js");
|
|
14
|
+
var _url = require("url");
|
|
15
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
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
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
19
|
function isThirdPartyWarning(warning) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return true;
|
|
18
|
-
return false;
|
|
20
|
+
if (warning.id && /node_modules/.test(warning.id)) return true;
|
|
21
|
+
if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
|
|
22
|
+
return false;
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.default("playwright")
|
|
27
|
-
.argOptional())
|
|
28
|
-
.argument("[outfile]", "output bundle", "./output/bundle_v2.js")
|
|
29
|
-
.allowUnknownOption()
|
|
30
|
-
.action(async (mode, outfile) => {
|
|
31
|
-
await moveWebTemplateFiles();
|
|
32
|
-
const currentTemplateTsConfig = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "template.tsconfig.json");
|
|
33
|
-
await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
34
|
-
await build(outfile, mode);
|
|
24
|
+
_dotenv.default.config();
|
|
25
|
+
_commander.program.description("build the intuned server").addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright"]).default("playwright").argOptional()).argument("[outfile]", "output bundle", "./output/bundle_v2.js").allowUnknownOption().action(async (mode, outfile) => {
|
|
26
|
+
await (0, _webTemplate.moveWebTemplateFiles)();
|
|
27
|
+
const currentTemplateTsConfig = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "template.tsconfig.json");
|
|
28
|
+
await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
29
|
+
await build(outfile, mode);
|
|
35
30
|
});
|
|
36
31
|
async function build(outfile, mode) {
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"applicationinsights",
|
|
90
|
-
"fingerprint-generator",
|
|
91
|
-
"fingerprint-injector",
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
console.log(`📦 Building ${outfile}`);
|
|
95
|
-
const outfileFolder = path.dirname(outfile);
|
|
96
|
-
// copy assets to outfile folder
|
|
97
|
-
const assetsDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "common", "assets");
|
|
98
|
-
await fs.copy(assetsDir, `${outfileFolder}/assets`);
|
|
99
|
-
await bundle.write({
|
|
100
|
-
format: "cjs",
|
|
101
|
-
file: outfile,
|
|
102
|
-
inlineDynamicImports: true,
|
|
103
|
-
});
|
|
104
|
-
console.log(`✨ Build succeeded: ${outfile}`);
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
buildFailed = true;
|
|
108
|
-
console.error("error", error);
|
|
109
|
-
}
|
|
110
|
-
if (buildFailed) {
|
|
111
|
-
console.error("build failed");
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
32
|
+
let bundle = null;
|
|
33
|
+
let buildFailed = false;
|
|
34
|
+
try {
|
|
35
|
+
bundle = await (0, _rollup.rollup)({
|
|
36
|
+
input: `./intuned/WebTemplate/index.${mode}.ts`,
|
|
37
|
+
output: {
|
|
38
|
+
globals: {
|
|
39
|
+
crypto: "crypto"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
plugins: [(0, _pluginJson.default)(), (0, _pluginNodeResolve.nodeResolve)({
|
|
43
|
+
exportConditions: ["node"],
|
|
44
|
+
preferBuiltins: true
|
|
45
|
+
}), (0, _pluginTypescript.default)({
|
|
46
|
+
tsconfig: "./intuned/WebTemplate/tsconfig.json",
|
|
47
|
+
exclude: ["**/*.d.ts"]
|
|
48
|
+
}), (0, _pluginCommonjs.default)({
|
|
49
|
+
include: ["node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**"],
|
|
50
|
+
extensions: [".js"],
|
|
51
|
+
ignoreGlobal: false,
|
|
52
|
+
sourceMap: false,
|
|
53
|
+
dynamicRequireTargets: ["api/**/*.js", "auth-sessions/**/*.js"],
|
|
54
|
+
requireReturnsDefault: "auto",
|
|
55
|
+
transformMixedEsModules: true
|
|
56
|
+
}), (0, _pluginDynamicImportVars.default)({
|
|
57
|
+
include: ["**/*.js"],
|
|
58
|
+
exclude: ["**/*.d.ts", "**/*.js.map"]
|
|
59
|
+
})],
|
|
60
|
+
onwarn: (warning, warn) => {
|
|
61
|
+
if (isThirdPartyWarning(warning)) return;
|
|
62
|
+
warn(warning);
|
|
63
|
+
},
|
|
64
|
+
external: ["@intuned/playwright", "@intuned/playwright-core", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector"]
|
|
65
|
+
});
|
|
66
|
+
console.log(`📦 Building ${outfile}`);
|
|
67
|
+
const outfileFolder = path.dirname(outfile);
|
|
68
|
+
const assetsDir = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "common", "assets");
|
|
69
|
+
await fs.copy(assetsDir, `${outfileFolder}/assets`);
|
|
70
|
+
await bundle.write({
|
|
71
|
+
format: "cjs",
|
|
72
|
+
file: outfile,
|
|
73
|
+
inlineDynamicImports: true
|
|
74
|
+
});
|
|
75
|
+
console.log(`✨ Build succeeded: ${outfile}`);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
buildFailed = true;
|
|
78
|
+
console.error("error", error);
|
|
79
|
+
}
|
|
80
|
+
if (buildFailed) {
|
|
81
|
+
console.error("build failed");
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
114
84
|
}
|
|
115
|
-
program.parse(process.argv);
|
|
85
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,56 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getChromiumLaunchArgs = exports.REMOTE_DEBUGGING_PORT = void 0;
|
|
7
|
+
exports.loadState = loadState;
|
|
8
|
+
exports.saveSession = saveSession;
|
|
9
|
+
exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
|
|
10
|
+
exports.startOrRestartBrowser = startOrRestartBrowser;
|
|
11
|
+
var _child_process = require("child_process");
|
|
12
|
+
var playwright = _interopRequireWildcard(require("@intuned/playwright-core"));
|
|
13
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
14
|
+
var _fileUtils = require("./utils/fileUtils.js");
|
|
15
|
+
var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
|
|
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
|
+
const REMOTE_DEBUGGING_PORT = exports.REMOTE_DEBUGGING_PORT = 9222;
|
|
19
|
+
const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
|
|
20
|
+
exports.getChromiumLaunchArgs = getChromiumLaunchArgs;
|
|
17
21
|
async function getBrowser() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return playwrightBrowser;
|
|
22
|
+
let playwrightBrowser = null;
|
|
23
|
+
try {
|
|
24
|
+
playwrightBrowser = await playwright.chromium.connectOverCDP(`http://localhost:${REMOTE_DEBUGGING_PORT}`);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw new Error("Browser is not running");
|
|
27
|
+
}
|
|
28
|
+
return playwrightBrowser;
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
async function startOrRestartBrowser() {
|
|
31
|
+
const chromiumPath = await playwright.chromium.executablePath();
|
|
32
|
+
const chromeInstanceProcess = (0, _child_process.spawn)(chromiumPath, getChromiumLaunchArgs());
|
|
33
|
+
chromeInstanceProcess.stdout.on("data", data => {
|
|
34
|
+
console.log(`Chrome stdout: ${data}`);
|
|
35
|
+
});
|
|
36
|
+
chromeInstanceProcess.stderr.on("data", data => {
|
|
37
|
+
console.error(`Chrome stderr: ${data}`);
|
|
38
|
+
});
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
async function saveSessionFromOpenedBrowser(path) {
|
|
41
|
+
const browser = await getBrowser();
|
|
42
|
+
const context = await browser.contexts()[0];
|
|
43
|
+
return saveSession(path, context);
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// ToDo: logic to load storage without using the page.
|
|
50
|
-
}
|
|
51
|
-
export async function saveSession(path, context) {
|
|
52
|
-
const fullState = await getContextStorageState(context);
|
|
53
|
-
const fullPath = getFullPathInProject(path);
|
|
54
|
-
fs.ensureFileSync(fullPath);
|
|
55
|
-
await fs.writeJSON(fullPath, fullState);
|
|
45
|
+
async function loadState(path, context) {
|
|
46
|
+
const fullPath = (0, _fileUtils.getFullPathInProject)(path);
|
|
47
|
+
if (!(await fs.pathExists(fullPath))) {
|
|
48
|
+
throw new Error("session file does not exist");
|
|
49
|
+
}
|
|
50
|
+
const data = await fs.readJson(fullPath);
|
|
51
|
+
await context.addCookies(data.cookies);
|
|
56
52
|
}
|
|
53
|
+
async function saveSession(path, context) {
|
|
54
|
+
const fullState = await (0, _contextStorageStateHelpers.getContextStorageState)(context);
|
|
55
|
+
const fullPath = (0, _fileUtils.getFullPathInProject)(path);
|
|
56
|
+
fs.ensureFileSync(fullPath);
|
|
57
|
+
await fs.writeJSON(fullPath, fullState);
|
|
58
|
+
}
|