@sanity/runtime-cli 5.0.4 → 5.2.0
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 +23 -49
- package/dist/actions/blueprints/blueprint.d.ts +9 -5
- package/dist/actions/blueprints/index.d.ts +1 -1
- package/dist/actions/blueprints/index.js +1 -1
- package/dist/actions/functions/index.d.ts +0 -1
- package/dist/actions/functions/index.js +0 -1
- package/dist/baseCommands.d.ts +10 -0
- package/dist/baseCommands.js +23 -11
- package/dist/commands/blueprints/add.d.ts +0 -8
- package/dist/commands/blueprints/add.js +12 -93
- package/dist/commands/blueprints/config.d.ts +2 -24
- package/dist/commands/blueprints/config.js +12 -179
- package/dist/commands/blueprints/deploy.js +12 -69
- package/dist/commands/blueprints/destroy.d.ts +5 -4
- package/dist/commands/blueprints/destroy.js +21 -61
- package/dist/commands/blueprints/info.js +11 -19
- package/dist/commands/blueprints/init.d.ts +0 -16
- package/dist/commands/blueprints/init.js +10 -167
- package/dist/commands/blueprints/logs.js +14 -67
- package/dist/commands/blueprints/plan.js +8 -13
- package/dist/commands/blueprints/stacks.js +10 -19
- package/dist/cores/blueprints/add.d.ts +13 -0
- package/dist/cores/blueprints/add.js +107 -0
- package/dist/cores/blueprints/config.d.ts +13 -0
- package/dist/cores/blueprints/config.js +222 -0
- package/dist/cores/blueprints/deploy.d.ts +14 -0
- package/dist/cores/blueprints/deploy.js +81 -0
- package/dist/cores/blueprints/destroy.d.ts +13 -0
- package/dist/cores/blueprints/destroy.js +106 -0
- package/dist/cores/blueprints/index.d.ts +18 -0
- package/dist/cores/blueprints/index.js +9 -0
- package/dist/cores/blueprints/info.d.ts +11 -0
- package/dist/cores/blueprints/info.js +33 -0
- package/dist/cores/blueprints/init.d.ts +15 -0
- package/dist/cores/blueprints/init.js +190 -0
- package/dist/cores/blueprints/logs.d.ts +11 -0
- package/dist/cores/blueprints/logs.js +74 -0
- package/dist/cores/blueprints/plan.d.ts +6 -0
- package/dist/cores/blueprints/plan.js +11 -0
- package/dist/cores/blueprints/stacks.d.ts +10 -0
- package/dist/cores/blueprints/stacks.js +30 -0
- package/dist/cores/index.d.ts +20 -0
- package/dist/cores/index.js +1 -0
- package/dist/utils/display/blueprints-formatting.js +12 -11
- package/dist/utils/display/colors.d.ts +3 -1
- package/dist/utils/display/colors.js +8 -2
- package/oclif.manifest.json +29 -64
- package/package.json +5 -1
- package/dist/actions/functions/invoke.d.ts +0 -6
- package/dist/actions/functions/invoke.js +0 -18
- package/dist/commands/functions/invoke.d.ts +0 -13
- package/dist/commands/functions/invoke.js +0 -42
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import Spinner from 'yocto-spinner';
|
|
6
|
-
import { readLocalBlueprint, writeConfigFile } from '../../actions/blueprints/blueprint.js';
|
|
7
|
-
import { getProject, listProjects } from '../../actions/blueprints/projects.js';
|
|
8
|
-
import { createStack, getStack, listStacks } from '../../actions/blueprints/stacks.js';
|
|
9
|
-
import { bold, dim, niceId } from '../../utils/display/colors.js';
|
|
10
|
-
import { presentBlueprintParserErrors } from '../../utils/display/errors.js';
|
|
11
|
-
import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
|
|
12
|
-
export default class ConfigCommand extends Command {
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BlueprintCommand } from '../../baseCommands.js';
|
|
3
|
+
import { blueprintConfigCore } from '../../cores/blueprints/config.js';
|
|
4
|
+
export default class ConfigCommand extends BlueprintCommand {
|
|
13
5
|
static description = 'View or edit Blueprint configuration';
|
|
14
6
|
static examples = [
|
|
15
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -43,174 +35,15 @@ export default class ConfigCommand extends Command {
|
|
|
43
35
|
hidden: true, // LAUNCH LIMIT: 1 Stack per Project
|
|
44
36
|
}),
|
|
45
37
|
};
|
|
46
|
-
sanityToken;
|
|
47
|
-
projectId;
|
|
48
|
-
stackId;
|
|
49
38
|
async run() {
|
|
50
|
-
const {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
this.error('Blueprint parse errors.');
|
|
57
|
-
}
|
|
58
|
-
if (!configStackId && !configProjectId) {
|
|
59
|
-
this.error('Project configuration is missing! Use `sanity-run blueprints init` to create a configuration.');
|
|
60
|
-
}
|
|
61
|
-
this.log(bold('Current configuration:'));
|
|
62
|
-
this.log(` Sanity Project: ${niceId(configProjectId)}`);
|
|
63
|
-
this.log(` Blueprint deployment: ${niceId(configStackId)}`);
|
|
64
|
-
if ((editProjectId || editStackId) && !editConfig) {
|
|
65
|
-
this.log('To update the configuration, use the --edit flag.');
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (!editConfig && !testConfig)
|
|
69
|
-
return;
|
|
70
|
-
const { token, error: tokenErr } = await validTokenOrErrorMessage();
|
|
71
|
-
if (tokenErr)
|
|
72
|
-
this.error(tokenErr.message);
|
|
73
|
-
this.sanityToken = token;
|
|
74
|
-
if (testConfig && !editConfig) {
|
|
75
|
-
if (configStackId && configProjectId) {
|
|
76
|
-
await this.testConfigAndReport({ stackId: configStackId, projectId: configProjectId });
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.log('Unable to test the configuration. Both Project and Stack IDs must be set.');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (!editConfig)
|
|
83
|
-
return;
|
|
84
|
-
const projectId = editProjectId || (await this.promptForProjectId({ knownProjectId: configProjectId }));
|
|
85
|
-
if (!projectId)
|
|
86
|
-
this.error('Project ID is required.');
|
|
87
|
-
// LAUNCH LIMIT: 1 Stack per Project - do not allow Stack ID to be set
|
|
88
|
-
// const stackId =
|
|
89
|
-
// editStackId || (await this.promptForStackId({projectId, knownStackId: configStackId}))
|
|
90
|
-
let stackId = configStackId;
|
|
91
|
-
if (testConfig) {
|
|
92
|
-
if (projectId && stackId) {
|
|
93
|
-
const { ok: newConfigOk } = await this.testConfigAndReport({
|
|
94
|
-
stackId,
|
|
95
|
-
projectId,
|
|
96
|
-
reinit: editConfig,
|
|
97
|
-
});
|
|
98
|
-
if (!newConfigOk)
|
|
99
|
-
this.error('Updated configuration has not been saved.');
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
this.error('Unable to test the configuration. Both Project and Stack IDs must be set.');
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// LAUNCH LIMIT: 1 Stack per Project - do not allow Stack ID to be set
|
|
106
|
-
if (stackId?.endsWith(projectId))
|
|
107
|
-
stackId = undefined;
|
|
108
|
-
try {
|
|
109
|
-
// update or create .blueprint/config.json
|
|
110
|
-
writeConfigFile({ projectId, stackId });
|
|
111
|
-
this.log('Configuration updated successfully.');
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
this.log('Unable to dynamically update config. Use these values in your blueprint:');
|
|
115
|
-
// LAUNCH LIMIT: 1 Stack per Project - do not allow Stack ID to be set
|
|
116
|
-
this.log(highlight(JSON.stringify({ metadata: { projectId /*, stackId*/ } }, null, 2)));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async promptForProjectId({ knownProjectId }) {
|
|
120
|
-
if (!this.sanityToken)
|
|
121
|
-
this.error('Unable to list projects. Missing API token.');
|
|
122
|
-
const { ok, projects, error } = await listProjects({ token: this.sanityToken });
|
|
123
|
-
if (!ok)
|
|
124
|
-
this.error(error ?? 'Unknown error listing projects');
|
|
125
|
-
if (projects.length === 0) {
|
|
126
|
-
this.error('No Sanity projects found. Use `npx sanity init` to create one.');
|
|
127
|
-
}
|
|
128
|
-
const projectChoices = projects.map(({ displayName, id: projectId }) => ({
|
|
129
|
-
name: `"${displayName}" ${niceId(projectId)}`,
|
|
130
|
-
value: projectId,
|
|
131
|
-
}));
|
|
132
|
-
const { pickedProjectId } = await inquirer.prompt([
|
|
133
|
-
{
|
|
134
|
-
type: 'list',
|
|
135
|
-
name: 'pickedProjectId',
|
|
136
|
-
message: 'Select your Sanity project:',
|
|
137
|
-
choices: projectChoices,
|
|
138
|
-
default: knownProjectId,
|
|
139
|
-
},
|
|
140
|
-
]);
|
|
141
|
-
return pickedProjectId;
|
|
142
|
-
}
|
|
143
|
-
async promptForStackId({ projectId, knownStackId, }) {
|
|
144
|
-
if (!this.sanityToken)
|
|
145
|
-
this.error('Unable to list Stacks. Missing API token.');
|
|
146
|
-
const auth = { token: this.sanityToken, projectId };
|
|
147
|
-
// get stacks for selected project
|
|
148
|
-
const { ok: stacksOk, stacks, error: stacksError } = await listStacks(auth);
|
|
149
|
-
if (!stacksOk)
|
|
150
|
-
this.error(stacksError ?? 'Unknown error listing stacks');
|
|
151
|
-
if (stacks.length > 0) {
|
|
152
|
-
const stackChoices = stacks.map((s) => ({
|
|
153
|
-
name: `"${s.name}" ${niceId(s.id)} ${dim(`(${s.resources.length} res)`)}`,
|
|
154
|
-
value: s.id,
|
|
155
|
-
}));
|
|
156
|
-
stackChoices.push({ name: 'Unset Stack association', value: 'unset' });
|
|
157
|
-
const { pickedStackId } = await inquirer.prompt([
|
|
158
|
-
{
|
|
159
|
-
type: 'list',
|
|
160
|
-
name: 'pickedStackId',
|
|
161
|
-
message: 'Select a stack:',
|
|
162
|
-
choices: stackChoices,
|
|
163
|
-
default: knownStackId,
|
|
164
|
-
},
|
|
165
|
-
]);
|
|
166
|
-
return pickedStackId === 'unset' ? undefined : pickedStackId;
|
|
167
|
-
}
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
170
|
-
async testConfigAndReport({ stackId, projectId, reinit = false, }) {
|
|
171
|
-
if (!this.sanityToken)
|
|
172
|
-
this.error('Unable to test the configuration. Missing API token.');
|
|
173
|
-
const spinner = Spinner({ text: 'Testing the configuration...' }).start();
|
|
174
|
-
const { ok, error } = await getStack({
|
|
175
|
-
stackId,
|
|
176
|
-
auth: { token: this.sanityToken, projectId },
|
|
39
|
+
const { success, error } = await blueprintConfigCore({
|
|
40
|
+
bin: this.config.bin,
|
|
41
|
+
log: (message) => this.log(message),
|
|
42
|
+
blueprint: this.blueprint,
|
|
43
|
+
token: this.sanityToken,
|
|
44
|
+
flags: this.flags,
|
|
177
45
|
});
|
|
178
|
-
if (!
|
|
179
|
-
|
|
180
|
-
// check if configured project and stack can be reinitialized
|
|
181
|
-
if (reinit && stackId === `ST-${projectId}`) {
|
|
182
|
-
await this.startReinitializeStack({ projectId, stackId });
|
|
183
|
-
return { ok: true, error: null };
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
spinner.success('Configuration is valid.');
|
|
188
|
-
}
|
|
189
|
-
return { ok, error };
|
|
190
|
-
}
|
|
191
|
-
async startReinitializeStack({ projectId, stackId }) {
|
|
192
|
-
if (!this.sanityToken)
|
|
193
|
-
this.error('Unable to reinitialize the Stack. Missing API token.');
|
|
194
|
-
const auth = { token: this.sanityToken, projectId };
|
|
195
|
-
// stack id IS ST-${projectId} – it has already been checked and doesn't exist
|
|
196
|
-
this.log(`A new Blueprint deployment can be created with the ${chalk.bold('existing')} configuration.`);
|
|
197
|
-
const { confirm } = await inquirer.prompt([
|
|
198
|
-
{
|
|
199
|
-
type: 'confirm',
|
|
200
|
-
name: 'confirm',
|
|
201
|
-
message: `Do you want to create a ${chalk.blue('new')}, empty Blueprint deployment with the ${chalk.blue('existing')} configuration?`,
|
|
202
|
-
},
|
|
203
|
-
]);
|
|
204
|
-
if (!confirm)
|
|
205
|
-
this.error('Reinitialization cancelled.');
|
|
206
|
-
const { ok: projectOk, project } = await getProject(auth);
|
|
207
|
-
if (!projectOk)
|
|
208
|
-
this.error('Failed to find Project while creating Stack');
|
|
209
|
-
const projectDisplayName = project.displayName;
|
|
210
|
-
const stackPayload = { name: projectDisplayName, projectId, document: { resources: [] } };
|
|
211
|
-
const response = await createStack({ stackPayload, auth });
|
|
212
|
-
if (!response.ok)
|
|
213
|
-
this.error(response.error || 'Failed to create new Stack');
|
|
214
|
-
this.log(`New Blueprint deployment created for "${projectDisplayName}"`);
|
|
46
|
+
if (!success)
|
|
47
|
+
this.error(error);
|
|
215
48
|
}
|
|
216
49
|
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { setTimeout } from 'node:timers/promises';
|
|
2
1
|
import { Flags } from '@oclif/core';
|
|
3
|
-
import Spinner from 'yocto-spinner';
|
|
4
|
-
import { stashAsset } from '../../actions/blueprints/assets.js';
|
|
5
|
-
import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
|
|
6
2
|
import { DeployedBlueprintCommand } from '../../baseCommands.js';
|
|
7
|
-
import {
|
|
8
|
-
import { isLocalFunctionResource } from '../../utils/types.js';
|
|
3
|
+
import { blueprintDeployCore } from '../../cores/blueprints/deploy.js';
|
|
9
4
|
export default class DeployCommand extends DeployedBlueprintCommand {
|
|
10
5
|
static description = 'Deploy a Blueprint';
|
|
11
6
|
static examples = [
|
|
@@ -19,69 +14,17 @@ export default class DeployCommand extends DeployedBlueprintCommand {
|
|
|
19
14
|
}),
|
|
20
15
|
};
|
|
21
16
|
async run() {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (functionResources?.length) {
|
|
28
|
-
for (const resource of functionResources) {
|
|
29
|
-
const fnSpinner = Spinner({ text: `Processing ${resource.name}...` }).start();
|
|
30
|
-
const result = await stashAsset({ resource, auth: this.auth });
|
|
31
|
-
if (result.success && result.assetId) {
|
|
32
|
-
const src = resource.src;
|
|
33
|
-
resource.src = result.assetId; // TODO: properly reference asset - for now, the API expects the assetId
|
|
34
|
-
fnSpinner.success(`${resource.name} ${niceId(result.assetId)}`);
|
|
35
|
-
this.log(` Source: ${src}`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
fnSpinner.error(`Failed to process ${resource.name}`);
|
|
39
|
-
this.log(` Error: ${result.error}`);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const stackPayload = {
|
|
17
|
+
const { success, error } = await blueprintDeployCore({
|
|
18
|
+
bin: this.config.bin,
|
|
19
|
+
log: (message) => this.log(message),
|
|
20
|
+
auth: this.auth,
|
|
21
|
+
stackId: this.stackId,
|
|
45
22
|
projectId: this.projectId,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
spinner.success(`Deployment "${bold(stack.name)}" ${niceId(stack.id)} started!`);
|
|
53
|
-
if (!flags['no-wait']) {
|
|
54
|
-
const waitSpinner = Spinner({ text: 'Waiting for deployment to complete...' }).start();
|
|
55
|
-
while (true) {
|
|
56
|
-
// TODO: watch logs and print those while polling
|
|
57
|
-
const { ok, stack: currentStack } = await getStack({ stackId: stack.id, auth: this.auth });
|
|
58
|
-
if (!ok) {
|
|
59
|
-
waitSpinner.error('Failed to check deployment status');
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
const operation = currentStack.recentOperation;
|
|
63
|
-
if (!operation) {
|
|
64
|
-
waitSpinner.error('No operation found');
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
if (operation.status === 'COMPLETED') {
|
|
68
|
-
waitSpinner.success('Deployment completed successfully');
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
if (operation.status === 'FAILED') {
|
|
72
|
-
waitSpinner.error('Deployment failed');
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
await setTimeout(1000);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.log('Use `sanity-run blueprints info` to check status');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
spinner.error(`${red('Failed')} to update deployment`);
|
|
84
|
-
this.log(`Error: ${deployError || JSON.stringify(stack, null, 2) || 'Unknown error'}`);
|
|
85
|
-
}
|
|
23
|
+
deployedStack: this.deployedStack,
|
|
24
|
+
blueprint: this.blueprint,
|
|
25
|
+
flags: this.flags,
|
|
26
|
+
});
|
|
27
|
+
if (!success)
|
|
28
|
+
this.error(error);
|
|
86
29
|
}
|
|
87
30
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class DestroyCommand extends
|
|
1
|
+
import { BlueprintCommand } from '../../baseCommands.js';
|
|
2
|
+
export default class DestroyCommand extends BlueprintCommand<typeof DestroyCommand> {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
|
-
|
|
8
|
-
id: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'stack-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
10
|
};
|
|
10
11
|
run(): Promise<void>;
|
|
11
12
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { setTimeout } from 'node:timers/promises';
|
|
2
1
|
import { Flags } from '@oclif/core';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { DeployedBlueprintCommand } from '../../baseCommands.js';
|
|
7
|
-
import { bold, niceId } from '../../utils/display/colors.js';
|
|
8
|
-
export default class DestroyCommand extends DeployedBlueprintCommand {
|
|
2
|
+
import { BlueprintCommand } from '../../baseCommands.js';
|
|
3
|
+
import { blueprintDestroyCore } from '../../cores/blueprints/destroy.js';
|
|
4
|
+
export default class DestroyCommand extends BlueprintCommand {
|
|
9
5
|
static description = 'Destroy a Blueprint deployment (will not delete local files)';
|
|
10
6
|
static examples = [
|
|
11
7
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -15,70 +11,34 @@ export default class DestroyCommand extends DeployedBlueprintCommand {
|
|
|
15
11
|
static flags = {
|
|
16
12
|
force: Flags.boolean({
|
|
17
13
|
description: 'Force destroy (skip confirmation)',
|
|
14
|
+
aliases: ['f'],
|
|
18
15
|
default: false,
|
|
19
16
|
}),
|
|
20
|
-
|
|
17
|
+
'project-id': Flags.string({
|
|
21
18
|
description: 'Project associated with the Stack (defaults to current Project)',
|
|
22
|
-
|
|
19
|
+
aliases: ['projectId', 'project'],
|
|
20
|
+
dependsOn: ['stack-id', 'force'],
|
|
23
21
|
hidden: true, // LAUNCH LIMIT: 1 Stack per Project
|
|
24
22
|
}),
|
|
25
|
-
id: Flags.string({
|
|
23
|
+
'stack-id': Flags.string({
|
|
26
24
|
description: 'Stack ID to destroy (defaults to current Stack)',
|
|
27
|
-
|
|
25
|
+
aliases: ['stackId', 'stack'],
|
|
28
26
|
hidden: true, // LAUNCH LIMIT: 1 Stack per Project
|
|
29
27
|
}),
|
|
28
|
+
'no-wait': Flags.boolean({
|
|
29
|
+
description: 'Do not wait for destruction to complete',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
30
32
|
};
|
|
31
33
|
async run() {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.error(error || 'Failed to destroy deployment');
|
|
39
|
-
this.log(`Deployment "${stack.name}" ${niceId(stack.id)} destroyed`);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
let stack = this.deployedStack;
|
|
43
|
-
if (flags.id) {
|
|
44
|
-
const { ok, stack: foundStack, error } = await getStack({ stackId: flags.id, auth: this.auth });
|
|
45
|
-
if (!ok)
|
|
46
|
-
this.error(error || 'Failed to get stack');
|
|
47
|
-
stack = foundStack;
|
|
48
|
-
}
|
|
49
|
-
const destroySpinner = Spinner({
|
|
50
|
-
text: `Destroying ${bold(stack.name)} ${niceId(stack.id)}...`,
|
|
51
|
-
color: 'red',
|
|
34
|
+
const { success, error } = await blueprintDestroyCore({
|
|
35
|
+
bin: this.config.bin,
|
|
36
|
+
log: (message) => this.log(message),
|
|
37
|
+
token: this.sanityToken,
|
|
38
|
+
blueprint: this.blueprint,
|
|
39
|
+
flags: this.flags,
|
|
52
40
|
});
|
|
53
|
-
if (!
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
type: 'confirm',
|
|
57
|
-
name: 'confirm',
|
|
58
|
-
message: `Are you sure you want to destroy stack "${stack.name}" ${niceId(stack.id)}?`,
|
|
59
|
-
default: false,
|
|
60
|
-
},
|
|
61
|
-
]);
|
|
62
|
-
if (!confirm) {
|
|
63
|
-
this.log('Deployment destruction cancelled');
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
destroySpinner.start();
|
|
67
|
-
let i = 5;
|
|
68
|
-
while (i >= 0) {
|
|
69
|
-
destroySpinner.text = `Destroying deployment in ${bold((i--).toString())} seconds...`;
|
|
70
|
-
await setTimeout(1000);
|
|
71
|
-
}
|
|
72
|
-
destroySpinner.text = 'Destroying deployment 💥';
|
|
73
|
-
await setTimeout(500);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
destroySpinner.start();
|
|
77
|
-
}
|
|
78
|
-
const { ok, error } = await destroyStack({ stackId: stack.id, auth: this.auth });
|
|
79
|
-
if (!ok)
|
|
80
|
-
this.error(error || 'Failed to destroy deployment');
|
|
81
|
-
// TODO: update local config
|
|
82
|
-
destroySpinner.success(`Deployment "${stack.name}" ${niceId(stack.id)} destroyed`);
|
|
41
|
+
if (!success)
|
|
42
|
+
this.error(error);
|
|
83
43
|
}
|
|
84
44
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
3
2
|
import { DeployedBlueprintCommand } from '../../baseCommands.js';
|
|
4
|
-
import {
|
|
5
|
-
import { niceId } from '../../utils/display/colors.js';
|
|
3
|
+
import { blueprintInfoCore } from '../../cores/blueprints/info.js';
|
|
6
4
|
export default class InfoCommand extends DeployedBlueprintCommand {
|
|
7
5
|
static description = 'Show information about a Blueprint deployment';
|
|
8
6
|
static examples = [
|
|
@@ -17,21 +15,15 @@ export default class InfoCommand extends DeployedBlueprintCommand {
|
|
|
17
15
|
}),
|
|
18
16
|
};
|
|
19
17
|
async run() {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
this.log(formatStackInfo(stack, true));
|
|
32
|
-
if (stack.resources) {
|
|
33
|
-
this.log('');
|
|
34
|
-
this.log(formatResourceTree(stack.resources));
|
|
35
|
-
}
|
|
18
|
+
const { success, error } = await blueprintInfoCore({
|
|
19
|
+
bin: this.config.bin,
|
|
20
|
+
log: (message) => this.log(message),
|
|
21
|
+
auth: this.auth,
|
|
22
|
+
stackId: this.stackId,
|
|
23
|
+
deployedStack: this.deployedStack,
|
|
24
|
+
flags: this.flags,
|
|
25
|
+
});
|
|
26
|
+
if (!success)
|
|
27
|
+
this.error(error);
|
|
36
28
|
}
|
|
37
29
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import type { AuthParams, Stack } from '../../utils/types.js';
|
|
3
2
|
export default class InitCommand extends Command {
|
|
4
3
|
static description: string;
|
|
5
4
|
static examples: string[];
|
|
@@ -13,20 +12,5 @@ export default class InitCommand extends Command {
|
|
|
13
12
|
'stack-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
13
|
'stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
14
|
};
|
|
16
|
-
sanityToken: string | undefined;
|
|
17
15
|
run(): Promise<void>;
|
|
18
|
-
promptForBlueprintType(): Promise<string>;
|
|
19
|
-
promptForProject(): Promise<{
|
|
20
|
-
projectId: string;
|
|
21
|
-
displayName: string;
|
|
22
|
-
}>;
|
|
23
|
-
promptForStackId({ projectId }: {
|
|
24
|
-
projectId: string;
|
|
25
|
-
}): Promise<string>;
|
|
26
|
-
createEmptyStack({ projectId, name, projectBased, }: {
|
|
27
|
-
projectId: string;
|
|
28
|
-
name: string;
|
|
29
|
-
projectBased?: boolean;
|
|
30
|
-
}): Promise<Stack>;
|
|
31
|
-
createProjectBasedStack(auth: AuthParams): Promise<Stack>;
|
|
32
16
|
}
|