Skip to content

Commit faffa24

Browse files
committed
Cleanup octane edition code
Octane has been the default for multiple major versions, so we can remove and simplify the code.
1 parent be20bd3 commit faffa24

File tree

10 files changed

+22
-208
lines changed

10 files changed

+22
-208
lines changed

blueprints/component-class/index.js

+3-42
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
'use strict';
22

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

108
const typescriptBlueprintPolyfill = require('ember-cli-typescript-blueprint-polyfill');
119

12-
const OCTANE = has('octane');
13-
14-
// TODO: this should be reading from the @ember/canary-features module
15-
// need to refactor broccoli/features.js to be able to work more similarly
16-
// to https://github.com/emberjs/data/pull/6231
17-
const EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = true;
18-
1910
// intentionally avoiding use-edition-detector
2011
module.exports = {
2112
description: 'Generates a component class.',
@@ -32,7 +23,7 @@ module.exports = {
3223
{
3324
name: 'component-class',
3425
type: ['@ember/component', '@glimmer/component', '@ember/component/template-only'],
35-
default: OCTANE ? '@glimmer/component' : '@ember/component',
26+
default: '@glimmer/component',
3627
aliases: [
3728
{ cc: '@ember/component' },
3829
{ gc: '@glimmer/component' },
@@ -50,34 +41,6 @@ module.exports = {
5041
init() {
5142
this._super && this._super.init.apply(this, arguments);
5243
typescriptBlueprintPolyfill(this);
53-
54-
let isOctane = has('octane');
55-
56-
this.availableOptions.forEach((option) => {
57-
if (option.name === 'component-class') {
58-
if (isOctane) {
59-
option.default = '@glimmer/component';
60-
} else {
61-
option.default = '@ember/component';
62-
}
63-
} else if (option.name === 'component-structure') {
64-
option.type = ['flat', 'nested'];
65-
option.default = 'flat';
66-
option.aliases = [{ fs: 'flat' }, { ns: 'nested' }];
67-
}
68-
});
69-
70-
this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = EMBER_GLIMMER_SET_COMPONENT_TEMPLATE || isOctane;
71-
},
72-
73-
install() {
74-
if (!this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE) {
75-
throw new SilentError(
76-
'Usage of `ember generate component-class` is only available on canary'
77-
);
78-
}
79-
80-
return this._super.install.apply(this, arguments);
8144
},
8245

8346
fileMapTokens(options) {
@@ -116,9 +79,7 @@ module.exports = {
11679
let defaultExport = '';
11780
let componentSignature = '';
11881

119-
let componentClass = options.componentClass;
120-
121-
switch (componentClass) {
82+
switch (options.componentClass) {
12283
case '@ember/component':
12384
importComponent = `import Component from '@ember/component';`;
12485
defaultExport = `Component.extend({});`;
@@ -141,7 +102,7 @@ module.exports = {
141102
componentSignature,
142103
defaultExport,
143104
path: getPathOption(options),
144-
componentClass,
105+
componentClass: options.componentClass,
145106
};
146107
},
147108
};

blueprints/component/index.js

+7-49
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
'use strict';
22

33
const chalk = require('chalk');
4-
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 { has } = require('@ember/edition-utils');
97
const { generateComponentSignature } = require('../-utils');
108

119
const typescriptBlueprintPolyfill = require('ember-cli-typescript-blueprint-polyfill');
1210

13-
const OCTANE = has('octane');
14-
15-
// TODO: this should be reading from the @ember/canary-features module
16-
// need to refactor broccoli/features.js to be able to work more similarly
17-
// to https://github.com/emberjs/data/pull/6231
18-
const EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = true;
19-
2011
// intentionally avoiding use-edition-detector
2112
module.exports = {
2213
description: 'Generates a component.',
@@ -33,14 +24,14 @@ module.exports = {
3324
{
3425
name: 'component-class',
3526
type: ['@ember/component', '@glimmer/component', '@ember/component/template-only', ''],
36-
default: OCTANE ? '--no-component-class' : '@ember/component',
27+
default: '--no-component-class',
3728
aliases: [
3829
{ cc: '@ember/component' },
3930
{ gc: '@glimmer/component' },
4031
{ tc: '@ember/component/template-only' },
4132
{ nc: '' },
4233
{ 'no-component-class': '' },
43-
{ 'with-component-class': OCTANE ? '@glimmer/component' : '@ember/component' },
34+
{ 'with-component-class': '@glimmer/component' },
4435
],
4536
},
4637
{
@@ -55,26 +46,8 @@ module.exports = {
5546
this._super && this._super.init.apply(this, arguments);
5647
typescriptBlueprintPolyfill(this);
5748

58-
let isOctane = has('octane');
59-
60-
this.availableOptions.forEach((option) => {
61-
if (option.name === 'component-class') {
62-
if (isOctane) {
63-
option.default = '--no-component-class';
64-
} else {
65-
option.default = '@ember/component';
66-
}
67-
} else if (option.name === 'component-structure') {
68-
option.type = ['flat', 'nested'];
69-
option.default = 'flat';
70-
option.aliases = [{ fs: 'flat' }, { ns: 'nested' }];
71-
}
72-
});
73-
7449
this.skippedJsFiles = new Set();
7550
this.savedLocals = {};
76-
77-
this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = EMBER_GLIMMER_SET_COMPONENT_TEMPLATE || isOctane;
7851
},
7952

8053
install(options) {
@@ -85,14 +58,6 @@ module.exports = {
8558
options.componentClass = '';
8659
}
8760

88-
if (!this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE) {
89-
if (options.componentClass !== '@ember/component') {
90-
throw new SilentError(
91-
'Usage of --component-class argument to `ember generate component` is only available on canary'
92-
);
93-
}
94-
}
95-
9661
return this._super.install.apply(this, arguments);
9762
},
9863

@@ -101,7 +66,7 @@ module.exports = {
10166
// matter what it is set to. All we want is to delete the optional JS
10267
// file if the user had created one (when using this generator, created
10368
// manually, added later with component-class generator...).
104-
options.componentClass = '@ember/component';
69+
options.componentClass = '@glimmer/component';
10570

10671
return this._super.uninstall.apply(this, arguments);
10772
},
@@ -127,7 +92,7 @@ module.exports = {
12792
fileMapTokens(options) {
12893
let commandOptions = this.options;
12994

130-
if (this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && commandOptions.componentStructure === 'flat') {
95+
if (commandOptions.componentStructure === 'flat') {
13196
return {
13297
__path__() {
13398
return 'components';
@@ -139,10 +104,7 @@ module.exports = {
139104
return options.dasherizedModuleName;
140105
},
141106
};
142-
} else if (
143-
this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE &&
144-
commandOptions.componentStructure === 'nested'
145-
) {
107+
} else if (commandOptions.componentStructure === 'nested') {
146108
return {
147109
__path__() {
148110
return `components/${options.dasherizedModuleName}`;
@@ -163,7 +125,7 @@ module.exports = {
163125
files() {
164126
let files = this._super.files.apply(this, arguments);
165127

166-
if (this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE && this.options.componentClass === '') {
128+
if (this.options.componentClass === '') {
167129
files = files.filter((file) => {
168130
if (file.endsWith('.js') || file.endsWith('.ts')) {
169131
this.skippedJsFiles.add(file);
@@ -184,10 +146,6 @@ module.exports = {
184146
},
185147

186148
locals(options) {
187-
let componentClass = this.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE
188-
? options.componentClass
189-
: '@ember/component';
190-
191149
let sanitizedModuleName = options.entity.name.replace(/\//g, '-');
192150
let classifiedModuleName = stringUtil.classify(sanitizedModuleName);
193151

@@ -196,7 +154,7 @@ module.exports = {
196154
let defaultExport = '';
197155
let componentSignature = '';
198156

199-
switch (componentClass) {
157+
switch (options.componentClass) {
200158
case '@ember/component':
201159
importComponent = `import Component from '@ember/component';`;
202160
defaultExport = `Component.extend({});`;

lib/index.js

-39
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const MergeTrees = require('broccoli-merge-trees');
44
const Funnel = require('broccoli-funnel');
55
const path = require('path');
66
const Overrides = require('./overrides');
7-
const SilentError = require('silent-error');
87
const SupportedBrowsers = require('./browsers');
98

109
const paths = {};
@@ -82,44 +81,6 @@ module.exports = {
8281
if (overrides.hasBuildTimeWarning) {
8382
this.ui.writeWarnLine('[DEPRECATION] ' + overrides.buildTimeWarning);
8483
}
85-
86-
const { has } = require('@ember/edition-utils');
87-
88-
let optionalFeatures = this.project.addons.find((a) => a.name === '@ember/optional-features');
89-
let optionalFeaturesMissing = optionalFeatures === undefined;
90-
91-
if (has('octane')) {
92-
let message = [];
93-
94-
if (optionalFeaturesMissing) {
95-
message.push(
96-
`* the @ember/optional-features addon is missing, run \`ember install @ember/optional-features\` to install it`
97-
);
98-
}
99-
100-
if (message.length > 0) {
101-
message.unshift(
102-
`You have configured your application to indicate that it is using the 'octane' edition (via \`setEdition('octane')\`), but the appropriate Octane features were not enabled:\n`
103-
);
104-
105-
throw new SilentError(message.join('\n\t'));
106-
}
107-
} else {
108-
throw new SilentError(
109-
'The Ember Classic edition has been removed. Specifying "classic" in your package.json, or not specifying a value at all, is no longer supported. You must explicitly set the "ember.edition" property to "octane". You can also run `npx @ember/octanify` to do this. \n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_editions-classic'
110-
);
111-
}
112-
113-
if (
114-
!optionalFeaturesMissing &&
115-
optionalFeatures.isFeatureEnabled('jquery-integration') &&
116-
typeof optionalFeatures.isFeatureExplicitlySet === 'function' &&
117-
optionalFeatures.isFeatureExplicitlySet('jquery-integration')
118-
) {
119-
throw new SilentError(
120-
'Setting the `jquery-integration` optional feature flag to `true` was deprecated in Ember 3.x and removed in Ember 4.0.0. You must add the `@ember/optional-features` addon and set this feature to `false`.\n\nFor more information, see the deprecation guide: https://deprecations.emberjs.com/v3.x/#toc_optional-feature-jquery-integration'
121-
);
122-
}
12384
},
12485

12586
treeForVendor(tree) {

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

-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ 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 setupTestEnvironment = require('../helpers/setup-test-environment');
87
const chai = require('ember-cli-blueprint-test-helpers/chai');
98
const expect = chai.expect;
109

11-
const enableOctane = setupTestEnvironment.enableOctane;
1210
describe('Blueprint: component-class-addon', function () {
13-
enableOctane();
1411
setupTestHooks(this);
1512

1613
describe('in addon', function () {

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

+3-13
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ const expect = chai.expect;
1111

1212
const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest');
1313

14-
const setupTestEnvironment = require('../helpers/setup-test-environment');
15-
const enableOctane = setupTestEnvironment.enableOctane;
16-
1714
const glimmerComponentContents = `import Component from '@glimmer/component';
1815
1916
export default class Foo extends Component {}
@@ -32,9 +29,7 @@ export default templateOnly();
3229
describe('Blueprint: component-class', function () {
3330
setupTestHooks(this);
3431

35-
describe('in app - octane', function () {
36-
enableOctane();
37-
32+
describe('in app', function () {
3833
beforeEach(function () {
3934
return emberNew()
4035
.then(() =>
@@ -52,7 +47,6 @@ describe('Blueprint: component-class', function () {
5247
});
5348
});
5449

55-
// Octane default
5650
it('component-class foo --component-structure=flat --component-class=@glimmer/component', function () {
5751
return emberGenerateDestroy(
5852
[
@@ -151,9 +145,7 @@ describe('Blueprint: component-class', function () {
151145
});
152146
});
153147

154-
describe('in addon - octane', function () {
155-
enableOctane();
156-
148+
describe('in addon', function () {
157149
beforeEach(function () {
158150
return emberNew({ target: 'addon' })
159151
.then(() =>
@@ -215,9 +207,7 @@ describe('Blueprint: component-class', function () {
215207
});
216208
});
217209

218-
describe('in in-repo-addon - octane', function () {
219-
enableOctane();
220-
210+
describe('in in-repo-addon', function () {
221211
beforeEach(function () {
222212
return emberNew({ target: 'in-repo-addon' })
223213
.then(() =>

node-tests/blueprints/component-test.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ const expect = chai.expect;
1212
const generateFakePackageManifest = require('../helpers/generate-fake-package-manifest');
1313
const fixture = require('../helpers/fixture');
1414

15-
const setupTestEnvironment = require('../helpers/setup-test-environment');
16-
const enableOctane = setupTestEnvironment.enableOctane;
17-
1815
const glimmerComponentContents = `import Component from '@glimmer/component';
1916
2017
export default class Foo extends Component {}
@@ -33,9 +30,7 @@ export default templateOnly();
3330
describe('Blueprint: component', function () {
3431
setupTestHooks(this);
3532

36-
describe('in app - octane', function () {
37-
enableOctane();
38-
33+
describe('in app', function () {
3934
beforeEach(function () {
4035
return emberNew()
4136
.then(() =>
@@ -63,7 +58,6 @@ describe('Blueprint: component', function () {
6358
});
6459
});
6560

66-
// Octane default
6761
it('component foo --component-structure=flat --component-class=@glimmer/component', function () {
6862
return emberGenerateDestroy(
6963
[
@@ -278,9 +272,7 @@ describe('Blueprint: component', function () {
278272
});
279273
});
280274

281-
describe('in addon - octane', function () {
282-
enableOctane();
283-
275+
describe('in addon', function () {
284276
beforeEach(function () {
285277
return emberNew({ target: 'addon' })
286278
.then(() =>
@@ -392,9 +384,7 @@ describe('Blueprint: component', function () {
392384
});
393385
});
394386

395-
describe('in in-repo-addon - octane', function () {
396-
enableOctane();
397-
387+
describe('in in-repo-addon', function () {
398388
beforeEach(function () {
399389
return emberNew({ target: 'in-repo-addon' })
400390
.then(() =>

0 commit comments

Comments
 (0)