@intuned/runtime-dev 1.3.0-dev-52 → 1.3.0-responseLimits.1
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 +2 -2
- package/CHANGELOG.md +5 -1
- package/bin/intuned +2 -0
- package/dist/commands/api/run.js +4 -3
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/interface/run.js +5 -6
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +40 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +24 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +36 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +46 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +15 -0
- package/dist/commands/intuned-cli/commands/index.js +170 -0
- package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/init.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +54 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +20 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +13 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +39 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +37 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +21 -0
- package/dist/commands/intuned-cli/commands/types.js +21 -0
- package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +280 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +676 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +44 -0
- package/dist/commands/intuned-cli/controller/api.js +181 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +198 -0
- package/dist/commands/intuned-cli/controller/authSession.js +292 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +15 -0
- package/dist/commands/{deploy/utils.js → intuned-cli/controller/deploy.js} +115 -109
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +41 -0
- package/dist/commands/intuned-cli/helpers/auth.js +129 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/{common/cli/utils.js → commands/intuned-cli/helpers/intunedJson.js} +0 -16
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +12 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/dist/commands/intuned-cli/main.js +15 -0
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -34
- package/dist/{common/cli → commands/intuned-cli}/types.js +1 -2
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +4 -12
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +9 -2
- package/dist/common/runApi/errors.js +21 -8
- package/dist/common/runApi/index.d.ts +4 -1
- package/dist/common/runApi/index.js +33 -21
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +15 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/package.json +14 -13
- package/tsconfig.json +2 -1
- package/bin/check-auth-session +0 -3
- package/bin/cli-build +0 -3
- package/bin/create-auth-session +0 -3
- package/bin/deploy +0 -3
- package/bin/init +0 -3
- package/bin/run-api +0 -3
- package/dist/commands/cli-auth-sessions/check.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/check.js +0 -40
- package/dist/commands/cli-auth-sessions/create.d.ts +0 -2
- package/dist/commands/cli-auth-sessions/create.js +0 -53
- package/dist/commands/cli-auth-sessions/utils.d.ts +0 -28
- package/dist/commands/cli-auth-sessions/utils.js +0 -285
- package/dist/commands/cli-build/cli-build.d.ts +0 -2
- package/dist/commands/cli-build/cli-build.js +0 -20
- package/dist/commands/deploy/deploy.d.ts +0 -2
- package/dist/commands/deploy/deploy.js +0 -47
- package/dist/commands/deploy/utils.d.ts +0 -16
- package/dist/commands/init/init.d.ts +0 -2
- package/dist/commands/init/init.js +0 -22
- package/dist/commands/init/utils.d.ts +0 -11
- package/dist/commands/init/utils.js +0 -181
- package/dist/commands/run-api-cli/run-api.d.ts +0 -2
- package/dist/commands/run-api-cli/run-api.js +0 -57
- package/dist/commands/run-api-cli/utils.d.ts +0 -9
- package/dist/commands/run-api-cli/utils.js +0 -144
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +0 -92
- package/dist/common/cli/constants.d.ts +0 -33
- package/dist/common/cli/constants.js +0 -39
- package/dist/common/cli/utils.d.ts +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runBuild: () => Promise<boolean>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.runBuild = void 0;
|
|
7
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
|
+
var path = _interopRequireWildcard(require("path"));
|
|
9
|
+
var _child_process = require("child_process");
|
|
10
|
+
var _util = require("util");
|
|
11
|
+
var _terminal = require("../helpers/terminal");
|
|
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 && {}.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
|
+
const execPromise = (0, _util.promisify)(_child_process.exec);
|
|
15
|
+
const runBuild = async () => {
|
|
16
|
+
const distPath = path.join(process.cwd(), "dist");
|
|
17
|
+
if (await fs.exists(distPath)) {
|
|
18
|
+
await fs.remove(distPath);
|
|
19
|
+
}
|
|
20
|
+
const buildCommand = "tsc";
|
|
21
|
+
try {
|
|
22
|
+
await execPromise(buildCommand);
|
|
23
|
+
(0, _terminal.terminal)(`^g^+✨ Build completed successfully!^:\n`);
|
|
24
|
+
return true;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
(0, _terminal.terminal)(`^r^+An error occurred during the build process:^:\n`);
|
|
27
|
+
if ("stdout" in error) {
|
|
28
|
+
(0, _terminal.terminal)(`${error.stdout}\n`);
|
|
29
|
+
} else {
|
|
30
|
+
(0, _terminal.terminal)(`^${error.message}^:\n`);
|
|
31
|
+
}
|
|
32
|
+
(0, _terminal.terminal)(`^r^+Build failed^:\n`);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.runBuild = runBuild;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AuthCredentials, FileSystemTree } from "../types";
|
|
3
|
+
export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
|
|
4
|
+
export declare function runDeployProject(projectName: string, auth: AuthCredentials): Promise<void>;
|
|
5
|
+
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
6
|
+
export declare const validateProjectName: (projectName: string) => {
|
|
7
|
+
isValid: true;
|
|
8
|
+
} | {
|
|
9
|
+
isValid: false;
|
|
10
|
+
errorMessage: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const validateIntunedProject: () => Promise<{
|
|
13
|
+
isValid: boolean;
|
|
14
|
+
errorMessage?: string;
|
|
15
|
+
}>;
|
|
@@ -4,25 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertProjectToCodeTree = convertProjectToCodeTree;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
7
|
+
exports.projectNameSchema = void 0;
|
|
8
|
+
exports.runDeployProject = runDeployProject;
|
|
9
|
+
exports.validateProjectName = exports.validateIntunedProject = void 0;
|
|
9
10
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
10
11
|
var path = _interopRequireWildcard(require("path"));
|
|
11
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
12
|
var _minimatch = require("minimatch");
|
|
13
13
|
var _zod = require("zod");
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var _constants = require("../../common/cli/constants");
|
|
18
|
-
var _utils = require("../../common/cli/utils");
|
|
19
|
-
var _utils2 = require("../init/utils");
|
|
14
|
+
var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
|
|
15
|
+
var _constants = require("../constants");
|
|
16
|
+
var _helpers = require("../helpers");
|
|
20
17
|
var _lodash = require("lodash");
|
|
21
18
|
var _uuid = require("uuid");
|
|
19
|
+
var _terminal = require("../helpers/terminal");
|
|
20
|
+
var _promises = require("timers/promises");
|
|
21
|
+
var _ms = _interopRequireDefault(require("ms"));
|
|
22
|
+
var _build = require("./build");
|
|
22
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
24
|
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); }
|
|
24
25
|
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 && {}.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; }
|
|
25
|
-
const execPromise = (0, _util.promisify)(_child_process.exec);
|
|
26
26
|
function ignoreFilesByPattern(filePath, patterns, projectPath) {
|
|
27
27
|
const relativePath = path.relative(projectPath, filePath);
|
|
28
28
|
if (relativePath.startsWith("node_modules")) {
|
|
@@ -58,11 +58,11 @@ function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
|
58
58
|
results.push(path.relative(projectPath, fullPath));
|
|
59
59
|
}
|
|
60
60
|
} catch (error) {
|
|
61
|
-
|
|
61
|
+
(0, _terminal.terminal)(`^yWarning: Could not access ${fullPath}^:\n`);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
} catch (error) {
|
|
65
|
-
|
|
65
|
+
(0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
traverseDirectory(projectPath);
|
|
@@ -70,9 +70,9 @@ function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
|
70
70
|
}
|
|
71
71
|
async function convertProjectToCodeTree(projectPath) {
|
|
72
72
|
const filesToDeploy = listFilesNotIgnored(projectPath, _projectExclusions.default);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const filesToDeployText = " " + filesToDeploy.join("\n ");
|
|
74
|
+
(0, _terminal.terminal)("^CFiles to be deployed:^:\n");
|
|
75
|
+
(0, _terminal.terminal)(filesToDeployText + "\n");
|
|
76
76
|
function readDirectory(dirPath) {
|
|
77
77
|
const tree = {};
|
|
78
78
|
try {
|
|
@@ -93,7 +93,7 @@ async function convertProjectToCodeTree(projectPath) {
|
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
} catch (error) {
|
|
96
|
-
|
|
96
|
+
(0, _terminal.terminal)(`^yWarning: Could not read file ${entryPath}^:\n`);
|
|
97
97
|
}
|
|
98
98
|
} else if (stats.isDirectory()) {
|
|
99
99
|
const subTree = readDirectory(entryPath);
|
|
@@ -104,25 +104,24 @@ async function convertProjectToCodeTree(projectPath) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
} catch (error) {
|
|
107
|
-
|
|
107
|
+
(0, _terminal.terminal)(`^yWarning: Could not access ${entryPath}^:\n`);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
} catch (error) {
|
|
111
|
-
|
|
111
|
+
(0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
|
|
112
112
|
}
|
|
113
113
|
return tree;
|
|
114
114
|
}
|
|
115
|
-
console.log(_chalk.default.cyan("\n📦 Building project..."));
|
|
116
115
|
const tree = readDirectory(projectPath);
|
|
117
116
|
await mapToIDEParams(tree);
|
|
118
117
|
return tree;
|
|
119
118
|
}
|
|
120
|
-
async function
|
|
119
|
+
async function runDeployProject(projectName, auth) {
|
|
121
120
|
const {
|
|
122
121
|
workspaceId,
|
|
123
122
|
apiKey
|
|
124
123
|
} = auth;
|
|
125
|
-
const baseUrl = (0,
|
|
124
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
126
125
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create`;
|
|
127
126
|
const headers = {
|
|
128
127
|
"x-api-key": apiKey,
|
|
@@ -148,48 +147,84 @@ async function deployProject(projectName, auth) {
|
|
|
148
147
|
});
|
|
149
148
|
if (!response.ok) {
|
|
150
149
|
if (response.status === 401) {
|
|
151
|
-
throw new
|
|
150
|
+
throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
|
|
152
151
|
}
|
|
153
|
-
throw new
|
|
152
|
+
throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project deployment failed^:\n`, {
|
|
153
|
+
autoColor: false
|
|
154
|
+
});
|
|
154
155
|
}
|
|
156
|
+
(0, _terminal.terminal)("\n");
|
|
155
157
|
const startTime = Date.now();
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
|
|
159
|
+
function* getSpinnerGenerator() {
|
|
160
|
+
while (true) {
|
|
161
|
+
yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const spinnerGen = getSpinnerGenerator();
|
|
165
|
+
let updateSpinnerInterval = null;
|
|
166
|
+
if (_terminal.terminalStdout.isTTY) {
|
|
167
|
+
updateSpinnerInterval = setInterval(() => {
|
|
168
|
+
_terminal.terminal.previousLine(1);
|
|
169
|
+
_terminal.terminal.column(0);
|
|
170
|
+
_terminal.terminal.eraseLineAfter();
|
|
171
|
+
(0, _terminal.terminal)(`${spinnerGen.next().value} ^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
172
|
+
}, 50);
|
|
173
|
+
(0, _terminal.terminal)("\n");
|
|
174
|
+
} else {
|
|
175
|
+
(0, _terminal.terminal)(`^cDeploying ^:\n`);
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
while (true) {
|
|
179
|
+
await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
|
|
180
|
+
if (!_terminal.terminalStdout.isTTY) {
|
|
181
|
+
(0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
182
|
+
}
|
|
183
|
+
const {
|
|
184
|
+
status,
|
|
185
|
+
message,
|
|
186
|
+
projectId,
|
|
187
|
+
...rest
|
|
188
|
+
} = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
|
|
189
|
+
if (status === "pending") {
|
|
176
190
|
const elapsedTime = Date.now() - startTime;
|
|
177
191
|
if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
|
|
178
|
-
|
|
179
|
-
reject(new Error(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / 1000 / 60)} minutes`));
|
|
192
|
+
throw new _helpers.CLIError(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / (0, _ms.default)("1 minute"))} minutes`);
|
|
180
193
|
}
|
|
181
|
-
|
|
182
|
-
clearInterval(checkInterval);
|
|
183
|
-
reject(error);
|
|
194
|
+
continue;
|
|
184
195
|
}
|
|
185
|
-
|
|
186
|
-
|
|
196
|
+
_terminal.terminal.previousLine(1);
|
|
197
|
+
_terminal.terminal.eraseLine();
|
|
198
|
+
if (updateSpinnerInterval) {
|
|
199
|
+
clearTimeout(updateSpinnerInterval);
|
|
200
|
+
}
|
|
201
|
+
if (status === "completed") {
|
|
202
|
+
const url = (0, _helpers.getBaseUrl)();
|
|
203
|
+
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
|
|
204
|
+
(0, _terminal.terminal)(`^+You can check your project on the platform:^s ^c^_${url}/projects/${projectId}/details^:\n`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
208
|
+
if (rest.reason) {
|
|
209
|
+
errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
|
|
210
|
+
}
|
|
211
|
+
errorMessage += `^r^+Project deployment failed^:\n`;
|
|
212
|
+
throw new _helpers.CLIError(errorMessage, {
|
|
213
|
+
autoColor: false
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
} catch (e) {
|
|
217
|
+
if (updateSpinnerInterval) {
|
|
218
|
+
clearTimeout(updateSpinnerInterval);
|
|
219
|
+
}
|
|
220
|
+
throw e;
|
|
221
|
+
}
|
|
187
222
|
}
|
|
223
|
+
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(50, "Name must be 50 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
224
|
+
message: "Name cannot be a UUID"
|
|
225
|
+
});
|
|
188
226
|
const validateProjectName = projectName => {
|
|
189
|
-
const
|
|
190
|
-
message: "Name cannot be a UUID"
|
|
191
|
-
});
|
|
192
|
-
const validation = nameSchema.safeParse(projectName);
|
|
227
|
+
const validation = projectNameSchema.safeParse(projectName);
|
|
193
228
|
if (!validation.success) {
|
|
194
229
|
return {
|
|
195
230
|
isValid: false,
|
|
@@ -207,7 +242,7 @@ const validateIntunedProject = async () => {
|
|
|
207
242
|
name: "build",
|
|
208
243
|
check: async () => {
|
|
209
244
|
try {
|
|
210
|
-
const buildResult = await runBuild();
|
|
245
|
+
const buildResult = await (0, _build.runBuild)();
|
|
211
246
|
if (!buildResult) {
|
|
212
247
|
return {
|
|
213
248
|
isValid: false,
|
|
@@ -228,13 +263,12 @@ const validateIntunedProject = async () => {
|
|
|
228
263
|
name: "package.json",
|
|
229
264
|
check: async () => {
|
|
230
265
|
try {
|
|
231
|
-
var _packageJson$dependen;
|
|
232
266
|
const packageJsonPath = path.join(currentDirectoryToDeploy, "package.json");
|
|
233
267
|
await fs.exists(packageJsonPath);
|
|
234
268
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, {
|
|
235
269
|
encoding: "utf-8"
|
|
236
270
|
}));
|
|
237
|
-
const userCodePlaywrightVersion =
|
|
271
|
+
const userCodePlaywrightVersion = packageJson.dependencies?.playwright;
|
|
238
272
|
if (userCodePlaywrightVersion !== _constants.CURRENT_PLAYWRIGHT_VERSION) {
|
|
239
273
|
return {
|
|
240
274
|
isValid: false,
|
|
@@ -296,67 +330,39 @@ const validateIntunedProject = async () => {
|
|
|
296
330
|
};
|
|
297
331
|
exports.validateIntunedProject = validateIntunedProject;
|
|
298
332
|
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (response.status === 404) {
|
|
311
|
-
return {
|
|
312
|
-
status: "not_found",
|
|
313
|
-
message: "Project not found"
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
if (!response.ok) {
|
|
317
|
-
throw new Error("Error querying deployment status");
|
|
318
|
-
}
|
|
319
|
-
const data = await response.json();
|
|
320
|
-
if (data.status) {
|
|
321
|
-
return {
|
|
322
|
-
status: data.status,
|
|
323
|
-
message: data.message,
|
|
324
|
-
projectId: data.projectId
|
|
325
|
-
};
|
|
326
|
-
}
|
|
333
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
334
|
+
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create/${projectName}/result`;
|
|
335
|
+
const headers = {
|
|
336
|
+
"x-api-key": apiKey,
|
|
337
|
+
"Content-Type": "application/json"
|
|
338
|
+
};
|
|
339
|
+
const response = await fetch(url, {
|
|
340
|
+
headers,
|
|
341
|
+
method: "GET"
|
|
342
|
+
});
|
|
343
|
+
if (response.status === 404) {
|
|
327
344
|
return {
|
|
328
|
-
status: "
|
|
329
|
-
message:
|
|
345
|
+
status: "not_found",
|
|
346
|
+
message: "Project not found"
|
|
330
347
|
};
|
|
331
|
-
} catch (e) {
|
|
332
|
-
throw new Error(`Error during deployment`);
|
|
333
348
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const currentProjectDirectory = process.cwd();
|
|
337
|
-
console.log(_chalk.default.yellow("Running build..."));
|
|
338
|
-
const distPath = path.join(currentProjectDirectory, "dist");
|
|
339
|
-
if (await fs.exists(distPath)) {
|
|
340
|
-
await fs.remove(distPath);
|
|
349
|
+
if (!response.ok) {
|
|
350
|
+
throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
|
|
341
351
|
}
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
cwd: currentProjectDirectory
|
|
346
|
-
});
|
|
347
|
-
console.log(_chalk.default.green("🏗️ Build completed successfully"));
|
|
348
|
-
return true;
|
|
349
|
-
} catch (error) {
|
|
350
|
-
console.error(_chalk.default.red(`Build failed: ${error.message}`));
|
|
351
|
-
return false;
|
|
352
|
+
const data = await response.json();
|
|
353
|
+
if (data.status) {
|
|
354
|
+
return data;
|
|
352
355
|
}
|
|
356
|
+
return {
|
|
357
|
+
status: "failed",
|
|
358
|
+
message: `Deployment failed, please try again: ${data.message}`
|
|
359
|
+
};
|
|
353
360
|
};
|
|
354
|
-
exports.runBuild = runBuild;
|
|
355
361
|
async function mapToIDEParams(tree) {
|
|
356
362
|
if (!tree) {
|
|
357
363
|
return;
|
|
358
364
|
}
|
|
359
|
-
if (!tree["parameters"] ||
|
|
365
|
+
if (!tree["parameters"] || "file" in tree["parameters"]) {
|
|
360
366
|
return;
|
|
361
367
|
}
|
|
362
368
|
const apiParametersMap = {};
|
|
@@ -366,7 +372,7 @@ async function mapToIDEParams(tree) {
|
|
|
366
372
|
};
|
|
367
373
|
for (const parameterKey of cliParameters) {
|
|
368
374
|
const parameter = tree["parameters"].directory[parameterKey];
|
|
369
|
-
if (
|
|
375
|
+
if ("directory" in parameter) {
|
|
370
376
|
continue;
|
|
371
377
|
}
|
|
372
378
|
if ((0, _lodash.isEmpty)(parameter.file.contents)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadParameters(parameters: string): Promise<object | null>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadParameters = loadParameters;
|
|
7
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
|
+
var _helpers = require("../helpers");
|
|
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 && {}.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
|
+
async function loadParameters(parameters) {
|
|
12
|
+
let inputData;
|
|
13
|
+
if (await fs.exists(parameters)) {
|
|
14
|
+
inputData = await loadParametersFromFile(parameters);
|
|
15
|
+
} else {
|
|
16
|
+
try {
|
|
17
|
+
inputData = JSON.parse(parameters);
|
|
18
|
+
} catch (err) {
|
|
19
|
+
throw new _helpers.CLIError("Parameters must be a valid JSON string or a path to a JSON file");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return inputData;
|
|
23
|
+
}
|
|
24
|
+
async function loadParametersFromFile(parametersFile) {
|
|
25
|
+
if (!parametersFile) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const filePath = parametersFile;
|
|
30
|
+
await fs.access(filePath);
|
|
31
|
+
let inputData = null;
|
|
32
|
+
if (parametersFile) {
|
|
33
|
+
inputData = await fs.readJSON(filePath);
|
|
34
|
+
} else {
|
|
35
|
+
inputData = {};
|
|
36
|
+
}
|
|
37
|
+
return inputData;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error.code === "ENOENT") {
|
|
40
|
+
throw new _helpers.CLIError(`Parameters file not found: ${parametersFile}`);
|
|
41
|
+
} else if (error instanceof SyntaxError) {
|
|
42
|
+
throw new _helpers.CLIError(`Invalid JSON in parameters file: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
throw new _helpers.CLIError(`Error reading parameters file: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { API_FOLDER_NAME, AUTH_SESSIONS_FOLDER_NAME } from "../../../common/constants";
|
|
2
|
+
export declare function assertApiFileExists(dirname: typeof AUTH_SESSIONS_FOLDER_NAME, api: "create" | "check"): Promise<void>;
|
|
3
|
+
export declare function assertApiFileExists(dirname: typeof API_FOLDER_NAME, api: string): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertApiFileExists = assertApiFileExists;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _fsExtra = require("fs-extra");
|
|
9
|
+
var _errors = require("./errors");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
async function assertApiFileExists(dirname, api) {
|
|
12
|
+
const file = `${dirname}/${api}.ts`;
|
|
13
|
+
const filePath = _path.default.join(process.cwd(), file);
|
|
14
|
+
if (!(await (0, _fsExtra.exists)(filePath))) {
|
|
15
|
+
throw new _errors.CLIAssertionError(`^+^r API^ ^+${dirname}/${api}^ ^r^+is not implemented.^:`, {
|
|
16
|
+
autoColor: false
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AuthSessionMetadata } from "../types";
|
|
2
|
+
import { RunApiStorageState as StorageState } from "../../../common/runApi";
|
|
3
|
+
export declare function isAuthEnabled(): Promise<boolean>;
|
|
4
|
+
export declare function assertAuthEnabled(): Promise<void>;
|
|
5
|
+
export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
|
|
6
|
+
export declare function loadAuthSessionInstance(authSessionId: string): Promise<{
|
|
7
|
+
storageState: {
|
|
8
|
+
cookies: {
|
|
9
|
+
value: string;
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
domain: string;
|
|
13
|
+
expires: number;
|
|
14
|
+
httpOnly: boolean;
|
|
15
|
+
secure: boolean;
|
|
16
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
17
|
+
}[];
|
|
18
|
+
origins: {
|
|
19
|
+
origin: string;
|
|
20
|
+
localStorage: {
|
|
21
|
+
value: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}[];
|
|
24
|
+
}[];
|
|
25
|
+
sessionStorage?: {
|
|
26
|
+
sessionStorage: {
|
|
27
|
+
value: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}[];
|
|
30
|
+
origin: string;
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
};
|
|
33
|
+
metadata: AuthSessionMetadata;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function storeAuthSessionInstance({ state, id, input, proxy, }: {
|
|
36
|
+
state: StorageState;
|
|
37
|
+
id?: string;
|
|
38
|
+
input?: Record<string, any>;
|
|
39
|
+
proxy?: string;
|
|
40
|
+
}): Promise<string>;
|
|
41
|
+
export declare function registerGetAuthSessionParameters(authSessionId?: string): void;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assertAuthConsistent = assertAuthConsistent;
|
|
7
|
+
exports.assertAuthEnabled = assertAuthEnabled;
|
|
8
|
+
exports.isAuthEnabled = isAuthEnabled;
|
|
9
|
+
exports.loadAuthSessionInstance = loadAuthSessionInstance;
|
|
10
|
+
exports.registerGetAuthSessionParameters = registerGetAuthSessionParameters;
|
|
11
|
+
exports.storeAuthSessionInstance = storeAuthSessionInstance;
|
|
12
|
+
var _constants = require("../../../common/constants");
|
|
13
|
+
var _path = _interopRequireDefault(require("path"));
|
|
14
|
+
var _fsExtra = require("fs-extra");
|
|
15
|
+
var _intunedJson = require("./intunedJson");
|
|
16
|
+
var _errors = require("./errors");
|
|
17
|
+
var _runApi = require("../../../common/runApi");
|
|
18
|
+
var _formatZodError = require("../../../common/formatZodError");
|
|
19
|
+
var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
async function isAuthEnabled() {
|
|
22
|
+
try {
|
|
23
|
+
const intunedJson = await (0, _fsExtra.readJSON)(_path.default.join(process.cwd(), "Intuned.json"));
|
|
24
|
+
return Boolean(intunedJson?.authSessions?.enabled);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function assertAuthEnabled() {
|
|
30
|
+
if (!(await isAuthEnabled())) {
|
|
31
|
+
throw new _errors.CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function assertAuthConsistent(authSession) {
|
|
35
|
+
const _isAuthEnabled = await isAuthEnabled();
|
|
36
|
+
if (_isAuthEnabled && !authSession) {
|
|
37
|
+
throw new _errors.CLIAssertionError("Auth session is enabled, but no auth session is provided. Please provide an auth session ID.");
|
|
38
|
+
}
|
|
39
|
+
if (!_isAuthEnabled && authSession) {
|
|
40
|
+
throw new _errors.CLIAssertionError("Auth session is not enabled, enable it in Intuned.json to use it");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function loadAuthSessionInstance(authSessionId) {
|
|
44
|
+
try {
|
|
45
|
+
const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
|
|
46
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
47
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
48
|
+
if (!(await (0, _fsExtra.exists)(authSessionInstanceStoragePath))) {
|
|
49
|
+
throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} not found`);
|
|
50
|
+
}
|
|
51
|
+
const authSessionInstanceJson = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
|
|
52
|
+
const authSessionInstanceParseResult = _runApi.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
|
|
53
|
+
if (!authSessionInstanceParseResult.success) {
|
|
54
|
+
throw new _errors.CLIError(`Auth session instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
|
|
55
|
+
}
|
|
56
|
+
const metadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
|
|
57
|
+
return {
|
|
58
|
+
storageState: authSessionInstanceParseResult.data,
|
|
59
|
+
metadata
|
|
60
|
+
};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new _errors.CLIError(`Error retrieving auth session instance: ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function storeAuthSessionInstance({
|
|
66
|
+
state,
|
|
67
|
+
id,
|
|
68
|
+
input,
|
|
69
|
+
proxy
|
|
70
|
+
}) {
|
|
71
|
+
try {
|
|
72
|
+
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
73
|
+
await (0, _fsExtra.ensureDir)(authSessionsDirectoryPath);
|
|
74
|
+
const authSessionInstanceId = id ?? `auth-session-${Date.now()}`;
|
|
75
|
+
const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, authSessionInstanceId);
|
|
76
|
+
const authSessionExists = await (0, _fsExtra.pathExists)(authSessionInstancePath);
|
|
77
|
+
await (0, _fsExtra.ensureDir)(authSessionInstancePath);
|
|
78
|
+
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
79
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceStoragePath, state, {
|
|
80
|
+
spaces: 2
|
|
81
|
+
});
|
|
82
|
+
const projectAuthConfig = await (0, _intunedJson.getSettingIntunedJSON)("authSessions");
|
|
83
|
+
let existingMetadata = {};
|
|
84
|
+
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
85
|
+
if (authSessionExists) {
|
|
86
|
+
try {
|
|
87
|
+
existingMetadata = await (0, _fsExtra.readJSON)(authSessionInstanceMetadataPath);
|
|
88
|
+
} catch (readError) {
|
|
89
|
+
existingMetadata = {};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const authSessionMetadata = {
|
|
93
|
+
createdAt: existingMetadata.createdAt || new Date().toISOString(),
|
|
94
|
+
updatedAt: new Date().toISOString(),
|
|
95
|
+
...(projectAuthConfig.type === "API" && {
|
|
96
|
+
authSessionInput: input || existingMetadata.authSessionInput || {}
|
|
97
|
+
}),
|
|
98
|
+
authSessionId: authSessionInstanceId,
|
|
99
|
+
authSessionType: projectAuthConfig.type ?? existingMetadata.authSessionType ?? "API",
|
|
100
|
+
...(projectAuthConfig.type === "MANUAL" && {
|
|
101
|
+
recorderStartUrl: projectAuthConfig.startUrl,
|
|
102
|
+
recorderEndUrl: projectAuthConfig.endUrl
|
|
103
|
+
}),
|
|
104
|
+
authSessionInput: input || existingMetadata.authSessionInput || {},
|
|
105
|
+
authSessionProxy: proxy || existingMetadata.authSessionProxy
|
|
106
|
+
};
|
|
107
|
+
await (0, _fsExtra.writeJSON)(authSessionInstanceMetadataPath, authSessionMetadata, {
|
|
108
|
+
spaces: 2
|
|
109
|
+
});
|
|
110
|
+
return authSessionInstancePath;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw new _errors.CLIError(`Error storing auth session instance: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function registerGetAuthSessionParameters(authSessionId) {
|
|
116
|
+
async function getAuthSessionParameters() {
|
|
117
|
+
if (!authSessionId) {
|
|
118
|
+
throw new Error("getAuthSessionParameters cannot be called without using an auth session");
|
|
119
|
+
}
|
|
120
|
+
const {
|
|
121
|
+
metadata
|
|
122
|
+
} = await loadAuthSessionInstance(authSessionId);
|
|
123
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
124
|
+
throw new Error("Auth session is recorder-based, it does not have parameters.");
|
|
125
|
+
}
|
|
126
|
+
return metadata?.authSessionInput ?? {};
|
|
127
|
+
}
|
|
128
|
+
(0, _asyncLocalStorage.getExecutionContext)().getAuthSessionParameters = getAuthSessionParameters;
|
|
129
|
+
}
|