export default function() { m.route( document.body, prefix("/setup"), keys({ "/setup" : setup }, function(value, key) { return prefix(key); }) ); }
function serializeDebugInfo(options) { // Apply defaults. const { sanitize } = Object.assign({ sanitize: true }, options) const unsanitized = { tokens: githubUserTokens, reqRemaining: mapToObject(reqRemaining), reqReset: mapToObject(reqReset), utcEpochSeconds: utcEpochSeconds(), sanitized: false, } if (sanitize) { return { tokens: unsanitized.tokens.map(k => sha(k)), reqRemaining: mapKeys(unsanitized.reqRemaining, (v, k) => sha(k)), reqReset: mapKeys(unsanitized.reqReset, (v, k) => sha(k)), utcEpochSeconds: unsanitized.utcEpochSeconds, sanitized: true, } } else { return unsanitized } }
return result.map(function(row) { row = mapKeys(pick(row, keys), function(v, k) { return keyMap[k] || k; }); // Attempt to maximize compatibility with v0.5.0 (working against the g:P // Legacy API) row.domain = row.domain.replace(/^GO\:/, ''); row.subgraph = '1'; row.depth = '1'; row.intersection = []; return row; });
module.exports = function translateKeys(oldToNewMap, obj) { if (typeof obj !== "object") { throw new Error("needs an object"); } return mapKeys(obj, function (value, oldKey) { var newKey = oldToNewMap[oldKey]; if (newKey == null) { throw new Error("Key not found in translator."); } return newKey; }); };
function * run (context, heroku) { const reduce = require('lodash.reduce') const pickBy = require('lodash.pickby') const mapKeys = require('lodash.mapkeys') function lastRelease () { return heroku.request({ method: 'GET', partial: true, path: `/apps/${context.app}/releases`, headers: {Range: 'version ..; order=desc,max=1'} }).then((releases) => releases[0]) } let vars = reduce(context.args, function (vars, v) { let idx = v.indexOf('=') if (idx === -1) { cli.error(`${cli.color.cyan(v)} is invalid. Must be in the format ${cli.color.cyan('FOO=bar')}.`) process.exit(1) } vars[v.slice(0, idx)] = v.slice(idx + 1) return vars }, {}) let config yield cli.action( `Setting ${context.args.map((v) => cli.color.configVar(v.split('=')[0])).join(', ')} and restarting ${cli.color.app(context.app)}`, {success: false}, co(function * () { config = yield heroku.request({ method: 'patch', path: `/apps/${context.app}/config-vars`, body: vars }) let release = yield lastRelease() cli.action.done(`done, ${cli.color.release('v' + release.version)}`) }) ) config = pickBy(config, (_, k) => vars[k]) config = mapKeys(config, (_, k) => cli.color.green(k)) cli.styledObject(config) }
export default function() { m.route(document.body, prefix("/"), keys({ "/" : auth(home), "/login" : login, "/logout" : logout, "/content/new" : auth(schemaNew), "/content/:schema" : auth(edit), "/content/:schema/edit" : auth(schemaEdit), "/content/:schema/:id" : auth(edit), "/..." : { view : function() { return m("h1", "404"); } } }, function(value, key) { return prefix(key); })); }
getAttributesCamelCase(picker) { return mapKeys(this.getAttributes(picker), (value, key) => changeCase.camel(key)); }
getAttributesSnakeCase(picker) { return mapKeys(this.getAttributes(picker), (value, key) => changeCase.snake(key)); }