Skip to content

Commit 1082b53

Browse files
authored
Merge pull request #54 from dwickern/in-repo-addons
add in-repo-addons to generated tsconfig.json
2 parents 7f01d1d + 93ff36e commit 1082b53

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
bower.json
1515
ember-cli-build.js
1616
testem.js
17+
node-tests/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ script:
3535
# Usually, it's ok to finish the test scenario without reverting
3636
# to the addon's original dependency state, skipping "cleanup".
3737
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
38+
- yarn run nodetest
3839

3940
# We build PRs, but don't trigger separate builds for the PR from the branch.
4041
branches:

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ test_script:
3131
# Output useful info for debugging.
3232
- yarn versions
3333
- cmd: yarn run test
34+
- cmd: yarn run nodetest
3435

3536
# Don't actually build.
3637
build: off

blueprints/ember-cli-typescript/files/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
"baseUrl": ".",
1010
"paths": {
1111
"<%= dasherizedPackageName %>/tests/*": ["tests/*"],
12-
"<%= dasherizedPackageName %>/*": ["app/*"]
12+
"<%= dasherizedPackageName %>/*": [
13+
"app/*"<%
14+
inRepoAddons.forEach(function(path) { %>,
15+
"<%= path %>/app/*"<%
16+
}) %>
17+
]
1318
}
1419
},
1520
"exclude": [

blueprints/ember-cli-typescript/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ module.exports = {
2626
}
2727
},
2828

29+
locals() {
30+
return {
31+
inRepoAddons: (this.project.pkg['ember-addon'] || {}).paths || []
32+
};
33+
},
34+
2935
normalizeEntityName() {
3036
// Entity name is optional right now, creating this hook avoids an error.
3137
},
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const {
6+
setupTestHooks,
7+
emberNew,
8+
emberGenerate
9+
} = require('ember-cli-blueprint-test-helpers/helpers');
10+
const { expect, file } = require('ember-cli-blueprint-test-helpers/chai');
11+
12+
describe('Acceptance: ember-cli-typescript generator', function() {
13+
setupTestHooks(this);
14+
15+
it('basic app', function() {
16+
const args = ['ember-cli-typescript'];
17+
18+
return emberNew()
19+
.then(() => emberGenerate(args))
20+
.then(() => {
21+
const tsconfig = file('tsconfig.json');
22+
expect(tsconfig).to.exist;
23+
24+
const json = JSON.parse(tsconfig.content);
25+
expect(json.compilerOptions.paths).to.deep.equal({
26+
'my-app/tests/*': [ 'tests/*' ],
27+
'my-app/*': [ 'app/*' ]
28+
});
29+
});
30+
});
31+
32+
it('in-repo addons', function() {
33+
const args = ['ember-cli-typescript'];
34+
35+
return emberNew()
36+
.then(() => {
37+
const packagePath = path.resolve(process.cwd(), 'package.json');
38+
const contents = JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' }));
39+
contents['ember-addon'] = {
40+
paths: [
41+
'lib/my-addon-1',
42+
'lib/my-addon-2'
43+
]
44+
};
45+
fs.writeFileSync(packagePath, JSON.stringify(contents, null, 2));
46+
})
47+
.then(() => emberGenerate(args))
48+
.then(() => {
49+
const tsconfig = file('tsconfig.json');
50+
expect(tsconfig).to.exist;
51+
52+
const json = JSON.parse(tsconfig.content);
53+
expect(json.compilerOptions.paths).to.deep.equal({
54+
'my-app/tests/*': [ 'tests/*' ],
55+
'my-app/*': [
56+
'app/*',
57+
'lib/my-addon-1/app/*',
58+
'lib/my-addon-2/app/*',
59+
]
60+
});
61+
});
62+
});
63+
64+
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"scripts": {
2626
"build": "ember build",
2727
"start": "ember server",
28-
"test": "ember try:each"
28+
"test": "ember try:each",
29+
"nodetest": "mocha node-tests --recursive"
2930
},
3031
"dependencies": {
3132
"broccoli-debug": "^0.6.3",
@@ -43,6 +44,7 @@
4344
"broccoli-asset-rev": "^2.4.5",
4445
"ember-cli": "^2.13.3",
4546
"ember-cli-app-version": "^2.0.0",
47+
"ember-cli-blueprint-test-helpers": "^0.17.2",
4648
"ember-cli-dependency-checker": "^1.3.0",
4749
"ember-cli-eslint": "^3.0.0",
4850
"ember-cli-htmlbars": "^1.1.1",
@@ -59,6 +61,7 @@
5961
"ember-resolver": "^4.0.0",
6062
"ember-source": "~2.13.3",
6163
"loader.js": "^4.2.3",
64+
"mocha": "^2.2.1",
6265
"typescript": "^2.4.2"
6366
},
6467
"peerDependencies": {

0 commit comments

Comments
 (0)