Move track validation to a separate function
This commit is contained in:
17
lib/edits.js
17
lib/edits.js
@@ -41,6 +41,10 @@ function uploadToPlayStore(options, releaseFiles) {
|
||||
auth: options.auth,
|
||||
packageName: options.applicationId
|
||||
});
|
||||
yield validateSelectedTrack(appEdit.data, options).catch(reason => {
|
||||
core.setFailed(reason);
|
||||
return Promise.reject(reason);
|
||||
});
|
||||
var versionCodes = new Array();
|
||||
releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () {
|
||||
core.debug(`Uploading ${releaseFile}`);
|
||||
@@ -87,11 +91,6 @@ function uploadRelease(appEdit, options, releaseFile) {
|
||||
return Promise.reject(`${releaseFile} is invalid`);
|
||||
}
|
||||
}
|
||||
const allTracks = yield getAllTracks(appEdit, options);
|
||||
if (allTracks == undefined || allTracks.find(value => value.track == options.track) == undefined) {
|
||||
core.setFailed(`Track "${options.track}" could not be found `);
|
||||
return Promise.reject(`No track found for "${options.track}"`);
|
||||
}
|
||||
if (releaseFile.endsWith('.apk')) {
|
||||
const apk = yield uploadApk(appEdit, options, releaseFile);
|
||||
yield uploadMappingFile(appEdit, apk.versionCode, options);
|
||||
@@ -108,14 +107,18 @@ function uploadRelease(appEdit, options, releaseFile) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function getAllTracks(appEdit, options) {
|
||||
function validateSelectedTrack(appEdit, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const res = yield androidPublisher.edits.tracks.list({
|
||||
auth: options.auth,
|
||||
editId: appEdit.id,
|
||||
packageName: options.applicationId
|
||||
});
|
||||
return res.data.tracks;
|
||||
const allTracks = res.data.tracks;
|
||||
if (allTracks == undefined || allTracks.find(value => value.track == options.track) == undefined) {
|
||||
core.setFailed(`Track "${options.track}" could not be found `);
|
||||
return Promise.reject(`No track found for "${options.track}"`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function trackVersionCode(appEdit, options, versionCodes) {
|
||||
|
||||
Reference in New Issue
Block a user