Skip to content

Commit 3c9a102

Browse files
committed
fix: cleanup
1 parent 1e56dde commit 3c9a102

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

blueprints/ember-cli-typescript/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ module.exports = {
3333
let hasMirage = 'ember-cli-mirage' in (this.project.pkg.devDependencies || {});
3434
let isAddon = this.project.isEmberCLIAddon();
3535
let isMU = this._detectMU();
36-
let includes = isMU ? ['src'] : ['app', 'tests', 'types'].filter(Boolean);
36+
let includes = isMU ? ['src'] : ['app', isAddon && 'addon'].filter(Boolean);
3737

38-
if (isAddon) {
39-
includes.push('addon', 'test-support', 'addon-test-support');
38+
includes = includes.concat(['tests', 'types']).concat(inRepoAddons);
39+
40+
if (isAddon && !isMU) {
41+
includes.push('test-support', 'addon-test-support');
4042
}
4143
// Mirage is already covered for addons because it's under `tests/`
4244
if (hasMirage && !isAddon) {

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const IncrementalTypescriptCompiler = require('./lib/incremental-typescript-compiler');
55
const Funnel = require('broccoli-funnel');
66
const MergeTrees = require('broccoli-merge-trees');
7+
const stew = require('broccoli-stew');
78

89
module.exports = {
910
name: 'ember-cli-typescript',
@@ -57,7 +58,8 @@ module.exports = {
5758
return this._super.treeForApp.call(this, tree);
5859
}
5960
},
60-
// We manually invoke Babel for treeForAddon, treeForTestSupport and treeForAddonTestSupport
61+
62+
// We manually invoke Babel for treeForAddon and treeForAddonTestSupport
6163
// rather than calling _super because we're returning content on behalf of addons that aren't
6264
// ember-cli-typescript, and the _super impl would namespace all the files under our own name.
6365
treeForAddon() {
@@ -74,7 +76,9 @@ module.exports = {
7476
trees.push(this.compiler.treeForTests());
7577
trees.push(this.compiler.treeForTestSupport());
7678
}
77-
return this._super.treeForTestSupport.call(this, new MergeTrees(trees));
79+
return this._super.treeForTestSupport.call(this,
80+
stew.mv(new MergeTrees(trees), 'test-support/*', '/')
81+
);
7882
},
7983

8084
treeForAddonTestSupport() {

lib/incremental-typescript-compiler/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module.exports = class IncrementalTypescriptCompiler {
100100
treeForTestSupport() {
101101
let paths = {};
102102
for (let addon of this.addons) {
103-
paths[`${this._relativeAddonRoot(addon)}/test-support`] = `tests`;
103+
paths[`${this._relativeAddonRoot(addon)}/test-support`] = `test-support`;
104104
}
105105
return new TypescriptOutput(this, paths);
106106
}

lib/utilities/update-paths-for-addon.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = function(paths, addonName, appName, options) {
1212
let appStarPaths;
1313
paths = paths || {};
1414
appStarPaths = paths[appNameStar] = paths[appNameStar] || [];
15+
1516
if (options.removePaths) {
1617
if (paths.hasOwnProperty(addonName)) {
1718
delete paths[addonName];

node-tests/blueprints/ember-cli-typescript-test.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ describe('Acceptance: ember-cli-typescript generator', function() {
2323
// Mock npm-install that only modifies package.json
2424
return {
2525
run: function(options) {
26-
let pkgJson = fs.readJsonSync('package.json')
26+
let pkgJson = fs.readJsonSync('package.json');
2727
options.packages.forEach(function(pkg) {
2828
let pkgName = pkg.match(/^(.*)@[^@]*$/);
2929
pkgJson['devDependencies'][pkgName[1]] = '*';
3030
});
3131
fs.writeJsonSync('package.json', pkgJson);
3232
}
33-
}
33+
};
3434
}
3535
return originalTaskForFn.call(this, taskName);
3636
};
@@ -121,11 +121,11 @@ describe('Acceptance: ember-cli-typescript generator', function() {
121121

122122
expect(tsconfigJson.include).to.deep.equal([
123123
'app/**/*',
124+
'addon/**/*',
124125
'tests/**/*',
125126
'types/**/*',
126-
'addon/**/*',
127127
'test-support/**/*',
128-
'addon-test-support/**/*'
128+
'addon-test-support/**/*',
129129
]);
130130

131131
const projectTypes = file('types/dummy/index.d.ts');
@@ -168,7 +168,10 @@ describe('Acceptance: ember-cli-typescript generator', function() {
168168
expect(pkgJson.devDependencies).to.include.all.keys('@types/ember-data');
169169
expect(pkgJson.devDependencies).to.include.all.keys('ember-cli-qunit');
170170
expect(pkgJson.devDependencies).to.include.all.keys('@types/ember-qunit', '@types/qunit');
171-
expect(pkgJson.devDependencies).to.not.have.any.keys('@types/ember-mocha', '@types/mocha');
171+
expect(pkgJson.devDependencies).to.not.have.any.keys(
172+
'@types/ember-mocha',
173+
'@types/mocha'
174+
);
172175

173176
const tsconfig = file('tsconfig.json');
174177
expect(tsconfig).to.exist;
@@ -214,7 +217,10 @@ describe('Acceptance: ember-cli-typescript generator', function() {
214217
expect(pkgJson.devDependencies).to.not.have.any.keys('@types/ember-data');
215218
expect(pkgJson.devDependencies).to.include.all.keys('ember-cli-qunit');
216219
expect(pkgJson.devDependencies).to.include.all.keys('@types/ember-qunit', '@types/qunit');
217-
expect(pkgJson.devDependencies).to.not.have.any.keys('@types/ember-mocha', '@types/mocha');
220+
expect(pkgJson.devDependencies).to.not.have.any.keys(
221+
'@types/ember-mocha',
222+
'@types/mocha'
223+
);
218224

219225
const tsconfig = file('tsconfig.json');
220226
expect(tsconfig).to.exist;
@@ -275,7 +281,13 @@ describe('Acceptance: ember-cli-typescript generator', function() {
275281
'*': ['types/*'],
276282
});
277283

278-
expect(json.include).to.deep.equal(['app/**/*', 'tests/**/*', 'types/**/*', 'lib/my-addon-1/**/*', 'lib/my-addon-2/**/*']);
284+
expect(json.include).to.deep.equal([
285+
'app/**/*',
286+
'tests/**/*',
287+
'types/**/*',
288+
'lib/my-addon-1/**/*',
289+
'lib/my-addon-2/**/*',
290+
]);
279291

280292
const projectTypes = file('types/my-app/index.d.ts');
281293
expect(projectTypes).to.exist;
@@ -344,11 +356,11 @@ describe('Acceptance: ember-cli-typescript generator', function() {
344356

345357
expect(json.include).to.deep.equal([
346358
'app/**/*',
359+
'addon/**/*',
347360
'tests/**/*',
348361
'types/**/*',
349-
'addon/**/*',
350362
'test-support/**/*',
351-
'addon-test-support/**/*'
363+
'addon-test-support/**/*',
352364
]);
353365
});
354366
});

0 commit comments

Comments
 (0)