@@ -133,57 +133,33 @@ export async function createApp(args) {
133133 const puter = getPuter ( ) ;
134134 try {
135135 // Step 1: Create the app
136- const createAppResponse = await fetch ( `${ API_BASE } /drivers/call` , {
137- method : 'POST' ,
138- headers : getHeaders ( ) ,
139- body : JSON . stringify ( {
140- interface : "puter-apps" ,
141- method : "create" ,
142- args : {
143- object : {
144- name : name ,
145- index_url : url ,
146- title : name ,
147- description : description ,
148- maximize_on_start : false ,
149- background : false ,
150- metadata : {
151- window_resizable : true
152- }
153- } ,
154- options : {
155- dedupe_name : true
156- }
157- }
158- } )
136+ const createAppData = await puter . apps . create ( {
137+ name : name ,
138+ indexURL : url ,
139+ title : name ,
140+ description : description ,
141+ maximizeOnStart : false ,
142+ dedupeName : true
159143 } ) ;
160- const createAppData = await createAppResponse . json ( ) ;
161- if ( ! createAppData || ! createAppData . success ) {
144+ if ( ! createAppData ) {
162145 console . error ( chalk . red ( `Failed to create app "${ name } "` ) ) ;
163146 return ;
164147 }
165- const appUid = createAppData . result . uid ;
166- const appName = createAppData . result . name ;
167- const username = createAppData . result . owner . username ;
148+ const appUid = createAppData . uid ;
149+ const appName = createAppData . name ;
150+ const username = createAppData . owner . username ;
168151 console . log ( chalk . green ( `App "${ chalk . dim ( name ) } " created successfully!` ) ) ;
169152 console . log ( chalk . cyan ( `AppName: ${ chalk . dim ( appName ) } \nUID: ${ chalk . dim ( appUid ) } \nUsername: ${ chalk . dim ( username ) } ` ) ) ;
170153
171154 // Step 2: Create a directory for the app
172155 const uid = crypto . randomUUID ( ) ;
173156 const appDir = `/${ username } /AppData/${ appUid } ` ;
174157 console . log ( chalk . green ( `Creating directory...\nPath: ${ chalk . dim ( appDir ) } \nApp: ${ chalk . dim ( name ) } \nUID: ${ chalk . dim ( uid ) } \n` ) ) ;
175- const createDirResponse = await fetch ( `${ API_BASE } /mkdir` , {
176- method : 'POST' ,
177- headers : getHeaders ( ) ,
178- body : JSON . stringify ( {
179- parent : appDir ,
180- path : `app-${ uid } ` ,
181- overwrite : true ,
182- dedupe_name : false ,
183- create_missing_parents : true
184- } )
185- } ) ;
186- const createDirData = await createDirResponse . json ( ) ;
158+ const createDirData = await puter . fs . mkdir ( `${ appDir } /app-${ uid } ` , {
159+ overwrite : true ,
160+ dedupeName : false ,
161+ createMissingParents : true ,
162+ } )
187163 if ( ! createDirData || ! createDirData . uid ) {
188164 console . error ( chalk . red ( `Failed to create directory for app "${ name } "` ) ) ;
189165 return ;
0 commit comments