Skip to content

Commit 642d16b

Browse files
committed
Initial Commit
1 parent 700a173 commit 642d16b

File tree

17 files changed

+1723
-482
lines changed

17 files changed

+1723
-482
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.phpunit.result.cache
33
.composer/
44
vendor/
5+
.php-cs-fixer.cache
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace librarianphp\Build;
4+
5+
use Librarian\Builder\StaticBuilder;
6+
use Librarian\Provider\ContentServiceProvider;
7+
use Minicli\Command\CommandController;
8+
9+
class DefaultController extends CommandController
10+
{
11+
public function handle(): void
12+
{
13+
$outputDir = $this->getApp()->config->output_path;
14+
/** @var ContentServiceProvider $content */
15+
$content = $this->getApp()->content;
16+
17+
/** @var StaticBuilder $builder */
18+
$builder = $this->getApp()->builder;
19+
$this->getPrinter()->info("Starting Build", 1);
20+
$this->getPrinter()->info("Cleaning up output dir...");
21+
$builder->cleanUp();
22+
23+
//Build content single pages
24+
$contentTypes = $content->getContentTypes();
25+
foreach ($contentTypes as $contentType) {
26+
$this->getPrinter()->info("Building content type '$contentType'");
27+
$builder->buildContentType($contentType);
28+
}
29+
30+
$this->getPrinter()->info("Building tag pages");
31+
$tags = $content->fetchTagList();
32+
foreach ($tags as $tag => $articles) {
33+
$this->getPrinter()->info("Building $tag pages...");
34+
$builder->buildPaginatedTagPage(trim($tag));
35+
}
36+
37+
$this->getPrinter()->info("Building index");
38+
$builder->buildPaginatedIndex();
39+
40+
$this->getPrinter()->info("Copying Resources");
41+
$builder->copyPublicResources();
42+
43+
$this->getPrinter()->info("Building RSS feed");
44+
$builder->buildRssFeed();
45+
46+
$this->getPrinter()->success("Finished building static website at $outputDir.");
47+
}
48+
}

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
# command-help
1+
# command-build
22

3-
Librarian's built-in help command.
3+
Librarian's static builder command.
44

55
```shell
6-
./librarian help
6+
./librarian build
77
```
8+
## Config Requirements
9+
10+
Add the following `static.php` config file in Librarian's config folder:
11+
12+
```php
13+
<?php
14+
15+
return [
16+
/*****************************************************************************
17+
* Settings for static build output
18+
******************************************************************************/
19+
'output_path' => __DIR__ . '/../public',
20+
'assets_path' => __DIR__ . '/../app/Resources/public'
21+
];
22+
23+
```
24+
25+
- `output_path`: location where to dump the static build
26+
- `assets_path`: directory with public assets resources that should be copied into the document root of the generated website.

composer.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
{
2-
"name": "librarianphp/command-help",
2+
"name": "librarianphp/command-build",
33
"type": "library",
4-
"description": "Librarian's built-in help command",
4+
"description": "Librarian's static build command",
55
"license": "MIT",
6-
"homepage": "https://github.com/librarianphp/command-demo",
6+
"homepage": "https://github.com/librarianphp/command-build",
77
"keywords": ["cli","command-line", "markdown"],
88
"autoload": {
99
"psr-4": {
10-
"librarianphp\\": "Command/"
10+
"librarianphp\\": "Command/",
11+
"Librarian\\Builder\\": "src/"
1112
}
1213
},
1314
"require": {
14-
"minicli/minicli": "^3.2"
15+
"minicli/minicli": "^3.2",
16+
"librarianphp/librarian-core": "^3.0",
17+
"suin/php-rss-writer": "^1.6"
1518
},
1619
"require-dev": {
1720
"pestphp/pest": "^2.4",
18-
"friendsofphp/php-cs-fixer": "^3.16"
21+
"friendsofphp/php-cs-fixer": "^3.16",
22+
"mockery/mockery": "^1.5"
1923
},
2024
"scripts": {
2125
"test" : ["pest"],

0 commit comments

Comments
 (0)