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

12836 Upgrade ember cli and node version #1177

Open
wants to merge 9 commits into
base: develop
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
ember_tests:
docker:
# specify the version you desire here
- image: circleci/node:10.18-browsers
- image: circleci/node:16-browsers
environment:
BUILD_CONTEXT: test

Expand Down
2 changes: 2 additions & 0 deletions client/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# misc
/coverage/
!.*
.*/
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
85 changes: 46 additions & 39 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,85 +8,92 @@ module.exports = {
legacyDecorators: true,
},
},
plugins: [
'ember',
'hbs',
],
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'airbnb-base',
],
env: {
browser: true,
node: true,
es6: true,
},
rules: {
'ember/no-jquery': 'error',
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'import/no-named-as-default': 1,
'import/prefer-default-export': 1,
'import/extensions': 0,
'import/no-named-as-default-member': 1,
'import/named': 0,
'array-callback-return': 1,
camelcase: 0,
'class-methods-use-this': 0,
'consistent-return': 1,
'default-case': 1,
'ember/avoid-leaking-state-in-ember-objects': 0,
'ember/no-jquery': 'error',
eqeqeq: 1,
'lines-around-directive': 0,
'func-names': 0,
'space-before-function-paren': 0,
'prefer-arrow-callback': 0,
'prefer-rest-params': 1,
'implicit-arrow-linebreak': 1,
'import/extensions': 0,
'import/named': 0,
'import/no-extraneous-dependencies': 0,
'import/no-named-as-default': 1,
'import/no-named-as-default-member': 1,
'import/no-unresolved': 0,
'import/prefer-default-export': 1,
'lines-around-directive': 0,
'max-len': 0,
'no-mixed-operators': 1,
'no-shadow': 1,
'no-mixins': 0,
'no-nested-ternary': 1,
'no-param-reassign': 0,
'no-plusplus': 1,
'no-restricted-globals': 1,
'no-restricted-properties': 1,
'no-restricted-syntax': 1,
'prefer-const': 1,
'no-underscore-dangle': 0,
'no-use-before-define': 0,
'no-return-assign': 1,
camelcase: 0,
'class-methods-use-this': 0,
'max-len': 0,
'no-param-reassign': 0,
'implicit-arrow-linebreak': 1,
'no-nested-ternary': 1,
'no-restricted-properties': 1,
'prefer-promise-reject-errors': 1,
'no-plusplus': 1,
'no-return-await': 1,
'no-shadow': 1,
'no-underscore-dangle': 0,
'no-use-before-define': 0,
'operator-linebreak': 1,
'ember/avoid-leaking-state-in-ember-objects': 0,
'prefer-arrow-callback': 0,
'prefer-const': 1,
'prefer-promise-reject-errors': 1,
'prefer-rest-params': 1,
'space-before-function-paren': 0,
},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js',
'./.eslintrc.js',
'./.prettierrc.js',
'./.template-lintrc.js',
'./ember-cli-build.js',
'./testem.js',
'./blueprints/*/index.js',
'./config/**/*.js',
'./lib/*/index.js',
'./server/**/*.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
es6: true,
},
plugins: ['node'],
// extends: ['plugin:node/recommended'],
rules: {
...require('eslint-plugin-node').configs.recommended.rules, // eslint-disable-line

// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off',
},
},
{
// Test files:
files: ['tests/**/*-test.{js,ts}'],
// extends: ['plugin:qunit/recommended'],
},
],
};
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
Expand Down
2 changes: 2 additions & 0 deletions client/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
16.*

21 changes: 21 additions & 0 deletions client/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
3 changes: 3 additions & 0 deletions client/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true,
};
6 changes: 3 additions & 3 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Make use of the many generators for code, try `ember help generate` for more det

### Linting

* `yarn lint:hbs`
* `yarn lint:js`
* `yarn lint:js -- --fix`

* `yarn lint`
* `yarn lint:fix`

### Building

Expand Down
2 changes: 1 addition & 1 deletion client/app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import { inject as service } from '@ember/service';
import ENV from '../config/environment';
import ENV from 'client/config/environment';

