本文整理汇总了TypeScript中builder-util-runtime.githubUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript githubUrl函数的具体用法?TypeScript githubUrl怎么用?TypeScript githubUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了githubUrl函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
protected constructor(protected readonly options: GithubOptions, defaultHost: string, runtimeOptions: ProviderRuntimeOptions) {
super({
...runtimeOptions,
/* because GitHib uses S3 */
isUseMultipleRangeRequest: false,
})
this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
const apiHost = defaultHost === "github.com" ? "api.github.com" : defaultHost
this.baseApiUrl = newBaseUrl(githubUrl(options, apiHost))
}
示例2: getLatestVersion
async getLatestVersion(): Promise<UpdateInfo> {
const basePath = this.basePath
const cancellationToken = new CancellationToken()
const feedXml: string = (await this.httpRequest(newUrlFromBase(`${basePath}.atom`, this.baseUrl), {
Accept: "application/xml, application/atom+xml, text/xml, */*",
}, cancellationToken))!
const feed = parseXml(feedXml)
const latestRelease = feed.element("entry", false, `No published versions on GitHub`)
let version: string | null
try {
if (this.updater.allowPrerelease) {
// noinspection TypeScriptValidateJSTypes
version = latestRelease.element("link").attribute("href").match(/\/tag\/v?([^\/]+)$/)!![1]
}
else {
version = await this.getLatestVersionString(basePath, cancellationToken)
}
}
catch (e) {
throw newError(`Cannot parse releases feed: ${e.stack || e.message},\nXML:\n${feedXml}`, "ERR_UPDATER_INVALID_RELEASE_FEED")
}
if (version == null) {
throw newError(`No published versions on GitHub`, "ERR_UPDATER_NO_PUBLISHED_VERSIONS")
}
const channelFile = getChannelFilename(getDefaultChannelName())
const channelFileUrl = newUrlFromBase(this.getBaseDownloadPath(version, channelFile), this.baseUrl)
const requestOptions = this.createRequestOptions(channelFileUrl)
let rawData: string
try {
rawData = (await this.executor.request(requestOptions, cancellationToken))!!
}
catch (e) {
if (!this.updater.allowPrerelease && e instanceof HttpError && e.statusCode === 404) {
throw newError(`Cannot find ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND")
}
throw e
}
const result = parseUpdateInfo(rawData, channelFile, channelFileUrl)
if (isUseOldMacProvider()) {
(result as any).releaseJsonUrl = `${githubUrl(this.options)}/${requestOptions.path}`
}
if (result.releaseName == null) {
result.releaseName = latestRelease.elementValueOrEmpty("title")
}
if (result.releaseNotes == null) {
result.releaseNotes = computeReleaseNotes(this.updater.currentVersion, this.updater.fullChangelog, feed, latestRelease)
}
return result
}
示例3: getLatestVersion
async getLatestVersion(): Promise<UpdateInfo> {
const basePath = this.basePath
const cancellationToken = new CancellationToken()
const xElement = require("xelement")
const feedXml = await this.httpRequest(newUrlFromBase(`${basePath}.atom`, this.baseUrl), {
Accept: "application/xml, application/atom+xml, text/xml, */*",
}, cancellationToken)
const feed = new xElement.Parse(feedXml)
const latestRelease = feed.element("entry")
if (latestRelease == null) {
throw new Error(`No published versions on GitHub`)
}
let version: string | null
try {
if (this.updater.allowPrerelease) {
version = latestRelease.element("link").getAttr("href").match(/\/tag\/v?([^\/]+)$/)[1]
}
else {
version = await this.getLatestVersionString(basePath, cancellationToken)
}
}
catch (e) {
throw new Error(`Cannot parse releases feed: ${e.stack || e.message},\nXML:\n${feedXml}`)
}
if (version == null) {
throw new Error(`No published versions on GitHub`)
}
let result: UpdateInfo
const channelFile = getChannelFilename(getDefaultChannelName())
const channelFileUrl = newUrlFromBase(this.getBaseDownloadPath(version, channelFile), this.baseUrl)
const requestOptions = this.createRequestOptions(channelFileUrl)
let rawData: string
try {
rawData = (await this.executor.request(requestOptions, cancellationToken))!!
}
catch (e) {
if (!this.updater.allowPrerelease) {
if (e instanceof HttpError && e.response.statusCode === 404) {
throw new Error(`Cannot find ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}`)
}
}
throw e
}
try {
result = safeLoad(rawData)
}
catch (e) {
throw new Error(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}, rawData: ${rawData}`)
}
Provider.validateUpdateInfo(result)
if (isUseOldMacProvider()) {
(result as any).releaseJsonUrl = `${githubUrl(this.options)}/${requestOptions.path}`
}
if (result.releaseName == null) {
(result as any).releaseName = latestRelease.getElementValue("title")
}
if (result.releaseNotes == null) {
(result as any).releaseNotes = latestRelease.getElementValue("content")
}
return result
}
示例4: constructor
protected constructor(protected readonly options: GithubOptions, defaultHost: string, executor: HttpExecutor<any>) {
super(executor, false /* because GitHib uses S3 */)
this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
}
示例5: constructor
constructor(protected readonly options: GithubOptions, defaultHost: string, executor: HttpExecutor<any>) {
super(executor)
this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
}