Skip to content

Commit

Permalink
Merge pull request #2 from chevereto/chore/template_sync_f3e1eb7
Browse files Browse the repository at this point in the history
upstream merge template repository
  • Loading branch information
rodber authored Mar 3, 2022
2 parents 8dc1ef7 + a250c24 commit 6dd65fb
Show file tree
Hide file tree
Showing 17 changed files with 1,386 additions and 968 deletions.
6 changes: 6 additions & 0 deletions .ecs/.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This file is part of Chevere.

(c) Rodolfo Berrios <[email protected]>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
26 changes: 26 additions & 0 deletions .ecs/ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/ecs-chevere.php');
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SKIP, [
__DIR__ . '/**/naming.php',
__DIR__ . '/**/sorting.php',
__DIR__ . '/vendor/*',
__DIR__ . '/tests/_resources/*',
]);
};
2 changes: 1 addition & 1 deletion .templateversionrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d6403cd
f3e1eb7
12 changes: 10 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ project.plugins.push(
}],
['@vuepress/medium-zoom', true]
);
project.themeConfig.nav = require('./nav/en')
project.themeConfig.sidebar = require('./sidebar/en')
if (!project.themeConfig.nav) {
project.themeConfig.nav = [];
}
project.themeConfig.nav.push(
...require('./nav/en')
);
if (!project.themeConfig.sidebar) {
project.themeConfig.sidebar = [];
}
project.themeConfig.sidebar = require('./sidebar/en');
module.exports = project
2 changes: 1 addition & 1 deletion .vuepress/sidebar/en.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = {}
module.exports = []
54 changes: 33 additions & 21 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,56 @@

Refer to the [CONSOLE GUIDE](guides/console/SETUP.md).

## GitHub docs-deploy repo
## GitHub actions setup

