Skip to content

Commit e1c56e2

Browse files
committed
drop remote blacklist support
1 parent 6dfbe96 commit e1c56e2

File tree

5 files changed

+33
-294
lines changed

5 files changed

+33
-294
lines changed

lib/deny-list.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const denyList = [];
2+
3+
export default denyList;

lib/routes/install.js

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import sortOn from 'sort-on';
88
import figures from 'figures';
99
import npmKeyword from 'npm-keyword';
1010
import packageJson from 'package-json';
11-
import got from 'got';
11+
import denyList from '../deny-list.js';
1212

1313
const OFFICIAL_GENERATORS = new Set([
1414
'generator-angular',
@@ -38,29 +38,20 @@ export const install = app => inquirer.prompt([{
3838
const generatorMatchTerm = (generator, term) => `${generator.name} ${generator.description}`.includes(term);
3939
const getAllGenerators = _.memoize(() => npmKeyword('yeoman-generator'));
4040

41-
function searchMatchingGenerators(app, term, callback) {
42-
function handleDenyList(denyList) {
43-
const installedGenerators = app.env.getGeneratorNames();
44-
45-
getAllGenerators().then(allGenerators => {
46-
callback(null, allGenerators.filter(generator => {
47-
if (denyList.includes(generator.name)) {
48-
return false;
49-
}
50-
51-
if (installedGenerators.includes(generator.name)) {
52-
return false;
53-
}
41+
async function searchMatchingGenerators(app, term) {
42+
const installedGenerators = app.env.getGeneratorNames();
43+
const allGenerators = await getAllGenerators();
44+
return allGenerators.filter(generator => {
45+
if (denyList.includes(generator.name)) {
46+
return false;
47+
}
5448

55-
return generatorMatchTerm(generator, term);
56-
}));
57-
}, callback);
58-
}
49+
if (installedGenerators.includes(generator.name)) {
50+
return false;
51+
}
5952

60-
got('http://yeoman.io/blacklist.json')
61-
.json()
62-
.then(response => handleDenyList(response))
63-
.catch(() => handleDenyList([]));
53+
return generatorMatchTerm(generator, term);
54+
});
6455
}
6556

6657
function fetchGeneratorInfo(generator, callback) {
@@ -76,26 +67,20 @@ function fetchGeneratorInfo(generator, callback) {
7667
}).catch(callback);
7768
}
7869

79-
function searchNpm(app, term) {
80-
const promise = new Promise((resolve, reject) => {
81-
searchMatchingGenerators(app, term, (error, matches) => {
82-
if (error) {
83-
reject(error);
70+
async function searchNpm(app, term) {
71+
const matches = await searchMatchingGenerators(app, term);
72+
const packages = await new Promise((resolve, reject) => {
73+
async.map(matches, fetchGeneratorInfo, (error2, choices) => {
74+
if (error2) {
75+
reject(error2);
8476
return;
8577
}
8678

87-
async.map(matches, fetchGeneratorInfo, (error2, choices) => {
88-
if (error2) {
89-
reject(error2);
90-
return;
91-
}
92-
93-
resolve(choices);
94-
});
79+
resolve(choices);
9580
});
9681
});
9782

98-
return promise.then(choices => promptInstallOptions(app, sortOn(choices, ['official', 'name'])));
83+
return promptInstallOptions(app, sortOn(packages, ['official', 'name']));
9984
}
10085

10186
function promptInstallOptions(app, choices) {

0 commit comments

Comments
 (0)