mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-07-24 15:41:41 +02:00
Prefill package information
This commit is contained in:
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@@ -12,11 +12,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: [8.0, 8.1]
|
||||
laravel: [8.*, 9.*]
|
||||
dependency-version: [prefer-stable]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
|
||||
name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -26,14 +25,12 @@ jobs:
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip
|
||||
extensions: json, mbstring
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer require "illuminate/contracts=${{ matrix.laravel }}" --no-interaction --no-update
|
||||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
|
||||
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/pest --verbose
|
||||
@@ -53,7 +50,7 @@ jobs:
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.0
|
||||
extensions: dom, curl, libxml, mbstring, zip
|
||||
extensions: json, mbstring
|
||||
tools: composer:v2
|
||||
coverage: xdebug
|
||||
|
||||
@@ -64,8 +61,7 @@ jobs:
|
||||
run: vendor/bin/pest --coverage-text --coverage-clover=coverage.clover
|
||||
|
||||
- name: Upload coverage
|
||||
run: |
|
||||
vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
|
||||
run: vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
|
||||
|
||||
style:
|
||||
runs-on: ubuntu-latest
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to `:package_name` will be documented in this file.
|
||||
All notable changes to `json-parser` will be documented in this file.
|
||||
|
||||
Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
Contributions are **welcome** and will be fully **credited**.
|
||||
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/cerbero90/:package_name).
|
||||
We accept contributions via Pull Requests on [Github](https://github.com/cerbero90/json-parser).
|
||||
|
||||
|
||||
## Pull Requests
|
||||
|
45
README.md
45
README.md
@@ -1,9 +1,7 @@
|
||||
# :package_title
|
||||
# 🧩 JSON Parser
|
||||
|
||||
[![Author][ico-author]][link-author]
|
||||
[![PHP Version][ico-php]][link-php]
|
||||
[![Laravel Version][ico-laravel]][link-laravel]
|
||||
[![Octane Compatibility][ico-octane]][link-octane]
|
||||
[![Build Status][ico-actions]][link-actions]
|
||||
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
|
||||
[![Quality Score][ico-code-quality]][link-code-quality]
|
||||
@@ -12,7 +10,7 @@
|
||||
[![PSR-12][ico-psr12]][link-psr12]
|
||||
[![Total Downloads][ico-downloads]][link-downloads]
|
||||
|
||||
:package_description
|
||||
Zero-dependencies pull parser and lexer to save memory while reading big JSONs.
|
||||
|
||||
|
||||
## 📦 Install
|
||||
@@ -20,21 +18,12 @@
|
||||
Via Composer:
|
||||
|
||||
``` bash
|
||||
composer require cerbero/:package_name
|
||||
composer require cerbero/json-parser
|
||||
```
|
||||
|
||||
## 🔮 Usage
|
||||
|
||||
1. Create a new package by [using this template](https://github.com/cerbero90/skeleton/generate)
|
||||
1. Clone the newly created repository
|
||||
1. Run `php prefill.php`
|
||||
1. Delete `prefill.php`
|
||||
1. Review versions of PHP and Laravel to support in [composer.json](composer.json), [build.yml](.github/workflows/build.yml) and [README badges](README.md)
|
||||
1. Push changes to master
|
||||
1. Submit package to [Packagist](https://packagist.org/packages/submit)
|
||||
1. Add repository to [Scrutinizer](https://scrutinizer-ci.com/g/new)
|
||||
1. Initialize GitFlow
|
||||
1. Happy coding!
|
||||
work in progress... :)
|
||||
|
||||
## 📆 Change log
|
||||
|
||||
@@ -64,25 +53,21 @@ If you discover any security related issues, please email andrea.marco.sartori@g
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
|
||||
[ico-author]: https://img.shields.io/static/v1?label=author&message=cerbero90&color=50ABF1&logo=twitter&style=flat-square
|
||||
[ico-php]: https://img.shields.io/packagist/php-v/cerbero/:package_name?color=%234F5B93&logo=php&style=flat-square
|
||||
[ico-laravel]: https://img.shields.io/static/v1?label=laravel&message=%E2%89%A55.5&color=ff2d20&logo=laravel&style=flat-square
|
||||
[ico-octane]: https://img.shields.io/static/v1?label=octane&message=compatible&color=ff2d20&logo=laravel&style=flat-square
|
||||
[ico-version]: https://img.shields.io/packagist/v/cerbero/:package_name.svg?label=version&style=flat-square
|
||||
[ico-actions]: https://img.shields.io/github/workflow/status/cerbero90/:package_name/build?style=flat-square&logo=github
|
||||
[ico-php]: https://img.shields.io/packagist/php-v/cerbero/json-parser?color=%234F5B93&logo=php&style=flat-square
|
||||
[ico-version]: https://img.shields.io/packagist/v/cerbero/json-parser.svg?label=version&style=flat-square
|
||||
[ico-actions]: https://img.shields.io/github/workflow/status/cerbero90/json-parser/build?style=flat-square&logo=github
|
||||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
|
||||
[ico-psr12]: https://img.shields.io/static/v1?label=compliance&message=PSR-12&color=blue&style=flat-square
|
||||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/cerbero90/:package_name.svg?style=flat-square&logo=scrutinizer
|
||||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/cerbero90/:package_name.svg?style=flat-square&logo=scrutinizer
|
||||
[ico-downloads]: https://img.shields.io/packagist/dt/cerbero/:package_name.svg?style=flat-square
|
||||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/cerbero90/json-parser.svg?style=flat-square&logo=scrutinizer
|
||||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/cerbero90/json-parser.svg?style=flat-square&logo=scrutinizer
|
||||
[ico-downloads]: https://img.shields.io/packagist/dt/cerbero/json-parser.svg?style=flat-square
|
||||
|
||||
[link-author]: https://twitter.com/cerbero90
|
||||
[link-php]: https://www.php.net
|
||||
[link-laravel]: https://laravel.com
|
||||
[link-octane]: https://github.com/laravel/octane
|
||||
[link-packagist]: https://packagist.org/packages/cerbero/:package_name
|
||||
[link-actions]: https://github.com/cerbero90/:package_name/actions?query=workflow%3Abuild
|
||||
[link-packagist]: https://packagist.org/packages/cerbero/json-parser
|
||||
[link-actions]: https://github.com/cerbero90/json-parser/actions?query=workflow%3Abuild
|
||||
[link-psr12]: https://www.php-fig.org/psr/psr-12/
|
||||
[link-scrutinizer]: https://scrutinizer-ci.com/g/cerbero90/:package_name/code-structure
|
||||
[link-code-quality]: https://scrutinizer-ci.com/g/cerbero90/:package_name
|
||||
[link-downloads]: https://packagist.org/packages/cerbero/:package_name
|
||||
[link-scrutinizer]: https://scrutinizer-ci.com/g/cerbero90/json-parser/code-structure
|
||||
[link-code-quality]: https://scrutinizer-ci.com/g/cerbero90/json-parser
|
||||
[link-downloads]: https://packagist.org/packages/cerbero/json-parser
|
||||
[link-contributors]: ../../contributors
|
||||
|
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "cerbero/:package_name",
|
||||
"name": "cerbero/json-parser",
|
||||
"type": "library",
|
||||
"description": ":package_description",
|
||||
"description": "Zero-dependencies pull parser and lexer to save memory while reading big JSONs.",
|
||||
"keywords": [
|
||||
"laravel"
|
||||
"json",
|
||||
"parser",
|
||||
"lexer"
|
||||
],
|
||||
"homepage": "https://github.com/cerbero90/:package_name",
|
||||
"homepage": "https://github.com/cerbero90/json-parser",
|
||||
"license": "MIT",
|
||||
"authors": [{
|
||||
"name": "Andrea Marco Sartori",
|
||||
@@ -14,23 +16,23 @@
|
||||
"role": "Developer"
|
||||
}],
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"illuminate/support": ">=8.0"
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": ">=6.0",
|
||||
"pestphp/pest": "^1.21",
|
||||
"scrutinizer/ocular": "^1.8",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cerbero\\:package_ns\\": "src"
|
||||
"Cerbero\\JsonParser\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Cerbero\\:package_ns\\": "tests"
|
||||
"Cerbero\\JsonParser\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
@@ -41,11 +43,6 @@
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Cerbero\\:package_ns\\Providers\\:package_nsServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name=":package_name">
|
||||
<description>The coding standard of :package_name package</description>
|
||||
<ruleset name="json-parser">
|
||||
<description>The coding standard of json-parser package</description>
|
||||
<arg value="p" />
|
||||
|
||||
<config name="ignore_warnings_on_exit" value="1" />
|
||||
|
110
prefill.php
110
prefill.php
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
define('COL_DESCRIPTION', 0);
|
||||
define('COL_HELP', 1);
|
||||
define('COL_DEFAULT', 2);
|
||||
|
||||
$fields = [
|
||||
'package_name' => ['Package name', '<package> in https://github.com/vendor/package', basename(__DIR__)],
|
||||
'package_description' => ['Package very short description', '', ''],
|
||||
];
|
||||
|
||||
$values = [];
|
||||
|
||||
$replacements = [
|
||||
':package_name' => function () use (&$values) {
|
||||
return $values['package_name'];
|
||||
},
|
||||
':package_ns' => function () use (&$values) {
|
||||
$value = ucwords(str_replace(['-', '_'], ' ', $values['package_name']));
|
||||
return str_replace(' ', '', $value);
|
||||
},
|
||||
':package_title' => function () use (&$values) {
|
||||
return ucwords(str_replace(['-', '_'], ' ', $values['package_name']));
|
||||
},
|
||||
':package_description' => function () use (&$values) {
|
||||
return $values['package_description'];
|
||||
},
|
||||
];
|
||||
|
||||
function read_from_console($prompt)
|
||||
{
|
||||
if (function_exists('readline')) {
|
||||
$line = trim(readline($prompt));
|
||||
if (!empty($line)) {
|
||||
readline_add_history($line);
|
||||
}
|
||||
} else {
|
||||
echo $prompt;
|
||||
$line = trim(fgets(STDIN));
|
||||
}
|
||||
return $line;
|
||||
}
|
||||
|
||||
function interpolate($text, $values)
|
||||
{
|
||||
if (!preg_match_all('/\{(\w+)\}/', $text, $m)) {
|
||||
return $text;
|
||||
}
|
||||
foreach ($m[0] as $k => $str) {
|
||||
$f = $m[1][$k];
|
||||
$text = str_replace($str, $values[$f], $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
$modify = 'n';
|
||||
do {
|
||||
if ($modify == 'q') {
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
|
||||
echo "----------------------------------------------------------------------\n";
|
||||
echo "Please, provide the following information:\n";
|
||||
echo "----------------------------------------------------------------------\n";
|
||||
foreach ($fields as $f => $field) {
|
||||
$default = isset($field[COL_DEFAULT]) ? interpolate($field[COL_DEFAULT], $values) : '';
|
||||
$prompt = sprintf(
|
||||
'%s%s%s: ',
|
||||
$field[COL_DESCRIPTION],
|
||||
$field[COL_HELP] ? ' (' . $field[COL_HELP] . ')' : '',
|
||||
$field[COL_DEFAULT] !== '' ? ' [' . $default . ']' : ''
|
||||
);
|
||||
$values[$f] = read_from_console($prompt);
|
||||
if (empty($values[$f])) {
|
||||
$values[$f] = $default;
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
echo "----------------------------------------------------------------------\n";
|
||||
echo "Please, check that everything is correct:\n";
|
||||
echo "----------------------------------------------------------------------\n";
|
||||
foreach ($fields as $f => $field) {
|
||||
echo $field[COL_DESCRIPTION] . ": $values[$f]\n";
|
||||
}
|
||||
echo "\n";
|
||||
} while (($modify = strtolower(read_from_console('Modify files with these values? [y/N/q] '))) != 'y');
|
||||
echo "\n";
|
||||
|
||||
$files = array_merge(
|
||||
glob(__DIR__ . '/*.md'),
|
||||
glob(__DIR__ . '/*.xml.dist'),
|
||||
glob(__DIR__ . '/composer.json'),
|
||||
glob(__DIR__ . '/src/Providers/*.php'),
|
||||
glob(__DIR__ . '/tests/*.php')
|
||||
);
|
||||
foreach ($files as $f) {
|
||||
$contents = file_get_contents($f);
|
||||
foreach ($replacements as $str => $func) {
|
||||
$contents = str_replace($str, $func(), $contents);
|
||||
}
|
||||
file_put_contents($f, $contents);
|
||||
}
|
||||
|
||||
rename('./src/Providers/RenameMeServiceProvider.php', './src/Providers/' . $replacements[':package_ns']() . 'ServiceProvider.php');
|
||||
rename('./tests/RenameMeTest.php', './tests/' . $replacements[':package_ns']() . 'Test.php');
|
||||
|
||||
echo "Done.\n";
|
||||
echo "Now you should remove the file '" . basename(__FILE__) . "'.\n";
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Cerbero\:package_ns\Providers;
|
||||
namespace Cerbero\JsonParser\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Support\ServiceProvider;
|
||||
* The service provider.
|
||||
*
|
||||
*/
|
||||
class :package_nsServiceProvider extends ServiceProvider
|
||||
class JsonParserServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Cerbero\:package_ns;
|
||||
namespace Cerbero\JsonParser;
|
||||
|
||||
use Cerbero\:package_ns\Providers\:package_nsServiceProvider;
|
||||
use Cerbero\JsonParser\Providers\JsonParserServiceProvider;
|
||||
use Orchestra\Testbench\TestCase;
|
||||
|
||||
/**
|
||||
* The package test suite.
|
||||
*
|
||||
*/
|
||||
class :package_nsTest extends TestCase
|
||||
class JsonParserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Retrieve the package providers.
|
||||
@@ -20,7 +20,7 @@ class :package_nsTest extends TestCase
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
:package_nsServiceProvider::class,
|
||||
JsonParserServiceProvider::class,
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user