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

TypeScript builder-util.log函数代码示例

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

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



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

示例1: createSelfSignedCert

export async function createSelfSignedCert(publisher: string) {
  const tmpDir = new TmpDir()
  const targetDir = process.cwd()
  const tempPrefix = path.join(await tmpDir.getTempDir(), sanitizeFileName(publisher))
  const cer = `${tempPrefix}.cer`
  const pvk = `${tempPrefix}.pvk`

  log(bold('When asked to enter a password ("Create Private Key Password"), please select "None".'))

  try {
    await ensureDir(path.dirname(tempPrefix))
    const vendorPath = path.join(await getSignVendorPath(), "windows-10", process.arch)
    await exec(path.join(vendorPath, "makecert.exe"),
      ["-r", "-h", "0", "-n", `CN=${quoteString(publisher)}`, "-eku", "1.3.6.1.5.5.7.3.3", "-pe", "-sv", pvk, cer])

    const pfx = path.join(targetDir, `${sanitizeFileName(publisher)}.pfx`)
    await unlinkIfExists(pfx)
    await exec(path.join(vendorPath, "pvk2pfx.exe"), ["-pvk", pvk, "-spc", cer, "-pfx", pfx])
    log(`${pfx} created. Please see https://electron.build/code-signing how to use it to sign.`)

    const certLocation = "Cert:\\LocalMachine\\TrustedPeople"
    log(`${pfx} will be imported into ${certLocation} Operation will be succeed only if runned from root. Otherwise import file manually.`)
    await spawn("powershell.exe", ["Import-PfxCertificate", "-FilePath", `"${pfx}"`, "-CertStoreLocation", ""])
  }
  finally {
    await tmpDir.cleanup()
  }
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:28,代码来源:create-self-signed-cert.ts


示例2: rebuild

export async function rebuild(appDir: string, options: RebuildOptions) {
  const nativeDeps = await BluebirdPromise.filter(await options.productionDeps!.value, it => exists(path.join(it.path, "binding.gyp")), {concurrency: 8})
  if (nativeDeps.length === 0) {
    log(`No native production dependencies`)
    return
  }

  const platform = options.platform || process.platform
  const arch = options.arch || process.arch
  const additionalArgs = options.additionalArgs

  log(`Rebuilding native production dependencies for ${platform}:${arch}`)

  let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const isYarn = isYarnPath(execPath)
  const execArgs: Array<string> = []
  if (execPath == null) {
    execPath = getPackageToolPath()
  }
  else {
    execArgs.push(execPath)
    execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
  }

  const env = getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true)
  if (isYarn) {
    execArgs.push("run", "install", "--")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    await BluebirdPromise.map(nativeDeps, dep => {
      log(`Rebuilding native dependency ${dep.name}`)
      return spawn(execPath!, execArgs, {
        cwd: dep.path,
        env,
      })
        .catch(error => {
          if (dep.optional) {
            warn(`Cannot build optional native dep ${dep.name}`)
          }
          else {
            throw error
          }
        })
    }, {concurrency: process.platform === "win32" ? 1 : 2})
  }
  else {
    execArgs.push("rebuild")
    if (additionalArgs != null) {
      execArgs.push(...additionalArgs)
    }
    execArgs.push(...nativeDeps.map(it => `${it.name}@${it.version}`))
    await spawn(execPath, execArgs, {
      cwd: appDir,
      env,
    })
  }
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:58,代码来源:yarn.ts


示例3: installDependencies

function installDependencies(appDir: string, options: RebuildOptions): Promise<any> {
  const platform = options.platform || process.platform
  const arch = options.arch || process.arch
  const additionalArgs = options.additionalArgs

  log(`Installing app dependencies for ${platform}:${arch} to ${appDir}`)
  let execPath = process.env.npm_execpath || process.env.NPM_CLI_JS
  const execArgs = ["install", "--production"]

  if (!isYarnPath(execPath)) {
    if (process.env.NPM_NO_BIN_LINKS === "true") {
      execArgs.push("--no-bin-links")
    }
    execArgs.push("--cache-min", "999999999")
  }

  if (execPath == null) {
    execPath = getPackageToolPath()
  }
  else {
    execArgs.unshift(execPath)
    execPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
  }

  if (additionalArgs != null) {
    execArgs.push(...additionalArgs)
  }
  return spawn(execPath, execArgs, {
    cwd: appDir,
    env: getGypEnv(options.frameworkInfo, platform, arch, options.buildFromSource === true),
  })
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:32,代码来源:yarn.ts


示例4: installAppDeps

export async function installAppDeps(args: any) {
  try {
    log("electron-builder " + PACKAGE_VERSION)
  }
  catch (e) {
    // error in dev mode without babel
    if (!(e instanceof ReferenceError)) {
      throw e
    }
  }

  const projectDir = process.cwd()
  const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))
  const config = await getConfig(projectDir, null, null, packageMetadata)
  const muonVersion = config.muonVersion
  const results = await BluebirdPromise.all<string>([
    computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
    muonVersion == null ? getElectronVersion(projectDir, config, packageMetadata) : BluebirdPromise.resolve(muonVersion),
  ])

  // if two package.json — force full install (user wants to install/update app deps in addition to dev)
  await installOrRebuild(config, results[0], {
    frameworkInfo: {version: results[1], useCustomDist: muonVersion == null},
    platform: args.platform,
    arch: args.arch,
    productionDeps: createLazyProductionDeps(results[0]),
  }, results[0] !== projectDir)
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:28,代码来源:install-app-deps.ts


示例5: assertPack

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions = {}): Promise<void> {
  if (checkOptions.signed) {
    packagerOptions = signed(packagerOptions)
  }
  if (checkOptions.signedWin) {
    packagerOptions.cscLink = WIN_CSC_LINK
    packagerOptions.cscKeyPassword = ""
  }
  else if (packagerOptions.cscLink == null) {
    packagerOptions = deepAssign({}, packagerOptions, {config: {mac: {identity: null}}})
  }

  const projectDirCreated = checkOptions.projectDirCreated
  let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName)
  // const isDoNotUseTempDir = platform === "darwin"
  const customTmpDir = process.env.TEST_APP_TMP_DIR
  const tmpDir = new TmpDir()
  // non-macOS test uses the same dir as macOS test, but we cannot share node_modules (because tests executed in parallel)
  const dir = customTmpDir == null ? await tmpDir.createTempDir() : path.resolve(customTmpDir)
  if (customTmpDir != null) {
    await emptyDir(dir)
    log(`Custom temp dir used: ${customTmpDir}`)
  }

  await copyDir(projectDir, dir, it => {
    const basename = path.basename(it)
    return basename !== OUT_DIR_NAME && basename !== "node_modules" && !basename.startsWith(".")
  }, null, it => path.basename(it) !== "package.json")
  projectDir = dir

  await executeFinally((async () => {
    if (projectDirCreated != null) {
      await projectDirCreated(projectDir, tmpDir)
      if (checkOptions.installDepsBefore) {
        // bin links required (e.g. for node-pre-gyp - if package refers to it in the install script)
        await spawn(process.platform === "win32" ? "yarn.cmd" : "yarn", ["install", "--production", "--no-lockfile"], {
          cwd: projectDir,
        })
      }
    }

    const {packager, outDir} = await packAndCheck({projectDir, ...packagerOptions}, checkOptions)

    if (checkOptions.packed != null) {
      function base(platform: Platform, arch?: Arch): string {
        return path.join(outDir, `${platform.buildConfigurationKey}${getArchSuffix(arch == null ? Arch.x64 : arch)}${platform === Platform.MAC ? "" : "-unpacked"}`)
      }

      await checkOptions.packed({
        projectDir,
        outDir,
        getResources: (platform, arch) => path.join(base(platform, arch), "resources"),
        getContent: platform => base(platform),
        packager,
        tmpDir,
      })
    }
  })(), () => tmpDir.cleanup())
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:59,代码来源:packTester.ts


