Skip to content

Commit 23618b0

Browse files
authored
feat: Setup scripts for create issues (#136)
1 parent f119f38 commit 23618b0

File tree

13 files changed

+898
-0
lines changed

13 files changed

+898
-0
lines changed

scripts/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GITHUB_TOKEN=<token>

scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

scripts/dotenv.nu

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use ./util.nu *
2+
3+
const path_self = path self | path dirname;
4+
5+
export def load [] {
6+
open $"($path_self)/.env"
7+
| parse "{key}={value}"
8+
| as record key value
9+
}

scripts/figma.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"title": "React - Avatar Group",
4+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=396-11202&t=ORNvP0zJ1AaVmw9c-0)"
5+
},
6+
{
7+
"title": "React - Badge",
8+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=934-7371&t=ORNvP0zJ1AaVmw9c-0)"
9+
},
10+
{
11+
"title": "React - Button",
12+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1220-15148&t=ORNvP0zJ1AaVmw9c-0)"
13+
},
14+
{
15+
"title": "React - Cards",
16+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1220-15306&t=ORNvP0zJ1AaVmw9c-0)"
17+
},
18+
{
19+
"title": "React - Calendar",
20+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1220-15415&t=ORNvP0zJ1AaVmw9c-0)"
21+
},
22+
{
23+
"title": "React - Chip",
24+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=54-919&t=ORNvP0zJ1AaVmw9c-0)"
25+
},
26+
{
27+
"title": "React - Dropdown",
28+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1016-1803&t=ORNvP0zJ1AaVmw9c-0)"
29+
},
30+
{
31+
"title": "React - Dropdown Tree",
32+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1018-4882&t=ORNvP0zJ1AaVmw9c-0)"
33+
},
34+
{
35+
"title": "React - Dropdown Topics",
36+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=936-7489&t=ORNvP0zJ1AaVmw9c-0)"
37+
},
38+
{
39+
"title": "React - Flap",
40+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=767-27573&t=ORNvP0zJ1AaVmw9c-0)"
41+
},
42+
{
43+
"title": "React - Form",
44+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1220-15433&t=ORNvP0zJ1AaVmw9c-0)"
45+
},
46+
{
47+
"title": "React - Icons",
48+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=24-117&t=ORNvP0zJ1AaVmw9c-0)"
49+
},
50+
{
51+
"title": "React - Input",
52+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=571-5872&t=ORNvP0zJ1AaVmw9c-0)"
53+
},
54+
{
55+
"title": "React - Level",
56+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=934-7363&t=ORNvP0zJ1AaVmw9c-0)"
57+
},
58+
{
59+
"title": "React - Progress Bar",
60+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1009-2104&t=ORNvP0zJ1AaVmw9c-0)"
61+
},
62+
{
63+
"title": "React - Radio",
64+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=956-18937&t=ORNvP0zJ1AaVmw9c-0)"
65+
},
66+
{
67+
"title": "React - Scrollbar",
68+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1102-13468&t=ORNvP0zJ1AaVmw9c-0)"
69+
},
70+
{
71+
"title": "React - Search Input",
72+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=1220-15416&t=ORNvP0zJ1AaVmw9c-0)"
73+
},
74+
{
75+
"title": "React - Tag",
76+
"body": "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.\n> [See component in figma](https://www.figma.com/design/S9yCZSaZ9q54XSojWNhJft/Rust-Lang-ES?node-id=59-1129&t=ORNvP0zJ1AaVmw9c-0)"
77+
}
78+
]

