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

breaking: upgrades to Ember 5.3 / drops Ember 4.4 #735

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .ember-cli
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"disableAnalytics": false,

/**
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript
rather than JavaScript by default, when a TypeScript version of a given blueprint is available.
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript
rather than JavaScript by default, when a TypeScript version of a given blueprint is available.
*/
"isTypeScriptProject": false
}
12 changes: 0 additions & 12 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# unconventional js
/blueprints/*/files/
/blueprints/**/*files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/node_modules/

# misc
/coverage/
!.*
.*/
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
15 changes: 9 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

module.exports = {
root: true,
parser: 'babel-eslint',
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true,
requireConfigFile: false,
babelOptions: {
plugins: [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
],
},
},
plugins: ['ember'],
Expand All @@ -30,6 +33,7 @@ module.exports = {
files: [
'./.eslintrc.js',
'./.prettierrc.js',
'./.stylelintrc.js',
'./.template-lintrc.js',
'./ember-cli-build.js',
'./index.js',
Expand All @@ -45,8 +49,7 @@ module.exports = {
browser: false,
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
extends: ['plugin:n/recommended'],
},
{
// test files
Expand Down
15 changes: 7 additions & 8 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
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
cache: yarn
- name: Install Dependencies
run: yarn install --no-lockfile
Expand All @@ -57,21 +57,20 @@ jobs:
fail-fast: false
matrix:
try-scenario:
- ember-lts-3.28
- ember-4.0
- ember-lts-4.4
- ember-lts-4.8
- ember-lts-4.12
- ember-release
- ember-beta
- ember-canary
# - embroider-safe
# - embroider-optimized
- 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
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/
/declarations/

# dependencies
/bower_components/
/node_modules/

# misc
/.sass-cache
/.env*
/.pnp*
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log
**/.DS_Store

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
Expand Down
9 changes: 2 additions & 7 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
/dist/
/tmp/

# dependencies
/bower_components/

# misc
/.bowerrc
/.editorconfig
/.ember-cli
/.env*
Expand All @@ -18,11 +14,11 @@
/.gitignore
/.prettierignore
/.prettierrc.js
/.stylelintignore
/.stylelintrc.js
/.template-lintrc.js
/.travis.yml
/.watchmanconfig
/bower.json
/config/ember-try.js
/CONTRIBUTING.md
/ember-cli-build.js
/testem.js
Expand All @@ -33,7 +29,6 @@

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
Expand Down
14 changes: 1 addition & 13 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache
.lint-todo/
.*/

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try
9 changes: 8 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
'use strict';

module.exports = {
singleQuote: true,
overrides: [
{
files: '*.{js,ts}',
options: {
singleQuote: true,
},
},
],
};
8 changes: 8 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# unconventional files
/blueprints/*/files/

# compiled output
/dist/

# addons
/.node_modules.ember-try/
5 changes: 5 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'],
};
2 changes: 1 addition & 1 deletion .watchmanconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
"ignore_dirs": ["dist"]
}
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

An EmberJS validation framework that is completely and utterly computed property based.

## Features
## Compatibility

* Ember.js v4.8 or above
* Ember CLI v4.8 or above
* Node.js v16 or above

**No observers were used nor harmed while developing and testing this addon.**
## Features

- Lazily computed validations
- Ruby on rails inspired validators
Expand All @@ -35,17 +39,17 @@ You can also learn more by watching this Global Ember Meetup talk:
ember install ember-cp-validations
```

## Upgrading to 4.x
## Upgrading from 3.x

If you are upgrading from 3.x to 4.x, please checkout the [upgrading documentation](UPGRADING.md).
If you are upgrading from 3.x, please checkout the [upgrading documentation](UPGRADING.md).

## Helpful Links

- ### [Live Demo](http://adopted-ember-addons.github.io/ember-cp-validations)

- ### Documentation

- [4.x](http://adopted-ember-addons.github.io/ember-cp-validations/docs)
- [6.x](http://adopted-ember-addons.github.io/ember-cp-validations/docs)
- [3.x](https://rawgit.com/adopted-ember-addons/ember-cp-validations/c4123c983e54f24dd790ffa1bad66cfdf2f47ec6/docs/index.html)

- ### [Changelog](CHANGELOG.md)
Expand Down
8 changes: 4 additions & 4 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Upgrading v3.x to 4.x
# Upgrading from v3.x

This document is here to show breaking changes when upgrading from v3.x to v4.x.
This document is here to show breaking changes when upgrading from v3.x.

## Support Latest 2 LTS Releases

Expand All @@ -16,7 +16,7 @@ to the `validator` but it didn't feel consistent with the rest of the API. To no
this, we created a new `inline` validator that you can pass a function to via
the `validate` option.

**Before (3.x)**
**Version <= 3.x**

```javascript
validator(function(value, options, model, attribute) {
Expand All @@ -28,7 +28,7 @@ validator(function(value, options, model, attribute) {
});
```

**After (4.x)**
**Version >= 4.x**

```javascript
validator('inline', {
Expand Down
24 changes: 8 additions & 16 deletions addon/-private/ember-internals.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import __EMBER_METAL__ from '@ember/-internals/metal/index';
import {
isClassicDecorator,
descriptorForDecorator,
} from '@ember/-internals/metal/index';

export function getDependentKeys(descriptorOrDecorator) {
if (__EMBER_METAL__ && __EMBER_METAL__.descriptorForDecorator) {
let descriptor = __EMBER_METAL__.descriptorForDecorator(
descriptorOrDecorator
);
return descriptor._dependentKeys || [descriptor.altKey];
} else {
return descriptorOrDecorator._dependentKeys;
}
const descriptor = descriptorForDecorator(descriptorOrDecorator);
// TODO: Figure out why the fallback `|| [descriptor.altKey]` is needed
return descriptor._dependentKeys || [descriptor.altKey];
}

export function isDescriptor(o) {
if (__EMBER_METAL__ && __EMBER_METAL__.isClassicDecorator) {
return __EMBER_METAL__.isClassicDecorator(o);
} else {
return (
o && (typeof o === 'object' || typeof o === 'function') && o.isDescriptor
);
}
return isClassicDecorator(o);
}
4 changes: 2 additions & 2 deletions addon/-private/internal-result-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default EmberObject.extend({
}

return null;
}
},
),

errors: computed('error', function () {
Expand All @@ -82,7 +82,7 @@ export default EmberObject.extend({
}

return null;
}
},
),

warnings: computed('warning', function () {
Expand Down
5 changes: 4 additions & 1 deletion addon/-private/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export default class Options {
constructor({ model, attribute, options = {} }) {
const optionKeys = keys(options);
const createParams = { [OPTION_KEYS]: optionKeys, model, attribute };
const someOptionsAreDescriptors = optionKeys.some((key) => {
return isDescriptor(options[key]);
});

// 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 (someOptionsAreDescriptors) {
return OptionsObject.extend(options).create(createParams);
}

Expand Down
4 changes: 2 additions & 2 deletions addon/-private/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const Result = EmberObject.extend({
this._resultOverride ||
InternalResultObject.create({ model, attribute, _promise, _validator })
);
}
},
),

init() {
Expand Down Expand Up @@ -255,7 +255,7 @@ const Result = EmberObject.extend({
this._promise
.then(
(value) => this.update(value),
(value) => this.update(value)
(value) => this.update(value),
)
.catch((reason) => {
// TODO: send into error state
Expand Down
2 changes: 1 addition & 1 deletion addon/utils/deep-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function deepSet(
path,
value,
useEmberObject = false,
delimiter = '.'
delimiter = '.',
) {
let keyPath = path.split(delimiter);
let lastKeyIndex = keyPath.length - 1;
Expand Down
Loading