"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _pick() {
const data = _interopRequireDefault(require("lodash/pick"));
_pick = function () {
return data;
};
return data;
}
function _size() {
const data = _interopRequireDefault(require("lodash/size"));
_size = function () {
return data;
};
return data;
}
function _IOSUploader() {
const data = _interopRequireWildcard(require("./upload/IOSUploader"));
_IOSUploader = function () {
return data;
};
return data;
}
function _AndroidUploader() {
const data = _interopRequireDefault(require("./upload/AndroidUploader"));
_AndroidUploader = function () {
return data;
};
return data;
}
function _log() {
const data = _interopRequireDefault(require("../log"));
_log = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const COMMON_OPTIONS = ['id', 'latest', 'path'];
var _default = program => {
const ANDROID_OPTIONS = [...COMMON_OPTIONS, 'key', 'track'];
const androidCommand = program.command('upload:android [projectDir]').alias('ua');
setCommonOptions(androidCommand, '.apk');
androidCommand.option('--key <key>', 'path to the JSON key used to authenticate with Google Play').option('--track <track>', 'the track of the application to use, choose from: production, beta, alpha, internal, rollout', /^(production|beta|alpha|internal|rollout)$/i, 'internal').description('Uploads a standalone Android app to Google Play (works on macOS only). Uploads the latest build by default.').asyncActionProjectDir(createUploadAction(_AndroidUploader().default, ANDROID_OPTIONS));
const IOS_OPTIONS = [...COMMON_OPTIONS, 'appleId', 'appleIdPassword', 'itcTeamId', 'appName', 'sku', 'language', 'publicUrl'];
const iosCommand = program.command('upload:ios [projectDir]').alias('ui');
setCommonOptions(iosCommand, '.ipa');
iosCommand.option('--apple-id <apple-id>', 'your Apple ID username (you can also set EXPO_APPLE_ID env variable)') // apple unified App Store Connect and Developer Portal teams, this is temporary solution until fastlane implements those changes
// https://github.com/fastlane/fastlane/issues/14229
// after updating fastlane this value will be unnecessary
.option('--itc-team-id <itc-team-id>', 'App Store Connect Team ID (optional if there is only one team available)').option('--apple-id-password <apple-id-password>', 'your Apple ID password (you can also set EXPO_APPLE_ID_PASSWORD env variable)').option('--app-name <app-name>', `the name of your app as it will appear on the App Store, this can't be longer than 30 characters (default: expo.name from app.json)`).option('--sku <sku>', 'a unique ID for your app that is not visible on the App Store, will be generated unless provided').option('--language <language>', `primary language (e.g. English, German; run \`expo upload:ios --help\` to see the list of available languages)`, 'English').option('--public-url <url>', 'The URL of an externally hosted manifest (for self-hosted apps)').description('Uploads a standalone app to Apple TestFlight (works on macOS only). Uploads the latest build by default.').on('--help', function () {
console.log('Available languages:');
console.log(` ${_IOSUploader().LANGUAGES.join(', ')}`);
console.log();
}).asyncActionProjectDir(createUploadAction(_IOSUploader().default, IOS_OPTIONS));
};
exports.default = _default;
function setCommonOptions(command, fileExtension) {
command.option('--latest', 'uploads the latest build (default)').option('--id <id>', 'id of the build to upload').option('--path <path>', `path to the ${fileExtension} file`);
}
function createUploadAction(UploaderClass, optionKeys) {
return async (projectDir, command) => {
try {
ensurePlatformIsSupported();
await ensureOptionsAreValid(command);
const options = (0, _pick().default)(command, optionKeys);
if (UploaderClass.validateOptions) {
UploaderClass.validateOptions(options);
}
const uploader = new UploaderClass(projectDir, options);
await uploader.upload();
} catch (err) {
_log().default.error('Failed to upload the standalone app to the app store.');
throw err;
}
};
}
function ensurePlatformIsSupported() {
if (process.platform !== 'darwin') {
_log().default.error('Unsupported platform! This feature works on macOS only.');
process.exit(1);
}
}
async function ensureOptionsAreValid(command) {
const args = (0, _pick().default)(command, COMMON_OPTIONS);
if ((0, _size().default)(args) > 1) {
throw new Error(`You have to choose only one of --path, --id or --latest parameters`);
}
}
//# sourceMappingURL=../__sourcemaps__/commands/upload.js.map