scripts/figma.nu

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use ./util.nu *
2+
use ./graphql.nu
3+
4+
const $path_self = path self | path dirname
5+
const TITLE_LEN = "React - " | str length
6+
const BODY_TXT = "If you want to contribute in this component, comment to this issue asking for assignment, and send a PR as draft as soon as possible.
7+
> [See component in figma]("
8+
const BODY_LEN = $BODY_TXT | str length
9+
10+
export def figma_json [] {
11+
open $"($path_self)/figma.json"
12+
| update title {str substring ($TITLE_LEN)..}
13+
| update body {str substring ($BODY_LEN)..(($in | str length) - 2)}
14+
| rename --column {title:name,body:url}
15+
}
16+
17+
export def "update figma_json" [] {
18+
graphql send query react-components-issues | to json | save -f $"($path_self)/figma.json"
19+
}
20+
21+
export def by_name [name?: string] : [
22+
nothing -> string
23+
string -> string
24+
] {
25+
let $name = $in
26+
| guard_filter "name" (metadata $name) $name
27+
figma_json | where name == $name | get -i 0.url
28+
}
29+
30+
export def "compose issue" [name?: string] : [
31+
nothing -> string
32+
string -> string
33+
] {
34+
let figma_url = $in | by_name $name
35+
$"($BODY_TXT)($figma_url))"
36+
}

scripts/graphql.nu

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
const REPO_OWNER = "\"RustLangES\""
2+
const REPO_NAME = "\"design-system-components\""
3+
const REPO_ID = "\"R_kgDOOz1xQg\""
4+
const PROJECT_ID = "\"PVT_kwDOBHON284A7coi\""
5+
const MILESTONE_ID = "\"MI_kwDOOz1xQs4AyIXX\""
6+
7+
export def "flatten nodes" [] : [
8+
table -> table
9+
record -> record
10+
] {
11+
let $input = $in
12+
$input
13+
| columns
14+
| reduce --fold $input {|c, acc|
15+
$acc
16+
| update $c {
17+
if ($in | describe) !~ "table|record" {
18+
$in
19+
} else if ($in | get -i nodes) == null {
20+
flatten nodes
21+
} else {
22+
flatten|flatten|flatten nodes
23+
}
24+
}
25+
}
26+
}
27+
28+
export def "send query" [$query:string, --dry, --verbose] : nothing -> record {
29+
let query_s = $query | compose_query $dry
30+
31+
if $verbose {
32+
print $"(ansi d)[GRAPHQL] send query\n($query_s)(ansi reset)"
33+
} else {
34+
print $"(ansi lg)[GRAPHQL] Send query(ansi reset)"
35+
}
36+
37+
let res = gh api graphql -f query=($query_s) | from json
38+
39+
if ($res | get -i errors) != null {
40+
print $"(ansi lrb)\n($res.errors | table -e)(ansi reset)"
41+
error make {
42+
msg: "Graphql error",
43+
label: {
44+
text: "Query",
45+
span: (metadata $query).span
46+
}
47+
}
48+
}
49+
50+
let res = $res.data
51+
52+
let rateLimit = $res.rateLimit
53+
54+
print $"(ansi lgb)[GRAPHQL] request success +($rateLimit.cost) \(($rateLimit.used) / ($rateLimit.limit)\)(ansi reset)"
55+
56+
$res | reject rateLimit | flatten nodes
57+
}
58+
59+
export def "send mutate" [$query:string, --verbose] : nothing -> record {
60+
let query_s = $query | compose_mutate
61+
62+
if $verbose {
63+
print $"(ansi d)[GRAPHQL] send query\n($query_s)(ansi reset)"
64+
} else {
65+
print $"(ansi lg)[GRAPHQL] Send query(ansi reset)"
66+
}
67+
68+
let res = gh api graphql -f query=($query_s) | from json
69+
70+
if ($res | get -i errors) != null {
71+
print $"(ansi lrb)\n($res.errors | table -e)(ansi reset)"
72+
error make {
73+
msg: "Graphql error",
74+
label: {
75+
text: "Query",
76+
span: (metadata $query).span
77+
}
78+
}
79+
}
80+
81+
let res = $res.data
82+
83+
send query "" --dry
84+
85+
$res
86+
}
87+
88+
export def "send mutate createIssue" [issue, --verbose] : nothing -> string {
89+
send mutate (mutate createIssue $issue) --verbose=$verbose | get -i createIssue.issue.id
90+
}
91+
92+
export def "send mutate addIssueToProject" [issue, --verbose] : nothing -> string {
93+
send mutate (mutate addIssueToProject $issue) --verbose=$verbose | get -i addProjectV2ItemById.item.id
94+
}
95+
96+
export def "send mutate updateProjectFieldSelect" [item fieldId valueId --verbose] : nothing -> nothing {
97+
send mutate (mutate updateProjectFieldSelect $item $fieldId $valueId) --verbose=$verbose
98+
99+
()
100+
}
101+
102+
export def "send query issues" [--dry, --verbose] : nothing -> record {
103+
send query (query issues) --dry=$dry --verbose=$verbose | get -i organization.repository.issues
104+
}
105+
106+
export def "send query all-new-components-issues" [--dry, --verbose] : nothing -> table {
107+
send query (query all-new-components-issues) --dry=$dry --verbose=$verbose
108+
| get -i organization.repository.issues
109+
| rename --column {state:isOpen}
110+
| update isOpen {$in == "OPEN"}
111+
| update labels {get name}
112+
}
113+
114+
export def "send query org-project-fields" [--dry, --verbose] : nothing -> record {
115+
send query (query org-project-fields) --dry=$dry --verbose=$verbose | get -i organization.projectV2.fields
116+
}
117+
118+
export def compose_mutate [] : string -> string {
119+
$in | $"
120+
mutation {
121+
($in | str trim)
122+
}
123+
" | str trim
124+
}
125+
126+
export def compose_query [$dry:bool] : string -> string {
127+
$in | $"
128+
query {
129+
($in | str trim)
130+
131+
rateLimit\(dryRun: ($dry)\) {
132+
cost
133+
remaining
134+
limit
135+
nodeCount
136+
used
137+
}
138+
}
139+
" | str trim
140+
}
141+
142+
export def "query issues" [] {
143+
$"
144+
organization\(login: ($REPO_OWNER)) {
145+
repository\(name: ($REPO_NAME)) {
146+
issues\(states: OPEN, first: 4, filterBy: { labels: \"New Support\" }) {
147+
nodes {
148+
id
149+
title
150+
bodyText
151+
}
152+
}
153+
}
154+
}
155+
"
156+
}
157+
158+
export def "query all-new-components-issues" [] {
159+
$"
160+
organization\(login: ($REPO_OWNER)) {
161+
repository\(name: ($REPO_NAME)) {
162+
id
163+
issues\(first: 100, labels: [\"New Support\" \"New Component\"]) {
164+
nodes {
165+
title
166+
state
167+
labels\(first: 5) {
168+
nodes {
169+
name
170+
}
171+
}
172+
}
173+
}
174+
}
175+
}
176+
"
177+
}
178+
179+
export def "query org-project-fields" [] {
180+
$"
181+
organization\(login: ($REPO_OWNER)) {
182+
projectV2\(number: 19) {
183+
fields\(first: 50) {
184+
nodes {
185+
__typename
186+
... on ProjectV2Field {
187+
id
188+
name
189+
dataType
190+
}
191+
... on ProjectV2SingleSelectField {
192+
id
193+
name
194+
options {
195+
id
196+
name
197+
}
198+
}
199+
}
200+
}
201+
}
202+
}
203+
"
204+
}
205+
206+
export def "mutate createIssue" [$issue:record] {
207+
let labels = $issue.labels | each {to json} | str join " ";
208+
209+
let input = $"
210+
title: ($issue.title|to json),
211+
repositoryId: ($REPO_ID)
212+
body: ($issue.content|to json),
213+
milestoneId: ($MILESTONE_ID),
214+
labelIds: [($labels)],
215+
issueTypeId: ($issue.issueType|to json),
216+
parentIssueId: ($issue.parentIssue|to json)
217+
" | str trim;
218+
219+
print $"(ansi d)[GRAPHQL] mutation createIssue\n($input)(ansi reset)"
220+
221+
$"
222+
createIssue\(input: {($input)}) {
223+
issue {
224+
id
225+
}
226+
}
227+
"
228+
}
229+
230+
export def "mutate addIssueToProject" [$issueId:string] {
231+
let input = $"
232+
contentId: ($issueId|to json)
233+
projectId: ($PROJECT_ID)
234+
" | str trim;
235+
236+
print $"(ansi d)[GRAPHQL] mutation addProjectV2ItemById\n($input)(ansi reset)"
237+
238+
$"
239+
addProjectV2ItemById\(input: {($input)}) {
240+
item {
241+
id
242+
}
243+
}
244+
"
245+
}
246+
247+
export def "mutate updateProjectFieldSelect" [$itemId:string, $fieldId:string, $valueId:string] {
248+
let input = $"
249+
projectId: ($PROJECT_ID)
250+
itemId: ($itemId|to json)
251+
fieldId: ($fieldId|to json)
252+
value: { singleSelectOptionId: ($valueId|to json) }
253+
" | str trim;
254+
255+
print $"(ansi d)[GRAPHQL] mutation updateProjectV2ItemFieldValue\n($input)(ansi reset)"
256+
257+
$"
258+
updateProjectV2ItemFieldValue\(input: {($input)}) {
259+
projectV2Item {
260+
id
261+
}
262+
}
263+
"
264+
}

0 commit comments

Comments
 (0)