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

[bugfix] Ensure TS blueprints are always used #253

Merged
merged 2 commits into from
Sep 7, 2018
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
22 changes: 10 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ const stew = require('broccoli-stew');
module.exports = {
name: 'ember-cli-typescript',

init() {
this._super.init.apply(this, arguments);

// If we're a direct dependency of the app, we cheat and add our instance of the blueprints
// addon to the project, as only top-level addons contribute blueprints.
// This won't be necessary in 2.x if we shift to adding the blueprints addon as a host
// dependency on install.
if (this.project.addons.includes(this)) {
this.project.addons.push(this.addons.find(addon => addon.name === 'ember-cli-typescript-blueprints'));
}
},

included(includer) {
this._super.included.apply(this, arguments);

Expand All @@ -31,6 +19,16 @@ module.exports = {
},

includedCommands() {
// If we're a direct dependency of the app, we cheat and add our instance of the blueprints
// addon to the project, as only top-level addons contribute blueprints. We need to be careful
// with the timing of when we do this, as it has to happen after addon initialization is
// complete, but before blueprint paths are resolved.
// This won't be necessary in 2.x if we shift to adding the blueprints addon as a host
// dependency on install.
if (this.project.addons.includes(this)) {
this.project.addons.push(this.addons.find(addon => addon.name === 'ember-cli-typescript-blueprints'));
}

if (this.project.isEmberCLIAddon()) {
return {
'ts:precompile': require('./lib/commands/precompile'),
Expand Down
23 changes: 23 additions & 0 deletions node-tests/blueprints/packaged-blueprints-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
const setupTestHooks = blueprintHelpers.setupTestHooks;
const emberNew = blueprintHelpers.emberNew;
const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;

const expect = require('ember-cli-blueprint-test-helpers/chai').expect;

describe('Acceptance: TypeScript blueprints', function() {
setupTestHooks(this);

it('uses blueprints from ember-cli-typescript-blueprints', function() {
let args = ['helper', 'foo'];

return emberNew()
.then(() => emberGenerateDestroy(args, (file) => {
const generated = file('app/helpers/foo.ts');
expect(generated).to.contain('export function foo');
expect(generated).to.contain('export default helper(foo)');
}));
});
});