当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript builder-util-runtime.githubUrl函数代码示例

本文整理汇总了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))
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:11,代码来源:GitHubProvider.ts

示例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
  }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:56,代码来源:GitHubProvider.ts

示例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
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:69,代码来源:GitHubProvider.ts

示例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))
  }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:5,代码来源:GitHubProvider.ts

示例5: constructor

  constructor(protected readonly options: GithubOptions, defaultHost: string, executor: HttpExecutor<any>) {
    super(executor)

    this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:5,代码来源:GitHubProvider.ts


注:本文中的builder-util-runtime.githubUrl函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。