export default class ApplicationAdapter extends JSONAPIAdapter {
@service
Expand Down
16 changes: 13 additions & 3 deletions client/app/adapters/package.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import { inject as service } from '@ember/service';
import ENV from '../config/environment';
import ENV from 'client/config/environment';

// Taken from
// https://github.com/emberjs/data/blob/v3.24.0/packages/adapter/addon/-private/utils/serialize-into-hash.js
function serializeIntoHash(store, modelClass, snapshot, options = { includeId: true }) {
function serializeIntoHash(
store,
modelClass,
snapshot,
options = { includeId: true },
) {
const serializer = store.serializerFor(modelClass.modelName);

if (typeof serializer.serializeIntoHash === 'function') {
Expand Down Expand Up @@ -46,7 +51,12 @@ export default class PackageAdapter extends JSONAPIAdapter {

const data = serializeIntoHash(store, type, snapshot);

let url = this.buildURL(type.modelName, snapshot.id, snapshot, 'updateRecord');
const url = this.buildURL(
type.modelName,
snapshot.id,
snapshot,
'updateRecord',
);

return this.ajax(url, 'PATCH', { data });
}
Expand Down
2 changes: 1 addition & 1 deletion client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import defineModifier from 'ember-concurrency-test-waiter/define-modifier';
import config from './config/environment';
import config from 'client/config/environment';

// provides better test support for tasks
// https://github.com/bendemboski/ember-concurrency-test-waiter#usage
Expand Down
15 changes: 11 additions & 4 deletions client/app/authenticators/zap-api-authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fetch from 'fetch';
import OAuth2ImplicitGrantAuthenticator from 'ember-simple-auth/authenticators/oauth2-implicit-grant';
import { InvalidError } from '@ember-data/adapter/error';
import jwtDecode from 'jwt-decode';
import ENV from '../config/environment';
import ENV from 'client/config/environment';

export default class ZAPAuthenticator extends OAuth2ImplicitGrantAuthenticator {
async authenticate(...args) {
Expand All @@ -27,12 +27,16 @@ export default class ZAPAuthenticator extends OAuth2ImplicitGrantAuthenticator {
// Pass the NYCIDToken to backend /login endpoint.
// Server should provide an access_token used for signing
// requests using the Authorization header
const response = await fetch(`${ENV.host}/login?accessToken=${accessToken}&DEBUG_useremail=${attemptedLoginEmail}`);
const response = await fetch(
`${ENV.host}/login?accessToken=${accessToken}&DEBUG_useremail=${attemptedLoginEmail}`,
);
const body = await response.json();

if (!response.ok) throw body;

const displayName = `${(typeof NYCIDUser.givenName === 'undefined') ? '' : NYCIDUser.givenName} ${(typeof NYCIDUser.sn === 'undefined') ? '' : NYCIDUser.sn}`;
const displayName = `${
typeof NYCIDUser.givenName === 'undefined' ? '' : NYCIDUser.givenName
} ${typeof NYCIDUser.sn === 'undefined' ? '' : NYCIDUser.sn}`;

try {
// eslint-disable-next-line no-undef
Expand All @@ -42,7 +46,10 @@ export default class ZAPAuthenticator extends OAuth2ImplicitGrantAuthenticator {
});
} catch (e) {
// eslint-disable-next-line no-console
console.log('FS.identify failed. This may happen during tests, if using incognito mode, or if Mirage is blocking your request. Error message:', e);
console.log(
'FS.identify failed. This may happen during tests, if using incognito mode, or if Mirage is blocking your request. Error message:',
e,
);
}

// Since all requests to the API are now authenticated.
Expand Down
2 changes: 1 addition & 1 deletion client/app/components/auth/do-logout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ shows that else block when the iframe is still loading. When it is finished
loading, it yields the main block. --}}
{{#if this.iFrameDidLoad}}
{{yield}}
{{else if (hasBlock 'inverse')}}
{{else if (has-block 'inverse')}}
{{yield to="inverse"}}
{{/if}}
18 changes: 10 additions & 8 deletions client/app/components/auth/do-logout.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import Component from '@ember/component';
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action, set } from '@ember/object';
import { inject as service } from '@ember/service';
import ENV from '../../config/environment';
import ENV from 'client/config/environment';

export default class DoLogout extends Component {
@service session;

@tracked
iFrameDidLoad = false;

origin = window.location.origin;

get nycIDHost() {
const { origin } = new URL(ENV.NYCIDLocation || this.origin);

return `${origin}/account/idpLogout.htm?x-frames-allow-from=${this.origin}`;
}

origin = window.location.origin;

iFrameDidLoad = false;

@action
didLogoutNycId() {
this.session.invalidate(); // also logout of the current session

this.set('iFrameDidLoad', true);
set(this, 'iFrameDidLoad', true);
}
}
2 changes: 1 addition & 1 deletion client/app/components/auth/sign-in-button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Component from '@glimmer/component';
import ENV from '../../config/environment';
import ENV from 'client/config/environment';

export default class SignInButtonComponent extends Component {
get loginLocation() {
Expand Down
22 changes: 13 additions & 9 deletions client/app/components/auth/sign-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,31 @@ export default class AuthSignInComponent extends Component {

this.isLoginStarted = true;

const {
isNycidValidated,
isNycidEmailRegistered,
isCityEmployee,
} = await this.args.searchContacts(loginEmail);
const { isNycidValidated, isNycidEmailRegistered, isCityEmployee } = await this.args.searchContacts(loginEmail);

// We should always be redirecting nyc government employees to the NYC.ID login page
// (never to the register page) regardless of whether isNycidEmailRegistered is true or false
if (isCityEmployee) {
this.router.transitionTo('auth.login', { queryParams: { loginEmail, isCityEmployee } });
this.router.transitionTo('auth.login', {
queryParams: { loginEmail, isCityEmployee },
});
} else {
if (isNycidEmailRegistered) { // eslint-disable-line
// we can only know email validation after they logged in once.
// if it's null, it means we don't know because they've never logged in before (null).
if (isNycidValidated === true || isNycidValidated === null) {
this.router.transitionTo('auth.login', { queryParams: { loginEmail } });
this.router.transitionTo('auth.login', {
queryParams: { loginEmail },
});
} else if (isNycidValidated === false) {
this.router.transitionTo('auth.validate', { queryParams: { loginEmail } });
this.router.transitionTo('auth.validate', {
queryParams: { loginEmail },
});
}
} else {
this.router.transitionTo('auth.register', { queryParams: { loginEmail } });
this.router.transitionTo('auth.register', {
queryParams: { loginEmail },
});
}
}
}
Expand Down
Loading