Skip to content

Commit

Permalink
Add Embroider
Browse files Browse the repository at this point in the history
  • Loading branch information
patocallaghan committed Feb 25, 2021
1 parent bb30016 commit cb5f82b
Show file tree
Hide file tree
Showing 5 changed files with 524 additions and 41 deletions.
16 changes: 16 additions & 0 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default class ApplicationController extends Controller {
@service store;

init() {
super.init(...arguments);
let user = this.store.createRecord('user', {
username: 'x',
password: 'x',
email: 'x',
});
console.log(user.validations.isValid);
}
}
28 changes: 28 additions & 0 deletions app/models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Model, { attr } from '@ember-data/model';
import { validator, buildValidations } from 'ember-cp-validations';

const Validations = buildValidations({
username: validator('presence', true),
password: [
validator('presence', true),
validator('length', {
min: 4,
max: 8,
}),
],
email: [validator('presence', true), validator('format', { type: 'email' })],
emailConfirmation: [
validator('presence', true),
validator('confirmation', {
on: 'email',
message: '{description} do not match',
description: 'Email addresses',
}),
],
});

export default Model.extend(Validations, {
username: attr('string'),
password: attr('string'),
email: attr('string'),
});
22 changes: 8 additions & 14 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ module.exports = function (defaults) {
// Add options here
});

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

return app.toTree();
// return app.toTree();
const { Webpack } = require('@embroider/webpack');
return require('@embroider/compat').compatBuild(app, Webpack, {
staticAddonTestSupportTrees: true,
staticAddonTrees: true,
staticHelpers: true,
staticComponents: true,
});
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.2.0",
"@embroider/compat": "^0.36.0",
"@embroider/core": "^0.36.0",
"@embroider/webpack": "^0.36.0",
"@glimmer/component": "^1.0.3",
"@glimmer/tracking": "^1.0.3",
"babel-eslint": "^10.1.0",
Expand All @@ -38,6 +41,7 @@
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.1",
"ember-cp-validations": "^4.0.0-beta.10",
"ember-data": "~3.25.0",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.0.4",
Expand Down
Loading

0 comments on commit cb5f82b

Please sign in to comment.