eas-cli 10.2.3 → 10.2.4
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 +60 -60
- package/build/build/local.js +1 -1
- package/build/commandUtils/flags.d.ts +13 -0
- package/build/commandUtils/flags.js +47 -1
- package/build/commands/env/create.d.ts +23 -0
- package/build/commands/env/create.js +164 -0
- package/build/commands/env/delete.d.ts +18 -0
- package/build/commands/env/delete.js +92 -0
- package/build/commands/env/get.d.ts +19 -0
- package/build/commands/env/get.js +92 -0
- package/build/commands/env/link.d.ts +15 -0
- package/build/commands/env/link.js +57 -0
- package/build/commands/env/list.d.ts +16 -0
- package/build/commands/env/list.js +55 -0
- package/build/commands/env/unlink.d.ts +15 -0
- package/build/commands/env/unlink.js +62 -0
- package/build/commands/env/update.d.ts +21 -0
- package/build/commands/env/update.js +130 -0
- package/build/graphql/generated.d.ts +555 -52
- package/build/graphql/generated.js +42 -2
- package/build/graphql/mutations/EnvironmentVariableMutation.d.ts +38 -0
- package/build/graphql/mutations/EnvironmentVariableMutation.js +113 -0
- package/build/graphql/queries/EnvironmentVariablesQuery.d.ts +13 -0
- package/build/graphql/queries/EnvironmentVariablesQuery.js +83 -0
- package/build/graphql/types/EnvironmentVariable.d.ts +1 -0
- package/build/graphql/types/EnvironmentVariable.js +16 -0
- package/build/utils/formatVariable.d.ts +2 -0
- package/build/utils/formatVariable.js +16 -0
- package/build/utils/prompts.d.ts +9 -0
- package/build/utils/prompts.js +68 -0
- package/oclif.manifest.json +410 -1
- package/package.json +4 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@oclif/core");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
8
|
+
const flags_1 = require("../../commandUtils/flags");
|
|
9
|
+
const generated_1 = require("../../graphql/generated");
|
|
10
|
+
const EnvironmentVariableMutation_1 = require("../../graphql/mutations/EnvironmentVariableMutation");
|
|
11
|
+
const EnvironmentVariablesQuery_1 = require("../../graphql/queries/EnvironmentVariablesQuery");
|
|
12
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
13
|
+
const projectUtils_1 = require("../../project/projectUtils");
|
|
14
|
+
const prompts_1 = require("../../prompts");
|
|
15
|
+
const prompts_2 = require("../../utils/prompts");
|
|
16
|
+
class EnvironmentVariableUpdate extends EasCommand_1.default {
|
|
17
|
+
async runAsync() {
|
|
18
|
+
const { flags } = await this.parse(_a);
|
|
19
|
+
let { name, value, scope, 'non-interactive': nonInteractive, environment, visibility, } = this.validateFlags(flags);
|
|
20
|
+
const { privateProjectConfig: { projectId }, loggedIn: { graphqlClient }, } = await this.getContextAsync(_a, {
|
|
21
|
+
nonInteractive,
|
|
22
|
+
});
|
|
23
|
+
const [projectDisplayName, ownerAccount] = await Promise.all([
|
|
24
|
+
(0, projectUtils_1.getDisplayNameForProjectIdAsync)(graphqlClient, projectId),
|
|
25
|
+
(0, projectUtils_1.getOwnerAccountForProjectIdAsync)(graphqlClient, projectId),
|
|
26
|
+
]);
|
|
27
|
+
if (scope === generated_1.EnvironmentVariableScope.Project) {
|
|
28
|
+
if (!environment) {
|
|
29
|
+
environment = await (0, prompts_2.promptVariableEnvironmentAsync)(nonInteractive);
|
|
30
|
+
}
|
|
31
|
+
const existingVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdAsync(graphqlClient, projectId, environment);
|
|
32
|
+
if (!name) {
|
|
33
|
+
name = await (0, prompts_1.selectAsync)('Select variable', existingVariables.map(variable => ({
|
|
34
|
+
title: variable.name,
|
|
35
|
+
value: variable.name,
|
|
36
|
+
})));
|
|
37
|
+
}
|
|
38
|
+
const existingVariable = existingVariables.find(variable => variable.name === name);
|
|
39
|
+
if (!existingVariable) {
|
|
40
|
+
throw new Error(`Variable with name ${name} does not exist on project ${projectDisplayName}`);
|
|
41
|
+
}
|
|
42
|
+
if (!value) {
|
|
43
|
+
value = await (0, prompts_2.promptVariableValueAsync)({
|
|
44
|
+
nonInteractive,
|
|
45
|
+
required: false,
|
|
46
|
+
initial: existingVariable.value,
|
|
47
|
+
});
|
|
48
|
+
if (!value || value.length === 0) {
|
|
49
|
+
value = '';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createForAppAsync(graphqlClient, {
|
|
53
|
+
name,
|
|
54
|
+
value,
|
|
55
|
+
environment,
|
|
56
|
+
visibility,
|
|
57
|
+
overwrite: true,
|
|
58
|
+
}, projectId);
|
|
59
|
+
if (!variable) {
|
|
60
|
+
throw new Error(`Could not update variable with name ${name} on project ${projectDisplayName}`);
|
|
61
|
+
}
|
|
62
|
+
log_1.default.withTick(`Updated variable ${chalk_1.default.bold(name)} on project ${chalk_1.default.bold(projectDisplayName)}.`);
|
|
63
|
+
}
|
|
64
|
+
else if (scope === generated_1.EnvironmentVariableScope.Shared) {
|
|
65
|
+
const sharedVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.sharedAsync(graphqlClient, projectId);
|
|
66
|
+
if (!name) {
|
|
67
|
+
name = await (0, prompts_1.selectAsync)('Select variable', sharedVariables.map(variable => ({
|
|
68
|
+
title: variable.name,
|
|
69
|
+
value: variable.name,
|
|
70
|
+
})));
|
|
71
|
+
}
|
|
72
|
+
const existingVariable = sharedVariables.find(variable => variable.name === name);
|
|
73
|
+
if (!existingVariable) {
|
|
74
|
+
throw new Error("Variable with this name doesn't exist on this account. Use a different name.");
|
|
75
|
+
}
|
|
76
|
+
if (!value) {
|
|
77
|
+
value = await (0, prompts_2.promptVariableValueAsync)({
|
|
78
|
+
nonInteractive,
|
|
79
|
+
required: false,
|
|
80
|
+
initial: existingVariable.value,
|
|
81
|
+
});
|
|
82
|
+
if (!value || value.length === 0) {
|
|
83
|
+
value = '';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const variable = await EnvironmentVariableMutation_1.EnvironmentVariableMutation.createSharedVariableAsync(graphqlClient, {
|
|
87
|
+
name,
|
|
88
|
+
value,
|
|
89
|
+
visibility,
|
|
90
|
+
overwrite: true,
|
|
91
|
+
}, ownerAccount.id);
|
|
92
|
+
if (!variable) {
|
|
93
|
+
throw new Error(`Could not update variable with name ${name} on account ${ownerAccount.name}`);
|
|
94
|
+
}
|
|
95
|
+
log_1.default.withTick(`Updated shared variable ${chalk_1.default.bold(name)} on account ${chalk_1.default.bold(ownerAccount.name)}.`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
validateFlags(flags) {
|
|
99
|
+
if (flags['non-interactive']) {
|
|
100
|
+
if (!flags.name) {
|
|
101
|
+
throw new Error('Variable name is required in non-interactive mode. Run the command with --name flag.');
|
|
102
|
+
}
|
|
103
|
+
if (flags.scope === generated_1.EnvironmentVariableScope.Project && !flags.environment) {
|
|
104
|
+
throw new Error('Environment is required when updating project-wide variable in non-interactive mode. Run the command with --environment flag.');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return flags;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
_a = EnvironmentVariableUpdate;
|
|
111
|
+
EnvironmentVariableUpdate.description = 'update an environment variable on the current project or owner account';
|
|
112
|
+
EnvironmentVariableUpdate.hidden = true;
|
|
113
|
+
EnvironmentVariableUpdate.flags = {
|
|
114
|
+
name: core_1.Flags.string({
|
|
115
|
+
description: 'Name of the variable',
|
|
116
|
+
}),
|
|
117
|
+
value: core_1.Flags.string({
|
|
118
|
+
description: 'Text value or the variable',
|
|
119
|
+
}),
|
|
120
|
+
...flags_1.EASVariableVisibilityFlag,
|
|
121
|
+
...flags_1.EASVariableScopeFlag,
|
|
122
|
+
...flags_1.EASEnvironmentFlag,
|
|
123
|
+
...flags_1.EASNonInteractiveFlag,
|
|
124
|
+
};
|
|
125
|
+
EnvironmentVariableUpdate.contextDefinition = {
|
|
126
|
+
..._a.ContextOptions.ProjectConfig,
|
|
127
|
+
..._a.ContextOptions.Analytics,
|
|
128
|
+
..._a.ContextOptions.LoggedIn,
|
|
129
|
+
};
|
|
130
|
+
exports.default = EnvironmentVariableUpdate;
|