@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.
Files changed (114) hide show
  1. package/.babelrc +1 -2
  2. package/WebTemplate/api.ts +90 -92
  3. package/WebTemplate/controllers/authSessions/create.ts +2 -2
  4. package/WebTemplate/controllers/authSessions/store.ts +1 -1
  5. package/WebTemplate/controllers/runApi/helpers.ts +14 -12
  6. package/WebTemplate/index.playwright.ts +32 -42
  7. package/WebTemplate/jobs.ts +13 -2
  8. package/WebTemplate/utils.ts +53 -1
  9. package/api/test2.ts +6 -1
  10. package/auth-sessions/check.ts +3 -1
  11. package/auth-sessions/create.ts +10 -10
  12. package/bin/intuned-api-run +1 -1
  13. package/bin/intuned-auth-session-check +1 -1
  14. package/bin/intuned-auth-session-create +1 -1
  15. package/bin/intuned-auth-session-load +1 -1
  16. package/bin/intuned-auth-session-refresh +1 -1
  17. package/bin/intuned-browser-save-state +1 -1
  18. package/bin/intuned-browser-start +1 -1
  19. package/bin/intuned-build +1 -1
  20. package/bin/intuned-ts-check +1 -1
  21. package/dist/commands/api/run.js +109 -170
  22. package/dist/commands/auth-sessions/load.js +28 -26
  23. package/dist/commands/auth-sessions/run-check.js +54 -53
  24. package/dist/commands/auth-sessions/run-create.js +93 -96
  25. package/dist/commands/browser/save-state.js +14 -16
  26. package/dist/commands/browser/start-browser.js +11 -11
  27. package/dist/commands/build.js +79 -109
  28. package/dist/commands/common/browserUtils.js +53 -51
  29. package/dist/commands/common/getFirstLineNumber.js +93 -93
  30. package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
  31. package/dist/commands/common/sendMessageToClient.js +9 -4
  32. package/dist/commands/common/tsNodeImport.d.ts +1 -0
  33. package/dist/commands/common/tsNodeImport.js +18 -0
  34. package/dist/commands/common/utils/fileUtils.js +32 -22
  35. package/dist/commands/common/utils/settings.js +27 -19
  36. package/dist/commands/common/utils/unixSocket.js +43 -43
  37. package/dist/commands/common/utils/webTemplate.js +30 -28
  38. package/dist/commands/interface/run.js +162 -139
  39. package/dist/commands/ts-check.js +50 -50
  40. package/dist/common/Logger/Logger/index.js +55 -42
  41. package/dist/common/Logger/Logger/types.js +5 -1
  42. package/dist/common/Logger/index.js +55 -42
  43. package/dist/common/Logger/types.js +5 -1
  44. package/dist/common/asyncLocalStorage/index.js +16 -8
  45. package/dist/common/cleanEnvironmentVariables.js +16 -12
  46. package/dist/common/constants.js +7 -1
  47. package/dist/common/contextStorageStateHelpers.js +47 -38
  48. package/dist/common/getPlaywrightConstructs.js +178 -197
  49. package/dist/common/jwtTokenManager.js +76 -79
  50. package/dist/common/runApi/errors.js +159 -150
  51. package/dist/common/runApi/index.js +240 -232
  52. package/dist/common/runApi/types.d.ts +19 -5
  53. package/dist/common/runApi/types.js +53 -56
  54. package/dist/common/settingsSchema.js +15 -10
  55. package/dist/common/telemetry.js +28 -30
  56. package/dist/index.js +69 -4
  57. package/dist/runtime/RunError.js +18 -11
  58. package/dist/runtime/downloadDirectory.js +19 -13
  59. package/dist/runtime/enums.d.js +5 -0
  60. package/dist/runtime/enums.d.ts +11 -1
  61. package/dist/runtime/enums.js +18 -12
  62. package/dist/runtime/executionHelpers.test.js +53 -0
  63. package/dist/runtime/export.d.js +5 -0
  64. package/dist/runtime/export.d.ts +202 -1
  65. package/dist/runtime/extendPayload.js +21 -15
  66. package/dist/runtime/extendTimeout.js +28 -21
  67. package/dist/runtime/index.js +53 -6
  68. package/dist/runtime/requestMoreInfo.js +23 -16
  69. package/dist/runtime/runInfo.js +21 -14
  70. package/package.json +4 -7
  71. package/dist/commands/api/run.ts +0 -105
  72. package/dist/commands/auth-sessions/load.ts +0 -30
  73. package/dist/commands/auth-sessions/run-check.ts +0 -51
  74. package/dist/commands/auth-sessions/run-create.ts +0 -91
  75. package/dist/commands/browser/save-state.ts +0 -14
  76. package/dist/commands/browser/start-browser.ts +0 -11
  77. package/dist/commands/build.ts +0 -79
  78. package/dist/commands/common/browserUtils.ts +0 -45
  79. package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
  80. package/dist/commands/common/getDefaultExportFromFile.js +0 -12
  81. package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
  82. package/dist/commands/common/getFirstLineNumber.ts +0 -96
  83. package/dist/commands/common/sendMessageToClient.ts +0 -3
  84. package/dist/commands/common/utils/fileUtils.ts +0 -23
  85. package/dist/commands/common/utils/settings.ts +0 -22
  86. package/dist/commands/common/utils/unixSocket.ts +0 -38
  87. package/dist/commands/common/utils/webTemplate.ts +0 -23
  88. package/dist/commands/interface/run.ts +0 -156
  89. package/dist/commands/ts-check.ts +0 -51
  90. package/dist/common/Logger/Logger/index.ts +0 -53
  91. package/dist/common/Logger/Logger/types.ts +0 -1
  92. package/dist/common/Logger/index.ts +0 -53
  93. package/dist/common/Logger/types.ts +0 -1
  94. package/dist/common/asyncLocalStorage/index.ts +0 -9
  95. package/dist/common/cleanEnvironmentVariables.ts +0 -10
  96. package/dist/common/constants.ts +0 -1
  97. package/dist/common/contextStorageStateHelpers.ts +0 -43
  98. package/dist/common/getPlaywrightConstructs.ts +0 -182
  99. package/dist/common/jwtTokenManager.ts +0 -71
  100. package/dist/common/runApi/errors.ts +0 -154
  101. package/dist/common/runApi/index.ts +0 -253
  102. package/dist/common/runApi/types.ts +0 -43
  103. package/dist/common/settingsSchema.ts +0 -9
  104. package/dist/common/telemetry.ts +0 -23
  105. package/dist/index.ts +0 -4
  106. package/dist/runtime/RunError.ts +0 -12
  107. package/dist/runtime/downloadDirectory.ts +0 -13
  108. package/dist/runtime/enums.ts +0 -12
  109. package/dist/runtime/executionHelpers.test.ts +0 -51
  110. package/dist/runtime/extendPayload.ts +0 -15
  111. package/dist/runtime/extendTimeout.ts +0 -24
  112. package/dist/runtime/index.ts +0 -6
  113. package/dist/runtime/requestMoreInfo.ts +0 -18
  114. package/dist/runtime/runInfo.ts +0 -15
