-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.nu
116 lines (98 loc) · 2.65 KB
/
tools.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use ('dotnu' | path join all-dotnu.nu) *
def main [] {}
def 'main test' [] {
test-parse-docstrings
test-dependencies
test-dependencies-keep_builtins
test-execute-update-examples-no-output
}
def 'main test-nupm' [] {
overlay use tests/nupm/test.nu --prefix as nupm
nupm test
}
def 'test-parse-docstrings' [] {
[tests assets '**' '*.nu']
| path join
| glob $in
| each {test-parse-docstrings-output-yaml}
}
def 'test-parse-docstrings-output-yaml' [] {
let $path = $in
{
open $path
| parse-docstrings
| to yaml
}
| do_closure_save_results $'parse-docstrings-($path | path parse | get stem).yaml'
}
def 'test-dependencies' [] {
{
glob ([tests assets b *] | path join)
| dependencies ...$in
| to yaml
}
| do_closure_save_results 'dependencies.yaml'
}
def 'test-dependencies-keep_builtins' [] {
{
glob ([tests assets b *] | path join)
| dependencies ...$in --keep_builtins
| to yaml
}
| do_closure_save_results 'dependencies --keep_bulitins.yaml'
}
def 'test-execute-update-examples-no-output' [] {
{
[tests assets c hello-no-output.nu]
| path join
| path expand
| update-docstring-examples $in --no_git_check --echo
}
| do_closure_save_results hello-no-output.txt
}
def do_closure_save_results [
...output_path_segments
] {
let closure = $in
let $output_file = ['tests' 'output-yaml' ...$output_path_segments] | path join
if ($output_file | path exists) {rm $output_file}
view source $closure
| lines | skip | drop | str trim
| each {$'# ($in)'}
| str join (char nl)
| $in + (char nl) + (do $closure) + (char nl)
| save -fr $output_file
print $'file created/updated ($output_file)'
}
def 'main release' [] {
let $git_info = (gh repo view --json description,name | from json);
let $git_tag = git tag
| lines
| prepend '0.0.0'
| sort -n
| last
| split row '.'
| into int
| update 2 {$in + 1}
| str join '.'
let $desc = ($git_info | get description)
open nupm.nuon
| update description ($desc | str replace -r $'^($git_info.name) - ' '')
| update version $git_tag
| save -f nupm.nuon
'README.md'
| if ($in | path exists) {
open -r
} else {"\n"}
| lines
| update 2 ('<h1 align="center">' + $desc + '</h1>')
# | update 2 $'# ($desc)'
| str join (char nl)
| $in + (char nl)
| save -f README.md
prettier README.md -w
git add nupm.nuon
git add README.md
git commit -m $'($git_tag) nupm version'
git tag $git_tag
}