本文整理汇总了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()
}
}
示例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,
})
}
}
示例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),
})
}
示例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)
}
示例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())
}
示例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),
})
}
示例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)
}
示例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})
示例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"))
}
}
示例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}
}