From a3842e2dfc4cc77fa1289655340511775a0e320d Mon Sep 17 00:00:00 2001 From: samcyn Date: Wed, 10 Apr 2024 16:21:37 +0100 Subject: [PATCH] style(plugin): add initialization messages to console format messages show when plugin initialize --- packages/plugin/src/on-plugin-init.ts | 6 +++++- packages/plugin/src/utils.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/plugin/src/on-plugin-init.ts b/packages/plugin/src/on-plugin-init.ts index 3286b27..caa67dc 100644 --- a/packages/plugin/src/on-plugin-init.ts +++ b/packages/plugin/src/on-plugin-init.ts @@ -1,5 +1,6 @@ import type { GatsbyNode } from 'gatsby'; import { ERROR_CODES } from './constants'; +import { wrapWithAsterisks } from './utils'; /** * Use the onPluginInit API to set up things that should be run before the plugin is initialized. @@ -10,7 +11,10 @@ import { ERROR_CODES } from './constants'; * @see https://www.gatsbyjs.com/docs/reference/config-files/node-api-helpers/#reporter */ export const onPluginInit: GatsbyNode['onPluginInit'] = ({ reporter }) => { - reporter.info('Ye! Hubspot Blog Plugin Initialized. Check ReadMe.MD file for documentations'); + const info = `Hey, thanks for considering installing "gatsby-source-hubspot-node", + for documentation see https://github.com/samcyn/gatsby-source-hubspot-node`; + + reporter.info(wrapWithAsterisks(info)); reporter.setErrorMap({ [ERROR_CODES.HubspotSourcing]: { text: (context) => `${context.sourceMessage}: ${context.errorCode}`, diff --git a/packages/plugin/src/utils.ts b/packages/plugin/src/utils.ts index 9bf477b..b5cee8c 100644 --- a/packages/plugin/src/utils.ts +++ b/packages/plugin/src/utils.ts @@ -137,3 +137,13 @@ export function createAssetNode(gatsbyApi: SourceNodesArgs, data: IPostImageInpu */ return id; } + +export function wrapWithAsterisks(message: string) { + function createAsteriskLine(length: number) { + return '*'.repeat(length); + } + + const asteriskLine = createAsteriskLine(message.length / 2); + + return `${asteriskLine}*\n\n* ${message} *\n\n${asteriskLine}******`; +}