Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(embroider-3): checks for all possible decorators #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
cache: yarn
- name: Install Dependencies
run: yarn install --no-lockfile
Expand All @@ -57,21 +57,16 @@ jobs:
fail-fast: false
matrix:
try-scenario:
- ember-lts-3.28
- ember-4.0
- ember-lts-4.4
- ember-release
- ember-beta
- ember-canary
# - embroider-safe
# - embroider-optimized
- ember-4.8
- embroider-safe
- embroider-optimized

steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 16.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
10 changes: 9 additions & 1 deletion addon/-private/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { isDescriptor } from '../utils/utils';
const { keys } = Object;
const OPTION_KEYS = '__option_keys__';

const POSSIBLE_DECORATORS = ['AliasDecoratorImpl', 'ComputedDecoratorImpl'];

const OptionsObject = EmberObject.extend({
toObject() {
return this[OPTION_KEYS].reduce((obj, key) => {
Expand All @@ -17,9 +19,15 @@ export default class Options {
constructor({ model, attribute, options = {} }) {
const optionKeys = keys(options);
const createParams = { [OPTION_KEYS]: optionKeys, model, attribute };
const someOptionsAreCPs = optionKeys.some((key) => {
return (
isDescriptor(options[key]) ||
POSSIBLE_DECORATORS.includes(options[key]?.constructor?.name)
);
});

// If any of the options is a CP, we need to create a custom class for it
if (optionKeys.some((key) => isDescriptor(options[key]))) {
if (someOptionsAreCPs) {
return OptionsObject.extend(options).create(createParams);
}

Expand Down
55 changes: 3 additions & 52 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,17 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.28',
name: 'ember-4.8',
npm: {
devDependencies: {
'ember-source': '~3.28.0',
'ember-data': '~3.28.0',
},
},
},
{
name: 'ember-4.0',
npm: {
devDependencies: {
'ember-source': '~4.0.0',
'ember-data': '~4.0.0',
},
},
},
{
name: 'ember-lts-4.4',
npm: {
devDependencies: {
'ember-source': '~4.4.0',
'ember-data': '~4.4.0',
},
},
},
{
name: 'ember-release',
npm: {
devDependencies: {
'@ember/string': '3.0.1',
'ember-source': await getChannelURL('release'),
'ember-data': 'latest',
},
},
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'@ember/string': '3.0.1',
'ember-source': await getChannelURL('beta'),
'ember-data': 'beta',
},
},
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'@ember/string': '3.0.1',
'ember-source': await getChannelURL('canary'),
'ember-data': 'canary',
'ember-source': '~4.8.0',
'ember-data': '~4.8.0',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"webpack": "^5.74.0"
},
"engines": {
"node": "14.* || 16.* || >= 18"
"node": "16.* || >= 18"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
Loading