From bcb2d293644606e9089accffcd545d2235bb15ab Mon Sep 17 00:00:00 2001 From: Sam Van Campenhout Date: Sun, 6 Oct 2024 13:42:27 +0200 Subject: [PATCH 1/2] Remove the `classic` component-structure option The classic file structure is deprecated. --- blueprints/component-class/index.js | 29 +++--------- blueprints/component/index.js | 39 +++------------- node-tests/blueprints/component-class-test.js | 26 ----------- node-tests/blueprints/component-test.js | 46 ------------------- 4 files changed, 13 insertions(+), 127 deletions(-) diff --git a/blueprints/component-class/index.js b/blueprints/component-class/index.js index e742471cb57..fe37d0f34ea 100644 --- a/blueprints/component-class/index.js +++ b/blueprints/component-class/index.js @@ -3,7 +3,6 @@ const path = require('path'); const SilentError = require('silent-error'); const stringUtil = require('ember-cli-string-utils'); -const pathUtil = require('ember-cli-path-utils'); const getPathOption = require('ember-cli-get-component-path-option'); const normalizeEntityName = require('ember-cli-normalize-entity-name'); const { EOL } = require('os'); @@ -44,9 +43,9 @@ module.exports = { }, { name: 'component-structure', - type: OCTANE ? ['flat', 'nested', 'classic'] : ['classic'], - default: OCTANE ? 'flat' : 'classic', - aliases: OCTANE ? [{ fs: 'flat' }, { ns: 'nested' }, { cs: 'classic' }] : [{ cs: 'classic' }], + type: ['flat', 'nested'], + default: 'flat', + aliases: [{ fs: 'flat' }, { ns: 'nested' }], }, ], @@ -71,15 +70,9 @@ module.exports = { option.default = '@ember/component'; } } else if (option.name === 'component-structure') { - if (isOctane) { - option.type = ['flat', 'nested', 'classic']; - option.default = 'flat'; - option.aliases = [{ fs: 'flat' }, { ns: 'nested' }, { cs: 'classic' }]; - } else { - option.type = ['classic']; - option.default = 'classic'; - option.aliases = [{ cs: 'classic' }]; - } + option.type = ['flat', 'nested']; + option.default = 'flat'; + option.aliases = [{ fs: 'flat' }, { ns: 'nested' }]; } }); @@ -108,10 +101,7 @@ module.exports = { return 'component'; }, }; - } else if ( - commandOptions.componentStructure === 'classic' || - commandOptions.componentStructure === 'flat' - ) { + } else if (commandOptions.componentStructure === 'flat') { return { __path__() { return 'components'; @@ -149,11 +139,6 @@ module.exports = { if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) { if (options.pod) { templatePath = './template'; - } else { - templatePath = - pathUtil.getRelativeParentPath(options.entity.name) + - 'templates/components/' + - stringUtil.dasherize(options.entity.name); } } diff --git a/blueprints/component/index.js b/blueprints/component/index.js index fffa4961bea..4110185f17e 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -48,9 +48,9 @@ module.exports = { }, { name: 'component-structure', - type: OCTANE ? ['flat', 'nested', 'classic'] : ['classic'], - default: OCTANE ? 'flat' : 'classic', - aliases: OCTANE ? [{ fs: 'flat' }, { ns: 'nested' }, { cs: 'classic' }] : [{ cs: 'classic' }], + type: ['flat', 'nested'], + default: 'flat', + aliases: [{ fs: 'flat' }, { ns: 'nested' }], }, ], @@ -75,15 +75,9 @@ module.exports = { option.default = '@ember/component'; } } else if (option.name === 'component-structure') { - if (isOctane) { - option.type = ['flat', 'nested', 'classic']; - option.default = 'flat'; - option.aliases = [{ fs: 'flat' }, { ns: 'nested' }, { cs: 'classic' }]; - } else { - option.type = ['classic']; - option.default = 'classic'; - option.aliases = [{ cs: 'classic' }]; - } + option.type = ['flat', 'nested']; + option.default = 'flat'; + option.aliases = [{ fs: 'flat' }, { ns: 'nested' }]; } }); @@ -107,12 +101,6 @@ module.exports = { 'Usage of --component-class argument to `ember generate component` is only available on canary' ); } - - if (options.componentStructure !== 'classic') { - throw new SilentError( - 'Usage of --component-structure argument to `ember generate component` is only available on canary' - ); - } } return this._super.install.apply(this, arguments); @@ -161,21 +149,6 @@ module.exports = { return 'template'; }, }; - } else if ( - !this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE || - commandOptions.componentStructure === 'classic' - ) { - return { - __path__() { - return 'components'; - }, - __templatepath__() { - return 'templates/components'; - }, - __templatename__() { - return options.dasherizedModuleName; - }, - }; } else if ( this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && commandOptions.componentStructure === 'flat' diff --git a/node-tests/blueprints/component-class-test.js b/node-tests/blueprints/component-class-test.js index be866b0a8a2..df2219f8345 100644 --- a/node-tests/blueprints/component-class-test.js +++ b/node-tests/blueprints/component-class-test.js @@ -54,23 +54,6 @@ describe('Blueprint: component-class', function () { }); }); - // classic default - it('component-class foo --component-structure=classic --component-class=@ember/component', function () { - return emberGenerateDestroy( - [ - 'component-class', - 'foo', - '--component-structure', - 'classic', - '--component-class', - '@ember/component', - ], - (_file) => { - expect(_file('app/components/foo.js')).to.equal(emberComponentContents); - } - ); - }); - // Octane default it('component-class foo --component-structure=flat --component-class=@glimmer/component', function () { return emberGenerateDestroy( @@ -106,15 +89,6 @@ describe('Blueprint: component-class', function () { ); }); - it('component-class foo --component-structure=classic', function () { - return emberGenerateDestroy( - ['component-class', '--component-structure', 'classic', 'foo'], - (_file) => { - expect(_file('app/components/foo.js')).to.equal(glimmerComponentContents); - } - ); - }); - it('component-class foo --component-class=@ember/component', function () { return emberGenerateDestroy( ['component-class', '--component-class', '@ember/component', 'foo'], diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index b8338928887..ec05f865c28 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -64,34 +64,6 @@ describe('Blueprint: component', function () { }); }); - // classic default - it('component foo --component-structure=classic --component-class=@ember/component', function () { - return emberGenerateDestroy( - [ - 'component', - 'foo', - '--component-structure', - 'classic', - '--component-class', - '@ember/component', - ], - (_file) => { - expect(_file('app/components/foo.js')).to.equal(emberComponentContents); - - expect(_file('app/templates/components/foo.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/components/foo-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo', - componentInvocation: 'Foo', - }, - }) - ); - } - ); - }); - // Octane default it('component foo --component-structure=flat --component-class=@glimmer/component', function () { return emberGenerateDestroy( @@ -156,24 +128,6 @@ describe('Blueprint: component', function () { ); }); - it('component foo --component-structure=classic', function () { - return emberGenerateDestroy( - ['component', '--component-structure', 'classic', 'foo'], - (_file) => { - expect(_file('app/templates/components/foo.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/components/foo-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo', - componentInvocation: 'Foo', - }, - }) - ); - } - ); - }); - it('component foo --component-class=@ember/component', function () { return emberGenerateDestroy( ['component', '--component-class', '@ember/component', 'foo'], From 36242f3713f3bacbcdf749b21d39a0e06029e0f2 Mon Sep 17 00:00:00 2001 From: Sam Van Campenhout Date: Sun, 6 Oct 2024 13:53:06 +0200 Subject: [PATCH 2/2] Remove `--pod` support from the component generator The pod layout is deprecated for components. --- blueprints/component-class/index.js | 28 +--- blueprints/component/index.js | 40 +---- node-tests/blueprints/component-class-test.js | 95 ----------- node-tests/blueprints/component-test.js | 154 ------------------ 4 files changed, 4 insertions(+), 313 deletions(-) diff --git a/blueprints/component-class/index.js b/blueprints/component-class/index.js index fe37d0f34ea..d1245ec70e3 100644 --- a/blueprints/component-class/index.js +++ b/blueprints/component-class/index.js @@ -1,11 +1,9 @@ 'use strict'; -const path = require('path'); const SilentError = require('silent-error'); const stringUtil = require('ember-cli-string-utils'); const getPathOption = require('ember-cli-get-component-path-option'); const normalizeEntityName = require('ember-cli-normalize-entity-name'); -const { EOL } = require('os'); const { has } = require('@ember/edition-utils'); const { generateComponentSignature } = require('../-utils'); @@ -92,16 +90,7 @@ module.exports = { fileMapTokens(options) { let commandOptions = this.options; - if (commandOptions.pod) { - return { - __path__() { - return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); - }, - __name__() { - return 'component'; - }, - }; - } else if (commandOptions.componentStructure === 'flat') { + if (commandOptions.componentStructure === 'flat') { return { __path__() { return 'components'; @@ -129,30 +118,17 @@ module.exports = { let sanitizedModuleName = options.entity.name.replace(/\//g, '-'); let classifiedModuleName = stringUtil.classify(sanitizedModuleName); - let templatePath = ''; let importComponent = ''; let importTemplate = ''; let defaultExport = ''; let componentSignature = ''; - // if we're in an addon, build import statement - if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) { - if (options.pod) { - templatePath = './template'; - } - } - let componentClass = options.componentClass; switch (componentClass) { case '@ember/component': importComponent = `import Component from '@ember/component';`; - if (templatePath) { - importTemplate = `import layout from '${templatePath}';${EOL}`; - defaultExport = `Component.extend({${EOL} layout${EOL}});`; - } else { - defaultExport = `Component.extend({});`; - } + defaultExport = `Component.extend({});`; break; case '@glimmer/component': importComponent = `import Component from '@glimmer/component';`; diff --git a/blueprints/component/index.js b/blueprints/component/index.js index 4110185f17e..66bd7d76cbd 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -1,13 +1,10 @@ 'use strict'; const chalk = require('chalk'); -const path = require('path'); const SilentError = require('silent-error'); const stringUtil = require('ember-cli-string-utils'); -const pathUtil = require('ember-cli-path-utils'); const getPathOption = require('ember-cli-get-component-path-option'); const normalizeEntityName = require('ember-cli-normalize-entity-name'); -const { EOL } = require('os'); const { has } = require('@ember/edition-utils'); const { generateComponentSignature } = require('../-utils'); @@ -137,22 +134,7 @@ module.exports = { fileMapTokens(options) { let commandOptions = this.options; - if (commandOptions.pod) { - return { - __path__() { - return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); - }, - __templatepath__() { - return path.join(options.podPath, options.locals.path, options.dasherizedModuleName); - }, - __templatename__() { - return 'template'; - }, - }; - } else if ( - this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && - commandOptions.componentStructure === 'flat' - ) { + if (this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && commandOptions.componentStructure === 'flat') { return { __path__() { return 'components'; @@ -209,19 +191,6 @@ module.exports = { }, locals(options) { - // if we're in an addon, build import statement - let templatePath = ''; - if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) { - if (options.pod) { - templatePath = './template'; - } else { - templatePath = - pathUtil.getRelativeParentPath(options.entity.name) + - 'templates/components/' + - stringUtil.dasherize(options.entity.name); - } - } - let componentClass = this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE ? options.componentClass : '@ember/component'; @@ -237,12 +206,7 @@ module.exports = { switch (componentClass) { case '@ember/component': importComponent = `import Component from '@ember/component';`; - if (templatePath) { - importTemplate = `import layout from '${templatePath}';${EOL}`; - defaultExport = `Component.extend({${EOL} layout${EOL}});`; - } else { - defaultExport = `Component.extend({});`; - } + defaultExport = `Component.extend({});`; break; case '@glimmer/component': importComponent = `import Component from '@glimmer/component';`; diff --git a/node-tests/blueprints/component-class-test.js b/node-tests/blueprints/component-class-test.js index df2219f8345..f91e49e302c 100644 --- a/node-tests/blueprints/component-class-test.js +++ b/node-tests/blueprints/component-class-test.js @@ -4,14 +4,12 @@ const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers'); const setupTestHooks = blueprintHelpers.setupTestHooks; const emberNew = blueprintHelpers.emberNew; const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; -const setupPodConfig = blueprintHelpers.setupPodConfig; const modifyPackages = blueprintHelpers.modifyPackages; const chai = require('ember-cli-blueprint-test-helpers/chai'); const expect = chai.expect; const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest'); -const fixture = require('../helpers/fixture'); const setupTestEnvironment = require('../helpers/setup-test-environment'); const enableOctane = setupTestEnvironment.enableOctane; @@ -151,99 +149,6 @@ describe('Blueprint: component-class', function () { } ); }); - - describe('with podModulePrefix', function () { - beforeEach(function () { - setupPodConfig({ podModulePrefix: true }); - }); - - it('component-class foo --pod', function () { - return emberGenerateDestroy(['component-class', 'foo', '--pod'], (_file) => { - expect(_file('app/pods/components/foo/component.js')).to.equal( - fixture('component/component.js') - ); - }); - }); - - it('component-class x-foo --pod', function () { - return emberGenerateDestroy(['component-class', 'x-foo', '--pod'], (_file) => { - expect(_file('app/pods/components/x-foo/component.js')).to.equal( - fixture('component/component-dash.js') - ); - }); - }); - - it('component-class foo/x-foo --pod', function () { - return emberGenerateDestroy(['component-class', 'foo/x-foo', '--pod'], (_file) => { - expect(_file('app/pods/components/foo/x-foo/component.js')).to.equal( - fixture('component/component-nested.js') - ); - }); - }); - - it('component-class x-foo --pod --path foo', function () { - return emberGenerateDestroy( - ['component-class', 'x-foo', '--pod', '--path', 'foo'], - (_file) => { - expect(_file('app/pods/foo/x-foo/component.js')).to.equal( - fixture('component/component-dash.js') - ); - } - ); - }); - - it('component-class foo/x-foo --pod --path bar', function () { - return emberGenerateDestroy( - ['component-class', 'foo/x-foo', '--pod', '--path', 'bar'], - (_file) => { - expect(_file('app/pods/bar/foo/x-foo/component.js')).to.equal( - fixture('component/component-nested.js') - ); - } - ); - }); - - it('component-class x-foo --pod --path bar/foo', function () { - return emberGenerateDestroy( - ['component-class', 'x-foo', '--pod', '--path', 'bar/foo'], - (_file) => { - expect(_file('app/pods/bar/foo/x-foo/component.js')).to.equal( - fixture('component/component-dash.js') - ); - } - ); - }); - - it('component-class foo/x-foo --pod --path bar/baz', function () { - return emberGenerateDestroy( - ['component-class', 'foo/x-foo', '--pod', '--path', 'bar/baz'], - (_file) => { - expect(_file('app/pods/bar/baz/foo/x-foo/component.js')).to.equal( - fixture('component/component-nested.js') - ); - } - ); - }); - - it('component-class x-foo --pod -no-path', function () { - return emberGenerateDestroy(['component-class', 'x-foo', '--pod', '-no-path'], (_file) => { - expect(_file('app/pods/x-foo/component.js')).to.equal( - fixture('component/component-dash.js') - ); - }); - }); - - it('component-class foo/x-foo --pod -no-path', function () { - return emberGenerateDestroy( - ['component-class', 'foo/x-foo', '--pod', '-no-path'], - (_file) => { - expect(_file('app/pods/foo/x-foo/component.js')).to.equal( - fixture('component/component-nested.js') - ); - } - ); - }); - }); }); describe('in addon - octane', function () { diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index ec05f865c28..d1824ffd727 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -4,7 +4,6 @@ const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers'); const setupTestHooks = blueprintHelpers.setupTestHooks; const emberNew = blueprintHelpers.emberNew; const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; -const setupPodConfig = blueprintHelpers.setupPodConfig; const modifyPackages = blueprintHelpers.modifyPackages; const chai = require('ember-cli-blueprint-test-helpers/chai'); @@ -277,159 +276,6 @@ describe('Blueprint: component', function () { } ); }); - - describe('with podModulePrefix', function () { - beforeEach(function () { - setupPodConfig({ podModulePrefix: true }); - }); - - it('component foo --pod', function () { - return emberGenerateDestroy(['component', 'foo', '--pod'], (_file) => { - expect(_file('app/pods/components/foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/components/foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo', - componentInvocation: 'Foo', - }, - }) - ); - }); - }); - - it('component x-foo --pod', function () { - return emberGenerateDestroy(['component', 'x-foo', '--pod'], (_file) => { - expect(_file('app/pods/components/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/components/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'x-foo', - componentInvocation: 'XFoo', - }, - }) - ); - }); - }); - - it('component foo/x-foo --pod', function () { - return emberGenerateDestroy(['component', 'foo/x-foo', '--pod'], (_file) => { - expect(_file('app/pods/components/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/components/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo/x-foo', - componentInvocation: 'Foo::XFoo', - }, - }) - ); - }); - }); - - it('component x-foo --pod --path foo', function () { - return emberGenerateDestroy(['component', 'x-foo', '--pod', '--path', 'foo'], (_file) => { - expect(_file('app/pods/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'x-foo', - componentInvocation: 'XFoo', - path: 'foo/', - }, - }) - ); - }); - }); - - it('component foo/x-foo --pod --path bar', function () { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '--path', 'bar'], - (_file) => { - expect(_file('app/pods/bar/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/bar/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo/x-foo', - componentInvocation: 'Foo::XFoo', - path: 'bar/', - }, - }) - ); - } - ); - }); - - it('component x-foo --pod --path bar/foo', function () { - return emberGenerateDestroy( - ['component', 'x-foo', '--pod', '--path', 'bar/foo'], - (_file) => { - expect(_file('app/pods/bar/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - expect(_file('tests/integration/pods/bar/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'x-foo', - componentInvocation: 'XFoo', - path: 'bar/foo/', - }, - }) - ); - } - ); - }); - - it('component foo/x-foo --pod --path bar/baz', function () { - return emberGenerateDestroy( - ['component', 'foo/x-foo', '--pod', '--path', 'bar/baz'], - (_file) => { - expect(_file('app/pods/bar/baz/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/bar/baz/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo/x-foo', - componentInvocation: 'Foo::XFoo', - path: 'bar/baz/', - }, - }) - ); - } - ); - }); - - it('component x-foo --pod -no-path', function () { - return emberGenerateDestroy(['component', 'x-foo', '--pod', '-no-path'], (_file) => { - expect(_file('app/pods/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'x-foo', - componentInvocation: 'XFoo', - }, - }) - ); - }); - }); - - it('component foo/x-foo --pod -no-path', function () { - return emberGenerateDestroy(['component', 'foo/x-foo', '--pod', '-no-path'], (_file) => { - expect(_file('app/pods/foo/x-foo/template.hbs')).to.equal('{{yield}}'); - - expect(_file('tests/integration/pods/foo/x-foo/component-test.js')).to.equal( - fixture('component-test/default-template.js', { - replace: { - component: 'foo/x-foo', - componentInvocation: 'Foo::XFoo', - }, - }) - ); - }); - }); - }); }); describe('in addon - octane', function () {