Skip to content

Commit f834d70

Browse files
committed
Initial commit
0 parents  commit f834d70

16 files changed

+441
-0
lines changed

.github/changelog.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
options:
2+
title: '## Change Log'
3+
style: gh-release
4+
filters:
5+
# message length >= 12
6+
- name: msgLen
7+
minLen: 12
8+
# message words >= 3
9+
- name: wordsLen
10+
minLen: 3
11+
- name: keywords
12+
keywords: ['format code']
13+
exclude: true
14+
15+
# not matched will use 'Other' group.
16+
groups:
17+
- name: New
18+
keywords: [add, new]
19+
- name: Fixed
20+
startWiths: [add, new]
21+
keywords: [add, new]
22+
- name: Feat
23+
startWiths: [feat]
24+
keywords: [feature]
25+
- name: Update
26+
startWiths: [update, 'up:']
27+
keywords: [update]

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
# Check for updates to GitHub Actions every weekday
13+
interval: "daily"

.github/workflows/php.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Unit-Tests
2+
3+
# https://docs.github.com/cn/actions/reference/workflow-syntax-for-github-actions
4+
on:
5+
push:
6+
paths:
7+
- '**.php'
8+
- 'composer.json'
9+
- '**.yml'
10+
11+
jobs:
12+
test:
13+
name: Test on php ${{ matrix.php}} and ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
timeout-minutes: 10
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
php: [7.3, 7.4, 8.0] # 7.2,
20+
os: [ubuntu-latest, macOS-latest] # windows-latest,
21+
# include: # will not testing on php 7.2
22+
# - os: 'ubuntu-latest'
23+
# php: '7.2'
24+
# phpunit: '8.5.13'
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
30+
- name: Set ENV vars
31+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
32+
run: |
33+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
34+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
35+
36+
- name: Display Env
37+
run: env
38+
39+
# usage refer https://github.com/shivammathur/setup-php
40+
- name: Setup PHP
41+
timeout-minutes: 5
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: ${{ matrix.php}}
45+
tools: pecl, php-cs-fixer, phpunit:${{ matrix.phpunit }}
46+
extensions: mbstring, dom, fileinfo, mysql, openssl, igbinary, redis # , swoole-4.4.19 #optional, setup extensions
47+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
48+
coverage: none #optional, setup coverage driver: xdebug, none
49+
50+
- name: Install dependencies
51+
run: composer update --no-progress
52+
53+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
54+
# Docs: https://getcomposer.org/doc/articles/scripts.md
55+
56+
- name: Run test suite
57+
run: phpunit -v
58+
59+
# git status && git log -1 && git fetch --tags --force
60+
# git status && git log -1 && git fetch --prune --unshallow
61+
# git status && git log -1 && git fetch --depth=500 --tags --force
62+
# - name: Generate changelog
63+
# if: ${{ matrix.os == 'ubuntu-latest' && matrix.php == '7.4' }}
64+
# run: |
65+
# echo "changelog list by kite"
66+
# php bin/kite git chlog last head --style gh-release --no-merges --fetch-tags --unshallow --file tmp/changelog.md
67+
# cat tmp/changelog.md

