• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Cecilapp / Cecil / 5046064611

pending completion
5046064611

push

github

GitHub
perf: native_function_invocation (#1697)

322 of 322 new or added lines in 62 files covered. (100.0%)

2784 of 4121 relevant lines covered (67.56%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Command/Build.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Command;
15

16
use Cecil\Util;
17
use Symfony\Component\Console\Input\InputArgument;
18
use Symfony\Component\Console\Input\InputDefinition;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Input\InputOption;
21
use Symfony\Component\Console\Output\OutputInterface;
22

23
/**
24
 * Builds the website.
25
 */
26
class Build extends AbstractCommand
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function configure()
32
    {
33
        $this
×
34
            ->setName('build')
×
35
            ->setDescription('Builds the website')
×
36
            ->setDefinition(
×
37
                new InputDefinition([
×
38
                    new InputArgument('path', InputArgument::OPTIONAL, 'Use the given path as working directory'),
×
39
                    new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Set the path to extra config files (comma-separated)'),
×
40
                    new InputOption('drafts', 'd', InputOption::VALUE_NONE, 'Include drafts'),
×
41
                    new InputOption('page', 'p', InputOption::VALUE_REQUIRED, 'Build a specific page'),
×
42
                    new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Build without saving'),
×
43
                    new InputOption('baseurl', null, InputOption::VALUE_REQUIRED, 'Set the base URL'),
×
44
                    new InputOption('output', null, InputOption::VALUE_REQUIRED, 'Set the output directory'),
×
45
                    new InputOption('postprocess', null, InputOption::VALUE_OPTIONAL, 'Post-process output (disable with "no")', false),
×
46
                    new InputOption('clear-cache', null, InputOption::VALUE_OPTIONAL, 'Clear cache before build (optional cache key regular expression)', false),
×
47
                ])
×
48
            )
×
49
            ->setHelp('Builds the website in the output directory');
×
50
    }
51

52
    /**
53
     * {@inheritdoc}
54
     */
55
    protected function execute(InputInterface $input, OutputInterface $output)
56
    {
57
        $config = [];
×
58
        $options = [];
×
59
        $messageOpt = '';
×
60

61
        if ($input->getOption('baseurl')) {
×
62
            $config['baseurl'] = $input->getOption('baseurl');
×
63
        }
64
        if ($input->getOption('output')) {
×
65
            $config['output']['dir'] = $input->getOption('output');
×
66
            Util\File::getFS()->dumpFile(Util::joinFile($this->getPath(), self::TMP_DIR, 'output'), (string) $input->getOption('output'));
×
67
        }
68
        if ($input->getOption('postprocess') === null) {
×
69
            $config['postprocess']['enabled'] = true;
×
70
        }
71
        if ($input->getOption('postprocess') == 'no') {
×
72
            $config['postprocess']['enabled'] = false;
×
73
        }
74
        if ($input->getOption('clear-cache') === null) {
×
75
            $config['cache']['enabled'] = false;
×
76
        }
77

78
        $builder = $this->getBuilder($config);
×
79

80
        if ($input->getOption('drafts')) {
×
81
            $options['drafts'] = true;
×
82
            $messageOpt .= ' with drafts';
×
83
        }
84
        if ($input->getOption('dry-run')) {
×
85
            $options['dry-run'] = true;
×
86
            $messageOpt .= ' (dry-run)';
×
87
        }
88
        if ($input->getOption('page')) {
×
89
            $options['page'] = $input->getOption('page');
×
90
        }
91
        if ($input->getOption('clear-cache')) {
×
92
            if (0 < $removedFiles = (new \Cecil\Assets\Cache($this->getBuilder()))->clearByPattern($input->getOption('clear-cache'))) {
×
93
                $output->writeln(sprintf('<info>%s cache files removed by regular expression "%s"</info>', $removedFiles, $input->getOption('clear-cache')));
×
94
            }
95
        }
96

97
        $output->writeln(sprintf('Building website%s...', $messageOpt));
×
98
        $output->writeln(
×
99
            sprintf('<comment>Path: %s</comment>', $this->getPath()),
×
100
            OutputInterface::VERBOSITY_VERBOSE
×
101
        );
×
102
        if (!empty($this->getConfigFiles())) {
×
103
            $output->writeln(
×
104
                sprintf('<comment>Config: %s</comment>', implode(', ', $this->getConfigFiles())),
×
105
                OutputInterface::VERBOSITY_VERBOSE
×
106
            );
×
107
        }
108
        if ((bool) $builder->getConfig()->get('cache.enabled')) {
×
109
            $output->writeln(
×
110
                sprintf('<comment>Cache: %s</comment>', $builder->getConfig()->getCachePath()),
×
111
                OutputInterface::VERBOSITY_VERBOSE
×
112
            );
×
113
        }
114

115
        $builder->build($options);
×
116
        $output->writeln('Done! 🎉');
×
117

118
        return 0;
×
119
    }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc