11import { join } from 'node:path' ;
2- import { WorkspaceConfig } from '../../config.js' ;
2+ import { Config } from '../../config.js' ;
33import { copyDirectory , gitUpdate , logger } from '../../utils/index.js' ;
44import {
55 DIR_CONFIG ,
@@ -19,11 +19,11 @@ enum Location {
1919}
2020
2121export class TemplatesAccess {
22- static create ( config : WorkspaceConfig ) : TemplatesAccess {
22+ static create ( config : Config ) : TemplatesAccess {
2323 return new TemplatesAccess ( config ) ;
2424 }
2525
26- constructor ( private readonly config : WorkspaceConfig ) { }
26+ constructor ( private readonly config : Config ) { }
2727
2828 getPackageTemplatesDir ( ) : string {
2929 return join ( this . #getBaseDir( Location . PACKAGE ) , DIR_TEMPLATES ) ;
@@ -68,19 +68,19 @@ export class TemplatesAccess {
6868 }
6969
7070 getWorkspacePath ( ) : string {
71- return this . config . get ( ' workspacePath' ) ;
71+ return this . config . workspacePath ;
7272 }
7373
7474 getTemplatesRepository ( ) : string | null {
75- return this . config . get ( ' templatesRepository' ) ;
75+ return this . config . templatesRepository ;
7676 }
7777
78- createRepositoryUrl ( organization : string , name : string ) : string {
78+ createRepositoryUrl ( name : string ) : string {
7979 // TODO:
8080 // - add support for HTTPS URLs when provided in config
8181 // - add support for different repository hosts
8282 // - add support for different tenants
83- return `git@bitbucket.org:${ organization } /${ name } .git` ;
83+ return `git@bitbucket.org:${ this . config . organization } /${ name } .git` ;
8484 }
8585
8686 async initWorkspace ( ) : Promise < void > {
@@ -102,10 +102,7 @@ export class TemplatesAccess {
102102 // sync the templates from the repository if configured
103103 const templatesRepository = this . getTemplatesRepository ( ) ;
104104 if ( templatesRepository ) {
105- const url = this . createRepositoryUrl (
106- this . config . get ( 'organization' ) ,
107- templatesRepository
108- ) ;
105+ const url = this . createRepositoryUrl ( templatesRepository ) ;
109106 logger . log ( `Syncing templates from repository ${ url } ...` ) ;
110107
111108 await gitUpdate ( url , this . getWorkspacePath ( ) , this . getGitTemplatesDir ( ) ) ;
0 commit comments