@@ -1,30 +1,32 @@
1
- import * as fs from "fs-extra";
2
- import * as path from "path";
3
- import { getFullPathInProject, listProjectFilesAndFolders, } from "./fileUtils.js";
4
- import { fileURLToPath } from "url";
5
- export const moveWebTemplateFiles = async () => {
6
- await fs.remove("./intuned");
7
- await fs.ensureDir("./intuned");
8
- const currentFileLocation = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..", "WebTemplate");
9
- // copy WebTemplate to ./intuned
10
- await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
11
- filter: (src, dest) => {
12
- if (src.includes(".d.ts")) {
13
- return false;
14
- }
15
- return true;
16
- },
17
- });
18
- const filesAndFolders = await listProjectFilesAndFolders();
19
- const pathsIgnoreList = [
20
- getFullPathInProject("intuned"),
21
- getFullPathInProject("node_modules"),
22
- getFullPathInProject("package.json"),
23
- getFullPathInProject("yarn.lock"),
24
- getFullPathInProject(".env"),
25
- ];
26
- const filesToCopy = filesAndFolders.filter((file) => !pathsIgnoreList.includes(file.fullPath));
27
- for (const file of filesToCopy) {
28
- await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.moveWebTemplateFiles = void 0;
7
+ var fs = _interopRequireWildcard(require("fs-extra"));
8
+ var path = _interopRequireWildcard(require("path"));
9
+ var _fileUtils = require("./fileUtils.js");
10
+ var _url = require("url");
11
+ 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); }
12
+ 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; }
13
+ const moveWebTemplateFiles = async () => {
14
+ await fs.remove("./intuned");
15
+ await fs.ensureDir("./intuned");
16
+ const currentFileLocation = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "..", "..", "WebTemplate");
17
+ await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
18
+ filter: (src, dest) => {
19
+ if (src.includes(".d.ts")) {
20
+ return false;
21
+ }
22
+ return true;
29
23
  }
