ember-source 6.5.0-alpha.6 → 6.6.0-alpha.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.
@@ -0,0 +1,9 @@
1
+ <% if (componentClass === '@glimmer/component') {%>import Component from '@glimmer/component';
2
+
3
+ export default class <%= classifiedModuleName %> extends Component {
4
+ <template>
5
+ {{yield}}
6
+ </template>
7
+ }<%} else {%><template>
8
+ {{yield}}
9
+ </template><%}%>
@@ -0,0 +1,13 @@
1
+ <% if (componentClass === '@glimmer/component') {%>import Component from '@glimmer/component';
2
+
3
+ <%= componentSignature %>
4
+ export default class <%= classifiedModuleName %> extends Component<<%= classifiedModuleName %>Signature> {
5
+ <template>
6
+ {{yield}}
7
+ </template>
8
+ }<%} else {%>import type { TOC } from '@ember/component/template-only';
9
+
10
+ <%= componentSignature %>
11
+ <template>
12
+ {{yield}}
13
+ </template> satisfies TOC<<%= classifiedModuleName %>Signature>;<%}%>
@@ -4,6 +4,7 @@ const chalk = require('chalk');
4
4
  const stringUtil = require('ember-cli-string-utils');
5
5
  const getPathOption = require('ember-cli-get-component-path-option');
6
6
  const normalizeEntityName = require('ember-cli-normalize-entity-name');
7
+ const SilentError = require('silent-error');
7
8
  const { generateComponentSignature } = require('../-utils');
8
9
 
9
10
  const typescriptBlueprintPolyfill = require('ember-cli-typescript-blueprint-polyfill');
@@ -40,6 +41,17 @@ module.exports = {
40
41
  default: 'flat',
41
42
  aliases: [{ fs: 'flat' }, { ns: 'nested' }],
42
43
  },
44
+ {
45
+ name: 'component-authoring-format',
46
+ type: ['loose', 'strict'],
47
+ default: 'loose',
48
+ aliases: [
49
+ { loose: 'loose' },
50
+ { strict: 'strict' },
51
+ { 'template-tag': 'strict' },
52
+ { tt: 'strict' },
53
+ ],
54
+ },
43
55
  ],
44
56
 
45
57
  init() {
@@ -58,6 +70,18 @@ module.exports = {
58
70
  options.componentClass = '';
59
71
  }
60
72
 
73
+ if (options.componentAuthoringFormat === 'strict') {
74
+ if (options.componentClass === '@ember/component') {
75
+ throw new SilentError(
76
+ 'The "@ember/component" component class cannot be used in combination with the "--strict" flag'
77
+ );
78
+ }
79
+
80
+ if (options.componentClass === '') {
81
+ options.componentClass = '@ember/component/template-only';
82
+ }
83
+ }
84
+
61
85
  return this._super.install.apply(this, arguments);
62
86
  },
63
87
 
@@ -78,14 +102,16 @@ module.exports = {
78
102
  afterInstall(options) {
79
103
  this._super.afterInstall.apply(this, arguments);
80
104
 
81
- this.skippedJsFiles.forEach((file) => {
82
- let mapped = this.mapFile(file, this.savedLocals);
83
- this.ui.writeLine(` ${chalk.yellow('skip')} ${mapped}`);
84
- });
105
+ if (options.componentAuthoringFormat === 'loose') {
106
+ this.skippedJsFiles.forEach((file) => {
107
+ let mapped = this.mapFile(file, this.savedLocals);
108
+ this.ui.writeLine(` ${chalk.yellow('skip')} ${mapped}`);
109
+ });
85
110
 
86
- if (this.skippedJsFiles.size > 0) {
87
- let command = `ember generate component-class ${options.entity.name}`;
88
- this.ui.writeLine(` ${chalk.cyan('tip')} to add a class, run \`${command}\``);
111
+ if (this.skippedJsFiles.size > 0) {
112
+ let command = `ember generate component-class ${options.entity.name}`;
113
+ this.ui.writeLine(` ${chalk.cyan('tip')} to add a class, run \`${command}\``);
114
+ }
89
115
  }
90
116
  },
91
117
 
@@ -135,6 +161,21 @@ module.exports = {
135
161
  }
136
162
  });
