Skip to content

Commit eb46d49

Browse files
committed
Implement scoper
1 parent 4d7854a commit eb46d49

File tree

6 files changed

+240
-128
lines changed

6 files changed

+240
-128
lines changed

build-dev.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
echo "# Deleting vendor folder..."
4+
rm -r -f vendor
5+
rm composer.lock
6+
7+
echo "# Executing Composer..."
8+
composer update --no-plugins
9+
10+
echo "# Executing Scoper..."
11+
vendor/bin/php-scoper add-prefix --force
12+
13+
echo "# Migrating Build..."
14+
rm -r -f vendor
15+
mv build/vendor vendor
16+
rm -r -f build

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
./build-dev.sh
4+
5+
composer update --no-dev --optimize-autoloader --no-plugins

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"psr/cache": "^3.0"
4141
},
4242
"require-dev": {
43+
"humbug/php-scoper": "^0.18",
4344
"buggregator/trap": "^1",
4445
"ergebnis/composer-normalize": "^2",
4546
"friendsofphp/php-cs-fixer": "^3",
@@ -94,7 +95,7 @@
9495
}
9596
},
9697
"scripts": {
97-
"package": "mv composer.local.json composer.local.old && composer install --no-dev --optimize-autoloader --no-ansi --no-interaction --no-plugins --no-progress --no-scripts && mv composer.local.old composer.local.json",
98+
"package": "./build.sh",
9899
"pest": "@php vendor/bin/pest --order-by random --fail-on-risky --parallel --no-progress",
99100
"pest:coverage": "@php vendor/bin/pest --order-by random --fail-on-risky --coverage --parallel --no-progress",
100101
"pest:debug": "@php vendor/bin/pest --log-events-verbose-text pest.log --display-errors --fail-on-risky --no-progress",

scoper.inc.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Isolated\Symfony\Component\Finder\Finder;
6+
7+
return [
8+
'prefix' => 'Auth0\\WordPress\\Vendor',
9+
10+
'finders' => [
11+
Finder::create()
12+
->files()
13+
->ignoreVCS(true)
14+
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.(json|lock)/')
15+
->exclude([
16+
'doc',
17+
'test',
18+
'test_old',
19+
'tests',
20+
'Tests',
21+
'vendor-bin',
22+
])
23+
->in(['vendor', '.']),
24+
25+
Finder::create()->append([
26+
'composer.json',
27+
]),
28+
],
29+
30+
'exclude-namespaces' => [
31+
'/^Auth0\\\\WordPress\\\/',
32+
'/^Psr\\\/',
33+
],
34+
35+
'expose-global-constants' => false,
36+
'expose-global-classes' => false,
37+
'expose-global-functions' => false,
38+
39+
'patchers' => [],
40+
];

src/Actions/Updates.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Auth0\WordPress\Actions;
6+
7+
use function is_array;
8+
use function is_object;
9+
10+
final class Updates extends Base
11+
{
12+
protected array $registry = [
13+
'site_transient_update_plugins' => 'doUpdateCheck',
14+
'transient_update_plugins' => 'doUpdateCheck',
15+
];
16+
17+
public function doUpdateCheck($plugins)
18+
{
19+
trap($plugins);
20+
21+
if (! is_object($plugins)) {
22+
return $plugins;
23+
}
24+
25+
if (! isset($plugins->response) || ! is_array($plugins->response)) {
26+
$plugins->response = [];
27+
}
28+
29+
$plugins->response['auth0/wpAuth0.php'] = (object) [
30+
'slug' => 'auth0',
31+
'new_version' => '5.9',
32+
'url' => 'https://github.com/auth0/wordpress',
33+
'package' => 'https://github.com/auth0/wirdoress/archive/0.2.zip',
34+
];
35+
36+
return $plugins;
37+
}
38+
}

0 commit comments

Comments
 (0)