Skip to content

Commit

Permalink
Merge pull request #53 from kmvan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
kmvan authored Dec 2, 2019
2 parents fdb43ab + 4533087 commit bf9ead6
Show file tree
Hide file tree
Showing 10 changed files with 1,043 additions and 971 deletions.
7 changes: 5 additions & 2 deletions AppConfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"APP_VERSION": "3.6",
"APP_VERSION": "3.7",
"APP_NAME": "X Prober",
"APP_URL": "https://github.com/kmvan/x-prober",
"AUTHOR_URL": "https://inn-studio.com/prober",
"UPDATE_PHP_URLS": [
"https://raw.githubusercontent.com/kmvan/x-prober/master/dist/prober.php",
"https://api.inn-studio.com/download/?id=xprober"
],
"APP_CONFIG_URL": "https://raw.githubusercontent.com/kmvan/x-prober/master/AppConfig.json",
"APP_CONFIG_URLS": [
"https://raw.githubusercontent.com/kmvan/x-prober/master/AppConfig.json",
"https://api.inn-studio.com/download/?id=xprober-config"
],
"APP_CONFIG_URL_DEV": "http://127.0.0.1/prober/AppConfig.json",
"AUTHOR_NAME": "INN STUDIO",
"LATEST_PHP_STABLE_VERSION": 7,
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All Notable changes to `X-Prober` will be documented in this file

## 3.7.0 - 2019-12-03

### Add

- Add multi update check sources

## 3.6.0 - 2019-11-20

### Fix
Expand Down
5 changes: 3 additions & 2 deletions compiler/ConfigGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private function genPhpConfig(): bool
'APP_VERSION' => $appVersion,
'APP_NAME' => $appName,
'APP_URL' => $appUrl,
'APP_CONFIG_URL' => $appConfigUrl,
'APP_CONFIG_URLS' => $appConfigUrls,
'APP_CONFIG_URL_DEV' => $appConfigUrlDev,
'AUTHOR_URL' => $authorUrl,
'UPDATE_PHP_URLS' => $updatePhpUrls,
Expand All @@ -54,6 +54,7 @@ private function genPhpConfig(): bool
] = $config;

$updatePhpUrls = \implode("', '", $updatePhpUrls);
$appConfigUrls = \implode("', '", $appConfigUrls);

$configContent = <<<PHP
<?php
Expand All @@ -68,7 +69,7 @@ class ConfigApi
public static \$APP_VERSION = '{$appVersion}';
public static \$APP_NAME = '{$appName}';
public static \$APP_URL = '{$appUrl}';
public static \$APP_CONFIG_URL = '{$appConfigUrl}';
public static \$APP_CONFIG_URLS = array('{$appConfigUrls}');
public static \$APP_CONFIG_URL_DEV = '{$appConfigUrlDev}';
public static \$AUTHOR_URL = '{$authorUrl}';
public static \$UPDATE_PHP_URLS = array('{$updatePhpUrls}');
Expand Down
6 changes: 3 additions & 3 deletions dist/prober.php

Large diffs are not rendered by default.

