ember-cli 7.2.0-alpha.1 → 7.2.0-beta.1

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 (33) hide show
  1. package/CHANGELOG.md +40 -46
  2. package/RELEASE.md +6 -5
  3. package/docs/build/data.json +24 -9
  4. package/lib/models/project.js +13 -5
  5. package/lib/utilities/version-utils.js +6 -1
  6. package/package.json +23 -22
  7. package/packages/addon-blueprint/package.json +5 -5
  8. package/packages/app-blueprint/files/package.json +18 -18
  9. package/packages/app-blueprint/package.json +4 -4
  10. package/tests/helpers/acceptance.js +1 -7
  11. package/tests/helpers/fixturify-project.js +29 -137
  12. package/tests/helpers/per-bundle-addon-cache.js +17 -23
  13. package/packages/blueprint-blueprint/files/blueprints/__name__/files/.gitkeep +0 -0
  14. package/packages/blueprint-blueprint/files/blueprints/__name__/index.js +0 -16
  15. package/packages/blueprint-blueprint/index.js +0 -5
  16. package/packages/blueprint-blueprint/package.json +0 -13
  17. package/packages/blueprint-model/index.js +0 -1807
  18. package/packages/blueprint-model/node_modules/.bin/markdown-it +0 -21
  19. package/packages/blueprint-model/package.json +0 -31
  20. package/packages/blueprint-model/utilities/clean-remove.js +0 -31
  21. package/packages/blueprint-model/utilities/directory-for-package-name.js +0 -31
  22. package/packages/blueprint-model/utilities/edit-file-diff.js +0 -64
  23. package/packages/blueprint-model/utilities/experiments.js +0 -63
  24. package/packages/blueprint-model/utilities/file-info.js +0 -170
  25. package/packages/blueprint-model/utilities/insert-into-file.js +0 -125
  26. package/packages/blueprint-model/utilities/is-addon.js +0 -5
  27. package/packages/blueprint-model/utilities/markdown-color.js +0 -208
  28. package/packages/blueprint-model/utilities/open-editor.js +0 -44
  29. package/packages/blueprint-model/utilities/prepend-emoji.js +0 -12
  30. package/packages/blueprint-model/utilities/print-command.js +0 -102
  31. package/packages/blueprint-model/utilities/process-template.js +0 -10
  32. package/packages/blueprint-model/utilities/sequence.js +0 -42
  33. package/packages/blueprint-model/utilities/walk-up-path.js +0 -23
@@ -4,9 +4,10 @@ const path = require('path');
4
4
  const merge = require('lodash/merge');
5
5
  // this is a test-only dependency
6
6
  // eslint-disable-next-line n/no-unpublished-require
7
- const FixturifyProject = require('fixturify-project');
7
+ const { Project: FixturifyProject } = require('fixturify-project');
8
8
  const Project = require('../../lib/models/project');
9
9
  const MockCLI = require('./mock-cli');
10
+ const { readFile } = require('fs/promises');
10
11
 
11
12
  // used in these tests to ensure we are only
12
13
  // operating on the addons added here
@@ -45,22 +46,9 @@ function getOptionsObjectWithCallbackFunction(defaultOptions, optionsOrCallback)
45
46
  );
46
47
  }
47
48
 
48
- // Essentially a copy of the function in node-fixturify-project, converted from TS to JS.
49
- // We need this for use during toJSON().
50
- function parseScoped(name) {
51
- let matched = name.match(/(@[^@/]+)\/(.*)/);
52
- if (matched) {
53
- return {
54
- scope: matched[1],
55
- name: matched[2],
56
- };
57
- }
58
- return null;
59
- }
60
-
61
49
  module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
62
- writeSync() {
63
- super.writeSync(...arguments);
50
+ async write() {
51
+ await super.write(...arguments);
64
52
  this._hasWritten = true;
65
53
  }
66
54
 
@@ -68,26 +56,24 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
68
56
  merge(this.files, filesObj);
69
57
  }
70
58
 
