1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

reorganize site in preparation for beta and releaes (#161)

This commit is contained in:
Darren Schroeder 2022-02-25 13:10:38 -06:00 committed by GitHub
parent 7b76a8e662
commit ca89da5242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 1402 additions and 763 deletions

View file

@ -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

View file

@ -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

View file

@ -1,14 +1,15 @@
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]
let first-wave = [nu-system, nu-term-grid, nu-path, nu-ansi-term, nu-pretty-hex, nu-json, nu-protocol, nu-engine, nu-plugin, nu-table, nu-color-config,
nu-parser, nu-test-support, nu-cli]
echo $first-wave | each { enter $it; cargo publish; exit; sleep 1min }
echo $first-wave | each { |cratedir| enter $cratedir; cargo publish; exit; sleep 1min }
let second-wave = [nu-command, nu-completion, nu-cli]
let second-wave = [nu-command]
echo $second-wave | each { enter $it; cargo publish --no-verify; exit; sleep 1min }
echo $second-wave | each { |cratedir| enter $cratedir; cargo publish --no-verify; exit; sleep 1min }
ls nu_plugin_* | each { enter $it.name; cargo publish; exit }
ls nu_plugin_* | each { |plugin| enter $plugin.name; cargo publish; exit }
sleep 1min

View file

@ -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

View file

@ -3,69 +3,69 @@
# 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 site_table = [
[site repo];
[Nushell nushell]
[Extension vscode-nushell-lang]
[Documentation nushell.github.io]
[Wasm demo]
[Nu_Scripts nu_scripts]
[RFCs rfcs]
[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 query_prefix = "https://api.github.com/search/issues?q=repo:nushell/"
let query_date = (seq date --days 7 -r | get 6)
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)
let entries = ($site_table | each { |row|
let query_string = $"($query_prefix)($row.repo)($query_suffix)"
# this is for debugging the rate limit. comment it out if things are working well
# fetch -u $env.GITHUB_USERNAME -p $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 $env.GITHUB_USERNAME -p $env.GITHUB_PASSWORD $query_string | get items | select html_url user.login title)
$"## ($row.site)(char nl)(char nl)"
if ($site_json | all? ($it | empty?)) {
$"none found this week(char nl)(char nl)"
} else {
$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 | 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)
# 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)"
} else {
$"[($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
}
})
$"- ($user_name) created ($user_prs) (char nl)"
} | str collect
char nl
}
})
if ($entries | all? ($it | empty?)) {
} {
$entries | str collect
}
if ($entries | all? ($it | empty?)) {
# do nothing
} else {
$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)
let week_num = ((seq date -b '2019-08-23' -n 7 | length) - 1)
$"# This week in Nushell #($week_num)(char nl)(char nl)"
if ($nu.env | select GITHUB_USERNAME | empty?) || ($nu.env | select GITHUB_PASSWORD | empty?) {
echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $nu.env to use this script'
} {
if ($env | select GITHUB_USERNAME | empty?) || ($env | select GITHUB_PASSWORD | empty?) {
echo 'Please set GITHUB_USERNAME and GITHUB_PASSWORD in $env to use this script'
} else {
do-work | str collect
}