Skip to content

Commit e1910bd

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular/cli): remove unused ember-cli addon code
1 parent 29c86d2 commit e1910bd

File tree

2 files changed

+0
-236
lines changed

2 files changed

+0
-236
lines changed

packages/@angular/cli/ember-cli/lib/cli/lookup-command.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
const UnknownCommand = require('../commands/unknown');
44

55
module.exports = function(commands, commandName, commandArgs, optionHash) {
6-
let options = optionHash || {};
7-
let project = options.project;
8-
let ui = options.ui;
96

107
function aliasMatches(alias) {
118
return alias === commandName;
@@ -27,36 +24,10 @@ module.exports = function(commands, commandName, commandArgs, optionHash) {
2724
// Attempt to find command in ember-cli core commands
2825
let command = findCommand(commands, commandName);
2926

30-
let addonCommand;
31-
// Attempt to find command within addons
32-
if (project && project.eachAddonCommand) {
33-
project.eachAddonCommand((addonName, commands) => {
34-
addonCommand = findCommand(commands, commandName);
35-
return !addonCommand;
36-
});
37-
}
38-
39-
if (command && addonCommand) {
40-
if (addonCommand.overrideCore) {
41-
ui.writeWarnLine(`An ember-addon has attempted to override the core command "${command.prototype.name}". ` +
42-
`The addon command will be used as the overridding was explicit.`);
43-
44-
return addonCommand;
45-
}
46-
47-
ui.writeWarnLine(`An ember-addon has attempted to override the core command "${command.prototype.name}". ` +
48-
`The core command will be used.`);
49-
return command;
50-
}
51-
5227
if (command) {
5328
return command;
5429
}
5530

56-
if (addonCommand) {
57-
return addonCommand;
58-
}
59-
6031
// if we didn't find anything, return an "UnknownCommand"
6132
return class extends UnknownCommand {
6233
constructor(options) {

packages/@angular/cli/ember-cli/lib/models/project.js

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const fs = require('fs-extra');
1111
const _ = require('lodash');
1212
let logger = require('heimdalljs-logger')('ember-cli:project');
1313
const nodeModulesPath = require('node-modules-path');
14-
const heimdall = require('heimdalljs');
1514

1615
let processCwd = process.cwd();
1716
// ensure NULL_PROJECT is a singleton
@@ -89,16 +88,10 @@ class Project {
8988
return false;
9089
};
9190

92-
NULL_PROJECT.isEmberCLIAddon = function() {
93-
return false;
94-
};
95-
9691
NULL_PROJECT.name = function() {
9792
return path.basename(process.cwd());
9893
};
9994

100-
NULL_PROJECT.initializeAddons();
101-
10295
return NULL_PROJECT;
10396
}
10497

@@ -126,15 +119,6 @@ class Project {
126119
|| '@angular/cli' in this.dependencies();
127120
}
128121

129-
/**
130-
Returns whether or not this is an Ember CLI addon.
131-
@method isEmberCLIAddon
132-
@return {Boolean} Whether or not this is an Ember CLI Addon.
133-
*/
134-
isEmberCLIAddon() {
135-
return !!this.pkg.keywords && this.pkg.keywords.indexOf('ember-addon') > -1;
136-
}
137-
138122
/**
139123
Loads the configuration for this project and its addons.
140124
@public
@@ -143,8 +127,6 @@ class Project {
143127
@return {Object} Merged confiration object
144128
*/
145129
config(env) {
146-
this.initializeAddons();
147-
148130
let initialConfig = {};
149131

150132
return this.addons.reduce((config, addon) => {
@@ -231,139 +213,6 @@ class Project {
231213
return _.assign({}, devDependencies, pkg['dependencies']);
232214
}
233215

234-
/**
235-
Provides the list of paths to consult for addons that may be provided
236-
internally to this project. Used for middleware addons with built-in support.
237-
@private
238-
@method supportedInternalAddonPaths
239-
*/
240-
supportedInternalAddonPaths() {
241-
if (!this.root) { return []; }
242-
243-
let internalMiddlewarePath = path.join(__dirname, '../tasks/server/middleware');
244-
let legacyBlueprintsPath = require.resolve('ember-cli-legacy-blueprints');
245-
let emberTryPath = require.resolve('ember-try');
246-
return [
247-
path.join(internalMiddlewarePath, 'testem-url-rewriter'),
248-
path.join(internalMiddlewarePath, 'tests-server'),
249-
path.join(internalMiddlewarePath, 'history-support'),
250-
path.join(internalMiddlewarePath, 'broccoli-watcher'),
251-
path.join(internalMiddlewarePath, 'broccoli-serve-files'),
252-
path.join(internalMiddlewarePath, 'proxy-server'),
253-
path.dirname(legacyBlueprintsPath),
254-
path.dirname(emberTryPath),
255-
];
256-
}
257-
258-
/**
259-
Loads and initializes all addons for this project.
260-
@private
261-
@method initializeAddons
262-
*/
263-
initializeAddons() {
264-
if (this._addonsInitialized) {
265-
return;
266-
}
267-
this._addonsInitialized = true;
268-
269-
logger.info('initializeAddons for: %s', this.name());
270-
}
271-
272-
/**
273-
Returns what commands are made available by addons by inspecting
274-
`includedCommands` for every addon.
275-
@private
276-
@method addonCommands
277-
@return {Object} Addon names and command maps as key-value pairs
278-
*/
279-
addonCommands() {
280-
const Command = require('../models/command');
281-
let commands = {};
282-
this.addons.forEach(addon => {
283-
if (!addon.includedCommands) { return; }
284-
285-
let token = heimdall.start({
286-
name: `lookup-commands: ${addon.name}`,
287-
addonName: addon.name,
288-
addonCommandInitialization: true,
289-
});
290-
291-
let includedCommands = addon.includedCommands();
292-
let addonCommands = {};
293-
294-
for (let key in includedCommands) {
295-
if (typeof includedCommands[key] === 'function') {
296-
addonCommands[key] = includedCommands[key];
297-
} else {
298-
addonCommands[key] = Command.extend(includedCommands[key]);
299-
}
300-
}
301-
if (Object.keys(addonCommands).length) {
302-
commands[addon.name] = addonCommands;
303-
}
304-
305-
token.stop();
306-
});
307-
return commands;
308-
}
309-
310-
/**
311-
Execute a given callback for every addon command.
312-
Example:
313-
```
314-
project.eachAddonCommand(function(addonName, commands) {
315-
console.log('Addon ' + addonName + ' exported the following commands:' + commands.keys().join(', '));
316-
});
317-
```
318-
@private
319-
@method eachAddonCommand
320-
@param {Function} callback [description]
321-
*/
322-
eachAddonCommand(callback) {
323-
if (this.initializeAddons && this.addonCommands) {
324-
this.initializeAddons();
325-
let addonCommands = this.addonCommands();
326-
327-
_.forOwn(addonCommands, (commands, addonName) => callback(addonName, commands));
328-
}
329-
}
330-
331-
/**
332-
Path to the blueprints for this project.
333-
@private
334-
@method localBlueprintLookupPath
335-
@return {String} Path to blueprints
336-
*/
337-
localBlueprintLookupPath() {
338-
return path.join(this.cli.root, 'blueprints');
339-
}
340-
341-
/**
342-
Returns a list of paths (including addon paths) where blueprints will be looked up.
343-
@private
344-
@method blueprintLookupPaths
345-
@return {Array} List of paths
346-
*/
347-
blueprintLookupPaths() {
348-
return [this.localBlueprintLookupPath()];
349-
}
350-
351-
/**
352-
Returns a list of addon paths where blueprints will be looked up.
353-
@private
354-
@method addonBlueprintLookupPaths
355-
@return {Array} List of paths
356-
*/
357-
addonBlueprintLookupPaths() {
358-
let addonPaths = this.addons.map(addon => {
359-
if (addon.blueprintsPath) {
360-
return addon.blueprintsPath();
361-
}
362-
}, this);
363-
364-
return addonPaths.filter(Boolean).reverse();
365-
}
366-
367216
/**
368217
Reloads package.json
369218
@private
@@ -379,62 +228,6 @@ class Project {
379228
return this.pkg;
380229
}
381230

382-
/**
383-
Re-initializes addons.
384-
@private
385-
@method reloadAddons
386-
*/
387-
reloadAddons() {
388-
this.reloadPkg();
389-
this._addonsInitialized = false;
390-
return this.initializeAddons();
391-
}
392-
393-
/**
394-
Find an addon by its name
395-
@private
396-
@method findAddonByName
397-
@param {String} name Addon name as specified in package.json
398-
@return {Addon} Addon instance
399-
*/
400-
findAddonByName(name) {
401-
this.initializeAddons();
402-
403-
var exactMatch = _.find(this.addons, function(addon) {
404-
return name === addon.name || (addon.pkg && name === addon.pkg.name);
405-
});
406-
407-
if (exactMatch) {
408-
return exactMatch;
409-
}
410-
411-
return _.find(this.addons, function(addon) {
412-
return name.indexOf(addon.name) > -1 || (addon.pkg && name.indexOf(addon.pkg.name) > -1);
413-
});
414-
}
415-
416-
/**
417-
Generate test file contents.
418-
This method is supposed to be overwritten by test framework addons
419-
like `ember-cli-qunit` and `ember-cli-mocha`.
420-
@public
421-
@method generateTestFile
422-
@param {String} moduleName Name of the test module (e.g. `JSHint`)
423-
@param {Object[]} tests Array of tests with `name`, `passed` and `errorMessage` properties
424-
@return {String} The test file content
425-
*/
426-
generateTestFile() {
427-
let message = 'Please install an Ember.js test framework addon or update your dependencies.';
428-
429-
if (this.ui) {
430-
this.ui.writeDeprecateLine(message);
431-
} else {
432-
console.warn(message);
433-
}
434-
435-
return '';
436-
}
437-
438231
/**
439232
Returns a new project based on the first package.json that is found
440233
in `pathName`.

0 commit comments

Comments
 (0)