@intuned/runtime-dev 0.1.0-test.11 → 0.1.0-test.13
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 +0 -1
- package/dist/commands/api/run.js +156 -83
- package/dist/commands/api/run.ts +105 -0
- package/dist/commands/auth-sessions/load.js +20 -20
- package/dist/commands/auth-sessions/load.ts +30 -0
- package/dist/commands/auth-sessions/run-check.js +45 -39
- package/dist/commands/auth-sessions/run-check.ts +51 -0
- package/dist/commands/auth-sessions/run-create.js +84 -74
- package/dist/commands/auth-sessions/run-create.ts +91 -0
- package/dist/commands/browser/save-state.js +12 -7
- package/dist/commands/browser/save-state.ts +14 -0
- package/dist/commands/browser/start-browser.js +7 -4
- package/dist/commands/browser/start-browser.ts +11 -0
- package/dist/commands/build.js +97 -61
- package/dist/commands/build.ts +78 -0
- package/dist/commands/common/browserUtils.js +42 -31
- package/dist/commands/common/browserUtils.ts +45 -0
- package/dist/commands/common/getDefaultExportFromFile.js +11 -10
- package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
- package/dist/commands/common/getFirstLineNumber.js +90 -83
- package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +2 -2
- package/dist/commands/common/getFirstLineNumber.ts +96 -0
- package/dist/commands/common/sendMessageToClient.js +4 -2
- package/dist/commands/common/sendMessageToClient.ts +3 -0
- package/dist/commands/common/utils/fileUtils.js +16 -16
- package/dist/commands/common/utils/fileUtils.ts +23 -0
- package/dist/commands/common/utils/settings.js +17 -19
- package/dist/commands/common/utils/settings.ts +22 -0
- package/dist/commands/common/utils/unixSocket.js +43 -36
- package/dist/commands/common/utils/unixSocket.ts +38 -0
- package/dist/commands/common/utils/webTemplate.js +25 -18
- package/dist/commands/common/utils/webTemplate.ts +22 -0
- package/dist/commands/interface/run.js +139 -133
- package/dist/commands/interface/run.ts +156 -0
- package/dist/commands/ts-check.js +45 -41
- 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 +40 -46
- package/dist/common/Logger/Logger/index.ts +53 -0
- package/dist/common/Logger/Logger/types.js +1 -1
- package/dist/common/Logger/index.d.ts +1 -1
- package/dist/common/Logger/index.js +40 -46
- package/dist/common/Logger/index.ts +53 -0
- package/dist/common/Logger/types.js +1 -1
- package/dist/common/asyncLocalStorage/index.js +4 -4
- package/dist/common/asyncLocalStorage/index.ts +9 -0
- package/dist/common/cleanEnvironmentVariables.js +11 -9
- package/dist/common/cleanEnvironmentVariables.ts +10 -0
- package/dist/common/constants.js +1 -1
- package/dist/common/constants.ts +1 -0
- package/dist/common/contextStorageStateHelpers.js +36 -38
- package/dist/common/contextStorageStateHelpers.ts +43 -0
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +187 -157
- package/dist/common/getPlaywrightConstructs.ts +181 -0
- package/dist/common/jwtTokenManager.js +74 -61
- package/dist/common/jwtTokenManager.ts +71 -0
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +130 -121
- package/dist/common/runApi/errors.ts +154 -0
- package/dist/common/runApi/index.d.ts +4 -4
- package/dist/common/runApi/index.js +219 -233
- package/dist/common/runApi/index.ts +253 -0
- package/dist/common/runApi/types.d.ts +1 -1
- package/dist/common/runApi/types.js +55 -41
- package/dist/common/runApi/types.ts +43 -0
- package/dist/common/settingsSchema.js +9 -6
- package/dist/common/settingsSchema.ts +9 -0
- package/dist/common/telemetry.js +27 -16
- package/dist/common/telemetry.ts +23 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.ts +4 -0
- package/dist/runtime/RunError.d.ts +1 -1
- package/dist/runtime/RunError.js +10 -10
- package/dist/runtime/RunError.ts +12 -0
- package/dist/runtime/downloadDirectory.js +10 -10
- package/dist/runtime/downloadDirectory.ts +13 -0
- package/dist/runtime/enums.d.ts +1 -11
- package/dist/runtime/enums.js +12 -12
- package/dist/runtime/enums.ts +12 -0
- package/dist/runtime/{executionHelpers.test.js → executionHelpers.test.ts} +2 -2
- package/dist/runtime/export.d.ts +1 -202
- package/dist/runtime/extendPayload.d.ts +1 -1
- package/dist/runtime/extendPayload.js +13 -13
- package/dist/runtime/extendPayload.ts +15 -0
- package/dist/runtime/extendTimeout.js +19 -20
- package/dist/runtime/extendTimeout.ts +24 -0
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.ts +6 -0
- package/dist/runtime/requestMoreInfo.js +14 -14
- package/dist/runtime/requestMoreInfo.ts +18 -0
- package/dist/runtime/runInfo.d.ts +1 -1
- package/dist/runtime/runInfo.js +12 -13
- package/dist/runtime/runInfo.ts +15 -0
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- /package/dist/{runtime/enums.d.js → common/Logger/Logger/types.ts} +0 -0
- /package/dist/{runtime/export.d.js → common/Logger/types.ts} +0 -0
|
@@ -11,81 +11,91 @@ import { runWithContext } from "../../common/asyncLocalStorage";
|
|
|
11
11
|
import { nanoid } from "nanoid";
|
|
12
12
|
import { RunEnvironment } from "../../runtime/enums";
|
|
13
13
|
dotenv.config({
|
|
14
|
-
|
|
14
|
+
path: `.env`,
|
|
15
15
|
});
|
|
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
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
}
|
|
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,
|
|
78
59
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
82
93
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
process.exit(0);
|
|
94
|
+
await runWithContext({
|
|
95
|
+
runEnvironment: RunEnvironment.IDE,
|
|
96
|
+
extendedPayloads: [],
|
|
97
|
+
runId: nanoid(),
|
|
98
|
+
}, runCreate);
|
|
99
|
+
process.exit(0);
|
|
90
100
|
});
|
|
91
|
-
program.parse(process.argv);
|
|
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);
|
|
@@ -3,12 +3,17 @@ import { program } from "commander";
|
|
|
3
3
|
import { saveSessionFromOpenedBrowser } from "../common/browserUtils";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
dotenv.config({
|
|
6
|
-
|
|
6
|
+
path: `.env`,
|
|
7
7
|
});
|
|
8
|
-
program
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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);
|
|
13
18
|
});
|
|
14
|
-
program.parse(process.argv);
|
|
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);
|
|
@@ -3,9 +3,12 @@ import { program } from "commander";
|
|
|
3
3
|
import { startOrRestartBrowser } from "../common/browserUtils";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
dotenv.config({
|
|
6
|
-
|
|
6
|
+
path: `.env`,
|
|
7
7
|
});
|
|
8
|
-
program
|
|
9
|
-
|
|
8
|
+
program
|
|
9
|
+
.description("start browser testing purposes")
|
|
10
|
+
.allowUnknownOption()
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await startOrRestartBrowser();
|
|
10
13
|
});
|
|
11
|
-
program.parse(process.argv);
|
|
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
|
@@ -8,71 +8,107 @@ import dynamicImportVars from "@rollup/plugin-dynamic-import-vars";
|
|
|
8
8
|
import json from "@rollup/plugin-json";
|
|
9
9
|
import * as fs from "fs-extra";
|
|
10
10
|
import * as path from "path";
|
|
11
|
-
import { moveWebTemplateFiles } from "./common/utils/webTemplate";
|
|
11
|
+
import { moveWebTemplateFiles } from "./common/utils/webTemplate.js";
|
|
12
12
|
function isThirdPartyWarning(warning) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
18
|
}
|
|
17
19
|
import dotenv from "dotenv";
|
|
18
20
|
dotenv.config();
|
|
19
|
-
program
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(path.dirname(import.meta.url), "..", "..", "template.tsconfig.json");
|
|
32
|
+
await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
33
|
+
await build(outfile, mode);
|
|
24
34
|
});
|
|
25
35
|
async function build(outfile, mode) {
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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(path.dirname(import.meta.url), "..", "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
|
+
}
|
|
77
113
|
}
|
|
78
|
-
program.parse(process.argv);
|
|
114
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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";
|
|
12
|
+
function isThirdPartyWarning(warning) {
|
|
13
|
+
if (warning.id && /node_modules/.test(warning.id)) return true;
|
|
14
|
+
if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
import dotenv from "dotenv";
|
|
18
|
+
dotenv.config();
|
|
19
|
+
program.description("build the intuned server").addArgument(new Argument("<mode>", "mode of execution").choices(["vanilla", "playwright"]).default("playwright").argOptional()).argument("[outfile]", "output bundle", "./output/bundle_v2.js").allowUnknownOption().action(async (mode, outfile) => {
|
|
20
|
+
await moveWebTemplateFiles();
|
|
21
|
+
const currentTemplateTsConfig = path.resolve(path.dirname(import.meta.url), "..", "..", "template.tsconfig.json");
|
|
22
|
+
await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
23
|
+
await build(outfile, mode);
|
|
24
|
+
});
|
|
25
|
+
async function build(outfile, mode) {
|
|
26
|
+
let bundle = null;
|
|
27
|
+
let buildFailed = false;
|
|
28
|
+
try {
|
|
29
|
+
bundle = await rollup({
|
|
30
|
+
input: `./intuned/WebTemplate/index.${mode}.ts`,
|
|
31
|
+
output: {
|
|
32
|
+
globals: {
|
|
33
|
+
crypto: "crypto"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
plugins: [json(), nodeResolve({
|
|
37
|
+
exportConditions: ["node"],
|
|
38
|
+
preferBuiltins: true
|
|
39
|
+
}), typescript({
|
|
40
|
+
tsconfig: "./intuned/WebTemplate/tsconfig.json"
|
|
41
|
+
}), commonjs({
|
|
42
|
+
include: ["node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**", "../typescript-runtime/**"],
|
|
43
|
+
extensions: [".js"],
|
|
44
|
+
ignoreGlobal: false,
|
|
45
|
+
sourceMap: false,
|
|
46
|
+
dynamicRequireTargets: ["api/**/*.js", "auth-sessions/**/*.js"],
|
|
47
|
+
requireReturnsDefault: "auto",
|
|
48
|
+
transformMixedEsModules: true
|
|
49
|
+
}), dynamicImportVars({
|
|
50
|
+
include: ["**/*.js", "**/*.ts"],
|
|
51
|
+
exclude: ["**/*.d.ts", "**/*.js.map"]
|
|
52
|
+
})],
|
|
53
|
+
onwarn: (warning, warn) => {
|
|
54
|
+
if (isThirdPartyWarning(warning)) return;
|
|
55
|
+
warn(warning);
|
|
56
|
+
},
|
|
57
|
+
external: ["@intuned/playwright", "@intuned/playwright-core", "@intuned/runtime", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector"]
|
|
58
|
+
});
|
|
59
|
+
console.log(`📦 Building ${outfile}`);
|
|
60
|
+
const outfileFolder = path.dirname(outfile);
|
|
61
|
+
const assetsDir = path.resolve(path.dirname(import.meta.url), "..", "common", "assets");
|
|
62
|
+
await fs.copy(assetsDir, `${outfileFolder}/assets`);
|
|
63
|
+
await bundle.write({
|
|
64
|
+
format: "cjs",
|
|
65
|
+
file: outfile,
|
|
66
|
+
inlineDynamicImports: true
|
|
67
|
+
});
|
|
68
|
+
console.log(`✨ Build succeeded: ${outfile}`);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
buildFailed = true;
|
|
71
|
+
console.error("error", error);
|
|
72
|
+
}
|
|
73
|
+
if (buildFailed) {
|
|
74
|
+
console.error("build failed");
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
program.parse(process.argv);
|