@@ -57,6 +57,10 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
57
57
description : 'Skip installing optional dependencies.' ,
58
58
required : false ,
59
59
} ) ,
60
+ 'skip-git-init' : Flags . boolean ( {
61
+ description : 'Skip initializing a git repository in the Actor directory.' ,
62
+ required : false ,
63
+ } ) ,
60
64
} ;
61
65
62
66
static override args = {
@@ -68,7 +72,7 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
68
72
69
73
async run ( ) {
70
74
let { actorName } = this . args ;
71
- const { template : templateName , skipDependencyInstall } = this . flags ;
75
+ const { template : templateName , skipDependencyInstall, skipGitInit } = this . flags ;
72
76
73
77
// --template-archive-url is an internal, undocumented flag that's used
74
78
// for testing of templates that are not yet published in the manifest
@@ -308,6 +312,20 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
308
312
} ) ;
309
313
}
310
314
315
+ // Initialize git repository before reporting success, but store result for later
316
+ let gitInitResult : { success : boolean ; error ?: Error } = { success : true } ;
317
+ if ( ! skipGitInit ) {
318
+ try {
319
+ await execWithLog ( {
320
+ cmd : 'git' ,
321
+ args : [ 'init' ] ,
322
+ opts : { cwd : actFolderDir } ,
323
+ } ) ;
324
+ } catch ( err ) {
325
+ gitInitResult = { success : false , error : err as Error } ;
326
+ }
327
+ }
328
+
311
329
if ( dependenciesInstalled ) {
312
330
success ( { message : `Actor '${ actorName } ' was created. To run it, run "cd ${ actorName } " and "apify run".` } ) ;
313
331
info ( { message : 'To run your code in the cloud, run "apify push" and deploy your code to Apify Console.' } ) ;
@@ -319,5 +337,18 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
319
337
message : `Actor '${ actorName } ' was created. Please install its dependencies to be able to run it using "apify run".` ,
320
338
} ) ;
321
339
}
340
+
341
+ // Report git initialization result after actor creation success
342
+ if ( ! skipGitInit ) {
343
+ if ( gitInitResult . success ) {
344
+ info ( {
345
+ message : `Git repository initialized in '${ actorName } '. You can now commit and push your Actor to Git.` ,
346
+ } ) ;
347
+ } else {
348
+ // Git init is not critical, so we just warn if it fails
349
+ warning ( { message : `Failed to initialize git repository: ${ gitInitResult . error ! . message } ` } ) ;
350
+ warning ( { message : 'You can manually run "git init" in the Actor directory if needed.' } ) ;
351
+ }
352
+ }
322
353
}
323
354
}
0 commit comments