From dff6b0f591e0da8f95379fc2db8209c7e2be0644 Mon Sep 17 00:00:00 2001 From: "Micael Levi (@micalevisk)" Date: Fri, 15 Jul 2022 21:53:35 -0400 Subject: [PATCH 1/2] feat(core): display string tokens with double quotes on repl --- integration/repl/e2e/repl.spec.ts | 8 ++++---- packages/core/repl/repl-context.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integration/repl/e2e/repl.spec.ts b/integration/repl/e2e/repl.spec.ts index 03693f29600..b239776ee12 100644 --- a/integration/repl/e2e/repl.spec.ts +++ b/integration/repl/e2e/repl.spec.ts @@ -52,7 +52,7 @@ ${PROMPT}`, ${PROMPT}`); outputText = ''; - server.emit('line', 'get(UsersRepository)'); + server.emit('line', 'get("UsersRepository")'); expect(outputText).to.equal(`UsersRepository {} ${PROMPT}`); @@ -81,7 +81,7 @@ ${PROMPT}`, ${PROMPT}`); outputText = ''; - server.emit('line', '$(UsersRepository)'); + server.emit('line', '$("UsersRepository")'); expect(outputText).to.equal(`UsersRepository {} ${PROMPT}`); @@ -104,7 +104,7 @@ UsersModule: ◻ UsersController - providers: ◻ UsersService - ◻ UsersRepository + ◻ "UsersRepository" ${PROMPT}`, ); @@ -118,7 +118,7 @@ ${PROMPT}`, outputText += text; return true; }); - server.emit('line', 'methods(UsersRepository)'); + server.emit('line', 'methods("UsersRepository")'); expect(outputText).to.equal( ` diff --git a/packages/core/repl/repl-context.ts b/packages/core/repl/repl-context.ts index f8eef91a873..dd30922f0ab 100644 --- a/packages/core/repl/repl-context.ts +++ b/packages/core/repl/repl-context.ts @@ -109,7 +109,7 @@ export class ReplContext { ? typeof token === 'function' ? token.name : token?.toString() - : token; + : `"${token}"`; } private addNativeFunction( From 4261a2007691d0577c1332935aaee3e2cb826606 Mon Sep 17 00:00:00 2001 From: "Micael Levi (@micalevisk)" Date: Sat, 6 Aug 2022 10:48:23 -0400 Subject: [PATCH 2/2] fix(core): allow registering providers with same name --- packages/core/repl/repl-context.ts | 19 +++++++++++-------- .../native-functions/debug-repl-fn.spec.ts | 13 +++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/packages/core/repl/repl-context.ts b/packages/core/repl/repl-context.ts index dd30922f0ab..3801b214e01 100644 --- a/packages/core/repl/repl-context.ts +++ b/packages/core/repl/repl-context.ts @@ -80,21 +80,24 @@ export class ReplContext { const stringifiedToken = this.stringifyToken(token); if ( stringifiedToken === ApplicationConfig.name || - stringifiedToken === moduleRef.metatype.name || - this.globalScope[stringifiedToken] + stringifiedToken === moduleRef.metatype.name ) { return; } - // For in REPL auto-complete functionality - Object.defineProperty(this.globalScope, stringifiedToken, { - value: token, - configurable: false, - enumerable: true, - }); + + if (!this.globalScope[stringifiedToken]) { + // For in REPL auto-complete functionality + Object.defineProperty(this.globalScope, stringifiedToken, { + value: token, + configurable: false, + enumerable: true, + }); + } if (stringifiedToken === ModuleRef.name) { return; } + moduleDebugEntry[stringifiedToken] = token; }); diff --git a/packages/core/test/repl/native-functions/debug-repl-fn.spec.ts b/packages/core/test/repl/native-functions/debug-repl-fn.spec.ts index e7ddc4a04bc..a23090a5bd3 100644 --- a/packages/core/test/repl/native-functions/debug-repl-fn.spec.ts +++ b/packages/core/test/repl/native-functions/debug-repl-fn.spec.ts @@ -24,9 +24,15 @@ describe('DebugReplFn', () => { container.addController(class ControllerA {}, aModuleRef.token); container.addProvider(class ProviderA1 {}, aModuleRef.token); container.addProvider(class ProviderA2 {}, aModuleRef.token); + container.addProvider(class SharedProvider {}, aModuleRef.token); + container.addProvider( + { provide: 'StringToken', useValue: 123 }, + aModuleRef.token, + ); container.addProvider(class ProviderB1 {}, bModuleRef.token); container.addProvider(class ProviderB2 {}, bModuleRef.token); + container.addProvider(class SharedProvider {}, bModuleRef.token); mockApp = { container, @@ -68,10 +74,13 @@ ModuleA: - providers: ◻ ProviderA1 ◻ ProviderA2 + ◻ SharedProvider + ◻ "StringToken" ModuleB: - providers: ◻ ProviderB1 ◻ ProviderB2 + ◻ SharedProvider `); }); @@ -93,6 +102,8 @@ ModuleA: - providers: ◻ ProviderA1 ◻ ProviderA2 + ◻ SharedProvider + ◻ "StringToken" `); }); @@ -114,6 +125,8 @@ ModuleA: - providers: ◻ ProviderA1 ◻ ProviderA2 + ◻ SharedProvider + ◻ "StringToken" `); });