Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer.json to use new warranty module #1509

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions app/views/system/module_marketplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@

// Get latest version number
for (const pkg in pkg_details) {
compare_version = pkg_details[pkg]['version'].replace(/[^\d.-]/g, '')
compare_version = pkg_details[pkg]['version'].replace(/[^\d.b-]/g, '')

if (!compare_version.includes("-") && compare_version !== '' && compareVersions(latest_ver, '<', compare_version)) {
latest_ver = pkg_details[pkg]['version'].replace(/[^0-9b.]/g, '')
update_time = pkg_details[pkg]['time']
// Check if it's a beta/pre-release module
if (pkg_details[pkg]['version_normalized'].includes("beta")){
is_beta = true
} else {
is_beta = false
}
}
};
Expand Down Expand Up @@ -293,10 +296,34 @@ function compareVersions(v1, comparator, v2) {
if(['==','===','<','<=','>','>=','!=','!=='].indexOf(comparator) == -1) {
throw new Error('Invalid comparator. ' + comparator);
}
var v1parts = v1.replace(/[^\d.-]/g, '').split('.'), v2parts = v2.replace(/[^\d.-]/g, '').split('.');
var v1parts = v1.replace('b', '.0.0.').replace(/[^\d.-]/g, '').split('.'), v2parts = v2.replace('b', '.0.0.').replace(/[^\d.-]/g, '').split('.');

if (v1parts.length == 4){
v1parts.push("999999");
} else if (v1parts.length == 3){
v1parts.push("0");
v1parts.push("999999");
} else if (v1parts.length == 2){
v1parts.push("0");
v1parts.push("0");
v1parts.push("999999");
}

if (v2parts.length == 4){
v2parts.push("999999");
} else if (v2parts.length == 3){
v2parts.push("0");
v2parts.push("999999");
} else if (v2parts.length == 2){
v2parts.push("0");
v2parts.push("0");
v2parts.push("999999");
}

var maxLen = Math.max(v1parts.length, v2parts.length);
var part1, part2;
var cmp = 0;

for(var i = 0; i < maxLen && !cmp; i++) {
part1 = parseInt(v1parts[i], 10) || 0;
part2 = parseInt(v2parts[i], 10) || 0;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"munkireport/tag": "^3.0",
"munkireport/reportdata": "^3.0",
"ext-dom": "*",
"munkireport/warranty": "^4.0",
"munkireport/warranty": "^5.0",
"illuminate/events": "~7.0|~10.0",
"munkireport/comment": "^4.0",
"munkireport/supported_os": "^2.0",
Expand Down Expand Up @@ -115,4 +115,4 @@
"description": "Reporting tool for munki",
"license": "MIT",
"name": "munkireport/munkireport-php"
}
}