* Click the [Use this template](https://github.com/chevere/docs-deploy/generate) button
* Require to create three (3) repositories:
* (A) Repo for hosting your documentation website (for free!)
* (B) Repo for documentation (markdown files)
* (C) Repo for docs deploy (documentation website builer)

![Create repo](guides/create-repo-template.png)
* Requires to provide PAT ([Personal Access Tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)) with `repo` scope granted.

### (A) Hosting repo

* Create a new repository to use is as (free) hosting for your documentation website.

### (B) Docs repo

* Create a new repository to use it as your **docs repo** (markdown files) source.

💡 You can use [chevere/docs-template](https://github.com/chevere/docs-template) as base.

When done:

1. Go to **Secrets** under **Settings** from your new repo
2. Click on **New repository secret**
3. Provide the following repository **secrets**:

| Key | Description / example |
| ------------------------- | ------------------------------------------------------ |
| REPO_DOCS | GitHub docs repo as `chevere/docs` |
| REPO_DOCS_ACCESS_TOKEN | Token for the repo above |
| REPO_HOSTING | GitHub repo for hosting as `chevere/chevere.github.io` |
| REPO_HOSTING_ACCESS_TOKEN | Token for the repo above |
| CNAME | Hostname* for docs `chevere.org` |
| Key | Description / example |
| ------------------------ | -------------------------------------------------------------- |
| `REPO_DOCS_DEPLOY` | [Docs deploy](#c-docs-deploy-repo) repo as `owner/docs-deploy` |
| `REPO_DOCS_DEPLOY_TOKEN` | PAT to access `REPO_DOCS_DEPLOY` |

(*) Hostname: Make sure to CNAME your hostname to `<user>.github.io` as indicated in your GitHub pages repo.
### (C) docs-deploy repo

## GitHub docs repo
* Click the [Use this template](https://github.com/chevere/docs-deploy/generate) button to create your docs-deploy repo.

* Create a new repository to use it as your **docs repo**. You can use [chevere/docs-template](https://github.com/chevere/docs-template) as base.
![Create repo](guides/create-repo-template.png)

When done:

1. Go to **Secrets** under **Settings** from your new repo
2. Click on **New repository secret**
3. Provide the following repository **secrets**:

| Key | Description / example |
| --------------------------- | --------------------------------------------- |
| `REPO_DOCS_DEPLOY` | Repo used for deploy as `chevere/docs-deploy` |
| `REPO_DOCS_DEPLOY_USERNAME` | Username with access to repo above |
| `REPO_DOCS_DEPLOY_TOKEN` | Token for the repo above |

> The personal access token must grant access to `repo` scope
| Key | Description / example |
| --------------------------- | ---------------------------------------------------- |
| `REPO_DOCS` | [Docs repo](#b-docs-repo) as `owner/docs-repo` |
| `REPO_DOCS_ACCESS_TOKEN` | PAT to access `REPO_DOCS` |
| `REPO_HOSTING` | [Hosting repo](#a-hosting-repo) as `owner/host-repo` |
| `REPO_HOSTING_ACCESS_TOKEN` | PAT to access `REPO_HOSTING` |
| `CNAME` | Hostname for your website as `mydomain.com` |

### Automatic deployment on docs repo update
## Automatic deployment on docs repo update

Check the [push-deploy.yml](https://github.com/chevere/docs-template/blob/main/.github/workflows/push-deploy.yml) workflow used to automatic trigger workflows on the deploy repo from the docs repo.
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,21 @@
}
},
"require": {
"chevere/chevere": "^0.1"
"chevere/chevere": "^0.3"
},
"require-dev": {
"symplify/easy-coding-standard": "^9.1",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5",
"chevere/xr": "^0.1"
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
},
"scripts": {
"update-cs": "curl --create-dirs -O --output-dir .ecs https://raw.githubusercontent.com/chevere/code-style/main/.ecs/ecs-chevere.php"
},
"scripts-descriptions": {
"update-cs": "Update Chevere code style definition"
}
}
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ else
echo 'Skipping docs sourcing...'
fi

if [ $# -eq 3 ]; then
rm -rf docs/
cp -a $3 docs/
fi

echo 'Copy .vuepress/ contents to docs/.vuepress/'
cp -rf .vuepress/. docs/.vuepress/

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
},
"license": "MIT",
"devDependencies": {
"@vuepress/plugin-google-analytics": "^1.8.2",
"@vuepress/plugin-medium-zoom": "^1.8.2",
"@vuepress/plugin-pwa": "^1.8.2",
"vuepress": "^1.8.2"
"@vuepress/plugin-google-analytics": "^1.9.7",
"@vuepress/plugin-medium-zoom": "^1.9.7",
"@vuepress/plugin-pwa": "^1.9.7",
"vuepress": "^1.9.7"
},
"author": "Rodolfo Berrios",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
processUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true">
<include>
<directory suffix=".php">src/Chevere/Components/</directory>
<directory suffix=".php">src/Chevere/</directory>
</include>
</coverage>
</phpunit>
39 changes: 19 additions & 20 deletions src/BuildController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@

namespace DocsDeploy;

use Chevere\Components\Controller\Controller;
use function Chevere\Components\Filesystem\dirForPath;
use function Chevere\Components\Filesystem\fileForPath;
use function Chevere\Components\Parameter\parameters;
use function Chevere\Components\Parameter\stringParameter;

use Chevere\Components\Parameter\Parameters;
use Chevere\Components\Parameter\StringParameter;
use function Chevere\Components\Writer\streamFor;
use Chevere\Components\Writer\StreamWriter;
use Chevere\Interfaces\Filesystem\DirInterface;
use Chevere\Interfaces\Parameter\ArgumentsInterface;
use Chevere\Interfaces\Parameter\ParametersInterface;
use Chevere\Interfaces\Response\ResponseInterface;
use Chevere\Interfaces\Writer\WriterInterface;
use Chevere\Controller\Controller;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Filesystem\fileForPath;
use function Chevere\Parameter\parameters;
use function Chevere\Parameter\stringParameter;
use Chevere\Parameter\Parameters;
use Chevere\Parameter\StringParameter;
use function Chevere\Writer\streamFor;
use Chevere\Writer\StreamWriter;
use Chevere\Filesystem\Interfaces\DirInterface;
use Chevere\Parameter\Interfaces\ArgumentsInterface;
use Chevere\Parameter\Interfaces\ParametersInterface;
use Chevere\Response\Interfaces\ResponseInterface;
use Chevere\Writer\Interfaces\WriterInterface;

class BuildController extends Controller
{
Expand Down Expand Up @@ -73,11 +72,11 @@ private function processStyles(): void
$stylDefaultFile = fileForPath($stylesPath . 'default-' . $styl . $stylExt);
$stylFile = fileForPath($stylesPath . $styl . $stylExt);
if ($stylFile->exists() && $stylDefaultFile->exists()) {
$defaults = $stylDefaultFile->contents();
$customs = $stylFile->contents();
$stream = streamFor($stylFile->path()->toString(), 'w');
$defaults = $stylDefaultFile->getContents();
$customs = $stylFile->getContents();
$stream = streamFor($stylFile->path()->__toString(), 'w');
$stream->write($defaults . "\n\n" . $customs);
$this->writer->write('- ' . $stylFile->path()->toString() . "\n");
$this->writer->write('- ' . $stylFile->path()->__toString() . "\n");
}
}
}
Expand All @@ -97,7 +96,7 @@ private function processModules(): void
$file->create();
}
$file->put(toModuleExport($module));
$this->writer->write('- ' . $file->path()->toString() . "\n");
$this->writer->write('- ' . $file->path()->__toString() . "\n");
}
}
}
2 changes: 1 addition & 1 deletion src/Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace DocsDeploy;

use Chevere\Interfaces\Filesystem\DirInterface;
use Chevere\Filesystem\Interfaces\DirInterface;
use Countable;

class Flags implements Countable
Expand Down
16 changes: 8 additions & 8 deletions src/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace DocsDeploy;

use function Chevere\Components\Filesystem\dirForPath;
use function Chevere\Components\Filesystem\filePhpReturnForPath;
use Chevere\Interfaces\Filesystem\DirInterface;
use Chevere\Interfaces\Writer\WriterInterface;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Filesystem\filePhpReturnForPath;
use Chevere\Filesystem\Interfaces\DirInterface;
use Chevere\Writer\Interfaces\WriterInterface;
use RecursiveDirectoryIterator;
use RecursiveFilterIterator;
use RecursiveIteratorIterator;
Expand Down Expand Up @@ -57,10 +57,10 @@ public function __construct(DirInterface $dir, WriterInterface $writer)
$dir->assertExists();
$this->dir = $dir;
$this->writer = $writer;
$this->dirIterator = $this->getRecursiveDirectoryIterator($dir->path()->toString());
$this->dirIterator = $this->getRecursiveDirectoryIterator($dir->path()->__toString());
$this->filterIterator = $this->getRecursiveFilterIterator($this->dirIterator);
$this->recursiveIterator = new RecursiveIteratorIterator($this->filterIterator, RecursiveIteratorIterator::SELF_FIRST);
$this->chop = strlen($this->dir->path()->toString());
$this->chop = strlen($this->dir->path()->__toString());

try {
$this->recursiveIterator->rewind();
Expand All @@ -75,7 +75,7 @@ public function __construct(DirInterface $dir, WriterInterface $writer)
}
// @codeCoverageIgnoreEnd

$this->writer->write('👀 Iterating ' . $dir->path()->toString() . "\n\n");
$this->writer->write('👀 Iterating ' . $dir->path()->__toString() . "\n\n");
$this->iterate();
}

Expand Down Expand Up @@ -156,7 +156,7 @@ private function getDirFlags(Flags $flags): Flags
$filepath = $flags->dir()->path()->getChild($flagger . '.php');
$return = null;
if ($filepath->exists()) {
$filePhp = filePhpReturnForPath($filepath->toString());
$filePhp = filePhpReturnForPath($filepath->__toString());
$return = $filePhp->var();
}
$values[$flagger] = $return;
Expand Down
4 changes: 2 additions & 2 deletions src/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace DocsDeploy;

use function Chevere\Components\Filesystem\filePhpReturnForPath;
use function Chevere\Filesystem\filePhpReturnForPath;

class Modules
{
Expand Down Expand Up @@ -91,7 +91,7 @@ private function setSideFor(string $node): void
$contents = $this->iterator->contents()[$rootNode];
$filepath = $flags->dir()->path()->getChild('sidebar.php');
if ($filepath->exists()) {
$filePhp = filePhpReturnForPath($filepath->toString());
$filePhp = filePhpReturnForPath($filepath->__toString());
$side = $filePhp->var();
} elseif ($flags->hasNested() || $flags->hasReadme()) {
$side = $this->getSide($rootNode, $flags, $contents);
Expand Down
8 changes: 4 additions & 4 deletions tests/IteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace Chevere\Tests;

use function Chevere\Components\Filesystem\dirForPath;
use function Chevere\Components\Writer\streamTemp;
use Chevere\Components\Writer\StreamWriter;
use Chevere\Interfaces\Writer\WriterInterface;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Writer\streamTemp;
use Chevere\Writer\StreamWriter;
use Chevere\Writer\Interfaces\WriterInterface;
use DocsDeploy\Iterator;
use PHPUnit\Framework\TestCase;

Expand Down
10 changes: 5 additions & 5 deletions tests/ModulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace Chevere\Tests;

use function Chevere\Components\Filesystem\dirForPath;
use function Chevere\Components\Writer\streamTemp;
use Chevere\Components\Writer\StreamWriter;
use function Chevere\Filesystem\dirForPath;
use function Chevere\Writer\streamTemp;
use Chevere\Writer\StreamWriter;
use DocsDeploy\Iterator;
use DocsDeploy\Modules;
use PHPUnit\Framework\TestCase;
Expand All @@ -24,11 +24,11 @@ final class ModulesTest extends TestCase
{
public function testConstruct(): void
{
// $dir = dirForPath(__DIR__ . '/_resources/docs/');
$dir = dirForPath('/home/rodolfo/git/chevere/docs-deploy/docs/');
$dir = dirForPath(__DIR__ . '/_resources/docs/');
$writer = new StreamWriter(streamTemp(''));
$iterator = new Iterator($dir, $writer);
$modules = new Modules($iterator);
$this->expectNotToPerformAssertions();
$modules->execute();
}
}
Loading

0 comments on commit 6dd65fb

Please sign in to comment.