Skip to content

Commit

Permalink
fix: detect version (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricerenck authored Feb 5, 2021
1 parent 857a4b5 commit e9c5eed
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mauricerenck/komments",
"version": "0.10.0",
"version": "0.10.1",
"description": "A comment and webmention plugin for Kirby 3",
"type": "kirby-plugin",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "komments",
"version": "0.10.0",
"version": "0.10.1",
"description": "A comment and webmention plugin for Kirby 3",
"main": "index.js",
"author": "Maurice Renck",
Expand All @@ -13,6 +13,7 @@
"recognizeSelfClosing": true
},
"dependencies": {
"semver": "^7.3.4",
"vue": "^2.6.11",
"vue-hot-reload-api": "^2.3.4"
},
Expand Down
38 changes: 14 additions & 24 deletions src/components/Support.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div v-else class="versionBox">
<div v-if="hasVersionDiff">
<h4 class="update-available">There is an update available</h4>
<h3 class="version">{{this.releaseInfo.version}}</h3>
<h3 class="version">{{this.releaseInfo}}</h3>
</div>
<div v-else>
<h4>Your Komments plugin is up to date</h4>
Expand All @@ -18,12 +18,13 @@
</template>

<script>
import semver from "semver";
export default {
data() {
return {
version: '',
releaseInfo: {},
releaseInfo: 0,
hasVersionDiff: false,
hasError: false
};
Expand All @@ -48,33 +49,22 @@ export default {
this.hasError = true
}
let latest = this.version.split('.');
Object.keys(response.packages['mauricerenck/komments']).sort().forEach(function(key) {
const version = key.split('.')
this.releaseInfo = this.version
if(typeof version !== 'object') {
return false
}
const latest = this.version;
Object.keys(response.packages['mauricerenck/komments']).sort().forEach((version) => {
if(!semver.valid(version)) {
return false
}
if(parseInt(version[0]) > parseInt(latest[0])) {
latest[0] = version[0]
}
if(parseInt(version[1]) > parseInt(latest[1])) {
latest[1] = version[1]
}
if(parseInt(version[2]) > parseInt(latest[2])) {
latest[2] = version[2]
}
if(semver.gt(version, latest)) {
this.hasVersionDiff = semver.gt(version, latest)
this.releaseInfo = version.toString()
}
});
const versionInfo = response.packages['mauricerenck/komments'][latest.join('.')]
this.hasVersionDiff = versionInfo.version !== this.version
this.releaseInfo = versionInfo
})
.catch(error => {
console.log('catch', error)
this.hasError = true
})
});
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,13 @@ lru-cache@^4.1.2:
pseudomap "^1.0.2"
yallist "^2.1.2"

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"

[email protected]:
version "2.0.4"
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b"
Expand Down Expand Up @@ -1249,6 +1256,13 @@ semver@^6.0.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.4:
version "7.3.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97"
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==
dependencies:
lru-cache "^6.0.0"

simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"
Expand Down Expand Up @@ -1461,3 +1475,8 @@ yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=

yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

0 comments on commit e9c5eed

Please sign in to comment.