Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pehbehbeh committed May 7, 2017
2 parents f0b74e2 + d0a72d8 commit de71df4
Show file tree
Hide file tree
Showing 11 changed files with 466 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.php]
indent_size = 4

[*.md]
indent_size = 4
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
/vendor/
/wp-laravel-mix.zip
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: php
php:
- 5.6
- 7.0
- 7.1
cache:
directories:
- "$HOME/.composer/cache"
- vendor
before_install:
- phpenv config-rm xdebug.ini
- composer self-update
- nvm install 6.9
- nvm use 6.9
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
install:
- composer install -o --prefer-dist --no-interaction
script:
- yarn run lint
- yarn run package
notifications:
slack:
secure: r6BeRdVdY92N9KwBgspg5LUpO4nSQJsXjES9Fr9wv078+Z6bx/c+vajxkjKojJE7o1rmu5p7DNyoIf1XVJq/ge3RL+t5snmezkcWLTonhWfZ2YsEqITXJtCT/73qqjwy3yaMm/EJMRPJlMzQoSqEXFK80GKMnPZYTGVki+2nfIo/SAf4tUGrFJYYD+m2DNrGB85KBvTwFZqR3YxFfvVX+jhF2Q3EgStl35S5RJj8yu89gbdQbYaUMzEuoJkCm0AAkFB5PhSDVubVLQxRn8rAQGAmwc+2te77/tfOlEzRDSot63z7hGPq5i1bfdM93bA9P0m6aAvGBY/eb+uDJOZ+Adl16G8OufPqAs69zL81L/KMt8pctD+62HZtdjUa5/jZiHdbVjjf8cOLN88wOmgSu3NCoPE5C7pSNJkOPpOapIuBfpyNMWbYeHx9KL9qGeEi6co35RtZZjklTMfyEvZTrIPAaYFdUQKaVePyUqsL+so0Y3taPqFPSAylYc+ox8STLiKw8jW6nUveIa8YGpn5VsBd7zF7UH/RMtChcZBCYqo6TidnZmWPYBtNBM2M5a/f1NhaTusdzupOAN5hyggReQBLT3vb1tuqdpkletZ2EmcdIBTiqjF22tYRz3gh3GHYaw67t3TkWBdqtlpFXNDXcWTZSJINa6y+uNwskmR9sCg=
deploy:
provider: releases
api_key:
secure: ZHiEe2Fp+Q41Mm8F4Pm/blHbSUDbHuDIvbDYr+1sDrSERTQtpbFCmvgf0R/C6S6uYxqesZjPB0dZzPktaQ/on3xcv3zy0IowzsFueGUM46o1UWY+cajpZLdD/dsN0vgTHW2gyOw1KJzpJ3uc6y2X5aVlnubfYIlo1x7ukvEPVNBTXWjs+8vcSAKYJZ+NHKqrDUFlgoOnAAtyZu5wV2d/Dg7cqh3okYIb7eXxdUUmKFZ78mEQqr9L97FVNVxFSDWklSA4cR9+eg/FlZpne3YCCIopz4a4c2rmTDvPzpTUwrHolcH/7+sd5JxCvTyvm7CCmA9YHkOTWPrrDsj68Idv+ivsIV/l+jQ015DLMHSGjq/SzH8VYRPMrKCCFE2muB3t2IANFb39n1V514JlX4NS4Ir7FPlHEiNBYTSmwn1gYBtjjOv7aoeX+4aMwYZD2UIFjV7Zzbmy029n0uhTSN2Xtuy0+Hb680uo7WbEL6r8tjWjc/fL3aBCIh42CpPotgsHehkT0tT1t8SdcAiVnv6/YdV8SYa+zSPMlOYw1kosyBLJ1TG35Fhcvbm9ygJ9hqPo+s+4wJC1BYKwz+R7KJm9VpA9LW0F3d2oZCJCzZktkLqoN+VmquvRM4iEo3FgAVfbn/TwJM9yOS/N9c7z4lNPnZdIWXTM/tmxZznay9azQek=
file: wp-laravel-mix.zip
on:
tags: true
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "sourceboat/wp-laravel-mix",
"description": "Get versioned Laravel Mix file paths in WordPress.",
"type": "wordpress-muplugin",
"license": "MIT",
"authors": [
{
"name": "Sourceboat",
"email": "[email protected]"
}
],
"keywords": [
"wordpress",
"laravel",
"mix"
],
"support": {
"source": "https://github.com/sourceboat/wp-laravel-mix",
"issues": "https://github.com/sourceboat/wp-laravel-mix/issues"
},
"require": {
"php": ">=5.6.0",
"composer/installers": "^1.3"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.0"
}
}
186 changes: 186 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* Plugin Name: WP Laravel Mix
* Plugin URI: https://github.com/sourceboat/wp-laravel-mix/
* Description: Get versioned Laravel Mix file paths in WordPress.
* Version: 1.0.0
* Author: Sourceboat
* Author URI: https://sourceboat.com/
* License: MIT License
*/

if (! function_exists('starts_with')) {
/**
* Determine if a given string starts with a given substring.
*
* @param string $haystack
* @param string|array $needles
* @return bool
*/
function starts_with($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
return true;
}
}
return false;
}
}

if (! function_exists('mix')) {
/**
* Get the path to a versioned Mix file.
*
* @param string $path
* @param string $manifestDirectory
* @return \Illuminate\Support\HtmlString
*
* @throws \Exception
*/
function mix($path, $manifestDirectory = '')
{
static $manifest;

if (! starts_with($path, '/')) {
$path = "/{$path}";
}

if ($manifestDirectory && ! starts_with($manifestDirectory, '/')) {
$manifestDirectory = "/{$manifestDirectory}";
}

$rootDir = dirname(dirname(ABSPATH));

if (file_exists($rootDir . '/' . $manifestDirectory.'/hot')) {
return "http://localhost:8080" . $path;
}

if (! $manifest) {
$manifestPath = $rootDir . $manifestDirectory . 'mix-manifest.json';

if (! file_exists($manifestPath)) {
throw new Exception('The Mix manifest does not exist.');
}

$manifest = json_decode(file_get_contents($manifestPath), true);
}

if (! array_key_exists($path, $manifest)) {
throw new Exception(
"Unable to locate Mix file: {$path}. Please check your ".
'webpack.mix.js output paths and try again.'
);
}

$path = $manifestDirectory . $manifest[$path];
$path = str_replace('/web', '', $path);
$path = str_replace('//', '/', $path);
return WP_HOME . $path;
}
}
21 changes: 21 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2017 Sourceboat

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.
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"private": true,
"scripts": {
"lint": "vendor/bin/phpcs --extensions=php --ignore=vendor/ .",
"package": "zip -r wp-laravel-mix.zip . -x '.git/*'",
"precommit": "yarn run lint"
},
"dependencies": {
"husky": "^0.13.3"
}
}
5 changes: 5 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<ruleset name="Sourceboat">
<description>Sourceboat Coding Standards for WordPress Plugins</description>
<rule ref="PSR2"></rule>
</ruleset>
Loading

0 comments on commit de71df4

Please sign in to comment.