How to use the builder-util.log.debug function in builder-util

To help you get started, we’ve selected a few builder-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github electron-userland / electron-builder / packages / app-builder-lib / src / fileMatcher.ts View on Github external
if (fromStat.isFile()) {
      const toStat = await statOrNull(matcher.to)
      // https://github.com/electron-userland/electron-builder/issues/1245
      if (toStat != null && toStat.isDirectory()) {
        return await copyOrLinkFile(matcher.from, path.join(matcher.to, path.basename(matcher.from)), fromStat, isUseHardLink)
      }

      await ensureDir(path.dirname(matcher.to))
      return await copyOrLinkFile(matcher.from, matcher.to, fromStat)
    }

    if (matcher.isEmpty() || matcher.containsOnlyIgnore()) {
      matcher.prependPattern("**/*")
    }
    log.debug({matcher}, "copying files using pattern")
    return await copyDir(matcher.from, matcher.to, {filter: matcher.createFilter(), transformer, isUseHardLink: isUseHardLink ? USE_HARD_LINKS : null})
  })
}
github electron-userland / electron-builder / packages / electron-builder-lib / src / util / AppFileCopierHelper.ts View on Github external
export async function computeFileSets(matchers: Array, transformer: FileTransformer | null, platformPackager: PlatformPackager, isElectronCompile: boolean): Promise> {
  const fileSets: Array = []
  const packager = platformPackager.info

  for (const matcher of matchers) {
    const fileWalker = new AppFileWalker(matcher, packager)

    const fromStat = await statOrNull(matcher.from)
    if (fromStat == null) {
      log.debug({directory: matcher.from, reason: "doesn't exist"}, `skipped copying`)
      continue
    }

    const files = await walk(matcher.from, fileWalker.filter, fileWalker)
    const metadata = fileWalker.metadata
    fileSets.push(validateFileSet({src: matcher.from, files, metadata, transformedFiles: await transformFiles(transformer, files, metadata), destination: matcher.to}))
  }

  if (isElectronCompile) {
    // cache files should be first (better IO)
    fileSets.unshift(await compileUsingElectronCompile(fileSets[0], packager))
  }
  return fileSets
}
github electron-userland / electron-builder / packages / app-builder-lib / src / publish / PublishManager.ts View on Github external
export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager, publishConfigs: Array | null, arch: Arch | null): Promise | null> {
  if (publishConfigs === null) {
    return null
  }

  if (publishConfigs.length === 0) {
    log.debug(null, "getPublishConfigsForUpdateInfo: no publishConfigs, detect using repository info")
    // https://github.com/electron-userland/electron-builder/issues/925#issuecomment-261732378
    // default publish config is github, file should be generated regardless of publish state (user can test installer locally or manage the release process manually)
    const repositoryInfo = await packager.info.repositoryInfo
    debug(`getPublishConfigsForUpdateInfo: ${safeStringifyJson(repositoryInfo)}`)
    if (repositoryInfo != null && repositoryInfo.type === "github") {
      const resolvedPublishConfig = await getResolvedPublishConfig(packager, packager.info, {provider: repositoryInfo.type}, arch, false)
      if (resolvedPublishConfig != null) {
        debug(`getPublishConfigsForUpdateInfo: resolve to publish config ${safeStringifyJson(resolvedPublishConfig)}`)
        return [resolvedPublishConfig]
      }
    }
  }
  return publishConfigs
}
github electron-userland / electron-builder / packages / electron-publish / src / gitHubPublisher.ts View on Github external
private async overwriteArtifact(fileName: string, release: Release) {
    // delete old artifact and re-upload
    log.warn({file: fileName, reason: "already exists on GitHub"}, "overwrite published file")

    const assets = await this.githubRequest>(`/repos/${this.info.owner}/${this.info.repo}/releases/${release.id}/assets`, this.token, null)
    for (const asset of assets) {
      if (asset!.name === fileName) {
        await this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases/assets/${asset!.id}`, this.token, null, "DELETE")
        return
      }
    }

    log.debug({file: fileName, reason: "not found on GitHub"}, "trying to upload again")
  }
github electron-userland / electron-builder / packages / app-builder-lib / src / publish / PublishManager.ts View on Github external
scheduleUpload(publishConfig: PublishConfiguration, event: UploadTask, appInfo: AppInfo): void {
    if (publishConfig.provider === "generic") {
      return
    }

    const publisher = this.getOrCreatePublisher(publishConfig, appInfo)
    if (publisher == null) {
      log.debug({
        file: event.file,
        reason: "publisher is null",
        publishConfig: safeStringifyJson(publishConfig),
      }, "not published")
      return
    }

    const providerName = publisher.providerName
    if (this.publishOptions.publish === "onTagOrDraft" && getCiTag() == null && !(providerName === "GitHub" || providerName === "Bintray")) {
      log.info({file: event.file, reason: "current build is not for a git tag", publishPolicy: "onTagOrDraft"}, `not published to ${providerName}`)
      return
    }

    this.taskManager.addTask(publisher.upload(event))
  }
github electron-userland / electron-builder / packages / app-builder-lib / src / publish / PublishManager.ts View on Github external
if (info != null) {
      return info
    }

    const message = `Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).\nPlease see https://electron.build/configuration/publish`
    if (errorIfCannot) {
      throw new Error(message)
    }
    else {
      log.warn(message)
      return null
    }
  }

  if (!owner || !project) {
    log.debug({reason: "owner or project is not specified explicitly", provider, owner, project}, "calling getInfo")
    const info = await getInfo()
    if (info == null) {
      return null
    }

    if (!owner) {
      owner = info.user
    }
    if (!project) {
      project = info.project
    }
  }

  if (isGithub) {
    if ((options as GithubOptions).token != null && !(options as GithubOptions).private) {
      log.warn('"token" specified in the github publish options. It should be used only for [setFeedURL](module:electron-updater/out/AppUpdater.AppUpdater+setFeedURL).')
github electron-userland / electron-builder / packages / electron-builder-lib / src / remoteBuilder / RemoteBuildManager.ts View on Github external
.on("data", (object: any) => {
            const data = object.value
            if (log.isDebugEnabled) {
              log.debug({event: JSON.stringify(data, null, 2)}, "remote builder event")
            }

            if (data.status != null) {
              log.info({status: data.status}, "remote building")
            }
            else if ("error" in data) {
              resolve({files: null, error: data.error})
            }
            else if ("files" in data) {
              this.downloadArtifacts(data.files, data.fileSizes, data.baseUrl)
                .then(() => {
                  stream.destroy()
                  resolve({files: data.files, error: null})
                })
                .catch(reject)
            }
github electron-userland / electron-builder / packages / dmg-builder / src / licenseButtons.ts View on Github external
function hexEncode(str: string, lang: string, langWithRegion: string) {
  const macCodePages = getMacCodePage(lang, langWithRegion)
  let result = ""

  for (let i = 0; i < str.length; i++) {
    try {
      let hex = getMacHexCode(str, i, macCodePages)
      if (hex === undefined) {
        hex = "3F" //?
      }
      result += hex
    }
    catch (e) {
      log.debug({error: e, char: str[i]}, "cannot convert")
      result += "3F" //?
    }
  }

  return result
}
github electron-userland / electron-builder / packages / dmg-builder / src / licenseButtons.ts View on Github external
try {
      const fileData = safeLoad(await readFile(item.file, "utf-8")) as any
      const buttonsStr = labelToHex(fileData.lang, item.lang, item.langWithRegion) +
        labelToHex(fileData.agree, item.lang, item.langWithRegion) +
        labelToHex(fileData.disagree, item.lang, item.langWithRegion) +
        labelToHex(fileData.print, item.lang, item.langWithRegion) +
        labelToHex(fileData.save, item.lang, item.langWithRegion) +
        labelToHex(fileData.description, item.lang, item.langWithRegion)

      data = `data 'STR#' (${id}, "${name}") {\n`
      data += serializeString("0006" + buttonsStr)
      data += `\n};`

      if (log.isDebugEnabled) {
        log.debug({lang: item.langName, data}, `overwriting license buttons`)
      }
      return data
    }
    catch (e) {
      log.debug({error: e}, "cannot overwrite license buttons")
      return data
    }
  }

  return data
}