24
+ });
25
+ const filesAndFolders = await (0, _fileUtils.listProjectFilesAndFolders)();
26
+ const pathsIgnoreList = [(0, _fileUtils.getFullPathInProject)("intuned"), (0, _fileUtils.getFullPathInProject)("node_modules"), (0, _fileUtils.getFullPathInProject)("package.json"), (0, _fileUtils.getFullPathInProject)("yarn.lock"), (0, _fileUtils.getFullPathInProject)(".env")];
27
+ const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
28
+ for (const file of filesToCopy) {
29
+ await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
30
+ }
30
31
  };
32
+ exports.moveWebTemplateFiles = moveWebTemplateFiles;
@@ -1,162 +1,185 @@
1
1
  #!/usr/bin/env node
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
16
- .object({
17
- jobId: z.string().optional(),
18
- jobRunId: z.string().optional(),
19
- runId: z.string().optional(),
20
- queueId: z.string().optional(),
21
- })
22
- .optional(),
23
- }),
2
+ "use strict";
3
+
4
+ var _commander = require("commander");
5
+ var _dotenv = _interopRequireDefault(require("dotenv"));
6
+ var _asyncLocalStorage = require("../../common/asyncLocalStorage");
7
+ var net = _interopRequireWildcard(require("net"));
8
+ var _zod = _interopRequireDefault(require("zod"));
9
+ var _runApi = require("../../common/runApi");
10
+ var _enums = require("src/runtime/enums");
11
+ var _unixSocket = require("../common/utils/unixSocket");
12
+ var _promises = require("timers/promises");
13
+ var _jwtTokenManager = require("src/common/jwtTokenManager");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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
+ const nextRunApiSchema = _zod.default.object({
18
+ type: _zod.default.literal("next"),
19
+ parameters: _zod.default.object({
20
+ value: _zod.default.string()
21
+ })
24
22
  });
