mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-09-11 13:45:56 +03:00
This PR is part of porting all old scripts #221 and ports `make_release` folder ## Summary ### make_release/this_week_in_nu_weekly.nu This script has already been ported and has received some updates: #433. So I just removed it ```yaml from: before_v0.60/make_release/this_week_in_nu_weekly.nu to: make_release/this_week_in_nu_weekly.nu functions: do-work: make_release/this_week_in_nu_weekly.nu:1:query-week-span ``` ### make_release/this_week_in_nu_release.nu I have ported this, but I'm not sure if we need it because it has strange name and we have `prs.nu` and `make_release/release-note/` ```yaml from: before_v0.60/make_release/this_week_in_nu_release.nu to: make_release/this_week_in_nu_release.nu functions: do-work: make_release/this_week_in_nu_release.nu:1:do-work ``` ### make_release/nu_release.nu This has already been ported to `make_release/nu_release.nu` and has received new updates #828 so I just removed it ```yaml from: before_v0.60/make_release/nu_release.nu to: make_release/nu_release.nu ``` ### make_release/gen-js-ext.nu This has already been moved to `make_release/gen-js-ext.nu` and has received new updates #621 but not completely ported so I have ported it - pipeline `for` to `each` - `$nu.scope.commands` to `scope commands` - explicit `print` ```yaml from: before_v0.60/make_release/gen-js-ext.nu to: make_release/gen-js-ext.nu functions: gen_keywords: make_release/gen-js-ext.nu:1:gen_keywords gen_sub_keywords: make_release/gen-js-ext.nu:20:gen_sub_keywords ``` ### make_release/gen-ts-ext.nu I have ported this script ```yaml from: before_v0.60/make_release/gen-ts-ext.nu to: make_release/gen-ts-ext.nu functions: gen-ts-cmds-begin: make_release/gen-ts-ext.nu:1:gen-ts-cmds-begin gen-ts-cmds: make_release/gen-ts-ext.nu:18:gen-ts-cmds gen-ts-subs: make_release/gen-ts-ext.nu:40:gen-ts-subs ```
102 lines
3.0 KiB
Plaintext
102 lines
3.0 KiB
Plaintext
def gen_keywords [] {
|
|
let cmds = (scope commands
|
|
| where is_extern == false
|
|
and is_custom == false
|
|
and category !~ deprecated
|
|
and ($it.name | str contains -n ' ')
|
|
| get name
|
|
| str join '|')
|
|
|
|
let var_with_dash_or_under_regex = '(([a-zA-Z]+[\\-_]){1,}[a-zA-Z]+\\s)'
|
|
let preamble = '\\b('
|
|
let postamble = ')\\b'
|
|
$'"match": "($var_with_dash_or_under_regex)|($preamble)($cmds)($postamble)",'
|
|
}
|
|
print $"Generating keywords(char nl)"
|
|
print (gen_keywords)
|
|
print (char nl)
|
|
print (char nl)
|
|
|
|
def gen_sub_keywords [] {
|
|
let sub_cmds = (scope commands
|
|
| where is_extern == false
|
|
and is_custom == false
|
|
and category !~ deprecated
|
|
and ($it.name | str contains ' ')
|
|
| get name)
|
|
|
|
let preamble = '\\b('
|
|
let postamble = ')\\b'
|
|
let cmds = ($sub_cmds | each {|x|
|
|
let parts = ($x | split row ' ')
|
|
$'($parts.0)\\s($parts.1)'
|
|
} | str join '|')
|
|
$'"match": "($preamble)($cmds)($postamble)",'
|
|
}
|
|
print $"Generating sub keywords(char nl)"
|
|
print (gen_sub_keywords)
|
|
print (char nl)
|
|
|
|
def gen_keywords_alphabetically [] {
|
|
let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z]
|
|
let cmds = (scope commands
|
|
| where is_extern == false
|
|
and is_custom == false
|
|
and category !~ deprecated
|
|
and ($it.name | str contains -n ' ')
|
|
| get name)
|
|
|
|
let preamble = '\\b('
|
|
let postamble = ')\\b'
|
|
|
|
|
|
$alphabet | each {|alpha|
|
|
let letter_cmds = ($cmds | each {|cmd|
|
|
if ($cmd | str starts-with $alpha) {
|
|
$cmd
|
|
} else {
|
|
null
|
|
}
|
|
} | str join '|')
|
|
if ($letter_cmds | str trim | str length) > 0 {
|
|
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
|
}
|
|
} | str join "\n"
|
|
}
|
|
|
|
print "Generating keywords alphabetically\n"
|
|
print (gen_keywords_alphabetically)
|
|
print (char nl)
|
|
|
|
def gen_sub_keywords_alphabetically [] {
|
|
let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z]
|
|
let sub_cmds = (scope commands |
|
|
| where is_extern == false
|
|
and is_custom == false
|
|
and category !~ deprecated
|
|
and ($it.name | str contains ' ')
|
|
| get name)
|
|
|
|
let preamble = '\\b('
|
|
let postamble = ')\\b'
|
|
|
|
|
|
$alphabet | each {|alpha|
|
|
let letter_cmds = ($sub_cmds | each {|cmd|
|
|
if ($cmd | str starts-with $alpha) {
|
|
let parts = ($cmd | split row ' ')
|
|
$'($parts.0)\\s($parts.1)'
|
|
} else {
|
|
null
|
|
}
|
|
} | str join '|')
|
|
if ($letter_cmds | str trim | str length) > 0 {
|
|
$'"match": "($preamble)($letter_cmds)($postamble)",'
|
|
}
|
|
} | str join "\n"
|
|
}
|
|
|
|
print "Generating sub keywords alphabetically\n"
|
|
print (gen_sub_keywords_alphabetically)
|
|
print (char nl)
|