@intuned/runtime-dev 1.3.8-fix.0 → 1.3.9-dev1
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/common.js +23 -0
- package/bin/intuned +2 -0
- package/bin/intuned-api-run +2 -0
- package/dist/commands/common/utils/settings.js +3 -0
- package/dist/common/settingsSchema.d.ts +13 -0
- package/dist/common/settingsSchema.js +6 -0
- package/package/dist/commands/api/run.d.ts +6 -0
- package/package/dist/commands/api/run.js +123 -0
- package/package/dist/commands/auth-sessions/load.d.ts +2 -0
- package/package/dist/commands/auth-sessions/load.js +35 -0
- package/package/dist/commands/auth-sessions/run-check.d.ts +2 -0
- package/package/dist/commands/auth-sessions/run-check.js +74 -0
- package/package/dist/commands/auth-sessions/run-create.d.ts +2 -0
- package/package/dist/commands/auth-sessions/run-create.js +78 -0
- package/package/dist/commands/browser/save-state.d.ts +2 -0
- package/package/dist/commands/browser/save-state.js +17 -0
- package/package/dist/commands/browser/start-browser.d.ts +2 -0
- package/package/dist/commands/browser/start-browser.js +14 -0
- package/package/dist/commands/build.d.ts +1 -0
- package/package/dist/commands/build.js +84 -0
- package/package/dist/commands/common/browserUtils.d.ts +14 -0
- package/package/dist/commands/common/browserUtils.js +58 -0
- package/package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
- package/package/dist/commands/common/getFirstLineNumber.js +101 -0
- package/package/dist/commands/common/getFirstLineNumber.test.js +228 -0
- package/package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/package/dist/commands/common/projectExclusions.js +8 -0
- package/package/dist/commands/common/sendMessageToClient.d.ts +1 -0
- package/package/dist/commands/common/sendMessageToClient.js +10 -0
- package/package/dist/commands/common/tsNodeImport.d.ts +2 -0
- package/package/dist/commands/common/tsNodeImport.js +34 -0
- package/package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/package/dist/commands/common/utils/fileUtils.js +33 -0
- package/package/dist/commands/common/utils/settings.d.ts +2 -0
- package/package/dist/commands/common/utils/settings.js +31 -0
- package/package/dist/commands/common/utils/template.d.ts +2 -0
- package/package/dist/commands/common/utils/template.js +31 -0
- package/package/dist/commands/common/utils/unixSocket.d.ts +9 -0
- package/package/dist/commands/common/utils/unixSocket.js +44 -0
- package/package/dist/commands/interface/run.d.ts +1 -0
- package/package/dist/commands/interface/run.js +216 -0
- package/package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
- package/package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
- package/package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/deploy.command.js +38 -0
- package/package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
- package/package/dist/commands/intuned-cli/commands/index.js +203 -0
- package/package/dist/commands/intuned-cli/commands/init.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/init.command.js +13 -0
- package/package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +28 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
- package/package/dist/commands/intuned-cli/commands/save.command.d.ts +13 -0
- package/package/dist/commands/intuned-cli/commands/save.command.js +42 -0
- package/package/dist/commands/intuned-cli/commands/types.d.ts +31 -0
- package/package/dist/commands/intuned-cli/commands/types.js +29 -0
- package/package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/package/dist/commands/intuned-cli/controller/__test__/api.test.js +397 -0
- package/package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1059 -0
- package/package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
- package/package/dist/commands/intuned-cli/controller/api.js +189 -0
- package/package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
- package/package/dist/commands/intuned-cli/controller/authSession.js +420 -0
- package/package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/package/dist/commands/intuned-cli/controller/deploy.d.ts +4 -0
- package/package/dist/commands/intuned-cli/controller/deploy.js +139 -0
- package/package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/package/dist/commands/intuned-cli/controller/save.d.ts +14 -0
- package/package/dist/commands/intuned-cli/controller/save.js +345 -0
- package/package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
- package/package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
- package/package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/package/dist/commands/intuned-cli/helpers/api.js +19 -0
- package/package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
- package/package/dist/commands/intuned-cli/helpers/auth.js +144 -0
- package/package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/package/dist/commands/intuned-cli/helpers/backend.js +27 -0
- package/package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/package/dist/commands/intuned-cli/helpers/browser.js +57 -0
- package/package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/package/dist/commands/intuned-cli/helpers/errors.d.ts +13 -0
- package/package/dist/commands/intuned-cli/helpers/errors.js +37 -0
- package/package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
- package/package/dist/commands/intuned-cli/helpers/index.js +137 -0
- package/package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -0
- package/package/dist/commands/intuned-cli/helpers/intunedJson.js +71 -0
- package/package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- package/package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/traces.js +32 -0
- package/package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/validation.js +14 -0
- package/package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
- package/package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/package/dist/commands/intuned-cli/index.js +16 -0
- package/package/dist/commands/intuned-cli/main.d.ts +1 -0
- package/package/dist/commands/intuned-cli/main.js +22 -0
- package/package/dist/commands/intuned-cli/types.d.ts +41 -0
- package/package/dist/commands/intuned-cli/types.js +12 -0
- package/package/dist/commands/ts-check.d.ts +2 -0
- package/package/dist/commands/ts-check.js +56 -0
- package/package/dist/common/Logger/Logger/index.d.ts +12 -0
- package/package/dist/common/Logger/Logger/index.js +60 -0
- package/package/dist/common/Logger/Logger/types.d.ts +8 -0
- package/package/dist/common/Logger/Logger/types.js +5 -0
- package/package/dist/common/Logger/index.d.ts +12 -0
- package/package/dist/common/Logger/index.js +60 -0
- package/package/dist/common/Logger/types.d.ts +8 -0
- package/package/dist/common/Logger/types.js +5 -0
- package/package/dist/common/assets/browser_scripts.js +2580 -0
- package/package/dist/common/asyncLocalStorage/index.d.ts +16 -0
- package/package/dist/common/asyncLocalStorage/index.js +17 -0
- package/package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
- package/package/dist/common/cleanEnvironmentVariables.js +16 -0
- package/package/dist/common/constants.d.ts +10 -0
- package/package/dist/common/constants.js +16 -0
- package/package/dist/common/contextStorageStateHelpers.d.ts +21 -0
- package/package/dist/common/contextStorageStateHelpers.js +81 -0
- package/package/dist/common/extensionsHelpers.d.ts +8 -0
- package/package/dist/common/extensionsHelpers.js +80 -0
- package/package/dist/common/formatZodError.d.ts +2 -0
- package/package/dist/common/formatZodError.js +18 -0
- package/package/dist/common/jwtTokenManager.d.ts +17 -0
- package/package/dist/common/jwtTokenManager.js +109 -0
- package/package/dist/common/launchBrowser.d.ts +25 -0
- package/package/dist/common/launchBrowser.js +172 -0
- package/package/dist/common/playwrightContext.d.ts +31 -0
- package/package/dist/common/playwrightContext.js +144 -0
- package/package/dist/common/runApi/errors.d.ts +72 -0
- package/package/dist/common/runApi/errors.js +169 -0
- package/package/dist/common/runApi/importUsingImportFunction.d.ts +9 -0
- package/package/dist/common/runApi/importUsingImportFunction.js +46 -0
- package/package/dist/common/runApi/index.d.ts +11 -0
- package/package/dist/common/runApi/index.js +199 -0
- package/package/dist/common/runApi/types.d.ts +830 -0
- package/package/dist/common/runApi/types.js +73 -0
- package/package/dist/common/settingsSchema.d.ts +518 -0
- package/package/dist/common/settingsSchema.js +57 -0
- package/package/dist/common/setupContextHook.d.ts +17 -0
- package/package/dist/common/setupContextHook.js +22 -0
- package/package/dist/common/telemetry.d.ts +3 -0
- package/package/dist/common/telemetry.js +32 -0
- package/package/dist/index.d.ts +4 -0
- package/package/dist/index.js +69 -0
- package/package/dist/runtime/RunError.d.ts +5 -0
- package/package/dist/runtime/RunError.js +19 -0
- package/package/dist/runtime/attemptStore.d.ts +2 -0
- package/package/dist/runtime/attemptStore.js +23 -0
- package/package/dist/runtime/downloadDirectory.d.ts +1 -0
- package/package/dist/runtime/downloadDirectory.js +19 -0
- package/package/dist/runtime/enums.d.js +5 -0
- package/package/dist/runtime/enums.d.ts +11 -0
- package/package/dist/runtime/enums.js +18 -0
- package/package/dist/runtime/executionHelpers.test.js +52 -0
- package/package/dist/runtime/export.d.js +5 -0
- package/package/dist/runtime/export.d.ts +228 -0
- package/package/dist/runtime/extendPayload.d.ts +2 -0
- package/package/dist/runtime/extendPayload.js +21 -0
- package/package/dist/runtime/extendTimeout.d.ts +1 -0
- package/package/dist/runtime/extendTimeout.js +23 -0
- package/package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/package/dist/runtime/index.d.ts +7 -0
- package/package/dist/runtime/index.js +54 -0
- package/package/dist/runtime/runInfo.d.ts +2 -0
- package/package/dist/runtime/runInfo.js +21 -0
- package/package.json +1 -1
- package/WebTemplate.zip +0 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports._runCreateWithRetries = exports._runCreate = exports._runCheckWithRetries = exports._runCheck = void 0;
|
|
7
|
+
exports.executeAttemptCheckAuthSessionCLI = executeAttemptCheckAuthSessionCLI;
|
|
8
|
+
exports.executeAttemptCreateAuthSessionCLI = executeAttemptCreateAuthSessionCLI;
|
|
9
|
+
exports.executeRecordAuthSessionCLI = executeRecordAuthSessionCLI;
|
|
10
|
+
exports.executeRunCreateAuthSessionCLI = executeRunCreateAuthSessionCLI;
|
|
11
|
+
exports.executeRunUpdateAuthSessionCLI = executeRunUpdateAuthSessionCLI;
|
|
12
|
+
exports.executeRunValidateAuthSessionCLI = executeRunValidateAuthSessionCLI;
|
|
13
|
+
var _helpers = require("../helpers");
|
|
14
|
+
var _runApi = require("../../../common/runApi");
|
|
15
|
+
var _constants = require("../../../common/constants");
|
|
16
|
+
var _tsNodeImport = require("../../common/tsNodeImport");
|
|
17
|
+
var _terminal = require("../helpers/terminal");
|
|
18
|
+
var _browser = require("../helpers/browser");
|
|
19
|
+
var _launchBrowser = require("../../../common/launchBrowser");
|
|
20
|
+
var _promises = require("timers/promises");
|
|
21
|
+
var _contextStorageStateHelpers = require("../../../common/contextStorageStateHelpers");
|
|
22
|
+
async function executeRunValidateAuthSessionCLI({
|
|
23
|
+
id,
|
|
24
|
+
autoRecreate,
|
|
25
|
+
checkRetries,
|
|
26
|
+
createRetries,
|
|
27
|
+
...rest
|
|
28
|
+
}) {
|
|
29
|
+
(0, _terminal.terminal)(`^+Validating auth session with id ^c${id}^:\n`);
|
|
30
|
+
const {
|
|
31
|
+
storageState
|
|
32
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
33
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
34
|
+
(0, _helpers.registerGetAuthSessionParameters)(id);
|
|
35
|
+
const checkResult = await runCheckWithRetries({
|
|
36
|
+
auth: storageState,
|
|
37
|
+
retries: checkRetries,
|
|
38
|
+
...rest
|
|
39
|
+
});
|
|
40
|
+
if (!checkResult) {
|
|
41
|
+
if (!autoRecreate) {
|
|
42
|
+
throw new _helpers.CLIError("Auto recreate is disabled, please provide a new auth session or update it manually");
|
|
43
|
+
}
|
|
44
|
+
const {
|
|
45
|
+
metadata
|
|
46
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
47
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
48
|
+
throw new _helpers.CLIError("Auth session is recorder-based, please provide a new one or update it manually");
|
|
49
|
+
}
|
|
50
|
+
(0, _terminal.terminal)("^+Auto recreate is enabled - trying to re-create it^:\n");
|
|
51
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
|
|
52
|
+
const authSessionInput = metadata?.authSessionInput ?? {};
|
|
53
|
+
const storageState = await runCreateWithRetries({
|
|
54
|
+
authSessionId: id,
|
|
55
|
+
authSessionInput,
|
|
56
|
+
retries: createRetries,
|
|
57
|
+
metadata,
|
|
58
|
+
...rest
|
|
59
|
+
});
|
|
60
|
+
const checkResult = await runCheckWithRetries({
|
|
61
|
+
auth: storageState,
|
|
62
|
+
retries: checkRetries,
|
|
63
|
+
...rest
|
|
64
|
+
});
|
|
65
|
+
if (!checkResult) {
|
|
66
|
+
throw new _helpers.CLIError("Failed to re-create auth session");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
(0, _terminal.terminal)(`^+^gAuth session validated successfully^:\n`);
|
|
70
|
+
return storageState;
|
|
71
|
+
}
|
|
72
|
+
async function executeRunCreateAuthSessionCLI({
|
|
73
|
+
id,
|
|
74
|
+
input,
|
|
75
|
+
checkRetries,
|
|
76
|
+
createRetries,
|
|
77
|
+
log = true,
|
|
78
|
+
...rest
|
|
79
|
+
}) {
|
|
80
|
+
id = id ?? generateAuthSessionId();
|
|
81
|
+
(0, _terminal.terminal)(`^+Creating auth session with id ^c${id}^:\n`);
|
|
82
|
+
await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
|
|
83
|
+
const createdStorageState = await runCreateWithRetries({
|
|
84
|
+
authSessionId: id,
|
|
85
|
+
authSessionInput: input,
|
|
86
|
+
retries: createRetries,
|
|
87
|
+
...rest
|
|
88
|
+
});
|
|
89
|
+
const auth = createdStorageState;
|
|
90
|
+
const checkResult = await runCheckWithRetries({
|
|
91
|
+
auth,
|
|
92
|
+
retries: checkRetries,
|
|
93
|
+
...rest
|
|
94
|
+
});
|
|
95
|
+
if (!checkResult) {
|
|
96
|
+
throw new _helpers.CLIError("Failed to create auth session");
|
|
97
|
+
}
|
|
98
|
+
if (log) {
|
|
99
|
+
(0, _terminal.terminal)(`^+^gAuth session created successfully^:\n`);
|
|
100
|
+
}
|
|
101
|
+
return auth;
|
|
102
|
+
}
|
|
103
|
+
async function executeRunUpdateAuthSessionCLI({
|
|
104
|
+
id,
|
|
105
|
+
input,
|
|
106
|
+
checkRetries,
|
|
107
|
+
createRetries,
|
|
108
|
+
...rest
|
|
109
|
+
}) {
|
|
110
|
+
(0, _terminal.terminal)(`^+Updating auth session with id ^c${id}^:\n`);
|
|
111
|
+
let metadata = undefined;
|
|
112
|
+
if (input === undefined) {
|
|
113
|
+
({
|
|
114
|
+
metadata
|
|
115
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id));
|
|
116
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
117
|
+
throw new _helpers.CLIError("Auth session is recorder-based, it cannot be updated.");
|
|
118
|
+
}
|
|
119
|
+
input = metadata?.authSessionInput ?? {};
|
|
120
|
+
}
|
|
121
|
+
await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
|
|
122
|
+
const authSession = await executeRunCreateAuthSessionCLI({
|
|
123
|
+
id,
|
|
124
|
+
input,
|
|
125
|
+
checkRetries,
|
|
126
|
+
createRetries,
|
|
127
|
+
log: false,
|
|
128
|
+
metadata,
|
|
129
|
+
...rest
|
|
130
|
+
});
|
|
131
|
+
(0, _terminal.terminal)(`^+^gAuth session updated successfully^:\n`);
|
|
132
|
+
return authSession;
|
|
133
|
+
}
|
|
134
|
+
async function executeAttemptCreateAuthSessionCLI({
|
|
135
|
+
id,
|
|
136
|
+
input,
|
|
137
|
+
...rest
|
|
138
|
+
}) {
|
|
139
|
+
id = id ?? generateAuthSessionId(true);
|
|
140
|
+
(0, _terminal.terminal)(`^+Executing create auth session attempt with id ^c${id}^:\n`);
|
|
141
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
|
|
142
|
+
return await runCreateWithRetries({
|
|
143
|
+
authSessionId: id,
|
|
144
|
+
authSessionInput: input,
|
|
145
|
+
...rest
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function executeAttemptCheckAuthSessionCLI({
|
|
149
|
+
id,
|
|
150
|
+
...rest
|
|
151
|
+
}) {
|
|
152
|
+
(0, _terminal.terminal)(`^+Executing check auth session attempt with id ^c${id}^:\n`);
|
|
153
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
154
|
+
(0, _helpers.registerGetAuthSessionParameters)(id);
|
|
155
|
+
const {
|
|
156
|
+
storageState
|
|
157
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
158
|
+
const checkResult = await runCheckWithRetries({
|
|
159
|
+
auth: storageState,
|
|
160
|
+
...rest
|
|
161
|
+
});
|
|
162
|
+
if (!checkResult) {
|
|
163
|
+
throw new _helpers.CLIError("Check failed");
|
|
164
|
+
}
|
|
165
|
+
(0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
|
|
166
|
+
return storageState;
|
|
167
|
+
}
|
|
168
|
+
async function runCheck({
|
|
169
|
+
auth,
|
|
170
|
+
proxy,
|
|
171
|
+
headless,
|
|
172
|
+
timeout,
|
|
173
|
+
traceId,
|
|
174
|
+
keepBrowserOpen
|
|
175
|
+
}) {
|
|
176
|
+
return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
|
|
177
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
178
|
+
automationFunction: {
|
|
179
|
+
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
180
|
+
},
|
|
181
|
+
runOptions: await (0, _browser.getCLIRunOptions)({
|
|
182
|
+
headless,
|
|
183
|
+
proxy,
|
|
184
|
+
keepBrowserOpen
|
|
185
|
+
}),
|
|
186
|
+
auth: {
|
|
187
|
+
session: {
|
|
188
|
+
type: "state",
|
|
189
|
+
state: auth
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
tracing,
|
|
193
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
194
|
+
abortSignal
|
|
195
|
+
});
|
|
196
|
+
if (runApiResult.isErr()) {
|
|
197
|
+
throw runApiResult.error;
|
|
198
|
+
}
|
|
199
|
+
const result = runApiResult.value.result;
|
|
200
|
+
if (!result) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}, traceId), timeout);
|
|
205
|
+
}
|
|
206
|
+
const _runCheck = exports._runCheck = runCheck;
|
|
207
|
+
async function runCreate({
|
|
208
|
+
authSessionInput,
|
|
209
|
+
proxy,
|
|
210
|
+
headless,
|
|
211
|
+
timeout,
|
|
212
|
+
traceId,
|
|
213
|
+
keepBrowserOpen
|
|
214
|
+
}) {
|
|
215
|
+
return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
|
|
216
|
+
const result = await (0, _runApi.runApi)({
|
|
217
|
+
automationFunction: {
|
|
218
|
+
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`,
|
|
219
|
+
params: authSessionInput
|
|
220
|
+
},
|
|
221
|
+
runOptions: await (0, _browser.getCLIRunOptions)({
|
|
222
|
+
headless,
|
|
223
|
+
proxy,
|
|
224
|
+
keepBrowserOpen
|
|
225
|
+
}),
|
|
226
|
+
retrieveSession: true,
|
|
227
|
+
tracing,
|
|
228
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
229
|
+
abortSignal
|
|
230
|
+
});
|
|
231
|
+
if (result.isErr()) {
|
|
232
|
+
throw result.error;
|
|
233
|
+
}
|
|
234
|
+
return result.value.session;
|
|
235
|
+
}, traceId), timeout);
|
|
236
|
+
}
|
|
237
|
+
const _runCreate = exports._runCreate = runCreate;
|
|
238
|
+
async function runCheckWithRetries({
|
|
239
|
+
auth,
|
|
240
|
+
retries,
|
|
241
|
+
...rest
|
|
242
|
+
}) {
|
|
243
|
+
for (let i = 0; i < (retries ?? 1); i++) {
|
|
244
|
+
(0, _terminal.terminal)(`\n^+Running ^cauth session check${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
|
|
245
|
+
try {
|
|
246
|
+
let traceId = undefined;
|
|
247
|
+
if (rest.trace) {
|
|
248
|
+
traceId = "authsession-check-attempt";
|
|
249
|
+
if (retries) {
|
|
250
|
+
traceId += `-${i + 1}`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const checkResult = await runCheck({
|
|
254
|
+
auth,
|
|
255
|
+
traceId,
|
|
256
|
+
...rest
|
|
257
|
+
});
|
|
258
|
+
if (checkResult) {
|
|
259
|
+
(0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
} catch (error) {
|
|
263
|
+
if (error instanceof _runApi.RunAutomationError) {
|
|
264
|
+
(0, _helpers.logAutomationError)(error);
|
|
265
|
+
} else {
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
(0, _terminal.terminal)(`^+^yAuth session check failed^:\n`);
|
|
270
|
+
}
|
|
271
|
+
(0, _terminal.terminal)(`^+^rAuth session check failed after ${retries} attempts^:\n`);
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
const _runCheckWithRetries = exports._runCheckWithRetries = runCheckWithRetries;
|
|
275
|
+
async function runCreateWithRetries({
|
|
276
|
+
authSessionId,
|
|
277
|
+
authSessionInput,
|
|
278
|
+
retries,
|
|
279
|
+
trace,
|
|
280
|
+
metadata,
|
|
281
|
+
...rest
|
|
282
|
+
}) {
|
|
283
|
+
let newAuthSessionInstance = null;
|
|
284
|
+
for (let i = 0; i < (retries ?? 1); i++) {
|
|
285
|
+
(0, _terminal.terminal)(`\n^+Running ^cauth session create${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
|
|
286
|
+
try {
|
|
287
|
+
let traceId = undefined;
|
|
288
|
+
if (trace) {
|
|
289
|
+
traceId = "authsession-create-attempt";
|
|
290
|
+
if (retries) {
|
|
291
|
+
traceId += `-${i + 1}`;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
newAuthSessionInstance = await runCreate({
|
|
295
|
+
authSessionInput,
|
|
296
|
+
traceId,
|
|
297
|
+
...rest
|
|
298
|
+
});
|
|
299
|
+
(0, _terminal.terminal)(`^+^gAuth session create succeeded^:\n`);
|
|
300
|
+
break;
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (error instanceof _runApi.RunAutomationError) {
|
|
303
|
+
(0, _helpers.logAutomationError)(error);
|
|
304
|
+
} else {
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
(0, _terminal.terminal)(`^+^yAuth session create failed^:\n`);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!newAuthSessionInstance) {
|
|
311
|
+
throw new _helpers.CLIError(`Failed to create auth session after ${retries} retries`);
|
|
312
|
+
}
|
|
313
|
+
await (0, _helpers.storeAuthSessionInstance)({
|
|
314
|
+
state: newAuthSessionInstance,
|
|
315
|
+
id: authSessionId,
|
|
316
|
+
input: authSessionInput,
|
|
317
|
+
proxy: rest.proxy,
|
|
318
|
+
metadata
|
|
319
|
+
});
|
|
320
|
+
return newAuthSessionInstance;
|
|
321
|
+
}
|
|
322
|
+
const _runCreateWithRetries = exports._runCreateWithRetries = runCreateWithRetries;
|
|
323
|
+
async function executeRecordAuthSessionCLI({
|
|
324
|
+
id,
|
|
325
|
+
checkRetries,
|
|
326
|
+
timeout,
|
|
327
|
+
headless,
|
|
328
|
+
proxy,
|
|
329
|
+
trace = false,
|
|
330
|
+
keepBrowserOpen,
|
|
331
|
+
startUrl,
|
|
332
|
+
finishUrl
|
|
333
|
+
}) {
|
|
334
|
+
id = id ?? generateAuthSessionId();
|
|
335
|
+
(0, _terminal.terminal)(`^+Recording auth session with id ^c${id}^:\n`);
|
|
336
|
+
let authSession;
|
|
337
|
+
try {
|
|
338
|
+
authSession = await recordAuthSession({
|
|
339
|
+
startUrl,
|
|
340
|
+
finishUrl,
|
|
341
|
+
timeout,
|
|
342
|
+
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
343
|
+
});
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if (error instanceof _helpers.CLIError) {
|
|
346
|
+
throw new _helpers.CLIError(`Failed to record auth session: ${error.message}`);
|
|
347
|
+
}
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
await (0, _helpers.storeAuthSessionInstance)({
|
|
351
|
+
state: authSession,
|
|
352
|
+
id,
|
|
353
|
+
proxy,
|
|
354
|
+
metadata: {
|
|
355
|
+
createdAt: new Date().toISOString(),
|
|
356
|
+
updatedAt: new Date().toISOString(),
|
|
357
|
+
authSessionId: id,
|
|
358
|
+
authSessionType: "MANUAL",
|
|
359
|
+
recorderStartUrl: startUrl,
|
|
360
|
+
recorderEndUrl: finishUrl
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
await executeRunValidateAuthSessionCLI({
|
|
364
|
+
id,
|
|
365
|
+
headless,
|
|
366
|
+
timeout,
|
|
367
|
+
proxy,
|
|
368
|
+
autoRecreate: false,
|
|
369
|
+
checkRetries,
|
|
370
|
+
createRetries: 0,
|
|
371
|
+
trace,
|
|
372
|
+
keepBrowserOpen
|
|
373
|
+
});
|
|
374
|
+
(0, _terminal.terminal)(`^+^gAuth session ^c${id}^ ^+^grecorded successfully^:\n`);
|
|
375
|
+
}
|
|
376
|
+
async function recordAuthSession({
|
|
377
|
+
startUrl,
|
|
378
|
+
finishUrl,
|
|
379
|
+
timeout,
|
|
380
|
+
proxy
|
|
381
|
+
}) {
|
|
382
|
+
const {
|
|
383
|
+
context,
|
|
384
|
+
page
|
|
385
|
+
} = await (0, _launchBrowser.launchChromium)({
|
|
386
|
+
headless: false,
|
|
387
|
+
proxy,
|
|
388
|
+
appModeInitialUrl: startUrl
|
|
389
|
+
});
|
|
390
|
+
try {
|
|
391
|
+
if (!page.url().startsWith(startUrl)) {
|
|
392
|
+
await page.goto(startUrl);
|
|
393
|
+
}
|
|
394
|
+
(0, _terminal.terminal)(`^+Navigated to^ ^_${startUrl}^:\n`);
|
|
395
|
+
(0, _terminal.terminal)(`^+Waiting for^ ^_${finishUrl}^:...\n`);
|
|
396
|
+
const timeoutTimestamp = Date.now() + timeout;
|
|
397
|
+
while (true) {
|
|
398
|
+
if (Date.now() > timeoutTimestamp) {
|
|
399
|
+
throw new _helpers.CLIError("Timeout waiting for finish URL");
|
|
400
|
+
}
|
|
401
|
+
if (context.pages().length === 0) {
|
|
402
|
+
throw new _helpers.CLIError("Browser was closed before reaching the finish URL");
|
|
403
|
+
}
|
|
404
|
+
if (context.pages()[0].url().startsWith(finishUrl)) {
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
await (0, _promises.setTimeout)(1000);
|
|
408
|
+
}
|
|
409
|
+
(0, _terminal.terminal)(`^+Finish URL reached, capturing auth session...^:\n`);
|
|
410
|
+
await page.waitForLoadState("load");
|
|
411
|
+
const authSession = await (0, _contextStorageStateHelpers.getStorageState)(context);
|
|
412
|
+
return authSession;
|
|
413
|
+
} finally {
|
|
414
|
+
await context.close();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function generateAuthSessionId(isAttempt = false) {
|
|
418
|
+
if (isAttempt) return `auth-session-attempt-${Date.now()}`;
|
|
419
|
+
return `auth-session-${Date.now()}`;
|
|
420
|
+
}
|
|
@@ -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,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.projectNameSchema = 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
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
async function runDeployProject(projectName, auth) {
|
|
18
|
+
await (0, _save.runSaveProject)(projectName, auth);
|
|
19
|
+
const {
|
|
20
|
+
workspaceId,
|
|
21
|
+
apiKey
|
|
22
|
+
} = auth;
|
|
23
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
24
|
+
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy`;
|
|
25
|
+
const headers = {
|
|
26
|
+
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
27
|
+
"Content-Type": "application/json"
|
|
28
|
+
};
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
headers,
|
|
31
|
+
method: "POST"
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
if (response.status === 401) {
|
|
35
|
+
throw new _helpers.CLIError(`Invalid API key. Please check your API key and try again.`);
|
|
36
|
+
}
|
|
37
|
+
throw new _helpers.CLIError(`^r^+Invalid response from server\n^:^R${response.status} ${await response.text()}^:\n^r^+Project deployment failed^:\n`, {
|
|
38
|
+
autoColor: false
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
(0, _terminal.terminal)("\n");
|
|
42
|
+
const startTime = Date.now();
|
|
43
|
+
const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
|
|
44
|
+
function* getSpinnerGenerator() {
|
|
45
|
+
while (true) {
|
|
46
|
+
yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const spinnerGen = getSpinnerGenerator();
|
|
50
|
+
let updateSpinnerInterval = null;
|
|
51
|
+
if (_terminal.terminalStdout.isTTY) {
|
|
52
|
+
updateSpinnerInterval = setInterval(() => {
|
|
53
|
+
_terminal.terminal.previousLine(1);
|
|
54
|
+
_terminal.terminal.column(0);
|
|
55
|
+
_terminal.terminal.eraseLineAfter();
|
|
56
|
+
(0, _terminal.terminal)(`${spinnerGen.next().value} ^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
57
|
+
}, 50);
|
|
58
|
+
(0, _terminal.terminal)("\n");
|
|
59
|
+
} else {
|
|
60
|
+
(0, _terminal.terminal)(`^cDeploying ^:\n`);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
while (true) {
|
|
64
|
+
await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
|
|
65
|
+
if (!_terminal.terminalStdout.isTTY) {
|
|
66
|
+
(0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
67
|
+
}
|
|
68
|
+
const {
|
|
69
|
+
status,
|
|
70
|
+
message,
|
|
71
|
+
projectId,
|
|
72
|
+
...rest
|
|
73
|
+
} = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
|
|
74
|
+
if (status === "pending") {
|
|
75
|
+
const elapsedTime = Date.now() - startTime;
|
|
76
|
+
if (elapsedTime > _constants.PROJECT_DEPLOY_TIMEOUT) {
|
|
77
|
+
throw new _helpers.CLIError(`Deployment timed out after ${Math.floor(_constants.PROJECT_DEPLOY_TIMEOUT / (0, _ms.default)("1 minute"))} minutes`);
|
|
78
|
+
}
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
_terminal.terminal.previousLine(1);
|
|
82
|
+
_terminal.terminal.eraseLine();
|
|
83
|
+
if (updateSpinnerInterval) {
|
|
84
|
+
clearTimeout(updateSpinnerInterval);
|
|
85
|
+
}
|
|
86
|
+
if (status === "completed") {
|
|
87
|
+
const url = (0, _helpers.getBaseUrl)();
|
|
88
|
+
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
|
|
89
|
+
(0, _terminal.terminal)(`^+You can check your project on the platform:^s ^c^_${url}/projects/${projectId}/details^:\n`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
93
|
+
if (rest.reason) {
|
|
94
|
+
errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
|
|
95
|
+
}
|
|
96
|
+
errorMessage += `^r^+Project deployment failed^:\n`;
|
|
97
|
+
throw new _helpers.CLIError(errorMessage, {
|
|
98
|
+
autoColor: false
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
} catch (e) {
|
|
102
|
+
if (updateSpinnerInterval) {
|
|
103
|
+
clearTimeout(updateSpinnerInterval);
|
|
104
|
+
}
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
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, {
|
|
109
|
+
message: "Name cannot be a UUID"
|
|
110
|
+
});
|
|
111
|
+
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
112
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
113
|
+
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/deploy/result`;
|
|
114
|
+
const headers = {
|
|
115
|
+
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
116
|
+
"Content-Type": "application/json"
|
|
117
|
+
};
|
|
118
|
+
const response = await fetch(url, {
|
|
119
|
+
headers,
|
|
120
|
+
method: "GET"
|
|
121
|
+
});
|
|
122
|
+
if (response.status === 404) {
|
|
123
|
+
return {
|
|
124
|
+
status: "not_found",
|
|
125
|
+
message: "Project not found"
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
|
|
130
|
+
}
|
|
131
|
+
const data = await response.json();
|
|
132
|
+
if (data.status) {
|
|
133
|
+
return data;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
status: "failed",
|
|
137
|
+
message: `Deployment failed, please try again: ${data.message}`
|
|
138
|
+
};
|
|
139
|
+
};
|
|
@@ -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,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AuthCredentials } from "../types";
|
|
3
|
+
export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<void>;
|
|
4
|
+
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
5
|
+
export declare const validateProjectName: (projectName: string) => {
|
|
6
|
+
isValid: true;
|
|
7
|
+
} | {
|
|
8
|
+
isValid: false;
|
|
9
|
+
errorMessage: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const validateIntunedProject: () => Promise<{
|
|
12
|
+
isValid: boolean;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
}>;
|