11import { type Static } from "@sinclair/typebox" ;
2-
3- import fs from "node:fs" ;
4- import fsp from "node:fs/promises" ;
52import { v4 as uuidv4 } from "uuid" ;
63import {
74 appendPath ,
@@ -67,6 +64,7 @@ import {
6764 ReadmeRecordFileType ,
6865} from "./file-types/file-types" ;
6966import { isEmpty } from "lodash" ;
67+ import { FsService } from "./fs/fs.service" ;
7068
7169export class FsManager {
7270 private rootPath : string ;
@@ -83,7 +81,7 @@ export class FsManager {
8381 id : getIdFromPath ( appendPath ( this . rootPath , CONFIG_FILE ) ) ,
8482 type : "file" ,
8583 } ) ;
86- const rawConfig = fs . readFileSync ( configFile . path ) . toString ( ) ;
84+ const rawConfig = FsService . readFileSync ( configFile . path ) . toString ( ) ;
8785 const parsedConfig = parseJsonContent ( rawConfig , Config ) ;
8886 if ( parsedConfig . type === "error" ) {
8987 throw new Error (
@@ -112,11 +110,11 @@ export class FsManager {
112110 private async parseFolder ( rootPath : string , type : APIEntity [ "type" ] ) {
113111 const container : FsResource [ ] = [ ] ;
114112 const recursiveParser = async ( path : string ) => {
115- const children = await fsp . readdir ( path ) ;
113+ const children = await FsService . readdir ( path ) ;
116114 // eslint-disable-next-line
117115 for ( const child of children ) {
118116 const resourcePath = appendPath ( path , child ) ;
119- const resourceMetadata = await fsp . stat ( resourcePath ) ;
117+ const resourceMetadata = await FsService . stat ( resourcePath ) ;
120118
121119 if ( resourceMetadata . isDirectory ( ) ) {
122120 container . push (
@@ -251,7 +249,6 @@ export class FsManager {
251249 this . rootPath ,
252250 "environment"
253251 ) ;
254- console . log ( "ENV CONTAINER" , { resourceContainer } ) ;
255252 const entities : Environment [ ] = [ ] ;
256253 const erroredRecords : ErroredRecord [ ] = [ ] ;
257254 // eslint-disable-next-line
@@ -416,7 +413,9 @@ export class FsManager {
416413 path,
417414 type : "folder" ,
418415 } ) ;
419- const createResult = await createFolder ( resource , true ) ;
416+ const createResult = await createFolder ( resource , {
417+ errorIfDoesNotExist : true ,
418+ } ) ;
420419 if ( createResult . type === "error" ) {
421420 return createResult ;
422421 }
@@ -517,21 +516,17 @@ export class FsManager {
517516 } ,
518517 } ;
519518 }
520- console . log ( "rename 1" , id ) ;
521519 const folderResource = this . createResource ( {
522520 id,
523521 type : "folder" ,
524522 } ) ;
525523 const parentPath = getParentFolderPath ( folderResource ) ;
526- console . log ( "rename 2" , parentPath , newName ) ;
527524
528525 const newFolderResource = this . createResource ( {
529526 id : getIdFromPath ( appendPath ( parentPath , newName ) ) ,
530527 type : "folder" ,
531528 } ) ;
532529
533- console . log ( "rename 3" , newFolderResource ) ;
534-
535530 const renameResult = await rename ( folderResource , newFolderResource ) ;
536531 if ( renameResult . type === "error" ) {
537532 return renameResult ;
0 commit comments