137
163
  }
164
+ if (this.options.componentAuthoringFormat === 'strict') {
165
+ const strictFilesToRemove =
166
+ this.options.isTypeScriptProject || this.options.typescript ? '.gjs' : '.gts';
167
+ files = files.filter(
168
+ (file) =>
169
+ !(
170
+ file.endsWith('.js') ||
171
+ file.endsWith('.ts') ||
172
+ file.endsWith('.hbs') ||
173
+ file.endsWith(strictFilesToRemove)
174
+ )
175
+ );
176
+ } else {
177
+ files = files.filter((file) => !(file.endsWith('.gjs') || file.endsWith('.gts')));
178
+ }
138
179
 
139
180
  return files;
140
181
  },
@@ -172,6 +213,7 @@ module.exports = {
172
213
  }
173
214
 
174
215
  return {
216
+ classifiedModuleName,
175
217
  importTemplate,
176
218
  importComponent,
177
219
  componentSignature,
@@ -0,0 +1,28 @@
1
+ import { module, test } from 'qunit';
2
+ import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers';
3
+ import { render } from '@ember/test-helpers';
4
+ import <%= componentName %> from '<%= pkgName %>/components/<%= componentPathName %>';
5
+
6
+ module('<%= friendlyTestDescription %>', function (hooks) {
7
+ setupRenderingTest(hooks);
8
+
9
+ test('it renders', async function (assert) {
10
+ // Updating values is achieved using autotracking, just like in app code. For example:
11
+ // class State { @tracked myProperty = 0; }; const state = new State();
12
+ // and update using state.myProperty = 1; await rerender();
13
+ // Handle any actions with function myAction(val) { ... };
14
+
15
+ await render(<template><%= selfCloseComponent(componentName) %></template>);
16
+
17
+ assert.dom().hasText('');
18
+
19
+ // Template block usage:
20
+ await render(<template>
21
+ <%= openComponent(componentName) %>
22
+ template block text
23
+ <%= closeComponent(componentName) %>
24
+ </template>);
25
+
26
+ assert.dom().hasText('template block text');
27
+ });
28
+ });
@@ -0,0 +1,28 @@
1
+ import { module, test } from 'qunit';
2
+ import { setupRenderingTest } from '<%= modulePrefix %>/tests/helpers';
3
+ import { render } from '@ember/test-helpers';
4
+ import <%= componentName %> from '<%= pkgName %>/components/<%= componentPathName %>';
5
+
6
+ module('<%= friendlyTestDescription %>', function (hooks) {
7
+ setupRenderingTest(hooks);
8
+
9
+ test('it renders', async function (assert) {
10
+ // Updating values is achieved using autotracking, just like in app code. For example:
11
+ // class State { @tracked myProperty = 0; }; const state = new State();
12
+ // and update using state.myProperty = 1; await rerender();
13
+ // Handle any actions with function myAction(val) { ... };
14
+
15
+ await render(<template><%= selfCloseComponent(componentName) %></template>);
16
+
17
+ assert.dom().hasText('');
18
+
19
+ // Template block usage:
20
+ await render(<template>
21
+ <%= openComponent(componentName) %>
22
+ template block text
23
+ <%= closeComponent(componentName) %>
24
+ </template>);
25
+
26
+ assert.dom().hasText('template block text');
27
+ });
28
+ });
@@ -14,6 +14,12 @@ function invocationFor(options) {
14
14
  return parts.map((p) => stringUtil.classify(p)).join('::');
15
15
  }
16
16
 
17
+ function invocationForStrictComponentAuthoringFormat(options) {
18
+ let parts = options.entity.name.split('/');
19
+ let componentName = parts[parts.length - 1];
20
+ return stringUtil.classify(componentName);
21
+ }
22
+
17
23
  module.exports = {
18
24
  description: 'Generates a component integration or unit test.',
19
25
 
@@ -36,6 +42,17 @@ module.exports = {
36
42
  { unit: 'unit' },
37
43
  ],
38
44
  },
45
+ {
46
+ name: 'component-authoring-format',
47
+ type: ['loose', 'strict'],
48
+ default: 'loose',
49
+ aliases: [
50
+ { loose: 'loose' },
51
+ { strict: 'strict' },
52
+ { 'template-tag': 'strict' },
53
+ { tt: 'strict' },
54
+ ],
55
+ },
39
56
  ],
