-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c4166c
Showing
14 changed files
with
331 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/tests export-ignore | ||
/docs export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build | ||
composer.lock | ||
vendor | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
runs: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
preset: psr2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm | ||
|
||
# This triggers builds to run on the new TravisCI infrastructure. | ||
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ | ||
sudo: false | ||
|
||
## Cache composer | ||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' | ||
|
||
before_script: | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist | ||
|
||
script: | ||
- vendor/bin/phpcs --standard=psr2 src/ | ||
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
after_script: | ||
- | | ||
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover coverage.clover | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Changelog | ||
|
||
All Notable changes to `webpack-manifest` will be documented in this file. | ||
|
||
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. | ||
|
||
## NEXT - YYYY-MM-DD | ||
|
||
### Added | ||
- Nothing | ||
|
||
### Deprecated | ||
- Nothing | ||
|
||
### Fixed | ||
- Nothing | ||
|
||
### Removed | ||
- Nothing | ||
|
||
### Security | ||
- Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2017 <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# webpack-manifest | ||
|
||
A set of tools to help with handling manifest.json files generated by webpack plugin | ||
[danethurber/webpack-manifest-plugin](https://github.com/danethurber/webpack-manifest-plugin). | ||
|
||
|
||
## Install | ||
|
||
Via Composer | ||
|
||
``` bash | ||
$ composer require ovos/webpack-manifest | ||
``` | ||
|
||
## Usage | ||
|
||
``` php | ||
$skeleton = new Ovos\Webpack(); | ||
echo $skeleton->echoPhrase('Hello, League!'); | ||
``` | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
|
||
[ico-version]: https://img.shields.io/packagist/v/ovos/webpack-manifest.svg?style=flat-square | ||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square | ||
[ico-travis]: https://img.shields.io/travis/ovos/webpack-manifest/master.svg?style=flat-square | ||
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/ovos/webpack-manifest.svg?style=flat-square | ||
[ico-code-quality]: https://img.shields.io/scrutinizer/g/ovos/webpack-manifest.svg?style=flat-square | ||
[ico-downloads]: https://img.shields.io/packagist/dt/ovos/webpack-manifest.svg?style=flat-square | ||
|
||
[link-packagist]: https://packagist.org/packages/ovos/webpack-manifest | ||
[link-travis]: https://travis-ci.org/ovos/webpack-manifest | ||
[link-scrutinizer]: https://scrutinizer-ci.com/g/ovos/webpack-manifest/code-structure | ||
[link-code-quality]: https://scrutinizer-ci.com/g/ovos/webpack-manifest | ||
[link-downloads]: https://packagist.org/packages/ovos/webpack-manifest | ||
[link-author]: https://github.com/mh-ovos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "ovos/webpack-manifest", | ||
"type": "library", | ||
"description": "Processing webpack manifest.json files", | ||
"homepage": "https://github.com/ovos/webpack-manifest", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Maciej Holyszko", | ||
"email": "[email protected]", | ||
"homepage": "https://github.com/mh-ovos", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.4", | ||
"eloquent/pathogen": "^0.6.1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit" : "~4.0||~5.0||~6.0", | ||
"squizlabs/php_codesniffer": "^2.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Ovos\\Webpack\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Ovos\\Webpack\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "phpunit", | ||
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests", | ||
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0-dev" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="ovos Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
<logging> | ||
<log type="tap" target="build/report.tap"/> | ||
<log type="junit" target="build/report.junit.xml"/> | ||
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/> | ||
<log type="coverage-text" target="build/coverage.txt"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
namespace Ovos\Webpack; | ||
|
||
use Eloquent\Pathogen\FileSystem\FileSystemPath; | ||
use Eloquent\Pathogen\Path; | ||
use Eloquent\Pathogen\Resolver\BasePathResolver; | ||
|
||
class Manifest | ||
{ | ||
const MANIFEST_FILENAME = 'manifest.json'; | ||
|
||
/** | ||
* [manifest file dirname => [src file => target file]] | ||
* @var array[] | ||
*/ | ||
protected static $manifests = []; | ||
|
||
/** | ||
* Resolve path to the file from manifest.json | ||
* | ||
* @param string $path | ||
* @param string $base base dir which should be prepended to $path | ||
* @param string $manifestFilename | ||
* | ||
* @return string | ||
*/ | ||
public static function resolve($path, $base = null, $manifestFilename = self::MANIFEST_FILENAME) | ||
{ | ||
$relativePath = Path::fromString($path); | ||
$basePath = FileSystemPath::fromString($base ? $base : getcwd()); | ||
|
||
$resolver = new BasePathResolver; | ||
$fullPath = $resolver->resolve($basePath, $relativePath); | ||
|
||
$dirname = dirname($fullPath->string()); | ||
$manifest = self::getManifest($dirname, $manifestFilename); | ||
|
||
$filename = $relativePath->name(); | ||
if (isset($manifest[$filename])) { | ||
$path = $relativePath->replaceName($manifest[$filename])->string(); | ||
} | ||
|
||
return $path; | ||
} | ||
|
||
/** | ||
* Return contents of manifest file from a given dir | ||
* | ||
* @param string $dir | ||
* @param string $manifestFilename | ||
* @return array | ||
*/ | ||
public static function getManifest($dir, $manifestFilename = MANIFEST_FILENAME) | ||
{ | ||
$manifestPath = $dir . DIRECTORY_SEPARATOR . $manifestFilename; | ||
// normalize slashes | ||
$manifestPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $manifestPath); | ||
if (!isset(self::$manifests[$manifestPath])) { | ||
$manifest = []; | ||
if (file_exists($manifestPath)) { | ||
$manifest = json_decode(file_get_contents($manifestPath), true); | ||
} | ||
|
||
self::$manifests[$manifestPath] = $manifest; | ||
} | ||
|
||
return self::$manifests[$manifestPath]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Ovos\Webpack; | ||
|
||
class ManifestTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testResolve() | ||
{ | ||
$src = 'assets/test.js'; | ||
$target = Manifest::resolve($src, __DIR__); | ||
$this->assertEquals('assets/test.12345.js', $target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"test.js": "test.12345.js", | ||
"test2.js": "test2.67890.js" | ||
} |