@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +1 -2
- package/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +14 -12
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +53 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +109 -170
- package/dist/commands/auth-sessions/load.js +28 -26
- package/dist/commands/auth-sessions/run-check.js +54 -53
- package/dist/commands/auth-sessions/run-create.js +93 -96
- package/dist/commands/browser/save-state.js +14 -16
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/build.js +79 -109
- package/dist/commands/common/browserUtils.js +53 -51
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
- package/dist/commands/common/sendMessageToClient.js +9 -4
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +18 -0
- package/dist/commands/common/utils/fileUtils.js +32 -22
- package/dist/commands/common/utils/settings.js +27 -19
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/webTemplate.js +30 -28
- package/dist/commands/interface/run.js +162 -139
- package/dist/commands/ts-check.js +50 -50
- package/dist/common/Logger/Logger/index.js +55 -42
- package/dist/common/Logger/Logger/types.js +5 -1
- package/dist/common/Logger/index.js +55 -42
- package/dist/common/Logger/types.js +5 -1
- package/dist/common/asyncLocalStorage/index.js +16 -8
- package/dist/common/cleanEnvironmentVariables.js +16 -12
- package/dist/common/constants.js +7 -1
- package/dist/common/contextStorageStateHelpers.js +47 -38
- package/dist/common/getPlaywrightConstructs.js +178 -197
- package/dist/common/jwtTokenManager.js +76 -79
- package/dist/common/runApi/errors.js +159 -150
- package/dist/common/runApi/index.js +240 -232
- package/dist/common/runApi/types.d.ts +19 -5
- package/dist/common/runApi/types.js +53 -56
- package/dist/common/settingsSchema.js +15 -10
- package/dist/common/telemetry.js +28 -30
- package/dist/index.js +69 -4
- package/dist/runtime/RunError.js +18 -11
- package/dist/runtime/downloadDirectory.js +19 -13
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +18 -12
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +21 -15
- package/dist/runtime/extendTimeout.js +28 -21
- package/dist/runtime/index.js +53 -6
- package/dist/runtime/requestMoreInfo.js +23 -16
- package/dist/runtime/runInfo.js +21 -14
- package/package.json +4 -7
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -79
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -23
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -51
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/Logger/types.ts +0 -1
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/Logger/types.ts +0 -1
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -182
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/executionHelpers.test.ts +0 -51
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
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");
|
|
3
10
|
function compileTypeScript(apiFilePath) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const compilerOptions = {
|
|
12
|
+
lib: ["dom", "es2020"],
|
|
13
|
+
sourceMap: true,
|
|
14
|
+
inlineSourceMap: true,
|
|
15
|
+
inlineSources: true,
|
|
16
|
+
declaration: false,
|
|
17
|
+
noEmit: false,
|
|
18
|
+
module: _tsMorph.ModuleKind.CommonJS,
|
|
19
|
+
target: _tsMorph.ScriptTarget.ES2020
|
|
20
|
+
};
|
|
21
|
+
const project = new _tsMorph.Project({
|
|
22
|
+
compilerOptions
|
|
23
|
+
});
|
|
24
|
+
const sourceFile = project.addSourceFileAtPath(apiFilePath);
|
|
25
|
+
const outputJS = project.emitToMemory({
|
|
26
|
+
targetSourceFile: sourceFile
|
|
27
|
+
});
|
|
28
|
+
const outputJSText = outputJS.getFiles()[0].text;
|
|
29
|
+
return {
|
|
30
|
+
sourceFile,
|
|
31
|
+
outputJSText
|
|
32
|
+
};
|
|
21
33
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
function findFirstExecutableLine(sourceFile) {
|
|
35
|
+
var _defaultExportSymbol$;
|
|
36
|
+
let functionBody;
|
|
37
|
+
const defaultExportSymbol = sourceFile.getDefaultExportSymbol();
|
|
38
|
+
const defaultExportDeclaration = defaultExportSymbol === null || defaultExportSymbol === void 0 || (_defaultExportSymbol$ = defaultExportSymbol.getDeclarations()) === null || _defaultExportSymbol$ === void 0 ? void 0 : _defaultExportSymbol$[0];
|
|
39
|
+
if (defaultExportDeclaration) {
|
|
40
|
+
if (defaultExportDeclaration.getKind() === _tsMorph.ts.SyntaxKind.FunctionDeclaration) {
|
|
41
|
+
functionBody = defaultExportDeclaration.getBody();
|
|
42
|
+
} else {
|
|
43
|
+
const exportAssignments = sourceFile.getExportAssignments();
|
|
44
|
+
for (const exportAssignment of exportAssignments) {
|
|
45
|
+
const expression = exportAssignment.getExpression();
|
|
46
|
+
if (!expression) continue;
|
|
47
|
+
if (expression.getKind() === _tsMorph.ts.SyntaxKind.Identifier || expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction) {
|
|
48
|
+
var _sourceFile$getVariab;
|
|
49
|
+
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() === _tsMorph.ts.SyntaxKind.FunctionExpression || node.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction));
|
|
51
|
+
if (possiblyExportedFunction) {
|
|
52
|
+
functionBody = possiblyExportedFunction.getBody();
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
31
55
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
for (const exportAssignment of exportAssignments) {
|
|
36
|
-
const expression = exportAssignment.getExpression();
|
|
37
|
-
if (!expression)
|
|
38
|
-
continue;
|
|
39
|
-
if (expression.getKind() === ts.SyntaxKind.Identifier ||
|
|
40
|
-
expression.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
41
|
-
expression.getKind() === ts.SyntaxKind.ArrowFunction) {
|
|
42
|
-
const identifier = expression.getText();
|
|
43
|
-
const possiblyExportedFunction = sourceFile.getFunction(identifier) ||
|
|
44
|
-
sourceFile
|
|
45
|
-
.getVariableStatement(identifier)
|
|
46
|
-
?.getDescendants()
|
|
47
|
-
.find((node) => node.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
48
|
-
node.getKind() === ts.SyntaxKind.ArrowFunction);
|
|
49
|
-
if (possiblyExportedFunction) {
|
|
50
|
-
functionBody = possiblyExportedFunction.getBody();
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (Node.hasBody(expression) &&
|
|
55
|
-
(expression.getKind() === ts.SyntaxKind.FunctionExpression ||
|
|
56
|
-
expression.getKind() === ts.SyntaxKind.ArrowFunction)) {
|
|
57
|
-
// As these are anonymous, we directly access their body
|
|
58
|
-
functionBody = expression.getBody();
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
56
|
+
if (_tsMorph.Node.hasBody(expression) && (expression.getKind() === _tsMorph.ts.SyntaxKind.FunctionExpression || expression.getKind() === _tsMorph.ts.SyntaxKind.ArrowFunction)) {
|
|
57
|
+
functionBody = expression.getBody();
|
|
58
|
+
break;
|
|
62
59
|
}
|
|
60
|
+
}
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
}
|
|
63
|
+
if (!functionBody || !_tsMorph.Node.isStatemented(functionBody)) {
|
|
64
|
+
return -1;
|
|
65
|
+
}
|
|
66
|
+
if (functionBody.getStatements().length === 0) {
|
|
67
|
+
return -1;
|
|
68
|
+
}
|
|
69
|
+
const position = functionBody.getStatements()[0].getStart();
|
|
70
|
+
return sourceFile.getLineAndColumnAtPos(position);
|
|
72
71
|
}
|
|
73
72
|
async function getSourceMap(jsCode) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return new SourceMapConsumer(sourceMap);
|
|
73
|
+
const sourceMapBase64 = jsCode.substring(jsCode.lastIndexOf("//# sourceMappingURL=data:application/json;base64,") + "//# sourceMappingURL=data:application/json;base64,".length);
|
|
74
|
+
const sourceMapText = Buffer.from(sourceMapBase64, "base64").toString("utf-8");
|
|
75
|
+
const sourceMap = JSON.parse(sourceMapText);
|
|
76
|
+
return new _sourceMap.SourceMapConsumer(sourceMap);
|
|
79
77
|
}
|
|
80
78
|
async function mapFirstLineNumberBySourceMap(sourceFileName, jsCode, line, column) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return generatedLineNumber;
|
|
90
|
-
}
|
|
91
|
-
export default async function getFirstLineNumber(apiFilePath) {
|
|
92
|
-
const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
|
|
93
|
-
// Compile TypeScript to JavaScript and get the Typescript AST
|
|
94
|
-
const { sourceFile, outputJSText } = compileTypeScript(apiFilePath);
|
|
95
|
-
// Find the first line of code in the default export ts code
|
|
96
|
-
const result = findFirstExecutableLine(sourceFile);
|
|
97
|
-
if (result === -1)
|
|
98
|
-
return { sourceFileName, lineNumber: -1 };
|
|
99
|
-
return {
|
|
100
|
-
sourceFileName,
|
|
101
|
-
lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column),
|
|
102
|
-
};
|
|
79
|
+
const sourceMap = await getSourceMap(jsCode);
|
|
80
|
+
const generatedLineNumber = sourceMap.generatedPositionFor({
|
|
81
|
+
source: sourceFileName,
|
|
82
|
+
line,
|
|
83
|
+
column
|
|
84
|
+
}).line;
|
|
85
|
+
if (!generatedLineNumber) return -1;
|
|
86
|
+
return generatedLineNumber;
|
|
103
87
|
}
|
|
88
|
+
async function getFirstLineNumber(apiFilePath) {
|
|
89
|
+
const sourceFileName = apiFilePath.split("/").pop() ?? apiFilePath;
|
|
90
|
+
const {
|
|
91
|
+
sourceFile,
|
|
92
|
+
outputJSText
|
|
93
|
+
} = compileTypeScript(apiFilePath);
|
|
94
|
+
const result = findFirstExecutableLine(sourceFile);
|
|
95
|
+
if (result === -1) return {
|
|
96
|
+
sourceFileName,
|
|
97
|
+
lineNumber: -1
|
|
98
|
+
};
|
|
99
|
+
return {
|
|
100
|
+
sourceFileName,
|
|
101
|
+
lineNumber: await mapFirstLineNumberBySourceMap(sourceFileName, outputJSText, result.line, result.column)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _getFirstLineNumber = _interopRequireDefault(require("./getFirstLineNumber.js"));
|
|
5
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
6
|
+
var path = _interopRequireWildcard(require("path"));
|
|
7
|
+
var _url = require("url");
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
(0, _vitest.describe)("getFirstLineNumber", () => {
|
|
12
|
+
const testFilesDir = path.join(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "testFiles");
|
|
8
13
|
const createTestFile = (fileName, content) => {
|
|
9
14
|
const filePath = path.join(testFilesDir, fileName);
|
|
10
15
|
fs.writeFileSync(filePath, content);
|
|
11
16
|
return filePath;
|
|
12
17
|
};
|
|
13
|
-
beforeAll(() => {
|
|
18
|
+
(0, _vitest.beforeAll)(() => {
|
|
14
19
|
if (!fs.existsSync(testFilesDir)) {
|
|
15
20
|
fs.mkdirSync(testFilesDir);
|
|
16
21
|
}
|
|
17
22
|
});
|
|
18
|
-
afterAll(() => {
|
|
23
|
+
(0, _vitest.afterAll)(() => {
|
|
19
24
|
fs.readdirSync(testFilesDir).forEach(file => fs.unlinkSync(path.join(testFilesDir, file)));
|
|
20
25
|
fs.rmdirSync(testFilesDir);
|
|
21
26
|
});
|
|
22
|
-
it("correctly identifies first line in a default exported named function", async () => {
|
|
27
|
+
(0, _vitest.it)("correctly identifies first line in a default exported named function", async () => {
|
|
23
28
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
24
29
|
EnhancedPlaywrightPage,
|
|
25
30
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -42,10 +47,10 @@ describe("getFirstLineNumber", () => {
|
|
|
42
47
|
return { done: "true", name: "custom name from api1" };
|
|
43
48
|
}
|
|
44
49
|
`);
|
|
45
|
-
const result = await
|
|
46
|
-
expect(result.lineNumber).toBe(4);
|
|
50
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
51
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
47
52
|
});
|
|
48
|
-
it("correctly identifies first line in a default exported anonymous function", async () => {
|
|
53
|
+
(0, _vitest.it)("correctly identifies first line in a default exported anonymous function", async () => {
|
|
49
54
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
50
55
|
EnhancedPlaywrightPage,
|
|
51
56
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -68,10 +73,10 @@ describe("getFirstLineNumber", () => {
|
|
|
68
73
|
return { done: "true", name: "custom name from api1" };
|
|
69
74
|
}
|
|
70
75
|
`);
|
|
71
|
-
const result = await
|
|
72
|
-
expect(result.lineNumber).toBe(4);
|
|
76
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
77
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
73
78
|
});
|
|
74
|
-
it("correctly identifies first line in a default exported function identifier", async () => {
|
|
79
|
+
(0, _vitest.it)("correctly identifies first line in a default exported function identifier", async () => {
|
|
75
80
|
const filePath = createTestFile("defaultFunction.ts", `import {
|
|
76
81
|
EnhancedPlaywrightPage,
|
|
77
82
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -95,10 +100,10 @@ describe("getFirstLineNumber", () => {
|
|
|
95
100
|
}
|
|
96
101
|
export default runApi;
|
|
97
102
|
`);
|
|
98
|
-
const result = await
|
|
99
|
-
expect(result.lineNumber).toBe(4);
|
|
103
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
104
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
100
105
|
});
|
|
101
|
-
it("correctly identifies first line in a file with multiple exports including a default function", async () => {
|
|
106
|
+
(0, _vitest.it)("correctly identifies first line in a file with multiple exports including a default function", async () => {
|
|
102
107
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
103
108
|
EnhancedPlaywrightPage,
|
|
104
109
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -122,10 +127,10 @@ describe("getFirstLineNumber", () => {
|
|
|
122
127
|
return { done: "true", name: "custom name from api1" };
|
|
123
128
|
}
|
|
124
129
|
export default runApi;`);
|
|
125
|
-
const result = await
|
|
126
|
-
expect(result.lineNumber).toBe(7);
|
|
130
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
131
|
+
(0, _vitest.expect)(result.lineNumber).toBe(7);
|
|
127
132
|
});
|
|
128
|
-
it("correctly identifies first line in a default exported arrow function identifier", async () => {
|
|
133
|
+
(0, _vitest.it)("correctly identifies first line in a default exported arrow function identifier", async () => {
|
|
129
134
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
130
135
|
EnhancedPlaywrightPage,
|
|
131
136
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -148,10 +153,10 @@ describe("getFirstLineNumber", () => {
|
|
|
148
153
|
return { done: "true", name: "custom name from api1" };
|
|
149
154
|
}
|
|
150
155
|
export default runApi;`);
|
|
151
|
-
const result = await
|
|
152
|
-
expect(result.lineNumber).toBe(4);
|
|
156
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
157
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
153
158
|
});
|
|
154
|
-
it("correctly identifies first line in a default exported anonymous arrow function", async () => {
|
|
159
|
+
(0, _vitest.it)("correctly identifies first line in a default exported anonymous arrow function", async () => {
|
|
155
160
|
const filePath = createTestFile("multipleExports.ts", `import {
|
|
156
161
|
EnhancedPlaywrightPage,
|
|
157
162
|
EnhancedPlaywrightBrowserContext,
|
|
@@ -173,52 +178,52 @@ describe("getFirstLineNumber", () => {
|
|
|
173
178
|
await page.getByLabel("Search Wikipedia").press("Enter");
|
|
174
179
|
return { done: "true", name: "custom name from api1" };
|
|
175
180
|
};`);
|
|
176
|
-
const result = await
|
|
177
|
-
expect(result.lineNumber).toBe(4);
|
|
181
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
182
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
178
183
|
});
|
|
179
|
-
it("identifies first executable line in a default exported arrow function", async () => {
|
|
184
|
+
(0, _vitest.it)("identifies first executable line in a default exported arrow function", async () => {
|
|
180
185
|
const filePath = createTestFile("defaultArrowFunction.ts", `export default () => {
|
|
181
186
|
console.log("Hello, Arrow World!");
|
|
182
187
|
};`);
|
|
183
|
-
const result = await
|
|
184
|
-
expect(result.lineNumber).toBe(4);
|
|
188
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
189
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
185
190
|
});
|
|
186
|
-
it("identifies first executable line within nested functions of a default export", async () => {
|
|
191
|
+
(0, _vitest.it)("identifies first executable line within nested functions of a default export", async () => {
|
|
187
192
|
const filePath = createTestFile("nestedFunctions.ts", `const x = 4;
|
|
188
193
|
export default function() {
|
|
189
194
|
const nested = (x) => console.log("Nested function call");
|
|
190
195
|
nested(x);
|
|
191
196
|
}`);
|
|
192
|
-
const result = await
|
|
193
|
-
expect(result.lineNumber).toBe(5);
|
|
197
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
198
|
+
(0, _vitest.expect)(result.lineNumber).toBe(5);
|
|
194
199
|
});
|
|
195
|
-
it("handles async default exported function correctly", async () => {
|
|
200
|
+
(0, _vitest.it)("handles async default exported function correctly", async () => {
|
|
196
201
|
const filePath = createTestFile("asyncDefaultFunction.ts", `export default async function() {
|
|
197
202
|
await Promise.resolve(console.log("Async Hello, World!"));
|
|
198
203
|
}`);
|
|
199
|
-
const result = await
|
|
200
|
-
expect(result.lineNumber).toBe(4);
|
|
204
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
205
|
+
(0, _vitest.expect)(result.lineNumber).toBe(4);
|
|
201
206
|
});
|
|
202
|
-
it("returns -1 for a default exported class", async () => {
|
|
207
|
+
(0, _vitest.it)("returns -1 for a default exported class", async () => {
|
|
203
208
|
const filePath = createTestFile("defaultClass.ts", `export default class MyClass {
|
|
204
209
|
constructor() {}
|
|
205
210
|
}`);
|
|
206
|
-
const result = await
|
|
207
|
-
expect(result.lineNumber).toBe(-1);
|
|
211
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
212
|
+
(0, _vitest.expect)(result.lineNumber).toBe(-1);
|
|
208
213
|
});
|
|
209
|
-
it("returns -1 for a default exported variable", async () => {
|
|
214
|
+
(0, _vitest.it)("returns -1 for a default exported variable", async () => {
|
|
210
215
|
const filePath = createTestFile("defaultVariable.ts", `export default 42;`);
|
|
211
|
-
const result = await
|
|
212
|
-
expect(result.lineNumber).toBe(-1);
|
|
216
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
217
|
+
(0, _vitest.expect)(result.lineNumber).toBe(-1);
|
|
213
218
|
});
|
|
214
|
-
it("returns -1 when there is no default export", async () => {
|
|
219
|
+
(0, _vitest.it)("returns -1 when there is no default export", async () => {
|
|
215
220
|
const filePath = createTestFile("noDefaultExport.ts", `export const foo = () => console.log("bar");`);
|
|
216
|
-
const result = await
|
|
217
|
-
expect(result.lineNumber).toBe(-1);
|
|
221
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
222
|
+
(0, _vitest.expect)(result.lineNumber).toBe(-1);
|
|
218
223
|
});
|
|
219
|
-
it("returns -1 for an empty file", async () => {
|
|
224
|
+
(0, _vitest.it)("returns -1 for an empty file", async () => {
|
|
220
225
|
const filePath = createTestFile("emptyFile.ts", ``);
|
|
221
|
-
const result = await
|
|
222
|
-
expect(result.lineNumber).toBe(-1);
|
|
226
|
+
const result = await (0, _getFirstLineNumber.default)(filePath);
|
|
227
|
+
(0, _vitest.expect)(result.lineNumber).toBe(-1);
|
|
223
228
|
});
|
|
224
229
|
});
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sendBreakPointOnToClient = void 0;
|
|
7
|
+
const sendBreakPointOnToClient = (sourceFileName, lineNumber) => {
|
|
8
|
+
console.log(`breakpoint on ${sourceFileName}:${lineNumber}`);
|
|
5
9
|
};
|
|
10
|
+
exports.sendBreakPointOnToClient = sendBreakPointOnToClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tsNodeImport(apiFilePath: string): Promise<any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tsNodeImport = tsNodeImport;
|
|
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
|
+
async function tsNodeImport(apiFilePath) {
|
|
10
|
+
require("ts-node").register({
|
|
11
|
+
transpileOnly: true,
|
|
12
|
+
compilerOptions: {
|
|
13
|
+
lib: ["dom", "es2020"]
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const imported = await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(apiFilePath);
|
|
17
|
+
return imported.default;
|
|
18
|
+
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
console.error("Error reading the directory:", err);
|
|
21
|
-
throw err;
|
|
22
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
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) {
|
|
16
|
+
return path.resolve(process.cwd(), process.env.ROOT || "./", ...paths);
|
|
23
17
|
}
|
|
18
|
+
async function listProjectFilesAndFolders() {
|
|
19
|
+
const projectPath = path.resolve(process.cwd(), process.env.ROOT || "./");
|
|
20
|
+
try {
|
|
21
|
+
const files = await fs.readdir(projectPath, {
|
|
22
|
+
withFileTypes: true
|
|
23
|
+
});
|
|
24
|
+
return files.map(file => ({
|
|
25
|
+
type: file.isDirectory() ? "Folder" : "File",
|
|
26
|
+
fullPath: path.join(projectPath, file.name),
|
|
27
|
+
name: file.name
|
|
28
|
+
}));
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.error("Error reading the directory:", err);
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSettings = getSettings;
|
|
7
|
+
var _fileUtils = require("./fileUtils.js");
|
|
8
|
+
var _settingsSchema = require("../../../common/settingsSchema");
|
|
9
|
+
var _fsExtra = require("fs-extra");
|
|
10
|
+
async function getSettings() {
|
|
11
|
+
const settingsFilePath = (0, _fileUtils.getFullPathInProject)("Intuned.json");
|
|
12
|
+
console.log("loading settings");
|
|
13
|
+
const settings = await (0, _fsExtra.readJSON)(settingsFilePath);
|
|
14
|
+
if (settings) {
|
|
15
|
+
const parsed = _settingsSchema.settingsSchema.safeParse(settings);
|
|
16
|
+
console.log(parsed);
|
|
17
|
+
if (parsed.success) {
|
|
18
|
+
return parsed.data;
|
|
19
|
+
} else {
|
|
20
|
+
throw new Error(parsed.error.message);
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
authSessions: {
|
|
25
|
+
enabled: false
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JSONUnixSocket = void 0;
|
|
7
|
+
class JSONUnixSocket {
|
|
8
|
+
static LENGTH_HEADER_LENGTH = 4;
|
|
9
|
+
constructor(socket) {
|
|
10
|
+
this.socket = socket;
|
|
11
|
+
}
|
|
12
|
+
sendJSON(data) {
|
|
13
|
+
const dataToSend = JSON.stringify(data);
|
|
14
|
+
const length = Buffer.byteLength(dataToSend);
|
|
15
|
+
const buffer = Buffer.alloc(JSONUnixSocket.LENGTH_HEADER_LENGTH + length);
|
|
16
|
+
buffer.writeUInt32BE(length, 0);
|
|
17
|
+
buffer.write(dataToSend, JSONUnixSocket.LENGTH_HEADER_LENGTH);
|
|
18
|
+
this.socket.write(buffer);
|
|
19
|
+
}
|
|
20
|
+
async *receiveJSON() {
|
|
21
|
+
let buffer = Buffer.alloc(0);
|
|
22
|
+
const endPromise = new Promise((resolve, reject) => {
|
|
23
|
+
this.socket.once("end", () => {
|
|
24
|
+
console.log("end");
|
|
25
|
+
resolve();
|
|
26
|
+
});
|
|
27
|
+
this.socket.once("error", reject);
|
|
28
|
+
});
|
|
29
|
+
while (true) {
|
|
30
|
+
const chunk = await Promise.race([new Promise(resolve => this.socket.once("data", data => resolve(data))), endPromise]);
|
|
31
|
+
if (!(chunk instanceof Buffer)) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
35
|
+
const length = buffer.readUInt32BE(0);
|
|
36
|
+
if (buffer.length < length + JSONUnixSocket.LENGTH_HEADER_LENGTH) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const data = buffer.subarray(JSONUnixSocket.LENGTH_HEADER_LENGTH, length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
|
|
40
|
+
buffer = buffer.subarray(length + JSONUnixSocket.LENGTH_HEADER_LENGTH);
|
|
41
|
+
yield JSON.parse(data.toString());
|
|
43
42
|
}
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
|
-
JSONUnixSocket
|
|
45
|
+
exports.JSONUnixSocket = JSONUnixSocket;
|