Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI-1237: Publish docs #1660

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
files: var/acli.phar
- name: Publish docs
if: github.event_name == 'push'
run: |
./bin/acli self:make-docs -d docs
aws s3 sync docs s3://acquia-cli/docs
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# Require all checks to pass without having to enumerate them in the branch protection UI.
# @see https://github.community/t/is-it-possible-to-require-all-github-actions-tasks-to-pass-without-enumerating-them/117957
check:
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Auth/AuthLoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
$activeKey = $this->datastoreCloud->get('acli_key');
if ($activeKey) {
$activeKeyLabel = $keys[$activeKey]['label'];
$output->write("The following Cloud Platform API key is active: <options=bold>$activeKeyLabel</>");
$output->writeln("The following Cloud Platform API key is active: <options=bold>$activeKeyLabel</>");
}
else {
$output->write('No Cloud Platform API key is active');
$output->writeln('No Cloud Platform API key is active');

Check warning on line 33 in src/Command/Auth/AuthLoginCommand.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $activeKeyLabel = $keys[$activeKey]['label']; $output->writeln("The following Cloud Platform API key is active: <options=bold>{$activeKeyLabel}</>"); } else { - $output->writeln('No Cloud Platform API key is active'); + } // If keys already are saved locally, prompt to select. if ($keys && $input->isInteractive()) {
}

// If keys already are saved locally, prompt to select.
Expand Down
2 changes: 0 additions & 2 deletions src/Command/Self/ClearCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Acquia\Cli\Command\Self;

use Acquia\Cli\Attribute\RequireAuth;
use Acquia\Cli\Command\CommandBase;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -13,7 +12,6 @@
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;

#[RequireAuth]
#[AsCommand(name: 'self:clear-caches', description: 'Clears local Acquia CLI caches', aliases: ['cc', 'cr'])]
final class ClearCacheCommand extends CommandBase {

Expand Down
35 changes: 30 additions & 5 deletions src/Command/Self/MakeDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,55 @@

namespace Acquia\Cli\Command\Self;

use Acquia\Cli\Attribute\RequireAuth;
use Acquia\Cli\Command\CommandBase;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\DescriptorHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;

#[RequireAuth]
#[AsCommand(name: 'self:make-docs', description: 'Generate documentation for all ACLI commands', hidden: TRUE)]
final class MakeDocsCommand extends CommandBase {

protected function configure(): void {
$this->addOption('format', 'f', InputOption::VALUE_OPTIONAL, 'The format to describe the docs in.', 'rst');
$this->addOption('dump', 'd', InputOption::VALUE_OPTIONAL, 'Dump docs to directory');
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$helper = new DescriptorHelper();

$helper->describe($output, $this->getApplication(), [
'format' => $input->getOption('format'),
if (!$input->getOption('dump')) {
$helper->describe($output, $this->getApplication(), [
'format' => $input->getOption('format'),
]);
return Command::SUCCESS;
}

$docs_dir = $input->getOption('dump');
$this->localMachineHelper->getFilesystem()->mkdir($docs_dir);
$buffer = new BufferedOutput();
$helper->describe($buffer, $this->getApplication(), [
'format' => 'json',
]);

$commands = json_decode($buffer->fetch(), TRUE);
$index = [];
foreach ($commands['commands'] as $command) {
if ($command['definition']['hidden'] ?? FALSE) {
continue;
}
$filename = $command['name'] . '.json';
$index[] = [
'command' => $command['name'],
'help' => $command['help'],
'path' => $filename,
'usage' => $command['usage'][0],
];
file_put_contents("$docs_dir/$filename", json_encode($command));
}
file_put_contents("$docs_dir/index.json", json_encode($index));
return Command::SUCCESS;
}

Expand Down