Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Upgraded project to our latest standards (#99)
Browse files Browse the repository at this point in the history
* Upgraded project to our latest standards

* Updated Node.js version
  • Loading branch information
ping-localhost committed May 8, 2019
1 parent e957a10 commit 0660a96
Show file tree
Hide file tree
Showing 136 changed files with 205 additions and 205 deletions.
24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.idea/
.vagrant/
bin/
vendor/
var/
/node_modules/
test/fixtures/var/
test/fixtures/web/
package-lock.json
# Files
composer.lock
yarn.lock
composer.phar
package-lock.json
yarn.lock
/test/Bundler/dev1-cache
/test/Bundler/dev2-cache/eb43a_dev2.require.js.sources

# Folders
/.idea/
/.vagrant/
/bin/
/coverage/
/node_modules/
/tests/fixtures/var/
/tests/fixtures/web/
/var/
/vendor/
22 changes: 9 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
language: php

node_js:
- "node"
- "8"

sudo: false

cache:
Expand All @@ -13,48 +9,48 @@ cache:

matrix:
include:
# PHP 7.1 tests
# PHP 7.2 tests
- language: php
php: 7.1
php: 7.2
env: COMPOSER_FLAGS="--prefer-lowest"
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit
- language: php
php: 7.1
php: 7.2
env: COMPOSER_FLAGS="--prefer-stable"
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit
- language: php
php: 7.1
php: 7.2
env: COMPOSER_FLAGS=""
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit
- language: php
php: 7.1
php: 7.2
env: SYMFONY_VERSION="4.0.*"
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit

# PHP 7.2 tests
# PHP 7.3 tests
- language: php
php: 7.2
php: 7.3
env: COMPOSER_FLAGS=""
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit
- language: php
php: 7.2
php: 7.3
env: SYMFONY_VERSION="4.0.*"
before_script:
- composer update $COMPOSER_FLAGS --prefer-dist
script: vendor/bin/phpunit

# JS tests
- language: node_js
node_js: 8.5.0
node_js: node # Latest
env: YARN_TEST="TRUE"
script: npm test
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
THIS PROJECT IS WORK IN PROGRESS, NOTHING IS FINAL! USE AT OWN RISK.
# hostnet/asset-lib
[![Travis Status](https://travis-ci.org/hostnet/asset-lib.svg?branch=master)](https://travis-ci.org/hostnet/asset-lib)
[![AppVeyor Status](https://ci.appveyor.com/api/projects/status/github/hostnet/asset-lib?svg=true)](https://ci.appveyor.com/project/yannickl88/asset-lib)

# hostnet/resolver-lib
Resolver for assets
> This project is work in progress, nothing is final! Use at own risk.
An asset resolver inspired by webpack. This is used in conjunction with Symfony and the [asset-bundle](https://github.com/hostnet/asset-bundle).

## Assumptions:
- `node_modules` folder is always at ./, so: `./node_modules`
This library makes a single assumption, the `node_modules` should always be at the root of a project (so: `./node_modules`).
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"description": "Tool for finding all dependencies given a set of input files.",
"license": "MIT",
"require": {
"php": ">=7.1",
"psr/log": "^1.0",
"psr/simple-cache": "^1.0",
"symfony/console": "^4.0|^3.3",
"symfony/event-dispatcher": "^4.0|^3.3"
"php": ">=7.2",
"psr/log": "^1.0.0",
"psr/simple-cache": "^1.0.0",
"symfony/console": "^4.0.0",
"symfony/event-dispatcher": "^4.0.0"
},
"require-dev": {
"hostnet/phpcs-tool": "^6.0.2",
"mikey179/vfsStream": "^1.6",
"phpunit/phpunit": "^6.2",
"symfony/phpunit-bridge": "^4.0",
"symfony/process": "^4.0|^3.3"
"hostnet/phpcs-tool": "^8.3.3",
"mikey179/vfsstream": "^1.6.6",
"phpunit/phpunit": "^8.1.3",
"symfony/phpunit-bridge": "^4.2.8",
"symfony/process": "^4.2.8"
},
"autoload": {
"psr-4": {
Expand All @@ -24,7 +24,7 @@
},
"autoload-dev": {
"psr-4": {
"Hostnet\\Component\\Resolver\\": "test/"
"Hostnet\\Component\\Resolver\\": "tests/"
}
}
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "resolver-lib",
"version": "1.0.0",
"description": "THIS PROJECT IS WORK IN PROGRESS, NOTHING IS FINAL! USE AT OWN RISK.",
"name": "asset-lib",
"version": "0.3.0",
"description": "An asset resolver inspired by webpack (WIP)",
"repository": {
"type": "git",
"url": "git+https://github.com/hostnet/resolver-lib.git"
"url": "git+https://github.com/hostnet/asset-lib.git"
},
"author": "Hostnet BV.",
"license": "MIT",
"bugs": {
"url": "https://github.com/hostnet/resolver-lib/issues"
"url": "https://github.com/hostnet/asset-lib/issues"
},
"scripts": {
"test": "node_modules/.bin/jasmine",
Expand All @@ -18,16 +18,16 @@
},
"dependencies": {
"brotli": "1.3.2",
"clean-css": "^4.1.9",
"less": "^3.8.0",
"clean-css": "^4.2.1",
"less": "^3.9.0",
"split": "^1.0.1",
"terser": "^3.17.0",
"typescript": "^2.5.0"
"typescript": "^3.4.5"
},
"devDependencies": {
"istanbul": "^0.4.5",
"jasmine": "^2.0.0",
"jasmine": "^3.4.0",
"jasmine-promises": "^0.4.1"
},
"homepage": "https://github.com/hostnet/resolver-lib#readme"
"homepage": "https://github.com/hostnet/asset-lib"
}
12 changes: 8 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" forceCoversAnnotation="true">
<phpunit forceCoversAnnotation="true"
colors="true"
bootstrap="vendor/autoload.php"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite>
<directory>./test</directory>
<testsuite name="Asset Lib - Unit tests">
<directory>./tests</directory>
</testsuite>
</testsuites>

Expand All @@ -13,6 +17,6 @@
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
6 changes: 3 additions & 3 deletions src/Builder/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ final class Asset
*/
public function __construct(DependencyNodeInterface $file)
{
$this->file = $file->getFile();
$this->files = [];
$this->file = $file->getFile();
$this->files = [];

$walker = new TreeWalker(function (DependencyNodeInterface $dependency) {
$walker = new TreeWalker(function (DependencyNodeInterface $dependency): void {
$this->files[] = $dependency;
});

Expand Down
32 changes: 16 additions & 16 deletions src/Builder/BuildConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class BuildConfig implements \JsonSerializable
/**
* @var AbstractBuildStep[]
*/
private $steps = [];
private $writers = [];
private $actions = [];
private $steps = [];
private $writers = [];
private $actions = [];
private $extension_mapping = [];
private $paths;
private $checksum;
Expand Down Expand Up @@ -103,8 +103,8 @@ public function compile(): void
}

$supported_extensions = [];
$edges = [];
$i = 0;
$edges = [];
$i = 0;
foreach ($this->steps as $step) {
$ext = $step->acceptedExtension();

Expand Down Expand Up @@ -210,7 +210,7 @@ private function findPaths(array $edges, int $starting_state, int $ending_state)
$visitable_edges = array_values(array_filter($edges, function (array $edge) use ($starting_state) {
return $edge[1] === $starting_state;
}));
$seen = array_column($visitable_edges, 0);
$seen = array_column($visitable_edges, 0);

while (true) {
$has_changed = false;
Expand All @@ -224,9 +224,9 @@ private function findPaths(array $edges, int $starting_state, int $ending_state)
continue;
}

$has_changed = true;
$has_changed = true;
$visitable_edges[] = $edge;
$seen[] = $edge[0];
$seen[] = $edge[0];
}
}

Expand All @@ -239,7 +239,7 @@ private function findPaths(array $edges, int $starting_state, int $ending_state)
$visitable_edges_r = array_values(array_filter($visitable_edges, function (array $edge) use ($ending_state) {
return $edge[3] === $ending_state;
}));
$seen = array_column($visitable_edges_r, 0);
$seen = array_column($visitable_edges_r, 0);

while (true) {
$has_changed = false;
Expand All @@ -253,9 +253,9 @@ private function findPaths(array $edges, int $starting_state, int $ending_state)
continue;
}

$has_changed = true;
$has_changed = true;
$visitable_edges_r[] = $edge;
$seen[] = $edge[0];
$seen[] = $edge[0];
}
}

Expand Down Expand Up @@ -289,8 +289,8 @@ private function findLongestPath(array $edges, string $extension, int $starting_
$options[] = $edge;
}

$plan = $this->makeChoices($options, $edges, $ending_state);
$seen_edges = array_column($options, 0);
$plan = $this->makeChoices($options, $edges, $ending_state);
$seen_edges = array_column($options, 0);
$seen_actions = array_column($options, 5);

if (empty($plan)) {
Expand Down Expand Up @@ -322,9 +322,9 @@ private function findLongestPath(array $edges, string $extension, int $starting_
continue;
}

$has_changed = true;
$plan = array_merge($plan, $this->makeChoices($options, $edges, $ending_state));
$seen_edges = array_merge($seen_edges, array_column($options, 0));
$has_changed = true;
$plan = array_merge($plan, $this->makeChoices($options, $edges, $ending_state));
$seen_edges = array_merge($seen_edges, array_column($options, 0));
$seen_actions = array_merge($seen_edges, array_column($options, 5));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Builder/BuildFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BuildFiles implements \JsonSerializable
private $finder;
private $extension_map;
private $config;
private $files = [];
private $files = [];
private $compiled = false;

public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Bundler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function bundle(BuildConfig $build_config): void
$filesystem->dumpFile($config_file, json_encode($build_config, JSON_PRETTY_PRINT));

$new_build_config = true;
$extension_map = $build_config->getExtensionMap();
$extension_map = $build_config->getExtensionMap();
} else {
$extension_map = new ExtensionMap($json_data['mapping']);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public function bundle(BuildConfig $build_config): void

$reader = new OutputReader($this->config->getReporter());

$process->run(function ($type, $buffer) use ($reader) {
$process->run(function ($type, $buffer) use ($reader): void {
if (Process::OUT !== $type) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/OutputReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function append(string $content): void

// Now parse it line-by-line
while (false !== ($i = strpos($this->buffer, "\n"))) {
$line = substr($this->buffer, 0, $i);
$this->buffer = substr($this->buffer, $i+1);
$line = substr($this->buffer, 0, $i);
$this->buffer = substr($this->buffer, $i + 1);

$this->parseAndReport($line);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/FileCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ interface FileCacheInterface extends CacheInterface
/**
* Save the cache to disk.
*/
public function save();
public function save(): void;

/**
* Load the cache from disk.
*/
public function load();
public function load(): void;
}
4 changes: 2 additions & 2 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function getName(): string
*/
public function getParentName(): string
{
$dir_parts = explode('/', $this->path);
$dir_parts = explode('/', $this->path);
$module_parts = explode('/', $this->name);
$parts = [];
$parts = [];

for ($i = 0, $n = \count($dir_parts); $i < $n; $i++) {
if ($dir_parts[$i] === $module_parts[0]) {
Expand Down
2 changes: 1 addition & 1 deletion src/Packer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function pack(ConfigInterface $config): void
$finder = new ImportFinder($config->getProjectRoot());

$build_config = new BuildConfig($config);
$plugin_api = new PluginApi($finder, $config, $cache, $build_config);
$plugin_api = new PluginApi($finder, $config, $cache, $build_config);
(new PluginActivator($plugin_api))->ensurePluginsAreActivated();

$bundler = new Bundler($finder, $config);
Expand Down
Loading

0 comments on commit 0660a96

Please sign in to comment.