@app-masters/js-lib
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -0,0 +0,0 @@ # Changelog |
@@ -12,4 +12,8 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -30,10 +34,11 @@ | ||
key: "setup", | ||
value: function setup(client, packag, envs, storage, callback, customEnv) { | ||
value: function setup(client, version, envs, storage, callback, customEnv) { | ||
// Validate parans | ||
if (!client || ['web', 'mobile', 'admin'].indexOf(client) < 0) throw 'Unrecognized or undefined client: ' + client; // @todo Validate envs | ||
// @todo Validate packag | ||
if (!client || ['web', 'mobile', 'admin'].indexOf(client) < 0) throw 'Unrecognized or undefined client: ' + client; | ||
if (_typeof(version) === "object") throw 'version param should be just a string, like "1.2.3"'; // @todo Validate envs | ||
// @todo Validate storage | ||
if (!callback || !callback.onMinVersionNotSatifies || !callback.onNewVersion || !callback.onUncaughtError) throw 'You must pass callback parameter to AppBootstrap.setup, with onMinVersionNotSatifies, onNewVersion and onUncaughtError methods.'; | ||
AppBootstrap.callbacks = callback; // 1 - Decide env | ||
AppBootstrap.callbacks = callback; | ||
var logs = []; // 1 - Decide env | ||
@@ -44,9 +49,5 @@ var nodeEnv = null; | ||
nodeEnv = customEnv; | ||
console.log('Custom environment provided: ', customEnv); | ||
} else { | ||
nodeEnv = process.env.NODE_ENV; | ||
console.log('Default environment defined: ', process.env.NODE_ENV); | ||
logs.push('Custom environment provided: ' + customEnv); | ||
} | ||
var version = packag.version; | ||
var firebase; | ||
@@ -60,5 +61,5 @@ var buildTime; | ||
buildTimeString = buildTime.toDateString() + ' ' + buildTime.toTimeString(); | ||
console.log('CLIENT:' + client + ' - ENV:' + nodeEnv + ' - VERSION:' + version + ' - RELEASE DATE:' + process.env.APP_RELEASE + ' - BUILD_TIME:' + buildTimeString + ' - FIREBASE:' + firebase); | ||
logs.push('CLIENT: ' + client + ' - ENV: ' + nodeEnv + ' - VERSION: ' + version + ' - RELEASE DATE: ' + process.env.APP_RELEASE + ' - BUILD_TIME: ' + buildTimeString + ' - FIREBASE: ' + firebase); | ||
} else if (__DEV__ !== undefined) { | ||
console.log('MOBILE CLIENT:' + client + ' - ENV:' + nodeEnv + ' - VERSION:' + version); | ||
logs.push('MOBILE CLIENT: ' + client + ' - ENV: ' + nodeEnv + ' - VERSION: ' + version); | ||
} // console.log(envs); | ||
@@ -70,4 +71,3 @@ | ||
if (nodeEnv === 'development' && firebase) { | ||
config = envs['development_firebase']; | ||
console.log('> firebase development <'); | ||
config = envs['development_firebase']; // logs.push('> firebase development <'); | ||
} else { | ||
@@ -87,9 +87,7 @@ config = envs[nodeEnv]; | ||
_index.Rollbar.setup(config.rollbarToken, client + '_' + nodeEnv, process.env.APP_VERSION, nodeEnv); | ||
} else if (client === 'mobile') { | ||
// Config of rollbar for native | ||
console.log('AppBootstrap is not configuring the Rollbar, please check if other source is configuring it.'); | ||
} else if (nodeEnv === 'development') { | ||
console.warn('Rollbar not set on dev. It\'s ok.'); | ||
} else if (client === 'mobile') {// Config of rollbar for native | ||
// console.log('AppBootstrap is not configuring the Rollbar, please check if other source is configuring it.'); | ||
} else if (nodeEnv === 'development') {// console.warn('Rollbar not set on dev. It\'s ok.'); | ||
} else { | ||
throw new Error('You must have Rollbar or bugsnag on your app.'); | ||
throw new Error('You must have Rollbar on your app.'); | ||
} // 3 - Http | ||
@@ -100,3 +98,3 @@ | ||
_index.Http.setup(packag.version, client, nodeEnv, 'application/json'); | ||
_index.Http.setup(version, client, nodeEnv, 'application/json'); | ||
@@ -106,3 +104,3 @@ _index.HttpErrorHandler.setup(callback); // 4 - Moment | ||
moment.updateLocale('pt-br', require('moment/locale/pt-br')); // 5 - Version Check | ||
moment.defineLocale('pt-br', require('moment/locale/pt-br')); // 5 - Version Check | ||
@@ -109,0 +107,0 @@ _index.VersionCheck.setCurrentVersion(client, version); |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -8,4 +8,6 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -12,0 +14,0 @@ |
@@ -12,4 +12,6 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -16,0 +18,0 @@ |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import Http from './dist/http'; |
{ | ||
"name": "@app-masters/js-lib", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "JS lib", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -0,0 +0,0 @@ # JS-Lib |
import * as moment from 'moment'; | ||
import { Http, VersionCheck, Rollbar, HttpErrorHandler, Notification } from './index'; | ||
import {Http, VersionCheck, Rollbar, HttpErrorHandler, Notification} from './index'; | ||
class AppBootstrap { | ||
static setup (client, packag, envs, storage, callback, customEnv) { | ||
static setup(client, version, envs, storage, callback, customEnv) { | ||
@@ -12,4 +12,5 @@ // Validate parans | ||
throw ('Unrecognized or undefined client: ' + client); | ||
if (typeof version === "object") | ||
throw ('version param should be just a string, like "1.2.3"'); | ||
// @todo Validate envs | ||
// @todo Validate packag | ||
// @todo Validate storage | ||
@@ -20,2 +21,3 @@ if (!callback || !callback.onMinVersionNotSatifies || !callback.onNewVersion || !callback.onUncaughtError) | ||
const logs = []; | ||
// 1 - Decide env | ||
@@ -25,8 +27,4 @@ let nodeEnv = null; | ||
nodeEnv = customEnv; | ||
console.log('Custom environment provided: ', customEnv); | ||
} else { | ||
nodeEnv = process.env.NODE_ENV; | ||
console.log('Default environment defined: ', process.env.NODE_ENV); | ||
logs.push('Custom environment provided: ' + customEnv); | ||
} | ||
let version = packag.version; | ||
let firebase; | ||
@@ -39,5 +37,5 @@ let buildTime; | ||
buildTimeString = buildTime.toDateString() + ' ' + buildTime.toTimeString(); | ||
console.log('CLIENT:' + client + ' - ENV:' + nodeEnv + ' - VERSION:' + version + ' - RELEASE DATE:' + process.env.APP_RELEASE + ' - BUILD_TIME:' + buildTimeString + ' - FIREBASE:' + firebase); | ||
logs.push('CLIENT: ' + client + ' - ENV: ' + nodeEnv + ' - VERSION: ' + version + ' - RELEASE DATE: ' + process.env.APP_RELEASE + ' - BUILD_TIME: ' + buildTimeString + ' - FIREBASE: ' + firebase); | ||
} else if (__DEV__ !== undefined) { | ||
console.log('MOBILE CLIENT:' + client + ' - ENV:' + nodeEnv + ' - VERSION:' + version); | ||
logs.push('MOBILE CLIENT: ' + client + ' - ENV: ' + nodeEnv + ' - VERSION: ' + version); | ||
} | ||
@@ -49,3 +47,3 @@ | ||
config = envs['development_firebase']; | ||
console.log('> firebase development <'); | ||
// logs.push('> firebase development <'); | ||
} else { | ||
@@ -66,7 +64,7 @@ config = envs[nodeEnv]; | ||
// Config of rollbar for native | ||
console.log('AppBootstrap is not configuring the Rollbar, please check if other source is configuring it.'); | ||
// console.log('AppBootstrap is not configuring the Rollbar, please check if other source is configuring it.'); | ||
} else if (nodeEnv === 'development') { | ||
console.warn('Rollbar not set on dev. It\'s ok.'); | ||
// console.warn('Rollbar not set on dev. It\'s ok.'); | ||
} else { | ||
throw new Error('You must have Rollbar or bugsnag on your app.'); | ||
throw new Error('You must have Rollbar on your app.'); | ||
} | ||
@@ -76,7 +74,7 @@ | ||
Http.setBaseURL(config.baseUrl); | ||
Http.setup(packag.version, client, nodeEnv, 'application/json'); | ||
Http.setup(version, client, nodeEnv, 'application/json'); | ||
HttpErrorHandler.setup(callback); | ||
// 4 - Moment | ||
moment.updateLocale('pt-br', require('moment/locale/pt-br')); | ||
moment.defineLocale('pt-br', require('moment/locale/pt-br')); | ||
@@ -117,3 +115,3 @@ // 5 - Version Check | ||
// 8 - Notification | ||
if(config.notification){ | ||
if (config.notification) { | ||
Notification.setup(config.notification); | ||
@@ -125,15 +123,15 @@ } | ||
static onUncaughtError () { | ||
static onUncaughtError() { | ||
return AppBootstrap.callbacks.onUncaughtError; | ||
} | ||
static onMinVersionNotSatifies () { | ||
static onMinVersionNotSatifies() { | ||
return AppBootstrap.callbacks.onMinVersionNotSatifies; | ||
} | ||
static onNewVersion () { | ||
static onNewVersion() { | ||
return AppBootstrap.callbacks.onNewVersion; | ||
} | ||
static getConfig () { | ||
static getConfig() { | ||
return AppBootstrap.config; | ||
@@ -146,2 +144,2 @@ } | ||
export default AppBootstrap; | ||
export default AppBootstrap; |
@@ -0,0 +0,0 @@ import moment from 'moment'; |
@@ -0,0 +0,0 @@ // This file is used just to make "storage" work. |
@@ -0,0 +0,0 @@ export default function setup (accessToken, env, version, logOnDev, initializedCallback) { |
@@ -0,0 +0,0 @@ import HttpErrorHandler from './httpErrorHandler'; |
@@ -0,0 +0,0 @@ import Rollbar from './rollbar'; |
@@ -0,0 +0,0 @@ import Http from './http'; |
@@ -0,0 +0,0 @@ |
@@ -0,0 +0,0 @@ import Rollbar from './rollbar'; |
@@ -0,0 +0,0 @@ import NotificationWeb from './notificationWeb'; |
@@ -0,0 +0,0 @@ class NotificationCordova { |
@@ -0,0 +0,0 @@ import Http from './http'; |
@@ -0,0 +0,0 @@ import Text from './text'; |
@@ -0,0 +0,0 @@ const Plural = (function () { |
@@ -0,0 +0,0 @@ import rbar from './dependencies/rollbar'; |
@@ -0,0 +0,0 @@ import FlexStorage from './dependencies/flexStorage'; |
@@ -0,0 +0,0 @@ class Text { |
@@ -0,0 +0,0 @@ let minActualClientVersion = null; |
@@ -0,0 +0,0 @@ /* global test, expect */ |
@@ -0,0 +0,0 @@ /* global test, expect, jest */ |
@@ -0,0 +0,0 @@ /* global test, expect, jest */ |
@@ -0,0 +0,0 @@ const localStorageMock = (function () { |
@@ -0,0 +0,0 @@ import Plural, {pluralize, config} from '../dist/plural'; |
@@ -0,0 +0,0 @@ const envs = {}; |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
243850
58
5283
11
3