Skip to content

Commit

Permalink
Remove --pod support from the component blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
Windvis committed Oct 6, 2024
1 parent c056f7c commit 0d8919f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 192 deletions.
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
154 changes: 0 additions & 154 deletions node-tests/blueprints/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 0d8919f

Please sign in to comment.