@intuned/runtime-dev 1.3.8-deploy.5 → 1.3.8-deploy.7
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/controller/deploy.js +46 -14
- package/dist/commands/intuned-cli/controller/save.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/save.js +5 -3
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +71 -55
- package/dist/commands/intuned-cli/helpers/intunedJson.js +14 -3
- package/package.json +1 -1
|
@@ -20,10 +20,11 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
20
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
async function runDeployProject(projectName, auth) {
|
|
22
22
|
const result = await (0, _save.runSaveProject)(projectName, auth);
|
|
23
|
-
const
|
|
23
|
+
const shouldPromptFirstRunExperience = result?.state === "UNPUBLISHED";
|
|
24
24
|
let firstRun = undefined;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const settings = await (0, _helpers.loadIntunedJson)();
|
|
26
|
+
if (shouldPromptFirstRunExperience) {
|
|
27
|
+
firstRun = await handleFirstRunExperience(settings);
|
|
27
28
|
}
|
|
28
29
|
const {
|
|
29
30
|
workspaceId,
|
|
@@ -97,12 +98,22 @@ async function runDeployProject(projectName, auth) {
|
|
|
97
98
|
}
|
|
98
99
|
if (status === "completed") {
|
|
99
100
|
const url = (0, _helpers.getBaseUrl)();
|
|
101
|
+
const hasDefaultJob = await getDefaultJobExists({
|
|
102
|
+
baseUrl,
|
|
103
|
+
workspaceId,
|
|
104
|
+
projectName,
|
|
105
|
+
apiKey
|
|
106
|
+
});
|
|
100
107
|
const projectUrl = `${url}/projects/${projectId}`;
|
|
101
108
|
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
|
|
102
109
|
(0, _terminal.terminal)(`^+View project:^s ^c^_${projectUrl}/runs^:\n`);
|
|
103
|
-
(
|
|
110
|
+
if (settings.apiAccess.enabled) {
|
|
111
|
+
(0, _terminal.terminal)(`^+Run playground:^s ^c^_${projectUrl}/runs?playground=open^:\n`);
|
|
112
|
+
}
|
|
104
113
|
(0, _terminal.terminal)(`^+Manage jobs:^s ^c^_${projectUrl}/jobs^:\n`);
|
|
105
|
-
(
|
|
114
|
+
if (hasDefaultJob) {
|
|
115
|
+
(0, _terminal.terminal)(`^+Trigger default job:^s ^c^_${projectUrl}/jobs/default?action=trigger^:\n`);
|
|
116
|
+
}
|
|
106
117
|
return;
|
|
107
118
|
}
|
|
108
119
|
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
@@ -154,9 +165,8 @@ const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey)
|
|
|
154
165
|
};
|
|
155
166
|
};
|
|
156
167
|
{}
|
|
157
|
-
async function handleFirstRunExperience() {
|
|
168
|
+
async function handleFirstRunExperience(settings) {
|
|
158
169
|
let testAuthSessionInput = undefined;
|
|
159
|
-
const settings = await (0, _helpers.loadIntunedJson)();
|
|
160
170
|
const shouldPromptForTestAuthSession = settings.authSessions.enabled && settings.authSessions.type === "API";
|
|
161
171
|
let shouldPromptForDefaultJob = true;
|
|
162
172
|
if (shouldPromptForTestAuthSession) {
|
|
@@ -184,13 +194,13 @@ async function getFirstRunExperienceTestAuthSessionParameters({
|
|
|
184
194
|
metadata
|
|
185
195
|
} = await (0, _helpers.loadAuthSessionInstance)(authSessionId);
|
|
186
196
|
if (metadata.authSessionInput) {
|
|
187
|
-
const message = shouldPromptForDefaultJob ? "
|
|
197
|
+
const message = shouldPromptForDefaultJob ? "^+Create a test auth session using ^:^+%s^:^+'s parameters?^ :^/(required for creating default job)^:" : "^+Create a test auth session using ^:^+%s^:^+'s parameters?^:";
|
|
188
198
|
(0, _terminal.terminal)(message, authSessionId);
|
|
189
199
|
const answer = await _terminal.terminal.yesOrNo({
|
|
190
200
|
yes: ["y", "ENTER"],
|
|
191
201
|
no: ["n"],
|
|
192
|
-
echoYes: "^g^+Yes^:",
|
|
193
|
-
echoNo: "^r^+No^:"
|
|
202
|
+
echoYes: " ^g^+Yes^:",
|
|
203
|
+
echoNo: " ^r^+No^:"
|
|
194
204
|
}).promise;
|
|
195
205
|
(0, _terminal.terminal)("\n");
|
|
196
206
|
if (answer) {
|
|
@@ -202,16 +212,38 @@ async function getFirstRunExperienceTestAuthSessionParameters({
|
|
|
202
212
|
async function getFirstRunExperienceDefaultJobParameters({
|
|
203
213
|
defaultJobInput
|
|
204
214
|
}) {
|
|
205
|
-
(0, _terminal.terminal)("\n
|
|
215
|
+
(0, _terminal.terminal)("\n^+Create a default job?^:");
|
|
206
216
|
const answer = await _terminal.terminal.yesOrNo({
|
|
207
217
|
yes: ["y", "ENTER"],
|
|
208
218
|
no: ["n"],
|
|
209
|
-
echoYes: "^g^+Yes^:",
|
|
210
|
-
echoNo: "^r^+No^:"
|
|
219
|
+
echoYes: " ^g^+Yes^:",
|
|
220
|
+
echoNo: " ^r^+No^:"
|
|
211
221
|
}).promise;
|
|
212
222
|
(0, _terminal.terminal)("\n");
|
|
213
223
|
if (answer) {
|
|
214
|
-
console.log("defaultJobInput", defaultJobInput);
|
|
215
224
|
return defaultJobInput;
|
|
216
225
|
}
|
|
226
|
+
}
|
|
227
|
+
async function getDefaultJobExists({
|
|
228
|
+
baseUrl,
|
|
229
|
+
workspaceId,
|
|
230
|
+
projectName,
|
|
231
|
+
apiKey
|
|
232
|
+
}) {
|
|
233
|
+
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/jobs/default`;
|
|
234
|
+
const headers = {
|
|
235
|
+
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
236
|
+
"Content-Type": "application/json"
|
|
237
|
+
};
|
|
238
|
+
const response = await fetch(url, {
|
|
239
|
+
headers,
|
|
240
|
+
method: "GET"
|
|
241
|
+
});
|
|
242
|
+
if (response.status === 404) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
if (!response.ok) {
|
|
246
|
+
throw new _helpers.CLIError(`Error checking default job existence ${response.status}: ${await response.text()}`);
|
|
247
|
+
}
|
|
248
|
+
return true;
|
|
217
249
|
}
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import type { AuthCredentials } from "../types";
|
|
3
3
|
export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<{
|
|
4
4
|
projectId: string;
|
|
5
|
-
state: string;
|
|
5
|
+
state: string | undefined;
|
|
6
6
|
} | undefined>;
|
|
7
7
|
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
8
8
|
export declare const validateProjectName: (projectName: string) => {
|
|
@@ -33,7 +33,8 @@ const saveProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
|
|
|
33
33
|
return _zod.z.NEVER;
|
|
34
34
|
}
|
|
35
35
|
}).pipe(_zod.z.object({
|
|
36
|
-
id: _zod.z.string().uuid()
|
|
36
|
+
id: _zod.z.string().uuid(),
|
|
37
|
+
state: _zod.z.string().optional()
|
|
37
38
|
}));
|
|
38
39
|
async function runSaveProject(projectName, auth) {
|
|
39
40
|
const {
|
|
@@ -86,7 +87,8 @@ async function runSaveProject(projectName, auth) {
|
|
|
86
87
|
return;
|
|
87
88
|
}
|
|
88
89
|
const {
|
|
89
|
-
id: projectId
|
|
90
|
+
id: projectId,
|
|
91
|
+
state
|
|
90
92
|
} = parseResult.data;
|
|
91
93
|
const dotEnvPath = path.join(projectPath, ".env");
|
|
92
94
|
if (!(await fs.exists(dotEnvPath))) {
|
|
@@ -113,7 +115,7 @@ ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
|
|
|
113
115
|
}
|
|
114
116
|
return {
|
|
115
117
|
projectId,
|
|
116
|
-
state
|
|
118
|
+
state
|
|
117
119
|
};
|
|
118
120
|
}
|
|
119
121
|
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const intunedJsonSchema: z.ZodObject<{
|
|
3
|
-
|
|
2
|
+
export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
3
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
4
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
6
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
7
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
9
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
10
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
12
|
+
authSessions: z.ZodObject<{
|
|
4
13
|
enabled: z.ZodLiteral<false>;
|
|
5
14
|
}, "strip", z.ZodTypeAny, {
|
|
6
15
|
enabled: false;
|
|
7
16
|
}, {
|
|
8
17
|
enabled: false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
startUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
-
finishUrl: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}>;
|
|
19
|
+
apiAccess: z.ZodObject<{
|
|
20
|
+
enabled: z.ZodLiteral<false>;
|
|
14
21
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
|
|
16
|
-
enabled: true;
|
|
17
|
-
startUrl?: string | undefined;
|
|
18
|
-
finishUrl?: string | undefined;
|
|
22
|
+
enabled: false;
|
|
19
23
|
}, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
enabled: false;
|
|
25
|
+
}>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
authSessions: {
|
|
28
|
+
enabled: false;
|
|
29
|
+
};
|
|
30
|
+
apiAccess: {
|
|
31
|
+
enabled: false;
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
authSessions: {
|
|
35
|
+
enabled: false;
|
|
36
|
+
};
|
|
37
|
+
apiAccess: {
|
|
38
|
+
enabled: false;
|
|
39
|
+
};
|
|
40
|
+
}>, z.ZodObject<{
|
|
28
41
|
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
29
42
|
enabled: z.ZodLiteral<false>;
|
|
30
43
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -47,62 +60,65 @@ export declare const intunedJsonSchema: z.ZodObject<{
|
|
|
47
60
|
startUrl?: string | undefined;
|
|
48
61
|
finishUrl?: string | undefined;
|
|
49
62
|
}>]>;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
53
|
-
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
54
|
-
enabled: z.ZodLiteral<false>;
|
|
63
|
+
apiAccess: z.ZodObject<{
|
|
64
|
+
enabled: z.ZodLiteral<true>;
|
|
55
65
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
enabled:
|
|
66
|
+
enabled: true;
|
|
57
67
|
}, {
|
|
68
|
+
enabled: true;
|
|
69
|
+
}>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
authSessions: {
|
|
58
72
|
enabled: false;
|
|
59
|
-
}
|
|
60
|
-
enabled: z.ZodLiteral<true>;
|
|
61
|
-
type: z.ZodEnum<["MANUAL", "API"]>;
|
|
62
|
-
startUrl: z.ZodOptional<z.ZodString>;
|
|
63
|
-
finishUrl: z.ZodOptional<z.ZodString>;
|
|
64
|
-
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
} | {
|
|
65
74
|
type: "API" | "MANUAL";
|
|
66
75
|
enabled: true;
|
|
67
76
|
startUrl?: string | undefined;
|
|
68
77
|
finishUrl?: string | undefined;
|
|
69
|
-
}
|
|
78
|
+
};
|
|
79
|
+
apiAccess: {
|
|
80
|
+
enabled: true;
|
|
81
|
+
};
|
|
82
|
+
}, {
|
|
83
|
+
authSessions: {
|
|
84
|
+
enabled: false;
|
|
85
|
+
} | {
|
|
70
86
|
type: "API" | "MANUAL";
|
|
71
87
|
enabled: true;
|
|
72
88
|
startUrl?: string | undefined;
|
|
73
89
|
finishUrl?: string | undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
90
|
+
};
|
|
91
|
+
apiAccess: {
|
|
92
|
+
enabled: true;
|
|
93
|
+
};
|
|
94
|
+
}>]>>;
|
|
78
95
|
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
79
96
|
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
80
|
-
export declare function loadIntunedJson(): Promise<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
export declare function loadIntunedJson(): Promise<{
|
|
98
|
+
projectName?: string | undefined;
|
|
99
|
+
workspaceId?: string | undefined;
|
|
100
|
+
} & {
|
|
101
|
+
[k: string]: unknown;
|
|
102
|
+
} & ({
|
|
103
|
+
authSessions: {
|
|
84
104
|
enabled: false;
|
|
85
|
-
}
|
|
105
|
+
};
|
|
106
|
+
apiAccess: {
|
|
86
107
|
enabled: false;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
};
|
|
109
|
+
} | {
|
|
110
|
+
authSessions: {
|
|
111
|
+
enabled: false;
|
|
112
|
+
} | {
|
|
93
113
|
type: "API" | "MANUAL";
|
|
94
114
|
enabled: true;
|
|
95
115
|
startUrl?: string | undefined;
|
|
96
116
|
finishUrl?: string | undefined;
|
|
97
|
-
}
|
|
98
|
-
|
|
117
|
+
};
|
|
118
|
+
apiAccess: {
|
|
99
119
|
enabled: true;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}>]>;
|
|
103
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
104
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
105
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
120
|
+
};
|
|
121
|
+
})>;
|
|
106
122
|
export declare function getIntunedSettingsFile(): Promise<{
|
|
107
123
|
name: typeof intunedSettingsFileNames[number];
|
|
108
124
|
path: string;
|
|
@@ -18,6 +18,16 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
18
18
|
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; }
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
20
|
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
21
|
+
projectName: _zod.z.string().optional(),
|
|
22
|
+
workspaceId: _zod.z.string().optional()
|
|
23
|
+
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
24
|
+
authSessions: _zod.z.object({
|
|
25
|
+
enabled: _zod.z.literal(false)
|
|
26
|
+
}),
|
|
27
|
+
apiAccess: _zod.z.object({
|
|
28
|
+
enabled: _zod.z.literal(false)
|
|
29
|
+
})
|
|
30
|
+
}), _zod.z.object({
|
|
21
31
|
authSessions: _zod.z.union([_zod.z.object({
|
|
22
32
|
enabled: _zod.z.literal(false)
|
|
23
33
|
}), _zod.z.object({
|
|
@@ -26,9 +36,10 @@ const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
|
26
36
|
startUrl: _zod.z.string().optional(),
|
|
27
37
|
finishUrl: _zod.z.string().optional()
|
|
28
38
|
})]),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
39
|
+
apiAccess: _zod.z.object({
|
|
40
|
+
enabled: _zod.z.literal(true)
|
|
41
|
+
})
|
|
42
|
+
})]));
|
|
32
43
|
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
33
44
|
async function loadIntunedJson() {
|
|
34
45
|
const settingsFile = await getIntunedSettingsFile();
|