Skip to content

Commit d87cc22

Browse files
committed
Merge branch 'master' into v4
2 parents 34735ad + 529e6a5 commit d87cc22

File tree

13 files changed

+1134
-508
lines changed

13 files changed

+1134
-508
lines changed

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
2222
[#1017]: https://github.com/typed-ember/ember-cli-typescript/pull/1017
2323
[#1018]: https://github.com/typed-ember/ember-cli-typescript/pull/1018
2424

25+
## [3.1.3] - 2020-01-22
26+
27+
### Fixed 🔧
28+
29+
- Issue a warning if we detect a .js/.ts file collision ([#1046])
30+
31+
[#1046]: https://github.com/typed-ember/ember-cli-typescript/pull/1046
32+
33+
### Under the hood 🚗
34+
35+
- Add prettier eslint deps ([#1045])
36+
- Use Node 10 for CI (but don't "officially" stop supporting node 8 yet) ([#1047])
37+
- Bumped [31 dependency versions][3.1.3-deps-bumps]
38+
39+
[#1045]: https://github.com/typed-ember/ember-cli-typescript/pull/1045
40+
[#1047]: https://github.com/typed-ember/ember-cli-typescript/pull/1047
41+
[3.1.3-deps-bumps]: https://github.com/typed-ember/ember-cli-typescript/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Amerged+merged%3A2019-12-14T10%3A52%3A00%2B0600..2020-01-22T13%3A00%3A00%2B0600+chore%28deps%29+in%3Atitle+
42+
2543
## [3.1.2] - 2019-12-14
2644

2745
### Fixed 🔧
@@ -621,7 +639,8 @@ We now use Babel 7's support for TypeScript to build apps and addons. Most of th
621639

622640
[ember-cli-typify]: https://github.com/winding-lines/ember-cli-typify
623641
[unreleased]: https://github.com/typed-ember/ember-cli-typescript/compare/v4.0.0-alpha.1...HEAD
624-
[4.0.0-alpha.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.2...v4.0.0-alpha.1
642+
[4.0.0-alpha.1]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.3...v4.0.0-alpha.1
643+
[3.1.3]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.2...v3.1.3
625644
[3.1.2]: https://github.com/typed-ember/ember-cli-typescript/compare/v3.1.1...v3.1.2
626645
<!--
627646
Note that 3.1.1 *intentionally* includes all the changes between 3.0.0 and

package.json

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
},
4141
"dependencies": {
4242
"ansi-to-html": "^0.6.6",
43+
"broccoli-stew": "^3.0.0",
4344
"debug": "^4.0.0",
4445
"execa": "^3.0.0",
4546
"fs-extra": "^8.0.0",
@@ -50,36 +51,38 @@
5051
"walk-sync": "^2.0.0"
5152
},
5253
"devDependencies": {
53-
"@commitlint/cli": "8.2.0",
54-
"@commitlint/config-conventional": "8.2.0",
55-
"@ember/optional-features": "1.2.0",
54+
"@commitlint/cli": "8.3.5",
55+
"@commitlint/config-conventional": "8.3.4",
56+
"@ember/optional-features": "1.3.0",
5657
"@typed-ember/renovate-config": "1.2.1",
5758
"@types/capture-console": "1.0.0",
58-
"@types/chai": "4.2.7",
59+
"@types/chai": "4.2.8",
5960
"@types/chai-as-promised": "7.1.2",
6061
"@types/console-ui": "2.2.3",
6162
"@types/core-object": "3.0.1",
6263
"@types/debug": "4.1.5",
6364
"@types/ember": "3.1.1",
6465
"@types/ember-qunit": "3.4.7",
6566
"@types/esprima": "4.0.2",
66-
"@types/express": "4.17.1",
67+
"@types/express": "4.17.2",
6768
"@types/fs-extra": "8.0.1",
6869
"@types/got": "8.3.5",
69-
"@types/mocha": "5.2.7",
70+
"@types/mocha": "7.0.1",
7071
"@types/node": "9.6.55",
7172
"@types/qunit": "2.9.0",
72-
"@types/resolve": "0.0.8",
73-
"@types/semver": "6.2.0",
73+
"@types/resolve": "1.14.0",
74+
"@types/semver": "6.2.1",
7475
"@types/tmp": "0.1.0",
75-
"@typescript-eslint/eslint-plugin": "2.12.0",
76-
"@typescript-eslint/parser": "2.12.0",
76+
"@typescript-eslint/eslint-plugin": "2.19.0",
77+
"@typescript-eslint/parser": "2.19.0",
7778
"broccoli-asset-rev": "3.0.0",
79+
"broccoli-node-api": "1.7.0",
80+
"broccoli-plugin": "4.0.1",
7881
"capture-console": "1.0.1",
7982
"co": "4.6.0",
80-
"commitlint-azure-pipelines-cli": "1.0.2",
83+
"commitlint-azure-pipelines-cli": "1.0.3",
8184
"conventional-changelog-cli": "2.0.31",
82-
"ember-cli": "3.14.0",
85+
"ember-cli": "3.15.2",
8386
"ember-cli-addon-docs": "ember-learn/ember-cli-addon-docs#4f5bfd11",
8487
"ember-cli-addon-docs-esdoc": "0.2.3",
8588
"ember-cli-app-version": "3.2.0",
@@ -90,40 +93,42 @@
9093
"ember-cli-deploy-build": "2.0.0",
9194
"ember-cli-deploy-git": "1.3.4",
9295
"ember-cli-deploy-git-ci": "1.0.1",
93-
"ember-cli-htmlbars": "4.2.0",
96+
"ember-cli-htmlbars": "4.2.2",
9497
"ember-cli-inject-live-reload": "2.0.2",
9598
"ember-cli-release": "0.2.9",
9699
"ember-cli-sri": "2.1.1",
97100
"ember-cli-typescript-blueprints": "3.0.0",
98101
"ember-cli-uglify": "3.0.0",
99-
"ember-cli-update": "0.47.2",
102+
"ember-cli-update": "0.52.1",
100103
"ember-disable-prototype-extensions": "1.1.3",
101104
"ember-export-application-global": "2.0.1",
102105
"ember-load-initializers": "2.1.1",
103106
"ember-maybe-import-regenerator": "0.1.6",
104107
"ember-qunit": "4.6.0",
105-
"ember-resolver": "6.0.0",
106-
"ember-source": "3.15.0",
108+
"ember-resolver": "7.0.0",
109+
"ember-source": "3.16.1",
107110
"ember-try": "1.4.0",
108-
"eslint": "6.7.2",
111+
"eslint": "6.8.0",
112+
"eslint-config-prettier": "6.10.0",
109113
"eslint-plugin-ember": "7.7.2",
110-
"eslint-plugin-node": "10.0.0",
114+
"eslint-plugin-node": "11.0.0",
111115
"eslint-plugin-prettier": "3.1.2",
112116
"esprima": "4.0.1",
113117
"fixturify": "1.2.0",
114-
"got": "8.3.2",
115-
"handlebars": "4.5.3",
116-
"husky": "3.1.0",
118+
"got": "10.4.0",
119+
"handlebars": "4.7.3",
120+
"husky": "4.2.1",
117121
"in-repo-a": "link:tests/dummy/lib/in-repo-a",
118122
"in-repo-b": "link:tests/dummy/lib/in-repo-b",
119123
"loader.js": "4.7.0",
120-
"mocha": "6.2.2",
124+
"mocha": "7.0.1",
121125
"prettier": "1.19.1",
122-
"qunit-dom": "0.9.2",
123-
"testdouble": "3.12.4",
126+
"prettier-eslint": "9.0.1",
127+
"qunit-dom": "1.0.0",
128+
"testdouble": "3.12.5",
124129
"tmp": "0.1.0",
125-
"ts-node": "8.5.4",
126-
"typescript": "3.7.3"
130+
"ts-node": "8.6.2",
131+
"typescript": "3.7.5"
127132
},
128133
"resolutions": {
129134
"@types/ember": "3.1.1",
@@ -153,7 +158,7 @@
153158
"proseWrap": "never"
154159
},
155160
"volta": {
156-
"node": "10.17.0",
161+
"node": "10.18.1",
157162
"yarn": "1.21.1"
158163
}
159164
}

tests/dummy/app/shadowed-file.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/dummy/app/templates/docs/ts-guide/using-ts-effectively.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default class UserProfile extends Component {
166166
@service mySession!: MySession;
167167

168168
login(email: string, password: string) {
169-
this.session.login(email, password);
169+
this.mySession.login(email, password);
170170
}
171171
}
172172
```

tests/dummy/lib/in-repo-a/app/shadowed-file.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/dummy/lib/in-repo-b/app/shadowed-file.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

ts/addon.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import semver from 'semver';
22
import { Remote } from 'stagehand';
33
import { connect } from 'stagehand/lib/adapters/child-process';
44
import Addon from 'ember-cli/lib/models/addon';
5+
import PreprocessRegistry from 'ember-cli-preprocess-registry';
56
import { addon } from './lib/utilities/ember-cli-entities';
67
import fork from './lib/utilities/fork';
78
import TypecheckWorker from './lib/typechecking/worker';
@@ -17,6 +18,7 @@ export default addon({
1718

1819
included() {
1920
this._super.included.apply(this, arguments);
21+
2022
this._checkDevelopment();
2123
this._checkAddonAppFiles();
2224
this._checkBabelVersion();
@@ -68,12 +70,65 @@ export default addon({
6870
}
6971
},
7072

73+
74+
setupPreprocessorRegistry(type, registry) {
75+
if (type !== 'parent') return;
76+
77+
// If we're acting on behalf of the root app, issue a warning if we detect
78+
// a situation where a .js file from an addon has the same name as a .ts
79+
// file in the app, as which file wins is nondeterministic.
80+
if (this.parent === this.project) {
81+
this._registerCollisionDetectionPreprocessor(registry);
82+
}
83+
},
84+
7185
shouldIncludeChildAddon(addon) {
7286
// For testing, we have dummy in-repo addons set up, but e-c-ts doesn't depend on them;
7387
// its dummy app does. Otherwise we'd have a circular dependency.
7488
return !['in-repo-a', 'in-repo-b'].includes(addon.name);
7589
},
7690

91+
_registerCollisionDetectionPreprocessor(registry: PreprocessRegistry) {
92+
registry.add('js', {
93+
name: 'ember-cli-typescript-collision-check',
94+
toTree: (input, path) => {
95+
if (path !== '/') return input;
96+
97+
let addon = this;
98+
let checked = false;
99+
let stew = require('broccoli-stew') as typeof import('broccoli-stew');
100+
101+
return stew.afterBuild(input, function() {
102+
if (!checked) {
103+
checked = true;
104+
addon._checkForFileCollisions(this.inputPaths[0]);
105+
}
106+
});
107+
},
108+
});
109+
},
110+
111+
_checkForFileCollisions(directory: string) {
112+
let walkSync = require('walk-sync') as typeof import('walk-sync');
113+
let files = new Set(walkSync(directory, ['**/*.{js,ts}']));
114+
115+
let collisions = [];
116+
for (let file of files) {
117+
if (file.endsWith('.js') && files.has(file.replace(/\.js$/, '.ts'))) {
118+
collisions.push(file.replace(/\.js$/, '.{js,ts}'));
119+
}
120+
}
121+
122+
if (collisions.length) {
123+
this.ui.writeWarnLine(
124+
'Detected collisions between .js and .ts files of the same name. ' +
125+
'This can result in nondeterministic build output; ' +
126+
'see https://git.io/JvIwo for more information.\n - ' +
127+
collisions.join('\n - ')
128+
);
129+
}
130+
},
131+
77132
_checkBabelVersion() {
78133
let babel = this.parent.addons.find(addon => addon.name === 'ember-cli-babel');
79134
let version = babel && babel.pkg.version;

ts/tests/acceptance/build-test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,33 @@ describe('Acceptance: build', function() {
101101

102102
await server.waitForBuild();
103103
});
104+
105+
it('emits a warning when .js and .ts files conflict in the app/ tree', async () => {
106+
// Set up an in-repo addon
107+
app.updatePackageJSON(pkg => {
108+
pkg['ember-addon'].paths.push('lib/in-repo-addon');
109+
});
110+
111+
app.writeFile('lib/in-repo-addon/index.js', 'module.exports = { name: "in-repo-addon" };');
112+
app.writeFile(
113+
'lib/in-repo-addon/package.json',
114+
JSON.stringify({
115+
name: 'in-repo-addon',
116+
keywords: ['ember-addon'],
117+
})
118+
);
119+
120+
// Have it export a .js app file and attempt to overwrite it in the host with a .ts file
121+
app.writeFile('lib/in-repo-addon/app/foo.js', '// addon');
122+
app.writeFile('app/foo.ts', '// app');
123+
124+
let output = await app.build();
125+
126+
expect(output.all).to.include('skeleton-app/foo.{js,ts}');
127+
expect(output.all).to.include(
128+
'WARNING: Detected collisions between .js and .ts files of the same name.'
129+
);
130+
});
104131
});
105132

106133
function isExpressionStatement(stmt: Statement | ModuleDeclaration): stmt is ExpressionStatement {

ts/tests/helpers/skeleton-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default class SkeletonApp {
4444
));
4545
}
4646

47-
updatePackageJSON(callback: (arg: any) => string) {
47+
updatePackageJSON(callback: (arg: any) => any) {
4848
let pkgPath = `${this.root}/package.json`;
4949
let pkg = fs.readJSONSync(pkgPath);
5050
fs.writeJSONSync(pkgPath, callback(pkg) || pkg, { spaces: 2 });

ts/types/broccoli-stew/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'broccoli-stew' {
2+
import { Node as BroccoliNode } from 'broccoli-node-api';
3+
import Plugin from 'broccoli-plugin';
4+
5+
export function afterBuild(node: BroccoliNode, callback: (this: Plugin) => void): BroccoliNode;
6+
}

0 commit comments

Comments
 (0)