71
- buildProjectModel(ProjectClass = ProjectWithoutInternalAddons) {
59
+ async buildProjectModel(ProjectClass = ProjectWithoutInternalAddons) {
72
60
  if (!this._hasWritten) {
73
- this.writeSync();
61
+ await this.write();
74
62
  }
75
63
 
76
- let pkg = JSON.parse(this.toJSON('package.json'));
77
64
  let cli = new MockCLI();
78
- let root = path.join(this.root, this.name);
79
65
 
80
- return new ProjectClass(root, pkg, cli.ui, cli);
66
+ return new ProjectClass(this.baseDir, this.pkg, cli.ui, cli);
81
67
  }
82
68
 
83
- buildProjectModelForInRepoAddon(addonName, ProjectClass = ProjectWithoutInternalAddons) {
69
+ async buildProjectModelForInRepoAddon(addonName, ProjectClass = ProjectWithoutInternalAddons) {
84
70
  if (!this._hasWritten) {
85
- this.writeSync();
71
+ await this.write();
86
72
  }
87
73
 
88
- let pkg = JSON.parse(this.files.lib[addonName]['package.json']);
74
+ let root = path.join(this.baseDir, 'lib', addonName);
75
+ let pkg = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8'));
89
76
  let cli = new MockCLI();
90
- let root = path.join(this.root, this.name, 'lib', addonName);
91
77
 
92
78
  return new ProjectClass(root, pkg, cli.ui, cli);
93
79
  }
@@ -105,31 +91,7 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
105
91
  */
106
92
  addDependency(name, version, optionsOrCallback) {
107
93
  const options = getOptionsObjectWithCallbackFunction(optionsOrCallback);
108
- return super.addDependency(name, version, options.callback);
109
- }
110
-
111
- /**
112
- * Add a 'reference' entry to this object's `dependencies` list. A 'reference' dependency is
113
- * an entry in `dependencies` where the caller knows the dependency's source files are being
114
- * created elsewhere in the project tree, so no source files should be created locally in
115
- * `node_modules`, which is the standard FixturifyProject (and node-fixturify-project) behavior.
116
- * We do this by adding the necessary reference to `dependencies` during `toJSON`.
117
- *
118
- * This is used when two addons wish to share a single definition on disk for a dependency (various parts of
119
- * ember-cli optimize processing based on paths on disk.)
120
- *
121
- * Because there is no FixturifyProject being created, no callback is given as in other methods.
122
- *
123
- * @param {String} name name of the dependency
124
- * @param {String} version version of the dependency, defaults to '*'. For our purposes, '*' means
125
- * "whatever version was specified elsewhere."
126
- */
127
- addReferenceDependency(name, version = '*') {
128
- if (!this._referenceDependencies) {
129
- this._referenceDependencies = {};
130
- }
131
-
132
- this._referenceDependencies[name] = version;
94
+ return super.addDependency(new this.constructor(name, version), options.callback);
133
95
  }
134
96
 
135
97
  /**
@@ -148,30 +110,6 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
148
110
  return super.addDevDependency(name, version, options.callback);
149
111
  }
150
112
 
151
- /**
152
- * Add a 'reference' entry to this object's `devDependencies` list. A 'reference' devDependency is
153
- * an entry in `devDependencies` where the caller knows the dependency's source files are being
154
- * created elsewhere in the project tree, so no source files should be created locally in
155
- * `node_modules`, which is the standard FixturifyProject (and node-fixturify-project) behavior.
156
- * We do this by adding the necessary reference to `devDependencies` during `toJSON`.
157
- *
158
- * This is used when two addons wish to share a single definition on disk for a devDependency
159
- * (various parts of ember-cli optimize processing based on paths on disk.)
160
- *
161
- * Because there is no FixturifyProject being created, no callback is given as in other methods.
162
- *
163
- * @param {String} name name of the devDependency
164
- * @param {String} version version of the devDependency, defaults to '*'. For our purposes, '*' means
165
- * "whatever version was specified elsewhere."
166
- */
167
- addReferenceDevDependency(name, version = '*') {
168
- if (!this._referenceDevDependencies) {
169
- this._referenceDevDependencies = {};
170
- }
171
-
172
- this._referenceDevDependencies[name] = version;
173
- }
174
-
175
113
  /**
176
114
  * Add an addon to this object's `dependencies` list. The addon files will be written in
177
115
  * this object's `node_modules/<addon_name>` directory when this object is written out.
@@ -274,15 +212,22 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
274
212
  * a callback function while also specifying other properties.)
275
213
  * @returns {FixturifyProject} the newly-created addon
276
214
  */
277
- addInRepoAddon(name, version = '0.0.0', optionsOrCallback) {
215
+ async addInRepoAddon(name, version = '0.0.0', optionsOrCallback) {
278
216
  const options = getOptionsObjectWithCallbackFunction({ allowCachingPerBundle: false }, optionsOrCallback);
279
217
 
280
- const inRepoAddon = new EmberCLIFixturifyProject(name, version, (addon) => {
281
- prepareAddon(addon, options);
218
+ let inRepoAddon;
282
219
 
283
- if (typeof options.callback === 'function') {
284
- options.callback(addon);
285
- }
220
+ await new Promise((resolve) => {
221
+ inRepoAddon = new EmberCLIFixturifyProject(name, version, async (addon) => {
222
+ prepareAddon(addon, options);
223
+
224
+ if (typeof options.callback === 'function') {
225
+ await options.callback(addon);
226
+ resolve();
227
+ } else {
228
+ resolve();
229
+ }
230
+ });
286
231
  });
287
232
 
288
233
  // configure the current project to have an ember-addon configured at the
@@ -301,10 +246,9 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
301
246
 
302
247
  addon.paths.push(addonPath);
303
248
 
304
- this.files[addonRootDir] = this.files[addonRootDir] || {};
249
+ inRepoAddon.baseDir = path.join(this.baseDir, addonRootDir, inRepoAddon.pkg.name);
305
250
 
306
- let addonJSON = inRepoAddon.toJSON();
307
- Object.assign(this.files[addonRootDir], addonJSON);
251
+ await inRepoAddon.write();
308
252
  return inRepoAddon;
309
253
  }
310
254
 
@@ -322,12 +266,12 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
322
266
  * @returns {FixturifyProject} the newly-created addon
323
267
  */
324
268
  addInRepoEngine(name, version = '0.0.0', options = { allowCachingPerBundle: false, enableLazyLoading: false }) {
325
- const callback = (engine) => {
269
+ const callback = async (engine) => {
326
270
  engine.pkg.keywords.push('ember-engine');
327
271
 
328
272
  // call original callback if it exists
329
273
  if (typeof options.callback === 'function') {
330
- options.callback(engine);
274
+ await options.callback(engine);
331
275
  }
332
276
  };
333
277
 
@@ -341,56 +285,4 @@ module.exports = class EmberCLIFixturifyProject extends FixturifyProject {
341
285
 
342
286
  return this.addInRepoAddon(name, version, { ...options, callback });
343
287
  }
344
-
345
- /**
346
- * Convert the object into a data structure suitable for passing to `fixturify`.
347
- *
348
- * @param {String} key optional key. If specified, the object will be run through toJSON, then the given
349
- * property extracted and returned.
350
- * @returns {Object} the `toJSON` value of the object (wrapped) or the toJSON value of the specified field
351
- * (not wrapped.)
352
- */
353
- toJSON(key) {
354
- if (key) {
355
- return super.toJSON(key);
356
- }
357
-
358
- let jsonData = super.toJSON();
359
-
360
- let scoped = parseScoped(this.name);
361
-
362
- // Allowing for scoped names, get the object in the JSON structure that corresponds
363
- // to this FixturifyProject.
364
- let container = scoped ? jsonData[scoped.scope][scoped.name] : jsonData[this.name];
365
-
366
- if (this._referenceDependencies || this._referenceDevDependencies) {
367
- let pkg = JSON.parse(container['package.json']);
368
-
369
- if (this._referenceDependencies) {
370
- if (!pkg.dependencies) {
371
- pkg.dependencies = {};
372
- }
373
-
374
- Object.assign(pkg.dependencies, this._referenceDependencies);
375
- }
376
-
377
- if (this._referenceDevDependencies) {
378
- if (!pkg.devDependencies) {
379
- pkg.devDependencies = {};
380
- }
381
-
382
- Object.assign(pkg.devDependencies, this._referenceDevDependencies);
383
- }
384
-
385
- container['package.json'] = JSON.stringify(pkg, undefined, 2);
386
- }
387
-
388
- // an optimization to remove any node_modules declaration that has nothing in it,
389
- // to avoid creating extra directories for no reason.
390
- if (container['node_modules'] && Object.keys(container['node_modules']).length === 0) {
391
- delete container['node_modules'];
392
- }
393
-
394
- return jsonData;
395
- }
396
288
  };
@@ -110,53 +110,47 @@ function countAddons(projectOrAddon, config = { byName: {}, proxyCount: 0, realA
110
110
  *
111
111
  * @name createStandardCacheFixture
112
112
  */
113
- function createStandardCacheFixture() {
113
+ async function createStandardCacheFixture() {
114
114
  let project = new FixturifyProject('test-ember-project', '1.0.0');
115
115
 
116
- project.addInRepoAddon('test-addon-a', '1.0.0', {
116
+ await project.addInRepoAddon('test-addon-a', '1.0.0', {
117
117
  callback: (addonA) => {
118
- addonA.addInRepoAddon('test-addon-dep', '1.0.0');
119
-
120
- // At this point, TAD has been run through toJSON inside of TAA.
121
- // TAD itself has no issues.
122
- // in TAA, we want to store all the inrepo addons, at any level, in
123
- // PROJ/lib, so move TAD from TAA and change its path in TAA.
124
118
  addonA.pkg['ember-addon'].paths = ['../test-addon-dep'];
125
- project.files.lib = project.files.lib || {};
126
- project.files.lib['test-addon-dep'] = addonA.files.lib['test-addon-dep'];
127
- delete addonA.files.lib;
128
119
  },
129
120
  });
130
121
 
131
- project.addInRepoEngine('lazy-engine-a', '1.0.0', {
122
+ await project.addInRepoAddon('test-addon-dep', '1.0.0');
123
+
124
+ await project.addInRepoAddon('test-engine-dep', '1.0.0');
125
+ await project.addInRepoEngine('lazy-engine-a', '1.0.0', {
132
126
  enableLazyLoading: true,
133
127
  callback: (lazyEngineA) => {
134
- lazyEngineA.addInRepoAddon('test-engine-dep', '1.0.0');
135
-
136
- // Similar to above
137
128
  lazyEngineA.pkg['ember-addon'].paths = ['../test-engine-dep'];
138
- project.files.lib['test-engine-dep'] = lazyEngineA.files.lib['test-engine-dep'];
139
- delete lazyEngineA.files.lib;
140
129
  },
141
130
  });
142
131
 
143
- project.addInRepoEngine('lazy-engine-b', '1.0.0', {
132
+ await project.addInRepoEngine('lazy-engine-b', '1.0.0', {
144
133
  enableLazyLoading: true,
145
134
  callback: (lazyEngineB) => {
146
- // These two addon definitions have already been moved to project, so just
147
- // fix the ember-addon.paths and remove the files.lib entry.
148
135
  lazyEngineB.pkg['ember-addon'].paths = ['../test-engine-dep', '../test-addon-dep'];
149
- delete lazyEngineB.files.lib;
150
136
  },
151
137
  });
152
138
 
153
- project.addInRepoEngine('regular-engine-c', '1.0.0', {
139
+ await project.addInRepoEngine('regular-engine-c', '1.0.0', {
154
140
  callback: (regularEngineC) => {
155
141
  regularEngineC.pkg['ember-addon'].paths = ['../test-engine-dep'];
156
- delete regularEngineC.files.lib;
157
142
  },
158
143
  });
159
144
 
145
+ // this test is actively trying to test a very strange setup of dependencies so we need to correct
146
+ // the config vs what the above fixturify-project setup would have added
147
+ project.pkg['ember-addon'].paths = [
148
+ 'lib/test-addon-a',
149
+ 'lib/lazy-engine-a',
150
+ 'lib/lazy-engine-b',
151
+ 'lib/regular-engine-c',
152
+ ];
153
+
160
154
  return project;
161
155
  }
162
156
 
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- description: ''
5
-
6
- // locals(options) {
7
- // // Return custom template variables here.
8
- // return {
9
- // foo: options.entity.options.foo
10
- // };
11
- // }
12
-
13
- // afterInstall(options) {
14
- // // Perform extra work here.
15
- // }
16
- };
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- description: 'Generates a blueprint and definition.',
5
- };
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@ember-tooling/blueprint-blueprint",
3
- "version": "0.3.0",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/ember-cli/ember-cli.git",
7
- "directory": "packages/blueprint-blueprint"
8
- },
9
- "license": "MIT",
10
- "keywords": [
11
- "ember-blueprint"
12
- ]
13
- }