ember-cli 4.8.0 → 4.9.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/LICENSE +1 -1
  3. package/bin/ember +3 -0
  4. package/blueprints/addon/additional-package.json +19 -0
  5. package/blueprints/addon/files/npmignore +0 -1
  6. package/blueprints/addon/index.js +18 -18
  7. package/blueprints/app/files/.ember-cli +3 -3
  8. package/blueprints/app/files/.eslintrc.js +12 -3
  9. package/blueprints/app/files/app/{app.js → app.ts} +0 -0
  10. package/blueprints/app/files/app/{router.js → router.ts} +3 -1
  11. package/blueprints/app/files/config/environment.js +1 -0
  12. package/blueprints/app/files/package.json +12 -9
  13. package/blueprints/app/files/tests/helpers/{index.js → index.ts} +4 -3
  14. package/blueprints/app/files/tests/{test-helper.js → test-helper.ts} +0 -0
  15. package/blueprints/app/index.js +10 -0
  16. package/docs/build/data.json +44 -44
  17. package/lib/commands/addon.js +1 -0
  18. package/lib/commands/destroy.js +1 -1
  19. package/lib/commands/generate.js +2 -10
  20. package/lib/commands/init.js +1 -0
  21. package/lib/commands/new.js +32 -4
  22. package/lib/models/asset-size-printer.js +1 -1
  23. package/lib/models/blueprint.js +24 -1
  24. package/lib/models/builder.js +13 -6
  25. package/lib/models/project.js +2 -1
  26. package/lib/models/server-watcher.js +2 -2
  27. package/lib/models/watcher.js +23 -6
  28. package/lib/tasks/build-watch.js +9 -7
  29. package/lib/tasks/generate-from-blueprint.js +1 -1
  30. package/lib/tasks/install-blueprint.js +1 -1
  31. package/lib/tasks/interactive-new.js +153 -0
  32. package/lib/tasks/npm-task.js +1 -1
  33. package/lib/tasks/serve.js +10 -8
  34. package/lib/utilities/find-build-file.js +17 -9
  35. package/lib/utilities/lint-fix.js +11 -10
  36. package/package.json +12 -10
  37. package/blueprints/addon/additional-dev-dependencies.json +0 -8
  38. package/blueprints/addon/files/addon-config/environment.js +0 -5
  39. package/blueprints/app/files/vendor/.gitkeep +0 -0
@@ -3,7 +3,7 @@
3
3
  "logo": "https://ember-cli.com/assets/images/ember-cli-logo-small-dark.png",
4
4
  "name": "ember-cli",
5
5
  "description": "Command line tool for developing ambitious ember.js apps",
6
- "version": "4.8.0-release-d65f2e1286"
6
+ "version": "4.9.0-beta.0-beta-34257a7c8e"
7
7
  },
