Skip to content

Commit

Permalink
install:addon will show a deprecation warning then it will run the …
Browse files Browse the repository at this point in the history
…`install` command. Changed the verbage on install-npm.
  • Loading branch information
DanielOchoa committed May 3, 2015
1 parent 2d8eb68 commit a7a68b2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 2 deletions.
24 changes: 24 additions & 0 deletions lib/commands/install-addon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

var InstallCommand = require('./install');
var chalk = require('chalk');

module.exports = InstallCommand.extend({
name: 'install:addon',
description: 'This command has been deprecated. Please use `ember install` instead.',
works: 'insideProject',

anonymousOptions: [
'<addon-name>'
],

init: function() {
var warning = 'This command has been deprecated. Please use `ember ';
warning += 'install <addonName>` instead.';
this.ui.writeLine(chalk.red(warning));

if (this._super.init) {
this._super.init.call(this);
}
}
});
2 changes: 1 addition & 1 deletion lib/commands/install-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = Command.extend({
],

run: function() {
var err = 'This command has been deprecated. Please use `npm install ';
var err = 'This command has been removed. Please use `npm install ';
err += '<packageName> --save-dev --save-exact` instead.';
return Promise.reject(new SilentError(err));
}
Expand Down
88 changes: 88 additions & 0 deletions tests/unit/commands/install-addon-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
'use strict';

var expect = require('chai').expect;
var InstallAddonCommand = require('../../../lib/commands/install-addon');
var commandOptions = require('../../factories/command-options');
var AddonInstall = require('../../../lib/tasks/addon-install');
var Task = require('../../../lib/models/task');
var Promise = require('../../../lib/ext/promise');
var stub = require('../../helpers/stub').stub;
var Project = require('../../../lib/models/project');

describe('install:addon command', function() {
var command, options, tasks, npmInstance, generateBlueprintInstance;

beforeEach(function() {
tasks = {
AddonInstall: AddonInstall,
NpmInstall: Task.extend({
init: function() {
npmInstance = this;
}
}),

GenerateFromBlueprint: Task.extend({
init: function() {
generateBlueprintInstance = this;
}
})
};

options = commandOptions({
settings: {},
project: {
name: function() {
return 'some-random-name';
},
isEmberCLIProject: function() {
return true;
},
initializeAddons: function() { },
reloadAddons: function() {
this.addons = [{
pkg: {
name: 'ember-cli-photoswipe',
'ember-addon': {
defaultBlueprint: 'photoswipe'
}
}
}];
},

findAddonByName: Project.prototype.findAddonByName
},

tasks: tasks
});

stub(tasks.NpmInstall.prototype, 'run', Promise.resolve());
stub(tasks.GenerateFromBlueprint.prototype, 'run', Promise.resolve());

command = new InstallAddonCommand(options);

});

afterEach(function() {
tasks.NpmInstall.prototype.run.restore();
tasks.GenerateFromBlueprint.prototype.run.restore();
});


it('will show a deprecation warning', function() {
return command.validateAndRun(['ember-cli-photoswipe']).then(function() {
var msg = 'This command has been deprecated. Please use `ember install ';
msg += '<addonName>` instead.';

expect(command.ui.output).to.include(msg);

expect(npmInstance.ui, 'ui was set');
expect(npmInstance.project, 'project was set');
expect(npmInstance.analytics, 'analytics was set');

expect(generateBlueprintInstance.ui, 'ui was set');
expect(generateBlueprintInstance.project, 'project was set');
expect(generateBlueprintInstance.analytics, 'analytics was set');

});
});
});
2 changes: 1 addition & 1 deletion tests/unit/commands/install-npm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('install:npm command', function() {
});

command = new InstallCommand(options);
msg = 'This command has been deprecated. Please use `npm install ';
msg = 'This command has been removed. Please use `npm install ';
msg += '<packageName> --save-dev --save-exact` instead.';
});

Expand Down

0 comments on commit a7a68b2

Please sign in to comment.