mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-08-16 08:50:31 +03:00
Port before_v0.60/make_release
folder (#830)
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 ```
This commit is contained in:
parent
2fe0756df9
commit
13f2c47135
@ -1,24 +0,0 @@
|
||||
def gen_keywords [] {
|
||||
let cmds = (help commands | where description != '' | get name | str collect '|')
|
||||
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)",'
|
||||
}
|
||||
$"Generating keywords(char nl)"
|
||||
gen_keywords
|
||||
char nl
|
||||
char nl
|
||||
|
||||
def gen_sub_keywords [] {
|
||||
let sub_cmds = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | reject name description)
|
||||
let preamble = "\\b("
|
||||
let postamble = ")\\b"
|
||||
let cmds = (for x in $sub_cmds {
|
||||
$"($x.base)\\s($x.sub)"
|
||||
} | str collect '|')
|
||||
$'"match": "($preamble)($cmds)($postamble)",'
|
||||
}
|
||||
$"Generating sub keywords(char nl)"
|
||||
gen_sub_keywords
|
||||
char nl
|
@ -1,94 +0,0 @@
|
||||
def gen-ts-cmds-begin [] {
|
||||
# hooray for multi-line strings
|
||||
build-string "import * as vscode from 'vscode';
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const keywordsWithSubCommandsProvider = vscode.languages.registerCompletionItemProvider(
|
||||
'nushell',
|
||||
{
|
||||
provideCompletionItems(
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken,
|
||||
context: vscode.CompletionContext
|
||||
) {
|
||||
"
|
||||
}
|
||||
|
||||
# generate typescript from nushell commands
|
||||
def gen-ts-cmds [] {
|
||||
# let cmds = (help commands | do -i { each { where $it.subcommands == $nothing }} | where description != '' | select name description)
|
||||
let cmds = (help commands | where description != '' | select name description)
|
||||
let updated_cmds = (echo $cmds | insert camel { build-string $it.name 'Completion' | str camel-case } )
|
||||
|
||||
let ts = (echo $updated_cmds |
|
||||
each {
|
||||
let line1 = (build-string " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" (char newline))
|
||||
let line2 = (build-string " " $it.camel ".commitCharacters = [' '];" (char newline) (char newline))
|
||||
$line1 + $line2
|
||||
} | str collect)
|
||||
|
||||
build-string (echo $ts) (char nl) " return [ " (echo $updated_cmds | get camel | str collect ', ') " ];" (char nl) ' },' (char nl) ' }' (char nl) ' );' (char nl) (char nl) | str collect
|
||||
}
|
||||
|
||||
# generate typescript from nushell subcommands
|
||||
def gen-ts-subs [] {
|
||||
let cmds = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten)
|
||||
let updated_cmds = (echo $cmds | insert camelProvider {build-string $it.base 'SubCommandsProvider' | str camel-case } | insert method {build-string $it.name | str camel-case})
|
||||
let subs_count = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd cmd_count | update cmd_count { get cmd_count | length })
|
||||
let subs_collection = (help commands | get subcommands | insert base { get name | split column ' ' base sub} | flatten | group-by base | pivot cmd sub_cmds)
|
||||
|
||||
let ts = (echo $subs_collection |
|
||||
each {
|
||||
let preamble = (get sub_cmds | each --numbered {
|
||||
let method = (build-string $it.item.name | str camel-case)
|
||||
let camel = (build-string $it.item.base 'SubCommandsProvider' | str camel-case)
|
||||
if $it.index == 0 {
|
||||
let line01 = (build-string " const " $camel " = vscode.languages.registerCompletionItemProvider(" (char newline))
|
||||
let line02 = (build-string " 'nushell'," (char nl))
|
||||
let line03 = (build-string " {" (char nl))
|
||||
let line04 = (build-string " provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {" (char nl) (char nl))
|
||||
let line05 = (build-string " const linePrefix = document.lineAt(position).text.substr(0, position.character);" (char nl))
|
||||
let line06 = (build-string " if (linePrefix.endsWith('" $it.item.base " ')) {" (char nl) (char nl))
|
||||
let line07 = (build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl))
|
||||
let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl))
|
||||
$line01 + $line02 + $line03 + $line04 + $line05 + $line06 + $line07 + $line08
|
||||
} {
|
||||
let line07 = (build-string " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl))
|
||||
let line08 = (build-string ' ' $method '.detail = "' $it.item.description '";' (char nl) (char nl))
|
||||
$line07 + $line08
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
let methods = (echo $it.sub_cmds.name | str camel-case | str collect ', ')
|
||||
|
||||
let lines = $"
|
||||
return [
|
||||
($methods)
|
||||
];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
},
|
||||
' '
|
||||
);
|
||||
"
|
||||
|
||||
build-string $preamble $lines
|
||||
} | str collect)
|
||||
|
||||
echo $subs_collection |
|
||||
let post01 = (build-string " context.subscriptions.push(" (char nl))
|
||||
let post02 = (build-string " " (echo $updated_cmds | get camelProvider | uniq | str collect ', ') (char nl))
|
||||
let post03 = (build-string " );" (char nl) "}" (char nl))
|
||||
|
||||
build-string $ts $post01 $post02 $post03
|
||||
}
|
||||
|
||||
# def log [message:any] {
|
||||
# let now = (date now | date format '%Y%m%d_%H%M%S.%f')
|
||||
# let mess = (build-string $now '|DBG|' $message (char newline))
|
||||
# echo $mess | autoview
|
||||
# }
|
||||
|
||||
build-string (gen-ts-cmds-begin) (gen-ts-cmds) (gen-ts-subs) | save extension.ts
|
@ -1,17 +0,0 @@
|
||||
cd crates
|
||||
|
||||
let first-wave = [nu-path, nu-ansi-term, nu-pretty-hex, nu-source, nu-errors, nu-protocol, nu-value-ext, nu-test-support, nu-table, nu-data, nu-parser, nu-plugin, nu-stream, nu-engine, nu-json, nu-serde]
|
||||
|
||||
echo $first-wave | each { enter $it; cargo publish; exit; sleep 1min }
|
||||
|
||||
let second-wave = [nu-command, nu-completion, nu-cli]
|
||||
|
||||
echo $second-wave | each { enter $it; cargo publish --no-verify; exit; sleep 1min }
|
||||
|
||||
ls nu_plugin_* | each { enter $it.name; cargo publish; exit }
|
||||
|
||||
sleep 1min
|
||||
|
||||
cd ..
|
||||
|
||||
cargo publish
|
@ -1,66 +0,0 @@
|
||||
# fetch https://api.github.com/repos/nushell/nushell/pulls?q=is%3Apr+merged%3A%3E%3D2021-04-20+ | select html_url user.login title body
|
||||
# fetch https://api.github.com/search/issues?q=repo:nushell/nushell+is:pr+is:merged+merged:%3E2021-05-08 | get items | select html_url user.login title body
|
||||
# Repos to monitor
|
||||
|
||||
def do-work [] {
|
||||
let site_table = [
|
||||
[site repo];
|
||||
[Nushell nushell]
|
||||
[Extension vscode-nushell-lang]
|
||||
[Documentation nushell.github.io]
|
||||
[Wasm demo]
|
||||
[Nu_Scripts nu_scripts] [RFCs rfcs]
|
||||
# ] [Jupyter jupyter]
|
||||
]
|
||||
|
||||
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
|
||||
let query_date = (seq date --days 21 -r | last)
|
||||
# We're looking for something like "is:pr is:merged merged:>=2021-05-31&per_page=100&page=1"
|
||||
let per_page = "100"
|
||||
let page_num = "1" # need to implement iterating pages
|
||||
let colon = "%3A"
|
||||
let gt = "%3E"
|
||||
let eq = "%3D"
|
||||
let amp = "%26"
|
||||
let query_suffix = $"+is($colon)pr+is($colon)merged+merged($colon)($gt)($eq)($query_date)&per_page=100&page=1"
|
||||
|
||||
let entries = ($site_table | each {
|
||||
let query_string = $"($query_prefix)($it.repo)($query_suffix)"
|
||||
echo $query_string
|
||||
let site_json = (fetch $query_string | get items | select html_url user.login title body)
|
||||
$"## ($it.site)(char nl)(char nl)"
|
||||
if ($site_json | all? ($it | empty?)) {
|
||||
$"none found this week(char nl)(char nl)"
|
||||
} {
|
||||
$site_json | group-by user_login | pivot user prs | each { |row|
|
||||
let user_name = $row.user
|
||||
let pr_count = ($row.prs | length)
|
||||
|
||||
# only print the comma if there's another item
|
||||
let user_prs = ($row.prs | each -n { |pr|
|
||||
if $pr_count == ($pr.index + 1) {
|
||||
$"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl)"
|
||||
} {
|
||||
$"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl) and (char nl)"
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
$"### **($user_name)**(char nl)(char nl)---(char nl)($user_prs)(char nl)"
|
||||
} | str collect
|
||||
char nl
|
||||
}
|
||||
|
||||
# We need 2 seconds between fetches or github's api limiting will limit us
|
||||
sleep 2sec
|
||||
})
|
||||
|
||||
if ($entries | all? (echo $it | empty?)) {
|
||||
} {
|
||||
$entries | str collect
|
||||
}
|
||||
}
|
||||
|
||||
# 2019-08-23 was the release of 0.2.0, the first public release
|
||||
let week_num = (seq date -b '2019-08-23' -n 7 | length)
|
||||
$"# This week in Nushell #($week_num)(char nl)(char nl)"
|
||||
do-work | str collect
|
@ -1,71 +0,0 @@
|
||||
# fetch https://api.github.com/repos/nushell/nushell/pulls?q=is%3Apr+merged%3A%3E%3D2021-04-20+ | select html_url user.login title body
|
||||
# fetch https://api.github.com/search/issues?q=repo:nushell/nushell+is:pr+is:merged+merged:%3E2021-05-08 | get items | select html_url user.login title body
|
||||
# Repos to monitor
|
||||
|
||||
def do-work [] {
|
||||
let site_table = [
|
||||
[site repo];
|
||||
[Nushell nushell]
|
||||
[Extension vscode-nushell-lang]
|
||||
[Documentation nushell.github.io]
|
||||
[Wasm demo]
|
||||
[Nu_Scripts nu_scripts]
|
||||
[RFCs rfcs]
|
||||
[engine-q engine-q]
|
||||
[reedline reedline]
|
||||
# ] [Jupyter jupyter]
|
||||
]
|
||||
|
||||
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
|
||||
let query_date = (seq date --days 7 -r | last)
|
||||
let per_page = "100"
|
||||
let page_num = "1" # need to implement iterating pages
|
||||
let colon = "%3A"
|
||||
let gt = "%3E"
|
||||
let eq = "%3D"
|
||||
let amp = "%26"
|
||||
let query_suffix = $"+is($colon)pr+is($colon)merged+merged($colon)($gt)($eq)($query_date)&per_page=100&page=1"
|
||||
|
||||
let entries = ($site_table | each {
|
||||
let query_string = $"($query_prefix)($it.repo)($query_suffix)"
|
||||
# this is for debugging the rate limit. comment it out if things are working well
|
||||
# fetch -u $nu.env.GITHUB_USERNAME -p $nu.env.GITHUB_PASSWORD https://api.github.com/rate_limit | get resources | select core.limit core.remaining graphql.limit graphql.remaining integration_manifest.limit integration_manifest.remaining search.limit search.remaining
|
||||
let site_json = (fetch -u $nu.env.GITHUB_USERNAME -p $nu.env.GITHUB_PASSWORD $query_string | get items | select html_url user.login title)
|
||||
$"## ($it.site)(char nl)(char nl)"
|
||||
if ($site_json | all? ($it | empty?)) {
|
||||
$"none found this week(char nl)(char nl)"
|
||||
} {
|
||||
$site_json | group-by user_login | pivot user prs | each { |row|
|
||||
let user_name = $row.user
|
||||
let pr_count = ($row.prs | length)
|
||||
|
||||
# only print the comma if there's another item
|
||||
let user_prs = ($row.prs | each -n { |pr|
|
||||
if $pr_count == ($pr.index + 1) {
|
||||
$"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)"
|
||||
} {
|
||||
$"[($pr.item.title)](char lparen)($pr.item.html_url)(char rparen), and "
|
||||
}
|
||||
} | str collect)
|
||||
|
||||
$"- ($user_name) created ($user_prs) (char nl)"
|
||||
} | str collect
|
||||
char nl
|
||||
}
|
||||
})
|
||||
|
||||
if ($entries | all? ($it | empty?)) {
|
||||
} {
|
||||
$entries | str collect
|
||||
}
|
||||
}
|
||||
|
||||
# 2019-08-23 was the release of 0.2.0, the first public release
|
||||
let week_num = (seq date -b '2019-08-23' -n 7 | length)
|
||||
$"# This week in Nushell #($week_num)(char nl)(char nl)"
|
||||
|
||||
if ($nu.env | select GITHUB_USERNAME | empty?) or ($nu.env | select GITHUB_PASSWORD | empty?) {
|
||||
echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $nu.env to use this script'
|
||||
} {
|
||||
do-work | str collect
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
def gen_keywords [] {
|
||||
let cmds = ($nu.scope.commands
|
||||
let cmds = (scope commands
|
||||
| where is_extern == false
|
||||
and is_custom == false
|
||||
and category !~ deprecated
|
||||
and ($it.command | str contains -n ' ')
|
||||
| get command
|
||||
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)'
|
||||
@ -12,46 +12,46 @@ def gen_keywords [] {
|
||||
let postamble = ')\\b'
|
||||
$'"match": "($var_with_dash_or_under_regex)|($preamble)($cmds)($postamble)",'
|
||||
}
|
||||
$"Generating keywords(char nl)"
|
||||
gen_keywords
|
||||
char nl
|
||||
char nl
|
||||
print $"Generating keywords(char nl)"
|
||||
print (gen_keywords)
|
||||
print (char nl)
|
||||
print (char nl)
|
||||
|
||||
def gen_sub_keywords [] {
|
||||
let sub_cmds = ($nu.scope.commands
|
||||
let sub_cmds = (scope commands
|
||||
| where is_extern == false
|
||||
and is_custom == false
|
||||
and category !~ deprecated
|
||||
and ($it.command | str contains ' ')
|
||||
| get command)
|
||||
and ($it.name | str contains ' ')
|
||||
| get name)
|
||||
|
||||
let preamble = '\\b('
|
||||
let postamble = ')\\b'
|
||||
let cmds = (for x in $sub_cmds {
|
||||
let cmds = ($sub_cmds | each {|x|
|
||||
let parts = ($x | split row ' ')
|
||||
$'($parts.0)\\s($parts.1)'
|
||||
} | str join '|')
|
||||
$'"match": "($preamble)($cmds)($postamble)",'
|
||||
}
|
||||
$"Generating sub keywords(char nl)"
|
||||
gen_sub_keywords
|
||||
char nl
|
||||
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 = ($nu.scope.commands
|
||||
let cmds = (scope commands
|
||||
| where is_extern == false
|
||||
and is_custom == false
|
||||
and category !~ deprecated
|
||||
and ($it.command | str contains -n ' ')
|
||||
| get command)
|
||||
and ($it.name | str contains -n ' ')
|
||||
| get name)
|
||||
|
||||
let preamble = '\\b('
|
||||
let postamble = ')\\b'
|
||||
|
||||
|
||||
for alpha in $alphabet {
|
||||
let letter_cmds = (for cmd in $cmds {
|
||||
$alphabet | each {|alpha|
|
||||
let letter_cmds = ($cmds | each {|cmd|
|
||||
if ($cmd | str starts-with $alpha) {
|
||||
$cmd
|
||||
} else {
|
||||
@ -64,25 +64,25 @@ def gen_keywords_alphabetically [] {
|
||||
} | str join "\n"
|
||||
}
|
||||
|
||||
"Generating keywords alphabetically\n"
|
||||
gen_keywords_alphabetically
|
||||
char nl
|
||||
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 = ($nu.scope.commands
|
||||
let sub_cmds = (scope commands |
|
||||
| where is_extern == false
|
||||
and is_custom == false
|
||||
and category !~ deprecated
|
||||
and ($it.command | str contains ' ')
|
||||
| get command)
|
||||
and ($it.name | str contains ' ')
|
||||
| get name)
|
||||
|
||||
let preamble = '\\b('
|
||||
let postamble = ')\\b'
|
||||
|
||||
|
||||
for alpha in $alphabet {
|
||||
let letter_cmds = (for cmd in $sub_cmds {
|
||||
$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)'
|
||||
@ -96,6 +96,6 @@ def gen_sub_keywords_alphabetically [] {
|
||||
} | str join "\n"
|
||||
}
|
||||
|
||||
"Generating sub keywords alphabetically\n"
|
||||
gen_sub_keywords_alphabetically
|
||||
char nl
|
||||
print "Generating sub keywords alphabetically\n"
|
||||
print (gen_sub_keywords_alphabetically)
|
||||
print (char nl)
|
||||
|
93
make_release/gen-ts-ext.nu
Normal file
93
make_release/gen-ts-ext.nu
Normal file
@ -0,0 +1,93 @@
|
||||
def gen-ts-cmds-begin [] {
|
||||
# hooray for multi-line strings
|
||||
[ "import * as vscode from 'vscode';
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const keywordsWithSubCommandsProvider = vscode.languages.registerCompletionItemProvider(
|
||||
'nushell',
|
||||
{
|
||||
provideCompletionItems(
|
||||
document: vscode.TextDocument,
|
||||
position: vscode.Position,
|
||||
token: vscode.CancellationToken,
|
||||
context: vscode.CompletionContext
|
||||
) {
|
||||
" ] | str join
|
||||
}
|
||||
|
||||
# generate typescript from nushell commands
|
||||
def gen-ts-cmds [] {
|
||||
let cmds = (scope commands | where usage != '' | select name usage)
|
||||
let updated_cmds = (echo $cmds | insert camel {|it| $it.name + 'Completion' | str camel-case } )
|
||||
|
||||
let ts = (echo $updated_cmds |
|
||||
each {|it|
|
||||
let line1 = ([ " const " $it.camel " = new vscode.CompletionItem('" $it.name "');" (char newline) ] | str join)
|
||||
let line2 = ([ " " $it.camel ".commitCharacters = [' '];" (char newline) (char newline) ] | str join)
|
||||
$line1 + $line2
|
||||
} | str join)
|
||||
|
||||
[
|
||||
(echo $ts) (char nl)
|
||||
" return [ "
|
||||
(echo $updated_cmds | get camel | str join ', ')
|
||||
" ];"
|
||||
(char nl) ' },' (char nl), ' }' (char nl) ' );'
|
||||
(char nl) (char nl)
|
||||
] | str join
|
||||
}
|
||||
|
||||
# generate typescript from nushell subcommands
|
||||
def gen-ts-subs [] {
|
||||
let cmds = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub } | flatten --all)
|
||||
let updated_cmds = (echo $cmds | insert camelProvider {|row| $row.base + 'SubCommandsProvider' | str camel-case } | insert method {|row| $row.name | str camel-case})
|
||||
let subs_count = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd cmd_count | update cmd_count { get cmd_count | length })
|
||||
let subs_collection = (scope commands | where is_sub == true | select name usage | insert base { get name | split column ' ' base sub} | flatten --all | group-by base | transpose cmd sub_cmds)
|
||||
|
||||
let ts = ($subs_collection | each {|it|
|
||||
let preamble = (get sub_cmds | enumerate | each {|it|
|
||||
let method = ([ $it.item.name | str camel-case ] | str join)
|
||||
let camel = ([ $it.item.base 'SubCommandsProvider' | str camel-case ] | str join)
|
||||
if $it.index == 0 {
|
||||
let line01 = ([" const " $camel " = vscode.languages.registerCompletionItemProvider(" (char newline)] | str join)
|
||||
let line02 = ([" 'nushell'," (char nl)] | str join)
|
||||
let line03 = ([" {" (char nl)] | str join)
|
||||
let line04 = ([ " provideCompletionItems(document: vscode.TextDocument, position: vscode.Position) {" (char nl) (char nl) ] | str join)
|
||||
let line05 = ([ " const linePrefix = document.lineAt(position).text.substr(0, position.character);" (char nl) ] | str join)
|
||||
let line06 = ([ " if (linePrefix.endsWith('" $it.item.base " ')) {" (char nl) (char nl) ] | str join)
|
||||
let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join)
|
||||
let line08 = ([ ' ' $method '.detail = "' $it.item.usage '";' (char nl) (char nl) ] | str join)
|
||||
$line01 + $line02 + $line03 + $line04 + $line05 + $line06 + $line07 + $line08
|
||||
} else {
|
||||
let line07 = ([ " const " $method " = new vscode.CompletionItem('" $it.item.sub "', vscode.CompletionItemKind.Method);" (char nl) ] | str join)
|
||||
let line08 = ([ ' ' $method '.detail = "' $it.item.usage '";' (char nl) (char nl) ] | str join)
|
||||
$line07 + $line08
|
||||
}
|
||||
} | str join)
|
||||
|
||||
let methods = (echo $it.sub_cmds.name | str camel-case | str join ', ')
|
||||
|
||||
let lines = $"
|
||||
return [
|
||||
($methods)
|
||||
];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
},
|
||||
' '
|
||||
);
|
||||
"
|
||||
|
||||
$preamble + $lines
|
||||
} | str join)
|
||||
|
||||
let post01 = (" context.subscriptions.push(" + (char nl))
|
||||
let post02 = ([ " " (echo $updated_cmds | get camelProvider | uniq | str join ', ') (char nl) ] | str join)
|
||||
let post03 = ([ " );" (char nl) "}" (char nl) ] | str join)
|
||||
|
||||
[$ts $post01 $post02 $post03] | str join
|
||||
}
|
||||
|
||||
|
||||
[ (gen-ts-cmds-begin) (gen-ts-cmds) (gen-ts-subs) ] | str join | save -f extension.ts
|
62
make_release/this_week_in_nu_release.nu
Normal file
62
make_release/this_week_in_nu_release.nu
Normal file
@ -0,0 +1,62 @@
|
||||
# http get https://api.github.com/repos/nushell/nushell/pulls?q=is%3Apr+merged%3A%3E%3D2021-04-20+ | select html_url user.login title body
|
||||
# http get https://api.github.com/search/issues?q=repo:nushell/nushell+is:pr+is:merged+merged:%3E2021-05-08 | get items | select html_url user.login title body
|
||||
# Repos to monitor
|
||||
|
||||
def do-work [] {
|
||||
let site_table = [
|
||||
[site repo];
|
||||
[Nushell nushell]
|
||||
[Extension vscode-nushell-lang]
|
||||
[Documentation nushell.github.io]
|
||||
[Wasm demo]
|
||||
[Nu_Scripts nu_scripts] [RFCs rfcs]
|
||||
# ] [Jupyter jupyter]
|
||||
]
|
||||
|
||||
let query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
|
||||
let query_date = (seq date --days 21 -r | last)
|
||||
# We're looking for something like "is:pr is:merged merged:>=2021-05-31&per_page=100&page=1"
|
||||
let per_page = "100"
|
||||
let page_num = "1" # need to implement iterating pages
|
||||
let colon = "%3A"
|
||||
let gt = "%3E"
|
||||
let eq = "%3D"
|
||||
let amp = "%26"
|
||||
let query_suffix = $"+is($colon)pr+is($colon)merged+merged($colon)($gt)($eq)($query_date)&per_page=100&page=1"
|
||||
|
||||
let entries = ($site_table | each {|it|
|
||||
let query_string = $"($query_prefix)($it.repo)($query_suffix)"
|
||||
let site_json = (http get -u $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD $query_string | get items | select html_url user.login title body)
|
||||
print $"## ($it.site)(char nl)(char nl)"
|
||||
if ($site_json | all {is-empty}) {
|
||||
print $"none found this week(char nl)(char nl)"
|
||||
} else {
|
||||
print ($site_json | group-by user_login | transpose user prs | each { |row|
|
||||
let user_name = $row.user
|
||||
let pr_count = ($row.prs | length)
|
||||
|
||||
# only print the comma if there's another item
|
||||
let user_prs = ($row.prs | enumerate | each { |pr|
|
||||
if $pr_count == ($pr.index + 1) {
|
||||
print $"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl)"
|
||||
} else {
|
||||
print $"(char nl)### [($pr.item.title)](char lparen)($pr.item.html_url)(char rparen)(char nl)(char nl)($pr.item.body)(char nl) and (char nl)"
|
||||
}
|
||||
} | str join)
|
||||
|
||||
print $"### **($user_name)**(char nl)(char nl)---(char nl)($user_prs)(char nl)"
|
||||
} | str join)
|
||||
print (char nl)
|
||||
}
|
||||
|
||||
# We need 2 seconds between fetches or github's api limiting will limit us
|
||||
sleep 2sec
|
||||
})
|
||||
|
||||
$entries | str join
|
||||
}
|
||||
|
||||
# 2019-08-23 was the release of 0.2.0, the first public release
|
||||
let week_num = (seq date -b '2019-08-23' -n 7 | length)
|
||||
print $"# This week in Nushell #($week_num)(char nl)(char nl)"
|
||||
print (do-work | str join)
|
@ -56,7 +56,7 @@ def query-week-span [] {
|
||||
let week_num = ((seq date -b '2019-08-23' -n 7 | length) - 1)
|
||||
print $"# This week in Nushell #($week_num)(char nl)"
|
||||
|
||||
if ($env | select GITHUB_USERNAME | is-empty) or ($env | select GITHUB_PASSWORD | is-empty) {
|
||||
if ($env | get -i GITHUB_USERNAME | is-empty) or ($env | get -i GITHUB_PASSWORD | is-empty) {
|
||||
print 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $env to use this script'
|
||||
} else {
|
||||
query-week-span
|
||||
|
Loading…
Reference in New Issue
Block a user