• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript electron-builder-util.warn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中electron-builder-util.warn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript warn函数的具体用法?TypeScript warn怎么用?TypeScript warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了warn函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: computeDefaultAppDirectory

export async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | null | undefined): Promise<string> {
  if (userAppDir != null) {
    const absolutePath = path.resolve(projectDir, userAppDir)
    const stat = await statOrNull(absolutePath)
    if (stat == null) {
      throw new Error(`Application directory ${userAppDir} doesn't exists`)
    }
    else if (!stat.isDirectory()) {
      throw new Error(`Application directory ${userAppDir} is not a directory`)
    }
    else if (projectDir === absolutePath) {
      warn(`Specified application directory "${userAppDir}" equals to project dir — superfluous or wrong configuration`)
    }
    return absolutePath
  }

  for (const dir of DEFAULT_APP_DIR_NAMES) {
    const absolutePath = path.join(projectDir, dir)
    const packageJson = path.join(absolutePath, "package.json")
    const stat = await statOrNull(packageJson)
    if (stat != null && stat.isFile()) {
      return absolutePath
    }
  }
  return projectDir
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:26,代码来源:config.ts


示例2: warn

 .catch(error => {
   if (dep.optional) {
     warn(`Cannot build optional native dep ${dep.name}`)
   }
   else {
     throw error
   }
 })
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:8,代码来源:yarn.ts


示例3: checkMetadata

export function checkMetadata(metadata: Metadata, devMetadata: any | null, appPackageFile: string, devAppPackageFile: string): void {
  const errors: Array<string> = []
  const reportError = (missedFieldName: string) => {
    errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`)
  }

  const checkNotEmpty = (name: string, value: string | n) => {
    if (isEmptyOrSpaces(value)) {
      reportError(name)
    }
  }

  if ((metadata as any).directories != null) {
    errors.push(`"directories" in the root is deprecated, please specify in the "build"`)
  }

  checkNotEmpty("name", metadata.name)

  if (isEmptyOrSpaces(metadata.description)) {
    warn(`description is missed in the package.json (${appPackageFile})`)
  }
  if (!metadata.author) {
    warn(`author is missed in the package.json (${appPackageFile})`)
  }
  checkNotEmpty("version", metadata.version)

  if (devMetadata != null) {
    checkDependencies(devMetadata.dependencies, errors)
  }
  if (metadata !== devMetadata) {
    checkDependencies(metadata.dependencies, errors)

    if (metadata.build != null) {
      errors.push(`'build' in the application package.json (${appPackageFile}) is not supported since 3.0 anymore. Please move 'build' into the development package.json (${devAppPackageFile})`)
    }
  }

  const devDependencies = (metadata as any).devDependencies
  if (devDependencies != null && "electron-rebuild" in devDependencies) {
    log('electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies\n\nTo ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`')
  }

  if (errors.length > 0) {
    throw new Error(errors.join("\n"))
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:46,代码来源:packageMetadata.ts


示例4: async

 process.once("beforeExit", async () => {
   try {
     const list = (await listUserKeychains()).filter(it => it !== keychainFile)
     exec("security", ["list-keychains", "-d", "user", "-s"].concat(list))
   }
   catch (e) {
     warn(`Cannot restore keychain search list: ${e}`)
   }
 })
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:9,代码来源:codeSign.ts


示例5: signed

export function signed(packagerOptions: PackagerOptions): PackagerOptions {
  if (process.env.CSC_KEY_PASSWORD == null) {
    warn("macOS code sign is not tested — CSC_KEY_PASSWORD is not defined")
  }
  else {
    packagerOptions.cscLink = CSC_LINK
  }
  return packagerOptions
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:9,代码来源:packTester.ts


示例6: computeElectronVersion

export async function computeElectronVersion(projectDir: string, projectMetadata?: any | null): Promise<string> {
  // projectMetadata passed only for prepacked app asar and in this case no dev deps in the app.asar
  if (projectMetadata == null) {
    for (const name of ["electron", "electron-prebuilt", "electron-prebuilt-compile"]) {
      try {
        return (await readJson(path.join(projectDir, "node_modules", name, "package.json"))).version
      }
      catch (e) {
        if (e.code !== "ENOENT") {
          warn(`Cannot read electron version from ${name} package.json: ${e.message}`)
        }
      }
    }
  }

  const packageJsonPath = path.join(projectDir, "package.json")
  const electronPrebuiltDep = findFromElectronPrebuilt(projectMetadata || await readJson(packageJsonPath))
  if (electronPrebuiltDep == null || electronPrebuiltDep === "latest") {
    try {
      const releaseInfo = await httpExecutor.request<any>({
        hostname: "github.com",
        path: "/electron/electron/releases/latest",
        headers: {
          Accept: "application/json",
        },
      }, new CancellationToken())
      return (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
    }
    catch (e) {
      warn(e)
    }

    throw new Error(`Cannot find electron dependency to get electron version in the '${packageJsonPath}'`)
  }

  const firstChar = electronPrebuiltDep[0]
  return firstChar === "^" || firstChar === "~" ? electronPrebuiltDep.substring(1) : electronPrebuiltDep
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:38,代码来源:config.ts


示例7: reactCra

export async function reactCra(projectDir: string): Promise<Config> {
  if ((await statOrNull(path.join(projectDir, "public", "electron.js"))) == null) {
    warn("public/electron.js not found. Please see https://medium.com/@kitze/%EF%B8%8F-from-react-to-an-electron-app-ready-for-production-a0468ecb1da3")
  }

  return {
    directories: {
      buildResources: "assets"
    },
    files: ["build/**/*"],
    extraMetadata: {
      main: "build/electron.js"
    }
  }}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:14,代码来源:rectCra.ts


示例8: getToolPath

async function getToolPath(): Promise<ToolInfo> {
  if (isUseSystemSigncode()) {
    return {path: "osslsigncode"}
  }

  const result = process.env.SIGNTOOL_PATH
  if (result) {
    return {path: result}
  }

  const vendorPath = await getSignVendorPath()
  if (process.platform === "win32") {
    // use modern signtool on Windows Server 2012 R2 to be able to sign AppX
    if (isOldWin6()) {
      return {path: path.join(vendorPath, "windows-6", "signtool.exe")}
    }
    else {
      return {path: path.join(vendorPath, "windows-10", process.arch, "signtool.exe")}
    }
  }
  else if (process.platform === "darwin") {
    let suffix: string | null = null
    try {
      if (await isMacOsSierra()) {
        const toolDirPath = path.join(vendorPath, process.platform, "10.12")
        return {
          path: path.join(toolDirPath, "osslsigncode"),
          env: computeToolEnv([path.join(toolDirPath, "lib")]),
        }
      }
      else if (isCi) {
        // not clear for what we do this instead of using version detection
        suffix = "ci"
      }
    }
    catch (e) {
      warn(`${e.stack || e}`)
    }
    return {path: path.join(vendorPath, process.platform, `${suffix == null ? "" : `${suffix}/`}osslsigncode`)}
  }
  else {
    return {path: path.join(vendorPath, process.platform, "osslsigncode")}
  }
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:44,代码来源:windowsCodeSign.ts


示例9: reportError

  private async reportError(isMas: boolean, certificateType: CertType, qualifier: string | null | undefined, keychainName: string | null | undefined) {
    let message: string
    if (qualifier == null) {
      message = `App is not signed`
      if (isAutoDiscoveryCodeSignIdentity()) {
        const postfix = isMas ? "" : ` or custom non-Apple code signing certificate`
        message += `: cannot find valid "${certificateType}" identity${postfix}`
      }
      message += ", see https://github.com/electron-userland/electron-builder/wiki/Code-Signing"
      if (!isAutoDiscoveryCodeSignIdentity()) {
        message += `\n(CSC_IDENTITY_AUTO_DISCOVERY=false)`
      }
    }
    else {
      message = `Identity name "${qualifier}" is specified, but no valid identity with this name in the keychain`
    }

    const args = ["find-identity"]
    if (keychainName != null) {
      args.push(keychainName)
    }

    if (qualifier != null || isAutoDiscoveryCodeSignIdentity()) {
      const allIdentities = (await exec("security", args))
        .trim()
        .split("\n")
        .filter(it => !(it.includes("Policy: X.509 Basic") || it.includes("Matching identities")))
        .join("\n")
      message += "\n\nAll identities:\n" + allIdentities
    }

    if (isMas || this.forceCodeSigning) {
      throw new Error(message)
    }
    else {
      warn(message)
    }
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:38,代码来源:macPackager.ts


示例10: sign

  private async sign(appPath: string, outDir: string | null, masOptions: MasBuildOptions | null): Promise<void> {
    if (process.platform !== "darwin") {
      warn("macOS application code signing is supported only on macOS, skipping.")
      return
    }

    if (isPullRequest()) {
      if (process.env.CSC_FOR_PULL_REQUEST === "true") {
        warn(buildForPrWarning)
      }
      else {
        // https://github.com/electron-userland/electron-builder/issues/1524
        warn("Current build is a part of pull request, code signing will be skipped." +
          "\nSet env CSC_FOR_PULL_REQUEST to true to force code signing." +
          `\n${buildForPrWarning}`)
        return
      }
    }

    const isMas = masOptions != null
    const macOptions = this.platformSpecificBuildOptions
    const qualifier = (isMas ? masOptions!.identity : null) || macOptions.identity

    if (!isMas && qualifier === null) {
      if (this.forceCodeSigning) {
        throw new Error("identity explicitly is set to null, but forceCodeSigning is set to true")
      }
      log("identity explicitly is set to null, skipping macOS application code signing.")
      return
    }

    const keychainName = (await this.codeSigningInfo).keychainName
    const explicitType = isMas ? masOptions!.type : macOptions.type
    const type = explicitType || "distribution"
    const isDevelopment = type === "development"
    const certificateType = getCertificateType(isMas, isDevelopment)
    let identity = await findIdentity(certificateType, qualifier, keychainName)
    if (identity == null) {
      if (!isMas && !isDevelopment && explicitType !== "distribution") {
        identity = await findIdentity("Mac Developer", qualifier, keychainName)
        if (identity != null) {
          warn("Mac Developer is used to sign app — it is only for development and testing, not for production")
        }
      }

      if (identity == null) {
        await this.reportError(isMas, certificateType, qualifier, keychainName)
        return
      }
    }

    const signOptions: any = {
      "identity-validation": false,
      // https://github.com/electron-userland/electron-builder/issues/1699
      ignore: (file: string) => file.startsWith("/Contents/PlugIns", appPath.length),
      identity: identity!,
      type,
      platform: isMas ? "mas" : "darwin",
      version: this.config.electronVersion,
      app: appPath,
      keychain: keychainName || undefined,
      binaries:  (isMas && masOptions != null ? masOptions.binaries : macOptions.binaries) || undefined,
      requirements: isMas || macOptions.requirements == null ? undefined : await this.getResource(macOptions.requirements),
      "gatekeeper-assess": appleCertificatePrefixes.find(it => identity!.name.startsWith(it)) != null
    }

    await this.adjustSignOptions(signOptions, masOptions)
    await task(`Signing app (identity: ${identity.hash} ${identity.name})`, this.doSign(signOptions))

    // https://github.com/electron-userland/electron-builder/issues/1196#issuecomment-312310209
    if (masOptions != null && !isDevelopment) {
      const certType = isDevelopment ? "Mac Developer" : "3rd Party Mac Developer Installer"
      const masInstallerIdentity = await findIdentity(certType, masOptions.identity, keychainName)
      if (masInstallerIdentity == null) {
        throw new Error(`Cannot find valid "${certType}" identity to sign MAS installer, please see https://github.com/electron-userland/electron-builder/wiki/Code-Signing`)
      }

      const pkg = path.join(outDir!, this.expandArtifactNamePattern(masOptions, "pkg"))
      await this.doFlat(appPath, pkg, masInstallerIdentity, keychainName)
      this.dispatchArtifactCreated(pkg, null, Arch.x64, this.computeSafeArtifactName("pkg"))
    }
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:82,代码来源:macPackager.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript deepAssign.deepAssign函数代码示例发布时间:2022-05-25
下一篇:
TypeScript electron-builder-util.use函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap