@@ -57,6 +57,10 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
5757 description : 'Skip installing optional dependencies.' ,
5858 required : false ,
5959 } ) ,
60+ 'skip-git-init' : Flags . boolean ( {
61+ description : 'Skip initializing a git repository in the Actor directory.' ,
62+ required : false ,
63+ } ) ,
6064 } ;
6165
6266 static override args = {
@@ -68,7 +72,7 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
6872
6973 async run ( ) {
7074 let { actorName } = this . args ;
71- const { template : templateName , skipDependencyInstall } = this . flags ;
75+ const { template : templateName , skipDependencyInstall, skipGitInit } = this . flags ;
7276
7377 // --template-archive-url is an internal, undocumented flag that's used
7478 // for testing of templates that are not yet published in the manifest
@@ -308,6 +312,20 @@ export class CreateCommand extends ApifyCommand<typeof CreateCommand> {
308312 } ) ;
309313 }
310314
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+
311329 if ( dependenciesInstalled ) {
312330 success ( { message : `Actor '${ actorName } ' was created. To run it, run "cd ${ actorName } " and "apify run".` } ) ;
313331 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> {
319337 message : `Actor '${ actorName } ' was created. Please install its dependencies to be able to run it using "apify run".` ,
320338 } ) ;
321339 }
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+ }
322353 }
323354}
0 commit comments