@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.
Files changed (103) hide show
  1. package/.babelrc +1 -2
  2. package/dist/commands/api/run.js +170 -105
  3. package/dist/commands/api/run.ts +105 -0
  4. package/dist/commands/auth-sessions/load.js +26 -28
  5. package/dist/commands/auth-sessions/load.ts +30 -0
  6. package/dist/commands/auth-sessions/run-check.js +53 -52
  7. package/dist/commands/auth-sessions/run-check.ts +51 -0
  8. package/dist/commands/auth-sessions/run-create.js +96 -91
  9. package/dist/commands/auth-sessions/run-create.ts +91 -0
  10. package/dist/commands/browser/save-state.js +16 -14
  11. package/dist/commands/browser/save-state.ts +14 -0
  12. package/dist/commands/browser/start-browser.js +11 -11
  13. package/dist/commands/browser/start-browser.ts +11 -0
  14. package/dist/commands/build.js +108 -75
  15. package/dist/commands/build.ts +78 -0
  16. package/dist/commands/common/browserUtils.js +51 -53
  17. package/dist/commands/common/browserUtils.ts +45 -0
  18. package/dist/commands/common/getDefaultExportFromFile.js +12 -17
  19. package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
  20. package/dist/commands/common/getFirstLineNumber.js +93 -93
  21. package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
  22. package/dist/commands/common/getFirstLineNumber.ts +96 -0
  23. package/dist/commands/common/sendMessageToClient.js +4 -9
  24. package/dist/commands/common/sendMessageToClient.ts +3 -0
  25. package/dist/commands/common/utils/fileUtils.js +22 -32
  26. package/dist/commands/common/utils/fileUtils.ts +23 -0
  27. package/dist/commands/common/utils/settings.js +19 -27
  28. package/dist/commands/common/utils/settings.ts +22 -0
  29. package/dist/commands/common/utils/unixSocket.js +43 -43
  30. package/dist/commands/common/utils/unixSocket.ts +38 -0
  31. package/dist/commands/common/utils/webTemplate.js +27 -29
  32. package/dist/commands/common/utils/webTemplate.ts +22 -0
  33. package/dist/commands/interface/run.js +151 -150
  34. package/dist/commands/interface/run.ts +156 -0
  35. package/dist/commands/ts-check.js +49 -49
  36. package/dist/commands/ts-check.ts +50 -0
  37. package/dist/common/Logger/Logger/index.d.ts +1 -1
  38. package/dist/common/Logger/Logger/index.js +42 -55
  39. package/dist/common/Logger/Logger/index.ts +53 -0
  40. package/dist/common/Logger/Logger/types.js +1 -5
  41. package/dist/common/Logger/Logger/types.ts +1 -0
  42. package/dist/common/Logger/index.d.ts +1 -1
  43. package/dist/common/Logger/index.js +42 -55
  44. package/dist/common/Logger/index.ts +53 -0
  45. package/dist/common/Logger/types.js +1 -5
  46. package/dist/common/Logger/types.ts +1 -0
  47. package/dist/common/asyncLocalStorage/index.js +8 -16
  48. package/dist/common/asyncLocalStorage/index.ts +9 -0
  49. package/dist/common/cleanEnvironmentVariables.js +12 -16
  50. package/dist/common/cleanEnvironmentVariables.ts +10 -0
  51. package/dist/common/constants.js +1 -7
  52. package/dist/common/constants.ts +1 -0
  53. package/dist/common/contextStorageStateHelpers.js +38 -47
  54. package/dist/common/contextStorageStateHelpers.ts +43 -0
  55. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  56. package/dist/common/getPlaywrightConstructs.js +196 -177
  57. package/dist/common/getPlaywrightConstructs.ts +181 -0
  58. package/dist/common/jwtTokenManager.js +79 -76
  59. package/dist/common/jwtTokenManager.ts +71 -0
  60. package/dist/common/runApi/errors.d.ts +1 -1
  61. package/dist/common/runApi/errors.js +150 -159
  62. package/dist/common/runApi/errors.ts +154 -0
  63. package/dist/common/runApi/index.d.ts +4 -4
  64. package/dist/common/runApi/index.js +220 -269
  65. package/dist/common/runApi/index.ts +253 -0
  66. package/dist/common/runApi/types.d.ts +1 -1
  67. package/dist/common/runApi/types.js +56 -49
  68. package/dist/common/runApi/types.ts +43 -0
  69. package/dist/common/settingsSchema.js +10 -15
  70. package/dist/common/settingsSchema.ts +9 -0
  71. package/dist/common/telemetry.js +30 -28
  72. package/dist/common/telemetry.ts +23 -0
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -69
  75. package/dist/index.ts +4 -0
  76. package/dist/runtime/RunError.d.ts +1 -1
  77. package/dist/runtime/RunError.js +11 -18
  78. package/dist/runtime/RunError.ts +12 -0
  79. package/dist/runtime/downloadDirectory.js +13 -19
  80. package/dist/runtime/downloadDirectory.ts +13 -0
  81. package/dist/runtime/enums.d.ts +1 -11
  82. package/dist/runtime/enums.js +12 -18
  83. package/dist/runtime/enums.ts +12 -0
  84. package/dist/runtime/executionHelpers.test.ts +51 -0
  85. package/dist/runtime/export.d.ts +1 -202
  86. package/dist/runtime/extendPayload.d.ts +1 -1
  87. package/dist/runtime/extendPayload.js +15 -21
  88. package/dist/runtime/extendPayload.ts +15 -0
  89. package/dist/runtime/extendTimeout.js +21 -28
  90. package/dist/runtime/extendTimeout.ts +24 -0
  91. package/dist/runtime/index.d.ts +7 -7
  92. package/dist/runtime/index.js +6 -53
  93. package/dist/runtime/index.ts +6 -0
  94. package/dist/runtime/requestMoreInfo.js +16 -23
  95. package/dist/runtime/requestMoreInfo.ts +18 -0
  96. package/dist/runtime/runInfo.d.ts +1 -1
  97. package/dist/runtime/runInfo.js +14 -21
  98. package/dist/runtime/runInfo.ts +15 -0
  99. package/package.json +3 -2
  100. package/tsconfig.json +1 -1
  101. package/dist/runtime/enums.d.js +0 -5
  102. package/dist/runtime/executionHelpers.test.js +0 -53
  103. 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