示例6: rebuildAppNativeCode

async function rebuildAppNativeCode(args: any) {
  const projectDir = process.cwd()
  log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
  // this script must be used only for electron
  await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
    env: getGypEnv({version: await getElectronVersion(projectDir), useCustomDist: true}, args.platform, args.arch, true),
  })
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:8,代码来源:cli.ts


示例7: syncReleases

function syncReleases(outputDirectory: string, options: SquirrelOptions) {
  log("Sync releases to build delta package")
  const args = prepareArgs(["-u", options.remoteReleases!, "-r", outputDirectory], path.join(options.vendorPath, "SyncReleases.exe"))
  if (options.remoteToken) {
    args.push("-t", options.remoteToken)
  }
  return spawn(process.platform === "win32" ? path.join(options.vendorPath, "SyncReleases.exe") : "mono", args)
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:8,代码来源:squirrelPack.ts


示例8: log

 await BluebirdPromise.map(nativeDeps, dep => {
   log(`Rebuilding native dependency ${dep.name}`)
   return spawn(execPath!, execArgs, {
     cwd: dep.path,
     env,
   })
     .catch(error => {
       if (dep.optional) {
         warn(`Cannot build optional native dep ${dep.name}`)
       }
       else {
         throw error
       }
     })
 }, {concurrency: process.platform === "win32" ? 1 : 2})
开发者ID:jwheare,项目名称:electron-builder,代码行数:15,代码来源:yarn.ts


示例9: 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 | null | undefined) => {
    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:jwheare,项目名称:electron-builder,代码行数:46,代码来源:packageMetadata.ts


示例10: compileUsingElectronCompile

async function compileUsingElectronCompile(mainFileSet: ResolvedFileSet, packager: Packager): Promise<ResolvedFileSet> {
  log("Compiling using electron-compile")

  const electronCompileCache = await packager.tempDirManager.getTempDir({prefix: "electron-compile-cache"})
  const cacheDir = path.join(electronCompileCache, ".cache")
  // clear and create cache dir
  await ensureDir(cacheDir)
  const compilerHost = await createElectronCompilerHost(mainFileSet.src, cacheDir)
  const nextSlashIndex = mainFileSet.src.length + 1
  // pre-compute electron-compile to cache dir - we need to process only subdirectories, not direct files of app dir
  await BluebirdPromise.map(mainFileSet.files, file => {
    if (file.includes(NODE_MODULES_PATTERN) || file.includes(BOWER_COMPONENTS_PATTERN)
      || !file.includes(path.sep, nextSlashIndex) // ignore not root files
      || !mainFileSet.metadata.get(file)!.isFile()) {
      return null
    }
    return compilerHost.compile(file)
      .then((it: any) => null)
  }, CONCURRENCY)

  await compilerHost.saveConfiguration()

  const metadata = new Map<string, Stats>()
  const cacheFiles = await walk(cacheDir, (file, stat) => !file.startsWith("."), {
    consume: (file, fileStat) => {
      if (fileStat.isFile()) {
        metadata.set(file, fileStat)
      }
      return null
    }
  })

  // add shim
  const shimPath = `${mainFileSet.src}/${ELECTRON_COMPILE_SHIM_FILENAME}`
  cacheFiles.push(shimPath)
  metadata.set(shimPath, {isFile: () => true, isDirectory: () => false} as any)

  const transformedFiles = new Array(cacheFiles.length)
  transformedFiles[cacheFiles.length - 1] = `
'use strict';
require('electron-compile').init(__dirname, require('path').resolve(__dirname, '${packager.metadata.main || "index"}'), true);
`
  // cache files should be first (better IO)
  return {src: electronCompileCache, files: cacheFiles, transformedFiles, metadata, destination: mainFileSet.destination}
}
开发者ID:jwheare,项目名称:electron-builder,代码行数:45,代码来源:AppFileCopierHelper.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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