@@ -10,7 +10,6 @@ import {
1010import { PACKAGES_LIST } from '/shared/types/pkg' ;
1111import { DEFAULT_DEPENDENCY_UPDATE_STRATEGY } from '/shared/types/settings' ;
1212import type { GetProjectsOpts , Template , Workspace } from '/shared/types/workspace' ;
13- import { FileSystemStorage } from '/shared/types/storage' ;
1413
1514import type { Services } from '../services' ;
1615
@@ -21,7 +20,7 @@ import { DEFAULT_THUMBNAIL, NEW_SCENE_NAME, EMPTY_SCENE_TEMPLATE_REPO } from './
2120import { getProjectId } from './analytics' ;
2221
2322export function initializeWorkspace ( services : Services ) {
24- const { config, fs, ipc, path, pkg, npm } = services ;
23+ const { config, fs, ipc, path, pkg, npm, project } = services ;
2524
2625 // IMPORTANT: when './scene' get's moved to this same factory pattern, we should remove
2726 // the import for { getScene } and use it as "const scene = initializeScene(services)".
@@ -60,7 +59,7 @@ export function initializeWorkspace(services: Services) {
6059 }
6160
6261 async function getOldProjectThumbnailPath ( _path : string ) {
63- const workspaceConfigPath = await getConfigPath ( _path ) ;
62+ const workspaceConfigPath = await config . getWorkspaceConfigPath ( _path ) ;
6463 return path . join ( workspaceConfigPath , 'images' , 'project-thumbnail.png' ) ;
6564 }
6665
@@ -110,7 +109,7 @@ export function initializeWorkspace(services: Services) {
110109 getScene ( _path ) ,
111110 fs . stat ( _path ) ,
112111 opts ?. omitOutdatedPackages ? Promise . resolve ( { } ) : getOutdatedPackages ( _path ) ,
113- getProjectInfoFs ( _path ) ,
112+ project . getProjectInfoFs ( _path ) ,
114113 ] ) ;
115114 const thumbnail = await getProjectThumbnailAsBase64 ( _path , scene ) ;
116115 const layout = getRowsAndCols ( scene . scene . parcels . map ( $ => parseCoords ( $ ) ) ) ;
@@ -456,19 +455,8 @@ export function initializeWorkspace(services: Services) {
456455 if ( error ) throw new Error ( error ) ;
457456 }
458457
459- async function getConfigPath ( _path : string ) {
460- return ipc . invoke ( 'electron.getWorkspaceConfigPath' , _path ) ;
461- }
462-
463- async function getProjectInfoFs ( _path : string ) {
464- const configPath = await getConfigPath ( _path ) ;
465- const projectInfoPath = path . join ( configPath , 'project.json' ) ;
466- const projectInfo = await FileSystemStorage . getOrCreate < ProjectInfo > ( projectInfoPath ) ;
467- return projectInfo ;
468- }
469-
470458 async function updateProjectInfo ( { path, info } : { path : string ; info : Partial < ProjectInfo > } ) {
471- const projectInfoFs = await getProjectInfoFs ( path ) ;
459+ const projectInfoFs = await project . getProjectInfoFs ( path ) ;
472460 const projectInfo = await projectInfoFs . getAll ( ) ;
473461 await projectInfoFs . setAll ( { ...projectInfo , ...info } ) ;
474462 }
@@ -479,6 +467,8 @@ export function initializeWorkspace(services: Services) {
479467 hasNodeModules,
480468 getProjectThumbnailAsBase64,
481469 getOutdatedPackages,
470+ getProjectThumbnailPath,
471+ getOldProjectThumbnailPath,
482472 getProject,
483473 getPath,
484474 getProjects,
@@ -492,9 +482,7 @@ export function initializeWorkspace(services: Services) {
492482 reimportProject,
493483 saveThumbnail,
494484 openFolder,
495- getConfigPath,
496485 validateScenesPath,
497- getProjectInfoFs,
498486 updateProjectInfo,
499487 importProject,
500488 isProjectPathAvailable,
0 commit comments