Julian Noble
11 months ago
9 changed files with 418 additions and 101 deletions
@ -0,0 +1,52 @@ |
|||||||
|
# -*- tcl -*- |
||||||
|
# Maintenance Instruction: leave the 999999.xxx.x as is and use 'pmix make' or src/make.tcl to update from <pkg>-buildversion.txt |
||||||
|
# |
||||||
|
# Please consider using a BSD or MIT style license for greatest compatibility with the Tcl ecosystem. |
||||||
|
# Code using preferred Tcl licenses can be eligible for inclusion in Tcllib, Tklib and the punk package repository. |
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
# (C) 2023 |
||||||
|
# |
||||||
|
# @@ Meta Begin |
||||||
|
# Application punk::cap::scriptlibs 999999.0a1.0 |
||||||
|
# Meta platform tcl |
||||||
|
# Meta license <unspecified> |
||||||
|
# @@ Meta End |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
## Requirements |
||||||
|
##e.g package require frobz |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
namespace eval punk::cap::scriptlibs { |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
## Ready |
||||||
|
package provide punk::cap::scriptlibs [namespace eval punk::cap::scriptlibs { |
||||||
|
variable pkg punk::cap::scriptlibs |
||||||
|
variable version |
||||||
|
set version 999999.0a1.0 |
||||||
|
}] |
||||||
|
return |
@ -0,0 +1,3 @@ |
|||||||
|
0.1.0 |
||||||
|
#First line must be a semantic version number |
||||||
|
#all other lines are ignored. |
@ -0,0 +1,102 @@ |
|||||||
|
# -*- tcl -*- |
||||||
|
# Maintenance Instruction: leave the 999999.xxx.x as is and use 'pmix make' or src/make.tcl to update from <pkg>-buildversion.txt |
||||||
|
# |
||||||
|
# Please consider using a BSD or MIT style license for greatest compatibility with the Tcl ecosystem. |
||||||
|
# Code using preferred Tcl licenses can be eligible for inclusion in Tcllib, Tklib and the punk package repository. |
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
# (C) 2023 |
||||||
|
# |
||||||
|
# @@ Meta Begin |
||||||
|
# Application punk::cap::templates 999999.0a1.0 |
||||||
|
# Meta platform tcl |
||||||
|
# Meta license <unspecified> |
||||||
|
# @@ Meta End |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
## Requirements |
||||||
|
##e.g package require frobz |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
#register using: |
||||||
|
# punk::cap::register_capabilityname templates ::punk::cap::templates |
||||||
|
|
||||||
|
#By convention and for consistency, we don't register here during package loading - but require the calling app to do it. |
||||||
|
# (even if it tends to be done immediately after package require anyway) |
||||||
|
# registering capability handlers can involve validating existing provider data and is best done explicitly as required. |
||||||
|
# It is also possible for a capability handler to be registered to handle more than one capabilityname |
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
namespace eval punk::cap::templates { |
||||||
|
variable callback |
||||||
|
set callback [namespace current]::callback |
||||||
|
if {[info commands $callback] eq ""} { |
||||||
|
punk::cap::callbackbase create $callback |
||||||
|
oo::objdefine $callback { |
||||||
|
method pkg_register {pkg capdict fullcaplist} { |
||||||
|
if {![dict exists $capdict relpath]} { |
||||||
|
return 0 |
||||||
|
} |
||||||
|
return 1 |
||||||
|
} |
||||||
|
method pkg_unregister {pkg} { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#return a dict keyed on folder with source pkg as value |
||||||
|
proc folders {} { |
||||||
|
package require punk::cap |
||||||
|
set caplist [punk::cap::capabilities templates] |
||||||
|
# e.g {templates {punk::mix::templates ::somepkg}} |
||||||
|
set templates_record [lindex $caplist 0] |
||||||
|
set pkgs [dict get [lindex $templates_record 1] providers] |
||||||
|
|
||||||
|
set folderdict [dict create] |
||||||
|
foreach pkg $pkgs { |
||||||
|
set provide_statement [package ifneeded $pkg [package require $pkg]] |
||||||
|
set tmfile [lindex $provide_statement end] |
||||||
|
if {![file exists $tmfile]} { |
||||||
|
puts stderr "punk::cap::templates::folders WARNING - unable to determine base folder for package '$pkg' which is registered with punk::cap as a provider of 'templates' capability" |
||||||
|
continue |
||||||
|
} |
||||||
|
|
||||||
|
set caplist [dict get [punk::cap::pkgcap $pkg] accepted] |
||||||
|
set templates_entries [lsearch -all -inline -index 0 $caplist templates] ;#we generally expect only one - but if multiple exist - use them |
||||||
|
foreach templates_info $templates_entries { |
||||||
|
lassign $templates_info _templates templates_dict |
||||||
|
if {[dict exists $templates_dict relpath]} { |
||||||
|
#set tmdir [file dirname [lindex $provide_statement end]] |
||||||
|
set tpath [file normalize [file join $tmfile [dict get $templates_dict relpath]]] ;#relpath is relative to the tm *file* - not it's containing folder |
||||||
|
#relpath relative to file is important for tm files that are zip/tar based containers |
||||||
|
if {[file isdirectory $tpath]} { |
||||||
|
dict set folderdict $tpath [list source $pkg sourcetype package] |
||||||
|
} else { |
||||||
|
puts stderr "punk::cap::templates::folders WARNING - unable to determine relpath location [dict get $templates_dict relpath] for package '$pkg' which is registered with punk::cap as a provider of 'templates' capability" |
||||||
|
} |
||||||
|
} else { |
||||||
|
puts stderr "punk::cap::templates::folders WARNING - registered pkg '$pkg' has capability 'templates' but has an entry with no 'relpath' key - unable to use as source of templates" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return $folderdict |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ |
||||||
|
## Ready |
||||||
|
package provide punk::cap::templates [namespace eval punk::cap::templates { |
||||||
|
variable pkg punk::cap::templates |
||||||
|
variable version |
||||||
|
set version 999999.0a1.0 |
||||||
|
}] |
||||||
|
return |
@ -0,0 +1,3 @@ |
|||||||
|
0.1.0 |
||||||
|
#First line must be a semantic version number |
||||||
|
#all other lines are ignored. |
Loading…
Reference in new issue