From 00ccdc6755d0963d7a91912a5407b70885f3cabf Mon Sep 17 00:00:00 2001 From: pedro823 Date: Tue, 20 Jun 2023 12:42:59 -0300 Subject: [PATCH 1/4] Make chrome debugger be opt-in instead of default --- src/commands/link.ts | 11 +++++++---- src/modules/apps/link.ts | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/link.ts b/src/commands/link.ts index 89a22cee4..c69dbe93d 100644 --- a/src/commands/link.ts +++ b/src/commands/link.ts @@ -39,6 +39,11 @@ export default class Link extends CustomCommand { description: 'Allows linking the app despite Typescript errors.', default: false, }), + 'with-debugger': oclifFlags.boolean({ + char: 'd', + description: 'Start the chrome debugger tunnel after the app is linked.', + default: false, + }), workspace: oclifFlags.string({ char: 'w', description: `Starts a development session in the specified ${ColorifyConstants.ID( @@ -54,10 +59,8 @@ export default class Link extends CustomCommand { async run() { const { - flags, - flags: { account, setup, clean, unsafe, workspace }, + flags: { account, setup, clean, unsafe, workspace, 'no-watch': noWatch, 'with-debugger': withDebugger }, } = this.parse(Link) - const noWatch = flags['no-watch'] - await appLink({ account, workspace, setup, clean, unsafe, noWatch }) + await appLink({ account, workspace, setup, clean, unsafe, noWatch, withDebugger }) } } diff --git a/src/modules/apps/link.ts b/src/modules/apps/link.ts index d37978007..dfc03021a 100644 --- a/src/modules/apps/link.ts +++ b/src/modules/apps/link.ts @@ -54,6 +54,7 @@ interface LinkOptions { clean?: boolean setup?: boolean noWatch?: boolean + withDebugger?: boolean } const DELETE_SIGN = chalk.red('D') @@ -319,6 +320,10 @@ export async function appLink(options: LinkOptions) { if (debuggerStarted) { return } + if (!options.withDebugger) { + log.info('Debugger flag not set. To open a chrome debugger server, link your app using the --with-debugger flag.') + return + } const startDebugger = async () => { const port = await startDebuggerTunnel(manifest) if (!port) { From c2627a8bfdf66b39a6f04867701a0756926cd6b1 Mon Sep 17 00:00:00 2001 From: pedro823 Date: Tue, 20 Jun 2023 12:58:16 -0300 Subject: [PATCH 2/4] Add change on changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4172bda3..c9140a166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Update `recommendedEdition` in `edition.ts to `edition-store@5.x` + - Make Chrome debugger an opt-in instead of a default open port. ## [3.0.0] - 2021-10-20 From 4e4699b714c8fd8c95145a5758d3d59e41bf6315 Mon Sep 17 00:00:00 2001 From: pedro823 Date: Tue, 20 Jun 2023 13:07:02 -0300 Subject: [PATCH 3/4] Fix linter warning --- src/api/modules/workspace/common/edition.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/modules/workspace/common/edition.ts b/src/api/modules/workspace/common/edition.ts index 477f1809d..41ca55a0f 100644 --- a/src/api/modules/workspace/common/edition.ts +++ b/src/api/modules/workspace/common/edition.ts @@ -33,7 +33,11 @@ const promptSwitchEdition = (currEditionId: string) => { recommendedEdition )}.` ) - log.warn(`For more information about editions, check ${chalk.blue('https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-edition-app')}`) + log.warn( + `For more information about editions, check ${chalk.blue( + 'https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-edition-app' + )}` + ) return promptConfirm(`Would you like to change the edition to ${chalk.blue(recommendedEdition)} now?`, false) } From 7f76c0c72c4f8e8fcab51374c13c8d19da20a95a Mon Sep 17 00:00:00 2001 From: pedro823 Date: Wed, 21 Jun 2023 15:39:57 -0300 Subject: [PATCH 4/4] Change domain used from app.io.vtex.com to ws.io.vtex.com for exclusive websocket usage --- src/api/clients/IOClients/infra/Runtime.ts | 2 +- src/modules/apps/debugger.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/clients/IOClients/infra/Runtime.ts b/src/api/clients/IOClients/infra/Runtime.ts index b81d4176e..db2f6f423 100644 --- a/src/api/clients/IOClients/infra/Runtime.ts +++ b/src/api/clients/IOClients/infra/Runtime.ts @@ -24,7 +24,7 @@ export class Runtime { } public async debugDotnetApp(appName: string, appVendor: string, appMajor: string, debugInst: string) { - const host = 'app.io.vtex.com' + const host = 'ws.io.vtex.com' const path = `/${appVendor}.${appName}/v${appMajor}/${this.account}/${this.workspace}/_debug/dotnet` const clusterHeader = cluster() ? { [Headers.VTEX_UPSTREAM_TARGET]: cluster() } : null diff --git a/src/modules/apps/debugger.ts b/src/modules/apps/debugger.ts index de5efbfe9..43a1081e0 100644 --- a/src/modules/apps/debugger.ts +++ b/src/modules/apps/debugger.ts @@ -108,7 +108,7 @@ export default function startDebuggerTunnel( const { account, workspace } = SessionManager.getSingleton() const appMajor = versionMajor(version) - const host = 'app.io.vtex.com' + const host = 'ws.io.vtex.com' const path = `/${vendor}.${name}/v${appMajor}/${account}/${workspace}/_debug/attach` return new Promise((resolve, reject) => {