Skip to content

Commit

Permalink
Added the --unstable flag to the ti sdk list command
Browse files Browse the repository at this point in the history
  • Loading branch information
cb1kenobi committed Jun 28, 2022
1 parent bd05fbf commit dceca51
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/commands/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ SdkSubcommands.list = {
releases: {
abbr: 'r',
desc: 'retrieve and print all releases'
},
unstable: {
abbr: 'u',
desc: 'retrieve and print all unstable release candidate (rc) and beta releases'
}
},
options: {
Expand Down Expand Up @@ -143,7 +147,7 @@ async function list(logger, config, cli) {
const os = cli.env.os.name;

const [ releases, branches, branchBuilds ] = (await Promise.allSettled([
cli.argv.releases && getReleases(os),
(cli.argv.releases || cli.argv.unstable) && getReleases(os, cli.argv.unstable),
cli.argv.branches && getBranches(),
cli.argv.branch && getBranchBuilds(cli.argv.branch, os)
])).map(r => {
Expand Down Expand Up @@ -558,7 +562,7 @@ async function install(logger, config, cli) {
let downloadedFile = null;
let file = null;
let url = null;
const releases = await getReleases(osName);
const releases = await getReleases(osName, true);

// step 0: make sure the install location exists

Expand Down Expand Up @@ -1291,18 +1295,19 @@ async function uninstall(logger, config, cli) {
/**
* Retrieves the list of releases.
* @param {String} os - The name of the OS (osx, linux, win32)
* @param {Boolean} [unstable] - When `true`, returns beta and rc releases along with ga releases.
* @returns {Promise<Release[]>}
*/
async function getReleases(os) {
async function getReleases(os, unstable) {
const releaseRE = /^(\d+)\.(\d+)\.(\d+)\.(\w+)$/;
const releaseTypes = [ 'beta', 'rc', 'ga' ];

return (await Promise.allSettled([
got('https://downloads.titaniumsdk.com/registry/beta.json', { responseType: 'json' }).then(res => ({ type: 'beta', releases: res.body })),
got('https://downloads.titaniumsdk.com/registry/rc.json', { responseType: 'json' }).then(res => ({ type: 'rc', releases: res.body })),
unstable && got('https://downloads.titaniumsdk.com/registry/beta.json', { responseType: 'json' }).then(res => ({ type: 'beta', releases: res.body })),
unstable && got('https://downloads.titaniumsdk.com/registry/rc.json', { responseType: 'json' }).then(res => ({ type: 'rc', releases: res.body })),
got('https://downloads.titaniumsdk.com/registry/ga.json', { responseType: 'json' }).then(res => ({ type: 'ga', releases: res.body }))
])).flatMap(r => {
return r.status === 'fulfilled' ? r.value.releases.map(rel => {
return r.status === 'fulfilled' && r.value ? r.value.releases.map(rel => {
rel.type = r.value.type;
return rel;
}) : [];
Expand Down

0 comments on commit dceca51

Please sign in to comment.