Skip to content

Commit

Permalink
Switches the first parameter of apps:create to actually be the label,…
Browse files Browse the repository at this point in the history
… not the name, and adds an additional flag to use the label as the name of the app to match Atomic's behaviour.

Closes #34
  • Loading branch information
pgibson1-godaddy authored and gforsythe-godaddy committed Jul 7, 2022
1 parent bf318cd commit e874427
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/API/Apps/AppsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ public function removeCustomIp($accessToken, $appId, $ip)
->delete("apps/{$appId}/ips/{$ip}");
}

public function createApp($accessToken, $accountId, $name, $primaryDomain, $multisite = false, $multisiteType = null)
public function createApp($accessToken, $accountId, $label, $primaryDomain, $multisite = false, $multisiteType = null, $useLabelInSitesDir = false)
{
$data = [
'name' => $name,
'label' => $label,
'accountId' => (int) $accountId,
'primaryDomain' => $primaryDomain,
'multisite' => (bool) $multisite,
'name' => $useLabelInSitesDir ? $label : $primaryDomain
];
if ($multisiteType) {
$data['multisiteType'] = $multisiteType;
Expand Down
9 changes: 6 additions & 3 deletions src/Command/Apps/CreateAppCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public function configure()
$this
->setDescription('Create new app')
->addArgument('accountId', InputArgument::REQUIRED, 'Account ID')
->addArgument('name', InputArgument::REQUIRED, 'App Name/Domain')
->addArgument('label', InputArgument::REQUIRED, 'App Label (name for the appr to appear as in Atomic)')
->addArgument('primaryDomain', InputArgument::REQUIRED, 'Primary Domain')
->addOption('multisite', 'm', InputOption::VALUE_REQUIRED, 'Enable multisite type (subdomain or subfolder)')
->addOption('use-label-in-sites-dir', null, InputOption::VALUE_NONE, 'Uses the label you have set as the directory name in the ~/sites/ directory when you login to the server.
Without this option, the directory will be named the same as the primaryDomain which is the default behavior when creating a site via Atomic.')
;
$this->addOauthOptions();
}
Expand All @@ -49,10 +51,11 @@ public function execute(InputInterface $input, OutputInterface $output)
$r = $this->api->createApp(
$token,
$input->getArgument('accountId'),
$input->getArgument('name'),
$input->getArgument('label'),
$input->getArgument('primaryDomain'),
!!$multi,
$multi ?: null
$multi ?: null,
$input->getOption('use-label-in-sites-dir')
);

$output->writeln(json_encode(json_decode($r->getBody()->getContents(), true), JSON_PRETTY_PRINT));
Expand Down

0 comments on commit e874427

Please sign in to comment.