From 9836b9a12d78f86723a6948d0195809a64131bcf Mon Sep 17 00:00:00 2001 From: Ar-mane Date: Sun, 12 May 2024 01:27:33 +0100 Subject: [PATCH] fix: update destination path --- package.json | 2 +- src/domain/MainExtension.ts | 19 +++++++++---------- src/domain/TemplateManager.ts | 13 +++++++------ src/extension.ts | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 2bf3edf..b98780e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "2.0.41", + "version": "2.0.42", "name": "component-maker", "displayName": "Component Maker", "publisher": "Ar-mane", diff --git a/src/domain/MainExtension.ts b/src/domain/MainExtension.ts index 2e97f66..3a1f7c2 100644 --- a/src/domain/MainExtension.ts +++ b/src/domain/MainExtension.ts @@ -2,34 +2,33 @@ import { ConfigLoader } from '@/domain/ConfigLoader'; import { TemplateManager } from '@/domain/TemplateManager'; import { Files } from '@/utility/Files'; import { getComponentDestincation } from '@/utility/fileUtility'; -import { ExtensionContext, Uri } from 'vscode'; +import { Uri } from 'vscode'; export class MainExtension { - private context: ExtensionContext; private uri: Uri; - private constructor(context: ExtensionContext, uri: Uri) { - this.context = context; + private constructor(uri: Uri) { + this.uri = uri; } - private setContext(context: ExtensionContext) { - this.context = context; + private setUri(uri: Uri) { + this.uri = uri; } async run() { const configLoader = ConfigLoader.instance(); const dest = Files.toRelative(getComponentDestincation(this.uri)); - await TemplateManager.instance(configLoader, dest).run(); + await TemplateManager.instance(configLoader).run(dest); } // ______ singleton _______ private static instance: MainExtension | null = null; - public static from(context: ExtensionContext, uri: Uri): MainExtension { + public static from(uri: Uri): MainExtension { if (this.instance === null) { - this.instance = new MainExtension(context, uri); + this.instance = new MainExtension(uri); } - this.instance.setContext(context); + this.instance.setUri(uri); return this.instance; } // ____ END singleton _____ diff --git a/src/domain/TemplateManager.ts b/src/domain/TemplateManager.ts index 4a5d47f..e58e885 100644 --- a/src/domain/TemplateManager.ts +++ b/src/domain/TemplateManager.ts @@ -13,14 +13,15 @@ import { export class TemplateManager { private configLoader: ConfigLoader; private config!: Config; - private destination: string; + private destination!: string; - private constructor(configLoader: ConfigLoader, destination: RelativePath) { + private constructor(configLoader: ConfigLoader) { this.configLoader = configLoader; - this.destination = destination; } - async run() { + + async run(destination: RelativePath) { + this.destination = destination; this.config = await this.configLoader.getConfig(); const template = await DialogManager.promptTemplateSelection(this.config); const componentName = await DialogManager.promptComponentName(); @@ -76,9 +77,9 @@ export class TemplateManager { // ______ singleton _______ private static _instance: TemplateManager | null = null; - public static instance(configLoader: ConfigLoader, destination: RelativePath): TemplateManager { + public static instance(configLoader: ConfigLoader): TemplateManager { if (this._instance === null) { - this._instance = new TemplateManager(configLoader, destination); + this._instance = new TemplateManager(configLoader); } return this._instance; } diff --git a/src/extension.ts b/src/extension.ts index 14a0106..c062ca4 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -15,7 +15,7 @@ export function activate(context: ExtensionContext) { throw new TerminationError(TerminateReason.NoUriProvided); } - await MainExtension.from(context, uri).run(); + await MainExtension.from(uri).run(); DialogManager.displaySuccessNotification(); } catch (error) { if (error instanceof TerminationError) { @@ -28,4 +28,4 @@ export function activate(context: ExtensionContext) { context.subscriptions.push(command); } -export function deactivate() {} +export function deactivate() { }