-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdelete.ts
More file actions
70 lines (59 loc) · 1.88 KB
/
delete.ts
File metadata and controls
70 lines (59 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {Args} from '@oclif/core';
import {MrtCommand} from '@salesforce/b2c-tooling/cli';
import {deleteEnvVar} from '@salesforce/b2c-tooling/operations/mrt';
import {t} from '../../../../i18n/index.js';
/**
* Delete an environment variable from an MRT project environment.
*/
export default class MrtEnvVarDelete extends MrtCommand<typeof MrtEnvVarDelete> {
static args = {
key: Args.string({
description: 'Environment variable name',
required: true,
}),
};
static description = t(
'commands.mrt.env.var.delete.description',
'Delete an environment variable from a Managed Runtime environment',
);
static enableJsonFlag = true;
static examples = [
'<%= config.bin %> <%= command.id %> MY_VAR --project acme-storefront --environment production',
'<%= config.bin %> <%= command.id %> OLD_API_KEY -p my-project -e staging',
];
static flags = {
...MrtCommand.baseFlags,
};
async run(): Promise<{key: string; project: string; environment: string}> {
this.requireMrtCredentials();
const {key} = this.args;
const {mrtProject: project, mrtEnvironment: environment} = this.resolvedConfig;
if (!project) {
this.error(
'MRT project is required. Provide --project flag, set SFCC_MRT_PROJECT, or set mrtProject in dw.json.',
);
}
if (!environment) {
this.error(
'MRT environment is required. Provide --environment flag, set SFCC_MRT_ENVIRONMENT, or set mrtEnvironment in dw.json.',
);
}
await deleteEnvVar(
{
projectSlug: project,
environment,
key,
origin: this.resolvedConfig.mrtOrigin,
},
this.getMrtAuth(),
);
this.log(
t('commands.mrt.env.var.delete.success', 'Deleted {{key}} from {{project}}/{{environment}}', {
key,
project,
environment,
}),
);
return {key, project, environment};
}
}