const parseDependencies = (functionStr) => { const parsed = babylon.parse(functionStr, { sourceType: 'script' }); // get the first argument of the function, then get its desctructued properties const properties = f.flow( f.get('program.body.0.expression.params.0.properties'), f.map('key.name') )(parsed); return properties; }
const createProtocallResolver = options => { const protocallResolver = _.get('noDefaultProtocols', options) ? new protocall.Resolver() : protocall.getDefaultResolver(_.getOr(process.cwd(), 'baseDir', options)); if (_.has('protocols', options)) protocallResolver.use(options.protocols); return protocallResolver; }
program .command('android:package [project-dir]') .description('Prints the android package name for a given project (reads from app.json)') .action(act(async (dir) => { const projectManifest = await readBuildManifest(dir); const path = ['android', 'package']; const packageName = F.get(path, projectManifest); if (isEmpty(packageName)) { const message = `Couldn't find a value associated with "${path.join('.')}" in your project's app.json`; console.log(chalk.red(message)); return false; } console.log(packageName); return true; }, true));
const resolveProtocalls = (nconf, resolver, preseveBuffer) => { const originalValues = nconf.load(); return resolver.resolve(originalValues).then(resolvedValues => { const paths = getPaths(originalValues); for (const path of paths) { const resolvedValue = _.get(path, resolvedValues); if (_.get(path, originalValues) !== resolvedValue) nconf.set( path.join(':'), _.isBuffer(resolvedValue) && !preseveBuffer ? resolvedValue.toString() : resolvedValue ); } }); }
async function ensureNoInProgressBuilds (projectManifest, expState) { try { if (isStatusInProgress(await buildStatus(projectManifest, expState))) { return false; } return true; } catch (error) { const message = F.get(['response', 'body', 'err'], error); if (message === 'This experience is missing a name and cannot be published.') { // user never published this app before, aka no build in process // not ideal check as message can change, but will work for now until check:status is deprecated return true; } throw error; } }
// Definition of associated actions below /** * Process the hook for a given step * @param nconf nconf instance * @param hooks defined hooks * @param stepName * @returns {Function} */ const processHook = (nconf, hooks, stepName) => { const hook = _.get(stepName, hooks); if (hook) return hook(nconf); }