diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b1e2f0f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: "Release" + +on: + push: + tags: + - "*" + +env: + COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" + +jobs: + build: + name: Upload Release Asset + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + tools: composer:v2 + coverage: none + + - name: Install Box package + run: composer global config minimum-stability dev && composer global require humbug/box ${{ env.COMPOSER_FLAGS }} + + - name: Install Composer packages + run: composer install --no-dev ${{ env.COMPOSER_FLAGS }} + + - name: Bump the version + run: ./bin/bump-version ${{ github.ref }} + + - name: Build phar file + run: box compile + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + body: TODO + + - name: Upload phar + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./schemarkdown.phar + asset_name: schemarkdown.phar + asset_content_type: application/octet-stream diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f36d9d5..e0aa4c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -76,7 +76,7 @@ jobs: command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - name: Bump the version - run: ./scripts/bump-version + run: ./bin/bump-version - name: Execute phpcs run: php vendor/bin/phpcs diff --git a/Makefile b/Makefile index e30c80d..0bd54e5 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ container: @docker-compose logs -f bump: - @./scripts/bump-version ${VERSION} + @./bin/bump-version ${VERSION} schemarkdown.phar: bump @echo ">>> Building phar ..." diff --git a/README.md b/README.md index 2096999..d63e3be 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,15 @@ # Schemarkdown -[![Build Status](https://travis-ci.com/MilesChou/schemarkdown.svg?branch=master)](https://travis-ci.com/MilesChou/schemarkdown) -[![codecov](https://codecov.io/gh/MilesChou/schemarkdown/branch/master/graph/badge.svg)](https://codecov.io/gh/MilesChou/schemarkdown) -[![Codacy Badge](https://app.codacy.com/project/badge/Grade/4d50659b49da4ce797e7ad1ff5339c78)](https://www.codacy.com/manual/MilesChou/schemarkdown-cli) -[![Latest Stable Version](https://poser.pugx.org/MilesChou/schemarkdown/v/stable)](https://packagist.org/packages/MilesChou/schemarkdown) -[![Total Downloads](https://poser.pugx.org/MilesChou/schemarkdown/d/total.svg)](https://packagist.org/packages/MilesChou/schemarkdown) -[![License](https://poser.pugx.org/MilesChou/schemarkdown/license)](https://packagist.org/packages/MilesChou/schemarkdown) +[![Release](https://github.com/MilesChou/schemarkdown-cli/actions/workflows/release.yml/badge.svg)](https://github.com/MilesChou/schemarkdown-cli/actions/workflows/release.yml) +[![tests](https://github.com/MilesChou/schemarkdown-cli/actions/workflows/tests.yml/badge.svg)](https://github.com/MilesChou/schemarkdown-cli/actions/workflows/tests.yml) -The schema document generator. +The schema document generator and eloquent model generator for CLI, only. + +Use the [schemarkdown](https://github.com/MilesChou/schemarkdown) library. ## Installation -Download the [Release](https://github.com/MilesChou/schemarkdown/releases) phar file and execute it: +Download the [Release](https://github.com/MilesChou/schemarkdown-cli/releases) phar file and execute it: ```bash chmod +x schemarkdown.phar @@ -27,27 +25,48 @@ schemarkdown ## Usage +### `schema:markdown` + In Laravel project, you can run this command immediately: ```bash cd /path/to/your/project -schemarkdown +schemarkdown schema:markdown ``` -Schema document are stored to `generated` directory default. Use the `--output-dir` option to change it. +Schema document are stored to `docs` directory default. Use the `--output-dir` option to change it. -In the other framework, you must provide config file like Laravel. Use `--config-file` option to specify custom config. +In the other framework, you must provide config file like Laravel. Use `--config-file` option to specify customize configuration. This tool will load `.env` before load config. Use the `--env` option to specify .env path. -Use the `--connection` option to specify **connection name** in Laravel config to generate document of one database. +Use the `--connection` option to specify **connection name** in Laravel config to generate the document of one database. + +Use the `--overwrite` option if you want to overwrite the exists document. + +### `schema:model` + +Just like `schema:markdown`, run this command directly: + +```bash +cd /path/to/your-laravel-project +schemarkdown schema:model +``` + +It's will generate model code into `app/Models` directory (Laravel 8 default), use the `--output-dir` option can change output dir. If want to change namespace, use the `--namespace` option. + +In the other framework but using Eloquent ORM library, you must provide config file like laravel project. Use `--config-file` option to specify customize configuration. + +If only want build one connection, use the `--connection` option to specify. + +Use the `--overwrite` option if you want to overwrite exist code. ## Example Here is example [SQL](/examples/examples.sql), import MySQL and run following command: ``` -php bin/schemarkdown.php --config-file=tests/Fixtures/database.php --connection=examples --output-dir=examples +php schemarkdown.phar --config-file=tests/Fixtures/database.php --connection=examples --output-dir=examples ``` It will generate this [Markdown documents](/examples). diff --git a/scripts/bump-version b/bin/bump-version similarity index 100% rename from scripts/bump-version rename to bin/bump-version