in src/commands/codepush/release-cordova.ts [36:105]
public async run(client: AppCenterClient): Promise<CommandResult> {
if (!(await isValidDeployment(client, this.app, this.specifiedDeploymentName))) {
return failure(ErrorCodes.InvalidParameter, `Deployment "${this.specifiedDeploymentName}" does not exist.`);
} else {
this.deploymentName = this.specifiedDeploymentName;
}
const appInfo = (
await out.progress(
"Getting app info...",
clientRequest<models.AppResponse>((cb) => client.appsOperations.get(this.app.ownerName, this.app.appName, cb))
)
).result;
this.os = appInfo.os.toLowerCase();
this.platform = appInfo.platform.toLowerCase();
if (!isValidOS(this.os)) {
return failure(ErrorCodes.InvalidParameter, `Platform must be either "ios" or "android".`);
}
if (!isValidPlatform(this.platform)) {
return failure(ErrorCodes.Exception, `Platform must be "Cordova".`);
}
if (this.specifiedTargetBinaryVersion) {
this.targetBinaryVersion = this.specifiedTargetBinaryVersion;
} else {
this.targetBinaryVersion = await getCordovaProjectAppVersion();
}
if (!isValidRange(this.targetBinaryVersion)) {
return failure(ErrorCodes.InvalidParameter, "Invalid binary version(s) for a release.");
}
const cordovaCommand: string = this.getCordovaCommand();
let cordovaCLI: string;
try {
cordovaCLI = getCordovaOrPhonegapCLI();
} catch (e) {
return failure(
ErrorCodes.Exception,
`Unable to ${cordovaCommand} project. Please ensure that either the Cordova or PhoneGap CLI is installed.`
);
}
out.text(chalk.cyan(`Running "${cordovaCLI} ${cordovaCommand}" command:\n`));
try {
childProcess.execSync([cordovaCLI, cordovaCommand, this.os, "--verbose"].join(" "), { stdio: "inherit" });
} catch (error) {
debug(`Failed to release a CodePush update - ${inspect(error)}`);
return failure(
ErrorCodes.Exception,
`Unable to ${cordovaCommand} project. Please ensure that the CWD represents a Cordova project and that the "${this.os}" platform was added by running "${cordovaCLI} platform add ${this.os}".`
);
}
try {
this.updateContentsPath = this.getOutputFolder();
} catch (error) {
debug(`Failed to release a CodePush update - ${inspect(error)}`);
return failure(
ErrorCodes.Exception,
`No output folder found. Please ensure that the CWD represents a Cordova project and that the "${this.os}" platform was added by running "${cordovaCLI} platform add ${this.os}".`
);
}
out.text(chalk.cyan("\nReleasing update contents to CodePush:\n"));
return await this.release(client);
}