@intuned/runtime-dev 1.2.0-cli.4 → 1.2.0-cli.5
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/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_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/commands/intuned-cli/constants/index.d.ts +36 -0
- package/dist/commands/intuned-cli/constants/index.js +63 -0
- package/dist/commands/intuned-cli/constants/readme.d.ts +1 -0
- package/dist/commands/intuned-cli/constants/readme.js +81 -0
- package/dist/commands/intuned-cli/controller/api.js +7 -7
- package/dist/commands/intuned-cli/controller/authSession.js +24 -23
- 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 +9 -11
- 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 +17 -0
- package/dist/commands/intuned-cli/helpers/auth.js +105 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +26 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/errors.js +55 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +10 -0
- package/dist/commands/intuned-cli/helpers/index.js +115 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.js +19 -0
- 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/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/types.d.ts +42 -0
- package/dist/commands/intuned-cli/types.js +13 -0
- package/dist/common/cli/cliReadme.d.ts +0 -1
- package/dist/common/cli/cliReadme.js +1 -83
- package/dist/common/cli/constants.d.ts +0 -35
- package/dist/common/cli/constants.js +1 -43
- package/dist/common/cli/types.d.ts +0 -74
- package/dist/common/cli/types.js +1 -13
- package/dist/common/cli/utils.d.ts +0 -9
- package/dist/common/cli/utils.js +1 -39
- package/package.json +1 -7
- 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 -28
- package/dist/commands/intuned-cli/commands/helpers.js +0 -138
- 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/commands/intuned-cli/{terminal.d.ts → helpers/terminal.d.ts} +0 -0
- /package/dist/commands/intuned-cli/{terminal.js → helpers/terminal.js} +0 -0
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ensureAuthApi = ensureAuthApi;
|
|
7
|
-
exports.ensureRecorderURLs = ensureRecorderURLs;
|
|
8
|
-
exports.getAuthType = getAuthType;
|
|
9
|
-
exports.getStorageState = getStorageState;
|
|
10
|
-
exports.isAuthEnabled = isAuthEnabled;
|
|
11
|
-
exports.recordAuthSession = recordAuthSession;
|
|
12
|
-
exports.retrieveAuthSessionInstance = retrieveAuthSessionInstance;
|
|
13
|
-
exports.runCheckApi = runCheckApi;
|
|
14
|
-
exports.runCheckApiViaCLI = runCheckApiViaCLI;
|
|
15
|
-
exports.runCreateApi = runCreateApi;
|
|
16
|
-
exports.runCreateApiViaCLI = runCreateApiViaCLI;
|
|
17
|
-
exports.storeAuthSessionInstance = storeAuthSessionInstance;
|
|
18
|
-
var _path = _interopRequireDefault(require("path"));
|
|
19
|
-
var _constants = require("../../common/constants");
|
|
20
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
21
|
-
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
22
|
-
var _enums = require("../../runtime/enums");
|
|
23
|
-
var _nanoid = require("nanoid");
|
|
24
|
-
var _runApi = require("../../common/runApi");
|
|
25
|
-
var _tsNodeImport = require("../common/tsNodeImport");
|
|
26
|
-
var _promptly = require("promptly");
|
|
27
|
-
var _utils = require("../../common/cli/utils");
|
|
28
|
-
var _types = require("../../common/cli/types");
|
|
29
|
-
var playwright = _interopRequireWildcard(require("playwright-core"));
|
|
30
|
-
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); }
|
|
31
|
-
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; }
|
|
32
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
33
|
-
async function isAuthEnabled() {
|
|
34
|
-
try {
|
|
35
|
-
const intunedJson = await fs.readJSON(_path.default.join(process.cwd(), "Intuned.json"));
|
|
36
|
-
return Boolean(intunedJson?.authSessions?.enabled);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function getAuthType() {
|
|
42
|
-
const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
43
|
-
return projectAuthConfig.type ?? "API";
|
|
44
|
-
}
|
|
45
|
-
async function ensureRecorderURLs() {
|
|
46
|
-
const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
47
|
-
if (projectAuthConfig.type === "MANUAL" && projectAuthConfig.startUrl && projectAuthConfig.endUrl) {
|
|
48
|
-
return {
|
|
49
|
-
startUrl: projectAuthConfig.startUrl,
|
|
50
|
-
endUrl: projectAuthConfig.endUrl
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
throw new Error("Auth session recorder URLs are not configured, please configure them in Intuned.json");
|
|
54
|
-
}
|
|
55
|
-
async function ensureAuthApi(operation) {
|
|
56
|
-
const authApiFile = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/${operation}.ts`;
|
|
57
|
-
const authApiFilePath = _path.default.join(process.cwd(), authApiFile);
|
|
58
|
-
return await fs.exists(authApiFilePath);
|
|
59
|
-
}
|
|
60
|
-
async function runCreateApi(authSessionInput) {
|
|
61
|
-
try {
|
|
62
|
-
const createApiOperationId = (0, _nanoid.nanoid)();
|
|
63
|
-
const authSessionInstance = await (0, _asyncLocalStorage.runWithContext)({
|
|
64
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
65
|
-
extendedPayloads: [],
|
|
66
|
-
runId: createApiOperationId
|
|
67
|
-
}, () => runCreateApiViaCLI(authSessionInput));
|
|
68
|
-
return authSessionInstance;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
throw new Error(`Error running the create API: ${error.message}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
async function runCheckApi(authSessionPath) {
|
|
74
|
-
try {
|
|
75
|
-
const checkApiOperationId = (0, _nanoid.nanoid)();
|
|
76
|
-
const checkResult = await (0, _asyncLocalStorage.runWithContext)({
|
|
77
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
78
|
-
extendedPayloads: [],
|
|
79
|
-
runId: checkApiOperationId
|
|
80
|
-
}, () => runCheckApiViaCLI(authSessionPath));
|
|
81
|
-
return checkResult;
|
|
82
|
-
} catch (error) {
|
|
83
|
-
if (error.message === _types.CHECK_FAILED_ERROR_MESSAGE) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
throw new Error(`Error running the check API: ${error.message}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function runCreateApiViaCLI(authSessionInput) {
|
|
90
|
-
const createApiName = `${_constants.AUTH_SESSIONS_FOLDER_NAME}/create`;
|
|
91
|
-
const generator = (0, _runApi.runApiGenerator)({
|
|
92
|
-
automationFunction: {
|
|
93
|
-
name: createApiName,
|
|
94
|
-
params: authSessionInput
|
|
95
|
-
},
|
|
96
|
-
runOptions: {
|
|
97
|
-
headless: false,
|
|
98
|
-
environment: "standalone"
|
|
99
|
-
},
|
|
100
|
-
retrieveSession: true,
|
|
101
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
102
|
-
});
|
|
103
|
-
let nextGeneratorParam = undefined;
|
|
104
|
-
while (true) {
|
|
105
|
-
const {
|
|
106
|
-
value,
|
|
107
|
-
done
|
|
108
|
-
} = await generator.next(...(nextGeneratorParam ? [nextGeneratorParam] : []));
|
|
109
|
-
if (done) {
|
|
110
|
-
if (value.isErr()) {
|
|
111
|
-
if (value.error instanceof _runApi.AutomationError) {
|
|
112
|
-
throw value.error.error;
|
|
113
|
-
}
|
|
114
|
-
console.error(value.error);
|
|
115
|
-
throw new Error("Error while running create");
|
|
116
|
-
}
|
|
117
|
-
return value.value.session;
|
|
118
|
-
}
|
|
119
|
-
if (value.action === "request_more_info" && value.requestType == "multiple_choice") {
|
|
120
|
-
nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser + `, choices: ${value.choices}`, {
|
|
121
|
-
validator: input => {
|
|
122
|
-
if (!value.choices.includes(input)) {
|
|
123
|
-
throw new Error("Please type on of the allowed choices");
|
|
124
|
-
}
|
|
125
|
-
return input;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
} else if (value.action === "request_more_info" && value.requestType == "otp") {
|
|
129
|
-
nextGeneratorParam = await (0, _promptly.prompt)(value.messageToUser, {});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async function runCheckApiViaCLI(authSessionPath) {
|
|
134
|
-
const runApiResult = await (0, _runApi.runApi)({
|
|
135
|
-
automationFunction: {
|
|
136
|
-
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
137
|
-
},
|
|
138
|
-
runOptions: {
|
|
139
|
-
headless: false,
|
|
140
|
-
environment: "standalone"
|
|
141
|
-
},
|
|
142
|
-
auth: {
|
|
143
|
-
session: {
|
|
144
|
-
type: "file",
|
|
145
|
-
path: authSessionPath
|
|
146
|
-
},
|
|
147
|
-
runCheck: false
|
|
148
|
-
},
|
|
149
|
-
importFunction: _tsNodeImport.tsNodeImport
|
|
150
|
-
});
|
|
151
|
-
if (runApiResult.isErr()) {
|
|
152
|
-
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
153
|
-
throw runApiResult.error.error;
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
const result = runApiResult.value.result;
|
|
158
|
-
if (!result) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
async function storeAuthSessionInstance(authSessionInstance, customName, authSessionInput) {
|
|
164
|
-
try {
|
|
165
|
-
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
166
|
-
await fs.ensureDir(authSessionsDirectoryPath);
|
|
167
|
-
const authSessionInstanceId = customName ?? `auth-session-${Date.now()}`;
|
|
168
|
-
const authSessionInstancePath = _path.default.join(authSessionsDirectoryPath, authSessionInstanceId);
|
|
169
|
-
const authSessionExists = await fs.pathExists(authSessionInstancePath);
|
|
170
|
-
await fs.ensureDir(authSessionInstancePath);
|
|
171
|
-
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
172
|
-
await fs.writeJSON(authSessionInstanceStoragePath, authSessionInstance, {
|
|
173
|
-
spaces: 2
|
|
174
|
-
});
|
|
175
|
-
const projectAuthConfig = await (0, _utils.getSettingIntunedJSON)("authSessions");
|
|
176
|
-
let existingMetadata = {};
|
|
177
|
-
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
178
|
-
if (authSessionExists) {
|
|
179
|
-
try {
|
|
180
|
-
existingMetadata = await fs.readJSON(authSessionInstanceMetadataPath);
|
|
181
|
-
} catch (readError) {
|
|
182
|
-
existingMetadata = {};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const authSessionMetadata = {
|
|
186
|
-
createdAt: existingMetadata.createdAt || new Date().toISOString(),
|
|
187
|
-
updatedAt: new Date().toISOString(),
|
|
188
|
-
...(projectAuthConfig.type === "API" && {
|
|
189
|
-
authSessionInput: authSessionInput || existingMetadata.authSessionInput || {}
|
|
190
|
-
}),
|
|
191
|
-
authSessionId: authSessionInstanceId,
|
|
192
|
-
authSessionType: projectAuthConfig.type ?? existingMetadata.authSessionType ?? "API",
|
|
193
|
-
...(projectAuthConfig.type === "MANUAL" && {
|
|
194
|
-
recorderStartUrl: projectAuthConfig.startUrl,
|
|
195
|
-
recorderEndUrl: projectAuthConfig.endUrl
|
|
196
|
-
})
|
|
197
|
-
};
|
|
198
|
-
await fs.writeJSON(authSessionInstanceMetadataPath, authSessionMetadata, {
|
|
199
|
-
spaces: 2
|
|
200
|
-
});
|
|
201
|
-
return authSessionInstancePath;
|
|
202
|
-
} catch (error) {
|
|
203
|
-
throw new Error(`Error storing auth session instance: ${error.message}`);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
async function retrieveAuthSessionInstance(authSessionId, pathsOnly = false) {
|
|
207
|
-
try {
|
|
208
|
-
const authSessionInstancePath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME, authSessionId);
|
|
209
|
-
const authSessionInstanceStoragePath = _path.default.join(authSessionInstancePath, `auth-session.json`);
|
|
210
|
-
const authSessionInstanceMetadataPath = _path.default.join(authSessionInstancePath, `metadata.json`);
|
|
211
|
-
if (!(await fs.exists(authSessionInstanceStoragePath))) {
|
|
212
|
-
throw new Error(`Auth session instance with ID ${authSessionId} not found`);
|
|
213
|
-
}
|
|
214
|
-
if (pathsOnly) {
|
|
215
|
-
return {
|
|
216
|
-
authSessionInstanceStoragePath,
|
|
217
|
-
authSessionInstanceMetadataPath
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
const authSessionInstance = await fs.readJSON(authSessionInstanceStoragePath);
|
|
221
|
-
const metadata = await fs.readJSON(authSessionInstanceMetadataPath);
|
|
222
|
-
return {
|
|
223
|
-
authSessionInstance,
|
|
224
|
-
metadata
|
|
225
|
-
};
|
|
226
|
-
} catch (error) {
|
|
227
|
-
throw new Error(`Error retrieving auth session instance: ${error.message}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
async function getStorageState(context) {
|
|
231
|
-
const result = {};
|
|
232
|
-
const storageState = await context.storageState();
|
|
233
|
-
result.cookies = storageState.cookies;
|
|
234
|
-
result.origins = storageState.origins;
|
|
235
|
-
const sessionDataList = [];
|
|
236
|
-
const pages = context.pages();
|
|
237
|
-
for (const page of pages) {
|
|
238
|
-
if (page.isClosed()) continue;
|
|
239
|
-
try {
|
|
240
|
-
const sessionData = await page.evaluate(() => {
|
|
241
|
-
const items = {
|
|
242
|
-
...window.sessionStorage
|
|
243
|
-
};
|
|
244
|
-
return {
|
|
245
|
-
origin: window.location.origin,
|
|
246
|
-
sessionStorage: Object.entries(items).map(([name, value]) => ({
|
|
247
|
-
name,
|
|
248
|
-
value
|
|
249
|
-
}))
|
|
250
|
-
};
|
|
251
|
-
});
|
|
252
|
-
sessionDataList.push(sessionData);
|
|
253
|
-
} catch (error) {
|
|
254
|
-
console.error("Error getting sessionStorage:", error);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
result.sessionStorage = sessionDataList;
|
|
258
|
-
return result;
|
|
259
|
-
}
|
|
260
|
-
async function recordAuthSession(startUrl, endUrl) {
|
|
261
|
-
let browser;
|
|
262
|
-
try {
|
|
263
|
-
browser = await playwright.chromium.launch({
|
|
264
|
-
headless: false,
|
|
265
|
-
args: ["--start-maximized", "--no-sandbox"]
|
|
266
|
-
});
|
|
267
|
-
const context = await browser.newContext({
|
|
268
|
-
viewport: null
|
|
269
|
-
});
|
|
270
|
-
const page = await context.newPage();
|
|
271
|
-
await page.goto(startUrl);
|
|
272
|
-
await page.waitForURL(url => url.toString().startsWith(endUrl), {
|
|
273
|
-
timeout: 300000
|
|
274
|
-
});
|
|
275
|
-
const storageState = await getStorageState(context);
|
|
276
|
-
return storageState;
|
|
277
|
-
} catch (error) {
|
|
278
|
-
throw new Error(`Authentication recording failed: ${error.message}`);
|
|
279
|
-
} finally {
|
|
280
|
-
if (browser) {
|
|
281
|
-
await browser.close();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _commander = require("commander");
|
|
5
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
6
|
-
var _utils = require("../deploy/utils");
|
|
7
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
_dotenv.default.config({
|
|
9
|
-
path: `.env`
|
|
10
|
-
});
|
|
11
|
-
_commander.program.name("intuned-build-project").description("Build your current Intuned project").action(async () => {
|
|
12
|
-
try {
|
|
13
|
-
await (0, _utils.runBuild)();
|
|
14
|
-
} catch (error) {
|
|
15
|
-
process.exit(1);
|
|
16
|
-
} finally {
|
|
17
|
-
process.exit(0);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var _commander = require("commander");
|
|
5
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
7
|
-
var _utils = require("./utils");
|
|
8
|
-
var _utils2 = require("../../common/cli/utils");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
_dotenv.default.config({
|
|
11
|
-
path: `.env`
|
|
12
|
-
});
|
|
13
|
-
_commander.program.description("Deploy an Intuned project to be public").argument("[project-name]", "Name of the project to deploy").option("-w, --workspace-id <id>", "Your Intuned workspace ID").option("-k, --api-key <key>", "Your Intuned API key").action(async (projectName, options) => {
|
|
14
|
-
try {
|
|
15
|
-
const {
|
|
16
|
-
isValid,
|
|
17
|
-
errorMessage
|
|
18
|
-
} = await (0, _utils.validateIntunedProject)();
|
|
19
|
-
if (!isValid) {
|
|
20
|
-
const userErrorMesage = `Project to be deployed is not a valid Intuned project: ${errorMessage}, modify and check again`;
|
|
21
|
-
throw new Error(userErrorMesage);
|
|
22
|
-
}
|
|
23
|
-
const _projectName = projectName || (await (0, _utils2.getSettingIntunedJSON)("projectName"));
|
|
24
|
-
if (!_projectName) {
|
|
25
|
-
throw new Error("Project name is required");
|
|
26
|
-
}
|
|
27
|
-
const projectNameValidation = (0, _utils.validateProjectName)(_projectName);
|
|
28
|
-
if (!projectNameValidation.isValid) {
|
|
29
|
-
throw new Error(projectNameValidation.errorMessage);
|
|
30
|
-
}
|
|
31
|
-
const auth = await (0, _utils2.getAuthCredentials)(options);
|
|
32
|
-
const {
|
|
33
|
-
deployDone,
|
|
34
|
-
projectId,
|
|
35
|
-
deployErrorMessage
|
|
36
|
-
} = await (0, _utils.deployProject)(_projectName, auth);
|
|
37
|
-
if (!deployDone) {
|
|
38
|
-
throw new Error(`Project not deployed: ${deployErrorMessage}`);
|
|
39
|
-
}
|
|
40
|
-
const url = (0, _utils2.getBaseUrl)();
|
|
41
|
-
console.log(_chalk.default.green(`\n✅ Project "${_projectName}" deployed successfully!` + `\n\nYou can check your project on the platform: ${_chalk.default.bold(`${url}/projects/${projectId}/details`)}\n`));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error(_chalk.default.red(`\n${error.message}`));
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AuthCredentials, FileSystemTree } from "../../common/cli/types";
|
|
2
|
-
export declare function convertProjectToCodeTree(projectPath: string): Promise<FileSystemTree>;
|
|
3
|
-
export declare function deployProject(projectName: string, auth: AuthCredentials): Promise<{
|
|
4
|
-
deployDone: boolean;
|
|
5
|
-
projectId?: string;
|
|
6
|
-
deployErrorMessage?: string;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const validateProjectName: (projectName: string) => {
|
|
9
|
-
isValid: boolean;
|
|
10
|
-
errorMessage?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const validateIntunedProject: () => Promise<{
|
|
13
|
-
isValid: boolean;
|
|
14
|
-
errorMessage?: string;
|
|
15
|
-
}>;
|
|
16
|
-
export declare const runBuild: () => Promise<boolean>;
|