@@ -21,6 +21,8 @@ protected function configure()
21
21
->setDescription ('Create a new Apiato application ' )
22
22
->addArgument ('name ' , InputArgument::REQUIRED )
23
23
->addOption ('dev ' , null , InputOption::VALUE_NONE , 'Installs the latest "development" release ' )
24
+ ->addOption ('git ' , null , InputOption::VALUE_NONE , 'Initialize a Git repository ' )
25
+ ->addOption ('branch ' , null , InputOption::VALUE_REQUIRED , 'The branch that should be created for a new repository ' , 'main ' )
24
26
->addOption ('force ' , 'f ' , InputOption::VALUE_NONE , 'Forces install even if the directory already exists ' )
25
27
->setHelp ('This command only shows a message to welcome user and nothing more. ' );
26
28
}
@@ -95,6 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
95
97
);
96
98
}
97
99
100
+ // TODO: Remove github checks if dont want to implement github support
101
+ if ($ input ->getOption ('git ' ) || $ input ->getOption ('github ' ) !== false ) {
102
+ $ this ->createRepository ($ directory , $ input , $ output );
103
+ }
104
+
98
105
$ output ->writeln (PHP_EOL . '<comment>Apiato ready! Build something amazing.</comment> ' );
99
106
}
100
107
@@ -116,6 +123,29 @@ protected function getVersion(InputInterface $input)
116
123
return '' ;
117
124
}
118
125
126
+ /**
127
+ * Create a Git repository and commit the base Laravel skeleton.
128
+ *
129
+ * @param string $directory
130
+ * @param \Symfony\Component\Console\Input\InputInterface $input
131
+ * @param \Symfony\Component\Console\Output\OutputInterface $output
132
+ * @return void
133
+ */
134
+ protected function createRepository (string $ directory , InputInterface $ input , OutputInterface $ output )
135
+ {
136
+ chdir ($ directory );
137
+
138
+ $ branch = $ input ->getOption ('branch ' ) ?: 'main ' ;
139
+
140
+ $ commands = [
141
+ "git init -q -b {$ branch } . " ,
142
+ 'git add . ' ,
143
+ 'git commit -q -m "Set up a fresh Apiato app" ' ,
144
+ ];
145
+
146
+ $ this ->runCommands ($ commands , $ input , $ output );
147
+ }
148
+
119
149
/**
120
150
* Verify that the application does not already exist.
121
151
*
0 commit comments