contentful-hugo
Advanced tools
Comparing version 2.1.0 to 2.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LOG_PREFIX = void 0; | ||
// eslint-disable-next-line import/prefer-default-export | ||
exports.LOG_PREFIX = '[contentful hugo]'; | ||
//# sourceMappingURL=contants.js.map |
@@ -0,4 +1,4 @@ | ||
import { ContentfulClientApi } from 'contentful'; | ||
import { ConfigContentfulSettings } from '../main/config/types'; | ||
import { ContentfulClientApi } from 'contentful'; | ||
declare const createContentfulClient: (settings: ConfigContentfulSettings, previewMode?: boolean) => ContentfulClientApi; | ||
export default createContentfulClient; |
@@ -14,2 +14,2 @@ export declare enum LogCategories { | ||
*/ | ||
export declare const initLogger: (quietMode?: boolean, verboseMode?: boolean) => (message: unknown, type?: LogTypes, category?: LogCategories) => void; | ||
export declare const initLogger: (quietMode?: boolean, verboseMode?: boolean) => typeof log; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.replaceBackslashesWithForwardSlashes = exports.endsWith = exports.trailingSpaces = exports.leadingSpaces = exports.removeLeadingAndTrailingSlashes = exports.specialEntities = exports.replaceSpecialEntities = exports.isMultilineString = exports.characterIsWhiteSpace = void 0; | ||
var removeLeadingAndTrailingSlashes = function (string) { | ||
return string.replace(/^\/+|\/+$/g, ''); | ||
}; | ||
var removeLeadingAndTrailingSlashes = function (string) { return string.replace(/^\/+|\/+$/g, ''); }; | ||
exports.removeLeadingAndTrailingSlashes = removeLeadingAndTrailingSlashes; | ||
@@ -40,5 +38,3 @@ var isMultilineString = function (string) { | ||
exports.replaceSpecialEntities = replaceSpecialEntities; | ||
var characterIsWhiteSpace = function (char) { | ||
return /\s/.test(char); | ||
}; | ||
var characterIsWhiteSpace = function (char) { return /\s/.test(char); }; | ||
exports.characterIsWhiteSpace = characterIsWhiteSpace; | ||
@@ -86,10 +82,6 @@ var leadingSpaces = function (string, count) { | ||
*/ | ||
var endsWith = function (str, ext) { | ||
return new RegExp("".concat(ext, "$")).test(str || ''); | ||
}; | ||
var endsWith = function (str, ext) { return new RegExp("".concat(ext, "$")).test(str || ''); }; | ||
exports.endsWith = endsWith; | ||
var replaceBackslashesWithForwardSlashes = function (input) { | ||
return input.replace(/\\/g, '/'); | ||
}; | ||
var replaceBackslashesWithForwardSlashes = function (input) { return input.replace(/\\/g, '/'); }; | ||
exports.replaceBackslashesWithForwardSlashes = replaceBackslashesWithForwardSlashes; | ||
//# sourceMappingURL=strings.js.map |
@@ -7,7 +7,5 @@ "use strict"; | ||
} | ||
else { | ||
return false; | ||
} | ||
return false; | ||
}; | ||
exports.default = checkIfFinished; | ||
//# sourceMappingURL=checkIfFinished.js.map |
@@ -10,3 +10,3 @@ import { ContentfulHugoConfig } from './types'; | ||
*/ | ||
declare const loadFile: (rootDir: string | undefined, fileName: string) => Promise<ContentfulHugoConfig | false>; | ||
declare const loadFile: (rootDir?: string, fileName?: string) => Promise<ContentfulHugoConfig | false>; | ||
export { loadFile, loadJavascriptConfigFile, loadYamlConfigFile, checkContentfulSettings, }; |
@@ -72,3 +72,3 @@ "use strict"; | ||
var loadJavascriptConfigFile = function (filePath) { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
// eslint-disable-next-line global-require | ||
var configObject = require(filePath); | ||
@@ -108,2 +108,3 @@ if (configObject && typeof configObject === 'object') { | ||
if (rootDir === void 0) { rootDir = '.'; } | ||
if (fileName === void 0) { fileName = ''; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -110,0 +111,0 @@ var filePath, fileType; |
@@ -67,2 +67,3 @@ "use strict"; | ||
case 0: | ||
// eslint-disable-next-line no-param-reassign | ||
rootDir = path_1.default.resolve(rootDir); | ||
@@ -91,4 +92,4 @@ if (!fileName) return [3 /*break*/, 2]; | ||
if (result) { | ||
var config_1 = (0, fileLoader_1.checkContentfulSettings)(result); | ||
configList.push(config_1); | ||
var conf = (0, fileLoader_1.checkContentfulSettings)(result); | ||
configList.push(conf); | ||
} | ||
@@ -95,0 +96,0 @@ }); |
@@ -22,7 +22,5 @@ "use strict"; | ||
exports.determineFileType = determineFileType; | ||
var isValidFileExtension = function (extension) { | ||
return ['md', 'yaml', 'yml', 'json'].some(function (ext) { | ||
return (0, strings_1.endsWith)(extension || 'md', ext); | ||
}); | ||
}; | ||
var isValidFileExtension = function (extension) { return ['md', 'yaml', 'yml', 'json'].some(function (ext) { | ||
return (0, strings_1.endsWith)(extension || 'md', ext); | ||
}); }; | ||
exports.isValidFileExtension = isValidFileExtension; | ||
@@ -29,0 +27,0 @@ var isTypeConfig = function (input) { |
import { ContentSettings } from './index'; | ||
import { ConfigContentfulSettings } from './config/types'; | ||
export declare const prepDirectory: (settings: ContentSettings) => Promise<void>; | ||
declare const getContentType: (limit: number, skip: number, contentSettings: ContentSettings, contentfulSettings: ConfigContentfulSettings, previewMode?: boolean, itemsPulled?: number | undefined, directoryPrepped?: boolean) => Promise<{ | ||
declare const getContentType: (limit: number, skip: number, contentSettings: ContentSettings, contentfulSettings: ConfigContentfulSettings, previewMode?: boolean, itemsPulled?: number, directoryPrepped?: boolean) => Promise<{ | ||
totalItems: number; | ||
@@ -6,0 +6,0 @@ typeId: string; |
@@ -79,2 +79,3 @@ "use strict"; | ||
if (previewMode === void 0) { previewMode = false; } | ||
if (itemsPulled === void 0) { itemsPulled = 0; } | ||
if (directoryPrepped === void 0) { directoryPrepped = false; } | ||
@@ -112,2 +113,3 @@ return __awaiter(void 0, void 0, void 0, function () { | ||
if (!contentSettings.fileExtension) { | ||
// eslint-disable-next-line no-param-reassign | ||
contentSettings.fileExtension = 'md'; | ||
@@ -114,0 +116,0 @@ } |
@@ -54,2 +54,3 @@ "use strict"; | ||
exports.copyStaticContent = exports.initializeDirectory = exports.loadConfig = exports.fetchDataFromContentful = void 0; | ||
var Limiter = require("async-limiter"); | ||
var config_1 = require("./config"); | ||
@@ -65,3 +66,2 @@ Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } }); | ||
Object.defineProperty(exports, "copyStaticContent", { enumerable: true, get: function () { return fileManager_1.copyStaticContent; } }); | ||
var Limiter = require("async-limiter"); | ||
var logger_1 = require("../helpers/logger"); | ||
@@ -68,0 +68,0 @@ var fetchType = function (limit, skip, settings, contentfulSettings, preview) { |
@@ -50,5 +50,3 @@ "use strict"; | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
return resolve(); | ||
}, milli); | ||
setTimeout(function () { return resolve(); }, milli); | ||
}); | ||
@@ -55,0 +53,0 @@ }; |
@@ -19,5 +19,3 @@ "use strict"; | ||
var noExtension = name_1.replace('.html', ''); | ||
var camelCaseName = noExtension.replace(/-([a-z])/g, function (g) { | ||
return g[1].toUpperCase(); | ||
}); | ||
var camelCaseName = noExtension.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); | ||
shortcodes[camelCaseName] = { | ||
@@ -24,0 +22,0 @@ filename: name_1, |
@@ -97,6 +97,6 @@ "use strict"; | ||
} | ||
else if (isTaxonomy) { | ||
if (isTaxonomy) { | ||
return "./".concat(path, "/").concat(fName, "/_index.").concat(ext); | ||
} | ||
else if (isSingle) { | ||
if (isSingle) { | ||
return "./".concat(path, "/").concat(fName, ".").concat(ext); | ||
@@ -206,3 +206,2 @@ } | ||
var setFileContent = function (frontMatter, fileExtension, mainContent) { | ||
if (frontMatter === void 0) { frontMatter = {}; } | ||
var fileContent = ''; | ||
@@ -235,49 +234,46 @@ switch (fileExtension) { | ||
*/ | ||
var createFile = function (contentSettings, entryId, frontMatter, mainContent) { | ||
if (frontMatter === void 0) { frontMatter = {}; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var fileExtension, isHeadless, isTaxonomy, isSingle, fileContent, hasDynamicFilename, filePath; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
fileExtension = contentSettings.fileExtension, isHeadless = contentSettings.isHeadless, isTaxonomy = contentSettings.isTaxonomy, isSingle = contentSettings.isSingle; | ||
if (isHeadless && isTaxonomy) { | ||
throw new Error('A content type cannot have both isHeadless and isTaxonomy set to true'); | ||
} | ||
fileContent = setFileContent(frontMatter, fileExtension || null, mainContent); | ||
hasDynamicFilename = typeof contentSettings.fileName === 'string' && !isSingle; | ||
if (!hasDynamicFilename) return [3 /*break*/, 2]; | ||
// since filename can change we need to delete the previous instance | ||
return [4 /*yield*/, cleanPreviousDynamicLocation(contentSettings, entryId)]; | ||
case 1: | ||
// since filename can change we need to delete the previous instance | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
var createFile = function (contentSettings, entryId, frontMatter, mainContent) { return __awaiter(void 0, void 0, void 0, function () { | ||
var fileExtension, isHeadless, isTaxonomy, isSingle, fileContent, hasDynamicFilename, filePath; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
fileExtension = contentSettings.fileExtension, isHeadless = contentSettings.isHeadless, isTaxonomy = contentSettings.isTaxonomy, isSingle = contentSettings.isSingle; | ||
if (isHeadless && isTaxonomy) { | ||
throw new Error('A content type cannot have both isHeadless and isTaxonomy set to true'); | ||
} | ||
fileContent = setFileContent(frontMatter, fileExtension || null, mainContent); | ||
hasDynamicFilename = typeof contentSettings.fileName === 'string' && !isSingle; | ||
if (!hasDynamicFilename) return [3 /*break*/, 2]; | ||
// since filename can change we need to delete the previous instance | ||
return [4 /*yield*/, cleanPreviousDynamicLocation(contentSettings, entryId)]; | ||
case 1: | ||
// since filename can change we need to delete the previous instance | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
// create file | ||
return [4 /*yield*/, (0, exports.createDirectoryForFile)(contentSettings, entryId)]; | ||
case 3: | ||
// create file | ||
return [4 /*yield*/, (0, exports.createDirectoryForFile)(contentSettings, entryId)]; | ||
case 3: | ||
// create file | ||
_a.sent(); | ||
filePath = (0, exports.determineFilePath)(contentSettings, entryId); | ||
return [4 /*yield*/, (0, fs_extra_1.writeFile)(filePath, fileContent).catch(function (error) { | ||
if (error) { | ||
(0, logger_1.log)(error); | ||
} | ||
})]; | ||
case 4: | ||
_a.sent(); | ||
if (!hasDynamicFilename) return [3 /*break*/, 6]; | ||
// write the new location to filesystem so we can delete if it changes | ||
return [4 /*yield*/, logDynamicLocation(contentSettings, entryId, filePath)]; | ||
case 5: | ||
// write the new location to filesystem so we can delete if it changes | ||
_a.sent(); | ||
_a.label = 6; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
_a.sent(); | ||
filePath = (0, exports.determineFilePath)(contentSettings, entryId); | ||
return [4 /*yield*/, (0, fs_extra_1.writeFile)(filePath, fileContent).catch(function (error) { | ||
if (error) { | ||
(0, logger_1.log)(error); | ||
} | ||
})]; | ||
case 4: | ||
_a.sent(); | ||
if (!hasDynamicFilename) return [3 /*break*/, 6]; | ||
// write the new location to filesystem so we can delete if it changes | ||
return [4 /*yield*/, logDynamicLocation(contentSettings, entryId, filePath)]; | ||
case 5: | ||
// write the new location to filesystem so we can delete if it changes | ||
_a.sent(); | ||
_a.label = 6; | ||
case 6: return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
}); }; | ||
exports.default = createFile; | ||
//# sourceMappingURL=createFile.js.map |
@@ -24,3 +24,2 @@ "use strict"; | ||
entry, locale) { | ||
if (entry === void 0) { entry = {}; } | ||
var strParts = nameStr.split('.'); | ||
@@ -27,0 +26,0 @@ if (typeof entry !== 'object') { |
@@ -0,7 +1,7 @@ | ||
import { Entry } from 'contentful'; | ||
import { CustomFieldsConfig } from '../../config/types'; | ||
import { Entry } from 'contentful'; | ||
interface AppendableFieldsResult { | ||
[key: string]: unknown; | ||
} | ||
declare const getCustomFields: (appendFields: CustomFieldsConfig | undefined, entry: Entry<unknown>) => AppendableFieldsResult; | ||
declare const getCustomFields: (appendFields: CustomFieldsConfig, entry: Entry<unknown>) => AppendableFieldsResult; | ||
export default getCustomFields; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var getCustomFields = function (appendFields, entry) { | ||
if (appendFields === void 0) { appendFields = {}; } | ||
var fields = {}; | ||
Object.keys(appendFields).forEach(function (key) { | ||
var fieldVal = appendFields[key]; | ||
switch (typeof fieldVal) { | ||
case 'function': | ||
fields[key] = fieldVal(entry); | ||
break; | ||
default: | ||
fields[key] = fieldVal; | ||
break; | ||
} | ||
}); | ||
if (typeof appendFields === 'object') { | ||
Object.keys(appendFields).forEach(function (key) { | ||
var fieldVal = appendFields[key]; | ||
switch (typeof fieldVal) { | ||
case 'function': | ||
fields[key] = fieldVal(entry); | ||
break; | ||
default: | ||
fields[key] = fieldVal; | ||
break; | ||
} | ||
}); | ||
} | ||
return fields; | ||
@@ -18,0 +19,0 @@ }; |
@@ -121,3 +121,3 @@ "use strict"; | ||
var year = input.split('-')[0]; | ||
if (isNaN(Number(year))) { | ||
if (Number.isNaN(Number(year))) { | ||
return false; | ||
@@ -127,3 +127,3 @@ } | ||
var date = Date.parse(input); | ||
if (isNaN(date)) { | ||
if (Number.isNaN(date)) { | ||
return false; | ||
@@ -185,2 +185,3 @@ } | ||
if (fieldOverride && ((_b = fieldOverride.options) === null || _b === void 0 ? void 0 : _b.fieldName)) { | ||
// eslint-disable-next-line prefer-destructuring | ||
fieldName = fieldOverride.options.fieldName; | ||
@@ -187,0 +188,0 @@ } |
@@ -20,2 +20,4 @@ "use strict"; | ||
return (0, getAssetFields_1.default)(target); | ||
default: | ||
break; | ||
} | ||
@@ -34,2 +36,3 @@ } | ||
var item = node_1[_i]; | ||
// eslint-disable-next-line no-use-before-define | ||
contentArr.push(richTextNodes(item)); | ||
@@ -36,0 +39,0 @@ } |
@@ -9,7 +9,7 @@ "use strict"; | ||
var _a, _b; | ||
return { | ||
return ({ | ||
id: target.sys.id, | ||
// contentType doesn't exist if the entry is "missing or inaccessible" | ||
contentType: (_b = (_a = target.sys.contentType) === null || _a === void 0 ? void 0 : _a.sys) === null || _b === void 0 ? void 0 : _b.id, | ||
}; | ||
}); | ||
}; | ||
@@ -38,3 +38,3 @@ var mapAsset = function (target) { | ||
if (parentContentType === void 0) { parentContentType = ''; } | ||
return _a = {}, | ||
return (_a = {}, | ||
_a[rich_text_types_1.BLOCKS.HEADING_1] = function (node, next) { | ||
@@ -91,5 +91,3 @@ return "# ".concat(next(node.content), "\n\n"); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_a[rich_text_types_1.BLOCKS.HR] = function (node, next) { | ||
return "---\n\n"; | ||
}, | ||
_a[rich_text_types_1.BLOCKS.HR] = function (_node, _next) { return "---\n\n"; }, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
@@ -126,3 +124,3 @@ _a[rich_text_types_1.BLOCKS.EMBEDDED_ASSET] = function (node, next) { | ||
}, | ||
_a; | ||
_a); | ||
}; | ||
@@ -137,10 +135,6 @@ var sanitizedMarkOutput = function (input, markWrapper) { | ||
if (parentContentType === void 0) { parentContentType = ''; } | ||
return { | ||
return ({ | ||
renderMark: (_a = {}, | ||
_a[rich_text_types_1.MARKS.BOLD] = function (text) { | ||
return sanitizedMarkOutput(text, '**'); | ||
}, | ||
_a[rich_text_types_1.MARKS.ITALIC] = function (text) { | ||
return sanitizedMarkOutput(text, '_'); | ||
}, | ||
_a[rich_text_types_1.MARKS.BOLD] = function (text) { return sanitizedMarkOutput(text, '**'); }, | ||
_a[rich_text_types_1.MARKS.ITALIC] = function (text) { return sanitizedMarkOutput(text, '_'); }, | ||
_a[rich_text_types_1.MARKS.CODE] = function (text) { | ||
@@ -154,3 +148,3 @@ if ((0, strings_1.isMultilineString)(text)) { | ||
renderNode: optionsRenderNode(parentContentType), | ||
}; | ||
}); | ||
}; | ||
@@ -157,0 +151,0 @@ /** |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -7,4 +43,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var chokidar_1 = __importDefault(require("chokidar")); | ||
var strings_1 = require("../../helpers/strings"); | ||
var fileManager_1 = require("./fileManager"); | ||
var strings_1 = require("../../helpers/strings"); | ||
var contants_1 = require("../../helpers/contants"); | ||
@@ -29,18 +65,36 @@ var logger_1 = require("../../helpers/logger"); | ||
}; | ||
var handleCopy = function (path) { | ||
var rootDir = getRootDir(path); | ||
var outDir = directoryMap[rootDir]; | ||
if (!outDir) { | ||
return; | ||
} | ||
return (0, fileManager_1.copyFileToOutputDirectory)(path, rootDir, outDir); | ||
}; | ||
var handleDelete = function (path) { | ||
var rootDir = getRootDir(path); | ||
var outDir = directoryMap[rootDir]; | ||
if (!outDir) { | ||
return; | ||
} | ||
return (0, fileManager_1.deleteFileFromOutputDirectory)(path, rootDir, outDir); | ||
}; | ||
var handleCopy = function (path) { return __awaiter(void 0, void 0, void 0, function () { | ||
var rootDir, outDir; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
rootDir = getRootDir(path); | ||
outDir = directoryMap[rootDir]; | ||
if (!outDir) { | ||
return [2 /*return*/]; | ||
} | ||
return [4 /*yield*/, (0, fileManager_1.copyFileToOutputDirectory)(path, rootDir, outDir)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
var handleDelete = function (path) { return __awaiter(void 0, void 0, void 0, function () { | ||
var rootDir, outDir; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
rootDir = getRootDir(path); | ||
outDir = directoryMap[rootDir]; | ||
if (!outDir) { | ||
return [2 /*return*/]; | ||
} | ||
return [4 /*yield*/, (0, fileManager_1.deleteFileFromOutputDirectory)(path, rootDir, outDir)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
var watcher = chokidar_1.default.watch(watchPaths, { | ||
@@ -47,0 +101,0 @@ persistent: true, |
@@ -39,5 +39,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var logger_1 = require("../helpers/logger"); | ||
var fs_extra_1 = require("fs-extra"); | ||
var path_1 = require("path"); | ||
var logger_1 = require("../helpers/logger"); | ||
var deleteFile = function (filePath, quietMode) { | ||
@@ -44,0 +44,0 @@ if (quietMode === void 0) { quietMode = false; } |
@@ -199,2 +199,3 @@ "use strict"; | ||
case 9: | ||
// eslint-disable-next-line no-await-in-loop | ||
path = _b.sent(); | ||
@@ -201,0 +202,0 @@ _b.label = 10; |
@@ -42,4 +42,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var contentful_1 = __importDefault(require("../helpers/contentful")); | ||
var logger_1 = require("../helpers/logger"); | ||
var contentful_1 = __importDefault(require("../helpers/contentful")); | ||
var fetchEntryFromContentful_1 = __importDefault(require("./fetchEntryFromContentful")); | ||
@@ -46,0 +46,0 @@ var fetchEntriesLinkedToAsset = function (assetId, config, previewMode) { |
@@ -48,27 +48,25 @@ "use strict"; | ||
var logger_1 = require("../helpers/logger"); | ||
var updateEntry = function (config, sys, previewMode) { | ||
return (0, fetchEntryFromContentful_1.default)(sys.id, sys.contentType.sys.id, config, previewMode).then(function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var fileLocations, _i, fileLocations_1, location_1, message, payload; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, determineFileLocation_1.default)(config, sys.id, sys.contentType.sys.id, false)]; | ||
case 1: | ||
fileLocations = _a.sent(); | ||
for (_i = 0, fileLocations_1 = fileLocations; _i < fileLocations_1.length; _i++) { | ||
location_1 = fileLocations_1[_i]; | ||
(0, logger_1.log)("[contentful hugo] created ".concat((0, path_1.resolve)(location_1))); | ||
} | ||
message = "Created ".concat(fileLocations.length, " file").concat(fileLocations.length === 1 ? '' : 's'); | ||
payload = { | ||
message: message, | ||
date: new Date(), | ||
entryId: sys.id, | ||
contentType: sys.contentType.sys.id, | ||
files: fileLocations, | ||
}; | ||
return [2 /*return*/, payload]; | ||
} | ||
}); | ||
}); }); | ||
}; | ||
var updateEntry = function (config, sys, previewMode) { return (0, fetchEntryFromContentful_1.default)(sys.id, sys.contentType.sys.id, config, previewMode).then(function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var fileLocations, _i, fileLocations_1, location_1, message, payload; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, determineFileLocation_1.default)(config, sys.id, sys.contentType.sys.id, false)]; | ||
case 1: | ||
fileLocations = _a.sent(); | ||
for (_i = 0, fileLocations_1 = fileLocations; _i < fileLocations_1.length; _i++) { | ||
location_1 = fileLocations_1[_i]; | ||
(0, logger_1.log)("[contentful hugo] created ".concat((0, path_1.resolve)(location_1))); | ||
} | ||
message = "Created ".concat(fileLocations.length, " file").concat(fileLocations.length === 1 ? '' : 's'); | ||
payload = { | ||
message: message, | ||
date: new Date(), | ||
entryId: sys.id, | ||
contentType: sys.contentType.sys.id, | ||
files: fileLocations, | ||
}; | ||
return [2 /*return*/, payload]; | ||
} | ||
}); | ||
}); }); }; | ||
exports.updateEntry = updateEntry; | ||
@@ -75,0 +73,0 @@ var removeEntry = function (config, sys) { return __awaiter(void 0, void 0, void 0, function () { |
@@ -123,5 +123,3 @@ #!/usr/bin/env node | ||
} | ||
app.get('/status', function (_req, res) { | ||
return res.status(200).send('ok'); | ||
}); | ||
app.get('/status', function (_req, res) { return res.status(200).send('ok'); }); | ||
app.post('/', function (req, res) { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -160,5 +158,3 @@ var sys, triggerType; | ||
case 'Entry': | ||
return [2 /*return*/, (0, handleEntry_1.updateEntry)(config, sys, previewMode).then(function (payload) { | ||
return res.status(200).send(payload); | ||
})]; | ||
return [2 /*return*/, (0, handleEntry_1.updateEntry)(config, sys, previewMode).then(function (payload) { return res.status(200).send(payload); })]; | ||
case 'Asset': | ||
@@ -179,5 +175,3 @@ // handle asset publish / changes (find affected entries and refetch them) | ||
case 'DeletedEntry': | ||
return [2 /*return*/, (0, handleEntry_1.removeEntry)(config, sys).then(function (payload) { | ||
return res.status(200).send(payload); | ||
})]; | ||
return [2 /*return*/, (0, handleEntry_1.removeEntry)(config, sys).then(function (payload) { return res.status(200).send(payload); })]; | ||
case 'Asset': | ||
@@ -184,0 +178,0 @@ // handle asset removal (find entries connected to an asset that has been modified and refetch them) |
{ | ||
"name": "contentful-hugo", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Node module that pulls data from Contentful and turns it into markdown files for Hugo. Can be used with other Static Site Generators, but has some Hugo specific features.", | ||
@@ -31,3 +31,3 @@ "main": "./dist/main/index.js", | ||
"lint": "eslint --ext .js,.ts .", | ||
"lint:fix": "eslint . --fix", | ||
"lint:fix": "eslint --ext .js,.ts . --fix", | ||
"postinstall": "node postInstall.js", | ||
@@ -68,10 +68,10 @@ "prebuild": "npm run lint", | ||
"@types/js-yaml": "^4.0.4", | ||
"@typescript-eslint/eslint-plugin": "^5.1.0", | ||
"@typescript-eslint/parser": "^5.1.0", | ||
"eslint": "^8.2.0", | ||
"@typescript-eslint/eslint-plugin": "^5.9.0", | ||
"@typescript-eslint/parser": "^5.9.0", | ||
"eslint": "^8.6.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-standard": "^16.0.3", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^5.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"jest": "^27.2.5", | ||
@@ -78,0 +78,0 @@ "prettier": "^2.4.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
298223
3682