util::resources::cdnjs_get_newest_version (public)

 util::resources::cdnjs_get_newest_version -resource_info resource_info

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Return the newest version for the library denoted by 'resource_info' from cdnjs.

Switches:
-resource_info (required)

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-admin/www/posture-overview.tcl packages/acs-admin/ www/posture-overview.tcl util::resources::cdnjs_get_newest_version util::resources::cdnjs_get_newest_version packages/acs-admin/www/posture-overview.tcl->util::resources::cdnjs_get_newest_version packages/acs-tcl/lib/check-installed.tcl packages/acs-tcl/ lib/check-installed.tcl packages/acs-tcl/lib/check-installed.tcl->util::resources::cdnjs_get_newest_version util::json2dict util::json2dict (public) util::resources::cdnjs_get_newest_version->util::json2dict util::resources::cdnjs_version_API util::resources::cdnjs_version_API (public) util::resources::cdnjs_get_newest_version->util::resources::cdnjs_version_API util::resources::http_get_with_default util::resources::http_get_with_default (private) util::resources::cdnjs_get_newest_version->util::resources::http_get_with_default

Testcases:
No testcase defined.
Source code:
        set version unknown

        if {![dict exists $resource_info versionCheckAPI]} {
            return $version
        }
        set versionCheckAPI [dict get $resource_info versionCheckAPI]
        dict with resource_info {
            set library [dict get $versionCheckAPI library]
            #ns_log notice ... versionCheckAPI $versionCheckAPI configuredVersion $configuredVersion
            set jsonURL [::util::resources::cdnjs_version_API  -source [dict get $versionCheckAPI cdn]  -library $library  -count [dict get $versionCheckAPI count]]
            
            switch [dict get $versionCheckAPI cdn] {
                cdnjs {
                    set json [http_get_with_default  -url $jsonURL  -key versionCheck-$library  -default {{"results"""}}]
                    set jsonDict [util::json2dict $json]
                    #ns_log notice "=== jsonDict $library: $jsonDict"
                    foreach entry [dict get $jsonDict results] {
                        #ns_log notice "... $library compare with '[dict get $entry name]' -> [expr {[dict get $entry name] eq $library}]"
                        if {[dict get $entry name] eq $library} {
                            set version [dict get $entry version]
                            break
                        }
                    }
                }
                jsdelivr {
                    set json [http_get_with_default  -url $jsonURL  -key versionCheck-$library  -default {{"tags": {"latest""unknown"}}}]
                    set jsonDict [util::json2dict $json]
                    #ns_log notice "=== jsonDict $library: $jsonDict"
                    #ns_log notice "=== TAGS [dict get $jsonDict tags]"
                    set version [dict get [dict get $jsonDict tags] latest]
                }
                default {
                    error "unknown versionCheckAPI: '[dict get $versionCheckAPI cdn]'"
                }
            }
        }
        return $version
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: