@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
package/dist/commands/api/run.js
CHANGED
|
@@ -1,178 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { runWithContext } from "../../common/asyncLocalStorage";
|
|
7
|
-
import { RunEnvironment } from "../../runtime/enums";
|
|
8
|
-
import { cleanEnvironmentVariables } from "../../common/cleanEnvironmentVariables";
|
|
9
|
-
import { logger } from "../../common/Logger";
|
|
10
|
-
import { nanoid } from "nanoid";
|
|
11
|
-
import chalk from "chalk";
|
|
12
|
-
import { runApi } from "../../common/runApi";
|
|
13
|
-
import { AutomationError } from "../../common/runApi";
|
|
14
|
-
dotenv.config({
|
|
15
|
-
path: `.env`,
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
16
6
|
});
|
|
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
|
-
// if (mode === "vanilla") {
|
|
46
|
-
// Execute the function with the input data
|
|
47
|
-
// const result = await defaultExport(inputData);
|
|
48
|
-
// return result;
|
|
49
|
-
// }
|
|
50
|
-
// const { page, context } = await getPlaywrightConstructsForMode(
|
|
51
|
-
// mode,
|
|
52
|
-
// options.cdpAddress,
|
|
53
|
-
// authSessionPathToUse ? authSessionPathToUse : undefined
|
|
54
|
-
// );
|
|
55
|
-
// // wait for the page to get stable, this is a workaround for a bug in playwright when you try to do something
|
|
56
|
-
// // on a page after connecting to it immediately, the page needs some time to get stable.
|
|
57
|
-
// let isPageStable = false;
|
|
58
|
-
// let retry = 0;
|
|
59
|
-
// // will wait maximum 2 seconds before failing.
|
|
60
|
-
// while (!isPageStable && retry < 10) {
|
|
61
|
-
// try {
|
|
62
|
-
// await page.locator("html").all();
|
|
63
|
-
// isPageStable = true;
|
|
64
|
-
// break;
|
|
65
|
-
// } catch (error) {
|
|
66
|
-
// if (error?.message?.includes("Execution context was destroyed")) {
|
|
67
|
-
// await new Promise((resolve) => setTimeout(resolve, 200));
|
|
68
|
-
// } else {
|
|
69
|
-
// // throwing to make sure we do not hide any other unexpected issues.
|
|
70
|
-
// throw error;
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
73
|
-
// retry++;
|
|
74
|
-
// }
|
|
75
|
-
// if (!isPageStable) {
|
|
76
|
-
// throw new Error("The page is not stable, try to run again.");
|
|
77
|
-
// }
|
|
78
|
-
const runApiResult = await runApi({
|
|
79
|
-
automationFunction: {
|
|
80
|
-
name: `api/${apiName}`,
|
|
81
|
-
params: inputData ?? {},
|
|
82
|
-
},
|
|
83
|
-
auth: authSessionPathToUse
|
|
84
|
-
? {
|
|
85
|
-
session: {
|
|
86
|
-
type: "file",
|
|
87
|
-
path: authSessionPathToUse,
|
|
88
|
-
},
|
|
89
|
-
runCheck: false,
|
|
90
|
-
}
|
|
91
|
-
: undefined,
|
|
92
|
-
runOptions: {
|
|
93
|
-
environment: "ide",
|
|
94
|
-
cdpAddress: options.cdpAddress,
|
|
95
|
-
mode,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
if (runApiResult.isErr()) {
|
|
99
|
-
if (runApiResult.error instanceof AutomationError) {
|
|
100
|
-
throw runApiResult.error.error;
|
|
101
|
-
}
|
|
102
|
-
console.error("An error occurred while running the API", runApiResult.error);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const { result, extendedPayloads: payloadToAppend } = runApiResult.value;
|
|
106
|
-
const isResponseObject = typeof result === "object" && result !== null;
|
|
107
|
-
const hasMoreThank5Keys = isResponseObject && Object.keys(result).length > 5;
|
|
108
|
-
const hasNestedObjects = isResponseObject &&
|
|
109
|
-
Object.values(result).some((value) => typeof value === "object");
|
|
110
|
-
const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
|
|
111
|
-
const resultsDir = "/tmp/run-results";
|
|
112
|
-
if (options.outputFileId && shouldWriteToFile) {
|
|
113
|
-
logger.info(chalk.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
|
|
114
|
-
fs.ensureDirSync(resultsDir);
|
|
115
|
-
const path = `${resultsDir}/${options.outputFileId}.json`;
|
|
116
|
-
await fs.writeJson(path, result, {
|
|
117
|
-
spaces: 2,
|
|
118
|
-
});
|
|
7
|
+
exports.executeCLI = executeCLI;
|
|
8
|
+
var _commander = require("commander");
|
|
9
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
10
|
+
var _settings = require("../common/utils/settings");
|
|
11
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
12
|
+
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
13
|
+
var _enums = require("../../runtime/enums");
|
|
14
|
+
var _cleanEnvironmentVariables = require("../../common/cleanEnvironmentVariables");
|
|
15
|
+
var _Logger = require("../../common/Logger");
|
|
16
|
+
var _nanoid = require("nanoid");
|
|
17
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
|
+
var _runApi = require("../../common/runApi");
|
|
19
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
20
|
+
var _fileUtils = require("../common/utils/fileUtils");
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
_dotenv.default.config({
|
|
25
|
+
path: `.env`
|
|
26
|
+
});
|
|
27
|
+
async function executeCLI(apiName, mode, inputData, options) {
|
|
28
|
+
(0, _cleanEnvironmentVariables.cleanEnvironmentVariables)();
|
|
29
|
+
let authSessionPathToUse = null;
|
|
30
|
+
const settings = await (0, _settings.getSettings)();
|
|
31
|
+
if (settings.authSessions.enabled) {
|
|
32
|
+
if (!options.authSessionPath) {
|
|
33
|
+
throw new Error("Auth session is enabled but no auth session provided");
|
|
119
34
|
}
|
|
120
|
-
|
|
121
|
-
|
|
35
|
+
authSessionPathToUse = options.authSessionPath;
|
|
36
|
+
} else {
|
|
37
|
+
if (options.authSessionPath) {
|
|
38
|
+
throw new Error("Auth session is not enabled but auth session provided. To use auth session please enable it in Intuned.json");
|
|
122
39
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
40
|
+
}
|
|
41
|
+
const apiFilePath = (0, _fileUtils.getFullPathInProject)("api", `${apiName}.ts`);
|
|
42
|
+
const runApiModule = await (0, _tsNodeImport.tsNodeImport)(apiFilePath);
|
|
43
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
44
|
+
automationFunction: {
|
|
45
|
+
module: runApiModule,
|
|
46
|
+
params: inputData
|
|
47
|
+
},
|
|
48
|
+
auth: authSessionPathToUse ? {
|
|
49
|
+
session: {
|
|
50
|
+
type: "file",
|
|
51
|
+
path: authSessionPathToUse
|
|
52
|
+
},
|
|
53
|
+
runCheck: false
|
|
54
|
+
} : undefined,
|
|
55
|
+
runOptions: {
|
|
56
|
+
environment: "ide",
|
|
57
|
+
cdpAddress: options.cdpAddress,
|
|
58
|
+
mode
|
|
131
59
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
60
|
+
});
|
|
61
|
+
if (runApiResult.isErr()) {
|
|
62
|
+
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
63
|
+
throw runApiResult.error.error;
|
|
135
64
|
}
|
|
65
|
+
console.error("An error occurred while running the API", runApiResult.error);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const {
|
|
69
|
+
result,
|
|
70
|
+
extendedPayloads: payloadToAppend
|
|
71
|
+
} = runApiResult.value;
|
|
72
|
+
const isResponseObject = typeof result === "object" && result !== null;
|
|
73
|
+
const hasMoreThank5Keys = isResponseObject && Object.keys(result).length > 5;
|
|
74
|
+
const hasNestedObjects = isResponseObject && Object.values(result).some(value => typeof value === "object");
|
|
75
|
+
const shouldWriteToFile = isResponseObject && (hasMoreThank5Keys || hasNestedObjects);
|
|
76
|
+
const resultsDir = "/tmp/run-results";
|
|
77
|
+
if (options.outputFileId && shouldWriteToFile) {
|
|
78
|
+
_Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: Results saved (Run: ${options.outputFileId})`));
|
|
79
|
+
fs.ensureDirSync(resultsDir);
|
|
80
|
+
const path = `${resultsDir}/${options.outputFileId}.json`;
|
|
81
|
+
await fs.writeJson(path, result, {
|
|
82
|
+
spaces: 2
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
console.log("result:", result);
|
|
86
|
+
}
|
|
87
|
+
const hasPayloadToAppend = payloadToAppend && payloadToAppend.length > 0;
|
|
88
|
+
if (hasPayloadToAppend && options.outputFileId) {
|
|
89
|
+
_Logger.logger.info(_chalk.default.underline.bgBlue.white(`Click to Open: payloads to append (Run: ${options.outputFileId})`));
|
|
90
|
+
fs.ensureDirSync(resultsDir);
|
|
91
|
+
const path = `${resultsDir}/${options.outputFileId}-payloads-to-append.json`;
|
|
92
|
+
await fs.writeJson(path, payloadToAppend, {
|
|
93
|
+
spaces: 2
|
|
94
|
+
});
|
|
95
|
+
} else if (hasPayloadToAppend) {
|
|
96
|
+
_Logger.logger.info("payload to append:", payloadToAppend);
|
|
97
|
+
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
98
|
+
}
|
|
136
99
|
}
|
|
137
|
-
program
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
])
|
|
154
|
-
.default("playwright-standalone")
|
|
155
|
-
.argOptional())
|
|
156
|
-
.action(async (apiName, mode, options) => {
|
|
157
|
-
let inputData = null;
|
|
158
|
-
if (options.input) {
|
|
159
|
-
inputData = await fs.readJSON(options.input);
|
|
160
|
-
}
|
|
161
|
-
else if (options.json) {
|
|
162
|
-
inputData = JSON.parse(options.json);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
inputData = {};
|
|
166
|
-
}
|
|
167
|
-
await runWithContext({
|
|
168
|
-
runEnvironment: RunEnvironment.IDE,
|
|
169
|
-
extendedPayloads: [],
|
|
170
|
-
runId: nanoid(),
|
|
171
|
-
proxy: options.proxy,
|
|
172
|
-
}, () => executeCLI(apiName, mode, inputData, options));
|
|
173
|
-
// playwright keeps an open handle to the connected browser and it stops the process from exiting
|
|
174
|
-
// there is no way to close the connection gracefully without destroying the context/browser
|
|
175
|
-
// https://github.com/microsoft/playwright/issues/4956
|
|
176
|
-
process.exit(0);
|
|
100
|
+
_commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
|
|
101
|
+
let inputData = null;
|
|
102
|
+
if (options.input) {
|
|
103
|
+
inputData = await fs.readJSON(options.input);
|
|
104
|
+
} else if (options.json) {
|
|
105
|
+
inputData = JSON.parse(options.json);
|
|
106
|
+
} else {
|
|
107
|
+
inputData = {};
|
|
108
|
+
}
|
|
109
|
+
await (0, _asyncLocalStorage.runWithContext)({
|
|
110
|
+
runEnvironment: _enums.RunEnvironment.IDE,
|
|
111
|
+
extendedPayloads: [],
|
|
112
|
+
runId: (0, _nanoid.nanoid)(),
|
|
113
|
+
proxy: options.proxy
|
|
114
|
+
}, () => executeCLI(apiName, mode, inputData, options));
|
|
115
|
+
process.exit(0);
|
|
177
116
|
});
|
|
178
|
-
program.parse(process.argv);
|
|
117
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
dotenv
|
|
8
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _getPlaywrightConstructs = require("../../common/getPlaywrightConstructs");
|
|
6
|
+
var _settings = require("../common/utils/settings");
|
|
7
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
_dotenv.default.config({
|
|
10
|
+
path: `.env`
|
|
9
11
|
});
|
|
10
|
-
program
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
_commander.program.description("load auth session to browser").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").allowUnknownOption().action(async ({
|
|
13
|
+
cdpAddress,
|
|
14
|
+
authSessionPath
|
|
15
|
+
}) => {
|
|
16
|
+
const setting = await (0, _settings.getSettings)();
|
|
17
|
+
if (!setting.authSessions.enabled) {
|
|
18
|
+
throw new Error("Auth session is not enabled");
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
context
|
|
22
|
+
} = await (0, _getPlaywrightConstructs.getRemotePlaywrightContext)(cdpAddress);
|
|
23
|
+
await (0, _getPlaywrightConstructs.loadSessionToContext)({
|
|
24
|
+
context,
|
|
25
|
+
session: {
|
|
26
|
+
type: "file",
|
|
27
|
+
path: authSessionPath
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
context,
|
|
23
|
-
session: {
|
|
24
|
-
type: "file",
|
|
25
|
-
path: authSessionPath,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
process.exit(0);
|
|
29
|
+
});
|
|
30
|
+
process.exit(0);
|
|
29
31
|
});
|
|
30
|
-
program.parse(process.argv);
|
|
32
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
6
|
+
var _fileUtils = require("../common/utils/fileUtils");
|
|
7
|
+
var _settings = require("../common/utils/settings");
|
|
8
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
|
+
var _constants = require("../../common/constants");
|
|
10
|
+
var _runApi = require("../../common/runApi");
|
|
11
|
+
var _tsNodeImport = require("../common/tsNodeImport");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
_dotenv.default.config({
|
|
16
|
+
path: `.env`
|
|
11
17
|
});
|
|
12
|
-
program
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
_commander.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 _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
19
|
+
cdpAddress,
|
|
20
|
+
authSessionPath
|
|
21
|
+
}) => {
|
|
22
|
+
const setting = await (0, _settings.getSettings)();
|
|
23
|
+
if (!setting.authSessions.enabled) {
|
|
24
|
+
throw new Error("auth session is not enabled");
|
|
25
|
+
}
|
|
26
|
+
const checkFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
27
|
+
if (!fs.exists(checkFilePath)) {
|
|
28
|
+
throw new Error("auth session check file not found");
|
|
29
|
+
}
|
|
30
|
+
const checkModule = await (0, _tsNodeImport.tsNodeImport)(checkFilePath);
|
|
31
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
32
|
+
automationFunction: {
|
|
33
|
+
module: checkModule
|
|
34
|
+
},
|
|
35
|
+
runOptions: {
|
|
36
|
+
environment: "ide",
|
|
37
|
+
mode,
|
|
38
|
+
cdpAddress
|
|
39
|
+
},
|
|
40
|
+
auth: {
|
|
41
|
+
session: {
|
|
42
|
+
type: "file",
|
|
43
|
+
path: authSessionPath
|
|
44
|
+
},
|
|
45
|
+
runCheck: false
|
|
25
46
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mode,
|
|
37
|
-
cdpAddress,
|
|
38
|
-
},
|
|
39
|
-
auth: {
|
|
40
|
-
session: {
|
|
41
|
-
type: "file",
|
|
42
|
-
path: authSessionPath,
|
|
43
|
-
},
|
|
44
|
-
runCheck: false,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
if (runApiResult.isErr()) {
|
|
48
|
-
throw new Error(runApiResult.error);
|
|
49
|
-
}
|
|
50
|
-
const result = runApiResult.value.result;
|
|
51
|
-
console.log("check result", result);
|
|
52
|
-
if (!result) {
|
|
53
|
-
throw new Error("auth session check failed");
|
|
54
|
-
}
|
|
55
|
-
process.exit(0);
|
|
47
|
+
});
|
|
48
|
+
if (runApiResult.isErr()) {
|
|
49
|
+
throw new Error(runApiResult.error);
|
|
50
|
+
}
|
|
51
|
+
const result = runApiResult.value.result;
|
|
52
|
+
console.log("check result", result);
|
|
53
|
+
if (!result) {
|
|
54
|
+
throw new Error("auth session check failed");
|
|
55
|
+
}
|
|
56
|
+
process.exit(0);
|
|
56
57
|
});
|
|
57
|
-
program.parse(process.argv);
|
|
58
|
+
_commander.program.parse(process.argv);
|