Skip to content

Commit

Permalink
Make ember-simple-auth a peerDep, drop support for node < 14 (#454)
Browse files Browse the repository at this point in the history
* Make ember-simple-auth a peerDep

* ember-cli-update to 4.8.1, drop support for node < 14

* Update .template-lintrc.js

* Add @ember/string to devDeps

* yarn upgrade

* Update ember-try.js

* Update ESA to use session setup
  • Loading branch information
RobbieTheWagner authored Jan 8, 2024
1 parent 5517c12 commit 74b75c5
Show file tree
Hide file tree
Showing 19 changed files with 3,498 additions and 4,553 deletions.
8 changes: 7 additions & 1 deletion .ember-cli
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
"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.
*/
"isTypeScriptProject": false
}
30 changes: 16 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ on:
pull_request: {}

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
test:
name: "Tests"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand All @@ -33,12 +34,13 @@ jobs:
floating:
name: "Floating Dependencies"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: Install Dependencies
run: yarn install --no-lockfile
Expand All @@ -48,28 +50,28 @@ jobs:
try-scenarios:
name: ${{ matrix.try-scenario }}
runs-on: ubuntu-latest
needs: 'test'
needs: "test"
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
try-scenario:
- ember-lts-3.24
- ember-lts-3.28
- ember-lts-4.4
- ember-release
- ember-beta
- ember-canary
- ember-classic
- ember-default-with-jquery
- embroider-safe
- embroider-optimized

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 14.x
cache: yarn
- name: Install Dependencies
run: yarn install --frozen-lockfile
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try

# broccoli-debug
/DEBUG/
1 change: 1 addition & 0 deletions .template-lintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module.exports = {
extends: 'recommended',
rules: {
'no-autofocus-attribute': false,
'require-input-label': false,
},
};
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.19.0
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,5 @@ login, logout, and updating/verifying user attributes.

## Support

* Ember versions 3.4+
* Ember versions 3.28+
* AWS Amplify 1.x
25 changes: 7 additions & 18 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ module.exports = async function () {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.24',
name: 'ember-lts-3.28',
npm: {
devDependencies: {
'ember-source': '~3.24.3',
'ember-source': '~3.28.0',
},
},
},
{
name: 'ember-lts-3.28',
name: 'ember-lts-4.4',
npm: {
devDependencies: {
'ember-source': '~3.28.0',
'ember-source': '~4.4.0',
},
},
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-simple-auth': '^6.0.0',
'ember-source': await getChannelURL('release'),
},
},
Expand All @@ -35,6 +36,7 @@ module.exports = async function () {
name: 'ember-beta',
npm: {
devDependencies: {
'ember-simple-auth': '^6.0.0',
'ember-source': await getChannelURL('beta'),
},
},
Expand All @@ -43,24 +45,11 @@ module.exports = async function () {
name: 'ember-canary',
npm: {
devDependencies: {
'ember-simple-auth': '^6.0.0',
'ember-source': await getChannelURL('canary'),
},
},
},
{
name: 'ember-default-with-jquery',
env: {
EMBER_OPTIONAL_FEATURES: JSON.stringify({
'jquery-integration': true,
}),
},
npm: {
devDependencies: {
'@ember/jquery': '^1.1.0',
'ember-source': '~3.28.0',
},
},
},
{
name: 'ember-classic',
env: {
Expand Down
6 changes: 4 additions & 2 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function (defaults) {
let app = new EmberAddon(defaults, {
// Add options here
const app = new EmberAddon(defaults, {
'ember-simple-auth': {
useSessionSetupMethod: true,
},
});

/*
Expand Down
51 changes: 27 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,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 @@ -31,54 +31,57 @@
"@aws-amplify/core": "^4.3.13",
"amazon-cognito-identity-js": "^5.2.5",
"crypto-browserify": "^3.12.0",
"ember-auto-import": "^2.3.0",
"ember-auto-import": "^2.4.3",
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.0.1"
"ember-cli-htmlbars": "^6.1.1"
},
"devDependencies": {
"@babel/core": "^7.0.0-0",
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.6.0",
"@embroider/test-setup": "^1.0.0",
"@glimmer/component": "^1.0.4",
"@glimmer/tracking": "^1.0.4",
"@ember/string": "^3.1.1",
"@ember/test-helpers": "^2.8.1",
"@embroider/test-setup": "^1.8.3",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~4.1.0",
"ember-cli": "~4.8.1",
"ember-cli-code-coverage": "^1.0.3",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-dependency-checker": "^3.3.1",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-terser": "^4.0.2",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^8.1.1",
"ember-load-initializers": "^2.1.2",
"ember-qunit": "^5.1.5",
"ember-qunit": "^6.0.0",
"ember-resolver": "^8.0.3",
"ember-simple-auth": "^4.1.1",
"ember-simple-auth": "^4.2.2",
"ember-sinon": "^5.0.0",
"ember-source": "~4.4.0",
"ember-source": "~4.8.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^3.15.0",
"ember-template-lint": "^4.16.1",
"ember-try": "^2.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-disable-features": "^0.1.3",
"eslint-plugin-ember": "^10.5.8",
"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.5.1",
"qunit": "^2.17.2",
"prettier": "^2.7.1",
"qunit": "^2.19.2",
"qunit-dom": "^2.0.0",
"release-it": "^14.2.2",
"release-it-lerna-changelog": "^4.0.1",
"webpack": "^5.66.0"
"webpack": "^5.74.0"
},
"peerDependencies": {
"ember-simple-auth": "^4.0.0 || ^5.0.0 || >= 6.0.0"
},
"engines": {
"node": "12.* || 14.* || >= 16"
"node": "14.* || 16.* || >= 18"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
1 change: 0 additions & 1 deletion tests/dummy/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>ember-cognito</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand Down
31 changes: 13 additions & 18 deletions tests/dummy/app/routes/application.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
/* eslint-disable ember/no-mixins */
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';

export default Route.extend(ApplicationRouteMixin, {
currentUser: service(),

beforeModel() {
return this._loadCurrentUser();
},
import { inject as service } from '@ember/service';

sessionAuthenticated() {
this._super(...arguments);
this._loadCurrentUser();
},
export default class Application extends Route {
@service currentUser;
@service session;

_loadCurrentUser() {
return this.currentUser.load().catch(() => this.session.invalidate());
},
});
async beforeModel() {
await this.session.setup();
try {
await this.currentUser.load();
} catch (err) {
await this.invalidate();
}
}
}
16 changes: 16 additions & 0 deletions tests/dummy/app/services/session.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { inject as service } from '@ember/service';
import BaseSessionService from 'ember-simple-auth/services/session';

export default class SessionService extends BaseSessionService {
@service currentUser;

async handleAuthentication() {
super.handleAuthentication(...arguments);

try {
await this.currentUser.load();
} catch (err) {
await this.invalidate();
}
}
}
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.1.0",
"version": "4.8.1",
"blueprints": [
{
"name": "addon",
Expand Down
8 changes: 2 additions & 6 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
'use strict';

module.exports = function (environment) {
let ENV = {
const ENV = {
modulePrefix: 'dummy',
environment,
rootURL: '/',
locationType: 'auto',
locationType: 'history',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},

APP: {
Expand Down
Empty file removed tests/helpers/.gitkeep
Empty file.
Loading

0 comments on commit 74b75c5

Please sign in to comment.