|
7 | 7 | get, |
8 | 8 | getOptions, |
9 | 9 | getRuntimeData, |
10 | | - LAYOUT_IMPORT_SPECIFIER, |
11 | | - META_DECORATORS, |
12 | 10 | METHOD_DECORATORS, |
13 | 11 | startsWithUpperCaseLetter |
14 | 12 | } = require("./util"); |
@@ -68,9 +66,6 @@ function getEmberObjectProps( |
68 | 66 | prop.setRuntimeData(runtimeData); |
69 | 67 | instanceProps.push(prop); |
70 | 68 | } |
71 | | - if (prop.isLayout) { |
72 | | - prop.setLayoutValue(LAYOUT_IMPORT_SPECIFIER); |
73 | | - } |
74 | 69 | }); |
75 | 70 |
|
76 | 71 | // Assign decoator names to the binding props if any |
@@ -127,7 +122,7 @@ function getDecoratorInfo(specifier, importPropDecoratorMap) { |
127 | 122 | decoratorName = localName; |
128 | 123 | } else { |
129 | 124 | if (isMetaDecorator) { |
130 | | - decoratorName = META_DECORATORS[importedName] || localName; |
| 125 | + decoratorName = localName; |
131 | 126 | } else { |
132 | 127 | decoratorName = importPropDecoratorMap[importedName]; |
133 | 128 | } |
@@ -175,18 +170,12 @@ function getSpecifierLocalIdentifier(specifier) { |
175 | 170 | */ |
176 | 171 | function setSpecifierProps(specifier, importPropDecoratorMap) { |
177 | 172 | const isMetaDecorator = !importPropDecoratorMap; |
178 | | - const importedName = get(specifier, "imported.name"); |
179 | 173 | const decoratorImportedName = get( |
180 | 174 | importPropDecoratorMap, |
181 | 175 | get(specifier, "imported.name") |
182 | 176 | ); |
183 | 177 | specifier.local = getSpecifierLocalIdentifier(specifier); |
184 | | - if (isMetaDecorator) { |
185 | | - const metaDecoratorName = META_DECORATORS[importedName]; |
186 | | - if (metaDecoratorName) { |
187 | | - specifier.imported.name = metaDecoratorName; |
188 | | - } |
189 | | - } else { |
| 178 | + if (!isMetaDecorator) { |
190 | 179 | specifier.imported.name = decoratorImportedName; |
191 | 180 | } |
192 | 181 | // Needed one more time as we changed the imported name |
@@ -232,12 +221,11 @@ function getDecoratorsToImport(instanceProps, decoratorsMap = {}) { |
232 | 221 | attribute: specs.attribute || prop.hasAttributeDecorator, |
233 | 222 | className: specs.className || prop.hasClassNameDecorator, |
234 | 223 | classNames: specs.classNames || prop.isClassNames, |
235 | | - layout: specs.layout || prop.isLayout, |
| 224 | + layout: specs.layout || prop.isLayoutDecorator, |
| 225 | + templateLayout: specs.templateLayout || prop.isTemplateLayoutDecorator, |
236 | 226 | off: specs.off || prop.hasOffDecorator, |
237 | | - readOnly: specs.readOnly || prop.hasReadOnly, |
238 | 227 | tagName: specs.tagName || prop.isTagName, |
239 | | - unobserves: specs.unobserves || prop.hasUnobservesDecorator, |
240 | | - volatile: specs.volatile || prop.hasVolatile |
| 228 | + unobserves: specs.unobserves || prop.hasUnobservesDecorator |
241 | 229 | }; |
242 | 230 | }, decoratorsMap); |
243 | 231 | } |
@@ -375,45 +363,6 @@ function getEmberObjectCallExpressions(j, root) { |
375 | 363 | ); |
376 | 364 | } |
377 | 365 |
|
378 | | -/** |
379 | | - * Extracts the layout property name |
380 | | - * |
381 | | - * @param {Object} j - jscodeshift lib reference |
382 | | - * @param {File} root |
383 | | - * @returns {String} Name of the layout property |
384 | | - */ |
385 | | -function getLayoutPropertyName(j, root) { |
386 | | - const layoutPropCollection = root.find(j.Property, { |
387 | | - key: { |
388 | | - type: "Identifier", |
389 | | - name: "layout" |
390 | | - } |
391 | | - }); |
392 | | - if (layoutPropCollection.length) { |
393 | | - const layoutProp = layoutPropCollection.get(); |
394 | | - return get(layoutProp, "value.value.name"); |
395 | | - } |
396 | | -} |
397 | | - |
398 | | -/** |
399 | | - * Update the layout import name |
400 | | - * |
401 | | - * @param {Object} j - jscodeshift lib reference |
402 | | - * @param {File} root |
403 | | - */ |
404 | | -function updateLayoutImportDeclaration(j, root, layoutName) { |
405 | | - if (!layoutName) { |
406 | | - return; |
407 | | - } |
408 | | - const layoutIdentifier = root |
409 | | - .find(j.ImportDefaultSpecifier, { local: { name: layoutName } }) |
410 | | - .find(j.Identifier); |
411 | | - |
412 | | - if (layoutIdentifier.length) { |
413 | | - layoutIdentifier.get().value.name = LAYOUT_IMPORT_SPECIFIER; |
414 | | - } |
415 | | -} |
416 | | - |
417 | 366 | /** |
418 | 367 | * Returns the variable name |
419 | 368 | * |
@@ -544,7 +493,6 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) { |
544 | 493 | } |
545 | 494 | // Parse the import statements |
546 | 495 | const importedDecoratedProps = getImportedDecoratedProps(j, root); |
547 | | - const layoutName = getLayoutPropertyName(j, root); |
548 | 496 | let transformed = false; |
549 | 497 | let decoratorsToImportMap = {}; |
550 | 498 |
|
@@ -603,7 +551,6 @@ function replaceEmberObjectExpressions(j, root, filePath, options = {}) { |
603 | 551 | key => decoratorsToImportMap[key] |
604 | 552 | ); |
605 | 553 | createDecoratorImportDeclarations(j, root, decoratorsToImport); |
606 | | - updateLayoutImportDeclaration(j, root, layoutName); |
607 | 554 | logger.info(`[${filePath}]: SUCCESS`); |
608 | 555 | } |
609 | 556 | return transformed; |
|
0 commit comments