40
57
 
41
58
  fileMapTokens: function () {
@@ -55,6 +72,23 @@ module.exports = {
55
72
  };
56
73
  },
57
74
 
75
+ files() {
76
+ let files = this._super.files.apply(this, arguments);
77
+
78
+ if (this.options.componentAuthoringFormat === 'strict') {
79
+ const strictFilesToRemove =
80
+ this.options.isTypeScriptProject || this.options.typescript ? '.gjs' : '.gts';
81
+ files = files.filter(
82
+ (file) =>
83
+ !(file.endsWith('.js') || file.endsWith('.ts') || file.endsWith(strictFilesToRemove))
84
+ );
85
+ } else {
86
+ files = files.filter((file) => !(file.endsWith('.gjs') || file.endsWith('.gts')));
87
+ }
88
+
89
+ return files;
90
+ },
91
+
58
92
  locals: function (options) {
59
93
  let dasherizedModuleName = stringUtil.dasherize(options.entity.name);
60
94
  let componentPathName = dasherizedModuleName;
@@ -74,7 +108,10 @@ module.exports = {
74
108
  ? "import { hbs } from 'ember-cli-htmlbars';"
75
109
  : "import hbs from 'htmlbars-inline-precompile';";
76
110
 
77
- let templateInvocation = invocationFor(options);
111
+ let templateInvocation =
112
+ this.options.componentAuthoringFormat === 'strict'
113
+ ? invocationForStrictComponentAuthoringFormat(options)
114
+ : invocationFor(options);
78
115
  let componentName = templateInvocation;
79
116
  let openComponent = (descriptor) => `<${descriptor}>`;
80
117
  let closeComponent = (descriptor) => `</${descriptor}>`;
@@ -92,6 +129,7 @@ module.exports = {
92
129
  selfCloseComponent,
93
130
  friendlyTestDescription,
94
131
  hbsImportStatement,
132
+ pkgName: options.project.pkg.name,
95
133
  };
96
134
  },
97
135
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "6.5.0-alpha.6",
2
+ "version": "6.6.0-alpha.1",
3
3
  "buildType": "tag",
4
- "SHA": "6c601053dab9c40d900f19d16b08620c5e13f6ba",
5
- "assetPath": "/tag/shas/6c601053dab9c40d900f19d16b08620c5e13f6ba.tgz"
4
+ "SHA": "e50c80ebf2cbfd5c13d66f3c89fcf4a49163ffac",
5
+ "assetPath": "/tag/shas/e50c80ebf2cbfd5c13d66f3c89fcf4a49163ffac.tgz"
6
6
  }
@@ -5,7 +5,7 @@
5
5
  * Portions Copyright 2008-2011 Apple Inc. All rights reserved.
6
6
  * @license Licensed under MIT license
7
7
  * See https://raw.github.com/emberjs/ember.js/master/LICENSE
8
- * @version 6.5.0-alpha.6
8
+ * @version 6.6.0-alpha.1
9
9
  */
10
10
  /* eslint-disable no-var */
11
11
  /* globals global globalThis self */
@@ -15039,7 +15039,7 @@ var define, require;
15039
15039
  }, Symbol.toStringTag, { value: 'Module' });
15040
15040
 
15041
15041
  // this file gets replaced with the real value during the build
15042
- const version = '6.5.0-alpha.6';
15042
+ const version = '6.6.0-alpha.1';
15043
15043
 
15044
15044
  const emberVersion = /*#__PURE__*/Object.defineProperty({
15045
15045
  __proto__: null,