eas-cli 21.0.2 → 21.0.3
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/README.md +144 -170
- package/build/chat/chatClient.d.ts +37 -0
- package/build/chat/chatClient.js +359 -0
- package/build/chat/detectProject.d.ts +5 -0
- package/build/chat/detectProject.js +41 -0
- package/build/chat/renderMarkdown.d.ts +7 -0
- package/build/chat/renderMarkdown.js +47 -0
- package/build/chat/replInput.d.ts +10 -0
- package/build/chat/replInput.js +52 -0
- package/build/commands/chat.d.ts +18 -0
- package/build/commands/chat.js +221 -0
- package/build/commands/env/create.d.ts +1 -0
- package/build/commands/env/create.js +4 -1
- package/build/commands/env/set.d.ts +27 -0
- package/build/commands/env/set.js +222 -0
- package/build/commands/env/update.d.ts +1 -0
- package/build/commands/env/update.js +4 -1
- package/build/commands/observe/events.js +6 -5
- package/build/commands/observe/metrics-summary.js +4 -3
- package/build/commands/observe/metrics.js +5 -4
- package/build/commands/observe/routes.js +4 -3
- package/build/commands/observe/session.d.ts +6 -1
- package/build/commands/observe/session.js +133 -7
- package/build/commands/observe/versions.js +4 -3
- package/build/graphql/generated.d.ts +94 -0
- package/build/graphql/queries/ObserveQuery.d.ts +2 -1
- package/build/graphql/queries/ObserveQuery.js +7 -1
- package/build/observe/fetchCustomEvents.d.ts +2 -1
- package/build/observe/fetchCustomEvents.js +1 -0
- package/build/observe/fetchSessions.d.ts +42 -0
- package/build/observe/fetchSessions.js +36 -0
- package/build/observe/formatSessions.d.ts +16 -0
- package/build/observe/formatSessions.js +36 -0
- package/build/observe/metricNames.d.ts +7 -0
- package/build/observe/metricNames.js +13 -0
- package/oclif.manifest.json +2110 -1808
- package/package.json +5 -5
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const chatClient_1 = require("../chat/chatClient");
|
|
7
|
+
const detectProject_1 = require("../chat/detectProject");
|
|
8
|
+
const replInput_1 = require("../chat/replInput");
|
|
9
|
+
const EasCommand_1 = tslib_1.__importDefault(require("../commandUtils/EasCommand"));
|
|
10
|
+
const flags_1 = require("../commandUtils/flags");
|
|
11
|
+
const AppQuery_1 = require("../graphql/queries/AppQuery");
|
|
12
|
+
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
13
|
+
const json_1 = require("../utils/json");
|
|
14
|
+
const EXIT_WORDS = new Set(['exit', 'quit', 'q']);
|
|
15
|
+
const USER_LABEL = `${chalk_1.default.bold.cyan('Chat')}${chalk_1.default.dim(' > ')}`;
|
|
16
|
+
const CHAT_HELP = [
|
|
17
|
+
'Commands:',
|
|
18
|
+
' /help Show this help',
|
|
19
|
+
' /clear Start a new conversation',
|
|
20
|
+
' /exit Quit',
|
|
21
|
+
].join('\n');
|
|
22
|
+
class Chat extends EasCommand_1.default {
|
|
23
|
+
static description = 'ask an AI assistant about your Expo account and EAS projects';
|
|
24
|
+
static hidden = true;
|
|
25
|
+
static args = {
|
|
26
|
+
message: core_1.Args.string({
|
|
27
|
+
required: false,
|
|
28
|
+
description: 'Message to send to the assistant (omit to open an interactive prompt)',
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
static flags = {
|
|
32
|
+
account: core_1.Flags.string({
|
|
33
|
+
char: 'a',
|
|
34
|
+
description: 'Account to scope the conversation to (defaults to your primary account)',
|
|
35
|
+
}),
|
|
36
|
+
project: core_1.Flags.string({
|
|
37
|
+
char: 'p',
|
|
38
|
+
description: 'Project to focus the conversation on, as @account-name/project-slug or a project slug',
|
|
39
|
+
}),
|
|
40
|
+
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
41
|
+
};
|
|
42
|
+
static contextDefinition = {
|
|
43
|
+
...this.ContextOptions.LoggedIn,
|
|
44
|
+
};
|
|
45
|
+
async runAsync() {
|
|
46
|
+
const { args, flags } = await this.parse(Chat);
|
|
47
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
48
|
+
if (json) {
|
|
49
|
+
(0, json_1.enableJsonOutput)();
|
|
50
|
+
}
|
|
51
|
+
if (!args.message && (json || nonInteractive)) {
|
|
52
|
+
throw new Error('Provide a message, e.g. `eas chat "how are my builds?"`.');
|
|
53
|
+
}
|
|
54
|
+
const { loggedIn: { actor, authenticationInfo, graphqlClient }, } = await this.getContextAsync(Chat, { nonInteractive });
|
|
55
|
+
if (!authenticationInfo.sessionSecret) {
|
|
56
|
+
throw new Error('`eas chat` requires an interactive login. Run `eas login` first. Chat does not support EXPO_TOKEN access tokens yet.');
|
|
57
|
+
}
|
|
58
|
+
const { sessionSecret } = authenticationInfo;
|
|
59
|
+
let accountName = flags.account ?? getDefaultAccountName(actor);
|
|
60
|
+
let projectLabel;
|
|
61
|
+
let projectDetectedFromDirectory = false;
|
|
62
|
+
if (flags.project) {
|
|
63
|
+
const resolved = await resolveProjectAsync(graphqlClient, flags.project, accountName);
|
|
64
|
+
accountName = resolved.accountName;
|
|
65
|
+
projectLabel = resolved.label;
|
|
66
|
+
}
|
|
67
|
+
else if (!flags.account) {
|
|
68
|
+
const detected = await (0, detectProject_1.detectCurrentProjectAsync)(graphqlClient);
|
|
69
|
+
if (detected) {
|
|
70
|
+
accountName = detected.accountName;
|
|
71
|
+
projectLabel = detected.label;
|
|
72
|
+
projectDetectedFromDirectory = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (json) {
|
|
76
|
+
const messages = [
|
|
77
|
+
(0, chatClient_1.makeUserMessage)(scopeMessageToProject(args.message, projectLabel)),
|
|
78
|
+
];
|
|
79
|
+
const result = await (0, chatClient_1.streamChatResponseAsync)({
|
|
80
|
+
messages: [...messages],
|
|
81
|
+
accountName,
|
|
82
|
+
sessionSecret,
|
|
83
|
+
stream: false,
|
|
84
|
+
});
|
|
85
|
+
(0, json_1.printJsonOnlyOutput)({
|
|
86
|
+
message: args.message,
|
|
87
|
+
account: accountName ?? null,
|
|
88
|
+
project: projectLabel ?? null,
|
|
89
|
+
response: result.text,
|
|
90
|
+
toolCalls: result.toolCalls,
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (projectLabel) {
|
|
95
|
+
log_1.default.log(chalk_1.default.dim(projectDetectedFromDirectory
|
|
96
|
+
? `Project: ${projectLabel} (from current directory; use --account to widen)`
|
|
97
|
+
: `Project: ${projectLabel}`));
|
|
98
|
+
}
|
|
99
|
+
if (!nonInteractive) {
|
|
100
|
+
log_1.default.log(chalk_1.default.dim('Use /help for commands, or /exit to quit.'));
|
|
101
|
+
}
|
|
102
|
+
const input = nonInteractive
|
|
103
|
+
? undefined
|
|
104
|
+
: (0, replInput_1.createChatReplInput)({ history: args.message ? [args.message] : [] });
|
|
105
|
+
const messages = [];
|
|
106
|
+
if (args.message) {
|
|
107
|
+
log_1.default.log(`${USER_LABEL}${args.message}`);
|
|
108
|
+
log_1.default.newLine();
|
|
109
|
+
messages.push((0, chatClient_1.makeUserMessage)(scopeMessageToProject(args.message, projectLabel)));
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
for (;;) {
|
|
113
|
+
const lastMessage = messages[messages.length - 1];
|
|
114
|
+
if (!lastMessage || lastMessage.role === 'assistant') {
|
|
115
|
+
if (!input) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
const scopeNextMessage = messages.length === 0;
|
|
119
|
+
const nextMessage = await readNextUserMessageAsync(input, messages, projectLabel, scopeNextMessage);
|
|
120
|
+
if (nextMessage === null) {
|
|
121
|
+
log_1.default.log(chalk_1.default.dim('Ending chat.'));
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
messages.push((0, chatClient_1.makeUserMessage)(nextMessage));
|
|
125
|
+
}
|
|
126
|
+
let result;
|
|
127
|
+
try {
|
|
128
|
+
result = await (0, chatClient_1.streamChatResponseAsync)({
|
|
129
|
+
messages: [...messages],
|
|
130
|
+
accountName,
|
|
131
|
+
sessionSecret,
|
|
132
|
+
stream: true,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (!input) {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
log_1.default.error(error instanceof Error ? error.message : String(error));
|
|
140
|
+
messages.pop();
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
messages.push(result.assistantMessage);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
input?.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.default = Chat;
|
|
152
|
+
async function readNextUserMessageAsync(input, messages, projectLabel, scopeFirstMessage = false) {
|
|
153
|
+
let shouldRestoreProjectScope = scopeFirstMessage;
|
|
154
|
+
for (;;) {
|
|
155
|
+
log_1.default.newLine();
|
|
156
|
+
const line = await input.askAsync(USER_LABEL);
|
|
157
|
+
if (line === null) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const trimmed = line.trim();
|
|
161
|
+
if (!trimmed) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (EXIT_WORDS.has(trimmed.toLowerCase())) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
if (trimmed.startsWith('/')) {
|
|
168
|
+
const command = trimmed.slice(1).split(/\s+/)[0].toLowerCase();
|
|
169
|
+
if (['exit', 'quit', 'q'].includes(command)) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
if (['clear', 'new', 'reset'].includes(command)) {
|
|
173
|
+
messages.length = 0;
|
|
174
|
+
shouldRestoreProjectScope = true;
|
|
175
|
+
log_1.default.log(chalk_1.default.dim('Started a new conversation.'));
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (['help', 'h', '?'].includes(command)) {
|
|
179
|
+
log_1.default.log(chalk_1.default.dim(CHAT_HELP));
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
log_1.default.warn(`Unknown command "/${command}". Type /help for commands.`);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
log_1.default.newLine();
|
|
186
|
+
return shouldRestoreProjectScope ? scopeMessageToProject(trimmed, projectLabel) : trimmed;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function scopeMessageToProject(message, projectLabel) {
|
|
190
|
+
return projectLabel ? `Regarding the EAS project ${projectLabel}: ${message}` : message;
|
|
191
|
+
}
|
|
192
|
+
function getDefaultAccountName(actor) {
|
|
193
|
+
if ('primaryAccount' in actor && actor.primaryAccount) {
|
|
194
|
+
return actor.primaryAccount.name;
|
|
195
|
+
}
|
|
196
|
+
return actor.accounts[0]?.name ?? undefined;
|
|
197
|
+
}
|
|
198
|
+
async function resolveProjectAsync(graphqlClient, projectReference, fallbackAccountName) {
|
|
199
|
+
const parsed = parseProjectReference(projectReference);
|
|
200
|
+
const accountForLookup = parsed.account ?? fallbackAccountName;
|
|
201
|
+
if (!accountForLookup) {
|
|
202
|
+
throw new Error(`Could not determine which account owns project "${projectReference}". Pass it as @account-name/project-slug.`);
|
|
203
|
+
}
|
|
204
|
+
const fullName = `@${accountForLookup}/${parsed.slug}`;
|
|
205
|
+
let app;
|
|
206
|
+
try {
|
|
207
|
+
app = await AppQuery_1.AppQuery.byFullNameAsync(graphqlClient, fullName);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
throw new Error(`Project ${fullName} was not found or you do not have access to it.`);
|
|
211
|
+
}
|
|
212
|
+
return { accountName: app.ownerAccount.name, label: app.fullName };
|
|
213
|
+
}
|
|
214
|
+
function parseProjectReference(reference) {
|
|
215
|
+
const cleaned = reference.startsWith('@') ? reference.slice(1) : reference;
|
|
216
|
+
const parts = cleaned.split('/');
|
|
217
|
+
if (parts.length === 2 && parts[0] && parts[1]) {
|
|
218
|
+
return { account: parts[0], slug: parts[1] };
|
|
219
|
+
}
|
|
220
|
+
return { slug: cleaned };
|
|
221
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class EnvCreate extends EasCommand {
|
|
3
3
|
static description: string;
|
|
4
|
+
static hidden: boolean;
|
|
4
5
|
static args: {
|
|
5
6
|
environment: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
7
|
};
|
|
@@ -15,7 +15,8 @@ const projectUtils_1 = require("../../project/projectUtils");
|
|
|
15
15
|
const prompts_1 = require("../../prompts");
|
|
16
16
|
const prompts_2 = require("../../utils/prompts");
|
|
17
17
|
class EnvCreate extends EasCommand_1.default {
|
|
18
|
-
static description = 'create an environment variable for the current project or account';
|
|
18
|
+
static description = 'create an environment variable for the current project or account (deprecated, use eas env:set)';
|
|
19
|
+
static hidden = true;
|
|
19
20
|
static args = {
|
|
20
21
|
environment: core_1.Args.string({
|
|
21
22
|
description: "Environment to create the variable in. Default environments are 'production', 'preview', and 'development'.",
|
|
@@ -48,6 +49,8 @@ class EnvCreate extends EasCommand_1.default {
|
|
|
48
49
|
...this.ContextOptions.LoggedIn,
|
|
49
50
|
};
|
|
50
51
|
async runAsync() {
|
|
52
|
+
log_1.default.warn('This command is deprecated. Use eas env:set instead.');
|
|
53
|
+
log_1.default.newLine();
|
|
51
54
|
const { args, flags } = await this.parse(EnvCreate);
|
|
52
55
|
const validatedFlags = this.sanitizeFlags(flags);
|
|
53
56
|
const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(EnvCreate, {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
export default class EnvSet extends EasCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
environment: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
scope: import("@oclif/core/lib/interfaces").OptionFlag<"project" | "account", import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
visibility: import("@oclif/core/lib/interfaces").OptionFlag<"plaintext" | "sensitive" | "secret" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
type: import("@oclif/core/lib/interfaces").OptionFlag<"string" | "file" | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
static contextDefinition: {
|
|
18
|
+
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
19
|
+
analytics: import("../../commandUtils/context/AnalyticsContextField").default;
|
|
20
|
+
projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
|
|
21
|
+
};
|
|
22
|
+
runAsync(): Promise<void>;
|
|
23
|
+
private resolveEnvironmentsAsync;
|
|
24
|
+
private findExistingVariableAsync;
|
|
25
|
+
private resolveVariableDetailsAsync;
|
|
26
|
+
private sanitizeFlags;
|
|
27
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
9
|
+
const flags_1 = require("../../commandUtils/flags");
|
|
10
|
+
const generated_1 = require("../../graphql/generated");
|
|
11
|
+
const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
|
|
12
|
+
const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
|
|
13
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
14
|
+
const projectUtils_1 = require("../../project/projectUtils");
|
|
15
|
+
const json_1 = require("../../utils/json");
|
|
16
|
+
const prompts_1 = require("../../utils/prompts");
|
|
17
|
+
class EnvSet extends EasCommand_1.default {
|
|
18
|
+
static description = 'set (create or update) an environment variable on the current project or account';
|
|
19
|
+
static args = {
|
|
20
|
+
environment: core_1.Args.string({
|
|
21
|
+
description: "Environment to set the variable in. Default environments are 'production', 'preview', and 'development'.",
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
static flags = {
|
|
26
|
+
name: core_1.Flags.string({
|
|
27
|
+
description: 'Name of the variable',
|
|
28
|
+
aliases: ['variable-name'],
|
|
29
|
+
}),
|
|
30
|
+
value: core_1.Flags.string({
|
|
31
|
+
description: 'Text value of the variable',
|
|
32
|
+
aliases: ['variable-value'],
|
|
33
|
+
}),
|
|
34
|
+
type: core_1.Flags.option({
|
|
35
|
+
description: 'The type of variable',
|
|
36
|
+
options: ['string', 'file'],
|
|
37
|
+
})(),
|
|
38
|
+
...flags_1.EASVariableVisibilityFlag,
|
|
39
|
+
...flags_1.EASEnvironmentVariableScopeFlag,
|
|
40
|
+
...flags_1.EASMultiEnvironmentFlag,
|
|
41
|
+
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
42
|
+
};
|
|
43
|
+
static contextDefinition = {
|
|
44
|
+
...this.ContextOptions.ProjectId,
|
|
45
|
+
...this.ContextOptions.Analytics,
|
|
46
|
+
...this.ContextOptions.LoggedIn,
|
|
47
|
+
};
|
|
48
|
+
async runAsync() {
|
|
49
|
+
const { args, flags } = await this.parse(EnvSet);
|
|
50
|
+
const { name: nameFlag, value, type, visibility, scope, environment, } = this.sanitizeFlags(flags);
|
|
51
|
+
const { json: jsonFlag, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
52
|
+
const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(EnvSet, {
|
|
53
|
+
nonInteractive,
|
|
54
|
+
});
|
|
55
|
+
if (jsonFlag) {
|
|
56
|
+
(0, json_1.enableJsonOutput)();
|
|
57
|
+
}
|
|
58
|
+
const name = nameFlag ?? (await (0, prompts_1.promptVariableNameAsync)(nonInteractive));
|
|
59
|
+
const environments = await this.resolveEnvironmentsAsync(environment, args.environment, {
|
|
60
|
+
nonInteractive,
|
|
61
|
+
graphqlClient,
|
|
62
|
+
projectId,
|
|
63
|
+
});
|
|
64
|
+
const existingVariable = await this.findExistingVariableAsync(graphqlClient, {
|
|
65
|
+
scope,
|
|
66
|
+
projectId,
|
|
67
|
+
name,
|
|
68
|
+
environments,
|
|
69
|
+
});
|
|
70
|
+
const environmentsToSet = existingVariable
|
|
71
|
+
? [...new Set([...(existingVariable.environments ?? []), ...environments])]
|
|
72
|
+
: environments;
|
|
73
|
+
const { value: resolvedValue, visibility: resolvedVisibility, type: resolvedType, fileName, } = await this.resolveVariableDetailsAsync({ name, value, type, visibility, nonInteractive }, existingVariable);
|
|
74
|
+
const [projectDisplayName, ownerAccount] = await Promise.all([
|
|
75
|
+
(0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId),
|
|
76
|
+
(0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
|
|
77
|
+
]);
|
|
78
|
+
if (scope === generated_1.EnvironmentVariableScope.Project) {
|
|
79
|
+
const variable = existingVariable
|
|
80
|
+
? await EnvironmentVariableMutation_1.EnvironmentVariableMutation.updateAsync(graphqlClient, {
|
|
81
|
+
id: existingVariable.id,
|
|
82
|
+
name,
|
|
83
|
+
value: resolvedValue,
|
|
84
|
+
visibility: resolvedVisibility,
|
|
85
|
+
environments: environmentsToSet,
|
|
86
|
+
type: resolvedType,
|
|
87
|
+
fileName,
|
|
88
|
+
})
|
|
89
|
+
: await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
|
|
90
|
+
name,
|
|
91
|
+
value: resolvedValue,
|
|
92
|
+
environments,
|
|
93
|
+
visibility: resolvedVisibility,
|
|
94
|
+
type: resolvedType ?? generated_1.EnvironmentSecretType.String,
|
|
95
|
+
fileName,
|
|
96
|
+
}, projectId);
|
|
97
|
+
if (!variable) {
|
|
98
|
+
throw new Error(`Could not set variable with name ${name} on project ${projectDisplayName}`);
|
|
99
|
+
}
|
|
100
|
+
if (jsonFlag) {
|
|
101
|
+
(0, json_1.printJsonOnlyOutput)(variable);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
log_1.default.withTick(`${existingVariable ? 'Updated' : 'Created'} variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (scope === generated_1.EnvironmentVariableScope.Shared) {
|
|
108
|
+
const variable = existingVariable
|
|
109
|
+
? await EnvironmentVariableMutation_1.EnvironmentVariableMutation.updateAsync(graphqlClient, {
|
|
110
|
+
id: existingVariable.id,
|
|
111
|
+
name,
|
|
112
|
+
value: resolvedValue,
|
|
113
|
+
visibility: resolvedVisibility,
|
|
114
|
+
environments: environmentsToSet,
|
|
115
|
+
type: resolvedType,
|
|
116
|
+
})
|
|
117
|
+
: await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
|
|
118
|
+
name,
|
|
119
|
+
value: resolvedValue,
|
|
120
|
+
visibility: resolvedVisibility,
|
|
121
|
+
environments,
|
|
122
|
+
type: resolvedType ?? generated_1.EnvironmentSecretType.String,
|
|
123
|
+
}, ownerAccount.id);
|
|
124
|
+
if (!variable) {
|
|
125
|
+
throw new Error(`Could not set variable with name ${name} on account ${ownerAccount.name}`);
|
|
126
|
+
}
|
|
127
|
+
if (jsonFlag) {
|
|
128
|
+
(0, json_1.printJsonOnlyOutput)(variable);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
log_1.default.withTick(`${existingVariable ? 'Updated' : 'Created'} variable ${chalk_1.default.bold(name)} on account ${chalk_1.default.bold(ownerAccount.name)}.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async resolveEnvironmentsAsync(environmentFlag, environmentArg, { nonInteractive, graphqlClient, projectId, }) {
|
|
136
|
+
const environments = environmentFlag ?? (environmentArg ? [environmentArg] : undefined);
|
|
137
|
+
if (environments && environments.length > 0) {
|
|
138
|
+
return environments;
|
|
139
|
+
}
|
|
140
|
+
const promptedEnvironments = await (0, prompts_1.promptVariableEnvironmentAsync)({
|
|
141
|
+
nonInteractive,
|
|
142
|
+
multiple: true,
|
|
143
|
+
canEnterCustomEnvironment: true,
|
|
144
|
+
graphqlClient,
|
|
145
|
+
projectId,
|
|
146
|
+
});
|
|
147
|
+
if (!promptedEnvironments || promptedEnvironments.length === 0) {
|
|
148
|
+
throw new Error('No environments selected');
|
|
149
|
+
}
|
|
150
|
+
return promptedEnvironments;
|
|
151
|
+
}
|
|
152
|
+
async findExistingVariableAsync(graphqlClient, { scope, projectId, name, environments, }) {
|
|
153
|
+
if (scope === generated_1.EnvironmentVariableScope.Project) {
|
|
154
|
+
const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, {
|
|
155
|
+
appId: projectId,
|
|
156
|
+
filterNames: [name],
|
|
157
|
+
});
|
|
158
|
+
return existingVariables.find(variable => variable.scope === generated_1.EnvironmentVariableScope.Project &&
|
|
159
|
+
variable.environments?.some(env => environments.includes(env)));
|
|
160
|
+
}
|
|
161
|
+
const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, {
|
|
162
|
+
appId: projectId,
|
|
163
|
+
filterNames: [name],
|
|
164
|
+
});
|
|
165
|
+
return existingVariables.find(variable => variable.environments?.some(env => environments.includes(env)));
|
|
166
|
+
}
|
|
167
|
+
async resolveVariableDetailsAsync({ name, value, type, visibility, nonInteractive, }, existingVariable) {
|
|
168
|
+
let newType;
|
|
169
|
+
if (type === 'file') {
|
|
170
|
+
newType = generated_1.EnvironmentSecretType.FileBase64;
|
|
171
|
+
}
|
|
172
|
+
else if (type === 'string') {
|
|
173
|
+
newType = generated_1.EnvironmentSecretType.String;
|
|
174
|
+
}
|
|
175
|
+
let newVisibility = visibility ? (0, prompts_1.parseVisibility)(visibility) : undefined;
|
|
176
|
+
if (!type && !value && !nonInteractive) {
|
|
177
|
+
newType = await (0, prompts_1.promptVariableTypeAsync)(nonInteractive, existingVariable?.type);
|
|
178
|
+
}
|
|
179
|
+
if (!newVisibility && !nonInteractive) {
|
|
180
|
+
newVisibility = await (0, prompts_1.promptVariableVisibilityAsync)(nonInteractive, existingVariable?.visibility);
|
|
181
|
+
}
|
|
182
|
+
if (value && !newType) {
|
|
183
|
+
newType = existingVariable?.type;
|
|
184
|
+
}
|
|
185
|
+
if (!value) {
|
|
186
|
+
value = await (0, prompts_1.promptVariableValueAsync)({
|
|
187
|
+
nonInteractive,
|
|
188
|
+
hidden: newVisibility !== generated_1.EnvironmentVariableVisibility.Public,
|
|
189
|
+
filePath: (newType ?? existingVariable?.type) === generated_1.EnvironmentSecretType.FileBase64,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
newVisibility =
|
|
193
|
+
newVisibility ?? existingVariable?.visibility ?? generated_1.EnvironmentVariableVisibility.Public;
|
|
194
|
+
let fileName;
|
|
195
|
+
if (newType === generated_1.EnvironmentSecretType.FileBase64) {
|
|
196
|
+
const environmentFilePath = path_1.default.resolve(value);
|
|
197
|
+
if (!(await fs_extra_1.default.pathExists(environmentFilePath))) {
|
|
198
|
+
if (type === 'file') {
|
|
199
|
+
throw new Error(`File "${value}" does not exist`);
|
|
200
|
+
}
|
|
201
|
+
throw new Error(`Variable "${name}" is a file type, but "${value}" does not exist as a file. If you want to convert it to a string, pass --type string.`);
|
|
202
|
+
}
|
|
203
|
+
fileName = path_1.default.basename(environmentFilePath);
|
|
204
|
+
value = await fs_extra_1.default.readFile(environmentFilePath, 'base64');
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
value,
|
|
208
|
+
visibility: newVisibility,
|
|
209
|
+
type: newType,
|
|
210
|
+
fileName,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
sanitizeFlags(flags) {
|
|
214
|
+
return {
|
|
215
|
+
...flags,
|
|
216
|
+
scope: flags.scope === 'account'
|
|
217
|
+
? generated_1.EnvironmentVariableScope.Shared
|
|
218
|
+
: generated_1.EnvironmentVariableScope.Project,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
exports.default = EnvSet;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
2
|
export default class EnvUpdate extends EasCommand {
|
|
3
3
|
static description: string;
|
|
4
|
+
static hidden: boolean;
|
|
4
5
|
static flags: {
|
|
5
6
|
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
7
|
environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -17,7 +17,8 @@ const prompts_1 = require("../../prompts");
|
|
|
17
17
|
const prompts_2 = require("../../utils/prompts");
|
|
18
18
|
const variableUtils_1 = require("../../utils/variableUtils");
|
|
19
19
|
class EnvUpdate extends EasCommand_1.default {
|
|
20
|
-
static description = 'update an environment variable on the current project or account';
|
|
20
|
+
static description = 'update an environment variable on the current project or account (deprecated, use eas env:set)';
|
|
21
|
+
static hidden = true;
|
|
21
22
|
static flags = {
|
|
22
23
|
'variable-name': core_1.Flags.string({
|
|
23
24
|
description: 'Current name of the variable',
|
|
@@ -53,6 +54,8 @@ class EnvUpdate extends EasCommand_1.default {
|
|
|
53
54
|
...this.ContextOptions.LoggedIn,
|
|
54
55
|
};
|
|
55
56
|
async runAsync() {
|
|
57
|
+
log_1.default.warn('This command is deprecated. Use eas env:set instead.');
|
|
58
|
+
log_1.default.newLine();
|
|
56
59
|
const { args, flags } = await this.parse(EnvUpdate);
|
|
57
60
|
const { name, value: rawValue, scope, 'variable-name': currentName, 'variable-environment': currentEnvironment, 'non-interactive': nonInteractive, environment: environments, type, visibility, } = this.sanitizeInputs(flags, args);
|
|
58
61
|
const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(EnvUpdate, {
|
|
@@ -52,6 +52,7 @@ class ObserveEvents extends EasCommand_1.default {
|
|
|
52
52
|
};
|
|
53
53
|
async runAsync() {
|
|
54
54
|
const { flags, args } = await this.parse(ObserveEvents);
|
|
55
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
55
56
|
if (args.eventName && flags['all-events']) {
|
|
56
57
|
throw new Error('--all-events cannot be combined with an event name argument. Pass an event name to filter by it, or pass --all-events to list all events across all event names.');
|
|
57
58
|
}
|
|
@@ -60,9 +61,9 @@ class ObserveEvents extends EasCommand_1.default {
|
|
|
60
61
|
commandClass: ObserveEvents,
|
|
61
62
|
loggedInOnlyContextDefinition: ObserveEvents.loggedInOnlyContextDefinition,
|
|
62
63
|
projectIdOverride: flags['project-id'],
|
|
63
|
-
nonInteractive
|
|
64
|
+
nonInteractive,
|
|
64
65
|
});
|
|
65
|
-
if (
|
|
66
|
+
if (json) {
|
|
66
67
|
(0, json_1.enableJsonOutput)();
|
|
67
68
|
}
|
|
68
69
|
const { daysBack, startTime, endTime } = (0, startAndEndTime_1.resolveTimeRange)(flags);
|
|
@@ -74,7 +75,7 @@ class ObserveEvents extends EasCommand_1.default {
|
|
|
74
75
|
endTime,
|
|
75
76
|
platform,
|
|
76
77
|
});
|
|
77
|
-
if (
|
|
78
|
+
if (json) {
|
|
78
79
|
(0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventNamesJson)(names, isTruncated));
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
@@ -106,7 +107,7 @@ class ObserveEvents extends EasCommand_1.default {
|
|
|
106
107
|
endTime,
|
|
107
108
|
platform,
|
|
108
109
|
});
|
|
109
|
-
if (
|
|
110
|
+
if (json) {
|
|
110
111
|
(0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventsEmptyWithSuggestionsJson)(args.eventName, names, isTruncated));
|
|
111
112
|
}
|
|
112
113
|
else {
|
|
@@ -120,7 +121,7 @@ class ObserveEvents extends EasCommand_1.default {
|
|
|
120
121
|
}
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
if (
|
|
124
|
+
if (json) {
|
|
124
125
|
(0, json_1.printJsonOnlyOutput)((0, formatCustomEvents_1.buildObserveCustomEventsJson)(events, pageInfo));
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
@@ -58,14 +58,15 @@ class ObserveMetricsSummary extends EasCommand_1.default {
|
|
|
58
58
|
};
|
|
59
59
|
async runAsync() {
|
|
60
60
|
const { flags } = await this.parse(ObserveMetricsSummary);
|
|
61
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
61
62
|
const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
|
|
62
63
|
command: this,
|
|
63
64
|
commandClass: ObserveMetricsSummary,
|
|
64
65
|
loggedInOnlyContextDefinition: ObserveMetricsSummary.loggedInOnlyContextDefinition,
|
|
65
66
|
projectIdOverride: flags['project-id'],
|
|
66
|
-
nonInteractive
|
|
67
|
+
nonInteractive,
|
|
67
68
|
});
|
|
68
|
-
if (
|
|
69
|
+
if (json) {
|
|
69
70
|
(0, json_1.enableJsonOutput)();
|
|
70
71
|
}
|
|
71
72
|
const metricNames = flags.metric?.length
|
|
@@ -77,7 +78,7 @@ class ObserveMetricsSummary extends EasCommand_1.default {
|
|
|
77
78
|
const argumentsStat = flags.stat?.length
|
|
78
79
|
? Array.from(new Set(flags.stat.map(formatMetrics_1.resolveStatKey)))
|
|
79
80
|
: undefined;
|
|
80
|
-
if (
|
|
81
|
+
if (json) {
|
|
81
82
|
const stats = argumentsStat ?? DEFAULT_STATS_JSON;
|
|
82
83
|
(0, json_1.printJsonOnlyOutput)((0, formatMetrics_1.buildObserveMetricsJson)(metricsMap, metricNames, stats, totalEventCounts, buildNumbersMap, updateIdsMap));
|
|
83
84
|
}
|
|
@@ -54,21 +54,22 @@ class ObserveMetrics extends EasCommand_1.default {
|
|
|
54
54
|
};
|
|
55
55
|
async runAsync() {
|
|
56
56
|
const { flags, args } = await this.parse(ObserveMetrics);
|
|
57
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
57
58
|
const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
|
|
58
59
|
command: this,
|
|
59
60
|
commandClass: ObserveMetrics,
|
|
60
61
|
loggedInOnlyContextDefinition: ObserveMetrics.loggedInOnlyContextDefinition,
|
|
61
62
|
projectIdOverride: flags['project-id'],
|
|
62
|
-
nonInteractive
|
|
63
|
+
nonInteractive,
|
|
63
64
|
});
|
|
64
|
-
if (
|
|
65
|
+
if (json) {
|
|
65
66
|
(0, json_1.enableJsonOutput)();
|
|
66
67
|
}
|
|
67
68
|
let metricName;
|
|
68
69
|
if (args.metric) {
|
|
69
70
|
metricName = (0, metricNames_1.resolveMetricName)(args.metric);
|
|
70
71
|
}
|
|
71
|
-
else if (
|
|
72
|
+
else if (nonInteractive) {
|
|
72
73
|
throw new errors_1.EasCommandError('A metric argument is required in non-interactive mode. Available metrics: ' +
|
|
73
74
|
Object.keys(metricNames_1.METRIC_ALIASES).join(', '));
|
|
74
75
|
}
|
|
@@ -97,7 +98,7 @@ class ObserveMetrics extends EasCommand_1.default {
|
|
|
97
98
|
}),
|
|
98
99
|
(0, fetchEvents_1.fetchTotalEventCountAsync)(graphqlClient, projectId, metricName, platforms, startTime, endTime),
|
|
99
100
|
]);
|
|
100
|
-
if (
|
|
101
|
+
if (json) {
|
|
101
102
|
(0, json_1.printJsonOnlyOutput)((0, formatEvents_1.buildObserveEventsJson)(events, pageInfo));
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
@@ -59,14 +59,15 @@ class ObserveRoutes extends EasCommand_1.default {
|
|
|
59
59
|
};
|
|
60
60
|
async runAsync() {
|
|
61
61
|
const { flags } = await this.parse(ObserveRoutes);
|
|
62
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
62
63
|
const { projectId, graphqlClient } = await (0, resolveProjectContext_1.resolveObserveCommandContextAsync)({
|
|
63
64
|
command: this,
|
|
64
65
|
commandClass: ObserveRoutes,
|
|
65
66
|
loggedInOnlyContextDefinition: ObserveRoutes.loggedInOnlyContextDefinition,
|
|
66
67
|
projectIdOverride: flags['project-id'],
|
|
67
|
-
nonInteractive
|
|
68
|
+
nonInteractive,
|
|
68
69
|
});
|
|
69
|
-
if (
|
|
70
|
+
if (json) {
|
|
70
71
|
(0, json_1.enableJsonOutput)();
|
|
71
72
|
}
|
|
72
73
|
const metricNames = flags.metric?.length
|
|
@@ -91,7 +92,7 @@ class ObserveRoutes extends EasCommand_1.default {
|
|
|
91
92
|
buildNumber: flags['build-number'],
|
|
92
93
|
routeNames,
|
|
93
94
|
});
|
|
94
|
-
if (
|
|
95
|
+
if (json) {
|
|
95
96
|
const stats = argumentsStat ?? DEFAULT_STATS_JSON;
|
|
96
97
|
(0, json_1.printJsonOnlyOutput)((0, formatNavigationRoutes_1.buildObserveNavigationRoutesJson)(routes, metricNames, stats, pageInfoByPlatform));
|
|
97
98
|
}
|