@intuned/runtime 1.3.16 → 1.3.18-interface.6
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/bin/intuned +0 -0
- package/bin/intuned-interface +7 -0
- package/dist/chunk-6ZRJOUQS.mjs +16 -0
- package/dist/chunk-6ZRJOUQS.mjs.map +1 -0
- package/dist/chunk-7YL2JUTE.mjs +146 -0
- package/dist/chunk-7YL2JUTE.mjs.map +1 -0
- package/dist/chunk-B3T6RXPC.mjs +794 -0
- package/dist/chunk-B3T6RXPC.mjs.map +1 -0
- package/dist/chunk-FGV5T6SI.mjs +27 -0
- package/dist/chunk-FGV5T6SI.mjs.map +1 -0
- package/dist/chunk-G4PO5RIV.mjs +85 -0
- package/dist/chunk-G4PO5RIV.mjs.map +1 -0
- package/dist/chunk-LZOMFHX3.mjs +38 -0
- package/dist/chunk-LZOMFHX3.mjs.map +1 -0
- package/dist/{common/formatZodError.js → chunk-NDMVGENG.mjs} +9 -9
- package/dist/chunk-NDMVGENG.mjs.map +1 -0
- package/dist/chunk-W4UX6G4X.mjs +17 -0
- package/dist/chunk-W4UX6G4X.mjs.map +1 -0
- package/dist/chunk-XC75QGFG.mjs +1106 -0
- package/dist/chunk-XC75QGFG.mjs.map +1 -0
- package/dist/chunk-XOAZ2MGA.mjs +59 -0
- package/dist/chunk-XOAZ2MGA.mjs.map +1 -0
- package/dist/commands/interface/run.d.mts +3 -0
- package/dist/commands/interface/run.d.ts +3 -1
- package/dist/commands/interface/run.js +2060 -178
- package/dist/commands/interface/run.js.map +1 -0
- package/dist/commands/interface/run.mjs +255 -0
- package/dist/commands/interface/run.mjs.map +1 -0
- package/dist/common/asyncLocalStorage/index.d.mts +17 -0
- package/dist/common/asyncLocalStorage/index.d.ts +9 -8
- package/dist/common/asyncLocalStorage/index.js +34 -9
- package/dist/common/asyncLocalStorage/index.js.map +1 -0
- package/dist/common/asyncLocalStorage/index.mjs +12 -0
- package/dist/common/asyncLocalStorage/index.mjs.map +1 -0
- package/dist/common/binStartupScript.d.mts +2 -0
- package/dist/common/binStartupScript.d.ts +2 -1
- package/dist/common/binStartupScript.js +127 -11
- package/dist/common/binStartupScript.js.map +1 -0
- package/dist/common/binStartupScript.mjs +135 -0
- package/dist/common/binStartupScript.mjs.map +1 -0
- package/dist/common/cleanEnvironmentVariables.d.mts +3 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +3 -1
- package/dist/common/cleanEnvironmentVariables.js +30 -7
- package/dist/common/cleanEnvironmentVariables.js.map +1 -0
- package/dist/common/cleanEnvironmentVariables.mjs +8 -0
- package/dist/common/cleanEnvironmentVariables.mjs.map +1 -0
- package/dist/common/constants.d.mts +13 -0
- package/dist/common/constants.d.ts +13 -10
- package/dist/common/constants.js +58 -14
- package/dist/common/constants.js.map +1 -0
- package/dist/common/constants.mjs +28 -0
- package/dist/common/constants.mjs.map +1 -0
- package/dist/common/contextStorageStateHelpers.d.mts +24 -0
- package/dist/common/contextStorageStateHelpers.d.ts +8 -5
- package/dist/common/contextStorageStateHelpers.js +51 -23
- package/dist/common/contextStorageStateHelpers.js.map +1 -0
- package/dist/common/contextStorageStateHelpers.mjs +10 -0
- package/dist/common/contextStorageStateHelpers.mjs.map +1 -0
- package/dist/common/jwtTokenManager.d.mts +19 -0
- package/dist/common/jwtTokenManager.d.ts +6 -4
- package/dist/common/jwtTokenManager.js +112 -40
- package/dist/common/jwtTokenManager.js.map +1 -0
- package/dist/common/jwtTokenManager.mjs +11 -0
- package/dist/common/jwtTokenManager.mjs.map +1 -0
- package/dist/common/runApi/index.d.mts +11 -0
- package/dist/common/runApi/index.d.ts +10 -10
- package/dist/common/runApi/index.js +1776 -93
- package/dist/common/runApi/index.js.map +1 -0
- package/dist/common/runApi/index.mjs +18 -0
- package/dist/common/runApi/index.mjs.map +1 -0
- package/dist/common/settingsSchema.d.mts +536 -0
- package/dist/common/settingsSchema.d.ts +9 -6
- package/dist/common/settingsSchema.js +55 -20
- package/dist/common/settingsSchema.js.map +1 -0
- package/dist/common/settingsSchema.mjs +10 -0
- package/dist/common/settingsSchema.mjs.map +1 -0
- package/dist/common/telemetry.d.mts +6 -0
- package/dist/common/telemetry.d.ts +6 -3
- package/dist/common/telemetry.js +41 -9
- package/dist/common/telemetry.js.map +1 -0
- package/dist/common/telemetry.mjs +31 -0
- package/dist/common/telemetry.mjs.map +1 -0
- package/dist/export.d-BAUMB-lG.d.mts +140 -0
- package/dist/export.d-BAUMB-lG.d.ts +140 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +783 -98
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +47 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime/index.d.mts +163 -0
- package/dist/runtime/index.d.ts +163 -10
- package/dist/runtime/index.js +779 -88
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/index.mjs +42 -0
- package/dist/runtime/index.mjs.map +1 -0
- package/package.json +80 -23
- package/.babelrc +0 -21
- package/.eslintignore +0 -10
- package/.eslintrc.js +0 -39
- package/InterfaceTemplate/index.playwright.ts +0 -6
- package/InterfaceTemplate/utils.ts +0 -61
- package/dist/commands/api/run.d.ts +0 -6
- package/dist/commands/api/run.js +0 -123
- package/dist/commands/auth-sessions/load.d.ts +0 -2
- package/dist/commands/auth-sessions/load.js +0 -35
- package/dist/commands/auth-sessions/run-check.d.ts +0 -2
- package/dist/commands/auth-sessions/run-check.js +0 -74
- package/dist/commands/auth-sessions/run-create.d.ts +0 -2
- package/dist/commands/auth-sessions/run-create.js +0 -78
- package/dist/commands/browser/save-state.d.ts +0 -2
- package/dist/commands/browser/save-state.js +0 -17
- package/dist/commands/browser/start-browser.d.ts +0 -2
- package/dist/commands/browser/start-browser.js +0 -14
- package/dist/commands/build.d.ts +0 -1
- package/dist/commands/build.js +0 -84
- package/dist/commands/common/browserUtils.d.ts +0 -14
- package/dist/commands/common/browserUtils.js +0 -58
- package/dist/commands/common/getFirstLineNumber.d.ts +0 -9
- package/dist/commands/common/getFirstLineNumber.js +0 -101
- package/dist/commands/common/getFirstLineNumber.test.js +0 -228
- package/dist/commands/common/projectExclusions.d.ts +0 -2
- package/dist/commands/common/projectExclusions.js +0 -8
- package/dist/commands/common/sendMessageToClient.d.ts +0 -1
- package/dist/commands/common/sendMessageToClient.js +0 -10
- package/dist/commands/common/tsNodeImport.d.ts +0 -2
- package/dist/commands/common/tsNodeImport.js +0 -34
- package/dist/commands/common/utils/fileUtils.d.ts +0 -6
- package/dist/commands/common/utils/fileUtils.js +0 -33
- package/dist/commands/common/utils/settings.d.ts +0 -2
- package/dist/commands/common/utils/settings.js +0 -31
- package/dist/commands/common/utils/template.d.ts +0 -2
- package/dist/commands/common/utils/template.js +0 -31
- package/dist/commands/common/utils/unixSocket.d.ts +0 -23
- package/dist/commands/common/utils/unixSocket.js +0 -87
- package/dist/commands/get-headless-user-agent.d.ts +0 -1
- package/dist/commands/get-headless-user-agent.js +0 -18
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
- package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/build.command.js +0 -12
- package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
- package/dist/commands/intuned-cli/commands/command.js +0 -9
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +0 -38
- package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
- package/dist/commands/intuned-cli/commands/index.js +0 -203
- package/dist/commands/intuned-cli/commands/init.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/init.command.js +0 -13
- package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run.command.js +0 -8
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -31
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
- package/dist/commands/intuned-cli/commands/save.command.d.ts +0 -13
- package/dist/commands/intuned-cli/commands/save.command.js +0 -42
- package/dist/commands/intuned-cli/commands/types.d.ts +0 -35
- package/dist/commands/intuned-cli/commands/types.js +0 -31
- package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
- package/dist/commands/intuned-cli/constants/index.js +0 -25
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -397
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1059
- package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
- package/dist/commands/intuned-cli/controller/api.js +0 -191
- package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
- package/dist/commands/intuned-cli/controller/authSession.js +0 -424
- package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/build.js +0 -36
- package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
- package/dist/commands/intuned-cli/controller/deploy.js +0 -276
- package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
- package/dist/commands/intuned-cli/controller/index.js +0 -46
- package/dist/commands/intuned-cli/controller/save.d.ts +0 -17
- package/dist/commands/intuned-cli/controller/save.js +0 -351
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -114
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -40
- package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/api.js +0 -19
- package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
- package/dist/commands/intuned-cli/helpers/auth.js +0 -144
- package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
- package/dist/commands/intuned-cli/helpers/backend.js +0 -27
- package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -15
- package/dist/commands/intuned-cli/helpers/browser.js +0 -64
- package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
- package/dist/commands/intuned-cli/helpers/context.js +0 -33
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
- package/dist/commands/intuned-cli/helpers/errors.js +0 -44
- package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
- package/dist/commands/intuned-cli/helpers/index.js +0 -137
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -39
- package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
- package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
- package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
- package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/traces.js +0 -32
- package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/validation.js +0 -14
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
- package/dist/commands/intuned-cli/helpers/wrapper.js +0 -66
- package/dist/commands/intuned-cli/index.d.ts +0 -1
- package/dist/commands/intuned-cli/index.js +0 -16
- package/dist/commands/intuned-cli/main.d.ts +0 -1
- package/dist/commands/intuned-cli/main.js +0 -23
- package/dist/commands/intuned-cli/types.d.ts +0 -41
- package/dist/commands/intuned-cli/types.js +0 -12
- package/dist/commands/ts-check.d.ts +0 -2
- package/dist/commands/ts-check.js +0 -56
- package/dist/common/Logger/Logger/index.d.ts +0 -12
- package/dist/common/Logger/Logger/index.js +0 -60
- package/dist/common/Logger/Logger/types.d.ts +0 -8
- package/dist/common/Logger/Logger/types.js +0 -5
- package/dist/common/Logger/index.d.ts +0 -12
- package/dist/common/Logger/index.js +0 -60
- package/dist/common/Logger/types.d.ts +0 -8
- package/dist/common/Logger/types.js +0 -5
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
- package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
- package/dist/common/extension/extensionsHelpers.d.ts +0 -11
- package/dist/common/extension/extensionsHelpers.js +0 -147
- package/dist/common/extension/intunedExtensionServer.d.ts +0 -24
- package/dist/common/extension/intunedExtensionServer.js +0 -178
- package/dist/common/extension/types.d.ts +0 -212
- package/dist/common/extension/types.js +0 -51
- package/dist/common/formatZodError.d.ts +0 -2
- package/dist/common/intunedJson.d.ts +0 -229
- package/dist/common/intunedJson.js +0 -133
- package/dist/common/launchBrowser.d.ts +0 -31
- package/dist/common/launchBrowser.js +0 -207
- package/dist/common/playwrightContext.d.ts +0 -31
- package/dist/common/playwrightContext.js +0 -144
- package/dist/common/runApi/errors.d.ts +0 -72
- package/dist/common/runApi/errors.js +0 -169
- package/dist/common/runApi/importUsingImportFunction.d.ts +0 -9
- package/dist/common/runApi/importUsingImportFunction.js +0 -46
- package/dist/common/runApi/types.d.ts +0 -830
- package/dist/common/runApi/types.js +0 -73
- package/dist/common/setupContextHook.d.ts +0 -17
- package/dist/common/setupContextHook.js +0 -22
- package/dist/runtime/RunError.d.ts +0 -5
- package/dist/runtime/RunError.js +0 -19
- package/dist/runtime/attemptStore.d.ts +0 -2
- package/dist/runtime/attemptStore.js +0 -23
- package/dist/runtime/captcha.d.ts +0 -15
- package/dist/runtime/captcha.js +0 -191
- package/dist/runtime/captcha.test.js +0 -821
- package/dist/runtime/downloadDirectory.d.ts +0 -1
- package/dist/runtime/downloadDirectory.js +0 -19
- package/dist/runtime/enums.d.js +0 -5
- package/dist/runtime/enums.d.ts +0 -11
- package/dist/runtime/enums.js +0 -18
- package/dist/runtime/executionHelpers.test.js +0 -52
- package/dist/runtime/export.d.js +0 -5
- package/dist/runtime/export.d.ts +0 -284
- package/dist/runtime/extendPayload.d.ts +0 -2
- package/dist/runtime/extendPayload.js +0 -21
- package/dist/runtime/extendTimeout.d.ts +0 -1
- package/dist/runtime/extendTimeout.js +0 -23
- package/dist/runtime/getAiGatewayConfig.d.ts +0 -10
- package/dist/runtime/getAiGatewayConfig.js +0 -16
- package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
- package/dist/runtime/getAuthSessionParameters.js +0 -20
- package/dist/runtime/persistentStore.d.ts +0 -2
- package/dist/runtime/persistentStore.js +0 -37
- package/dist/runtime/persistentStore.test.js +0 -101
- package/dist/runtime/runInfo.d.ts +0 -2
- package/dist/runtime/runInfo.js +0 -21
- package/template.tsconfig.json +0 -11
- package/tsconfig.eslint.json +0 -5
- package/tsconfig.json +0 -25
- package/typedoc.json +0 -49
- /package/dist/common/assets/{browser_scripts.js → assets/browser_scripts.js} +0 -0
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.projectNameSchema = exports.START_RUN_INPUT_QUERY_PARAM_KEY = void 0;
|
|
7
|
-
exports.runDeployProject = runDeployProject;
|
|
8
|
-
var _zod = require("zod");
|
|
9
|
-
var _constants = require("../constants");
|
|
10
|
-
var _helpers = require("../helpers");
|
|
11
|
-
var _terminal = require("../helpers/terminal");
|
|
12
|
-
var _promises = require("timers/promises");
|
|
13
|
-
var _ms = _interopRequireDefault(require("ms"));
|
|
14
|
-
var _save = require("./save");
|
|
15
|
-
var _constants2 = require("../../../common/constants");
|
|
16
|
-
var _path = _interopRequireDefault(require("path"));
|
|
17
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
18
|
-
var _prompts = _interopRequireDefault(require("prompts"));
|
|
19
|
-
var _terminalLink = _interopRequireDefault(require("terminal-link"));
|
|
20
|
-
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); }
|
|
21
|
-
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; }
|
|
22
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
const START_RUN_INPUT_QUERY_PARAM_KEY = exports.START_RUN_INPUT_QUERY_PARAM_KEY = "startRunInput";
|
|
24
|
-
async function runDeployProject(projectName, auth) {
|
|
25
|
-
const result = await (0, _save.runSaveProject)(projectName, auth);
|
|
26
|
-
const enableFirstRunExperience = result?.enableFirstRunExperience ?? false;
|
|
27
|
-
let firstRunExperienceInput = undefined;
|
|
28
|
-
const settings = await (0, _helpers.loadIntunedJson)();
|
|
29
|
-
if (enableFirstRunExperience) {
|
|
30
|
-
firstRunExperienceInput = await promptFirstRunExperience(settings);
|
|
31
|
-
}
|
|
32
|
-
const {
|
|
33
|
-
workspaceId,
|
|
34
|
-
apiKey
|
|
35
|
-
} = auth;
|
|
36
|
-
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
37
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy`;
|
|
38
|
-
const headers = {
|
|
39
|
-
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
40
|
-
"Content-Type": "application/json"
|
|
41
|
-
};
|
|
42
|
-
const response = await fetch(url, {
|
|
43
|
-
headers,
|
|
44
|
-
method: "POST",
|
|
45
|
-
body: JSON.stringify({
|
|
46
|
-
firstRunExperienceInput
|
|
47
|
-
})
|
|
48
|
-
});
|
|
49
|
-
if (!response.ok) {
|
|
50
|
-
if (response.status === 401) {
|
|
51
|
-
throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
|
|
52
|
-
}
|
|
53
|
-
throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project deployment failed^:\n`, {
|
|
54
|
-
autoColor: false
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
(0, _terminal.terminal)("\n");
|
|
58
|
-
const startTime = Date.now();
|
|
59
|
-
const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
|
|
60
|
-
function* getSpinnerGenerator() {
|
|
61
|
-
while (true) {
|
|
62
|
-
yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const spinnerGen = getSpinnerGenerator();
|
|
66
|
-
let updateSpinnerInterval = null;
|
|
67
|
-
if (_terminal.terminalStdout.isTTY) {
|
|
68
|
-
updateSpinnerInterval = setInterval(() => {
|
|
69
|
-
_terminal.terminal.previousLine(1);
|
|
70
|
-
_terminal.terminal.column(0);
|
|
71
|
-
_terminal.terminal.eraseLineAfter();
|
|
72
|
-
(0, _terminal.terminal)(`${spinnerGen.next().value} ^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
73
|
-
}, 50);
|
|
74
|
-
(0, _terminal.terminal)("\n");
|
|
75
|
-
} else {
|
|
76
|
-
(0, _terminal.terminal)(`^cDeploying ^:\n`);
|
|
77
|
-
}
|
|
78
|
-
try {
|
|
79
|
-
while (true) {
|
|
80
|
-
await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
|
|
81
|
-
if (!_terminal.terminalStdout.isTTY) {
|
|
82
|
-
(0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
83
|
-
}
|
|
84
|
-
const {
|
|
85
|
-
status,
|
|
86
|
-
message,
|
|
87
|
-
projectId,
|
|
88
|
-
...rest
|
|
89
|
-
} = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
|
|
90
|
-
if (status === "pending") {
|
|
91
|
-
const elapsedTime = Date.now() - startTime;
|
|
92
|
-
if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
|
|
93
|
-
throw new _helpers.CLIError(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / (0, _ms.default)("1 minute"))} minutes`);
|
|
94
|
-
}
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
_terminal.terminal.previousLine(1);
|
|
98
|
-
_terminal.terminal.eraseLine();
|
|
99
|
-
if (updateSpinnerInterval) {
|
|
100
|
-
clearTimeout(updateSpinnerInterval);
|
|
101
|
-
}
|
|
102
|
-
if (status === "completed") {
|
|
103
|
-
const url = (0, _helpers.getBaseUrl)();
|
|
104
|
-
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n\n`);
|
|
105
|
-
const projectUrl = `${url}/projects/${projectId}`;
|
|
106
|
-
const runsUrl = `${projectUrl}/runs`;
|
|
107
|
-
const jobsUrl = `${projectUrl}/jobs`;
|
|
108
|
-
const runsPlaygroundUrl = `${runsUrl}?${buildRunsPlaygroundQueryParams({
|
|
109
|
-
enableFirstRunExperience,
|
|
110
|
-
settings,
|
|
111
|
-
testAuthSessionId: rest.testAuthSessionId
|
|
112
|
-
})}`;
|
|
113
|
-
const defaultJobTriggerUrl = rest.defaultJobId ? `${jobsUrl}/${rest.defaultJobId}?action=trigger` : undefined;
|
|
114
|
-
const actions = [{
|
|
115
|
-
label: "View Project",
|
|
116
|
-
url: runsUrl
|
|
117
|
-
}, ...(settings.apiAccess.enabled ? [{
|
|
118
|
-
label: "Run Playground",
|
|
119
|
-
url: runsPlaygroundUrl
|
|
120
|
-
}] : []), {
|
|
121
|
-
label: "Manage Jobs",
|
|
122
|
-
url: jobsUrl
|
|
123
|
-
}, ...(defaultJobTriggerUrl !== undefined ? [{
|
|
124
|
-
label: "Trigger Default Job",
|
|
125
|
-
url: defaultJobTriggerUrl
|
|
126
|
-
}] : [])];
|
|
127
|
-
if (_terminalLink.default.isSupported) {
|
|
128
|
-
for (const action of actions) {
|
|
129
|
-
const link = (0, _terminalLink.default)(`[ ${action.label} ]`, action.url);
|
|
130
|
-
(0, _terminal.terminal)(`^+${link.replaceAll("%", "%%")}^ `);
|
|
131
|
-
}
|
|
132
|
-
(0, _terminal.terminal)("\n");
|
|
133
|
-
} else {
|
|
134
|
-
for (const action of actions) {
|
|
135
|
-
(0, _terminal.terminal)(`^+${action.label}:^ ^c^_${action.url}^:\n`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
141
|
-
if (rest.reason) {
|
|
142
|
-
errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
|
|
143
|
-
}
|
|
144
|
-
errorMessage += `^r^+Project deployment failed^:\n`;
|
|
145
|
-
throw new _helpers.CLIError(errorMessage, {
|
|
146
|
-
autoColor: false
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
} catch (e) {
|
|
150
|
-
if (updateSpinnerInterval) {
|
|
151
|
-
clearTimeout(updateSpinnerInterval);
|
|
152
|
-
}
|
|
153
|
-
throw e;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 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, {
|
|
157
|
-
message: "Name cannot be a UUID"
|
|
158
|
-
});
|
|
159
|
-
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
160
|
-
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
161
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy/result`;
|
|
162
|
-
const headers = {
|
|
163
|
-
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
164
|
-
"Content-Type": "application/json"
|
|
165
|
-
};
|
|
166
|
-
const response = await fetch(url, {
|
|
167
|
-
headers,
|
|
168
|
-
method: "GET"
|
|
169
|
-
});
|
|
170
|
-
if (response.status === 404) {
|
|
171
|
-
return {
|
|
172
|
-
status: "not_found",
|
|
173
|
-
message: "Project not found"
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
if (!response.ok) {
|
|
177
|
-
throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
|
|
178
|
-
}
|
|
179
|
-
const data = await response.json();
|
|
180
|
-
if (data.status) {
|
|
181
|
-
return data;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
status: "failed",
|
|
185
|
-
message: `Deployment failed, please try again: ${data.message}`
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
async function promptFirstRunExperience(settings) {
|
|
189
|
-
let testAuthSessionInput = undefined;
|
|
190
|
-
const shouldPromptForTestAuthSession = settings.authSessions.enabled && settings.authSessions.type === "API";
|
|
191
|
-
const defaultJobInput = settings.metadata?.defaultJobInput;
|
|
192
|
-
const shouldPromptForDefaultJob = defaultJobInput !== undefined;
|
|
193
|
-
if (shouldPromptForTestAuthSession) {
|
|
194
|
-
testAuthSessionInput = await promptFirstRunExperienceTestAuthSessionParameters({
|
|
195
|
-
shouldPromptForDefaultJob
|
|
196
|
-
});
|
|
197
|
-
if (!testAuthSessionInput) {
|
|
198
|
-
return {};
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
testAuthSessionInput,
|
|
203
|
-
defaultJobInput: shouldPromptForDefaultJob ? await promptFirstRunExperienceDefaultJobParameters({
|
|
204
|
-
defaultJobInput
|
|
205
|
-
}) : undefined
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
async function promptFirstRunExperienceTestAuthSessionParameters({
|
|
209
|
-
shouldPromptForDefaultJob
|
|
210
|
-
}) {
|
|
211
|
-
const authSessionInstancesDirectory = _path.default.join(process.cwd(), _constants2.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
212
|
-
if (!(await fs.exists(authSessionInstancesDirectory))) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const authSessionId = (await fs.readdir(authSessionInstancesDirectory)).shift();
|
|
216
|
-
if (!authSessionId) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const {
|
|
220
|
-
metadata
|
|
221
|
-
} = await (0, _helpers.loadAuthSessionInstance)(authSessionId);
|
|
222
|
-
if (!metadata.authSessionId) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const message = shouldPromptForDefaultJob ? `^:^+Create a test auth session using^ ^c${authSessionId}^:^+ parameters?^ ^/(required for creating default job)^:` : `^:^+Create a test auth session using^ ^c${authSessionId}^:^+ parameters?^:`;
|
|
226
|
-
const {
|
|
227
|
-
value
|
|
228
|
-
} = await (0, _prompts.default)({
|
|
229
|
-
type: "confirm",
|
|
230
|
-
name: "value",
|
|
231
|
-
message: _terminal.terminal.str(message).toString(),
|
|
232
|
-
initial: true
|
|
233
|
-
});
|
|
234
|
-
if (value === undefined) {
|
|
235
|
-
throw new _helpers.AbortedCLIError();
|
|
236
|
-
}
|
|
237
|
-
if (value) {
|
|
238
|
-
return metadata.authSessionInput;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
async function promptFirstRunExperienceDefaultJobParameters({
|
|
242
|
-
defaultJobInput
|
|
243
|
-
}) {
|
|
244
|
-
const {
|
|
245
|
-
value
|
|
246
|
-
} = await (0, _prompts.default)({
|
|
247
|
-
type: "confirm",
|
|
248
|
-
name: "value",
|
|
249
|
-
message: _terminal.terminal.str(`^:^+Create a default job with sample parameters?^:`).toString(),
|
|
250
|
-
initial: true
|
|
251
|
-
});
|
|
252
|
-
if (value === undefined) {
|
|
253
|
-
throw new _helpers.AbortedCLIError();
|
|
254
|
-
}
|
|
255
|
-
if (value) {
|
|
256
|
-
return defaultJobInput;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function buildRunsPlaygroundQueryParams({
|
|
260
|
-
enableFirstRunExperience,
|
|
261
|
-
settings,
|
|
262
|
-
testAuthSessionId
|
|
263
|
-
}) {
|
|
264
|
-
const params = new URLSearchParams();
|
|
265
|
-
if (!enableFirstRunExperience) return params.toString();
|
|
266
|
-
params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({}));
|
|
267
|
-
const input = settings.metadata?.defaultRunPlaygroundInput;
|
|
268
|
-
if (!input) return params.toString();
|
|
269
|
-
if (testAuthSessionId) {
|
|
270
|
-
input.authSessionId = testAuthSessionId;
|
|
271
|
-
}
|
|
272
|
-
params.set(START_RUN_INPUT_QUERY_PARAM_KEY, JSON.stringify({
|
|
273
|
-
...input
|
|
274
|
-
}));
|
|
275
|
-
return params.toString();
|
|
276
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function loadParameters(parameters: string): Promise<object | null>;
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { AuthCredentials } from "../types";
|
|
3
|
-
export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<{
|
|
4
|
-
projectId: string;
|
|
5
|
-
enableFirstRunExperience: boolean | undefined;
|
|
6
|
-
} | undefined>;
|
|
7
|
-
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
-
export declare const validateProjectName: (projectName: string) => {
|
|
9
|
-
isValid: true;
|
|
10
|
-
} | {
|
|
11
|
-
isValid: false;
|
|
12
|
-
errorMessage: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const validateIntunedProject: () => Promise<{
|
|
15
|
-
isValid: boolean;
|
|
16
|
-
errorMessage?: string;
|
|
17
|
-
}>;
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.projectNameSchema = void 0;
|
|
7
|
-
exports.runSaveProject = runSaveProject;
|
|
8
|
-
exports.validateProjectName = exports.validateIntunedProject = void 0;
|
|
9
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
10
|
-
var path = _interopRequireWildcard(require("path"));
|
|
11
|
-
var _minimatch = require("minimatch");
|
|
12
|
-
var _zod = require("zod");
|
|
13
|
-
var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
|
|
14
|
-
var _constants = require("../constants");
|
|
15
|
-
var _helpers = require("../helpers");
|
|
16
|
-
var _lodash = require("lodash");
|
|
17
|
-
var _uuid = require("uuid");
|
|
18
|
-
var _terminal = require("../helpers/terminal");
|
|
19
|
-
var _build = require("./build");
|
|
20
|
-
var dotenv = _interopRequireWildcard(require("dotenv"));
|
|
21
|
-
var _constants2 = require("../../../common/constants");
|
|
22
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
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
|
-
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 saveProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
|
|
26
|
-
try {
|
|
27
|
-
return JSON.parse(val);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
ctx.addIssue({
|
|
30
|
-
code: _zod.z.ZodIssueCode.custom,
|
|
31
|
-
message: "Response is not valid JSON"
|
|
32
|
-
});
|
|
33
|
-
return _zod.z.NEVER;
|
|
34
|
-
}
|
|
35
|
-
}).pipe(_zod.z.object({
|
|
36
|
-
id: _zod.z.string().uuid(),
|
|
37
|
-
enableFirstRunExperience: _zod.z.boolean().optional()
|
|
38
|
-
}));
|
|
39
|
-
async function runSaveProject(projectName, auth) {
|
|
40
|
-
const {
|
|
41
|
-
workspaceId,
|
|
42
|
-
apiKey
|
|
43
|
-
} = auth;
|
|
44
|
-
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
45
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}`;
|
|
46
|
-
const headers = {
|
|
47
|
-
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
-
};
|
|
50
|
-
const projectPath = process.cwd();
|
|
51
|
-
const codeTree = await convertProjectToCodeTree(projectPath);
|
|
52
|
-
const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
|
|
53
|
-
codeTree["Intuned.json"] = {
|
|
54
|
-
file: {
|
|
55
|
-
contents: JSON.stringify(intunedSettingsFile.parse(await fs.readFile(intunedSettingsFile.path, "utf-8")))
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
codeTree["tsconfig.json"] = {
|
|
59
|
-
file: {
|
|
60
|
-
contents: JSON.stringify(_constants.tsConfigCli, null, 2)
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const saveProjectPayload = {
|
|
64
|
-
codeTree,
|
|
65
|
-
platformType: "CLI",
|
|
66
|
-
language: "typescript"
|
|
67
|
-
};
|
|
68
|
-
const response = await fetch(url, {
|
|
69
|
-
headers,
|
|
70
|
-
method: "PUT",
|
|
71
|
-
body: JSON.stringify(saveProjectPayload)
|
|
72
|
-
});
|
|
73
|
-
if (!response.ok) {
|
|
74
|
-
if (response.status === 401) {
|
|
75
|
-
throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
|
|
76
|
-
}
|
|
77
|
-
throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project save failed^:\n`, {
|
|
78
|
-
autoColor: false
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
(0, _terminal.terminal)("^g^+Project saved successfully!^:\n");
|
|
82
|
-
const body = await response.text();
|
|
83
|
-
const parseResult = saveProjectApiResponseSchema.safeParse(body);
|
|
84
|
-
if (!parseResult.success) {
|
|
85
|
-
(0, _terminal.terminal)(`^yWarning: Could not parse save project response:^:\n`);
|
|
86
|
-
(0, _terminal.terminal)(body + "\n");
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const {
|
|
90
|
-
id: projectId,
|
|
91
|
-
enableFirstRunExperience
|
|
92
|
-
} = parseResult.data;
|
|
93
|
-
const dotEnvPath = path.join(projectPath, ".env");
|
|
94
|
-
if (!(await fs.exists(dotEnvPath))) {
|
|
95
|
-
await fs.writeFile(dotEnvPath, `${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}
|
|
96
|
-
${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
|
|
97
|
-
${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
|
|
98
|
-
(0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
|
|
99
|
-
}
|
|
100
|
-
const envContent = await fs.readFile(dotEnvPath, "utf-8");
|
|
101
|
-
const dotenvContent = dotenv.parse(envContent);
|
|
102
|
-
let contentToAppend = "";
|
|
103
|
-
if (!dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] || dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] !== projectId) {
|
|
104
|
-
contentToAppend += `\n${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}`;
|
|
105
|
-
}
|
|
106
|
-
if (!dotenvContent[_constants2.WORKSPACE_ID_ENV_VAR_KEY]) {
|
|
107
|
-
contentToAppend += `\n${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}`;
|
|
108
|
-
}
|
|
109
|
-
if (!dotenvContent[_constants2.API_KEY_ENV_VAR_KEY]) {
|
|
110
|
-
contentToAppend += `\n${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`;
|
|
111
|
-
}
|
|
112
|
-
if (contentToAppend) {
|
|
113
|
-
await fs.appendFile(dotEnvPath, contentToAppend + "\n");
|
|
114
|
-
(0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
projectId,
|
|
118
|
-
enableFirstRunExperience
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 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, {
|
|
122
|
-
message: "Name cannot be a UUID"
|
|
123
|
-
});
|
|
124
|
-
const validateProjectName = projectName => {
|
|
125
|
-
const validation = projectNameSchema.safeParse(projectName);
|
|
126
|
-
if (!validation.success) {
|
|
127
|
-
return {
|
|
128
|
-
isValid: false,
|
|
129
|
-
errorMessage: validation.error.errors[0].message
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
return {
|
|
133
|
-
isValid: true
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
exports.validateProjectName = validateProjectName;
|
|
137
|
-
const validateIntunedProject = async () => {
|
|
138
|
-
const currentDirectoryToSave = process.cwd();
|
|
139
|
-
const intunedSettingsFile = await (0, _helpers.getIntunedSettingsFile)();
|
|
140
|
-
const validationSteps = [{
|
|
141
|
-
name: "build",
|
|
142
|
-
check: async () => {
|
|
143
|
-
try {
|
|
144
|
-
const buildResult = await (0, _build.runBuild)();
|
|
145
|
-
if (!buildResult) {
|
|
146
|
-
return {
|
|
147
|
-
isValid: false,
|
|
148
|
-
errorMessage: "Build failed"
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
isValid: true
|
|
153
|
-
};
|
|
154
|
-
} catch (error) {
|
|
155
|
-
return {
|
|
156
|
-
isValid: false,
|
|
157
|
-
errorMessage: "Build failed"
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
name: intunedSettingsFile.name,
|
|
163
|
-
check: async () => {
|
|
164
|
-
try {
|
|
165
|
-
const intunedJsonPath = path.join(currentDirectoryToSave, intunedSettingsFile.name);
|
|
166
|
-
await fs.exists(intunedJsonPath);
|
|
167
|
-
return {
|
|
168
|
-
isValid: true
|
|
169
|
-
};
|
|
170
|
-
} catch (error) {
|
|
171
|
-
return {
|
|
172
|
-
isValid: false,
|
|
173
|
-
errorMessage: `${intunedSettingsFile.name} file not found`
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}, {
|
|
178
|
-
name: "api folder",
|
|
179
|
-
check: async () => {
|
|
180
|
-
try {
|
|
181
|
-
const apiFolderPath = path.join(currentDirectoryToSave, "api");
|
|
182
|
-
await fs.access(apiFolderPath);
|
|
183
|
-
return {
|
|
184
|
-
isValid: true
|
|
185
|
-
};
|
|
186
|
-
} catch (error) {
|
|
187
|
-
return {
|
|
188
|
-
isValid: false,
|
|
189
|
-
errorMessage: "API folder not found"
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}];
|
|
194
|
-
for (const step of validationSteps) {
|
|
195
|
-
const result = await step.check();
|
|
196
|
-
if (!result.isValid) {
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return {
|
|
201
|
-
isValid: true
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
exports.validateIntunedProject = validateIntunedProject;
|
|
205
|
-
function ignoreFilesByPattern(filePath, patterns, projectPath) {
|
|
206
|
-
const relativePath = path.relative(projectPath, filePath);
|
|
207
|
-
if (relativePath.startsWith("node_modules")) {
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
for (const pattern of patterns) {
|
|
211
|
-
if (!pattern || pattern.startsWith("#")) continue;
|
|
212
|
-
if (pattern.startsWith("!")) {
|
|
213
|
-
if ((0, _minimatch.minimatch)(relativePath, pattern.substring(1))) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
} else if ((0, _minimatch.minimatch)(relativePath, pattern)) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
function listFilesNotIgnored(projectPath, ignorePatterns) {
|
|
223
|
-
const results = [];
|
|
224
|
-
function traverseDirectory(dirPath) {
|
|
225
|
-
try {
|
|
226
|
-
const entries = fs.readdirSync(dirPath);
|
|
227
|
-
for (const entry of entries) {
|
|
228
|
-
const fullPath = path.join(dirPath, entry);
|
|
229
|
-
if (ignoreFilesByPattern(fullPath, ignorePatterns, projectPath)) {
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
try {
|
|
233
|
-
const stats = fs.statSync(fullPath);
|
|
234
|
-
if (stats.isDirectory()) {
|
|
235
|
-
traverseDirectory(fullPath);
|
|
236
|
-
} else if (stats.isFile()) {
|
|
237
|
-
results.push(path.relative(projectPath, fullPath));
|
|
238
|
-
}
|
|
239
|
-
} catch (error) {
|
|
240
|
-
(0, _terminal.terminal)(`^yWarning: Could not access ${fullPath}^:\n`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
} catch (error) {
|
|
244
|
-
(0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
traverseDirectory(projectPath);
|
|
248
|
-
return results;
|
|
249
|
-
}
|
|
250
|
-
async function convertProjectToCodeTree(projectPath) {
|
|
251
|
-
const filesToSave = listFilesNotIgnored(projectPath, _projectExclusions.default);
|
|
252
|
-
const filesToSaveText = " " + filesToSave.join("\n ");
|
|
253
|
-
(0, _terminal.terminal)("^CFiles to be saved:^:\n");
|
|
254
|
-
(0, _terminal.terminal)(filesToSaveText + "\n");
|
|
255
|
-
function readDirectory(dirPath) {
|
|
256
|
-
const tree = {};
|
|
257
|
-
try {
|
|
258
|
-
const entries = fs.readdirSync(dirPath);
|
|
259
|
-
for (const entry of entries) {
|
|
260
|
-
const entryPath = path.join(dirPath, entry);
|
|
261
|
-
if (ignoreFilesByPattern(entryPath, _projectExclusions.default, projectPath)) {
|
|
262
|
-
continue;
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
const stats = fs.statSync(entryPath);
|
|
266
|
-
if (stats.isFile()) {
|
|
267
|
-
try {
|
|
268
|
-
const content = fs.readFileSync(entryPath, "utf-8");
|
|
269
|
-
tree[entry] = {
|
|
270
|
-
file: {
|
|
271
|
-
contents: content
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
} catch (error) {
|
|
275
|
-
(0, _terminal.terminal)(`^yWarning: Could not read file ${entryPath}^:\n`);
|
|
276
|
-
}
|
|
277
|
-
} else if (stats.isDirectory()) {
|
|
278
|
-
const subTree = readDirectory(entryPath);
|
|
279
|
-
if (Object.keys(subTree).length > 0) {
|
|
280
|
-
tree[entry] = {
|
|
281
|
-
directory: subTree
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
(0, _terminal.terminal)(`^yWarning: Could not access ${entryPath}^:\n`);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
} catch (error) {
|
|
290
|
-
(0, _terminal.terminal)(`^YWarning: Could not read directory ${dirPath}^:\n`);
|
|
291
|
-
}
|
|
292
|
-
return tree;
|
|
293
|
-
}
|
|
294
|
-
const tree = readDirectory(projectPath);
|
|
295
|
-
mapToIDEParams(tree);
|
|
296
|
-
return tree;
|
|
297
|
-
}
|
|
298
|
-
function mapToIDEParams(tree) {
|
|
299
|
-
if (!tree) {
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
if (!tree["parameters"] || "file" in tree["parameters"]) {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const apiParametersMap = {};
|
|
306
|
-
const cliParameters = Object.keys(tree["parameters"].directory);
|
|
307
|
-
const ____testParameters = {
|
|
308
|
-
directory: {}
|
|
309
|
-
};
|
|
310
|
-
for (const parameterKey of cliParameters) {
|
|
311
|
-
const parameter = tree["parameters"].directory[parameterKey];
|
|
312
|
-
if ("directory" in parameter) {
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
if ((0, _lodash.isEmpty)(parameter.file.contents)) {
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
const parameterPayload = JSON.parse(parameter.file.contents);
|
|
319
|
-
if (!parameterPayload["__api-name"]) {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
const api = parameterPayload["__api-name"];
|
|
323
|
-
const {
|
|
324
|
-
"__api-name": _,
|
|
325
|
-
...parameterValue
|
|
326
|
-
} = parameterPayload;
|
|
327
|
-
const testParameter = {
|
|
328
|
-
name: parameterKey.replace(".json", ""),
|
|
329
|
-
lastUsed: false,
|
|
330
|
-
id: (0, _uuid.v4)(),
|
|
331
|
-
value: JSON.stringify(parameterValue)
|
|
332
|
-
};
|
|
333
|
-
if (!apiParametersMap[api]) {
|
|
334
|
-
apiParametersMap[api] = [];
|
|
335
|
-
}
|
|
336
|
-
apiParametersMap[api].push(testParameter);
|
|
337
|
-
}
|
|
338
|
-
for (const api in apiParametersMap) {
|
|
339
|
-
if (apiParametersMap[api].length > 0) {
|
|
340
|
-
apiParametersMap[api][apiParametersMap[api].length - 1].lastUsed = true;
|
|
341
|
-
}
|
|
342
|
-
____testParameters.directory[`${api}.json`] = {
|
|
343
|
-
file: {
|
|
344
|
-
contents: JSON.stringify(apiParametersMap[api], null, 2)
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
delete tree["parameters"];
|
|
349
|
-
tree["____testParameters"] = ____testParameters;
|
|
350
|
-
return;
|
|
351
|
-
}
|