* delete package versions action v1 * updated action for build and smoke test * test and error message update * test fix * ci testing * ci testing * ci testing * ci testing * ci test * ci testing * ci test name * docs * docs * docs * test * test * test * docs * usage doc * doc * docs * format test * doc update * doc test * formatting check * scenario update * usage update * format * test * test * test * test * test * table test * test * format update * links * test * test * test * test * test * docs update * test * formatting * fix broken links * doc update * test * table test * test * test * test * test * test * test * test * test * test * test * doc test * test * test * test * test * test * test * test t * test * test * test * test * test * test * docs * doc update
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import {Input} from './input'
|
|
import {Observable, of, throwError} from 'rxjs'
|
|
import {deletePackageVersions, getOldestVersions} from './version'
|
|
import {concatMap, map} from 'rxjs/operators'
|
|
|
|
export function getVersionIds(input: Input): Observable<string[]> {
|
|
if (input.packageVersionIds.length > 0) {
|
|
return of(input.packageVersionIds)
|
|
}
|
|
|
|
if (input.hasOldestVersionQueryInfo()) {
|
|
return getOldestVersions(
|
|
input.owner,
|
|
input.repo,
|
|
input.packageName,
|
|
input.numOldVersionsToDelete,
|
|
input.token
|
|
).pipe(map(versionInfo => versionInfo.map(info => info.id)))
|
|
}
|
|
|
|
return throwError(
|
|
"Could not get packageVersionIds. Explicitly specify using the 'package-version-ids' input or provide the 'package-name' and 'num-old-versions-to-delete' inputs to dynamically retrieve oldest versions"
|
|
)
|
|
}
|
|
|
|
export function deleteVersions(input: Input): Observable<boolean> {
|
|
if (!input.token) {
|
|
return throwError('No token found')
|
|
}
|
|
|
|
if (input.numOldVersionsToDelete <= 0) {
|
|
console.log(
|
|
'Number of old versions to delete input is 0 or less, no versions will be deleted'
|
|
)
|
|
return of(true)
|
|
}
|
|
|
|
return getVersionIds(input).pipe(
|
|
concatMap(ids => deletePackageVersions(ids, input.token))
|
|
)
|
|
}
|