- "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
- 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
- _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, {
22
- cdpAddress,
23
- pathToSave,
24
- input,
25
- json
26
- }) => {
27
- let inputData = null;
28
- if (input) {
29
- inputData = await fs.readJSON(input);
30
- } else if (json) {
31
- inputData = JSON.parse(json);
32
- } else {
33
- inputData = {};
34
- }
35
- const setting = await (0, _settings.getSettings)();
36
- if (!setting.authSessions.enabled) {
37
- throw new Error("auth sessions feature is not enabled");
38
- }
39
- const createFilePath = (0, _fileUtils.getFullPathInProject)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create.ts");
40
- if (!fs.exists(createFilePath)) {
41
- throw new Error("auth session create file not found");
42
- }
43
- async function runCreate() {
44
- const generator = (0, _runApi.runApiGenerator)({
45
- automationFunction: {
46
- name: "auth-sessions/create",
47
- params: inputData ?? {}
48
- },
49
- runOptions: {
50
- environment: "ide",
51
- mode,
52
- cdpAddress
53
- },
54
- retrieveSession: true
55
- });
56
- let nextGeneratorParam = undefined;
57
- while (true) {
58
- const {
59
- value,
60
- done
61
- } = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
62
- if (done) {
63
- if (value.isErr()) {
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
- } else if (value.action === "request_more_info" && value.requestType == "otp") {
85
- nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
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
- await (0, _asyncLocalStorage.runWithContext)({
90
- runEnvironment: _enums.RunEnvironment.IDE,
91
- extendedPayloads: [],
92
- runId: (0, _nanoid.nanoid)()
93
- }, runCreate);
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
- _commander.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);
@@ -1,17 +1,19 @@
1
1
  #!/usr/bin/env node
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`
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
- _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);
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
- _commander.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);
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
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`
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
- _commander.program.description("start browser testing purposes").allowUnknownOption().action(async () => {
12
- await (0, _browserUtils.startOrRestartBrowser)();
8
+ program
9
+ .description("start browser testing purposes")
10
+ .allowUnknownOption()
11
+ .action(async () => {
12
+ await startOrRestartBrowser();
13
13
  });
14
- _commander.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);
@@ -1,81 +1,114 @@
1
1
  #!/usr/bin/env node
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");
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
- if (warning.id && /node_modules/.test(warning.id)) return true;
20
- if (warning.ids && warning.ids.every(id => /node_modules/.test(id))) return true;
21
- return false;
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
- _dotenv.default.config();
24
- _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) => {
25
- await (0, _webTemplate.moveWebTemplateFiles)();
26
- const currentTemplateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
27
- await fs.copy(currentTemplateTsConfig, "./intuned/WebTemplate/tsconfig.json");
28
- await build(outfile, mode);
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
- let bundle = null;
32
- let buildFailed = false;
33
- try {
34
- bundle = await (0, _rollup.rollup)({
35
- input: `./intuned/WebTemplate/index.${mode}.ts`,
36
- output: {
37
- globals: {
38
- crypto: "crypto"
39
- }
40
- },
41
- plugins: [(0, _pluginJson.default)(), (0, _pluginNodeResolve.nodeResolve)({
42
- exportConditions: ["node"],
43
- preferBuiltins: true
44
- }), (0, _pluginTypescript.default)({
45
- tsconfig: "./intuned/WebTemplate/tsconfig.json"
46
- }), (0, _pluginCommonjs.default)({
47
- include: ["node_modules/**", "intuned/WebTemplate/**", "dist", "../typescript-sdk/**", "../typescript-runtime/**"],
48
- extensions: [".js"],
49
- ignoreGlobal: false,
50
- sourceMap: false,
51
- dynamicRequireTargets: ["api/**/*.ts", "auth-sessions/**/*.ts", "api/**/*.js", "auth-sessions/**/*.js"]
52
- }), (0, _pluginDynamicImportVars.default)({
53
- include: ["**/*.js", "**/*.ts"],
54
- exclude: ["**/*.d.ts", "**/*.js.map"]
55
- })],
56
- onwarn: (warning, warn) => {
57
- if (isThirdPartyWarning(warning)) return;
58
- warn(warning);
59
- },
60
- external: ["@intuned/playwright", "@intuned/playwright-core", "jsdom", "canvas", "pdfjs-dist", "pdf-to-png-converter", "crypto", "applicationinsights", "fingerprint-generator", "fingerprint-injector"]
61
- });
62
- console.log(`📦 Building ${outfile}`);
63
- const outfileFolder = path.dirname(outfile);
64
- const assetsDir = path.resolve(__dirname, "..", "common", "assets");
65
- await fs.copy(assetsDir, `${outfileFolder}/assets`);
66
- await bundle.write({
67
- format: "cjs",
68
- file: outfile,
69
- inlineDynamicImports: true
70
- });
71
- console.log(`✨ Build succeeded: ${outfile}`);
72
- } catch (error) {
73
- buildFailed = true;
74
- console.error("error", error);
75
- }
76
- if (buildFailed) {
77
- console.error("build failed");
78
- process.exit(1);
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
- _commander.program.parse(process.argv);
114
+ program.parse(process.argv);