From b81a7c8872308965d5e5b2dd6f4c5750246efbdc Mon Sep 17 00:00:00 2001 From: soridalac Date: Fri, 13 Dec 2024 09:27:10 -0800 Subject: [PATCH] feat: update mso --- src/commands/org/create/sandbox.ts | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/commands/org/create/sandbox.ts b/src/commands/org/create/sandbox.ts index daa6dd29..15647473 100644 --- a/src/commands/org/create/sandbox.ts +++ b/src/commands/org/create/sandbox.ts @@ -6,12 +6,14 @@ */ import { Duration } from '@salesforce/kit'; +import { MultiStageOutput } from '@oclif/multi-stage-output'; import { Flags } from '@salesforce/sf-plugins-core'; -import { Lifecycle, Messages, SandboxEvents, SandboxRequest, SfError } from '@salesforce/core'; +import { Lifecycle, Messages, SandboxEvents, SandboxProcessObject, SandboxRequest, SfError } from '@salesforce/core'; import { Interfaces } from '@oclif/core'; import requestFunctions, { readSandboxDefFile } from '../../../shared/sandboxRequest.js'; import { SandboxCommandBase, SandboxCommandResponse } from '../../../shared/sandboxCommandBase.js'; import { SandboxLicenseType } from '../../../shared/orgTypes.js'; +import sandboxRequest from '../../../shared/sandboxRequest.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-org', 'create.sandbox'); @@ -124,6 +126,7 @@ export default class CreateSandbox extends SandboxCommandBase({ + stages: this.flags.async + ? ['Prepare request', 'Send request', 'Done'] + : ['Prepare request', 'Send request', 'Waiting for org to respond', 'Done'], + title: this.flags.async ? 'Create Sandbox (async)': 'Create Sandbox', + jsonEnabled: false, + postStagesBlock: [ + { + label: 'SandboxId', + get: (data) => data?.id, + type: 'dynamic-key-value', + bold: true + }, + { + label: 'Status', + get: (data) => data?.status, + type: 'dynamic-key-value', + bold: true + }, + ] + }); + + mso.goto('Prepare request', {status: 'Pending'}); + if (!this.flags.async) { - this.spinner.start('Sandbox Create'); + mso.skipTo('Send request'); } this.debug('Calling create with SandboxRequest: %s ', sandboxReq); try { + mso.goto('Send request', {status: 'In Progress'}); const sandboxProcessObject = await this.prodOrg.createSandbox(sandboxReq, { wait: this.flags.wait, interval: this.flags['poll-interval'], async: this.flags.async, }); + console.log('Sandbox Process Object', sandboxProcessObject); + + mso.updateData({status: sandboxProcessObject.Status, id: sandboxProcessObject.Id}); + + if (sandboxProcessObject.Status === 'In Progress') { + mso.goto('Waiting for org to respond', { status: 'In Progress', id: sandboxProcessObject.Id}); + } + this.latestSandboxProgressObj = sandboxProcessObject; this.saveSandboxProgressConfig(); + + mso.goto('Done', {status: sandboxProcessObject.Status, id: sandboxProcessObject.Id}); if (this.flags.async) { + mso.goto('Waiting for org to respond', { status: 'Pending', id: sandboxProcessObject.Id}); + + mso.skipTo('Done', {status: sandboxProcessObject.Status, id: sandboxProcessObject.Id}); + mso.stop(); process.exitCode = 68; } return this.getSandboxCommandResponse(); } catch (err) { - this.spinner.stop(); + mso.error() + mso.stop(); if (this.pollingTimeOut && this.latestSandboxProgressObj) { void lifecycle.emit(SandboxEvents.EVENT_ASYNC_RESULT, undefined); process.exitCode = 68;