@glimpse/glimpse-common
Advanced tools
Comparing version 0.22.13 to 0.22.15
{ | ||
"name": "@glimpse/glimpse-common", | ||
"version": "0.22.13", | ||
"version": "0.22.15", | ||
"license": "See license in license.md", | ||
@@ -5,0 +5,0 @@ "main": "./release/src/index.js", |
@@ -1,1 +0,5 @@ | ||
export declare function printBannerGreeting(clientUri?: string): void; | ||
import { IConfigSettings } from '../configuration/IConfigSettings'; | ||
export declare function printShortBanner(clientUri?: string): void; | ||
export declare function getLogoG(logText: any, seperator: any, clientHeader: any, docsHeader: any): string; | ||
export declare function printBannerGreeting(configSettings: IConfigSettings, clientUri?: string): void; | ||
export declare function printLongBanner(clientUri?: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var PackageHelper_1 = require("../common/PackageHelper"); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
// we only want to print banner once | ||
@@ -16,35 +18,63 @@ var bannerPrinted = false; | ||
} | ||
function printBannerGreeting(clientUri) { | ||
if (!bannerPrinted) { | ||
bannerPrinted = true; | ||
var packageHelper = PackageHelper_1.PackageHelper.instance; | ||
var packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
var packageVersion = packageHelper.getPackageVersion(packagePath); | ||
var logText = 'Running Project Glimpse v' + packageVersion; | ||
var clientHeader = ' - Open Glimpse at: '; | ||
var docsHeader = ' - More info at: '; | ||
var max = Math.max(clientHeader.length, docsHeader.length); | ||
var clientText = rightPad(clientHeader, max) + " " + clientUri; | ||
var docsText = rightPad(docsHeader, max) + " http://node.getglimpse.com"; | ||
var horizontalRule = repeat('=', Math.max(logText.length, clientText.length, docsText.length)); | ||
var horizontalRule2 = repeat('-', logText.length); | ||
var parts = [ | ||
'', | ||
horizontalRule, | ||
logText, | ||
horizontalRule2, | ||
clientText, | ||
docsText, | ||
horizontalRule, | ||
'' | ||
]; | ||
if (!clientUri) { | ||
// remove clientText if client not specified | ||
parts.splice(parts.indexOf(clientText), 1); | ||
} | ||
console.log(parts.join(require('os').EOL)); | ||
function shouldPrintShortBanner(configSettings) { | ||
return configSettings.getBoolean('banner.short', false); | ||
} | ||
function shouldSkipBanner(configSettings) { | ||
return configSettings.getBoolean('banner.suppress', false); | ||
} | ||
function printShortBanner(clientUri) { | ||
var packageHelper = PackageHelper_1.PackageHelper.instance; | ||
var packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
var packageVersion = packageHelper.getPackageVersion(packagePath); | ||
var logText = "Running Project Glimpse v" + packageVersion + "."; | ||
var clientText = ''; | ||
if (clientUri) { | ||
clientText = " Open Glimpse at " + clientUri; | ||
} | ||
console.log("" + logText + clientText); | ||
} | ||
exports.printShortBanner = printShortBanner; | ||
function getLogoG(logText, seperator, clientHeader, docsHeader) { | ||
var info1 = clientHeader ? clientHeader : docsHeader; | ||
var info2 = clientHeader ? docsHeader : ''; | ||
var loc = path.join(__dirname, 'logo.txt'); | ||
var text = fs.readFileSync(loc, { encoding: 'utf8' }); | ||
text = text.replace(/\$glimpse-logText\$/g, logText); | ||
text = text.replace(/\$glimpse-seperator\$/g, seperator); | ||
text = text.replace(/\$glimpse-info1\$/g, info1); | ||
text = text.replace(/\$glimpse-info2\$/g, info2); | ||
return text; | ||
} | ||
exports.getLogoG = getLogoG; | ||
function printBannerGreeting(configSettings, clientUri) { | ||
if (bannerPrinted || shouldSkipBanner(configSettings)) { | ||
return; | ||
} | ||
bannerPrinted = true; | ||
if (shouldPrintShortBanner(configSettings)) { | ||
printShortBanner(clientUri); | ||
} | ||
else { | ||
printLongBanner(clientUri); | ||
} | ||
} | ||
exports.printBannerGreeting = printBannerGreeting; | ||
function printLongBanner(clientUri) { | ||
var packageHelper = PackageHelper_1.PackageHelper.instance; | ||
var packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
var packageVersion = packageHelper.getPackageVersion(packagePath); | ||
var logText = 'Running Project Glimpse v' + packageVersion; | ||
var clientHeader = ' - Open Glimpse at: '; | ||
var docsHeader = ' - More info at: '; | ||
var max = Math.max(clientHeader.length, docsHeader.length); | ||
var clientText = undefined; | ||
if (clientUri) { | ||
clientText = rightPad(clientHeader, max) + " " + clientUri; | ||
} | ||
var docsText = rightPad(docsHeader, max) + " http://node.getglimpse.com"; | ||
var horizontalRule2 = repeat('-', logText.length); | ||
console.log(getLogoG(logText, horizontalRule2, clientText, docsText)); | ||
} | ||
exports.printLongBanner = printLongBanner; | ||
//# sourceMappingURL=../../../maps/src/logging/Banner.js.map |
import { PackageHelper } from '../common/PackageHelper'; | ||
import { IConfigSettings } from '../configuration/IConfigSettings'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
@@ -20,36 +23,67 @@ // we only want to print banner once | ||
export function printBannerGreeting(clientUri?: string): void { | ||
if (!bannerPrinted) { | ||
bannerPrinted = true; | ||
const packageHelper = PackageHelper.instance; | ||
const packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
const packageVersion = packageHelper.getPackageVersion(packagePath); | ||
function shouldPrintShortBanner(configSettings: IConfigSettings): boolean { | ||
return configSettings.getBoolean('banner.short', false); | ||
} | ||
const logText = 'Running Project Glimpse v' + packageVersion; | ||
const clientHeader = ' - Open Glimpse at: '; | ||
const docsHeader = ' - More info at: '; | ||
const max = Math.max(clientHeader.length, docsHeader.length); | ||
function shouldSkipBanner(configSettings: IConfigSettings): boolean { | ||
return configSettings.getBoolean('banner.suppress', false); | ||
} | ||
const clientText = `${rightPad(clientHeader, max)} ${clientUri}`; | ||
const docsText = `${rightPad(docsHeader, max)} http://node.getglimpse.com`; | ||
const horizontalRule = repeat('=', Math.max(logText.length, clientText.length, docsText.length)); | ||
const horizontalRule2 = repeat('-', logText.length); | ||
const parts = [ | ||
'', | ||
horizontalRule, | ||
logText, | ||
horizontalRule2, | ||
clientText, | ||
docsText, | ||
horizontalRule, | ||
'' | ||
]; | ||
export function printShortBanner(clientUri?: string) { | ||
const packageHelper = PackageHelper.instance; | ||
const packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
const packageVersion = packageHelper.getPackageVersion(packagePath); | ||
if (!clientUri) { | ||
// remove clientText if client not specified | ||
parts.splice(parts.indexOf(clientText), 1); | ||
} | ||
const logText = `Running Project Glimpse v${packageVersion}.`; | ||
let clientText = ''; | ||
if (clientUri) { | ||
clientText = ` Open Glimpse at ${clientUri}`; | ||
} | ||
console.log(`${logText}${clientText}`); | ||
} | ||
console.log(parts.join(require('os').EOL)); | ||
export function getLogoG(logText, seperator, clientHeader, docsHeader): string { | ||
const info1 = clientHeader ? clientHeader : docsHeader; | ||
const info2 = clientHeader ? docsHeader : ''; | ||
const loc = path.join(__dirname, 'logo.txt'); | ||
let text = fs.readFileSync(loc, { encoding: 'utf8' }); | ||
text = text.replace(/\$glimpse-logText\$/g, logText); | ||
text = text.replace(/\$glimpse-seperator\$/g, seperator); | ||
text = text.replace(/\$glimpse-info1\$/g, info1); | ||
text = text.replace(/\$glimpse-info2\$/g, info2); | ||
return text; | ||
} | ||
export function printBannerGreeting(configSettings: IConfigSettings, clientUri?: string): void { | ||
if (bannerPrinted || shouldSkipBanner(configSettings)) { | ||
return; | ||
} | ||
bannerPrinted = true; | ||
if (shouldPrintShortBanner(configSettings)) { | ||
printShortBanner(clientUri); | ||
} | ||
else { | ||
printLongBanner(clientUri); | ||
} | ||
} | ||
export function printLongBanner(clientUri?: string): void { | ||
const packageHelper = PackageHelper.instance; | ||
const packagePath = packageHelper.findPackageJsonPath(__dirname); | ||
const packageVersion = packageHelper.getPackageVersion(packagePath); | ||
const logText = 'Running Project Glimpse v' + packageVersion; | ||
const clientHeader = ' - Open Glimpse at: '; | ||
const docsHeader = ' - More info at: '; | ||
const max = Math.max(clientHeader.length, docsHeader.length); | ||
let clientText = undefined; | ||
if (clientUri) { | ||
clientText = `${rightPad(clientHeader, max)} ${clientUri}`; | ||
} | ||
const docsText = `${rightPad(docsHeader, max)} http://node.getglimpse.com`; | ||
const horizontalRule2 = repeat('-', logText.length); | ||
console.log(getLogoG(logText, horizontalRule2, clientText, docsText)); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157855
94
2386
6