diff --git a/src/commands/url.js b/src/commands/url.js index 592bcb2..1580658 100644 --- a/src/commands/url.js +++ b/src/commands/url.js @@ -1,4 +1,5 @@ import chalk from 'chalk'; +import fp from 'lodash/fp'; import { Project, UrlUtils } from 'xdl'; @@ -6,6 +7,21 @@ import CommandError from '../CommandError'; import log from '../log'; import urlOpts from '../urlOpts'; +const logArtifactUrl = (platform) => async (projectDir, options) => { + const res = await Project.buildAsync(projectDir, { current: false, mode: 'status' }); + const url = fp.compose( + fp.get(['artifacts', 'url']), + fp.head, + fp.filter(job => platform && job.platform === platform), + fp.getOr([], 'jobs') + )(res); + if (url) { + log.nested(url); + } else { + throw new Error(`No ${platform} binary file found. Use "exp build:${platform}" to create one.`); + } +} + async function action(projectDir, options) { await urlOpts.optsAsync(projectDir, options); @@ -35,4 +51,16 @@ export default program => { .allowOffline() .allowNonInteractive() .asyncActionProjectDir(action, /* skipProjectValidation: */ true, /* skipAuthCheck: */ true); + + program + .command('url:ipa [project-dir]') + .description('Displays the standalone iOS binary URL you can use to download your app binary') + .allowNonInteractive() + .asyncActionProjectDir(logArtifactUrl('ios'), true); + + program + .command('url:apk [project-dir]') + .description('Displays the standalone Android binary URL you can use to download your app binary') + .allowNonInteractive() + .asyncActionProjectDir(logArtifactUrl('android'), true); };