Skip to content

Commit

Permalink
Merge pull request #11 from Turbo87/missing-apis
Browse files Browse the repository at this point in the history
Add "generate-missing-apis-list" script
  • Loading branch information
rwjblue authored Jul 5, 2017
2 parents 5ffc533 + 9bb9139 commit fc8d982
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 1 deletion.
175 changes: 175 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"url": "git+https://github.com/ember-cli/ember-rfc176-data.git"
},
"devDependencies": {
"chalk": "^1.1.3"
"chalk": "^1.1.3",
"got": "^7.1.0"
}
}
54 changes: 54 additions & 0 deletions scripts/generate-missing-apis-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env node

const got = require('got');
const chalk = require("chalk");

const globals = require("../globals.json");

got('http://builds.emberjs.com/canary/ember-docs.json').then(response => {
let json = JSON.parse(response.body);
processJSON(json);

}).catch(error => {
console.error(chalk.red(error));
});

function processJSON(json) {
let staticClasses = Object.keys(json.classes)
.map(it => json.classes[it])
.filter(it => it.static)
.map(it => it.name);

json.classitems
.filter(it => it.access === 'public')
.filter(it => staticClasses.indexOf(it.class) !== -1)
.forEach(it => {
if (!it.name) { return; }

let globalName = `${it.class}.${it.name}`;
let globalsKey = globalName.replace(/^Ember\./, '');
let newImport = globals[globalsKey];

if (newImport) {
console.log(chalk.green(`${globalName} -> ${newImport}`));
} else {
console.log(chalk.red(`${globalName} -> ?`));
}
});

Object.keys(json.classes)
.map(it => json.classes[it])
.filter(it => !it.static)
.filter(it => it.access === 'public')
.forEach(it => {
let globalName = it.name;
let globalsKey = globalName.replace(/^Ember\./, '');
let newImport = globals[globalsKey];

if (newImport) {
console.log(chalk.green(`${globalName} -> ${newImport}`));
} else {
console.log(chalk.red(`${globalName} -> ?`));
}
})
}

0 comments on commit fc8d982

Please sign in to comment.