1,898 changes: 968 additions & 930 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,30 @@
]
},
"devDependencies": {
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/plugin-proposal-decorators": "^7.7.0",
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/plugin-transform-strict-mode": "^7.2.0",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-transform-runtime": "^7.7.4",
"@babel/plugin-transform-strict-mode": "^7.7.4",
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.7.1",
"@babel/preset-react": "^7.7.0",
"@babel/preset-env": "^7.7.4",
"@babel/preset-react": "^7.7.4",
"@babel/preset-stage-0": "^7.0.0",
"@babel/preset-typescript": "^7.7.2",
"@babel/preset-typescript": "^7.7.4",
"@types/core-js": "^2.5.2",
"@types/lodash-es": "^4.17.3",
"@types/node": "^12.12.11",
"@types/node": "^12.12.14",
"@types/query-string": "^6.3.0",
"@types/react": "^16.9.11",
"@types/react": "^16.9.13",
"@types/react-dom": "^16.9.4",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-styled-components": "^1.10.6",
"babel-preset-env": "^1.7.0",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^6.0.3",
"eslint": "^6.6.0",
"eslint-plugin-react": "^7.16.0",
"eslint": "^6.7.2",
"eslint-plugin-react": "^7.17.0",
"lodash-es": "^4.17.15",
"lodash-webpack-plugin": "^0.11.5",
"mobx": "^5.15.0",
Expand All @@ -108,11 +108,11 @@
"webpack-log": "^3.0.1"
},
"dependencies": {
"@babel/runtime": "^7.7.2",
"@babel/runtime": "^7.7.4",
"@types/styled-components": "^4.4.0",
"@typescript-eslint/eslint-plugin": "^2.8.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.8.0",
"@typescript-eslint/parser": "^2.8.0",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-polyfill": "^6.26.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Bootstrap/Conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function conf(array $conf)
'version' => ConfigApi::$APP_VERSION,
'appName' => ConfigApi::$APP_NAME,
'appUrl' => ConfigApi::$APP_URL,
'appConfigUrl' => ConfigApi::$APP_CONFIG_URL,
'appConfigUrls' => ConfigApi::$APP_CONFIG_URLS,
'appConfigUrlDev' => ConfigApi::$APP_CONFIG_URL_DEV,
'authorUrl' => ConfigApi::$AUTHOR_URL,
'authorName' => ConfigApi::$AUTHOR_NAME,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Bootstrap/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BootstrapStore {
public readonly ID = 'bootstrap'
public readonly conf = get(conf, this.ID)
public version: string = get(this.conf, 'version')
public appConfigUrl: string = get(this.conf, 'appConfigUrl')
public appConfigUrls: string[] = get(this.conf, 'appConfigUrls')
public appConfigUrlDev: string = get(this.conf, 'appConfigUrlDev')
public appName: string = get(this.conf, 'appName')
public appUrl: string = get(this.conf, 'appUrl')
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Config/ConfigApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

class ConfigApi
{
public static $APP_VERSION = '3.6';
public static $APP_VERSION = '3.7';
public static $APP_NAME = 'X Prober';
public static $APP_URL = 'https://github.com/kmvan/x-prober';
public static $APP_CONFIG_URL = 'https://raw.githubusercontent.com/kmvan/x-prober/master/AppConfig.json';
public static $APP_CONFIG_URLS = array('https://raw.githubusercontent.com/kmvan/x-prober/master/AppConfig.json', 'https://api.inn-studio.com/download/?id=xprober-config');
public static $APP_CONFIG_URL_DEV = 'http://127.0.0.1/prober/AppConfig.json';
public static $AUTHOR_URL = 'https://inn-studio.com/prober';
public static $UPDATE_PHP_URLS = array('https://raw.githubusercontent.com/kmvan/x-prober/master/dist/prober.php', 'https://api.inn-studio.com/download/?id=xprober');
Expand Down
50 changes: 37 additions & 13 deletions src/Components/Config/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { observable, action, configure } from 'mobx'
import ToastStore from '~components/Toast/src/stores'
import { gettext } from '~components/Language/src'
import BootstrapStore from '~components/Bootstrap/src/stores'
import conf from '~components/Helper/src/components/conf'

configure({
enforceActions: 'observed',
Expand Down Expand Up @@ -35,20 +36,43 @@ class ConfigStore {
}

private fetch = async () => {
const { isDev, appConfigUrl, appConfigUrlDev } = BootstrapStore

await fetch(isDev ? appConfigUrlDev : appConfigUrl)
.then(res => res.json())
.then(res => {
this.setAppConfig(res)
})
.catch(e => {
ToastStore.open(
gettext(
'Error: can not fetch remote config data, update checker is disabled.'
)
const { isDev, appConfigUrls, appConfigUrlDev } = BootstrapStore
let configStatus = false

// dev version
if (isDev) {
await fetch(appConfigUrlDev)
.then(res => res.json())
.then(res => {
this.setAppConfig(res)
})
.catch(e => {})

return
}

// online version
for (let i = 0; i < appConfigUrls.length; i++) {
await fetch(appConfigUrls[i])
.then(res => res.json())
.then(res => {
this.setAppConfig(res)
configStatus = true
})
.catch(e => {})

if (configStatus) {
break
}
}

if (!configStatus) {
ToastStore.open(
gettext(
'Error: can not fetch remote config data, update checker is disabled.'
)
})
)
}
}

@action
Expand Down

0 comments on commit bf9ead6

Please sign in to comment.