Skip to content

Commit

Permalink
Add "generate-missing-apis-list" script
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Jul 4, 2017
1 parent aa43574 commit 9bb9139
Showing 1 changed file with 54 additions and 0 deletions.
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 9bb9139

Please sign in to comment.