const getSourceFilePaths = () => { return new Promise((resolve, reject) => { glob(SOURCE_PATTERN, (error, files) => { if (error) { reject(error); return; } resolve(files.map(filePath => path.join(process.cwd(), filePath))); }); }); }
runner(process.argv.slice(2), { templates: defaultTemplates, cwd: process.cwd(), logger: new Logger(console.log.bind(console)), debug: !!process.env.DEBUG, exec: (action, body) => { const opts = body && body.length > 0 ? { input: body } : {} return require('execa').command(action, { ...opts, shell: true }) }, createPrompter: () => require('enquirer'), }).then(({ success }) => process.exit(success ? 0 : 1))
/* * Paths to / */ const pathsToRoot = (startFrom = process.cwd()) => { return _(_.range(path.dirname(startFrom).split(path.sep).length)) .map(end => _.dropRight(path.dirname(startFrom).split(path.sep), end).join(path.sep)) .unshift(startFrom) .dropRight() .value(); }
const gitHeadPath = cwd => { const filepath = find('.git/HEAD', { cwd: cwd || process.cwd() }); if (!fs.existsSync(filepath)) { throw new Error('.git/HEAD does not exist'); } return filepath; }
runner(process.argv.slice(2), { templates: defaultTemplates, cwd: process.cwd(), logger: new Logger(console.log.bind(console)), debug: !!process.env.DEBUG, exec: (action, body) => { const opts = body && body.length > 0 ? { input: body } : {}; return require('execa').shell(action, opts); }, createPrompter: () => require('enquirer') });
/* * Helper to map the cwd on the host to the one in the container */ const getContainerPath = appRoot => { // Break up our app root and cwd so we can get a diff const cwd = process.cwd().split(path.sep); const dir = _.drop(cwd, appRoot.split(path.sep).length); // Add our in-container app root // this will always be /app dir.unshift('/app'); // Return the directory return dir.join('/'); }
// Switch the default service for the ssh command if its used lando.events.on('cli-ssh-run', data => { if (_.get(data, 'options._app.recipe') === 'lagoon' && data.options.service === 'appserver') { // Get lagoon config const appRoot = _.get(data, 'options._app.root', process.cwd()); const config = lagoonConf.loadConfigFiles(appRoot); // Find CLI containers const cliServices = _(_.get(config, 'compose.services', {})) .map((service, name) => _.merge({}, service, {name})) .filter(service => _.includes(cliServiceTypes, service.labels['lando.type'])) .map('name') .value(); // Use the first CLI container we find data.options.service = _.first(cliServices); data.options.s = _.first(cliServices); } });
const resolveLuFileContent = function(file, luObjects, srcId) { let parentFilePath = srcId === 'stdin' ? process.cwd() : path.parse(path.resolve(srcId)).dir // Support wild cards at the end of a relative .LU file path. // './bar/*' should look for all .lu files under the specified folder. // './bar/**' should recursively look for .lu files under sub-folders as well. if(file.filePath.endsWith('*')) { const isRecursive = file.filePath.endsWith('**') const rootFolder = file.filePath.replace(/\*/g, '') let rootPath = rootFolder; if(!path.isAbsolute(rootFolder)) { rootPath = path.resolve(parentFilePath, rootFolder); } // Get LU files in this location const luFilesToAdd = helpers.findLUFiles(rootPath, isRecursive); // add these to filesToParse for(let f = 0; f < luFilesToAdd.length; f++){ const opts = new luOptions(luFilesToAdd[f], file.includeInCollate) luObjects.push(new luObject(readLuFile(luFilesToAdd[f]), opts)) } return } if(!path.isAbsolute(file.filePath)) { file.filePath = path.resolve(parentFilePath, file.filePath) } // find matching parsed files and ensure includeInCollate is updated if needed. luObjects.push(new luObject(readLuFile(file.filePath), new luOptions(file.filePath, file.includeInCollate))) }
const rootPath = process.cwd(); let count = 0; const codeLineMap = {};
getApp(startFrom = process.cwd(), warn = true) { const merger = require('./config').merge; const utils = require('./bootstrap');
constructor(baseDir = process.cwd(), log = new Log()) { this.base = baseDir; this.log = log;
const makePgSmartTagsFromFilePlugin = ( tagsFile = process.cwd() + '/postgraphile.tags.json5', ): Plugin => {
}); const rootPath = process.cwd(); let allFiles = []; let fileCount = 0;
/* * Helper to locate the "closest" platform yaml */ const traverseUp = (startFrom = process.cwd()) => { return _(_.range(path.dirname(startFrom).split(path.sep).length)) .map(end => _.dropRight(path.dirname(startFrom).split(path.sep), end).join(path.sep)) .unshift(startFrom) .dropRight() .value(); }