.github/workflows/release.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Tag-release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Test on php ${{ matrix.php}}
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [7.4]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set ENV for github-release
23+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
24+
run: |
25+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
26+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
27+
28+
# usage refer https://github.com/shivammathur/setup-php
29+
- name: Setup PHP
30+
timeout-minutes: 5
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php}}
34+
tools: pecl, php-cs-fixer, phpunit
35+
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
36+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
37+
coverage: none #optional, setup coverage driver: xdebug, none
38+
39+
- name: Install dependencies # eg: v1.0.3
40+
run: |
41+
echo $RELEASE_TAG
42+
echo $RELEASE_NAME
43+
tag1=${GITHUB_REF#refs/*/}
44+
echo "release tag: ${tag1}"
45+
composer update --no-progress
46+
47+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
48+
# Docs: https://getcomposer.org/doc/articles/scripts.md
49+
50+
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context
51+
# - name: Generate changelog file
52+
# id: changelog
53+
# run: |
54+
# php bin/kite gh cl prev $RELEASE_TAG --style gh-release --no-merges --fetch-tags --unshallow --file tmp/changelog-${RELEASE_TAG}.md
55+
# cat tmp/changelog-${RELEASE_TAG}.md
56+
57+
# https://github.com/meeDamian/github-release
58+
# - name: Create release and upload assets
59+
# uses: meeDamian/[email protected]
60+
# with:
61+
# gzip: false
62+
# token: ${{ secrets.GITHUB_TOKEN }}
63+
# tag: ${{ env.RELEASE_TAG }}
64+
# name: ${{ env.RELEASE_TAG }}
65+
# body: |
66+
# ${{ steps.changelog.outputs.CHLOGBODY }}
67+
# files: kite-${{ env.RELEASE_TAG }}.phar
68+
69+
# https://github.com/softprops/action-gh-release
70+
- name: Create release and upload assets
71+
uses: softprops/action-gh-release@v1
72+
# if: startsWith(github.ref, 'refs/tags/')
73+
with:
74+
name: ${{ env.RELEASE_TAG }}
75+
tag_name: ${{ env.RELEASE_TAG }}
76+
# body_path: tmp/changelog-${{ env.RELEASE_TAG }}.md
77+
# files: kite-${{ env.RELEASE_TAG }}.phar
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
# GITHUB_REPOSITORY: my_gh_org/my_gh_repo

.gitignore

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.buildpath
2+
.settings/
3+
.project
4+
*.patch
5+
.idea/
6+
.git/
7+
tmp/
8+
vendor/
9+
*.lock
10+
*.phar
11+
*.log
12+
*.tgz
13+
*.txt
14+
*.cache
15+
.phpintel/
16+
.env
17+
.phpstorm.meta.php
18+
.DS_Store
19+
.kite.php
20+
bin/php-cs-fixer
21+
/plugin/local/
22+
node_modules/

.php-cs-fixer.php

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of phpcom-lab/cli-markdown.
5+
6+
@link https://github.com/inhere
7+
@author https://github.com/inhere
8+
@license MIT
9+
EOF;
10+
11+
return (new PhpCsFixer\Config())
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@PSR2' => true,
15+
'array_syntax' => [
16+
'syntax' => 'short'
17+
],
18+
'list_syntax' => [
19+
'syntax' => 'short'
20+
],
21+
'class_attributes_separation' => true,
22+
'declare_strict_types' => true,
23+
'global_namespace_import' => [
24+
'import_constants' => true,
25+
'import_functions' => true,
26+
],
27+
'header_comment' => [
28+
'comment_type' => 'PHPDoc',
29+
'header' => $header,
30+
'separate' => 'bottom'
31+
],
32+
'no_unused_imports' => true,
33+
'single_quote' => true,
34+
'standardize_not_equals' => true,
35+
'void_return' => true, // add :void for method
36+
])
37+
->setFinder(
38+
PhpCsFixer\Finder::create()
39+
->exclude('test')
40+
->exclude('runtime')
41+
->exclude('vendor')
42+
->in(__DIR__)
43+
)
44+
->setUsingCache(false);

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 PHPComLab
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# link https://github.com/humbug/box/blob/master/Makefile
2+
#SHELL = /bin/sh
3+
# 每行命令之前必须有一个tab键。如果想用其他键,可以用内置变量.RECIPEPREFIX 声明
4+
# mac 下这条声明 没起作用 !!
5+
.RECIPEPREFIX = >
6+
.PHONY: all usage help clean
7+
8+
# 需要注意的是,每行命令在一个单独的shell中执行。这些Shell之间没有继承关系。
9+
# - 解决办法是将两行命令写在一行,中间用分号分隔。
10+
# - 或者在换行符前加反斜杠转义 \
11+
12+
# 接收命令行传入参数 make COMMAND tag=v2.0.4
13+
# TAG=$(tag) # 使用 $(TAG)
14+
15+
# 定义变量
16+
#SHELL := /bin/bash
17+
18+
# Full build flags used when building binaries. Not used for test compilation/execution.
19+
#BUILDFLAGS := -ldflags \
20+
# " -X $(ROOT_PACKAGE)/pkg/cmd/version.Version=$(VERSION)
21+
22+
# if 条件
23+
#ifdef DEBUG
24+
#BUILDFLAGS := -gcflags "all=-N -l" $(BUILDFLAGS)
25+
#endif
26+
27+
.DEFAULT_GOAL := help
28+
help:
29+
@echo "There some make command for the project\n"
30+
@echo "Available Commands:"
31+
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
32+
33+
clean: ## Clean all created artifacts
34+
git clean --exclude=.idea/ -fdx
35+
36+
cs-fix: ## Fix code style for all files
37+
gofmt -w ./
38+
39+
cs-diff: ## Display code style error files
40+
gofmt -l ./

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# php-pkg-template
2+
3+
[![License](https://img.shields.io/packagist/l/inherelab/php-pkg-template.svg?style=flat-square)](LICENSE)
4+
[![Php Version](https://img.shields.io/badge/php-%3E=7.2.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/inherelab/php-pkg-template)
5+
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/inherelab/php-pkg-template)](https://github.com/inherelab/php-pkg-template)
6+
[![Actions Status](https://github.com/inherelab/php-pkg-template/workflows/Unit-Tests/badge.svg)](https://github.com/inherelab/php-pkg-template/actions)
7+
8+
TODO: package description
9+
10+
## Install
11+
12+
**composer**
13+
14+
```bash
15+
composer require inherelab/php-pkg-template
16+
```
17+
18+
## Usage
19+
20+
- clone this repository to local
21+
- update readme description
22+
- search all `inherelab/php-pkg-template` and replace to your package name.
23+
- update `composer.json` contents: name, description, require, autoload
24+
25+
## License
26+
27+
[MIT](LICENSE)

composer.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "inherelab/php-pkg-template",
3+
"description": "TODO: package description",
4+
"type": "template",
5+
"license": "MIT",
6+
"homepage": "https://github.com/inherelab/php-pkg-template",
7+
"authors": [
8+
{
9+
"name": "inhere",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php": ">7.1.0",
15+
"ext-mbstring": "*",
16+
"toolkit/cli-utils":"~1.0"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"PkgOwner\\PkgName\\": "src/"
21+
}
22+
},
23+
"bin": [
24+
25+
],
26+
"scripts": {
27+
"test": "php vender/bin/phpunit"
28+
}
29+
}

example/demo.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use PhpComLab\CliMarkdown\CliMarkdown;
4+
5+
require dirname(__DIR__) . '/vendor/autoload.php';
6+
7+
$contents = file_get_contents(dirname(__DIR__) . '/README.md');
8+
$praser = new CliMarkdown;
9+
10+
$rendered = $praser->render($contents);
11+
12+
echo $rendered;
13+

0 commit comments

Comments
 (0)