@intuned/runtime-dev 1.2.0-cli.0 → 1.2.0-cli.10
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/dist/commands/api/run.js +2 -1
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/build.command.js +1 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +3 -4
- package/dist/commands/intuned-cli/commands/init.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +1 -1
- package/dist/{common/cli/constants.d.ts → commands/intuned-cli/constants/index.d.ts} +2 -4
- package/dist/{common/cli/constants.js → commands/intuned-cli/constants/index.js} +22 -5
- package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
- package/dist/{common/cli/cliReadme.js → commands/intuned-cli/constants/readme.js} +13 -15
- 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 +25 -0
- package/dist/commands/intuned-cli/controller/api.js +40 -38
- package/dist/commands/intuned-cli/controller/authSession.d.ts +176 -10
- package/dist/commands/intuned-cli/controller/authSession.js +125 -125
- package/dist/commands/intuned-cli/controller/build.js +1 -1
- package/dist/commands/intuned-cli/controller/deploy.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/deploy.js +47 -32
- package/dist/commands/intuned-cli/controller/index.js +5 -4
- package/dist/commands/intuned-cli/controller/init.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/init.js +12 -15
- 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/{common/cli/utils.d.ts → commands/intuned-cli/helpers/backend.d.ts} +0 -1
- 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 -20
- 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/{terminal.js → helpers/terminal.js} +3 -2
- 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/main.js +4 -1
- package/dist/{common/cli → commands/intuned-cli}/types.d.ts +1 -32
- package/dist/common/runApi/types.d.ts +140 -9
- package/dist/common/runApi/types.js +28 -27
- package/package.json +2 -7
- 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 -284
- 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/deploy/utils.js +0 -407
- 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 -175
- package/dist/commands/intuned-cli/commands/helpers.d.ts +0 -26
- package/dist/commands/intuned-cli/commands/helpers.js +0 -126
- package/dist/commands/intuned-cli/terminal.d.ts +0 -1
- 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 → commands/intuned-cli}/types.js +0 -0
|
@@ -3,76 +3,65 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports._runCreateWithRetries = exports._runCreate = exports._runCheckWithRetries = exports._runCheck = void 0;
|
|
6
7
|
exports.executeAttemptCheckAuthSessionCLI = executeAttemptCheckAuthSessionCLI;
|
|
7
8
|
exports.executeAttemptCreateAuthSessionCLI = executeAttemptCreateAuthSessionCLI;
|
|
8
9
|
exports.executeRunCreateAuthSessionCLI = executeRunCreateAuthSessionCLI;
|
|
9
10
|
exports.executeRunUpdateAuthSessionCLI = executeRunUpdateAuthSessionCLI;
|
|
10
11
|
exports.executeRunValidateAuthSessionCLI = executeRunValidateAuthSessionCLI;
|
|
11
|
-
|
|
12
|
-
var _utils = require("../../cli-auth-sessions/utils");
|
|
13
|
-
var _path = _interopRequireDefault(require("path"));
|
|
14
|
-
var _helpers = require("../commands/helpers");
|
|
12
|
+
var _helpers = require("../helpers");
|
|
15
13
|
var _runApi = require("../../../common/runApi");
|
|
16
14
|
var _constants = require("../../../common/constants");
|
|
17
15
|
var _tsNodeImport = require("../../common/tsNodeImport");
|
|
18
|
-
var _terminal = require("../terminal");
|
|
19
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
var _terminal = require("../helpers/terminal");
|
|
20
17
|
async function executeRunValidateAuthSessionCLI({
|
|
21
18
|
id,
|
|
22
19
|
autoRecreate,
|
|
23
20
|
checkRetries,
|
|
24
21
|
createRetries,
|
|
25
|
-
useExistingContext = false,
|
|
26
22
|
...rest
|
|
27
23
|
}) {
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
(0, _terminal.terminal)(`^+Validating auth session with id ^c${id}^:\n`);
|
|
25
|
+
const {
|
|
26
|
+
storageState
|
|
27
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
28
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
29
|
+
(0, _helpers.registerGetAuthSessionParameters)(id);
|
|
30
|
+
const checkResult = await runCheckWithRetries({
|
|
31
|
+
auth: storageState,
|
|
32
|
+
retries: checkRetries,
|
|
33
|
+
...rest
|
|
34
|
+
});
|
|
35
|
+
if (!checkResult) {
|
|
36
|
+
if (!autoRecreate) {
|
|
37
|
+
throw new _helpers.CLIError("Auto recreate is disabled, please provide a new auth session or update it manually");
|
|
38
|
+
}
|
|
30
39
|
const {
|
|
31
|
-
|
|
32
|
-
} = await (0,
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
metadata
|
|
41
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
42
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
43
|
+
throw new _helpers.CLIError("Auth session is recorder-based, please provide a new one or update it manually");
|
|
44
|
+
}
|
|
45
|
+
(0, _terminal.terminal)("^+Auto recreate is enabled - trying to re-create it^:\n");
|
|
46
|
+
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create");
|
|
47
|
+
const authSessionInput = metadata?.authSessionInput ?? {};
|
|
48
|
+
const storageState = await runCreateWithRetries({
|
|
49
|
+
authSessionId: id,
|
|
50
|
+
authSessionInput,
|
|
51
|
+
retries: createRetries,
|
|
52
|
+
...rest
|
|
53
|
+
});
|
|
35
54
|
const checkResult = await runCheckWithRetries({
|
|
36
|
-
|
|
55
|
+
auth: storageState,
|
|
37
56
|
retries: checkRetries,
|
|
38
57
|
...rest
|
|
39
58
|
});
|
|
40
59
|
if (!checkResult) {
|
|
41
|
-
|
|
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, _utils.retrieveAuthSessionInstance)(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
|
-
await runCreateWithRetries({
|
|
54
|
-
authSessionId: id,
|
|
55
|
-
authSessionInput,
|
|
56
|
-
retries: createRetries,
|
|
57
|
-
...rest
|
|
58
|
-
});
|
|
59
|
-
const checkResult = await runCheckWithRetries({
|
|
60
|
-
authSessionPath: authSessionPathToUse,
|
|
61
|
-
retries: checkRetries,
|
|
62
|
-
...rest
|
|
63
|
-
});
|
|
64
|
-
if (!checkResult) {
|
|
65
|
-
throw new _helpers.CLIError("Failed to re-create auth session");
|
|
66
|
-
}
|
|
60
|
+
throw new _helpers.CLIError("Failed to re-create auth session");
|
|
67
61
|
}
|
|
68
|
-
(0, _terminal.terminal)(`^+^gAuth session validated successfully^:\n`);
|
|
69
|
-
return authSessionPathToUse;
|
|
70
|
-
};
|
|
71
|
-
if (useExistingContext) {
|
|
72
|
-
return await validate();
|
|
73
|
-
} else {
|
|
74
|
-
return await (0, _helpers.withCLIContext)(validate)();
|
|
75
62
|
}
|
|
63
|
+
(0, _terminal.terminal)(`^+^gAuth session validated successfully^:\n`);
|
|
64
|
+
return storageState;
|
|
76
65
|
}
|
|
77
66
|
async function executeRunCreateAuthSessionCLI({
|
|
78
67
|
id,
|
|
@@ -82,29 +71,28 @@ async function executeRunCreateAuthSessionCLI({
|
|
|
82
71
|
log = true,
|
|
83
72
|
...rest
|
|
84
73
|
}) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})();
|
|
74
|
+
id = id ?? `auth-session-${Date.now()}`;
|
|
75
|
+
(0, _terminal.terminal)(`^+Creating auth session with id ^c${id}^:\n`);
|
|
76
|
+
await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
|
|
77
|
+
const createdStorageState = await runCreateWithRetries({
|
|
78
|
+
authSessionId: id,
|
|
79
|
+
authSessionInput: input,
|
|
80
|
+
retries: createRetries,
|
|
81
|
+
...rest
|
|
82
|
+
});
|
|
83
|
+
const auth = createdStorageState;
|
|
84
|
+
const checkResult = await runCheckWithRetries({
|
|
85
|
+
auth,
|
|
86
|
+
retries: checkRetries,
|
|
87
|
+
...rest
|
|
88
|
+
});
|
|
89
|
+
if (!checkResult) {
|
|
90
|
+
throw new _helpers.CLIError("Failed to create auth session");
|
|
91
|
+
}
|
|
92
|
+
if (log) {
|
|
93
|
+
(0, _terminal.terminal)(`^+^gAuth session created successfully^:\n`);
|
|
94
|
+
}
|
|
95
|
+
return auth;
|
|
108
96
|
}
|
|
109
97
|
async function executeRunUpdateAuthSessionCLI({
|
|
110
98
|
id,
|
|
@@ -114,28 +102,26 @@ async function executeRunUpdateAuthSessionCLI({
|
|
|
114
102
|
...rest
|
|
115
103
|
}) {
|
|
116
104
|
(0, _terminal.terminal)(`^+Updating auth session with id ^c${id}^:\n`);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
throw new Error("Auth session is recorder-based, it cannot be updated.");
|
|
124
|
-
}
|
|
125
|
-
input = metadata?.authSessionInput ?? {};
|
|
105
|
+
if (input === undefined) {
|
|
106
|
+
const {
|
|
107
|
+
metadata
|
|
108
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
109
|
+
if (metadata?.authSessionType === "MANUAL") {
|
|
110
|
+
throw new _helpers.CLIError("Auth session is recorder-based, it cannot be updated.");
|
|
126
111
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
112
|
+
input = metadata?.authSessionInput ?? {};
|
|
113
|
+
}
|
|
114
|
+
await Promise.all([await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "create"), await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check")]);
|
|
115
|
+
const authSession = await executeRunCreateAuthSessionCLI({
|
|
116
|
+
id,
|
|
117
|
+
input,
|
|
118
|
+
checkRetries,
|
|
119
|
+
createRetries,
|
|
120
|
+
log: false,
|
|
121
|
+
...rest
|
|
122
|
+
});
|
|
123
|
+
(0, _terminal.terminal)(`^+^gAuth session updated successfully^:\n`);
|
|
124
|
+
return authSession;
|
|
139
125
|
}
|
|
140
126
|
async function executeAttemptCreateAuthSessionCLI({
|
|
141
127
|
id,
|
|
@@ -158,28 +144,28 @@ async function executeAttemptCheckAuthSessionCLI({
|
|
|
158
144
|
}) {
|
|
159
145
|
(0, _terminal.terminal)(`^+Executing check auth session attempt with id ^c${id}^:\n`);
|
|
160
146
|
await (0, _helpers.assertApiFileExists)(_constants.AUTH_SESSIONS_FOLDER_NAME, "check");
|
|
147
|
+
(0, _helpers.registerGetAuthSessionParameters)(id);
|
|
161
148
|
const {
|
|
162
|
-
|
|
163
|
-
} = await (0,
|
|
164
|
-
const authSessionPathToUse = authSessionInstanceStoragePath;
|
|
149
|
+
storageState
|
|
150
|
+
} = await (0, _helpers.loadAuthSessionInstance)(id);
|
|
165
151
|
const checkResult = await runCheckWithRetries({
|
|
166
|
-
|
|
152
|
+
auth: storageState,
|
|
167
153
|
retries: 1,
|
|
168
154
|
...rest
|
|
169
155
|
});
|
|
170
156
|
if (!checkResult) {
|
|
171
|
-
throw new
|
|
157
|
+
throw new _helpers.CLIError("Check failed");
|
|
172
158
|
}
|
|
173
159
|
(0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
|
|
174
|
-
return
|
|
160
|
+
return storageState;
|
|
175
161
|
}
|
|
176
162
|
async function runCheck({
|
|
177
|
-
|
|
163
|
+
auth,
|
|
178
164
|
proxy,
|
|
179
165
|
headless,
|
|
180
166
|
timeout
|
|
181
167
|
}) {
|
|
182
|
-
return await (0, _helpers.withTimeout)(async
|
|
168
|
+
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
183
169
|
const runApiResult = await (0, _runApi.runApi)({
|
|
184
170
|
automationFunction: {
|
|
185
171
|
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
@@ -191,37 +177,35 @@ async function runCheck({
|
|
|
191
177
|
},
|
|
192
178
|
auth: {
|
|
193
179
|
session: {
|
|
194
|
-
type: "
|
|
195
|
-
|
|
180
|
+
type: "state",
|
|
181
|
+
state: auth
|
|
196
182
|
},
|
|
197
183
|
runCheck: false
|
|
198
184
|
},
|
|
199
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
185
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
186
|
+
abortSignal
|
|
200
187
|
});
|
|
201
188
|
if (runApiResult.isErr()) {
|
|
202
|
-
|
|
203
|
-
throw runApiResult.error.error;
|
|
204
|
-
}
|
|
205
|
-
return false;
|
|
189
|
+
throw runApiResult.error;
|
|
206
190
|
}
|
|
207
191
|
const result = runApiResult.value.result;
|
|
208
192
|
if (!result) {
|
|
209
193
|
return false;
|
|
210
194
|
}
|
|
211
195
|
return result;
|
|
212
|
-
}, timeout)
|
|
196
|
+
}, timeout);
|
|
213
197
|
}
|
|
198
|
+
const _runCheck = exports._runCheck = runCheck;
|
|
214
199
|
async function runCreate({
|
|
215
200
|
authSessionInput,
|
|
216
201
|
proxy,
|
|
217
202
|
headless,
|
|
218
203
|
timeout
|
|
219
204
|
}) {
|
|
220
|
-
return await (0, _helpers.withTimeout)(async
|
|
221
|
-
const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
|
|
205
|
+
return await (0, _helpers.withTimeout)(async abortSignal => {
|
|
222
206
|
const result = await (0, _runApi.runApi)({
|
|
223
207
|
automationFunction: {
|
|
224
|
-
name:
|
|
208
|
+
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`,
|
|
225
209
|
params: authSessionInput
|
|
226
210
|
},
|
|
227
211
|
runOptions: {
|
|
@@ -230,20 +214,18 @@ async function runCreate({
|
|
|
230
214
|
proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
|
|
231
215
|
},
|
|
232
216
|
retrieveSession: true,
|
|
233
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
217
|
+
importFunction: _tsNodeImport.tsNodeImport,
|
|
218
|
+
abortSignal
|
|
234
219
|
});
|
|
235
220
|
if (result.isErr()) {
|
|
236
|
-
|
|
237
|
-
throw result.error.error;
|
|
238
|
-
}
|
|
239
|
-
console.error(result.error);
|
|
240
|
-
throw new Error("Error while running create");
|
|
221
|
+
throw result.error;
|
|
241
222
|
}
|
|
242
223
|
return result.value.session;
|
|
243
|
-
}, timeout)
|
|
224
|
+
}, timeout);
|
|
244
225
|
}
|
|
226
|
+
const _runCreate = exports._runCreate = runCreate;
|
|
245
227
|
async function runCheckWithRetries({
|
|
246
|
-
|
|
228
|
+
auth,
|
|
247
229
|
retries,
|
|
248
230
|
...rest
|
|
249
231
|
}) {
|
|
@@ -251,22 +233,29 @@ async function runCheckWithRetries({
|
|
|
251
233
|
(0, _terminal.terminal)(`\n^+Running ^cauth session check${i === 0 ? "" : ` ^/(Attempt ${i + 1})`}^:...\n`);
|
|
252
234
|
try {
|
|
253
235
|
const checkResult = await runCheck({
|
|
254
|
-
|
|
236
|
+
auth,
|
|
255
237
|
...rest
|
|
256
238
|
});
|
|
239
|
+
console.log({
|
|
240
|
+
checkResult
|
|
241
|
+
});
|
|
257
242
|
if (checkResult) {
|
|
258
243
|
(0, _terminal.terminal)(`^+^gAuth session check passed^:\n`);
|
|
259
244
|
return true;
|
|
260
245
|
}
|
|
261
246
|
} catch (error) {
|
|
262
|
-
(
|
|
263
|
-
|
|
247
|
+
if (error instanceof _runApi.AutomationError) {
|
|
248
|
+
(0, _helpers.logAutomationError)(error);
|
|
249
|
+
} else {
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
264
252
|
}
|
|
265
253
|
(0, _terminal.terminal)(`^+^yAuth session check failed^:\n`);
|
|
266
254
|
}
|
|
267
255
|
(0, _terminal.terminal)(`^+^rAuth session check failed after ${retries} attempts^:\n`);
|
|
268
256
|
return false;
|
|
269
257
|
}
|
|
258
|
+
const _runCheckWithRetries = exports._runCheckWithRetries = runCheckWithRetries;
|
|
270
259
|
async function runCreateWithRetries({
|
|
271
260
|
authSessionId,
|
|
272
261
|
authSessionInput,
|
|
@@ -284,12 +273,23 @@ async function runCreateWithRetries({
|
|
|
284
273
|
(0, _terminal.terminal)(`^+^gAuth session create succeeded^:\n`);
|
|
285
274
|
break;
|
|
286
275
|
} catch (error) {
|
|
287
|
-
(
|
|
288
|
-
|
|
276
|
+
if (error instanceof _runApi.AutomationError) {
|
|
277
|
+
(0, _helpers.logAutomationError)(error);
|
|
278
|
+
} else {
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
(0, _terminal.terminal)(`^+^yAuth session create failed^:\n`);
|
|
289
282
|
}
|
|
290
283
|
}
|
|
291
284
|
if (!newAuthSessionInstance) {
|
|
292
285
|
throw new _helpers.CLIError(`Failed to create auth session after ${retries} retries`);
|
|
293
286
|
}
|
|
294
|
-
|
|
295
|
-
|
|
287
|
+
await (0, _helpers.storeAuthSessionInstance)({
|
|
288
|
+
state: newAuthSessionInstance,
|
|
289
|
+
id: authSessionId,
|
|
290
|
+
input: authSessionInput,
|
|
291
|
+
proxy: rest.proxy
|
|
292
|
+
});
|
|
293
|
+
return newAuthSessionInstance;
|
|
294
|
+
}
|
|
295
|
+
const _runCreateWithRetries = exports._runCreateWithRetries = runCreateWithRetries;
|
|
@@ -8,7 +8,7 @@ var fs = _interopRequireWildcard(require("fs-extra"));
|
|
|
8
8
|
var path = _interopRequireWildcard(require("path"));
|
|
9
9
|
var _child_process = require("child_process");
|
|
10
10
|
var _util = require("util");
|
|
11
|
-
var _terminal = require("../terminal");
|
|
11
|
+
var _terminal = require("../helpers/terminal");
|
|
12
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
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
14
|
const execPromise = (0, _util.promisify)(_child_process.exec);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { AuthCredentials, FileSystemTree } from "
|
|
2
|
+
import type { AuthCredentials, FileSystemTree } from "../types";
|
|
3
3
|
export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
|
|
4
4
|
export declare function runDeployProject(projectName: string, auth: AuthCredentials): Promise<void>;
|
|
5
5
|
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -12,14 +12,12 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
12
12
|
var _minimatch = require("minimatch");
|
|
13
13
|
var _zod = require("zod");
|
|
14
14
|
var _projectExclusions = _interopRequireDefault(require("../../common/projectExclusions"));
|
|
15
|
-
var _constants = require("
|
|
16
|
-
var
|
|
17
|
-
var _utils2 = require("../../init/utils");
|
|
15
|
+
var _constants = require("../constants");
|
|
16
|
+
var _helpers = require("../helpers");
|
|
18
17
|
var _lodash = require("lodash");
|
|
19
18
|
var _uuid = require("uuid");
|
|
20
|
-
var _terminal = require("../terminal");
|
|
19
|
+
var _terminal = require("../helpers/terminal");
|
|
21
20
|
var _promises = require("timers/promises");
|
|
22
|
-
var _helpers = require("../commands/helpers");
|
|
23
21
|
var _ms = _interopRequireDefault(require("ms"));
|
|
24
22
|
var _build = require("./build");
|
|
25
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -123,7 +121,7 @@ async function runDeployProject(projectName, auth) {
|
|
|
123
121
|
workspaceId,
|
|
124
122
|
apiKey
|
|
125
123
|
} = auth;
|
|
126
|
-
const baseUrl = (0,
|
|
124
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
127
125
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create`;
|
|
128
126
|
const headers = {
|
|
129
127
|
"x-api-key": apiKey,
|
|
@@ -157,25 +155,34 @@ async function runDeployProject(projectName, auth) {
|
|
|
157
155
|
}
|
|
158
156
|
(0, _terminal.terminal)("\n");
|
|
159
157
|
const startTime = Date.now();
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
const timeElapsedText = () => ((Date.now() - startTime) / (0, _ms.default)("1 second")).toFixed(1);
|
|
159
|
+
function* getSpinnerGenerator() {
|
|
160
|
+
yield* "⠙⠹⠸⠼⠴⠦⠧⠇";
|
|
161
|
+
}
|
|
162
|
+
const spinnerGen = getSpinnerGenerator();
|
|
163
|
+
let updateSpinnerInterval = null;
|
|
164
|
+
if (_terminal.terminalStdout.isTTY) {
|
|
165
|
+
updateSpinnerInterval = setInterval(() => {
|
|
166
166
|
_terminal.terminal.previousLine(1);
|
|
167
|
-
_terminal.terminal.column(
|
|
167
|
+
_terminal.terminal.column(0);
|
|
168
168
|
_terminal.terminal.eraseLineAfter();
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
(0, _terminal.terminal)(`${spinnerGen.next().value}^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
170
|
+
}, 50);
|
|
171
|
+
(0, _terminal.terminal)("\n");
|
|
172
|
+
} else {
|
|
173
|
+
(0, _terminal.terminal)(`^cDeploying ^:\n`);
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
while (true) {
|
|
177
|
+
await (0, _promises.setTimeout)(_constants.PROJECT_DEPLOY_CHECK_PERIOD);
|
|
178
|
+
if (!_terminal.terminalStdout.isTTY) {
|
|
179
|
+
(0, _terminal.terminal)(`^cDeploying ^:^K(${timeElapsedText()}s)^ \n`);
|
|
173
180
|
}
|
|
174
|
-
lastCheckTime = Date.now();
|
|
175
181
|
const {
|
|
176
182
|
status,
|
|
177
183
|
message,
|
|
178
|
-
projectId
|
|
184
|
+
projectId,
|
|
185
|
+
...rest
|
|
179
186
|
} = await checkIntunedProjectDeployStatus(workspaceId, projectName, apiKey);
|
|
180
187
|
if (status === "pending") {
|
|
181
188
|
const elapsedTime = Date.now() - startTime;
|
|
@@ -186,17 +193,29 @@ async function runDeployProject(projectName, auth) {
|
|
|
186
193
|
}
|
|
187
194
|
_terminal.terminal.previousLine(1);
|
|
188
195
|
_terminal.terminal.eraseLine();
|
|
189
|
-
|
|
196
|
+
if (updateSpinnerInterval) {
|
|
197
|
+
clearTimeout(updateSpinnerInterval);
|
|
198
|
+
}
|
|
190
199
|
if (status === "completed") {
|
|
191
|
-
const url = (0,
|
|
200
|
+
const url = (0, _helpers.getBaseUrl)();
|
|
192
201
|
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
|
|
193
202
|
(0, _terminal.terminal)(`^+You can check your project on the platform:^s ^c^_${url}/projects/${projectId}/details^:\n`);
|
|
194
203
|
return;
|
|
195
204
|
}
|
|
196
|
-
|
|
205
|
+
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
206
|
+
if (rest.reason) {
|
|
207
|
+
errorMessage += `^r^+Reason:^:\n^R${rest.reason}^:\n`;
|
|
208
|
+
}
|
|
209
|
+
errorMessage += `^r^+Project deployment failed^:\n`;
|
|
210
|
+
throw new _helpers.CLIError(errorMessage, {
|
|
211
|
+
autoColor: false
|
|
212
|
+
});
|
|
197
213
|
}
|
|
198
214
|
} catch (e) {
|
|
199
|
-
|
|
215
|
+
if (updateSpinnerInterval) {
|
|
216
|
+
clearTimeout(updateSpinnerInterval);
|
|
217
|
+
}
|
|
218
|
+
throw e;
|
|
200
219
|
}
|
|
201
220
|
}
|
|
202
221
|
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, {
|
|
@@ -309,7 +328,7 @@ const validateIntunedProject = async () => {
|
|
|
309
328
|
};
|
|
310
329
|
exports.validateIntunedProject = validateIntunedProject;
|
|
311
330
|
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
312
|
-
const baseUrl = (0,
|
|
331
|
+
const baseUrl = (0, _helpers.getBaseUrl)();
|
|
313
332
|
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/create/${projectName}/result`;
|
|
314
333
|
const headers = {
|
|
315
334
|
"x-api-key": apiKey,
|
|
@@ -326,15 +345,11 @@ const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey)
|
|
|
326
345
|
};
|
|
327
346
|
}
|
|
328
347
|
if (!response.ok) {
|
|
329
|
-
throw new
|
|
348
|
+
throw new _helpers.CLIError(`Error querying deployment status ${response.status}: ${await response.text()}`);
|
|
330
349
|
}
|
|
331
350
|
const data = await response.json();
|
|
332
351
|
if (data.status) {
|
|
333
|
-
return
|
|
334
|
-
status: data.status,
|
|
335
|
-
message: data.message,
|
|
336
|
-
projectId: data.projectId
|
|
337
|
-
};
|
|
352
|
+
return data;
|
|
338
353
|
}
|
|
339
354
|
return {
|
|
340
355
|
status: "failed",
|
|
@@ -345,7 +360,7 @@ async function mapToIDEParams(tree) {
|
|
|
345
360
|
if (!tree) {
|
|
346
361
|
return;
|
|
347
362
|
}
|
|
348
|
-
if (!tree["parameters"] ||
|
|
363
|
+
if (!tree["parameters"] || "file" in tree["parameters"]) {
|
|
349
364
|
return;
|
|
350
365
|
}
|
|
351
366
|
const apiParametersMap = {};
|
|
@@ -355,7 +370,7 @@ async function mapToIDEParams(tree) {
|
|
|
355
370
|
};
|
|
356
371
|
for (const parameterKey of cliParameters) {
|
|
357
372
|
const parameter = tree["parameters"].directory[parameterKey];
|
|
358
|
-
if (
|
|
373
|
+
if ("directory" in parameter) {
|
|
359
374
|
continue;
|
|
360
375
|
}
|
|
361
376
|
if ((0, _lodash.isEmpty)(parameter.file.contents)) {
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.loadParameters = loadParameters;
|
|
7
7
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
|
+
var _helpers = require("../helpers");
|
|
8
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); }
|
|
9
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; }
|
|
10
11
|
async function loadParameters(parameters) {
|
|
@@ -15,7 +16,7 @@ async function loadParameters(parameters) {
|
|
|
15
16
|
try {
|
|
16
17
|
inputData = JSON.parse(parameters);
|
|
17
18
|
} catch (err) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new _helpers.CLIError("Parameters must be a valid JSON string or a path to a JSON file");
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
return inputData;
|
|
@@ -36,10 +37,10 @@ async function loadParametersFromFile(parametersFile) {
|
|
|
36
37
|
return inputData;
|
|
37
38
|
} catch (error) {
|
|
38
39
|
if (error.code === "ENOENT") {
|
|
39
|
-
throw new
|
|
40
|
+
throw new _helpers.CLIError(`Parameters file not found: ${parametersFile}`);
|
|
40
41
|
} else if (error instanceof SyntaxError) {
|
|
41
|
-
throw new
|
|
42
|
+
throw new _helpers.CLIError(`Invalid JSON in parameters file: ${error.message}`);
|
|
42
43
|
}
|
|
43
|
-
throw new
|
|
44
|
+
throw new _helpers.CLIError(`Error reading parameters file: ${error.message}`);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FileSystemTree, TemplateId } from "
|
|
1
|
+
import { FileSystemTree, TemplateId } from "../types";
|
|
2
2
|
export declare function mountFiles(cwd: string, tree: FileSystemTree): Promise<void>;
|
|
3
3
|
export declare function checkEmptyDirectory(): Promise<boolean>;
|
|
4
4
|
export declare function selectTemplate(templateName: string): Promise<TemplateId>;
|