25
- const nextRunApiSchema = z.object({
26
- type: z.literal("next"),
27
- parameters: z.object({ value: z.string() }),
23
+ const abortRunApiSchema = _zod.default.object({
24
+ type: _zod.default.literal("abort"),
25
+ parameters: _zod.default.object({}).optional()
28
26
  });
29
- const abortRunApiSchema = z.object({
30
- type: z.literal("abort"),
31
- parameters: z.object({}).optional(),
27
+ const tokenUpdateSchema = _zod.default.object({
28
+ type: _zod.default.literal("tokenUpdate"),
29
+ parameters: _zod.default.object({
30
+ functionsToken: _zod.default.string()
31
+ })
32
32
  });
33
- const inputSchema = z.union([
34
- startRunApiSchema,
35
- nextRunApiSchema,
36
- abortRunApiSchema,
37
- ]);
38
- dotenv.config({
39
- path: `.env`,
33
+ _dotenv.default.config({
34
+ path: `.env`
40
35
  });
41
- program
42
- .description("run user automation and communicate using unix socket")
43
- .argument("<socket-path>", "path to unix socket")
44
- .action(async (socketPath) => {
36
+ function main(importFunction) {
37
+ _commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
38
+ const startRunApiSchema = _zod.default.object({
39
+ type: _zod.default.literal("start"),
40
+ parameters: _runApi.runApiParametersSchema.extend({
41
+ automationFunction: _runApi.runApiParametersSchema.shape.automationFunction.omit({
42
+ module: true
43
+ }).extend({
44
+ name: _zod.default.string()
45
+ }),
46
+ retrieveSession: _zod.default.boolean(),
47
+ context: _zod.default.object({
48
+ jobId: _zod.default.string().optional(),
49
+ jobRunId: _zod.default.string().optional(),
50
+ runId: _zod.default.string().optional(),
51
+ queueId: _zod.default.string().optional()
52
+ }).optional()
53
+ })
54
+ });
55
+ const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema]);
45
56
  let context;
46
57
  const throttleTime = 1_000;
47
58
  let timeoutTimestamp = Date.now();
48
- const client = net.createConnection(socketPath, () => {
49
- console.log("connected to server!");
50
- });
59
+ const client = net.createConnection(socketPath);
51
60
  let generator = null;
52
61
  const abortController = new AbortController();
53
- client.on("end", () => {
54
- console.log("Disconnected from socket");
55
- });
56
- client.on("error", (err) => {
57
- console.error("Child connection error:", err);
58
- void generator?.throw(err).catch(() => undefined);
62
+ client.on("error", err => {
63
+ var _generator2;
64
+ void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(err).catch(() => undefined));
59
65
  });
60
66
  process.on("SIGINT", () => {
61
- console.log("Received SIGINT");
62
- void generator?.throw(new Error("Interrupted")).catch(() => undefined);
63
- client.end();
64
- process.exit(1);
67
+ var _generator3;
68
+ void ((_generator3 = generator) === null || _generator3 === void 0 ? void 0 : _generator3.throw(new Error("Interrupted")).catch(() => undefined));
69
+ client.end();
70
+ process.exit(1);
71
+ });
72
+ process.on("SIGTERM", () => {
73
+ var _generator4;
74
+ void ((_generator4 = generator) === null || _generator4 === void 0 ? void 0 : _generator4.throw(new Error("Interrupted")).catch(() => undefined));
75
+ client.end();
76
+ process.exit(1);
65
77
  });
66
- const jsonUnixSocket = new JSONUnixSocket(client);
78
+ const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
67
79
  async function runGeneratorAndSendResult(next) {
68
- if (!generator)
69
- return;
70
- const result = await runWithContext(context, () => generator.next(next));
71
- if (result.done) {
72
- const resultToSend = result.value.isOk()
73
- ? result.value.value
74
- : result.value.error.json;
75
- const success = result.value.isOk();
76
- jsonUnixSocket.sendJSON({
77
- type: "done",
78
- result: resultToSend,
79
- success,
80
- });
81
- return true;
82
- }
83
- else {
84
- jsonUnixSocket.sendJSON({ type: "yield", result: result.value });
85
- return false;
86
- }
80
+ const _generator = generator;
81
+ if (_generator == null) return;
82
+ const result = await (0, _asyncLocalStorage.runWithContext)(context, () => _generator.next(next));
83
+ if (result.done) {
84
+ const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
85
+ const success = result.value.isOk();
86
+ jsonUnixSocket.sendJSON({
87
+ type: "done",
88
+ result: resultToSend,
89
+ success
90
+ });
91
+ return true;
92
+ } else {
93
+ jsonUnixSocket.sendJSON({
94
+ type: "yield",
95
+ result: result.value
96
+ });
97
+ return false;
98
+ }
87
99
  }
88
100
  for await (const data of jsonUnixSocket.receiveJSON()) {
89
- const inputParseResult = inputSchema.safeParse(data);
90
- if (!inputParseResult.success) {
91
- console.error(inputParseResult.error.errors);
92
- jsonUnixSocket.sendJSON({
93
- type: "done",
94
- result: {
95
- error: "InvalidJSON",
96
- message: "Invalid input",
97
- details: {
98
- errors: inputParseResult.error.errors,
99
- },
100
- },
101
- success: false,
102
- });
103
- break;
104
- }
105
- const input = inputParseResult.data;
106
- if (input.type === "abort") {
107
- abortController.abort();
108
- await setTimeout(10);
109
- jsonUnixSocket.sendJSON({ type: "done", result: null });
110
- break;
111
- }
112
- if (input.type === "start") {
113
- const gen = runApiGenerator({
114
- ...input.parameters,
115
- abortSignal: abortController.signal,
116
- });
117
- generator = gen;
118
- context = {
119
- extendedPayloads: [],
120
- runEnvironment: input.parameters.runOptions.environment === "deployed"
121
- ? RunEnvironment.DEPLOYED
122
- : RunEnvironment.IDE,
123
- timeoutInfo: {
124
- extendTimeoutCallback: async () => {
125
- if (Date.now() - timeoutTimestamp < throttleTime)
126
- return;
127
- timeoutTimestamp = Date.now();
128
- jsonUnixSocket.sendJSON({ type: "extend" });
129
- },
130
- },
131
- ...(input.parameters.context ?? {}),
132
- proxy: getProxyUrlFromRunOptions(input.parameters.runOptions),
133
- };
134
- if (await runGeneratorAndSendResult()) {
135
- break;
136
- }
137
- continue;
138
- }
139
- if (input.type === "next") {
140
- if (!generator) {
141
- throw new Error("generator not started");
101
+ const inputParseResult = inputSchema.safeParse(data);
102
+ if (!inputParseResult.success) {
103
+ console.error(inputParseResult.error.errors);
104
+ jsonUnixSocket.sendJSON({
105
+ type: "done",
106
+ result: {
107
+ error: "InvalidInput",
108
+ message: "Invalid input",
109
+ details: {
110
+ errors: inputParseResult.error.errors
142
111
  }
143
- if (await runGeneratorAndSendResult(input.parameters.value)) {
144
- break;
112
+ },
113
+ success: false
114
+ });
115
+ break;
116
+ }
117
+ const input = inputParseResult.data;
118
+ if (input.type === "abort") {
119
+ abortController.abort();
120
+ await (0, _promises.setTimeout)(10);
121
+ jsonUnixSocket.sendJSON({
122
+ type: "done",
123
+ result: null
124
+ });
125
+ break;
126
+ }
127
+ if (input.type === "start") {
128
+ const gen = (0, _runApi.runApiGenerator)({
129
+ ...input.parameters,
130
+ automationFunction: {
131
+ ...input.parameters.automationFunction,
132
+ module: importFunction ? await importFunction(input.parameters.automationFunction.name) : await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(input.parameters.automationFunction.name)
133
+ },
134
+ abortSignal: abortController.signal
135
+ });
136
+ generator = gen;
137
+ context = {
138
+ extendedPayloads: [],
139
+ runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
140
+ timeoutInfo: {
141
+ extendTimeoutCallback: async () => {
142
+ if (Date.now() - timeoutTimestamp < throttleTime) return;
143
+ timeoutTimestamp = Date.now();
144
+ jsonUnixSocket.sendJSON({
145
+ type: "extend"
146
+ });
145
147
  }
146
- continue;
148
+ },
149
+ ...(input.parameters.context ?? {}),
150
+ proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
151
+ };
152
+ if (await runGeneratorAndSendResult()) {
153
+ break;
154
+ }
155
+ continue;
156
+ }
157
+ if (input.type === "next") {
158
+ if (!generator) {
159
+ throw new Error("generator not started");
147
160
  }
161
+ if (await runGeneratorAndSendResult(input.parameters.value)) {
162
+ break;
163
+ }
164
+ continue;
165
+ }
166
+ if (input.type === "tokenUpdate") {
167
+ _jwtTokenManager.backendFunctionsTokenManager.token = input.parameters.functionsToken;
168
+ }
148
169
  }
149
170
  process.exit(0);
150
- });
151
- program.parse(process.argv);
171
+ });
172
+ _commander.program.parse(process.argv);
173
+ }
152
174
  function getProxyUrlFromRunOptions(runOptions) {
153
- if (runOptions?.environment !== "deployed")
154
- return undefined;
155
- const proxy = runOptions.proxy;
156
- if (!proxy)
157
- return undefined;
158
- const url = new URL(proxy.server);
159
- url.username = proxy.username;
160
- url.password = proxy.password;
161
- return url.toString();
175
+ if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
176
+ const proxy = runOptions.proxy;
177
+ if (!proxy) return undefined;
178
+ const url = new URL(proxy.server);
179
+ url.username = proxy.username;
180
+ url.password = proxy.password;
181
+ return url.toString();
162
182
  }
183
+ if (require.main === module) {
184
+ main();
185
+ }
@@ -1,55 +1,55 @@
1
1
  #!/usr/bin/env node
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.js";
7
- import { fileURLToPath } from "url";
8
- program
9
- .description("Check TypeScript types in the project")
10
- .allowUnknownOption()
11
- .action(async () => {
12
- await moveWebTemplateFiles();
13
- const templateTsConfig = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "template.tsconfig.json");
14
- await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
15
- checkTypes();
2
+ "use strict";
3
+
4
+ var ts = _interopRequireWildcard(require("typescript"));
5
+ var _commander = require("commander");
6
+ var fs = _interopRequireWildcard(require("fs-extra"));
7
+ var path = _interopRequireWildcard(require("path"));
8
+ var _webTemplate = require("./common/utils/webTemplate.js");
9
+ var _url = require("url");
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
+ _commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
13
+ await (0, _webTemplate.moveWebTemplateFiles)();
14
+ const templateTsConfig = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "template.tsconfig.json");
15
+ await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
16
+ checkTypes();
16
17
  });
17
18
  function checkTypes() {
18
- const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
19
- if (!configPath) {
20
- console.error("Could not find a valid 'tsconfig.json'.");
21
- process.exit(1);
22
- }
23
- const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
24
- const config = readConfigResult.config;
25
- const parseConfigHost = {
26
- useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
27
- readDirectory: ts.sys.readDirectory,
28
- fileExists: ts.sys.fileExists,
29
- readFile: ts.sys.readFile,
30
- };
31
- const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
32
- const program = ts.createProgram(parsed.fileNames, parsed.options);
33
- const emitResult = program.emit();
34
- const allDiagnostics = ts
35
- .getPreEmitDiagnostics(program)
36
- .concat(emitResult.diagnostics);
37
- allDiagnostics.forEach((diagnostic) => {
38
- if (diagnostic.file) {
39
- const { line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
40
- const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
41
- console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
42
- }
43
- else {
44
- console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
45
- }
46
- });
47
- if (allDiagnostics.length === 0) {
48
- console.log("✨ TypeScript type checking passed without errors.");
49
- }
50
- else {
51
- console.error("Errors found during TypeScript type checking.");
52
- process.exit(1);
19
+ const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
20
+ if (!configPath) {
21
+ console.error("Could not find a valid 'tsconfig.json'.");
22
+ process.exit(1);
23
+ }
24
+ const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
25
+ const config = readConfigResult.config;
26
+ const parseConfigHost = {
27
+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
28
+ readDirectory: ts.sys.readDirectory,
29
+ fileExists: ts.sys.fileExists,
30
+ readFile: ts.sys.readFile
31
+ };
32
+ const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
33
+ const program = ts.createProgram(parsed.fileNames, parsed.options);
34
+ const emitResult = program.emit();
35
+ const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
36
+ allDiagnostics.forEach(diagnostic => {
37
+ if (diagnostic.file) {
38
+ const {
39
+ line,
40
+ character
41
+ } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
42
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
43
+ console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
44
+ } else {
45
+ console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
53
46
  }
47
+ });
48
+ if (allDiagnostics.length === 0) {
49
+ console.log("✨ TypeScript type checking passed without errors.");
50
+ } else {
51
+ console.error("Errors found during TypeScript type checking.");
52
+ process.exit(1);
53
+ }
54
54
  }
55
- program.parse(process.argv);
55
+ _commander.program.parse(process.argv);
@@ -1,47 +1,60 @@
1
- import { formatWithOptions } from "node:util";
2
- import chalk from "chalk";
3
- const format = formatWithOptions.bind(undefined, { colors: true });
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
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, {
11
+ colors: true
12
+ });
4
13
  const LOG_LEVEL_COLORS = {
5
- TRACE: chalk.gray,
6
- DEBUG: chalk.blue,
7
- INFO: chalk.green,
8
- WARN: chalk.yellow,
9
- ERROR: chalk.red,
14
+ TRACE: _chalk.default.gray,
15
+ DEBUG: _chalk.default.blue,
16
+ INFO: _chalk.default.green,
17
+ WARN: _chalk.default.yellow,
18
+ ERROR: _chalk.default.red
10
19
  };
11
20
  class Logger {
12
- logFunction(entry) {
13
- const { level, timestamp, message, meta } = entry;
14
- const date = new Date(timestamp);
15
- const levelColor = LOG_LEVEL_COLORS[level];
16
- if (meta === undefined) {
17
- process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
18
- }
19
- else {
20
- process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
21
- }
22
- }
23
- log(level, message, meta) {
24
- this.logFunction({
25
- level,
26
- message,
27
- meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
28
- timestamp: Date.now(),
29
- });
30
- }
31
- trace(message, meta) {
32
- this.log("TRACE", message, meta);
33
- }
34
- debug(message, meta) {
35
- this.log("DEBUG", message, meta);
36
- }
37
- info(message, meta) {
38
- this.log("INFO", message, meta);
39
- }
40
- warn(message, meta) {
41
- this.log("WARN", message, meta);
42
- }
43
- error(message, meta) {
44
- this.log("ERROR", message, meta);
21
+ logFunction(entry) {
22
+ const {
23
+ level,
24
+ timestamp,
25
+ message,
26
+ meta
27
+ } = entry;
28
+ const date = new Date(timestamp);
29
+ const levelColor = LOG_LEVEL_COLORS[level];
30
+ if (meta === undefined) {
31
+ process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
32
+ } else {
33
+ process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
45
34
  }
35
+ }
36
+ log(level, message, meta) {
37
+ this.logFunction({
38
+ level,
39
+ message,
40
+ meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
41
+ timestamp: Date.now()
42
+ });
43
+ }
44
+ trace(message, meta) {
45
+ this.log("TRACE", message, meta);
46
+ }
47
+ debug(message, meta) {
48
+ this.log("DEBUG", message, meta);
49
+ }
50
+ info(message, meta) {
51
+ this.log("INFO", message, meta);
52
+ }
53
+ warn(message, meta) {
54
+ this.log("WARN", message, meta);
55
+ }
56
+ error(message, meta) {
57
+ this.log("ERROR", message, meta);
58
+ }
46
59
  }
47
- export const logger = new Logger();
60
+ const logger = exports.logger = new Logger();
@@ -1 +1,5 @@
1
- export {};
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });