mirror of
https://github.com/Findus23/devicedetector.net.git
synced 2024-09-19 15:43:46 +02:00
fix updater
This commit is contained in:
parent
e8fd7ebb27
commit
79027072cb
7 changed files with 61 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
vendor/
|
||||
tmp/
|
||||
config.ini
|
||||
public/version.json
|
||||
|
|
|
@ -6,9 +6,54 @@
|
|||
<router-link to="/main">Main</router-link>
|
||||
</div>
|
||||
<router-view/>
|
||||
<footer>
|
||||
<div>
|
||||
using Device Detector <a :href="'https://github.com/matomo-org/device-detector/tree/'+commitHash" target="_blank">{{shortHash}}</a>
|
||||
</div>
|
||||
<div>
|
||||
last updated on {{lastUpdated.toLocaleString()}}
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
|
||||
const versionJSON = 'http://local.devicedetector.net/version.json';
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Main',
|
||||
data() {
|
||||
return {
|
||||
commitHash: "",
|
||||
lastUpdated: new Date()
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
shortHash():string {
|
||||
return this.commitHash.substring(0,7);
|
||||
}
|
||||
},
|
||||
mounted(): void {
|
||||
const req = new XMLHttpRequest();
|
||||
req.onreadystatechange = (event: Event): void => {
|
||||
if (req.readyState === XMLHttpRequest.DONE) {
|
||||
if (req.status === 200) {
|
||||
const data = JSON.parse(req.responseText);
|
||||
console.log(data);
|
||||
this.commitHash = data.commitHash;
|
||||
this.lastUpdated = new Date(data.date);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
req.open('GET', versionJSON , true);
|
||||
req.send(null);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
#app {
|
||||
font-family: 'Avenir', Helvetica, Arial, sans-serif;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
|
||||
const baseURL = 'http://localhost/devicedetector.net/api.php';
|
||||
const baseURL = 'http://local.devicedetector.net/detect/';
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'Main',
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
]
|
||||
},
|
||||
"rules": {
|
||||
"quotemark": [true, "single"],
|
||||
"quotemark": [true, "double"],
|
||||
"indent": [true, "spaces", 4],
|
||||
"interface-name": false,
|
||||
"ordered-imports": false,
|
||||
|
|
|
@ -28,7 +28,7 @@ $cacheloader = new CacheLoader();
|
|||
|
||||
$item = $cacheloader->cache->getItem("supported");
|
||||
|
||||
if ($item->isHit() and false) {
|
||||
if ($item->isHit()) {
|
||||
$data = $item->get();
|
||||
} else {
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"githash": "adssdasa"
|
||||
}
|
16
update.php
16
update.php
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace DeviceDetectorNet;
|
||||
//system("composer update");
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
system("composer update");
|
||||
|
||||
$lockstring = file_get_contents("composer.lock");
|
||||
$composerLock = json_decode($lockstring, true);
|
||||
|
@ -10,10 +13,15 @@ $key = array_search("piwik/device-detector", array_column($composerLock["package
|
|||
$ddPackage = $composerLock["packages"][$key];
|
||||
|
||||
$commitHash = $ddPackage["source"]["reference"];
|
||||
$currentDate =
|
||||
print_r($composerLock["packages"][$key]);
|
||||
$currentDate = (new \DateTime())->format('c');
|
||||
|
||||
$version = [
|
||||
"commitHash" => $commitHash,
|
||||
"date" => $currentDate
|
||||
];
|
||||
|
||||
file_put_contents("public/version.json", json_encode($version, JSON_PRETTY_PRINT));
|
||||
$cacheLoader = new CacheLoader();
|
||||
|
||||
$cacheLoader->cache->clear();
|
||||
echo "Cache cleared";
|
||||
echo "Cache cleared\n";
|
||||
|
|
Loading…
Reference in a new issue