/* * Post our key */ postKey(key) { const postKey = ['users', _.get(this.session, 'user_id'), 'keys']; const options = (this.mode === 'node') ? {headers: {'User-Agent': 'Terminus/Lando'}} : {}; const data = _.trim(fs.readFileSync(key, 'utf8')); return pantheonRequest(this.request, this.log, 'post', postKey, JSON.stringify(data), options); }
compose('getId', data).then(id => { if (!_.isEmpty(id)) { // @todo: this assumes that the container we want // is probably the first id returned. What happens if that is // not true or we need other ids for this service? const ids = id.split('\n'); return docker.scan(_.trim(ids.shift())); } })
// Helper to get sites for autocomplete const getAutoCompleteSites = (answers, lando, input = null) => { const api = new PlatformshApiClient({api_token: _.trim(answers['platformsh-auth'])}); if (!_.isEmpty(platformshSites)) { return lando.Promise.resolve(platformshSites).filter(site => _.startsWith(site.name, input)); } else { return api.getAccountInfo().then(me => { platformshSites = _.map(me.projects, project => ({name: project.title, value: project.name})); return platformshSites; }) .catch(err => lando.Promise.reject(Error(err.error_description))); } }
shell.sh(['git', 'describe', '--tags', '--always', '--abbrev=1'], {mode: 'collect'}) // Trim the tag .then(data => _.trim(data.slice(1))) // Replace the version for our files .then(version => { const packageJson = require('./../package.json'); packageJson.version = version; log.info('Updating package.json to dev version %s', packageJson.version); fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2)); }) // Catch errors and do stuff so we can break builds when this fails .catch(error => { log.error(error); process.exit(error.code || 555); })
// Helper to post a github ssh key const postKey = (keyDir, token) => { // Auth github.authenticate({type: 'token', token}); // Post key return github.users.createKey({ title: 'lando', key: _.trim(fs.readFileSync(path.join(keyDir, `${gitHubLandoKey}.pub`), 'utf8')), }) // Catch key already in use error .catch(err => { const message = JSON.parse(err.message); // Report error for everything else if (_.has(message.errors, '[0].message') && message.errors[0].message !== 'key is already in use') { throw Error(throwError(err)); } }); }
/* * Helper to build mac docker version get command */ const getMacProp = prop => shell.sh(['defaults', 'read', `${macOSBase}/Contents/Info.plist`, prop]) .then(data => _.trim(data)) .catch(() => null)
const pageSize: number = 20; let articles: Article[]; keyword = _.trim(keyword || ''); keyword = decodeURIComponent(keyword); if (keyword) {
// Handle build steps // Go through each service and run additional build commands as needed app.events.on('post-init', () => { // Add in build hashes app.meta.lastPreBuildHash = _.trim(lando.cache.get(app.preLockfile)); app.meta.lastPostBuildHash = _.trim(lando.cache.get(app.postLockfile)); // Make sure containers for this app exist; if they don't and we have build locks, we need to kill them const buildServices = _.get(app, 'opts.services', app.services); app.events.on('pre-start', () => { return lando.engine.list({project: app.project, all: true}).then(data => { if (_.isEmpty(data)) { lando.cache.remove(app.preLockfile); lando.cache.remove(app.postLockfile); } }); }); // Queue up both legacy and new build steps app.events.on('pre-start', 100, () => { const preBuild = utils.filterBuildSteps(buildServices, app, preRootSteps, preBuildSteps, true); return utils.runBuild(app, preBuild, app.preLockfile, app.configHash); }); app.events.on('post-start', 100, () => { const postBuild = utils.filterBuildSteps(buildServices, app, postRootSteps, postBuildSteps); return utils.runBuild(app, postBuild, app.postLockfile, app.configHash); }); });
if (code !== 0 && _.isEmpty(stderr)) stderr = _.trim(_.last(_.compact(stdout.split(os.EOL))));
dStrs.map(function (dStr, n) { var place = _.trim(pStrs[n]) || ''; var res = _.words(dStr, /[\S]+/g); var parity = _.startsWith(place, '单')? 1: (_.startsWith(place, '双')? 2: 4); if(parity !== 4) { place = _.words(place, /\S+/g)[1]; } var day = Encoder.parseDayofWeek(res[0]); var indexes = Encoder.parseIndexes(res[1]); var weeks = Encoder.parseWeeks(res[2], parity); return new Duration(weeks, day, indexes, place); })
convertToConditionArgs(matched) { return matched ? [ _.compact( _.trim(matched[1]) .split(',') .map((str) => str.replace(/["'“”]/g, ''))), !_.startsWith(matched[0], '-'), ] : [] }