Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull server files from http-{mock,proxy} into their own blueprint #2610

Merged
merged 2 commits into from
Dec 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* `{{content-for 'test-body-footer'}}`

* Update to Ember Data v1.0.0-beta.12
* [BUGFIX] Create separate server blueprint to stop http-{mock,proxy} removing files [#2610](https://github.com/stefanpenner/ember-cli/pull/2610)

### 0.1.3

Expand Down
14 changes: 12 additions & 2 deletions blueprints/http-mock/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var EOL = require('os').EOL;
var Blueprint = require('../../lib/models/blueprint');

module.exports = {
description: 'Generates a mock api endpoint in /api prefix.',
Expand All @@ -12,9 +12,19 @@ module.exports = {
path: '/' + options.entity.name.replace(/^\//, '')
};
},

beforeInstall: function(options) {
var serverBlueprint = Blueprint.lookup('server', {
ui: this.ui,
analytics: this.analytics,
project: this.project
});

return serverBlueprint.install(options);
},

afterInstall: function() {
return this.addPackagesToProject([
{ name: 'morgan', target: '^1.3.2' },
{ name: 'connect-restreamer', target: '^1.0.0' }
]);
}
Expand Down
3 changes: 0 additions & 3 deletions blueprints/http-proxy/files/server/.jshintrc

This file was deleted.

22 changes: 0 additions & 22 deletions blueprints/http-proxy/files/server/index.js

This file was deleted.

15 changes: 12 additions & 3 deletions blueprints/http-proxy/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Promise = require('../../lib/ext/promise');
var Blueprint = require('../../lib/models/blueprint');

module.exports = {
description: 'Generates a relative proxy to another server.',
Expand All @@ -16,10 +16,19 @@ module.exports = {
};
},

beforeInstall: function(options) {
var serverBlueprint = Blueprint.lookup('server', {
ui: this.ui,
analytics: this.analytics,
project: this.project
});

return serverBlueprint.install(options);
},

afterInstall: function() {
return this.addPackagesToProject([
{ name: 'http-proxy', target: '^1.1.6' },
{ name: 'morgan', target: '^1.3.2' }
{ name: 'http-proxy', target: '^1.1.6' }
]);
}
};
11 changes: 11 additions & 0 deletions blueprints/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
description: 'Generates a server directory for mocks and proxies.',

normalizeEntityName: function() {},

afterInstall: function() {
return this.addPackagesToProject([
{ name: 'morgan', target: '^1.3.2' }
]);
}
};
23 changes: 13 additions & 10 deletions tests/acceptance/destroy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,22 +437,14 @@ describe('Acceptance: ember destroy', function() {

it('http-mock foo', function() {
var commandArgs = ['http-mock', 'foo'];
var files = [
'server/index.js',
'server/mocks/foo.js',
'server/.jshintrc'
];
var files = ['server/mocks/foo.js'];

return assertDestroyAfterGenerate(commandArgs, files);
});

it('http-proxy foo', function() {
var commandArgs = ['http-proxy', 'foo'];
var files = [
'server/index.js',
'server/proxies/foo.js',
'server/.jshintrc'
];
var files = ['server/proxies/foo.js'];

return assertDestroyAfterGenerate(commandArgs, files);
});
Expand Down Expand Up @@ -521,4 +513,15 @@ describe('Acceptance: ember destroy', function() {
});
});

it('http-mock <name> does not remove server/', function() {
return initApp()
.then(function() { return generate(['http-mock', 'foo']); })
.then(function() { return generate(['http-mock', 'bar']); })
.then(function() { return destroy(['http-mock', 'foo']); })
.then(function() {
assertFile('server/index.js');
assertFile('server/.jshintrc');
});
});

});
7 changes: 7 additions & 0 deletions tests/acceptance/generate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,4 +1100,11 @@ describe('Acceptance: ember generate', function() {
});
});
});

it('server', function() {
return generate(['server']).then(function() {
assertFile('server/index.js');
assertFile('server/.jshintrc');
});
});
});
12 changes: 2 additions & 10 deletions tests/acceptance/pods-destroy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,22 +439,14 @@ describe('Acceptance: ember destroy pod', function() {

it('http-mock foo --pod', function() {
var commandArgs = ['http-mock', 'foo', '--pod'];
var files = [
'server/index.js',
'server/mocks/foo.js',
'server/.jshintrc'
];
var files = ['server/mocks/foo.js'];

return assertDestroyAfterGenerate(commandArgs, files);
});

it('http-proxy foo --pod', function() {
var commandArgs = ['http-proxy', 'foo', '--pod'];
var files = [
'server/index.js',
'server/proxies/foo.js',
'server/.jshintrc'
];
var files = ['server/proxies/foo.js'];

return assertDestroyAfterGenerate(commandArgs, files);
});
Expand Down