16 + description?: string
17 + linux_x64_url?: string
18 + linux_aarch64_url?: string
19 + win32_x64_url?: string
20 + fedora_name?: string
22 + termux_name?: string
26 + if (package-exists
$org $name) {
27 + print $
"A manifest for ($org)/($name) already exists!" 31 + let source =
match $source {
33 + [ github codeberg custom ] |
34 + input list --fuzzy
"Pick a source, where the package is hosted." 36 + "github" |
"codeberg" |
"custom" =>
$source 38 + msg:
"unkown source" 40 + text:
"source must be one of github, codeberg or custom" 41 + span: (metadata
$source).span
49 + if $source ==
"github" {
50 + print "Since the
source of this package is github releases,
51 +the rest of the manifest values will be guessed on a best effort basis.
52 +Please review the manifest file afterwards."
53 + $manifest = (new-from-github
$org $name)
56 + if $source ==
'codeberg' {
57 + print
"Codeberg is not yet supported. Proceeding as if direct mode was selected." 58 + $manifest = (new-from-custom-input
$org $name)
61 + if (
$source ==
'custom') {
62 + $manifest = (new-from-custom-input
$org $name)
65 + if (
$manifest | is-empty) {
66 + print --stderr $
"New source type detected: ($source). Add handling for that!" 70 + let manifest_path = save-manifest
$manifest 72 + let open_with_editor = (input --default y
"Open the manifest in editor? (y/n)")
73 + if (
$open_with_editor ==
'y') { run-external
$env.EDITOR $manifest_path }
79 + cd (folders manifests)
80 + let org =
$manifest.organisation 81 + let name =
$manifest.name 82 + let version =
$manifest.version 83 + let file = (make-manifest-file-name
$org $name)
84 + mut manifest =
$manifest 86 + $manifest =
$manifest | update
'linux x64 url' { templatize
$version }
87 + $manifest =
$manifest | update
'linux aarch64 url' { templatize
$version }
88 + $manifest =
$manifest | update
'win32 x64 url' { templatize
$version }
90 + print
"Generated manifest: " 93 + $manifest | to nuon --indent
2 | save
$file 94 + print $
"Manifest for ($org)/($name) saved under ($file)." 96 + return (
$file | path expand)
101 +]: string -> string {
102 + if (
$in | is-not-empty) {
103 + str replace --all
$version "{ version }" 107 +def new-from-custom-input [
112 + let version = (input $
"Give version of ($org)/($name): ")
113 + let binary_path = (input --default
$name "Give relative binary path: ")
114 + let homepage = (input
"Give homepage: ")
115 + let description = (input
"Give description: ")
116 + let linux_x64_url = (input
"Give linux x64 url: ")
117 + let linux_aarch64_url = (input
"Give linux aarch64 url: ")
118 + let win32_x64_url = (input
"Give win32 x64 url: ")
119 + let fedora_name = (input --default
$name "Give fedora package name: ")
120 + let arch_name = (input --default
$name "Give arch package name: ")
121 + let termux_name = (input --default
$name "Give termux package name: ")
122 + let win32_name = (input --default (
$name ++
'.' ++
$name)
"Give win32 package name: ")
124 + return (make-manifest
$org $name 'custom' $version $binary_path $homepage $description '' $linux_x64_url $linux_aarch64_url $win32_x64_url $fedora_name $arch_name $termux_name $win32_name)
127 +def new-from-github [
133 + use ./native-package-manager
135 + mut version = github fetch-latest-release-version
$org $name 136 + let version_extractor = (input --default
"v(.*)" $
"Github tag version is ($version). Choose version extractor regex: ")
137 + $version = (
$version | parse --regex
$version_extractor | get capture0.
0)
138 + print $
"Extracted version is ($version)" 139 + let binary_path =
$name 140 + let homepage = github fetch-homepage
$org $name 141 + let description = github fetch-description
$org $name 143 + let release_artifacts = github fetch-release-artifacts
$org $name 144 + let linux_x64_url =
if (
$release_artifacts | is-empty) { null }
else select-linux-x64-artifact
$release_artifacts 145 + let linux_aarch64_url =
if (
$release_artifacts | is-empty) { null }
else select-linux-aarch64-artifact
$release_artifacts 146 + let win32_x64_url =
if (
$release_artifacts | is-empty) { null }
else select-win32-x64-artifact
$release_artifacts 148 + let arch_names = native-package-manager arch query-packages
$name 149 + let arch_name =
if (
$arch_names | is-empty) { null }
else select-native-package-name
$arch_names $name $
"Pick the arch package name for ($name)" 151 + let fedora_names = native-package-manager fedora query-packages
$name 152 + let fedora_name =
if (
$fedora_names | is-empty) { null }
else select-native-package-name
$fedora_names $name $
"Pick the fedora package name for ($name)" 154 + let termux_names = native-package-manager termux query-packages
$name 155 + let termux_name =
if (
$termux_names | is-empty) { null }
else select-native-package-name
$termux_names $name $
"Pick the termux package name for ($name)" 157 + let win32_names = native-package-manager win32 query-packages
$name 158 + let win32_name =
if (
$win32_names | is-empty) { null }
else select-native-package-name
$win32_names $name $
"Pick the win32 package name for ($name)" 160 + return (make-manifest
$org $name 'github' $version $binary_path $homepage $description $version_extractor $linux_x64_url $linux_aarch64_url $win32_x64_url $fedora_name $arch_name $termux_name $win32_name)
169 + binary_path: string
171 + description: string
172 + version_extractor?: string
173 + linux_x64_url?: string
174 + linux_aarch64_url?: string
175 + win32_x64_url?: string
176 + fedora_name?: string
178 + termux_name?: string
179 + win32_name?: string
182 + 'organisation':
$org 185 + 'version':
$version 186 + 'version extractor':
$version_extractor 187 + 'relative binary path':
$binary_path 188 + 'homepage':
$homepage 189 + 'description':
$description 190 + 'linux x64 url':
$linux_x64_url 191 + 'linux aarch64 url':
$linux_aarch64_url 192 + 'win32 x64 url':
$win32_x64_url 193 + 'fedora package name':
$fedora_name 194 + 'arch package name':
$arch_name 195 + 'termux package name':
$termux_name 196 + 'win32 package name':
$win32_name 200 +def select-artifact [
201 + all_artifacts: table<name:string,content_type:string,browser_download_url:string>
202 + filtered_artifacts: table<name:string,content_type:string,browser_download_url:string>
205 + let filtered_length =
$filtered_artifacts | length
206 + if (
$filtered_length ==
0) { return null }
207 + if (
$filtered_length ==
1) { return (
$filtered_artifacts | get browser_download_url.
0) }
208 + let pick = (
$filtered_artifacts | input list --display name --fuzzy $
"Select the artifact for ($target):")
209 + if (
$pick | is-empty) { return null }
210 + return (
$pick | get browser_download_url)
213 +def select-linux-x64-artifact [
214 + artifacts: table<name:string,content_type:string,browser_download_url:string>
216 + let filtered_artifacts =
$artifacts | filter-by-linux | filter-by-x64
217 + select-artifact
$artifacts $filtered_artifacts "linux x64" 220 +def select-linux-aarch64-artifact [
221 + artifacts: table<name:string,content_type:string,browser_download_url:string>
223 + let filtered_artifacts =
$artifacts | filter-by-linux | filter-by-aarch64
224 + select-artifact
$artifacts $filtered_artifacts "linux aarch64" 227 +def select-win32-x64-artifact [
228 + artifacts: table<name:string,content_type:string,browser_download_url:string>
230 + let filtered_artifacts =
$artifacts | filter-by-win32 | filter-by-x64
231 + select-artifact
$artifacts $filtered_artifacts "win32 x64" 234 +def filter-by-linux []: table<name:string,content_type:string,browser_download_url:string> -> table<name:string,content_type:string,browser_download_url:string> {
235 + where name =~
'(?i)[\.\-_]linux' 236 + |
where name !~
'.sig$' 237 + |
where name !~
'.sha.*$' 238 + |
where name !~
'.apk$' 239 + |
where name !~
'.deb$' 240 + |
where name !~
'.rpm$' 243 +def filter-by-win32 []: table<name:string,content_type:string,browser_download_url:string> -> table<name:string,content_type:string,browser_download_url:string> {
244 + where name =~
'(?i)[\.\-_]win' 245 + |
where name !~
'.sig$' 246 + |
where name !~
'.sha.*$' 247 + |
where name !~
'.msi$' 250 +def filter-by-x64 []: table<name:string,content_type:string,browser_download_url:string> -> table<name:string,content_type:string,browser_download_url:string> {
251 + where name =~
'(?i)x64' or name =~
'(?i)x86_64' or name =~
'(?i)amd64' or name =~
'(?i)64bit' 254 +def filter-by-aarch64 []: table<name:string,content_type:string,browser_download_url:string> -> table<name:string,content_type:string,browser_download_url:string> {
255 + where name =~
'(?i)aarch64' or name =~
'(?i)arm64' 262 +def select-native-package-name [
263 + native_packages: table<name:string, description:string>
267 + if (
$native_packages | is-empty) { return null }
268 + let exact_matches =
$native_packages |
where name ==
$name 269 + if (
$exact_matches !=
0) and (
$exact_matches | length) ==
1 { return (
$exact_matches | get name.
0) }
270 + let pick =
$native_packages | input list --fuzzy
$prompt 271 + if (
$pick | is-not-empty) { return (
$pick | get name) }
275 +def package-exists [
279 + cd (folders manifests)
283 + $manifest.name == (make-manifest-file-name
$org $name)
287 +def make-unique-package-name [
294 +def make-manifest-file-name [
298 + (make-unique-package-name
$org $name) ++
'.nu'