Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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 app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CachedShoe from 'ember-cached-shoe';
* @return {*}
*/
export const fixFilterQuery = query => {
if (query.hasOwnProperty('filter')) {
if (Object.prototype.hasOwnProperty.call(query, 'filter')) {
query.filter = JSON.stringify(query.filter);
}

Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/reset-password-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default Component.extend(FormMixin, {
this.router.transitionTo('login');
})
.catch(reason => {
if (reason && reason.hasOwnProperty('errors') && reason.errors[0].status === 404) {
if (reason && Object.prototype.hasOwnProperty.call(reason, 'errors') && reason.errors[0].status === 404) {
this.set('errorMessage', this.l10n.t('No account is registered with this email address.'));
} else {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/oauth/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default Controller.extend({
})
.catch(reason => {
if (!(this.isDestroyed || this.isDestroying)) {
if (reason && reason.hasOwnProperty('status_code') && reason.status_code === 401) {
if (reason && Object.prototype.hasOwnProperty.call(reason, 'status_code') && reason.status_code === 401) {
this.set('errorMessage', this.l10n.t('Your credentials were incorrect.'));
} else {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default Controller.extend({
})
.catch(reason => {
if (!(this.isDestroyed || this.isDestroying)) {
if (reason && reason.hasOwnProperty('status_code') && reason.status_code === 401) {
if (reason && Object.prototype.hasOwnProperty.call(reason, 'status_code') && reason.status_code === 401) {
this.set('errorMessage', this.l10n.t('Your credentials were incorrect.'));
} else {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default Controller.extend({
}
})
.catch(reason => {
if (reason && reason.hasOwnProperty('errors') && reason.errors[0].status === 409) {
if (reason && Object.prototype.hasOwnProperty.call(reason, 'errors') && reason.errors[0].status === 409) {
this.set('errorMessage', this.l10n.t('User already exists.'));
} else {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
Expand Down Expand Up @@ -57,7 +57,7 @@ export default Controller.extend({
})
.catch(reason => {
if (!(this.isDestroyed || this.isDestroying)) {
if (reason && reason.hasOwnProperty('status_code') && reason.status_code === 401) {
if (reason && Object.prototype.hasOwnProperty.call(reason, 'errors') && reason.status_code === 401) {
this.set('errorMessage', this.l10n.t('Your credentials were incorrect.'));
} else {
this.set('errorMessage', this.l10n.t('An unexpected error occurred.'));
Expand Down
2 changes: 1 addition & 1 deletion app/services/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default Service.extend({
deviceType: computed('currentWidth', function() {
let deviceType = 'computer';
forOwn(breakpoints, (value, key) => {
if (this.currentWidth >= value.min && (!value.hasOwnProperty('max') || this.currentWidth <= value.max)) {
if (this.currentWidth >= value.min && (!Object.prototype.hasOwnProperty.call(value, 'max') || this.currentWidth <= value.max)) {
deviceType = key;
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/services/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default Service.extend({
xhr.open('get', url);
let headers = fetchOptions.headers || {};
for (let k in headers) {
if (k !== 'Content-Type' && headers.hasOwnProperty(k)) {
if (k !== 'Content-Type' && Object.prototype.hasOwnProperty.call(headers, k)) {
xhr.setRequestHeader(k, fetchOptions.headers[k]);
}
}
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ module.exports = function(environment) {
'media-src' : '\'none\''
};
}

if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
Expand Down
66 changes: 33 additions & 33 deletions scripts/replace-config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
require('dotenv').config()
require('dotenv').config();

const fs = require('fs');
const promisify = require('util').promisify
const { merge } = require('lodash')
const safeEval = require('safe-eval')
const promisify = require('util').promisify;
const { merge } = require('lodash');
const safeEval = require('safe-eval');

const env = require('../config/environment')
const appName = 'open-event-frontend'
const env = require('../config/environment');
const appName = 'open-event-frontend';

const environment = env('production')
const environment = env('production');

async function replaceFastbootConfig() {
const packagePath = './dist/package.json'
const packageInfo = require('.' + packagePath)
const packagePath = './dist/package.json';
const packageInfo = require('.' + packagePath);

const old = packageInfo.fastboot.config[appName]
const old = packageInfo.fastboot.config[appName];
packageInfo.fastboot.config[appName] = merge(old, environment);
await promisify(fs.writeFile)(packagePath, JSON.stringify(packageInfo))
await promisify(fs.writeFile)(packagePath, JSON.stringify(packageInfo));

console.log('Transformed package.json with new environment')
//console.log('Transformed package.json with new environment')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

}

function findObject(js, objectStart) {
let braceCount = 1;

const start = js.indexOf("{", objectStart);
const start = js.indexOf('{', objectStart);

if (start < 0) {
return null;
Expand All @@ -38,15 +38,15 @@ function findObject(js, objectStart) {
const c = js[index];

if (!parseBlocker && !parseBlockerBuffer) {
if (c == "{") {
if (c === '{') {
braceCount += 1;
} else if (c == "}") {
braceCount -= 1;
} else if (c === '"' || c === "'" || c === "`") {
parseBlocker = c;
} else if (js[index - 1] == "/") {
if (c == "/") parseBlocker = "\n";
else if (c == "*") parseBlockerBuffer = "*/";
} else if (js[index - 1] === '/') {
if (c === '/') { parseBlocker = "\n"; }
else if (c === "*") { parseBlockerBuffer = "*/"; }
}

if (braceCount === 0) {
Expand All @@ -55,7 +55,7 @@ function findObject(js, objectStart) {
} else {
if (c === parseBlocker) {
parseBlocker = null;
} else if (c == '/' && js[index - 1] == '*') {
} else if (c === '/' && js[index - 1] == '*') {
parseBlockerBuffer = null;
}
}
Expand All @@ -72,43 +72,43 @@ function findObject(js, objectStart) {
}

function replace(str, start, end, replacement) {
return str.substring(0, start) + replacement + str.substring(end + 1, str.length)
return str.substring(0, start) + replacement + str.substring(end + 1, str.length);
}

async function replaceWebConfig() {
const pattern = new RegExp(`^${appName}.*\.js$`)
const basePath = './dist/assets/'
const appJs = (await promisify(fs.readdir)(basePath)).filter(name => name.match(pattern))
const pattern = new RegExp(`^${appName}.*\.js$`);
const basePath = './dist/assets/';
const appJs = (await promisify(fs.readdir)(basePath)).filter(name => name.match(pattern));

const envDefinition = 'define("open-event-frontend/config/environment"'
const envDefinition = 'define("open-event-frontend/config/environment"';

for (const js of appJs) {
const jsPath = basePath + js;
const code = (await promisify(fs.readFile)(jsPath)).toString()
let defineIndex = code.indexOf(envDefinition)
let defineIndex = code.indexOf(envDefinition);

if (defineIndex < 0) {
defineIndex = code.indexOf(envDefinition.replace(/"/g, "'"))
defineIndex = code.indexOf(envDefinition.replace(/"/g, "'"));
if (defineIndex < 0)
continue;
}

const defaultIndex = code.indexOf('default', defineIndex + 1)
const defaultIndex = code.indexOf('default', defineIndex + 1);

if (defaultIndex < 0)
if (defaultIndex < 0) {
continue;

}
// File with environment definition found

console.log('Transforming ' + js)
const object = findObject(code, defaultIndex)
//console.log('Transforming ' + js)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert


const object = findObject(code, defaultIndex);

console.log('Environment Object Found', object)
//console.log('Environment Object Found', object)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert


const webEnvJson = code.substring(object.start, object.end + 1)
const old = safeEval('(' + webEnvJson + ')')

const newEnv = JSON.stringify(merge(old, environment))
const newCode = replace(code, object.start, object.end, newEnv)

Expand Down