Skip to content

Commit

Permalink
Remove --pod support from the component generator
Browse files Browse the repository at this point in the history
The pod layout is deprecated for components.
  • Loading branch information
Windvis committed Oct 6, 2024
1 parent bcb2d29 commit 36242f3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 313 deletions.
28 changes: 2 additions & 26 deletions blueprints/component-class/index.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';`;
Expand Down
40 changes: 2 additions & 38 deletions blueprints/component/index.js
Original file line number Diff line number Diff line change
@@ -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');

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

0 comments on commit 36242f3

Please sign in to comment.