8
8
  "files": {
9
9
  "lib/broccoli/default-packager.js": {
@@ -4600,7 +4600,7 @@
4600
4600
  },
4601
4601
  {
4602
4602
  "file": "lib/models/blueprint.js",
4603
- "line": 1325,
4603
+ "line": 1344,
4604
4604
  "description": "Used to retrieve a task with the given name. Passes the new task\nthe standard information available (like `ui`, `analytics`, `project`, etc).",
4605
4605
  "itemtype": "method",
4606
4606
  "name": "taskFor",
@@ -4617,7 +4617,7 @@
4617
4617
  },
4618
4618
  {
4619
4619
  "file": "lib/models/blueprint.js",
4620
- "line": 1343,
4620
+ "line": 1362,
4621
4621
  "description": "Inserts the given content into a file. If the `contentsToInsert` string is already\npresent in the current contents, the file will not be changed unless `force` option\nis passed.\n\nIf `options.before` is specified, `contentsToInsert` will be inserted before\nthe first instance of that string. If `options.after` is specified, the\ncontents will be inserted after the first instance of that string.\nIf the string specified by options.before or options.after is not in the file,\nno change will be made.\n\nIf neither `options.before` nor `options.after` are present, `contentsToInsert`\nwill be inserted at the end of the file.\n\nExample:\n```\n// app/router.js\nRouter.map(function () {\n});\n```\n\n```\ninsertIntoFile('app/router.js', ' this.route(\"admin\");', {\n after: 'Router.map(function () {' + EOL\n}).then(function() {\n // file has been inserted into!\n});\n\n\n```\n\n```\n// app/router.js\nRouter.map(function () {\n this.route(\"admin\");\n});\n```",
4622
4622
  "itemtype": "method",
4623
4623
  "name": "insertIntoFile",
@@ -4647,7 +4647,7 @@
4647
4647
  },
4648
4648
  {
4649
4649
  "file": "lib/models/blueprint.js",
4650
- "line": 1447,
4650
+ "line": 1466,
4651
4651
  "description": "Used to retrieve a blueprint with the given name.",
4652
4652
  "itemtype": "method",
4653
4653
  "name": "lookupBlueprint",
@@ -4669,7 +4669,7 @@
4669
4669
  },
4670
4670
  {
4671
4671
  "file": "lib/models/blueprint.js",
4672
- "line": 1464,
4672
+ "line": 1483,
4673
4673
  "static": 1,
4674
4674
  "itemtype": "method",
4675
4675
  "name": "lookup",
@@ -4716,7 +4716,7 @@
4716
4716
  },
4717
4717
  {
4718
4718
  "file": "lib/models/blueprint.js",
4719
- "line": 1513,
4719
+ "line": 1532,
4720
4720
  "description": "Loads a blueprint from given path.",
4721
4721
  "static": 1,
4722
4722
  "itemtype": "method",
@@ -4744,7 +4744,7 @@
4744
4744
  },
4745
4745
  {
4746
4746
  "file": "lib/models/blueprint.js",
4747
- "line": 1541,
4747
+ "line": 1560,
4748
4748
  "static": 1,
4749
4749
  "itemtype": "method",
4750
4750
  "name": "list",
@@ -4774,7 +4774,7 @@
4774
4774
  },
4775
4775
  {
4776
4776
  "file": "lib/models/blueprint.js",
4777
- "line": 1590,
4777
+ "line": 1609,
4778
4778
  "description": "Files that are renamed when installed into the target directory.\nThis allows including files in the blueprint that would have an effect\non another process, such as a file named `.gitignore`.\n\nThe keys are the filenames used in the files folder.\nThe values are the filenames used in the target directory.",
4779
4779
  "static": 1,
4780
4780
  "itemtype": "property",
@@ -4785,7 +4785,7 @@
4785
4785
  },
4786
4786
  {
4787
4787
  "file": "lib/models/blueprint.js",
4788
- "line": 1605,
4788
+ "line": 1624,
4789
4789
  "static": 1,
4790
4790
  "itemtype": "property",
4791
4791
  "name": "ignoredFiles",
@@ -4795,7 +4795,7 @@
4795
4795
  },
4796
4796
  {
4797
4797
  "file": "lib/models/blueprint.js",
4798
- "line": 1611,
4798
+ "line": 1630,
4799
4799
  "static": 1,
4800
4800
  "itemtype": "property",
4801
4801
  "name": "ignoredUpdateFiles",
@@ -4805,7 +4805,7 @@
4805
4805
  },
4806
4806
  {
4807
4807
  "file": "lib/models/blueprint.js",
4808
- "line": 1617,
4808
+ "line": 1636,
4809
4809
  "static": 1,
4810
4810
  "itemtype": "property",
4811
4811
  "name": "defaultLookupPaths",
@@ -4815,7 +4815,7 @@
4815
4815
  },
4816
4816
  {
4817
4817
  "file": "lib/models/blueprint.js",
4818
- "line": 1625,
4818
+ "line": 1644,
4819
4819
  "access": "private",
4820
4820
  "tagname": "",
4821
4821
  "itemtype": "method",
@@ -4837,7 +4837,7 @@
4837
4837
  },
4838
4838
  {
4839
4839
  "file": "lib/models/blueprint.js",
4840
- "line": 1638,
4840
+ "line": 1657,
4841
4841
  "access": "private",
4842
4842
  "tagname": "",
4843
4843
  "itemtype": "method",
@@ -4855,7 +4855,7 @@
4855
4855
  },
4856
4856
  {
4857
4857
  "file": "lib/models/blueprint.js",
4858
- "line": 1649,
4858
+ "line": 1668,
4859
4859
  "access": "private",
4860
4860
  "tagname": "",
4861
4861
  "itemtype": "method",
@@ -4873,7 +4873,7 @@
4873
4873
  },
4874
4874
  {
4875
4875
  "file": "lib/models/blueprint.js",
4876
- "line": 1658,
4876
+ "line": 1677,
4877
4877
  "access": "private",
4878
4878
  "tagname": "",
4879
4879
  "itemtype": "method",
@@ -4900,7 +4900,7 @@
4900
4900
  },
4901
4901
  {
4902
4902
  "file": "lib/models/blueprint.js",
4903
- "line": 1672,
4903
+ "line": 1691,
4904
4904
  "access": "private",
4905
4905
  "tagname": "",
4906
4906
  "itemtype": "method",
@@ -4922,7 +4922,7 @@
4922
4922
  },
4923
4923
  {
4924
4924
  "file": "lib/models/blueprint.js",
4925
- "line": 1684,
4925
+ "line": 1703,
4926
4926
  "description": "Combines provided lookup paths with defaults and removes\nduplicates.",
4927
4927
  "access": "private",
4928
4928
  "tagname": "",
@@ -4945,7 +4945,7 @@
4945
4945
  },
4946
4946
  {
4947
4947
  "file": "lib/models/blueprint.js",
4948
- "line": 1699,
4948
+ "line": 1718,
4949
4949
  "description": "Looks for a __path__ token in the files folder. Must be present for\nthe blueprint to support pod tokens.",
4950
4950
  "access": "private",
4951
4951
  "tagname": "",
@@ -4968,7 +4968,7 @@
4968
4968
  },
4969
4969
  {
4970
4970
  "file": "lib/models/blueprint.js",
4971
- "line": 1738,
4971
+ "line": 1757,
4972
4972
  "access": "private",
4973
4973
  "tagname": "",
4974
4974
  "itemtype": "method",
@@ -4990,7 +4990,7 @@
4990
4990
  },
4991
4991
  {
4992
4992
  "file": "lib/models/blueprint.js",
4993
- "line": 1752,
4993
+ "line": 1771,
4994
4994
  "access": "private",
4995
4995
  "tagname": "",
4996
4996
  "itemtype": "method",
@@ -5012,7 +5012,7 @@
5012
5012
  },
5013
5013
  {
5014
5014
  "file": "lib/models/blueprint.js",
5015
- "line": 1762,
5015
+ "line": 1781,
5016
5016
  "access": "private",
5017
5017
  "tagname": "",
5018
5018
  "itemtype": "method",
@@ -5027,7 +5027,7 @@
5027
5027
  },
5028
5028
  {
5029
5029
  "file": "lib/models/blueprint.js",
5030
- "line": 1775,
5030
+ "line": 1794,
5031
5031
  "access": "private",
5032
5032
  "tagname": "",
5033
5033
  "itemtype": "method",
@@ -5049,7 +5049,7 @@
5049
5049
  },
5050
5050
  {
5051
5051
  "file": "lib/models/builder.js",
5052
- "line": 40,
5052
+ "line": 39,
5053
5053
  "access": "private",
5054
5054
  "tagname": "",
5055
5055
  "itemtype": "method",
@@ -5065,7 +5065,7 @@
5065
5065
  },
5066
5066
  {
5067
5067
  "file": "lib/models/builder.js",
5068
- "line": 55,
5068
+ "line": 60,
5069
5069
  "access": "private",
5070
5070
  "tagname": "",
5071
5071
  "itemtype": "method",
@@ -5075,7 +5075,7 @@
5075
5075
  },
5076
5076
  {
5077
5077
  "file": "lib/models/builder.js",
5078
- "line": 93,
5078
+ "line": 98,
5079
5079
  "description": "Determine whether the output path is safe to delete. If the outputPath\nappears anywhere in the parents of the project root, the build would\ndelete the project directory. In this case return `false`, otherwise\nreturn `true`.",
5080
5080
  "access": "private",
5081
5081
  "tagname": "",
@@ -5097,7 +5097,7 @@
5097
5097
  },
5098
5098
  {
5099
5099
  "file": "lib/models/builder.js",
5100
- "line": 115,
5100
+ "line": 120,
5101
5101
  "access": "private",
5102
5102
  "tagname": "",
5103
5103
  "itemtype": "method",
@@ -5114,7 +5114,7 @@
5114
5114
  },
5115
5115
  {
5116
5116
  "file": "lib/models/builder.js",
5117
- "line": 139,
5117
+ "line": 144,
5118
5118
  "access": "private",
5119
5119
  "tagname": "",
5120
5120
  "itemtype": "method",
@@ -5138,7 +5138,7 @@
5138
5138
  },
5139
5139
  {
5140
5140
  "file": "lib/models/builder.js",
5141
- "line": 164,
5141
+ "line": 169,
5142
5142
  "access": "private",
5143
5143
  "tagname": "",
5144
5144
  "itemtype": "method",
@@ -5152,7 +5152,7 @@
5152
5152
  },
5153
5153
  {
5154
5154
  "file": "lib/models/builder.js",
5155
- "line": 237,
5155
+ "line": 244,
5156
5156
  "description": "Delegates to the `cleanup` method of the wrapped Broccoli builder.",
5157
5157
  "access": "private",
5158
5158
  "tagname": "",
@@ -5167,7 +5167,7 @@
5167
5167
  },
5168
5168
  {
5169
5169
  "file": "lib/models/builder.js",
5170
- "line": 269,
5170
+ "line": 276,
5171
5171
  "description": "Checks for issues in the environment that can't easily be detected until\nafter a build and issues any necessary deprecation warnings.\n\n- check for old (pre 0.1.4) versions of heimdalljs",
5172
5172
  "access": "private",
5173
5173
  "tagname": "",
@@ -6182,7 +6182,7 @@
6182
6182
  },
6183
6183
  {
6184
6184
  "file": "lib/models/project.js",
6185
- "line": 508,
6185
+ "line": 509,
6186
6186
  "description": "Returns what commands are made available by addons by inspecting\n`includedCommands` for every addon.",
6187
6187
  "access": "private",
6188
6188
  "tagname": "",
@@ -6197,7 +6197,7 @@
6197
6197
  },
6198
6198
  {
6199
6199
  "file": "lib/models/project.js",
6200
- "line": 549,
6200
+ "line": 550,
6201
6201
  "description": "Execute a given callback for every addon command.\nExample:\n\n```\nproject.eachAddonCommand(function(addonName, commands) {\n console.log('Addon ' + addonName + ' exported the following commands:' + commands.keys().join(', '));\n});\n```",
6202
6202
  "access": "private",
6203
6203
  "tagname": "",
@@ -6215,7 +6215,7 @@
6215
6215
  },
6216
6216
  {
6217
6217
  "file": "lib/models/project.js",
6218
- "line": 572,
6218
+ "line": 573,
6219
6219
  "description": "Path to the blueprints for this project.",
6220
6220
  "access": "private",
6221
6221
  "tagname": "",
@@ -6230,7 +6230,7 @@
6230
6230
  },
6231
6231
  {
6232
6232
  "file": "lib/models/project.js",
6233
- "line": 583,
6233
+ "line": 584,
6234
6234
  "description": "Returns a list of paths (including addon paths) where blueprints will be looked up.",
6235
6235
  "access": "private",
6236
6236
  "tagname": "",
@@ -6245,7 +6245,7 @@
6245
6245
  },
6246
6246
  {
6247
6247
  "file": "lib/models/project.js",
6248
- "line": 601,
6248
+ "line": 602,
6249
6249
  "description": "Returns a list of addon paths where blueprints will be looked up.",
6250
6250
  "access": "private",
6251
6251
  "tagname": "",
@@ -6260,7 +6260,7 @@
6260
6260
  },
6261
6261
  {
6262
6262
  "file": "lib/models/project.js",
6263
- "line": 624,
6263
+ "line": 625,
6264
6264
  "description": "Reloads package.json of the project. Clears and reloads the packageInfo and\nper-bundle addon cache, too.",
6265
6265
  "access": "private",
6266
6266
  "tagname": "",
@@ -6275,7 +6275,7 @@
6275
6275
  },
6276
6276
  {
6277
6277
  "file": "lib/models/project.js",
6278
- "line": 652,
6278
+ "line": 653,
6279
6279
  "description": "Re-initializes addons.",
6280
6280
  "access": "private",
6281
6281
  "tagname": "",
@@ -6286,7 +6286,7 @@
6286
6286
  },
6287
6287
  {
6288
6288
  "file": "lib/models/project.js",
6289
- "line": 665,
6289
+ "line": 666,
6290
6290
  "description": "Find an addon by its name",
6291
6291
  "access": "public",
6292
6292
  "tagname": "",
@@ -6308,7 +6308,7 @@
6308
6308
  },
6309
6309
  {
6310
6310
  "file": "lib/models/project.js",
6311
- "line": 679,
6311
+ "line": 680,
6312
6312
  "description": "Generate test file contents.\n\nThis method is supposed to be overwritten by test framework addons\nlike `ember-qunit` and `ember-mocha`.",
6313
6313
  "access": "public",
6314
6314
  "tagname": "",
@@ -6335,7 +6335,7 @@
6335
6335
  },
6336
6336
  {
6337
6337
  "file": "lib/models/project.js",
6338
- "line": 703,
6338
+ "line": 704,
6339
6339
  "description": "Returns a new project based on the first `package.json` that is found\nin `pathName`.\n\nIf the above `package.json` specifies `ember-addon.projectRoot`, we load\nthe project based on the relative path between this directory and the\nspecified `projectRoot`.",
6340
6340
  "access": "private",
6341
6341
  "tagname": "",
@@ -6363,7 +6363,7 @@
6363
6363
  },
6364
6364
  {
6365
6365
  "file": "lib/models/project.js",
6366
- "line": 754,
6366
+ "line": 755,
6367
6367
  "description": "Returns a new project based on the first package.json that is found\nin `pathName`, or the nullProject.\n\nThe nullProject signifies no-project, but abides by the null object pattern",
6368
6368
  "access": "private",
6369
6369
  "tagname": "",
@@ -6386,7 +6386,7 @@
6386
6386
  },
6387
6387
  {
6388
6388
  "file": "lib/models/project.js",
6389
- "line": 778,
6389
+ "line": 779,
6390
6390
  "description": "Returns the project root based on the first package.json that is found",
6391
6391
  "static": 1,
6392
6392
  "itemtype": "method",
@@ -6411,7 +6411,7 @@
6411
6411
  },
6412
6412
  {
6413
6413
  "file": "lib/tasks/build-watch.js",
6414
- "line": 51,
6414
+ "line": 53,
6415
6415
  "description": "Exit silently",
6416
6416
  "access": "private",
6417
6417
  "tagname": "",
@@ -6437,7 +6437,7 @@
6437
6437
  },
6438
6438
  {
6439
6439
  "file": "lib/tasks/serve.js",
6440
- "line": 101,
6440
+ "line": 103,
6441
6441
  "description": "Exit silently",
6442
6442
  "access": "private",
6443
6443
  "tagname": "",
@@ -26,6 +26,7 @@ module.exports = NewCommand.extend({
26
26
  default: 'github',
27
27
  description: 'Installs the default CI blueprint. Either Travis or Github Actions is supported.',
28
28
  },
29
+ { name: 'typescript', type: Boolean, default: false, description: 'Set up the addon to use TypeScript' },
29
30
  ],
30
31
 
31
32
  anonymousOptions: ['<addon-name>'],
@@ -68,7 +68,7 @@ module.exports = Command.extend({
68
68
  };
69
69
 
70
70
  if (this.settings && this.settings.usePods && !commandOptions.classic) {
71
- commandOptions.pod = !commandOptions.pod;
71
+ commandOptions.pod = true;
72
72
  }
73
73
 
74
74
  if (commandOptions.in) {
@@ -58,16 +58,8 @@ module.exports = Command.extend({
58
58
  args: rawArgs,
59
59
  };
60
60
 
61
- if (this.settings && this.settings.usePods) {
62
- if (commandOptions.pod) {
63
- let warning = 'Using both .ember-cli usePods settings and --pod flag ';
64
- warning += 'together has been deprecated.';
65
- this.ui.writeDeprecateLine(warning);
66
- }
67
-
68
- if (!commandOptions.classic) {
69
- commandOptions.pod = !commandOptions.pod;
70
- }
61
+ if (this.settings && this.settings.usePods && !commandOptions.classic) {
62
+ commandOptions.pod = true;
71
63
  }
72
64
 
73
65
  if (commandOptions.in) {
@@ -42,6 +42,7 @@ module.exports = Command.extend({
42
42
  default: 'github',
43
43
  description: 'Installs the default CI blueprint. Either Travis or Github Actions is supported.',
44
44
  },
45
+ { name: 'typescript', type: Boolean, default: false, description: 'Set up the app to use TypeScript' },
45
46
  ],
46
47
 
47
48
  anonymousOptions: ['<glob-pattern>'],
@@ -38,9 +38,16 @@ module.exports = Command.extend({
38
38
  {
39
39
  name: 'ci-provider',
40
40
  type: ['travis', 'github'],
41
- default: 'github',
42
41
  description: 'Installs the default CI blueprint. Either Travis or Github Actions is supported.',
43
42
  },
43
+ {
44
+ name: 'interactive',
45
+ type: Boolean,
46
+ default: false,
47
+ aliases: ['i'],
48
+ description: 'Create a new Ember app/addon in an interactive way.',
49
+ },
50
+ { name: 'typescript', type: Boolean, default: false, description: 'Set up the app to use TypeScript' },
44
51
  ],
45
52
 
46
53
  anonymousOptions: ['<app-name>'],
@@ -53,10 +60,31 @@ module.exports = Command.extend({
53
60
 
54
61
  commandOptions.name = rawArgs.shift();
55
62
 
56
- if (!projectName) {
57
- message = `The \`ember ${this.name}\` command requires a name to be specified. For more details, use \`ember help\`.`;
63
+ if (!projectName || commandOptions.interactive) {
64
+ let answers = await this.runTask('InteractiveNew', commandOptions);
58
65
 
59
- return Promise.reject(new SilentError(message));
66
+ commandOptions.blueprint = answers.blueprint;
67
+
68
+ if (answers.name) {
69
+ projectName = answers.name;
70
+ commandOptions.name = answers.name;
71
+ }
72
+
73
+ if (answers.lang) {
74
+ commandOptions.lang = answers.lang;
75
+ }
76
+
77
+ if (answers.packageManager) {
78
+ commandOptions.yarn = answers.packageManager === 'yarn';
79
+ }
80
+
81
+ if (answers.ciProvider) {
82
+ commandOptions.ciProvider = answers.ciProvider;
83
+ }
84
+ }
85
+
86
+ if (!commandOptions.ciProvider) {
87
+ commandOptions.ciProvider = 'github';
60
88
  }
61
89
 
62
90
  if (commandOptions.dryRun) {
@@ -11,7 +11,7 @@ module.exports = class AssetPrinterSize {
11
11
  }
12
12
 
13
13
  print() {
14
- const filesize = require('filesize');
14
+ const { filesize } = require('filesize');
15
15
  let ui = this.ui;
16
16
 
17
17
  return this.makeAssetSizesObject().then((files) => {
@@ -490,7 +490,7 @@ let Blueprint = CoreObject.extend({
490
490
  // it's possible for people to set `{typescript: true}` in their `.ember-cli` file, which would
491
491
  // then erroneously trigger this message every time they generate a JS blueprint even though
492
492
  // they didn't pass the flag.
493
- if (options.typescript === true) {
493
+ if (options.typescript === true && isJavaScriptFile(fileInfo.outputPath)) {
494
494
  this.ui.writeLine(
495
495
  chalk.yellow(
496
496
  "You passed the '--typescript' flag but there is no TypeScript blueprint available. " +
@@ -1319,6 +1319,25 @@ let Blueprint = CoreObject.extend({
1319
1319
  let installText = packages.length > 1 ? 'install addons' : 'install addon';
1320
1320
  this._writeStatusToUI(chalk.green, installText, taskOptions['packages'].join(', '));
1321
1321
 
1322
+ if (!this.project.isEmberCLIProject()) {
1323
+ // our blueprint ran *outside* an ember-cli project. So the only way this
1324
+ // makes sense if the blueprint generated a new project, which we're now
1325
+ // ready to add some addons into. So we need to switch from "outside" mode
1326
+ // to "inside" by reinitializing the Project.
1327
+ //
1328
+ // One might think the cache clear is unnecessary, because in theory the
1329
+ // caches should be shareable, but in practice the new Project we create
1330
+ // below will have the same root dir as the NullProject and that makes bad
1331
+ // things happen.
1332
+ this.project.packageInfoCache._clear();
1333
+ const Project = require('../../lib/models/project');
1334
+ this.project = taskOptions.blueprintOptions.project = Project.closestSync(
1335
+ this.project.root,
1336
+ this.project.ui,
1337
+ this.project.cli
1338
+ );
1339
+ }
1340
+
1322
1341
  return this.taskFor('addon-install').run(taskOptions);
1323
1342
  },
1324
1343
 
@@ -1811,4 +1830,8 @@ function isTypeScriptFile(filePath) {
1811
1830
  return path.extname(filePath) === '.ts';
1812
1831
  }
1813
1832
 
1833
+ function isJavaScriptFile(filePath) {
1834
+ return path.extname(filePath) === '.js';
1835
+ }
1836
+
1814
1837
  module.exports = Blueprint;
@@ -26,7 +26,6 @@ class Builder extends CoreObject {
26
26
 
27
27
  // Use Broccoli 2.0 by default, if this fails due to .read/.rebuild API, fallback to broccoli-builder
28
28
  this.broccoliBuilderFallback = false;
29
- this.setupBroccoliBuilder();
30
29
 
31
30
  this._instantiationStack = new Error().stack.replace(/[^\n]*\n/, '');
32
31
  this._cleanup = this.cleanup.bind(this);
@@ -42,25 +41,31 @@ class Builder extends CoreObject {
42
41
  * @method readBuildFile
43
42
  * @param path The file path to read the build file from
44
43
  */
45
- readBuildFile(path) {
44
+ async readBuildFile(path) {
46
45
  // Load the build file
47
- let buildFile = findBuildFile('ember-cli-build.js', path);
46
+ let buildFile = await findBuildFile(path);
48
47
  if (buildFile) {
49
- return buildFile({ project: this.project });
48
+ return await buildFile({ project: this.project });
50
49
  }
51
50
 
52
51
  throw new SilentError('No ember-cli-build.js found.');
53
52
  }
54
53
 
54
+ async ensureBroccoliBuilder() {
55
+ if (this.builder === undefined) {
56
+ await this.setupBroccoliBuilder();
57
+ }
58
+ }
59
+
55
60
  /**
56
61
  * @private
57
62
  * @method setupBroccoliBuilder
58
63
  */
59
- setupBroccoliBuilder() {
64
+ async setupBroccoliBuilder() {
60
65
  this.environment = this.environment || 'development';
61
66
  process.env.EMBER_ENV = process.env.EMBER_ENV || this.environment;
62
67
 
63
- this.tree = this.readBuildFile(this.project.root);
68
+ this.tree = await this.readBuildFile(this.project.root);
64
69
 
65
70
  let broccoli = require('broccoli');
66
71
 
@@ -167,6 +172,8 @@ class Builder extends CoreObject {
167
172
  * @return {Promise}
168
173
  */
169
174
  async build(addWatchDirCallback, resultAnnotation) {
175
+ await this.ensureBroccoliBuilder();
176
+
170
177
  let buildResults, uiProgressIntervalID;
171
178
 
172
179
  try {
@@ -311,7 +311,7 @@ class Project {
311
311
  if (fs.existsSync(`${targetsPath}.js`)) {
312
312
  this._targets = this.require(targetsPath);
313
313
  } else {
314
- this._targets = require('../../blueprints/app/files/config/targets');
314
+ this._targets = { browsers: ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'] };
315
315
  }
316
316
  return this._targets;
317
317
  }
@@ -496,6 +496,7 @@ class Project {
496
496
  return;
497
497
  }
498
498
  this._addonsInitialized = true;
499
+ this._didDiscoverAddons = false;
499
500
 
500
501
  logger.info('initializeAddons for: %s', this.name());
501
502
 
@@ -3,8 +3,8 @@
3
3
  const Watcher = require('./watcher');
4
4
 
5
5
  module.exports = class ServerWatcher extends Watcher {
6
- constructor(options) {
7
- super(options);
6
+ constructor(options, build) {
7
+ super(options, build);
8
8
 
9
9
  this.watcher.on('add', this.didAdd.bind(this));
10
10
  this.watcher.on('delete', this.didDelete.bind(this));
@@ -12,19 +12,35 @@ const eventTypeNormalization = {
12
12
  change: 'changed',
13
13
  };
14
14
 
15
+ const ConstructedFromBuilder = Symbol('Watcher.build');
16
+
15
17
  module.exports = class Watcher extends CoreObject {
16
- constructor(_options) {
18
+ constructor(_options, build) {
19
+ if (build !== ConstructedFromBuilder) {
20
+ throw new Error('instantiate Watcher with (await Watcher.build()).watcher, not new Watcher()');
21
+ }
22
+
17
23
  super(_options);
18
24
 
19
25
  this.verbose = true;
26
+ this.serving = _options.serving;
27
+ }
20
28
 
21
- let options = this.buildOptions();
29
+ static async build(_options) {
30
+ let watcher = new this(_options, ConstructedFromBuilder);
31
+ await watcher.setupBroccoliWatcher(_options);
22
32
 
23
- logger.info('initialize %o', options);
33
+ // This indirection is because Watcher instances are themselves spec
34
+ // noncompliant thennables (see the then() method) so returning watcher
35
+ // directly will interfere with `await Watcher.build()`
36
+ return { watcher };
37
+ }
24
38
 
25
- this.serving = _options.serving;
39
+ async setupBroccoliWatcher() {
40
+ let options = this.buildOptions();
26
41
 
27
- this.watcher = this.watcher || this.constructBroccoliWatcher(options);
42
+ logger.info('initialize %o', options);
43
+ this.watcher = this.watcher || (await this.constructBroccoliWatcher(options));
28
44
 
29
45
  this.setupBroccoliChangeEvent();
30
46
  this.watcher.on('buildStart', this._setupBroccoliWatcherBuild.bind(this));
@@ -38,8 +54,9 @@ module.exports = class Watcher extends CoreObject {
38
54
  this.serveURL = serveURL;
39
55
  }
40
56
 
41
- constructBroccoliWatcher(options) {
57
+ async constructBroccoliWatcher(options) {
42
58
  const { Watcher } = require('broccoli');
59
+ await this.builder.ensureBroccoliBuilder();
43
60
  const { watchedSourceNodeWrappers } = this.builder.builder;
44
61
 
45
62
  let watcher = new Watcher(this.builder, watchedSourceNodeWrappers, { saneOptions: options, ignored: this.ignored });