From 20e76e2c49d57acc2bd3803c8d86be01ca5eb793 Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Thu, 19 Dec 2024 21:46:09 -0500 Subject: [PATCH 1/2] Introduce Pure IDE terminal debug command --- .../src/__lib__/LegendPureIDECommand.ts | 1 + .../src/stores/LegendPureIDETerminal.ts | 17 +++++++++++++++++ .../src/stores/PureIDEStore.ts | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts b/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts index af1b05dda9..5ba26b22fc 100644 --- a/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts +++ b/packages/legend-application-pure-ide/src/__lib__/LegendPureIDECommand.ts @@ -162,4 +162,5 @@ export enum LEGEND_PURE_IDE_TERMINAL_COMMAND { CLEAR = 'clear', ANSI = 'ansi', HELP = 'help', + DEBUG = 'debug', } diff --git a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts index 264a88cf6d..bc83ea51ff 100644 --- a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts +++ b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts @@ -343,6 +343,23 @@ export const setupTerminal = (ideStore: PureIDEStore): void => { return Promise.resolve(); }, }, + { + command: LEGEND_PURE_IDE_TERMINAL_COMMAND.DEBUG, + description: + 'Introsptect debug state. When passing no parameters, will show display summary of available variables', + usage: 'debug [abort | var varName | eval expression]', + aliases: [], + handler: async (args: string[]): Promise => { + const option = getNullableFirstEntry(args); + let command = { command: 'summary', args: [] as string[] }; + if (option) { + command = { command: option, args: args.slice(1) }; + } + flowResult(ideStore.debugState(command)).catch( + ideStore.applicationStore.alertUnhandledError, + ); + }, + }, { command: LEGEND_PURE_IDE_TERMINAL_COMMAND.HELP, description: 'Show help', diff --git a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts index 484705f6db..71bb941963 100644 --- a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts +++ b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts @@ -196,6 +196,7 @@ export class PureIDEStore implements CommandRegistrar { loadFile: flow, execute: flow, executeGo: flow, + debugState: flow, manageExecuteGoResult: flow, executeTests: flow, executeFullTestSuite: flow, @@ -880,6 +881,24 @@ export class PureIDEStore implements CommandRegistrar { ); } + *debugState(command: { command: string; args: any[] }): GeneratorFn { + yield flowResult( + this.client + .execute([], 'debugging', command) + .then((r) => { + const execResult = deserializeExecutionResult( + guaranteeNonNullable(r), + ); + this.applicationStore.terminalService.terminal.output( + execResult.text!, + ); + }) + .catch((er) => { + this.applicationStore.terminalService.terminal.fail(er.message); + }), + ); + } + *manageExecuteGoResult( result: ExecutionResult, potentiallyAffectedFiles: string[], From a540cf618f2857449ed04cad731c9c1c198d7215 Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Sat, 21 Dec 2024 15:22:23 -0500 Subject: [PATCH 2/2] Fix cicd problems --- .changeset/hip-books-eat.md | 5 +++++ .../src/stores/LegendPureIDETerminal.ts | 9 ++------- .../src/stores/PureIDEStore.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 .changeset/hip-books-eat.md diff --git a/.changeset/hip-books-eat.md b/.changeset/hip-books-eat.md new file mode 100644 index 0000000000..2a3a4b1e9d --- /dev/null +++ b/.changeset/hip-books-eat.md @@ -0,0 +1,5 @@ +--- +'@finos/legend-application-pure-ide': patch +--- + +Introduce Pure IDE terminal debug command diff --git a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts index bc83ea51ff..c2e35abbf5 100644 --- a/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts +++ b/packages/legend-application-pure-ide/src/stores/LegendPureIDETerminal.ts @@ -347,15 +347,10 @@ export const setupTerminal = (ideStore: PureIDEStore): void => { command: LEGEND_PURE_IDE_TERMINAL_COMMAND.DEBUG, description: 'Introsptect debug state. When passing no parameters, will show display summary of available variables', - usage: 'debug [abort | var varName | eval expression]', + usage: 'debug [summary | abort | _expression_to_eval_]', aliases: [], handler: async (args: string[]): Promise => { - const option = getNullableFirstEntry(args); - let command = { command: 'summary', args: [] as string[] }; - if (option) { - command = { command: option, args: args.slice(1) }; - } - flowResult(ideStore.debugState(command)).catch( + flowResult(ideStore.debugging({ args })).catch( ideStore.applicationStore.alertUnhandledError, ); }, diff --git a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts index 71bb941963..64b2552278 100644 --- a/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts +++ b/packages/legend-application-pure-ide/src/stores/PureIDEStore.ts @@ -196,7 +196,7 @@ export class PureIDEStore implements CommandRegistrar { loadFile: flow, execute: flow, executeGo: flow, - debugState: flow, + debugging: flow, manageExecuteGoResult: flow, executeTests: flow, executeFullTestSuite: flow, @@ -881,7 +881,7 @@ export class PureIDEStore implements CommandRegistrar { ); } - *debugState(command: { command: string; args: any[] }): GeneratorFn { + *debugging(command: { args: string[] }): GeneratorFn { yield flowResult( this.client .execute([], 'debugging', command)