@@ -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 commit comments