-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransforms.js
56 lines (55 loc) · 1.63 KB
/
transforms.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* JSONata expression to transform a GitHub GraphQL repository query result
* into Code.gov metadata schema format.
*
* This transform meets the Code.gov schema minimum requirements, plus tries
* to make the most use of available GitHub metadata.
*/
export const defaultGitHubTransform = `{
"name": name,
"description": $boolean(description) ? description : name,
"permissions": {
"licenses": $boolean(licenseInfo) ? [
{
"URL": [licenseInfo].url,
"name": [licenseInfo].key
}
] : null,
"usageType": isPrivate ? "governmentWideReuse" : "openSource"
},
"tags": $boolean(repositoryTopics.nodes) ? repositoryTopics[].nodes.topic.name : owner[].login,
"repositoryURL": url,
"homepageURL": $boolean(homepageUrl) ? homepageUrl : undefined,
"contact": {
"email": owner.email
},
"languages": languages[].nodes.name,
"laborHours": 0,
"vcs": "git",
"organization": owner.login
}`
/**
* JSONata expression to transform a GitHub GraphQL repository query result
* into Code.gov metadata schema format.
*
* This transform provides the bare minimum required by Code.gov.
*/
export const minimumGitHubTransform = `{
"name": name,
"description": $boolean(description) ? description : name,
"permissions": {
"licenses": $boolean(licenseInfo) ? [
{
"URL": [licenseInfo].url,
"name": [licenseInfo].key
}
] : null,
"usageType": isPrivate ? "governmentWideReuse" : "openSource"
},
"tags": $boolean(repositoryTopics.nodes) ? repositoryTopics[].nodes.topic.name : owner[].login,
"repositoryURL": url,
"contact": {
"email": owner.email
},
"laborHours": 0
}`