Skip to content

Commit

Permalink
Remove the classic component-structure option
Browse files Browse the repository at this point in the history
The classic file structure is deprecated.
  • Loading branch information
Windvis committed Oct 6, 2024
1 parent 0f9b3fc commit bcb2d29
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 127 deletions.
29 changes: 7 additions & 22 deletions blueprints/component-class/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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' }],
},
],

Expand All @@ -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' }];
}
});

Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}
}

Expand Down
39 changes: 6 additions & 33 deletions blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }],
},
],

Expand All @@ -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' }];
}
});

Expand All @@ -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);
Expand Down Expand Up @@ -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'
Expand Down
26 changes: 0 additions & 26 deletions node-tests/blueprints/component-class-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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'],
Expand Down
46 changes: 0 additions & 46 deletions node-tests/blueprints/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit bcb2d29

Please sign in to comment.