$scope.boot = function () { $scope.data = conf.get('apns') $scope.data.apns_payload_str = '{"aps":{"alert":"modified alert","badge":10}}' conf.set('apns_config', defaults) $scope.config = conf.get('apns_config') $scope.data.certificates_exists = $scope.checkCertificates() }
/** * * @param {Object} options function parameters * @param {String} [options.functionRequireName] used to require module * @param {String} [options.functionInstallName] used to install module * @param {Function} callback handle results */ function serveIncomingFunction (options, callback) { if (!options.functionRequireName) { callback(null, conf.get(PORTS)) return } var args = getArgs(options) var nextPortOptions = { registeredPorts: conf.get(PORTS), basePort: BASE_PORT } nextPort(nextPortOptions, function (error, port) { if (error) { callback(error) return } addPort({ name: options.functionRequireName, port: port }) args.push('--port') args.push(port) var startChildProcessOptions = { functionRequireName: options.functionRequireName, args: args } startChildProcess(startChildProcessOptions, callback) }) }
// Get translations function localize() { if (!conf.get('general.locale')) { conf.set('general.locale', app.getLocale()); } i18n.setLocale(conf.get('general.locale')); }
}, (err) => { if (err) { log.error(err) } let memory = _.split(batteryData['memory'], ' ') let iodisk = _.split(batteryData['iodisk'][1], ' ') let network = _.split(batteryData['network'], ' ') let download = Math.round(parseFloat(network[0])) let upload = Math.round(parseFloat(network[1])) let batteryObject = { 'remaining_time_minutes': utils.hoursToMinutes( Math.round((parseInt(batteryData['energynow']) / parseInt(batteryData['powernow'])) * 100) / 100), 'power_rate_w': Math.round(parseInt(batteryData['powernow'] / 10000)) / 100, 'remaining_capacity_percent': parseInt(batteryData['capacity']), 'voltage_v': Math.round(parseInt(batteryData['voltage-now'] / 10000)) / 100, 'charging_bool': batteryData['status'] === 'Charging', 'discharging_bool': batteryData['status'] === 'Discharging', 'ac_connected_bool': batteryData['ac-connected'] === '1', 'brightness_percent': Math.round((parseInt(batteryData['current-screen-light']) * 100 ) / parseInt(batteryData['max-screen-light'])), 'memory_percent': Math.round((parseInt(memory[1]) * 100) / parseInt(memory[0])), 'memory_mb': parseInt(memory[0]), 'read_request_per_s': parseInt(iodisk[0]), 'read_kb_per_s': parseInt(iodisk[1]), 'write_request_per_s': parseInt(iodisk[2]), 'write_kb_per_s': parseInt(iodisk[3]), 'cpu_usage_percent': 100 - parseInt(batteryData['cpu']), 'download_kb': download, 'upload_kb': upload, 'dm_enabled': !!conf.get('dm-already-start') } batteryObject = utils.standardizeNumberObject(batteryObject) if (monitorType === enums.LinuxPowerMonitor.BATTERY) { if (conf.get('logging-enabled')) { firebase.saveBatteryLogging(batteryObject) } let powerData = { 'ac_connected_bool': batteryObject['ac_connected_bool'], 'estimated_power_save_w': powerModel.powerSaveEstimate(batteryObject), 'estimated_power_consume_w': powerModel.powerNormalEstimate(batteryObject) } if (conf.get('dm-already-start')) { monitor.calculateSavedEnergy(powerData) } db.runQuery({ 'fn': 'addBattery', 'params': powerData }) } else if (monitorType === enums.LinuxPowerMonitor.BATTERY_FIRST_PROFILE) { db.runQuery({ 'fn': 'addBatteryFirstProfile', 'params': { 'estimated_power_save_w': powerModel.powerSaveEstimate(batteryObject), 'estimated_power_consume_w': powerModel.powerNormalEstimate(batteryObject) } }) } })
function getStatistics() { if (conf.has('saved-minutes')) { minutesSaved.text(conf.get('saved-minutes')) } if (conf.has('saved-energy-watts-second')) { let savedEnergy = Math.round((conf.get('saved-energy-watts-second') / 3600) * 1000) / 1000 energySaved.text(savedEnergy) moneySaved.text(Math.round((savedEnergy / 1000) * config.ELECTRICITY_PRICE_EURO_PER_KWH * 10000) / 10000) } }
function checkPowerControlSettings() { if (conf.get('dim-screen')) { dimScreen.prop('checked', true) } if (conf.get('turn-off-screen')) { turnOffScreenIdle.prop('checked', true) } if (conf.get('suspend-computer')) { suspendIdle.prop('checked', true) } }
function monitorIdle() { if (conf.get('turn-off-screen') || conf.get('suspend-computer')) { if (idle.getIdleTime() >= config.MONITOR_IDLE_TIMEOUT) { if (conf.get('suspend-computer') && idle.getIdleTime() >= config.MONITOR_IDLE_TIMEOUT_SUSPEND) { suspendComputer() } else if (conf.get('turn-off-screen')) { turnScreenOff() } } } }
function checkIfRegisteredUser() { if (conf.get('register-email')) { registered.show() registeredEmail.text(conf.get('register-email')) } else { $.getScript('../assets/bower_components/firebase/firebase.js', (data, textStatus, jqxhr) => { firebase.initializeApp(firebaseConfig) // jshint ignore:line notRegistered.show() }) } }
/** * Prompts for data tracking permission and sets up the global opt-in. */ function handleAppInsights(yo) { // Config is stored at: ~/.config/configstore/generator-docker.json var config = new Configstore(pkg.name); if (config.get('runningTests') !== undefined) { return; } if (config.get(AppInsightsOptInName) === undefined) { var done = yo.async(); var q = { type: 'confirm', name: 'optIn', message: 'Generator-docker would like to collect anonymized data\n' + 'on the options you selected to understand and improve your experience.\n' + 'To opt out later, you can delete ' + chalk.red('~/.config/configstore/' + pkg.name + '.json.\n') + 'Will you help us help you and your fellow developers?', default: true }; yo.prompt(q, function (props) { trackData = props.optIn; // Set the userId only if user opted-in. userId = trackData ? uuid.v1() : ''; config.set(AppInsightsOptInName, trackData); config.set(AppInsightsUserIdName, userId); var client = appInsights.getClient(AppInsightsKey); client.config.maxBatchIntervalMs = 1000; appInsights.setup(AppInsightsKey).start(); client.trackEvent('YoDockerCollectData', { 'opt-in': trackData.toString(), 'userId': userId }); appInsights.setAutoCollectPerformance(false); done(); }.bind(yo)); } else { trackData = config.get(AppInsightsOptInName); userId = config.get(AppInsightsUserIdName); // Create a user Id for opted-in users. if (trackData && userId === undefined) { userId = uuid.v1(); config.set(AppInsightsUserIdName, userId); } } }
function startDM() { conf.set('dm-already-stop', false) if (!conf.get('dm-already-start')) { conf.set('dm-already-start', true) conf.set('started-running', new Date()) notify('Demand control is activated.') firebase.startDM() if (conf.get('dim-screen')) { toggleDimScreen(true) } monitorIdleInterval = setInterval(monitorIdle, config.MONITOR_IDLE) } }
function stashUnstash (arg, value) { var clc = require('cli-color'); var Configstore = require('configstore'); var pkg = require('./package.json'); var logSymbols = require('log-symbols'); var conf = new Configstore(pkg.name); if (arg === 'stash') { require('./stats-module.js').getBalance(function (err, balance) { if (err) { console.error(err); process.exit(1); } if (balance - value < 0) { console.log(logSymbols.error + clc.red(" You don't have that much in your wallet!")); console.log(clc.green('Credit into the wallet, before stashing away.')); } else { conf.set('stashed', conf.get('stashed') === undefined ? 0 : conf.get('stashed') + value); var expenseObject = { reason: 'Credit into stash', category: 'Stash', credit: '', debit: value }; console.log(logSymbols.success + clc.green(' Stashed')); require('./file-module.js').writeExpense(expenseObject); } }); } else if (arg === 'unstash') { if (conf.get('stashed')) { if ((conf.get('stashed') - value) < 0) { console.log(logSymbols.error + clc.red(" You don't have that much in your stash!")); } else { conf.set('stashed', conf.get('stashed') - value); console.log(logSymbols.success + clc.green(' Withdrawn from stash, credited into the wallet!')); var expenseObject = { reason: 'Withdrawn from stash', category: 'Stash', credit: value, debit: '' }; require('./file-module.js').writeExpense(expenseObject); } } else { console.log(logSymbols.error + clc.red(" You don't have that much in your stash!")); } } }
function stopDM() { conf.set('dm-already-start', false) if (!conf.get('dm-already-stop')) { conf.set('dm-already-stop', true) monitor.calculateSavedMinutes() notify('Demand control is deactivated. Thank you for your participation.') firebase.stopDM() if (conf.get('dim-screen')) { toggleDimScreen(false) } if (monitorIdleInterval) { clearInterval(monitorIdleInterval) } } }
this.prompt(prompts, function (props) { verbConfig.set('username', props.username); verbConfig.set('author', { name: props.authorname, url: props.authorurl }); this.authorname = verbConfig.get('author').name; this.authorurl = verbConfig.get('author').url; this.username = verbConfig.get('username'); this.projectname = props.projectname; this.projectdesc = props.projectdesc; cb(); }.bind(this));
function addPort (options) { var ports = conf.get(PORTS) || {} ports[options.name] = options.port conf.set(PORTS, ports) }
function checkIfAppRunning() { if (remote.require('./lib/monitor').shouldAppBeRunning()) { appPaused.hide() appRunning.show() } else { appPaused.show() appRunning.hide() } if (conf.get('dm-already-start')) { dmRunningNo.hide() dmRunningYes.show() powerSaveRunningNo.hide() powerSaveRunningYes.show() } else { dmRunningNo.show() dmRunningYes.hide() powerSaveRunningNo.show() powerSaveRunningYes.hide() } }
/* Prepares app to run */ function startupRoutine() { // Get screen (display) object screen = electron.screen; // Localize (set i18n stuff) localize(); // Set menu createMenu(); // Creates window mainWindow = new BrowserWindow({ title: appName, height: 700, width: 900, center: true, titleBarStyle: 'hidden', icon: Path.join(__dirname, 'gfx', 'app-icon.png'), skipTaskbar: conf.get('general.mode') === 'tray', }); // Open DevTools and maximize in debug mode if (debug) { mainWindow.openDevTools(); mainWindow.maximize(); } /* In case of closing main window */ mainWindow.on('close', () => { app.quit(); }); startApp(); }
$scope.apns_upload_certificate = function(){ var filename = $scope.data.p12_certificate if(filename && fs.existsSync(filename)){ var base = path.dirname(filename) if(!fs.existsSync(path.join(base, 'certificates'))){ fs.mkdir(path.join(base, 'certificates')); } var defaults = {'certFilePath': path.join(base, '/certificates/cert.pem'), 'keyFilePath': path.join(base, '/certificates/key.pem'), 'writeFilename': path.join(base, 'certificates/certificate.p12')} conf.set('apns_config', defaults) $scope.config = conf.get('apns_config') // filename='/Users/pranav/Downloads/VESSEL.p12' var writeFilename = $scope.config.writeFilename try{ data = fs.readFileSync(filename) console.log(data, writeFilename) res = fs.writeFileSync(writeFilename, data) growl.success("Certificate uploaded.") $scope.generateKeys() $scope.data.certificates_exists = $scope.checkCertificates() }catch(e){ console.log(__dirname) growl.error('Check password once', {'title':"Unable to use given certificate."}) console.log(e) } }else{ growl.error("Certificate path is not correct.") } }
function showStats () { var expensesFilepath = xdgBasedir.data + '/wallet/expenses.csv'; var stream = fs.createReadStream(expensesFilepath); var totalCredit = 0.0; var totalDebit = 0.0; var totalStashed = conf.get('stashed'); csv .fromStream(stream) .transform(function (data) { return { 'date': data[0], 'reason': data[1], 'category': data[2], 'credit': numberIsNan(parseFloat(data[3])) ? 0.0 : parseFloat(data[3]), 'debit': numberIsNan(parseFloat(data[4])) ? 0.0 : parseFloat(data[4]) }; }) .on('data', function (data) { totalDebit += data.debit; totalCredit += data.credit; }) .on('end', function () { var result = [ '', 'Total Credit : ' + clc.blue(totalCredit), 'Total Debit : ' + clc.blue(totalDebit), clc.green('Balance : ') + clc.blue(totalCredit - totalDebit), clc.green('Stashed : ') + clc.blue(totalStashed), '' ].join('\n'); console.log(result); }); }
npm.load({}, function(err) { if (err) { exitOnError(err); } const url = conf.get(pkg); url ? open(url) : fetchUrl(pkg); function fetchUrl(pkg) { const proxyquire = require('proxyquire'); const repo = proxyquire('npm/lib/repo', { opener: function(url) { open(url); conf.set(pkg, url); } }); repo([pkg], exitOnError); }; function open(url) { opener(url, { command: NODE_ENV === 'test' ? 'echo' : npm.config.get('browser') }, exitOnError); } });
// Usage stats function Stats(enabled) { this.timer = {}; if (enabled === true) { const config = new Configstore(pkg.name); let clientID = uuidv4(); if (config.has('clientID')) { clientID = config.get('clientID'); } else { config.set('clientID', clientID); } const tracker = ua(trackingID, clientID); tracker.set('aip', 1); // Anonymize IP tracker.set('an', 'frontail'); // Application Name tracker.set('av', pkg.version); // Application Version tracker.set('ds', 'app'); // Data Source tracker.set('cd1', process.platform); // platform tracker.set('cd2', process.arch); // arch tracker.set('cd3', process.version.match(/^v(\d+\.\d+)/)[1]); // Node version tracker.set('cd4', isDocker()); // is Docker this.tracker = tracker; } return this; }
function listAll() { var tarifaPlugins = JSON.parse(fs.readFileSync(path.join(__dirname, '../plugins.json'))), conf = new Configstore('tarifa'), userPlugins = conf.get('plugins'); if(userPlugins) return tarifaPlugins.concat(userPlugins); else return tarifaPlugins; }
.then(result => { const data = result.stdout.trim().split('/'); projectId = `${data[data.length - 2]}-${data[data.length - 1]}`.replace(/\W/g, '-'); projectStore = store.get(projectId) || {}; return globby(process.argv[2] && process.argv[2].split(' ') || ['**/*.js', '!node_modules/**']); })
.action(function() { var conf = new Configstore('foso', { plugins: [] }); var plugins = conf.get('plugins'); plugins.forEach(function(plugin) { console.log(plugin.name); }); });
function createWindow () { mainWindow = new BrowserWindow({width: 500, height: 500, frame: false, "node-integration": false, preload: __dirname + '/app/js/preloadInit.js'}); mainWindow.setBounds(conf.get('windowBounds')); mainWindow.loadURL('file://' + __dirname + '/app/index.html'); mainWindow.on('closed', function() { mainWindow = null; }); }
getUUID: function() { var configStore = new ConfigStore('ember-cordova'); var id = configStore.get('uuid'); if (id === undefined) { id = uuid.v4().toString(); configStore.set('uuid', id); } return id; },
this.prompt(prompts, function (answers) { baseConfig.set('username', answers.username); baseConfig.set('author', { name: answers.authorname, url: answers.authorurl }); this.authorname = baseConfig.get('author').name; this.authorurl = baseConfig.get('author').url; this.username = baseConfig.get('username'); this.projectname = answers.projectname; this.projectdesc = answers.projectdesc; if (/^generator/.test(this.appname)) { this.generatorName = this.appname.replace(/^generator-/, ''); } cb(); }.bind(this));
module.exports.listAvailable = function() { var tarifaPlugins = JSON.parse(fs.readFileSync(path.join(__dirname, '../plugins.json'))), conf = new Configstore('tarifa'), userPlugins = conf.get('plugins'); tarifaPlugins = tarifaPlugins.filter(function (plugin) { return !plugin["default"]; }); if(userPlugins) return tarifaPlugins.concat(userPlugins); else return tarifaPlugins; };
function checkIfLimitedActivitySet() { if (conf.get('limited-activity')) { timeLimitStart.prop('disabled', false) timeLimitUpEnd.prop('disabled', false) } else { timeLimitUpCheckBox.prop('checked', true) } let startTime = conf.get('limited-activity-start-time') if (startTime !== undefined) { timeLimitStart.val(startTime) } let endTime = conf.get('limited-activity-end-time') if (endTime !== undefined) { timeLimitUpEnd.val(endTime) } }
module.exports = function(callback) { if (conf.get("authenticated_at")) { return callback(); } console.log( wrap( "Wunderline needs application credentials before continuing... please run `wunderline auth` and follow the instructions. More info: http://git.io/vOzAn" ) ); };
function updateNotifier() { if (!config.get('lastUpdateCheck')) { config.set('lastUpdateCheck', Date.now()); } if (Date.now() - config.get('lastUpdateCheck') >= updateCheckInterval) { checkVersion().then(function(latestVersion) { config.set('lastUpdateCheck', Date.now()); var currentVersion = getCurrentVersion(); if (semver.lt(currentVersion, latestVersion)) { console.log(String('Origami Build Tools update available: ').bold + String(latestVersion).bold.green + ' ' + String('(current: ' + currentVersion + ')').grey); console.log(String('Run ').bold + String('npm install -g origami-build-tools').bold.blue + String(' to update.').bold); } }, function(error) { log.primary('An error occured when trying to get latest version of origami-build-tools:'); log.secondaryError(error); }); } }