Skip to content

Commit

Permalink
Move copying default configs to happen when cloning repos
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpoe committed Mar 18, 2019
1 parent 281e1a4 commit eff916b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
30 changes: 30 additions & 0 deletions scripts/cloneRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

echo "Installing dev dependencies for joindin-vm\n";
system('composer install');
echo "Updating configuration files with defaults\n";
copyApiConfigs($repositoryToClone[0]);
copyWebConfigs($repositoryToClone[1]);

function getGitUsername(string $remoteString, bool $useHttps): string
{
Expand Down Expand Up @@ -93,3 +96,30 @@ function installViaComposer(string $repoName): void
echo $remoteCommand. "\n";
system($remoteCommand);
}

function copyApiConfigs(string $repoName): void
{
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $repoName;
chdir($path);

if (!file_exists('src/config.php')) {
echo 'Creating default API config' . PHP_EOL;
system("cp $path/src/config.php.dist $path/src/config.php");
}

if (!file_exists('src/database.php')) {
echo 'Creating default API database config' . PHP_EOL;
system("cp $path/src/database.php.dist $path/src/database.php");
}
}

function copyWebConfigs(string $repoName): void
{
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . $repoName;
chdir($path);

if (!file_exists('config/config.php')) {
echo 'Creating default Web config' . PHP_EOL;
system("cp $path/config/config.php.dist $path/config/config.php");
}
}
15 changes: 0 additions & 15 deletions scripts/fixConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,5 @@

VAGRANT_DIR=$PWD;

if [[ ! -e $VAGRANT_DIR/joindin-api/src/config.php ]]; then
echo "api config missing... fixing";
cp $VAGRANT_DIR/joindin-api/src/config.php.dist $VAGRANT_DIR/joindin-api/src/config.php;
fi

if [[ ! -f $VAGRANT_DIR/joindin-api/src/database.php ]]; then
echo "api database-config missing... fixing";
cp $VAGRANT_DIR/joindin-api/src/database.php.dist $VAGRANT_DIR/joindin-api/src/database.php;
fi

if [[ ! -f $VAGRANT_DIR/joindin-web2/config/config.php ]]; then
echo "Web config missing... fixing";
cp $VAGRANT_DIR/joindin-web2/config/config.php.dist $VAGRANT_DIR/joindin-web2/config/config.php;
fi

sed -i 's/https:\/\/m.joind.in/http:\/\/dev.joind.in/' $VAGRANT_DIR/joindin-api/src/config.php
sed -i 's/https:\/\/api.joind.in/http:\/\/api.dev.joind.in/' $VAGRANT_DIR/joindin-web2/config/config.php

0 comments on commit eff916b

Please sign in to comment.