本文整理汇总了TypeScript中builder-util.log类的典型用法代码示例。如果您正苦于以下问题:TypeScript log类的具体用法?TypeScript log怎么用?TypeScript log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了log类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getCertificateFromStoreInfo
export async function getCertificateFromStoreInfo(options: WindowsConfiguration, vm: VmManager): Promise<CertificateFromStoreInfo> {
const certificateSubjectName = options.certificateSubjectName
const certificateSha1 = options.certificateSha1
// ExcludeProperty doesn't work, so, we cannot exclude RawData, it is ok
// powershell can return object if the only item
const rawResult = await vm.exec("powershell.exe", ["Get-ChildItem -Recurse Cert: -CodeSigningCert | Select-Object -Property Subject,PSParentPath,Thumbprint | ConvertTo-Json -Compress"])
const certList = rawResult.length === 0 ? [] : asArray<CertInfo>(JSON.parse(rawResult))
for (const certInfo of certList) {
if (certificateSubjectName != null) {
if (!certInfo.Subject.includes(certificateSubjectName)) {
continue
}
}
else if (certInfo.Thumbprint !== certificateSha1) {
continue
}
const parentPath = certInfo.PSParentPath
const store = parentPath.substring(parentPath.lastIndexOf("\\") + 1)
log.debug({store, PSParentPath: parentPath}, "auto-detect certificate store")
// https://github.com/electron-userland/electron-builder/issues/1717
const isLocalMachineStore = (parentPath.includes("Certificate::LocalMachine"))
log.debug(null, "auto-detect using of LocalMachine store")
return {
thumbprint: certInfo.Thumbprint,
subject: certInfo.Subject,
store,
isLocalMachineStore
}
}
throw new Error(`Cannot find certificate ${certificateSubjectName || certificateSha1}, all certs: ${rawResult}`)
}
示例2: isSignAllowed
export function isSignAllowed(isPrintWarn = true): boolean {
if (process.platform !== "darwin") {
if (isPrintWarn) {
log.warn({reason: "supported only on macOS"}, "skipped macOS application code signing")
}
return false
}
const buildForPrWarning = "There are serious security concerns with CSC_FOR_PULL_REQUEST=true (see the CircleCI documentation (https://circleci.com/docs/1.0/fork-pr-builds/) for details)" +
"\nIf you have SSH keys, sensitive env vars or AWS credentials stored in your project settings and untrusted forks can make pull requests against your repo, then this option isn't for you."
if (isPullRequest()) {
if (isEnvTrue(process.env.CSC_FOR_PULL_REQUEST)) {
if (isPrintWarn) {
log.warn(buildForPrWarning)
}
}
else {
if (isPrintWarn) {
// https://github.com/electron-userland/electron-builder/issues/1524
log.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 false
}
}
return true
}
示例3: createSelfSignedCert
export async function createSelfSignedCert(publisher: string) {
const tmpDir = new TmpDir()
const targetDir = process.cwd()
const tempPrefix = path.join(await tmpDir.getTempDir({prefix: "self-signed-cert-creator"}), sanitizeFileName(publisher))
const cer = `${tempPrefix}.cer`
const pvk = `${tempPrefix}.pvk`
log.info(chalk.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.info({file: pfx}, `created. Please see https://electron.build/code-signing how to use it to sign.`)
const certLocation = "Cert:\\LocalMachine\\TrustedPeople"
log.info({file: pfx, certLocation}, `importing. 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()
}
}
示例4: getLicenseButtons
export async function getLicenseButtons(licenseButtonFiles: Array<LicenseButtonsFile>, langWithRegion: string, id: number, name: string) {
let data = getDefaultButtons(langWithRegion, id, name)
for (const item of licenseButtonFiles) {
if (item.langWithRegion !== langWithRegion) {
continue
}
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
}
示例5: 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.info("no native production dependencies")
return
}
const platform = options.platform || process.platform
const arch = options.arch || process.arch
const additionalArgs = options.additionalArgs
log.info({platform, arch}, "rebuilding native production dependencies")
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.info({name: dep.name}, `rebuilding native dependency`)
return spawn(execPath!, execArgs, {
cwd: dep.path,
env,
})
.catch(error => {
if (dep.optional) {
log.warn({dep: dep.name}, "cannot build optional native dep")
}
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,
})
}
}
示例6: getConfig
export async function getConfig(projectDir: string, configPath: string | null, configFromOptions: Configuration | null | undefined, packageMetadata: Lazy<{ [key: string]: any } | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))): Promise<Configuration> {
const configRequest: ReadConfigRequest = {packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata}
const configAndEffectiveFile = await _getConfig<Configuration>(configRequest, configPath)
const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result
if (configFromOptions != null) {
mergePublish(config, configFromOptions)
}
if (configAndEffectiveFile != null) {
log.info({file: configAndEffectiveFile.configFile == null ? 'package.json ("build" field)' : configAndEffectiveFile.configFile}, "loaded configuration")
}
let extendsSpec = config.extends
if (extendsSpec == null && extendsSpec !== null) {
const devDependencies = (await packageMetadata.value || {}).devDependencies
if (devDependencies != null) {
if ("react-scripts" in devDependencies) {
extendsSpec = "react-cra"
config.extends = extendsSpec
}
else if ("electron-webpack" in devDependencies) {
extendsSpec = "electron-webpack/electron-builder.yml"
config.extends = extendsSpec
}
}
}
if (extendsSpec == null) {
return deepAssign(getDefaultConfig(), config)
}
let parentConfig: Configuration | null
if (extendsSpec === "react-cra") {
parentConfig = await reactCra(projectDir)
log.info({preset: extendsSpec}, "loaded parent configuration")
}
else {
const parentConfigAndEffectiveFile = await loadParentConfig<Configuration>(configRequest, extendsSpec)
log.info({file: parentConfigAndEffectiveFile.configFile}, "loaded parent configuration")
parentConfig = parentConfigAndEffectiveFile.result
}
// electron-webpack and electrify client config - want to exclude some files
// we add client files configuration to main parent file matcher
if (parentConfig.files != null && config.files != null && (Array.isArray(config.files) || typeof config.files === "string") && Array.isArray(parentConfig.files) && parentConfig.files.length > 0) {
const mainFileSet = parentConfig.files[0]
if (typeof mainFileSet === "object" && (mainFileSet.from == null || mainFileSet.from === ".")) {
mainFileSet.filter = asArray(mainFileSet.filter)
mainFileSet.filter.push(...asArray(config.files as any))
delete (config as any).files
}
}
return deepAssign(getDefaultConfig(), parentConfig, config)
}
示例7: getConfig
export async function getConfig(projectDir: string,
configPath: string | null,
configFromOptions: Configuration | null | undefined,
packageMetadata: Lazy<{ [key: string]: any } | null> = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))): Promise<Configuration> {
const configRequest: ReadConfigRequest = {packageKey: "build", configFilename: "electron-builder", projectDir, packageMetadata}
const configAndEffectiveFile = await _getConfig<Configuration>(configRequest, configPath)
const config = configAndEffectiveFile == null ? {} : configAndEffectiveFile.result
if (configFromOptions != null) {
mergePublish(config, configFromOptions)
}
if (configAndEffectiveFile != null) {
log.info({file: configAndEffectiveFile.configFile == null ? 'package.json ("build" field)' : configAndEffectiveFile.configFile}, "loaded configuration")
}
if (config.extends == null && config.extends !== null) {
const metadata = await packageMetadata.value || {}
const devDependencies = metadata.devDependencies
const dependencies = metadata.dependencies
if ((dependencies != null && "react-scripts" in dependencies) || (devDependencies != null && "react-scripts" in devDependencies)) {
config.extends = "react-cra"
}
else if (devDependencies != null && "electron-webpack" in devDependencies) {
let file = "electron-webpack/out/electron-builder.js"
try {
file = require.resolve(file)
}
catch (ignore) {
file = require.resolve("electron-webpack/electron-builder.yml")
}
config.extends = `file:${file}`
}
}
let parentConfig: Configuration | null
if (config.extends === "react-cra") {
parentConfig = await reactCra(projectDir)
log.info({preset: config.extends}, "loaded parent configuration")
}
else if (config.extends != null) {
const parentConfigAndEffectiveFile = await loadParentConfig<Configuration>(configRequest, config.extends)
log.info({file: parentConfigAndEffectiveFile.configFile}, "loaded parent configuration")
parentConfig = parentConfigAndEffectiveFile.result
}
else {
parentConfig = null
}
return doMergeConfigs(config, parentConfig)
}
示例8: createBlockmap
export async function createBlockmap(file: string, target: Target, packager: PlatformPackager<any>, safeArtifactName: string | null): Promise<BlockMapDataHolder> {
const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`
log.info({blockMapFile: log.filePath(blockMapFile)}, "building block map")
const updateInfo = await executeAppBuilderAsJson<BlockMapDataHolder>(["blockmap", "--input", file, "--output", blockMapFile])
await packager.info.callArtifactBuildCompleted({
file: blockMapFile,
safeArtifactName: safeArtifactName == null ? null : `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,
target,
arch: null,
packager,
updateInfo,
})
return updateInfo
}
示例9: createBlockmap
export async function createBlockmap(file: string, target: Target, packager: PlatformPackager<any>, safeArtifactName: string | null): Promise<BlockMapDataHolder> {
const blockMapFile = `${file}${BLOCK_MAP_FILE_SUFFIX}`
log.info({blockMapFile: log.filePath(blockMapFile)}, "building block map")
const updateInfo: BlockMapDataHolder = JSON.parse(await exec(await getBlockMapTool(), ["-in", file, "-out", blockMapFile]))
packager.info.dispatchArtifactCreated({
file: blockMapFile,
safeArtifactName: `${safeArtifactName}${BLOCK_MAP_FILE_SUFFIX}`,
target,
arch: null,
packager,
updateInfo,
})
return updateInfo
}
示例10: computeElectronVersion
export async function computeElectronVersion(projectDir: string, projectMetadata: MetadataValue): Promise<string> {
const result = await getElectronVersionFromInstalled(projectDir)
if (result != null) {
return result
}
const electronPrebuiltDep = findFromElectronPrebuilt(await projectMetadata!!.value)
if (electronPrebuiltDep == null || electronPrebuiltDep === "latest") {
try {
const releaseInfo = JSON.parse((await httpExecutor.request({
hostname: "github.com",
path: "/electron/electron/releases/latest",
headers: {
Accept: "application/json",
},
}))!!)
return (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
}
catch (e) {
log.warn(e)
}
throw new Error(`Cannot find electron dependency to get electron version in the '${path.join(projectDir, "package.json")}'`)
}
return versionFromDependencyRange(electronPrebuiltDep)
}