Skip to content

Commit 36242f3

Browse files
committed
Remove --pod support from the component generator
The pod layout is deprecated for components.
1 parent bcb2d29 commit 36242f3

File tree

4 files changed

+4
-313
lines changed

4 files changed

+4
-313
lines changed

blueprints/component-class/index.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
'use strict';
22

3-
const path = require('path');
43
const SilentError = require('silent-error');
54
const stringUtil = require('ember-cli-string-utils');
65
const getPathOption = require('ember-cli-get-component-path-option');
76
const normalizeEntityName = require('ember-cli-normalize-entity-name');
8-
const { EOL } = require('os');
97
const { has } = require('@ember/edition-utils');
108
const { generateComponentSignature } = require('../-utils');
119

@@ -92,16 +90,7 @@ module.exports = {
9290
fileMapTokens(options) {
9391
let commandOptions = this.options;
9492

95-
if (commandOptions.pod) {
96-
return {
97-
__path__() {
98-
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
99-
},
100-
__name__() {
101-
return 'component';
102-
},
103-
};
104-
} else if (commandOptions.componentStructure === 'flat') {
93+
if (commandOptions.componentStructure === 'flat') {
10594
return {
10695
__path__() {
10796
return 'components';
@@ -129,30 +118,17 @@ module.exports = {
129118
let sanitizedModuleName = options.entity.name.replace(/\//g, '-');
130119
let classifiedModuleName = stringUtil.classify(sanitizedModuleName);
131120

132-
let templatePath = '';
133121
let importComponent = '';
134122
let importTemplate = '';
135123
let defaultExport = '';
136124
let componentSignature = '';
137125

138-
// if we're in an addon, build import statement
139-
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) {
140-
if (options.pod) {
141-
templatePath = './template';
142-
}
143-
}
144-
145126
let componentClass = options.componentClass;
146127

147128
switch (componentClass) {
148129
case '@ember/component':
149130
importComponent = `import Component from '@ember/component';`;
150-
if (templatePath) {
151-
importTemplate = `import layout from '${templatePath}';${EOL}`;
152-
defaultExport = `Component.extend({${EOL} layout${EOL}});`;
153-
} else {
154-
defaultExport = `Component.extend({});`;
155-
}
131+
defaultExport = `Component.extend({});`;
156132
break;
157133
case '@glimmer/component':
158134
importComponent = `import Component from '@glimmer/component';`;

blueprints/component/index.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
'use strict';
22

33
const chalk = require('chalk');
4-
const path = require('path');
54
const SilentError = require('silent-error');
65
const stringUtil = require('ember-cli-string-utils');
7-
const pathUtil = require('ember-cli-path-utils');
86
const getPathOption = require('ember-cli-get-component-path-option');
97
const normalizeEntityName = require('ember-cli-normalize-entity-name');
10-
const { EOL } = require('os');
118
const { has } = require('@ember/edition-utils');
129
const { generateComponentSignature } = require('../-utils');
1310

@@ -137,22 +134,7 @@ module.exports = {
137134
fileMapTokens(options) {
138135
let commandOptions = this.options;
139136

140-
if (commandOptions.pod) {
141-
return {
142-
__path__() {
143-
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
144-
},
145-
__templatepath__() {
146-
return path.join(options.podPath, options.locals.path, options.dasherizedModuleName);
147-
},
148-
__templatename__() {
149-
return 'template';
150-
},
151-
};
152-
} else if (
153-
this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE &&
154-
commandOptions.componentStructure === 'flat'
155-
) {
137+
if (this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && commandOptions.componentStructure === 'flat') {
156138
return {
157139
__path__() {
158140
return 'components';
@@ -209,19 +191,6 @@ module.exports = {
209191
},
210192

211193
locals(options) {
212-
// if we're in an addon, build import statement
213-
let templatePath = '';
214-
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy)) {
215-
if (options.pod) {
216-
templatePath = './template';
217-
} else {
218-
templatePath =
219-
pathUtil.getRelativeParentPath(options.entity.name) +
220-
'templates/components/' +
221-
stringUtil.dasherize(options.entity.name);
222-
}
223-
}
224-
225194
let componentClass = this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
226195
? options.componentClass
227196
: '@ember/component';
@@ -237,12 +206,7 @@ module.exports = {
237206
switch (componentClass) {
238207
case '@ember/component':
239208
importComponent = `import Component from '@ember/component';`;
240-
if (templatePath) {
241-
importTemplate = `import layout from '${templatePath}';${EOL}`;
242-
defaultExport = `Component.extend({${EOL} layout${EOL}});`;
243-
} else {
244-
defaultExport = `Component.extend({});`;
245-
}
209+
defaultExport = `Component.extend({});`;
246210
break;
247211
case '@glimmer/component':
248212
importComponent = `import Component from '@glimmer/component';`;

node-tests/blueprints/component-class-test.js

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
44
const setupTestHooks = blueprintHelpers.setupTestHooks;
55
const emberNew = blueprintHelpers.emberNew;
66
const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
7-
const setupPodConfig = blueprintHelpers.setupPodConfig;
87
const modifyPackages = blueprintHelpers.modifyPackages;
98

109
const chai = require('ember-cli-blueprint-test-helpers/chai');
1110
const expect = chai.expect;
1211

1312
const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest');
14-
const fixture = require('../helpers/fixture');
1513

1614
const setupTestEnvironment = require('../helpers/setup-test-environment');
1715
const enableOctane = setupTestEnvironment.enableOctane;
@@ -151,99 +149,6 @@ describe('Blueprint: component-class', function () {
151149
}
152150
);
153151
});
154-
155-
describe('with podModulePrefix', function () {
156-
beforeEach(function () {
157-
setupPodConfig({ podModulePrefix: true });
158-
});
159-
160-
it('component-class foo --pod', function () {
161-
return emberGenerateDestroy(['component-class', 'foo', '--pod'], (_file) => {
162-
expect(_file('app/pods/components/foo/component.js')).to.equal(
163-
fixture('component/component.js')
164-
);
165-
});
166-
});
167-
168-
it('component-class x-foo --pod', function () {
169-
return emberGenerateDestroy(['component-class', 'x-foo', '--pod'], (_file) => {
170-
expect(_file('app/pods/components/x-foo/component.js')).to.equal(
171-
fixture('component/component-dash.js')
172-
);
173-
});
174-
});
175-
176-
it('component-class foo/x-foo --pod', function () {
177-
return emberGenerateDestroy(['component-class', 'foo/x-foo', '--pod'], (_file) => {
178-
expect(_file('app/pods/components/foo/x-foo/component.js')).to.equal(
179-
fixture('component/component-nested.js')
180-
);
181-
});
182-
});
183-
184-
it('component-class x-foo --pod --path foo', function () {
185-
return emberGenerateDestroy(
186-
['component-class', 'x-foo', '--pod', '--path', 'foo'],
187-
(_file) => {
188-
expect(_file('app/pods/foo/x-foo/component.js')).to.equal(
189-
fixture('component/component-dash.js')
190-
);
191-
}
192-
);
193-
});
194-
195-
it('component-class foo/x-foo --pod --path bar', function () {
196-
return emberGenerateDestroy(
197-
['component-class', 'foo/x-foo', '--pod', '--path', 'bar'],
198-
(_file) => {
199-
expect(_file('app/pods/bar/foo/x-foo/component.js')).to.equal(
200-
fixture('component/component-nested.js')
201-
);
202-
}
203-
);
204-
});
205-
206-
it('component-class x-foo --pod --path bar/foo', function () {
207-
return emberGenerateDestroy(
208-
['component-class', 'x-foo', '--pod', '--path', 'bar/foo'],
209-
(_file) => {
210-
expect(_file('app/pods/bar/foo/x-foo/component.js')).to.equal(
211-
fixture('component/component-dash.js')
212-
);
213-
}
214-
);
215-
});
216-
217-
it('component-class foo/x-foo --pod --path bar/baz', function () {
218-
return emberGenerateDestroy(
219-
['component-class', 'foo/x-foo', '--pod', '--path', 'bar/baz'],
220-
(_file) => {
221-
expect(_file('app/pods/bar/baz/foo/x-foo/component.js')).to.equal(
222-
fixture('component/component-nested.js')
223-
);
224-
}
225-
);
226-
});
227-
228-
it('component-class x-foo --pod -no-path', function () {
229-
return emberGenerateDestroy(['component-class', 'x-foo', '--pod', '-no-path'], (_file) => {
230-
expect(_file('app/pods/x-foo/component.js')).to.equal(
231-
fixture('component/component-dash.js')
232-
);
233-
});
234-
});
235-
236-
it('component-class foo/x-foo --pod -no-path', function () {
237-
return emberGenerateDestroy(
238-
['component-class', 'foo/x-foo', '--pod', '-no-path'],
239-
(_file) => {
240-
expect(_file('app/pods/foo/x-foo/component.js')).to.equal(
241-
fixture('component/component-nested.js')
242-
);
243-
}
244-
);
245-
});
246-
});
247152
});
248153

249154
describe('in addon - octane', function () {

0 commit comments

Comments
 (0)