From b3566f8d48ec43d4dba469ee23de586ac59f958d Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 3 Aug 2019 22:06:57 -0400 Subject: [PATCH] Use Robo to extract zip archive --- RoboFile.php | 79 +++++++++++++++++------------------ vendor-bin/robo/composer.json | 1 - vendor-bin/robo/composer.lock | 59 +------------------------- 3 files changed, 40 insertions(+), 99 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index 7651a019..4e5e3064 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -208,49 +208,46 @@ class RoboFile extends \Robo\Tasks { // compile the stylesheet $t->taskExec($postcss)->arg($scss)->option("-o", $css); // download highlight.js - if (extension_loaded("zip")) { - $t->addCode(function() use ($tmp, $themeout) { - $languages = ["php", "bash", "shell", "xml", "nginx", "apache"]; - $post = http_build_query((function($langs) { - $out = []; - foreach($langs as $l) { - $out[$l.".js"] = "on"; - } - return $out; - })($languages)); - $conn = @fopen("https://highlightjs.org/download/", "r"); - if ($conn === false) { - throw new Exception("Unable to download Highlight.js"); + $t->addCode(function() use ($tmp, $themeout) { + $languages = ["php", "bash", "shell", "xml", "nginx", "apache"]; + $post = http_build_query((function($langs) { + $out = []; + foreach($langs as $l) { + $out[$l.".js"] = "on"; } - foreach (stream_get_meta_data($conn)['wrapper_data'] as $field) { - if (preg_match("/^Set-Cookie: csrftoken=([^;]+)/i", $field, $cookie)) { - break; - } + return $out; + })($languages)); + $conn = @fopen("https://highlightjs.org/download/", "r"); + if ($conn === false) { + throw new Exception("Unable to download Highlight.js"); + } + foreach (stream_get_meta_data($conn)['wrapper_data'] as $field) { + if (preg_match("/^Set-Cookie: csrftoken=([^;]+)/i", $field, $cookie)) { + break; } - $token = stream_get_contents($conn); - preg_match("/ [ - 'method' => "POST", - 'content' => $post, - 'header' => [ - "Referer: https://highlightjs.org/download/", - "Cookie: csrftoken={$cookie[1]}", - "Content-Type: application/x-www-form-urlencoded", - ], - ]])); - if ($hljs === false) { - throw new Exception("Unable to download Highlight.js"); - } else { - file_put_contents($tmp."highlightjs.zip", $hljs); - } - $z = new \ZipArchive; - $z->open($tmp."highlightjs.zip"); - $z->extractTo($themeout, "highlight.pack.js"); - }, "downloadHighlightjs"); - } else { - $this->say("Zip extension not installed; not updating hightlight.js"); - } + } + $token = stream_get_contents($conn); + preg_match("/ [ + 'method' => "POST", + 'content' => $post, + 'header' => [ + "Referer: https://highlightjs.org/download/", + "Cookie: csrftoken={$cookie[1]}", + "Content-Type: application/x-www-form-urlencoded", + ], + ]])); + if ($hljs === false) { + throw new Exception("Unable to download Highlight.js"); + } else { + file_put_contents($tmp."highlightjs.zip", $hljs); + } + $this->taskExtract($tmp."highlightjs.zip")->to($tmp."hljs")->run(); + $this->taskFilesystemStack()->copy($tmp."hljs/highlight.pack.js", $themeout."/highlight.pack.js")->run(); + }, "downloadHighlightjs"); + // copy JavaScript files from the Daux theme + # TODO // execute the collection return $t->run(); } diff --git a/vendor-bin/robo/composer.json b/vendor-bin/robo/composer.json index 8cba8493..58e4932b 100644 --- a/vendor-bin/robo/composer.json +++ b/vendor-bin/robo/composer.json @@ -5,6 +5,5 @@ "symfony/process": "^3.0" }, "require-dev": { - "splitbrain/php-archive": "^1.1" } } diff --git a/vendor-bin/robo/composer.lock b/vendor-bin/robo/composer.lock index 76036f8e..33c71e2c 100644 --- a/vendor-bin/robo/composer.lock +++ b/vendor-bin/robo/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0f7d93d4c470b72b0f6f0bc0317d603f", + "content-hash": "d95cf402fed434140db8ae87c3c8bf32", "packages": [ { "name": "consolidation/annotated-command", @@ -1734,62 +1734,7 @@ "time": "2019-04-06T14:04:46+00:00" } ], - "packages-dev": [ - { - "name": "splitbrain/php-archive", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/splitbrain/php-archive.git", - "reference": "10d89013572ba1f4d4ad7fcb74860242f4c3860b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/splitbrain/php-archive/zipball/10d89013572ba1f4d4ad7fcb74860242f4c3860b", - "reference": "10d89013572ba1f4d4ad7fcb74860242f4c3860b", - "shasum": "" - }, - "require": { - "php": ">=5.4" - }, - "require-dev": { - "ext-bz2": "*", - "ext-zip": "*", - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^4.8" - }, - "suggest": { - "ext-iconv": "Used for proper filename encode handling", - "ext-mbstring": "Can be used alternatively for handling filename encoding" - }, - "type": "library", - "autoload": { - "psr-4": { - "splitbrain\\PHPArchive\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andreas Gohr", - "email": "andi@splitbrain.org" - } - ], - "description": "Pure-PHP implementation to read and write TAR and ZIP archives", - "keywords": [ - "archive", - "extract", - "tar", - "unpack", - "unzip", - "zip" - ], - "time": "2018-09-09T12:13:53+00:00" - } - ], + "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [],