Skip to content

Commit

Permalink
Merge pull request #732 from adopted-ember-addons/update-ember-cli-to…
Browse files Browse the repository at this point in the history
…-4-8

Update ember-cli to v4.8
  • Loading branch information
MelSumner authored Jun 1, 2023
2 parents 007c327 + 13ae76a commit 24b9998
Show file tree
Hide file tree
Showing 22 changed files with 424 additions and 2,087 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
try-scenario:
- ember-lts-3.28
- ember-4.0
- ember-lts-4.4
- ember-release
- ember-beta
- ember-canary
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ An EmberJS validation framework that is completely and utterly computed property
- Support for Ember Data Models, Objects, Components, Services, etc.
- Support for nested models and objects
- Synchronous and asynchronous support
- Easily integrated with Ember Data's [DS.Errors](http://emberjs.com/api/data/classes/DS.Errors.html)
- Easily integrated with Ember Data
- No observers. Seriously... there are none. Like absolutely zero....
- Custom validators
- I18n support
Expand Down
2 changes: 1 addition & 1 deletion addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import Validator from './validations/validator';
* ```javascript
* // models/user.js
*
* export default DS.Model.extend(Validations, {
* export default Model.extend(Validations, {
* 'username': attr('string'),
* 'password': attr('string'),
* 'email': attr('string')
Expand Down
4 changes: 2 additions & 2 deletions addon/validators/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ export default Base;
* }),
* });
*
* export default DS.Model.extend(Validations, {
* 'username': DS.attr('string'),
* export default Model.extend(Validations, {
* 'username': attr('string'),
* });
* ```
*
Expand Down
6 changes: 3 additions & 3 deletions addon/validators/belongs-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
* details: validator('belongs-to')
* });
*
* export default DS.Model.extend(Validations, {
* 'details': DS.belongsTo('user-detail')
* export default Model.extend(Validations, {
* 'details': belongsTo('user-detail')
* });
* ```
*
Expand All @@ -31,7 +31,7 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
* lastName: validator('presence', true)
* });
*
* export default DS.Model.extend(Validations, {
* export default Model.extend(Validations, {
* "firstName": attr('string'),
* "lastName": attr('string'),
* });
Expand Down
2 changes: 1 addition & 1 deletion addon/validators/ds-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getPathAndKey } from 'ember-validators/ds-error';
/**
* <i class="fa fa-hand-o-right" aria-hidden="true"></i> [See All Options](#method_validate)
*
* Creates a link between this library and Ember-Data's [DS.Errors](http://emberjs.com/api/data/classes/DS.Errors.html)
* Creates a link between this library and Ember-Data
* to fetch the latest message for the given attribute.
*
* ## Examples
Expand Down
4 changes: 2 additions & 2 deletions addon/validators/has-many.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { isPromise } from 'ember-cp-validations/utils/utils';
* friends: validator('has-many')
* });
*
* export default DS.Model.extend(Validations, {
* friends: DS.hasMany('user')
* export default Model.extend(Validations, {
* friends: hasMany('user')
* });
* ```
*
Expand Down
10 changes: 10 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ module.exports = async function () {
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',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
const app = new EmberAddon(defaults, {
snippetSearchPaths: ['addon', 'tests/dummy/app'],
snippetPaths: ['snippets', 'tests/dummy/snippets'],

Expand Down
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
},
"scripts": {
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
"lint": "npm-run-all --print-name --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix": "npm-run-all --print-name --aggregate-output --continue-on-error --parallel \"lint:*:fix\"",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start": "ember serve",
"test": "npm-run-all lint test:*",
"test": "npm-run-all --print-name \"lint\" \"test:*\"",
"test:ember": "ember test",
"test:ember-compatibility": "ember try:each"
},
Expand All @@ -55,8 +55,8 @@
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.7.0",
"@embroider/test-setup": "^1.6.0",
"@ember/test-helpers": "^2.8.1",
"@embroider/test-setup": "^1.8.3",
"@fortawesome/ember-fontawesome": "^1.0.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
Expand All @@ -65,48 +65,46 @@
"@release-it-plugins/lerna-changelog": "^5.0.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^2.7.0",
"ember-auto-import": "^2.4.2",
"ember-cli": "~4.4.1",
"ember-auto-import": "^2.4.3",
"ember-cli": "~4.8.0",
"ember-cli-app-version": "^5.0.0",
"ember-cli-autoprefixer": "^2.0.0",
"ember-cli-dependency-checker": "^3.3.1",
"ember-cli-github-pages": "^0.2.2",
"ember-cli-htmlbars": "^6.0.1",
"ember-cli-htmlbars": "^6.1.1",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-moment-shim": "^3.8.0",
"ember-cli-sass": "^11.0.1",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-cli-yuidoc": "^0.8.8",
"ember-code-snippet": "^3.0.0",
"ember-data": "~4.4.0",
"ember-data": "~4.8.0",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.2",
"ember-prism": "^0.13.0",
"ember-qunit": "^5.1.5",
"ember-qunit": "^6.0.0",
"ember-resolver": "^8.0.3",
"ember-source": "~4.4.0",
"ember-source": "~4.8.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^4.8.0",
"ember-template-lint": "^4.16.1",
"ember-try": "^2.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-ember": "^10.6.1",
"eslint-plugin-ember": "^11.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-qunit": "^7.2.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.1",
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"qunit": "^2.19.1",
"prettier": "^2.7.1",
"qunit": "^2.19.2",
"qunit-dom": "^2.0.0",
"release-it": "^15.10.3",
"sass": "^1.62.1",
"webpack": "^5.72.1"
"webpack": "^5.74.0"
},
"engines": {
"node": "14.* || >= 16"
"node": "14.* || 16.* || >= 18"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/models/order-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Validations = buildValidations({
});

export default Model.extend(Validations, {
order: belongsTo('order', { async: true }),
selections: hasMany('order-selection', { async: true }),
order: belongsTo('order', { async: true, inverse: 'lines' }),
selections: hasMany('order-selection', { async: true, inverse: 'line' }),
type: attr('string'),
});
7 changes: 5 additions & 2 deletions tests/dummy/app/models/order-selection-question.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const Validations = buildValidations(
);

export default Model.extend(Validations, {
order: belongsTo('order', { async: true }),
selection: belongsTo('order-selection', { async: true }),
order: belongsTo('order', { async: true, inverse: 'questions' }),
selection: belongsTo('order-selection', {
async: true,
inverse: 'questions',
}),
text: attr('string'),
});
9 changes: 6 additions & 3 deletions tests/dummy/app/models/order-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ const Validations = buildValidations({
});

export default Model.extend(Validations, {
order: belongsTo('order', { async: true }),
line: belongsTo('order-line', { async: true }),
questions: hasMany('order-selection-question', { async: true }),
order: belongsTo('order', { async: true, inverse: 'selections' }),
line: belongsTo('order-line', { async: true, inverse: 'selections' }),
questions: hasMany('order-selection-question', {
async: true,
inverse: 'selection',
}),
quantity: attr('number'),
});
10 changes: 9 additions & 1 deletion tests/dummy/app/models/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ const Validations = buildValidations({

export default Model.extend(Validations, {
source: attr('string'),
lines: hasMany('order-line', { async: true }),
lines: hasMany('order-line', { async: true, inverse: 'order' }),
questions: hasMany('order-selection-question', {
async: true,
inverse: 'order',
}),
selections: hasMany('order-selection', {
async: true,
inverse: 'order',
}),
});
2 changes: 1 addition & 1 deletion tests/dummy/app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ export default Model.extend(Validations, {
username: attr('string'),
password: attr('string'),
email: attr('string'),
details: belongsTo('user-detail'),
details: belongsTo('user-detail', { async: true, inverse: null }),
});
// END-SNIPPET
2 changes: 1 addition & 1 deletion tests/dummy/config/ember-cli-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
{
"name": "ember-cli",
"version": "4.4.1",
"version": "4.8.0",
"blueprints": [
{
"name": "addon",
Expand Down
6 changes: 1 addition & 5 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = function (environment) {
let ENV = {
const ENV = {
modulePrefix: 'dummy',
environment,
rootURL: '/',
Expand All @@ -11,10 +11,6 @@ module.exports = function (environment) {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},

APP: {
Expand Down
27 changes: 18 additions & 9 deletions tests/integration/validations/factory-dependent-keys-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { A } from '@ember/array';
import EmberObject from '@ember/object';
import DS from 'ember-data';
import Model, { attr } from '@ember-data/model';
import setupObject from '../../helpers/setup-object';
import CollectionValidator from 'dummy/validators/collection';
import LengthValidator from 'dummy/validators/length';
Expand Down Expand Up @@ -49,10 +49,14 @@ module(
let DSErrorValidations = buildValidations({
username: validator('ds-error'),
});
let obj = setupObject(this, EmberObject.extend(DSErrorValidations), {
errors: DS.Errors.create(),
username: '',
});
this.owner.register(
'model:user',
Model.extend(DSErrorValidations, {
username: attr('string'),
})
);

let obj = this.owner.lookup('service:store').createRecord('user');

assert.true(obj.get('validations.attrs.username.isValid'));

Expand All @@ -72,12 +76,17 @@ module(
let DSErrorValidations = buildValidations({
'model.username': validator('ds-error'),
});
this.owner.register(
'model:user',
Model.extend(DSErrorValidations, {
username: attr('string'),
})
);

let user = this.owner.lookup('service:store').createRecord('user');

let obj = setupObject(this, EmberObject.extend(DSErrorValidations), {
model: EmberObject.create({
errors: DS.Errors.create(),
username: '',
}),
model: user,
});

assert.true(obj.get('validations.attrs.model.username.isValid'));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/validations/ds-model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { run } from '@ember/runloop';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Validations | DS.Model', function (hooks) {
module('Unit | Validations | Model', function (hooks) {
setupTest(hooks);

test('create model with defaults', function (assert) {
Expand Down
25 changes: 12 additions & 13 deletions tests/unit/validations/nested-model-relationship-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,24 +358,17 @@ module('Unit | Validations | Nested Model Relationships', function (hooks) {

test('order with invalid question shows valid if invalid question is deleted in reverse order', function (assert) {
assert.expect(9);
let order = run(() =>
this.owner
.lookup('service:store')
.createRecord('order', { id: 1, source: 'external' })
);
let done = assert.async();

let orderLine,
let order,
orderLine,
orderSelection,
orderSelectionQuestion,
orderSelectionQuestion2;

let store = this.owner.lookup('service:store');
run(() => {
let fakeSave = function (model) {
model.get('_internalModel').adapterWillCommit();
model.get('_internalModel').adapterDidCommit();
};

order = store.createRecord('order', { id: 1, source: 'external' });
orderLine = store.createRecord('order-line', {
id: 1,
order,
Expand All @@ -399,6 +392,14 @@ module('Unit | Validations | Nested Model Relationships', function (hooks) {
selection: orderSelection,
});

// Not sure if this is needed.
let fakeSave = function (model) {
if (model.get('_internalModel')) {
model.get('_internalModel').adapterWillCommit();
model.get('_internalModel').adapterDidCommit();
}
};

fakeSave(order);
fakeSave(orderLine);
fakeSave(orderSelection);
Expand All @@ -418,8 +419,6 @@ module('Unit | Validations | Nested Model Relationships', function (hooks) {
'Order Selection has 2 Order Selection Question'
);

let done = assert.async();

orderSelectionQuestion2
.validate()
.then(({ validations }) => {
Expand Down
Loading

0 comments on commit 24b9998

Please sign in to comment.