Skip to content

Commit ff50eb7

Browse files
committed
Add GSoC Org that use GitHub
Closes coala#36
1 parent 59f8038 commit ff50eb7

8 files changed

+227
-0
lines changed

app/data/organizations.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// This file is going to be replaced in production builds.
12
export default {
23
'coala': {
34
name: 'coala association e.V.',

lib/.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
browser: false
5+
}
6+
};

lib/gsoc-org/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
const path = require('path');
5+
const wikidataGsocOrg = require('./wikidataGsocOrg');
6+
7+
module.exports = {
8+
name: 'gsoc-org',
9+
preBuild: function () {
10+
const fetch = this.project.require('node-fetch');
11+
const fs = this.project.require('fs-extra');
12+
if(this.app.env == 'production') {
13+
const orgPath = path.join(this.app.project.root, 'app',
14+
'data', 'organizations.js');
15+
16+
return wikidataGsocOrg(fetch).then((data) =>{
17+
const orgDefinition = "export default " + JSON.stringify(data);
18+
fs.writeFile(orgPath, orgDefinition);
19+
});
20+
21+
} else {
22+
return true;
23+
}
24+
},
25+
isDevelopingAddon() {
26+
return true;
27+
}
28+
};

lib/gsoc-org/package-lock.json

+83
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/gsoc-org/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "gsoc-org",
3+
"keywords": [
4+
"ember-addon"
5+
],
6+
"dependencies": {
7+
"fetch": "^1.1.0",
8+
"fs-extra": "^6.0.1",
9+
"node-fetch": "^2.1.2"
10+
}
11+
}

lib/gsoc-org/wikidataGsocOrg.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const ENDPOINT = "https://query.wikidata.org/sparql?format=json&query=";
2+
const QUERY = `
3+
SELECT DISTINCT ?orgLabel ?githubUsername
4+
WHERE {
5+
?org wdt:P1344 wd:Q54276825.
6+
?org wdt:P2037 ?githubUsername
7+
SERVICE wikibase:label { bd:serviceParam wikibase:language "id,en". }
8+
} ORDER BY ?orgLabel
9+
`
10+
11+
module.exports = function(fetch) {
12+
const toJson = (res) => {
13+
return res.json();
14+
};
15+
const format = (json) => {
16+
const mapToCompatibleOrg = (item) => {
17+
return {
18+
name: item['orgLabel']['value'],
19+
trackers: [
20+
{
21+
type: 'github',
22+
identifier: item['githubUsername']['value']
23+
}
24+
]
25+
}
26+
}
27+
const toObject = (object, item) => {
28+
return Object.assign(object, { [item['name']]: item});
29+
}
30+
return json['results']['bindings']
31+
.map(mapToCompatibleOrg)
32+
.reduce(toObject, {});
33+
};
34+
return fetch(ENDPOINT + encodeURIComponent(QUERY)).then(toJson).then(format);
35+
}

lib/gsoc-org/yarn.lock

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
6+
version "1.0.1"
7+
resolved "https://registry.yarnpkg.com/biskviit/-/biskviit-1.0.1.tgz#037a0cd4b71b9e331fd90a1122de17dc49e420a7"
8+
dependencies:
9+
psl "^1.1.7"
10+
11+
12+
version "0.1.12"
13+
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
14+
dependencies:
15+
iconv-lite "~0.4.13"
16+
17+
fetch@^1.1.0:
18+
version "1.1.0"
19+
resolved "https://registry.yarnpkg.com/fetch/-/fetch-1.1.0.tgz#0a8279f06be37f9f0ebb567560a30a480da59a2e"
20+
dependencies:
21+
biskviit "1.0.1"
22+
encoding "0.1.12"
23+
24+
fs-extra@^6.0.1:
25+
version "6.0.1"
26+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b"
27+
dependencies:
28+
graceful-fs "^4.1.2"
29+
jsonfile "^4.0.0"
30+
universalify "^0.1.0"
31+
32+
graceful-fs@^4.1.2, graceful-fs@^4.1.6:
33+
version "4.1.11"
34+
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
35+
36+
iconv-lite@~0.4.13:
37+
version "0.4.23"
38+
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
39+
dependencies:
40+
safer-buffer ">= 2.1.2 < 3"
41+
42+
jsonfile@^4.0.0:
43+
version "4.0.0"
44+
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
45+
optionalDependencies:
46+
graceful-fs "^4.1.6"
47+
48+
psl@^1.1.7:
49+
version "1.1.27"
50+
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.27.tgz#2b2c77019db86855170d903532400bf71ee085b6"
51+
52+
"safer-buffer@>= 2.1.2 < 3":
53+
version "2.1.2"
54+
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
55+
56+
universalify@^0.1.0:
57+
version "0.1.1"
58+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,10 @@
5454
"linkifyjs": "^2.1.6",
5555
"minimatch": "^3.0.3",
5656
"moment": "^2.22.1"
57+
},
58+
"ember-addon": {
59+
"paths": [
60+
"lib/gsoc-org"
61+
]
5762
}
5863
}

0 commit comments

Comments
 (0)