Build script updated to allow remote js files to be local
This commit is contained in:
parent
17e8f6e708
commit
4fe73e0ef8
5 changed files with 27 additions and 9 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,11 +1,10 @@
|
||||||
/status.js
|
|
||||||
/src/status.js
|
|
||||||
/.idea
|
/.idea
|
||||||
/.module-cache
|
/.module-cache
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/vendor
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
/build/*
|
/build/*
|
||||||
!/build/template.phps
|
!/build/template.phps
|
||||||
!/build/build.php
|
!/build/build.php
|
||||||
!/build/_frontend
|
!/build/_frontend
|
||||||
/vendor
|
/*.js
|
||||||
|
|
|
@ -104,7 +104,7 @@ $opcache = (new Service([
|
||||||
]))->handle();
|
]))->handle();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Changing the look
|
## Building it yourself
|
||||||
|
|
||||||
The interface has been split up to allow you to easily change the colours of the gui, or even the core components, should you wish.
|
The interface has been split up to allow you to easily change the colours of the gui, or even the core components, should you wish.
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ The build process will create a compiled css file at `build/interface.css` and t
|
||||||
|
|
||||||
The core PHP template used in the build process, and that acts to pass various bits of data to the ReactJS side of things, is located at `build/template.phps`. If you wanted to update the version of ReactJS used, or how the wrapper html is structured, then this would be the file you'd want to update.
|
The core PHP template used in the build process, and that acts to pass various bits of data to the ReactJS side of things, is located at `build/template.phps`. If you wanted to update the version of ReactJS used, or how the wrapper html is structured, then this would be the file you'd want to update.
|
||||||
|
|
||||||
|
The template includes a few remote js files. If you want to make those local (for example, you have CSP policies in place and the remote urls are not whitelisted), then you can use the `-l` or `--local-js` flags when building, such as `php ./build/build.php -l`. This will fetch the remote script files and put them in the root of the repo, adjusting the links in the built `index.php` file to point to the local copies. If you want to build it again with remote files, run the command again without the flag.
|
||||||
|
|
||||||
## The interface
|
## The interface
|
||||||
|
|
||||||
### Overview
|
### Overview
|
||||||
|
@ -176,6 +178,7 @@ Also, if you choose to invalidate any files or reset the cache it will do this w
|
||||||
**Version 3.4.0**\
|
**Version 3.4.0**\
|
||||||
* Added new `datetime_format` config option for flexible formatting of date/time values
|
* Added new `datetime_format` config option for flexible formatting of date/time values
|
||||||
* Added the cached file's `modified` date/time to the output (when the file was either added or updated)
|
* Added the cached file's `modified` date/time to the output (when the file was either added or updated)
|
||||||
|
* You can now build the `index.php` file with the js files local rather than remote urls
|
||||||
* Added PR#83 from @Stevemoretz
|
* Added PR#83 from @Stevemoretz
|
||||||
|
|
||||||
**Version 3.3.1**\
|
**Version 3.3.1**\
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
* @license MIT, https://acollington.mit-license.org/
|
* @license MIT, https://acollington.mit-license.org/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$options = getopt('l', ['local-js']);
|
||||||
|
$makeJsLocal = (isset($options['l']) || isset($options['local-js']));
|
||||||
$parentPath = dirname(__DIR__);
|
$parentPath = dirname(__DIR__);
|
||||||
|
|
||||||
if (!file_exists($parentPath . '/node_modules')) {
|
if (!file_exists($parentPath . '/node_modules')) {
|
||||||
|
@ -25,12 +27,26 @@ echo "🚀 Creating single build file\n";
|
||||||
$template = trim(file_get_contents(__DIR__ . '/template.phps'));
|
$template = trim(file_get_contents(__DIR__ . '/template.phps'));
|
||||||
$jsOutput = trim(file_get_contents(__DIR__ . '/interface.js'));
|
$jsOutput = trim(file_get_contents(__DIR__ . '/interface.js'));
|
||||||
$cssOutput = trim(file_get_contents(__DIR__ . '/interface.css'));
|
$cssOutput = trim(file_get_contents(__DIR__ . '/interface.css'));
|
||||||
$phpOutput = trim(join('', array_slice(file($parentPath . '/src/Opcache/Service.php'), 3)));
|
$phpOutput = trim(implode('', array_slice(file($parentPath . '/src/Opcache/Service.php'), 3)));
|
||||||
$output = str_replace(
|
$output = str_replace(
|
||||||
['{{JS_OUTPUT}}', '{{CSS_OUTPUT}}', '{{PHP_OUTPUT}}'],
|
['{{JS_OUTPUT}}', '{{CSS_OUTPUT}}', '{{PHP_OUTPUT}}'],
|
||||||
[$jsOutput, $cssOutput, $phpOutput],
|
[$jsOutput, $cssOutput, $phpOutput],
|
||||||
$template
|
$template
|
||||||
);
|
);
|
||||||
|
if ($makeJsLocal) {
|
||||||
|
echo "🔗 Making js links local\n";
|
||||||
|
$jsTags = [];
|
||||||
|
$matched = preg_match_all('!<script src="([^"]*)"></script>!', $output, $jsTags);
|
||||||
|
if ($matched) {
|
||||||
|
foreach ($jsTags[1] as $jsUrl) {
|
||||||
|
$jsFile = basename($jsUrl);
|
||||||
|
$jsFilePath = $parentPath . '/' . $jsFile;
|
||||||
|
file_put_contents($jsFilePath, file_get_contents('https:' . $jsUrl));
|
||||||
|
$output = str_replace($jsUrl, $jsFile, $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($parentPath . '/index.php', $output);
|
file_put_contents($parentPath . '/index.php', $output);
|
||||||
|
|
||||||
echo "💯 Done!\n";
|
echo "💯 Done!\n";
|
||||||
|
|
|
@ -62,7 +62,7 @@ $opcache = (new Service($options))->handle();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
|
@ -70,7 +70,7 @@ $opcache = (new Service($options))->handle();
|
||||||
<script src="//unpkg.com/react/umd/react.production.min.js"></script>
|
<script src="//unpkg.com/react/umd/react.production.min.js"></script>
|
||||||
<script src="//unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
|
<script src="//unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
|
||||||
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
|
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
|
||||||
<style type="text/css">
|
<style>
|
||||||
{{CSS_OUTPUT}}
|
{{CSS_OUTPUT}}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue