From 07c0c15c6f1e7486778a9a347a6b14611a951a76 Mon Sep 17 00:00:00 2001 From: Simply007 Date: Wed, 9 Jan 2019 10:55:55 +0100 Subject: [PATCH] extract tracking header definition --- .gitignore | 13 +++++++------ .npmignore | 1 + package.json | 2 +- src/__tests__/gatsby-node.spec.js | 3 ++- src/config.js | 6 ++++++ src/gatsby-node.js | 7 ++----- 6 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 src/config.js diff --git a/.gitignore b/.gitignore index fbd8b8a9..4e805282 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -# Project dependencies -node_modules - -# Output files -/gatsby-node.js -/normalize.js +# Project dependencies +node_modules + +# Output files +/gatsby-node.js +/normalize.js +/config.js diff --git a/.npmignore b/.npmignore index 68be49d2..89444707 100644 --- a/.npmignore +++ b/.npmignore @@ -6,6 +6,7 @@ # Recursively allow files under subtree¨ !gatsby-node.js !normalize.js +!config.js !package.json !.npmignore !README.md diff --git a/package.json b/package.json index 66473249..9f46270d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-source-kentico-cloud", - "version": "2.2.0", + "version": "2.2.1", "description": "Gatsby source plugin for Kentico Cloud", "main": "./gatsby-node.js", "scripts": { diff --git a/src/__tests__/gatsby-node.spec.js b/src/__tests__/gatsby-node.spec.js index 6a7548a2..adfea0a8 100644 --- a/src/__tests__/gatsby-node.spec.js +++ b/src/__tests__/gatsby-node.spec.js @@ -1,6 +1,7 @@ const { TestHttpService } = require('kentico-cloud-core'); -const { customTrackingHeader, sourceNodes } = require('../gatsby-node'); +const { sourceNodes } = require('../gatsby-node'); +const { customTrackingHeader } = require('../config'); const { name, version } = require('../../package.json'); describe('customTrackingHeader', () => { diff --git a/src/config.js b/src/config.js new file mode 100644 index 00000000..916bccfe --- /dev/null +++ b/src/config.js @@ -0,0 +1,6 @@ +const customTrackingHeader = { + header: 'X-KC-SOURCE', + value: 'gatsby-source-kentico-cloud;2.2.1', +}; + +exports.customTrackingHeader = customTrackingHeader; diff --git a/src/gatsby-node.js b/src/gatsby-node.js index ebe7cfeb..650033e7 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -3,13 +3,10 @@ const _ = require(`lodash`); const { DeliveryClient } = require(`kentico-cloud-delivery`); const normalize = require(`./normalize`); const { parse, stringify } = require(`flatted/cjs`); +const { customTrackingHeader } = require('./config') + const defaultLanguageLiteral = `default`; -const customTrackingHeader = { - header: 'X-KC-SOURCE', - value: 'gatsby-source-kentico-cloud;2.2.0', -}; -exports.customTrackingHeader = customTrackingHeader; exports.sourceNodes = async ({ actions: { createNode }, createNodeId },