Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub org #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/data/organizations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file is going to be replaced in production builds.
export default {
coala: {
name: 'coala association e.V.',
Expand Down
6 changes: 6 additions & 0 deletions lib/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
node: true,
browser: false
}
};
28 changes: 28 additions & 0 deletions lib/gsoc-org/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-env node */
'use strict';

const path = require('path');
const wikidataGsocOrg = require('./wikidataGsocOrg');

module.exports = {
name: 'gsoc-org',
preBuild: function () {
const fetch = this.project.require('node-fetch');
const fs = this.project.require('fs-extra');
if(this.app.env == 'production') {
const orgPath = path.join(this.app.project.root, 'app',
'data', 'organizations.js');

return wikidataGsocOrg(fetch).then((data) =>{
const orgDefinition = "export default " + JSON.stringify(data);
fs.writeFile(orgPath, orgDefinition);
});

} else {
return true;
}
},
isDevelopingAddon() {
return true;
}
};
83 changes: 83 additions & 0 deletions lib/gsoc-org/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/gsoc-org/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "gsoc-org",
"keywords": [
"ember-addon"
],
"dependencies": {
"fetch": "^1.1.0",
"fs-extra": "^6.0.1",
"node-fetch": "^2.1.2"
}
}
35 changes: 35 additions & 0 deletions lib/gsoc-org/wikidataGsocOrg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const ENDPOINT = "https://query.wikidata.org/sparql?format=json&query=";
const QUERY = `
SELECT DISTINCT ?orgLabel ?githubUsername
WHERE {
?org wdt:P1344 wd:Q54276825.
?org wdt:P2037 ?githubUsername
SERVICE wikibase:label { bd:serviceParam wikibase:language "id,en". }
} ORDER BY ?orgLabel
`

module.exports = function(fetch) {
const toJson = (res) => {
return res.json();
};
const format = (json) => {
const mapToCompatibleOrg = (item) => {
return {
name: item['orgLabel']['value'],
trackers: [
{
type: 'github',
identifier: item['githubUsername']['value']
}
]
}
}
const toObject = (object, item) => {
return Object.assign(object, { [item['name']]: item});
}
return json['results']['bindings']
.map(mapToCompatibleOrg)
.reduce(toObject, {});
};
return fetch(ENDPOINT + encodeURIComponent(QUERY)).then(toJson).then(format);
}
58 changes: 58 additions & 0 deletions lib/gsoc-org/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


[email protected]:
version "1.0.1"
resolved "https://registry.yarnpkg.com/biskviit/-/biskviit-1.0.1.tgz#037a0cd4b71b9e331fd90a1122de17dc49e420a7"
dependencies:
psl "^1.1.7"

[email protected]:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"

fetch@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fetch/-/fetch-1.1.0.tgz#0a8279f06be37f9f0ebb567560a30a480da59a2e"
dependencies:
biskviit "1.0.1"
encoding "0.1.12"

fs-extra@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-6.0.1.tgz#8abc128f7946e310135ddc93b98bddb410e7a34b"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"

graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

iconv-lite@~0.4.13:
version "0.4.23"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
dependencies:
safer-buffer ">= 2.1.2 < 3"

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
optionalDependencies:
graceful-fs "^4.1.6"

psl@^1.1.7:
version "1.1.27"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.27.tgz#2b2c77019db86855170d903532400bf71ee085b6"

"safer-buffer@>= 2.1.2 < 3":
version "2.1.2"
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"

universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@
"linkifyjs": "^2.1.6",
"minimatch": "^3.0.3",
"moment": "^2.22.1"
},
"ember-addon": {
"paths": [
"lib/gsoc-org"
]
}
}