@intuned/runtime-dev 0.1.0-test.1 → 0.1.0-test.11
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 +3 -1
- package/Intuned.json +1 -1
- package/api/test2.ts +1 -4
- package/dist/commands/api/run.js +27 -35
- package/dist/commands/auth-sessions/load.js +11 -13
- package/dist/commands/auth-sessions/run-check.js +14 -19
- package/dist/commands/auth-sessions/run-create.js +23 -28
- package/dist/commands/browser/save-state.js +7 -10
- package/dist/commands/browser/start-browser.js +7 -10
- package/dist/commands/build.js +25 -30
- package/dist/commands/common/browserUtils.js +15 -28
- package/dist/commands/common/getDefaultExportFromFile.js +2 -10
- package/dist/commands/common/getFirstLineNumber.js +13 -20
- package/dist/commands/common/getFirstLineNumber.test.js +46 -51
- package/dist/commands/common/sendMessageToClient.js +2 -9
- package/dist/commands/common/utils/fileUtils.js +6 -16
- package/dist/commands/common/utils/settings.js +7 -13
- package/dist/commands/common/utils/unixSocket.js +2 -9
- package/dist/commands/common/utils/webTemplate.js +7 -16
- package/dist/commands/interface/run.js +34 -39
- package/dist/commands/ts-check.js +8 -12
- package/dist/common/Logger/Logger/index.js +9 -16
- package/dist/common/Logger/Logger/types.js +1 -5
- package/dist/common/Logger/index.js +9 -16
- package/dist/common/Logger/types.js +1 -5
- package/dist/common/asyncLocalStorage/index.js +4 -12
- package/dist/common/cleanEnvironmentVariables.js +1 -7
- package/dist/common/constants.js +1 -7
- package/dist/common/contextStorageStateHelpers.js +2 -9
- package/dist/common/getPlaywrightConstructs.js +28 -39
- package/dist/common/jwtTokenManager.js +8 -18
- package/dist/common/runApi/errors.js +24 -42
- package/dist/common/runApi/index.js +53 -88
- package/dist/common/runApi/types.js +31 -38
- package/dist/common/settingsSchema.js +2 -10
- package/dist/common/telemetry.js +3 -12
- package/dist/index.js +4 -69
- package/dist/runtime/RunError.js +1 -8
- package/dist/runtime/downloadDirectory.js +5 -11
- package/dist/runtime/enums.d.js +1 -5
- package/dist/runtime/enums.js +2 -8
- package/dist/runtime/executionHelpers.test.js +20 -22
- package/dist/runtime/export.d.js +1 -5
- package/dist/runtime/extendPayload.js +5 -11
- package/dist/runtime/extendTimeout.js +3 -9
- package/dist/runtime/index.js +6 -53
- package/dist/runtime/requestMoreInfo.js +2 -9
- package/dist/runtime/runInfo.js +5 -11
- package/package.json +3 -1
- package/preserve-dynamic-imports.js +16 -0
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = getFirstLineNumber;
|
|
7
|
-
exports.findFirstExecutableLine = findFirstExecutableLine;
|
|
8
|
-
var _tsMorph = require("ts-morph");
|
|
9
|
-
var _sourceMap = require("source-map");
|
|
1
|
+
import { ts, Project, ModuleKind, ScriptTarget, Node } from "ts-morph";
|
|
2
|
+
import { SourceMapConsumer } from "source-map";
|
|
10
3
|
function compileTypeScript(apiFilePath) {
|
|
11
4
|
const compilerOptions = {
|
|
12
5
|
lib: ["dom", "es2020"],
|
|
@@ -15,10 +8,10 @@ function compileTypeScript(apiFilePath) {
|
|
|
15
8
|
inlineSources: true,
|
|
16
9
|
declaration: false,
|
|
17
10
|
noEmit: false,
|
|
18
|
-
module:
|
|
19
|
-
target:
|
|
11
|
+
module: ModuleKind.CommonJS,
|
|
12
|
+
target: ScriptTarget.ES2020
|
|
20
13
|
};
|
|
21
|
-
const project = new
|
|
14
|
+
const project = new Project({
|
|
22
15
|
compilerOptions
|
|
23
16
|
});
|
|
24
17
|
const sourceFile = project.addSourceFileAtPath(apiFilePath);
|
|
@@ -31,36 +24,36 @@ function compileTypeScript(apiFilePath) {
|
|
|
31
24
|
outputJSText
|
|
32
25
|
};
|
|
33
26
|
}
|
|
34
|
-
function findFirstExecutableLine(sourceFile) {
|
|
27
|
+
export function findFirstExecutableLine(sourceFile) {
|
|
35
28
|
var _defaultExportSymbol$;
|
|
36
29
|
let functionBody;
|
|
37
30
|
const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
|
|
38
31
|
const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
|
|
39
32
|
if (defaultExportDeclaration) {
|
|
40
|
-
if (defaultExportDeclaration.getKind() ===
|
|
33
|
+
if (defaultExportDeclaration.getKind() === ts.SyntaxKind.FunctionDeclaration) {
|
|
41
34
|
functionBody = defaultExportDeclaration.getBody();
|
|
42
35
|
} else {
|
|
43
36
|
const exportAssignments = sourceFile.getExportAssignments();
|
|
44
37
|
for (const exportAssignment of exportAssignments) {
|
|
45
38
|
const expression = exportAssignment.getExpression();
|
|
46
39
|
if (!expression) continue;
|
|
47
|
-
if (expression.getKind() ===
|
|
40
|
+
if (expression.getKind() === ts.SyntaxKind.Identifier || expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction) {
|
|
48
41
|
var _sourceFile$getVariab;
|
|
49
42
|
const identifier = expression.getText();
|
|
50
|
-
const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() ===
|
|
43
|
+
const possiblyExportedFunction = sourceFile.getFunction(identifier) || ((_sourceFile$getVariab = sourceFile.getVariableStatement(identifier)) === null || _sourceFile$getVariab === void 0 ? void 0 : _sourceFile$getVariab.getDescendants().find(node => node.getKind() === ts.SyntaxKind.FunctionExpression || node.getKind() === ts.SyntaxKind.ArrowFunction));
|
|
51
44
|
if (possiblyExportedFunction) {
|
|
52
45
|
functionBody = possiblyExportedFunction.getBody();
|
|
53
46
|
break;
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
if (
|
|
49
|
+
if (Node.hasBody(expression) && (expression.getKind() === ts.SyntaxKind.FunctionExpression || expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
|
|
57
50
|
functionBody = expression.getBody();
|
|
58
51
|
break;
|
|
59
52
|
}
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
if (!functionBody || !
|
|
56
|
+
if (!functionBody || !Node.isStatemented(functionBody)) {
|
|
64
57
|
return -1;
|
|
65
58
|
}
|
|
66
59
|
if (functionBody.getStatements().length === 0) {
|
|
@@ -73,7 +66,7 @@ async function getSourceMap(jsCode) {
|
|
|
73
66
|
const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
|
|
74
67
|
const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
|
|
75
68
|
const sourceMap = JSON.parse(sourceMapText);
|
|
76
|
-
return new
|
|
69
|
+
return new SourceMapConsumer(sourceMap);
|
|
77
70
|
}
|
|
78
71
|
async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
|
|
79
72
|
const sourceMap = await getSourceMap(jsCode);
|
|
@@ -85,7 +78,7 @@ async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, colum
|
|
|
85
78
|
if (!generatedLineNumber) return -1;
|
|
86
79
|
return generatedLineNumber;
|
|
87
80
|
}
|
|
88
|
-
async function getFirstLineNumber(apiFilePath) {
|
|
81
|
+
export default async function getFirstLineNumber(apiFilePath) {
|
|
89
82
|
const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
|
|
90
83
|
const {
|
|
91
84
|
sourceFile,
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var path = _interopRequireWildcard(require("path"));
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
(0, _vitest.describe)("getFirstLineNumber", () => {
|
|
1
|
+
import { expect, describe, it, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import getFirstLineNumber from "./getFirstLineNumber";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
describe("getFirstLineNumber", () => {
|
|
11
6
|
const testFilesDir = path.join(__dirname, "testFiles");
|
|
12
7
|
const createTestFile = (fileName, content) => {
|
|
13
8
|
const filePath = path.join(testFilesDir, fileName);
|
|
14
9
|
fs.writeFileSync(filePath, content);
|
|
15
10
|
return filePath;
|
|
16
11
|
};
|
|
17
|
-
|
|
12
|
+
beforeAll(() => {
|
|
18
13
|
if (!fs.existsSync(testFilesDir)) {
|
|
19
14
|
fs.mkdirSync(testFilesDir);
|
|
20
15
|
}
|
|
21
16
|
});
|
|
22
|
-
|
|
17
|
+
afterAll(() => {
|
|
23
18
|
fs.readdirSync(testFilesDir).forEach(file => fs.unlinkSync(path.join(testFilesDir, file)));
|
|
24
19
|
fs.rmdirSync(testFilesDir);
|
|
25
20
|
});
|
|
26
|
-
|
|
21
|
+
it("correctly identifies first line in a default exported named function", async () => {
|
|
27
22
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
28
23
|
EnhancedPlaywrightPage,
|
|
29
24
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -46,10 +41,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
46
41
|
return { done: "true", name: "custom name from api1" };
|
|
47
42
|
}
|
|
48
43
|
`);
|
|
49
|
-
const result = await (
|
|
50
|
-
|
|
44
|
+
const result = await getFirstLineNumber(filePath);
|
|
45
|
+
expect(result.lineNumber).toBe(4);
|
|
51
46
|
});
|
|
52
|
-
|
|
47
|
+
it("correctly identifies first line in a default exported anonymous function", async () => {
|
|
53
48
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
54
49
|
EnhancedPlaywrightPage,
|
|
55
50
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -72,10 +67,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
72
67
|
return { done: "true", name: "custom name from api1" };
|
|
73
68
|
}
|
|
74
69
|
`);
|
|
75
|
-
const result = await (
|
|
76
|
-
|
|
70
|
+
const result = await getFirstLineNumber(filePath);
|
|
71
|
+
expect(result.lineNumber).toBe(4);
|
|
77
72
|
});
|
|
78
|
-
|
|
73
|
+
it("correctly identifies first line in a default exported function identifier", async () => {
|
|
79
74
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
80
75
|
EnhancedPlaywrightPage,
|
|
81
76
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -99,10 +94,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
99
94
|
}
|
|
100
95
|
export default runApi;
|
|
101
96
|
`);
|
|
102
|
-
const result = await (
|
|
103
|
-
|
|
97
|
+
const result = await getFirstLineNumber(filePath);
|
|
98
|
+
expect(result.lineNumber).toBe(4);
|
|
104
99
|
});
|
|
105
|
-
|
|
100
|
+
it("correctly identifies first line in a file with multiple exports including a default function", async () => {
|
|
106
101
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
107
102
|
EnhancedPlaywrightPage,
|
|
108
103
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -126,10 +121,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
126
121
|
return { done: "true", name: "custom name from api1" };
|
|
127
122
|
}
|
|
128
123
|
export default runApi;`);
|
|
129
|
-
const result = await (
|
|
130
|
-
|
|
124
|
+
const result = await getFirstLineNumber(filePath);
|
|
125
|
+
expect(result.lineNumber).toBe(7);
|
|
131
126
|
});
|
|
132
|
-
|
|
127
|
+
it("correctly identifies first line in a default exported arrow function identifier", async () => {
|
|
133
128
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
134
129
|
EnhancedPlaywrightPage,
|
|
135
130
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -152,10 +147,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
152
147
|
return { done: "true", name: "custom name from api1" };
|
|
153
148
|
}
|
|
154
149
|
export default runApi;`);
|
|
155
|
-
const result = await (
|
|
156
|
-
|
|
150
|
+
const result = await getFirstLineNumber(filePath);
|
|
151
|
+
expect(result.lineNumber).toBe(4);
|
|
157
152
|
});
|
|
158
|
-
|
|
153
|
+
it("correctly identifies first line in a default exported anonymous arrow function", async () => {
|
|
159
154
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
160
155
|
EnhancedPlaywrightPage,
|
|
161
156
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -177,52 +172,52 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
177
172
|
await page.getByLabel("Search Wikipedia").press("Enter");
|
|
178
173
|
return { done: "true", name: "custom name from api1" };
|
|
179
174
|
};`);
|
|
180
|
-
const result = await (
|
|
181
|
-
|
|
175
|
+
const result = await getFirstLineNumber(filePath);
|
|
176
|
+
expect(result.lineNumber).toBe(4);
|
|
182
177
|
});
|
|
183
|
-
|
|
178
|
+
it("identifies first executable line in a default exported arrow function", async () => {
|
|
184
179
|
const filePath = createTestFile("defaultArrowFunction.ts", `export default () => {
|
|
185
180
|
console.log("Hello, Arrow World!");
|
|
186
181
|
};`);
|
|
187
|
-
const result = await (
|
|
188
|
-
|
|
182
|
+
const result = await getFirstLineNumber(filePath);
|
|
183
|
+
expect(result.lineNumber).toBe(4);
|
|
189
184
|
});
|
|
190
|
-
|
|
185
|
+
it("identifies first executable line within nested functions of a default export", async () => {
|
|
191
186
|
const filePath = createTestFile("nestedFunctions.ts", `const x = 4;
|
|
192
187
|
export default function() {
|
|
193
188
|
const nested = (x) => console.log("Nested function call");
|
|
194
189
|
nested(x);
|
|
195
190
|
}`);
|
|
196
|
-
const result = await (
|
|
197
|
-
|
|
191
|
+
const result = await getFirstLineNumber(filePath);
|
|
192
|
+
expect(result.lineNumber).toBe(5);
|
|
198
193
|
});
|
|
199
|
-
|
|
194
|
+
it("handles async default exported function correctly", async () => {
|
|
200
195
|
const filePath = createTestFile("asyncDefaultFunction.ts", `export default async function() {
|
|
201
196
|
await Promise.resolve(console.log("Async Hello, World!"));
|
|
202
197
|
}`);
|
|
203
|
-
const result = await (
|
|
204
|
-
|
|
198
|
+
const result = await getFirstLineNumber(filePath);
|
|
199
|
+
expect(result.lineNumber).toBe(4);
|
|
205
200
|
});
|
|
206
|
-
|
|
201
|
+
it("returns -1 for a default exported class", async () => {
|
|
207
202
|
const filePath = createTestFile("defaultClass.ts", `export default class MyClass {
|
|
208
203
|
constructor() {}
|
|
209
204
|
}`);
|
|
210
|
-
const result = await (
|
|
211
|
-
|
|
205
|
+
const result = await getFirstLineNumber(filePath);
|
|
206
|
+
expect(result.lineNumber).toBe(-1);
|
|
212
207
|
});
|
|
213
|
-
|
|
208
|
+
it("returns -1 for a default exported variable", async () => {
|
|
214
209
|
const filePath = createTestFile("defaultVariable.ts", `export default 42;`);
|
|
215
|
-
const result = await (
|
|
216
|
-
|
|
210
|
+
const result = await getFirstLineNumber(filePath);
|
|
211
|
+
expect(result.lineNumber).toBe(-1);
|
|
217
212
|
});
|
|
218
|
-
|
|
213
|
+
it("returns -1 when there is no default export", async () => {
|
|
219
214
|
const filePath = createTestFile("noDefaultExport.ts", `export const foo = () => console.log("bar");`);
|
|
220
|
-
const result = await (
|
|
221
|
-
|
|
215
|
+
const result = await getFirstLineNumber(filePath);
|
|
216
|
+
expect(result.lineNumber).toBe(-1);
|
|
222
217
|
});
|
|
223
|
-
|
|
218
|
+
it("returns -1 for an empty file", async () => {
|
|
224
219
|
const filePath = createTestFile("emptyFile.ts", ``);
|
|
225
|
-
const result = await (
|
|
226
|
-
|
|
220
|
+
const result = await getFirstLineNumber(filePath);
|
|
221
|
+
expect(result.lineNumber).toBe(-1);
|
|
227
222
|
});
|
|
228
223
|
});
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.sendBreakPointOnToClient = void 0;
|
|
7
|
-
const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
|
|
1
|
+
export const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
|
|
8
2
|
console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
|
|
9
|
-
};
|
|
10
|
-
exports.sendBreakPointOnToClient = sendBreakPointOnToClient;
|
|
3
|
+
};
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getFullPathInProject = getFullPathInProject;
|
|
7
|
-
exports.listProjectFilesAndFolders = listProjectFilesAndFolders;
|
|
8
|
-
var path = _interopRequireWildcard(require("path"));
|
|
9
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
10
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
|
-
_dotenv.default.config();
|
|
15
|
-
function getFullPathInProject(...paths) {
|
|
1
|
+
import * as path from "path";
|
|
2
|
+
import * as fs from "fs-extra";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
dotenv.config();
|
|
5
|
+
export function getFullPathInProject(...paths) {
|
|
16
6
|
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
17
7
|
}
|
|
18
|
-
async function listProjectFilesAndFolders() {
|
|
8
|
+
export async function listProjectFilesAndFolders() {
|
|
19
9
|
const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
|
|
20
10
|
try {
|
|
21
11
|
const files = await fs.readdir(projectPath, {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.getSettings = getSettings;
|
|
7
|
-
var _fileUtils = require("./fileUtils");
|
|
8
|
-
var _settingsSchema = require("../../../common/settingsSchema");
|
|
9
|
-
var _fsExtra = require("fs-extra");
|
|
10
|
-
async function getSettings() {
|
|
11
|
-
const settingsFilePath = (0, _fileUtils.getFullPathInProject)("Intuned.json");
|
|
1
|
+
import { getFullPathInProject } from "./fileUtils";
|
|
2
|
+
import { settingsSchema } from "../../../common/settingsSchema";
|
|
3
|
+
import { readJSON } from "fs-extra";
|
|
4
|
+
export async function getSettings() {
|
|
5
|
+
const settingsFilePath = getFullPathInProject("Intuned.json");
|
|
12
6
|
console.log("loading settings");
|
|
13
|
-
const settings = await
|
|
7
|
+
const settings = await readJSON(settingsFilePath);
|
|
14
8
|
if (settings) {
|
|
15
|
-
const parsed =
|
|
9
|
+
const parsed = settingsSchema.safeParse(settings);
|
|
16
10
|
console.log(parsed);
|
|
17
11
|
if (parsed.success) {
|
|
18
12
|
return parsed.data;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.JSONUnixSocket = void 0;
|
|
7
|
-
class JSONUnixSocket {
|
|
1
|
+
export class JSONUnixSocket {
|
|
8
2
|
static LENGTH_HEADER_LENGTH = 4;
|
|
9
3
|
constructor(socket) {
|
|
10
4
|
this.socket = socket;
|
|
@@ -41,5 +35,4 @@ class JSONUnixSocket {
|
|
|
41
35
|
yield JSON.parse(data.toString());
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
}
|
|
45
|
-
exports.JSONUnixSocket = JSONUnixSocket;
|
|
38
|
+
}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.moveWebTemplateFiles = void 0;
|
|
7
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
|
-
var path = _interopRequireWildcard(require("path"));
|
|
9
|
-
var _fileUtils = require("./fileUtils");
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
const moveWebTemplateFiles = async () => {
|
|
1
|
+
import * as fs from "fs-extra";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import { getFullPathInProject, listProjectFilesAndFolders } from "./fileUtils";
|
|
4
|
+
export const moveWebTemplateFiles = async () => {
|
|
13
5
|
await fs.remove("./intuned");
|
|
14
6
|
await fs.ensureDir("./intuned");
|
|
15
7
|
const currentFileLocation = path.resolve(__dirname, "..", "..", "..", "..", "WebTemplate");
|
|
@@ -21,11 +13,10 @@ const moveWebTemplateFiles = async () => {
|
|
|
21
13
|
return true;
|
|
22
14
|
}
|
|
23
15
|
});
|
|
24
|
-
const filesAndFolders = await
|
|
25
|
-
const pathsIgnoreList = [
|
|
16
|
+
const filesAndFolders = await listProjectFilesAndFolders();
|
|
17
|
+
const pathsIgnoreList = [getFullPathInProject("intuned"), getFullPathInProject("node_modules"), getFullPathInProject("package.json"), getFullPathInProject("yarn.lock"), getFullPathInProject(".env")];
|
|
26
18
|
const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
|
|
27
19
|
for (const file of filesToCopy) {
|
|
28
20
|
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
29
21
|
}
|
|
30
|
-
};
|
|
31
|
-
exports.moveWebTemplateFiles = moveWebTemplateFiles;
|
|
22
|
+
};
|
|
@@ -1,45 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
context: _zod.default.object({
|
|
21
|
-
jobId: _zod.default.string().optional(),
|
|
22
|
-
jobRunId: _zod.default.string().optional(),
|
|
23
|
-
runId: _zod.default.string().optional(),
|
|
24
|
-
queueId: _zod.default.string().optional()
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
import { runWithContext } from "../../common/asyncLocalStorage";
|
|
5
|
+
import * as net from "net";
|
|
6
|
+
import z from "zod";
|
|
7
|
+
import { runApiGenerator, runApiParametersSchema } from "../../common/runApi";
|
|
8
|
+
import { RunEnvironment } from "src/runtime/enums";
|
|
9
|
+
import { JSONUnixSocket } from "../common/utils/unixSocket";
|
|
10
|
+
import { setTimeout } from "timers/promises";
|
|
11
|
+
const startRunApiSchema = z.object({
|
|
12
|
+
type: z.literal("start"),
|
|
13
|
+
parameters: runApiParametersSchema.extend({
|
|
14
|
+
retrieveSession: z.boolean(),
|
|
15
|
+
context: z.object({
|
|
16
|
+
jobId: z.string().optional(),
|
|
17
|
+
jobRunId: z.string().optional(),
|
|
18
|
+
runId: z.string().optional(),
|
|
19
|
+
queueId: z.string().optional()
|
|
25
20
|
}).optional()
|
|
26
21
|
})
|
|
27
22
|
});
|
|
28
|
-
const nextRunApiSchema =
|
|
29
|
-
type:
|
|
30
|
-
parameters:
|
|
31
|
-
value:
|
|
23
|
+
const nextRunApiSchema = z.object({
|
|
24
|
+
type: z.literal("next"),
|
|
25
|
+
parameters: z.object({
|
|
26
|
+
value: z.string()
|
|
32
27
|
})
|
|
33
28
|
});
|
|
34
|
-
const abortRunApiSchema =
|
|
35
|
-
type:
|
|
36
|
-
parameters:
|
|
29
|
+
const abortRunApiSchema = z.object({
|
|
30
|
+
type: z.literal("abort"),
|
|
31
|
+
parameters: z.object({}).optional()
|
|
37
32
|
});
|
|
38
|
-
const inputSchema =
|
|
39
|
-
|
|
33
|
+
const inputSchema = z.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema]);
|
|
34
|
+
dotenv.config({
|
|
40
35
|
path: `.env`
|
|
41
36
|
});
|
|
42
|
-
|
|
37
|
+
program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
|
|
43
38
|
let context;
|
|
44
39
|
const throttleTime = 1_000;
|
|
45
40
|
let timeoutTimestamp = Date.now();
|
|
@@ -63,10 +58,10 @@ _commander.program.description("run user automation and communicate using unix s
|
|
|
63
58
|
client.end();
|
|
64
59
|
process.exit(1);
|
|
65
60
|
});
|
|
66
|
-
const jsonUnixSocket = new
|
|
61
|
+
const jsonUnixSocket = new JSONUnixSocket(client);
|
|
67
62
|
async function runGeneratorAndSendResult(next) {
|
|
68
63
|
if (!generator) return;
|
|
69
|
-
const result = await
|
|
64
|
+
const result = await runWithContext(context, () => generator.next(next));
|
|
70
65
|
if (result.done) {
|
|
71
66
|
const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
|
|
72
67
|
const success = result.value.isOk();
|
|
@@ -104,7 +99,7 @@ _commander.program.description("run user automation and communicate using unix s
|
|
|
104
99
|
const input = inputParseResult.data;
|
|
105
100
|
if (input.type === "abort") {
|
|
106
101
|
abortController.abort();
|
|
107
|
-
await
|
|
102
|
+
await setTimeout(10);
|
|
108
103
|
jsonUnixSocket.sendJSON({
|
|
109
104
|
type: "done",
|
|
110
105
|
result: null
|
|
@@ -112,14 +107,14 @@ _commander.program.description("run user automation and communicate using unix s
|
|
|
112
107
|
break;
|
|
113
108
|
}
|
|
114
109
|
if (input.type === "start") {
|
|
115
|
-
const gen =
|
|
110
|
+
const gen = runApiGenerator({
|
|
116
111
|
...input.parameters,
|
|
117
112
|
abortSignal: abortController.signal
|
|
118
113
|
});
|
|
119
114
|
generator = gen;
|
|
120
115
|
context = {
|
|
121
116
|
extendedPayloads: [],
|
|
122
|
-
runEnvironment: input.parameters.runOptions.environment === "deployed" ?
|
|
117
|
+
runEnvironment: input.parameters.runOptions.environment === "deployed" ? RunEnvironment.DEPLOYED : RunEnvironment.IDE,
|
|
123
118
|
timeoutInfo: {
|
|
124
119
|
extendTimeoutCallback: async () => {
|
|
125
120
|
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
@@ -149,7 +144,7 @@ _commander.program.description("run user automation and communicate using unix s
|
|
|
149
144
|
}
|
|
150
145
|
process.exit(0);
|
|
151
146
|
});
|
|
152
|
-
|
|
147
|
+
program.parse(process.argv);
|
|
153
148
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
154
149
|
if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
|
|
155
150
|
const proxy = runOptions.proxy;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
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); }
|
|
10
|
-
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; }
|
|
11
|
-
_commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
|
|
12
|
-
await (0, _webTemplate.moveWebTemplateFiles)();
|
|
2
|
+
import * as ts from "typescript";
|
|
3
|
+
import { program } from "commander";
|
|
4
|
+
import * as fs from "fs-extra";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
import { moveWebTemplateFiles } from "./common/utils/webTemplate";
|
|
7
|
+
program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
|
|
8
|
+
await moveWebTemplateFiles();
|
|
13
9
|
const templateTsConfig = path.resolve(__dirname, "..", "..", "template.tsconfig.json");
|
|
14
10
|
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
15
11
|
checkTypes();
|
|
@@ -51,4 +47,4 @@ function checkTypes() {
|
|
|
51
47
|
process.exit(1);
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
|
|
50
|
+
program.parse(process.argv);
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.logger = void 0;
|
|
7
|
-
var _nodeUtil = require("node:util");
|
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const format = _nodeUtil.formatWithOptions.bind(undefined, {
|
|
1
|
+
import { formatWithOptions } from "node:util";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const format = formatWithOptions.bind(undefined, {
|
|
11
4
|
colors: true
|
|
12
5
|
});
|
|
13
6
|
const LOG_LEVEL_COLORS = {
|
|
14
|
-
TRACE:
|
|
15
|
-
DEBUG:
|
|
16
|
-
INFO:
|
|
17
|
-
WARN:
|
|
18
|
-
ERROR:
|
|
7
|
+
TRACE: chalk.gray,
|
|
8
|
+
DEBUG: chalk.blue,
|
|
9
|
+
INFO: chalk.green,
|
|
10
|
+
WARN: chalk.yellow,
|
|
11
|
+
ERROR: chalk.red
|
|
19
12
|
};
|
|
20
13
|
class Logger {
|
|
21
14
|
logFunction(entry) {
|
|
@@ -57,4 +50,4 @@ class Logger {
|
|
|
57
50
|
this.log("ERROR", message, meta);
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
|
-
const logger =
|
|
53
|
+
export const logger = new Logger();
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.logger = void 0;
|
|
7
|
-
var _nodeUtil = require("node:util");
|
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
const format = _nodeUtil.formatWithOptions.bind(undefined, {
|
|
1
|
+
import { formatWithOptions } from "node:util";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const format = formatWithOptions.bind(undefined, {
|
|
11
4
|
colors: true
|
|
12
5
|
});
|
|
13
6
|
const LOG_LEVEL_COLORS = {
|
|
14
|
-
TRACE:
|
|
15
|
-
DEBUG:
|
|
16
|
-
INFO:
|
|
17
|
-
WARN:
|
|
18
|
-
ERROR:
|
|
7
|
+
TRACE: chalk.gray,
|
|
8
|
+
DEBUG: chalk.blue,
|
|
9
|
+
INFO: chalk.green,
|
|
10
|
+
WARN: chalk.yellow,
|
|
11
|
+
ERROR: chalk.red
|
|
19
12
|
};
|
|
20
13
|
class Logger {
|
|
21
14
|
logFunction(entry) {
|
|
@@ -57,4 +50,4 @@ class Logger {
|
|
|
57
50
|
this.log("ERROR", message, meta);
|
|
58
51
|
}
|
|
59
52
|
}
|
|
60
|
-
const logger =
|
|
53
|
+
export const logger = new Logger();
|