mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
a little reorganization
This commit is contained in:
parent
19bd28d4f9
commit
0171910dfb
4 changed files with 0 additions and 0 deletions
94
make_release/gen-ts-ext.nu
Normal file
94
make_release/gen-ts-ext.nu
Normal file
|
@ -0,0 +1,94 @@
|
|||
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
|
17
make_release/nu_release.nu
Normal file
17
make_release/nu_release.nu
Normal file
|
@ -0,0 +1,17 @@
|
|||
cd crates
|
||||
|
||||
let first-wave = [nu-pretty-hex, nu-ansi-term, nu-source, nu-errors, nu-protocol, nu-value-ext, nu-test-support, nu-table, nu-parser, nu-plugin, nu-data, nu-stream, nu-engine, nu-json]
|
||||
|
||||
echo $first-wave | each { enter $it; cargo publish; exit; sleep 1min }
|
||||
|
||||
let second-wave = [nu-command, 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
|
59
make_release/this_week_in_nu_release.nu
Normal file
59
make_release/this_week_in_nu_release.nu
Normal file
|
@ -0,0 +1,59 @@
|
|||
# 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 7 -r | last)
|
||||
let query_suffix = $"+is:pr+is:merged+merged:%3E%3D($query_date)"
|
||||
|
||||
let entries = ($site_table | each {
|
||||
let query_string = $"($query_prefix)($it.repo)($query_suffix)"
|
||||
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
|
59
make_release/this_week_in_nu_weekly.nu
Normal file
59
make_release/this_week_in_nu_weekly.nu
Normal file
|
@ -0,0 +1,59 @@
|
|||
# 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 7 -r | last)
|
||||
let query_suffix = $"+is:pr+is:merged+merged:%3E%3D($query_date)"
|
||||
|
||||
let entries = ($site_table | each {
|
||||
let query_string = $"($query_prefix)($it.repo)($query_suffix)"
|
||||
let site_json = (fetch $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
|
||||
}
|
||||
|
||||
# We need 2 seconds between fetches or github's api limiting will limit us
|
||||
sleep 2sec
|
||||
})
|
||||
|
||||
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)"
|
||||
do-work | str collect
|
Loading…
Add table
Add a link
Reference in a new issue