From 987680d3bce9c49c49f4b9df5f94a722553307c0 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:18:18 +0200 Subject: [PATCH 1/9] Faster build times by being able to exclude certain paths from variable replacement: Issue: https://github.com/box-project/box2/issues/97 This uses this branch: https://github.com/webdevvie/box2-lib/tree/feature/faster-adding-with-excluded-regexp --- composer.json | 8 +++++++- res/schema.json | 7 +++++++ src/lib/KevinGH/Box/Command/Build.php | 7 +++++++ src/lib/KevinGH/Box/Configuration.php | 12 ++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 87f9f20b..5eba34f8 100644 --- a/composer.json +++ b/composer.json @@ -14,10 +14,16 @@ "support": { "issues": "https://github.com/box-project/box2/issues" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/webdevvie/box-lib" + } + ], "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "~1.6", + "herrera-io/box": "feature/faster-adding-with-excluded-regexp", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", diff --git a/res/schema.json b/res/schema.json index 22a4c55a..427cbd0f 100644 --- a/res/schema.json +++ b/res/schema.json @@ -43,6 +43,13 @@ }, "type": ["array", "string"] }, + "exclude-from-value-replace": { + "description": "A list of regular expressions for file paths to not value replace but add verbatim", + "items": { + "type": "string" + }, + "type": ["array", "string"] + }, "bootstrap": { "description": "A file used to load third-party class compactors.", "type": "string" diff --git a/src/lib/KevinGH/Box/Command/Build.php b/src/lib/KevinGH/Box/Command/Build.php index f4be0fee..d68c69a9 100644 --- a/src/lib/KevinGH/Box/Command/Build.php +++ b/src/lib/KevinGH/Box/Command/Build.php @@ -445,6 +445,12 @@ protected function execute(InputInterface $input, OutputInterface $output) unset($values, $key, $value); } + //set the regular expressions for files that don't need value replacement + if (array() !== ($excludedFromValueReplace = $this->config->getExcludedFromValueReplace())) { + $this->box->setExcludedFromValueReplace($excludedFromValueReplace, $this->config->getBasePath()); + } + + // register configured compactors if (array() !== ($compactors = $this->config->getCompactors())) { @@ -695,6 +701,7 @@ private function add( $box->addFile($file, $relative); } + $box->addFilesFromQueue(); } } } diff --git a/src/lib/KevinGH/Box/Configuration.php b/src/lib/KevinGH/Box/Configuration.php index 895eed64..89ea326d 100644 --- a/src/lib/KevinGH/Box/Configuration.php +++ b/src/lib/KevinGH/Box/Configuration.php @@ -216,6 +216,18 @@ function (&$file) { return array(); } + /** + * Returns a list of non parsed regular expressions to exclude files from getting replacements + * + * @return array + */ + public function getExcludedFromValueReplace() + { + if (isset($this->raw->{'exclude-from-value-replace'})) { + return (array)$this->raw->{'exclude-from-value-replace'}; + } + return array(); + } /** * Returns a filter callable for the configured blacklist. * From 5bb5195b3cd4df5534be5ac5b61bb06e2bef1a22 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:22:45 +0200 Subject: [PATCH 2/9] Renamed version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5eba34f8..49b725f4 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "feature/faster-adding-with-excluded-regexp", + "herrera-io/box": "faster-adding-with-excluded-regexp", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From e671a72c1797531e62a43a55cc0514388474f4d2 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:26:05 +0200 Subject: [PATCH 3/9] updated version so i can properly test this --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 49b725f4..b53a4a35 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "faster-adding-with-excluded-regexp", + "herrera-io/box": "faster-adding-with-excluded-regexp as 1.6.0", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From b0e6a9d18126b93f80ccfd1d39f7583097d727d2 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:26:43 +0200 Subject: [PATCH 4/9] preface it with dev- --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b53a4a35..c70290e4 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "faster-adding-with-excluded-regexp as 1.6.0", + "herrera-io/box": "faster-adding-with-excluded-regexp as dev-1.6.0", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From 76550938b41347ac8400b6f5be8b1def4eb9a0ff Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:27:42 +0200 Subject: [PATCH 5/9] wrong position for dev- --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c70290e4..349b848a 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "faster-adding-with-excluded-regexp as dev-1.6.0", + "herrera-io/box": "dev-faster-adding-with-excluded-regexp as 1.6.0", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From 814a0ef4c04e9c5e47dc1e596c8b29d778e31b99 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:31:00 +0200 Subject: [PATCH 6/9] fix in repo url for for box2-lib --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 349b848a..b270f87e 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "repositories": [ { "type": "vcs", - "url": "https://github.com/webdevvie/box-lib" + "url": "git@github.com:webdevvie/box2-lib.git" } ], "require": { From 8bf719eb2dd054abcccfb1fd35041718bb3ccf0b Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:35:26 +0200 Subject: [PATCH 7/9] updated version to match specific version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b270f87e..e9877b27 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "dev-faster-adding-with-excluded-regexp as 1.6.0", + "herrera-io/box": "dev-faster-adding-with-excluded-regexp as 1.6", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From 23ea629470102434f02a887ec71a21159319aa91 Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:37:24 +0200 Subject: [PATCH 8/9] reset version --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index e9877b27..87f9f20b 100644 --- a/composer.json +++ b/composer.json @@ -14,16 +14,10 @@ "support": { "issues": "https://github.com/box-project/box2/issues" }, - "repositories": [ - { - "type": "vcs", - "url": "git@github.com:webdevvie/box2-lib.git" - } - ], "require": { "php": ">=5.3.3", "herrera-io/annotations": "~1.0", - "herrera-io/box": "dev-faster-adding-with-excluded-regexp as 1.6", + "herrera-io/box": "~1.6", "herrera-io/json": "~1.0", "kherge/amend": "~3.0", "justinrainbow/json-schema": "~1.3", From 2c5cc97f5ab11640c561aaaa19202ebb1b2b85ee Mon Sep 17 00:00:00 2001 From: John Bakker Date: Mon, 6 Jun 2016 13:49:01 +0200 Subject: [PATCH 9/9] fixed problem when running unittest $box can be a Phar. check for instanceof Box first --- src/lib/KevinGH/Box/Command/Build.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/KevinGH/Box/Command/Build.php b/src/lib/KevinGH/Box/Command/Build.php index d68c69a9..4cd3af18 100644 --- a/src/lib/KevinGH/Box/Command/Build.php +++ b/src/lib/KevinGH/Box/Command/Build.php @@ -701,7 +701,9 @@ private function add( $box->addFile($file, $relative); } - $box->addFilesFromQueue(); + if($box instanceof Box) { + $box->addFilesFromQueue(); + } } } }