@stackbit/sdk
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -31,8 +31,4 @@ "use strict"; | ||
const envVars = []; | ||
const fileExists = fileBrowser.filePathExists(filePath); | ||
if (!fileExists) { | ||
return envVars; | ||
} | ||
const data = await fileBrowser.getFileData(filePath); | ||
if (typeof data !== 'string') { | ||
if (!data || typeof data !== 'string') { | ||
return envVars; | ||
@@ -39,0 +35,0 @@ } |
import { FileBrowser, FileBrowserAdapterInterface } from './file-browser'; | ||
import { Config } from '../config/config-loader'; | ||
export interface CMSMatcherOptions { | ||
@@ -7,3 +8,3 @@ fileBrowserAdapter?: FileBrowserAdapterInterface; | ||
export interface CMSMatchResult { | ||
cmsName: string; | ||
cmsName: Config['cmsName']; | ||
cmsDir?: string; | ||
@@ -10,0 +11,0 @@ cmsProjectId?: string; |
@@ -13,2 +13,3 @@ "use strict"; | ||
const utils_1 = require("@stackbit/utils"); | ||
const consts_1 = require("../consts"); | ||
class FileSystemFileBrowserAdapter { | ||
@@ -152,3 +153,3 @@ constructor({ dirPath }) { | ||
getFilePathsForFileName(fileName) { | ||
return lodash_1.default.get(this.filePathsByFileName, fileName); | ||
return lodash_1.default.get(this.filePathsByFileName, fileName, []); | ||
} | ||
@@ -168,3 +169,3 @@ directoryPathExists(dirPath) { | ||
const data = await this.fileBrowserAdapter.readFile(filePath); | ||
if (['yml', 'yaml', 'json', 'toml', 'md', 'mdx', 'markdown'].includes(extension)) { | ||
if ([...consts_1.DATA_FILE_EXTENSIONS, ...consts_1.MARKDOWN_FILE_EXTENSIONS].includes(extension)) { | ||
this.fileData[filePath] = utils_1.parseDataByFilePath(data, filePath); | ||
@@ -171,0 +172,0 @@ } |
import { FileBrowser, FileBrowserAdapterInterface } from './file-browser'; | ||
import { Config } from '../config/config-loader'; | ||
export interface SSGMatcherOptions { | ||
@@ -7,8 +8,9 @@ fileBrowserAdapter?: FileBrowserAdapterInterface; | ||
export interface SSGMatchResult { | ||
ssgName: string; | ||
ssgName: Config['ssgName']; | ||
ssgDir?: string; | ||
isTheme?: boolean; | ||
publishDir?: string; | ||
staticDir?: string; | ||
pagesDir?: string; | ||
dataDir?: string; | ||
staticDir?: string; | ||
envVars?: string[]; | ||
@@ -15,0 +17,0 @@ options?: { |
@@ -28,6 +28,7 @@ "use strict"; | ||
partialMatch = await ssgMatcher.match(fileBrowser); | ||
break; | ||
} | ||
else if (ssgMatcher.matchByPackageName) { | ||
partialMatch = await matchSSGByPackageName(fileBrowser, ssgMatcher.matchByPackageName); | ||
} | ||
if (partialMatch) { | ||
break; | ||
@@ -41,2 +42,3 @@ } | ||
ssgName: ssgMatcher.name, | ||
...(lodash_1.default.pick(ssgMatcher, ['publishDir', 'staticDir'])), | ||
...partialMatch | ||
@@ -64,2 +66,3 @@ }; | ||
name: 'gatsby', | ||
publishDir: 'public', | ||
match: async (fileBrowser) => { | ||
@@ -80,2 +83,4 @@ const partialMatch = await matchSSGByPackageName(fileBrowser, 'gatsby'); | ||
name: 'nextjs', | ||
publishDir: 'out', | ||
staticDir: 'static', | ||
matchByPackageName: 'next' | ||
@@ -85,2 +90,3 @@ }, | ||
name: 'hexo', | ||
publishDir: 'public', | ||
matchByPackageName: 'hexo' | ||
@@ -90,2 +96,4 @@ }, | ||
name: 'eleventy', | ||
// TODO: publishDir can be changed in 11ty config, read it from there | ||
publishDir: '_site', | ||
matchByPackageName: '@11ty/eleventy' | ||
@@ -129,3 +137,4 @@ }, | ||
layoutDir: 'layouts', | ||
staticDir: 'static' | ||
staticDir: 'static', | ||
publishDir: 'public' | ||
}; | ||
@@ -149,3 +158,4 @@ if (configFilePath) { | ||
dataDir: dirMap.dataDir, | ||
staticDir: dirMap.staticDir | ||
staticDir: dirMap.staticDir, | ||
publishDir: dirMap.publishDir | ||
}; | ||
@@ -196,3 +206,4 @@ } | ||
layouts_dir: '_layouts', | ||
includes_dir: '_includes' | ||
includes_dir: '_includes', | ||
destination: '_site' | ||
}; | ||
@@ -205,6 +216,7 @@ if (configFilePath) { | ||
ssgDir: '', | ||
isTheme: hasGemspecWithJekyll, | ||
pagesDir: dirMap.source, | ||
dataDir: dirMap.data_dir, | ||
staticDir: dirMap.source, | ||
isTheme: hasGemspecWithJekyll | ||
publishDir: dirMap.destination | ||
}; | ||
@@ -211,0 +223,0 @@ if (hasGemfileWithJekyll || hasGemspecWithJekyll) { |
import { Config } from './config-loader'; | ||
interface WriteConfigOptions { | ||
import { YamlConfig } from './config-schema'; | ||
export interface WriteConfigOptions { | ||
dirPath: string; | ||
@@ -7,2 +8,4 @@ config: Config; | ||
export declare function writeConfig({ dirPath, config }: WriteConfigOptions): Promise<void>; | ||
export {}; | ||
export declare function convertToYamlConfig({ config }: { | ||
config: Config; | ||
}): YamlConfig; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.writeConfig = void 0; | ||
exports.convertToYamlConfig = exports.writeConfig = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
@@ -13,3 +13,3 @@ const fs_extra_1 = __importDefault(require("fs-extra")); | ||
async function writeConfig({ dirPath, config }) { | ||
const yamlConfig = convertToYamlConfig(config); | ||
const yamlConfig = convertToYamlConfig({ config }); | ||
const filePath = path_1.default.join(dirPath, 'stackbit.yaml'); | ||
@@ -19,14 +19,17 @@ await fs_extra_1.default.outputFile(filePath, js_yaml_1.default.dump(yamlConfig)); | ||
exports.writeConfig = writeConfig; | ||
function convertToYamlConfig(config) { | ||
function convertToYamlConfig({ config }) { | ||
const yamlConfig = lodash_1.default.cloneDeep(lodash_1.default.omit(config, 'models')); | ||
yamlConfig.models = lodash_1.default.reduce(config.models, (yamlModels, model) => { | ||
const yamlModel = lodash_1.default.omit(model, ['name', 'invalid']); | ||
if (yamlModel.type === 'page' && !yamlModel.hideContent && yamlModel.fields) { | ||
lodash_1.default.remove(yamlModel.fields, (field) => field.name === 'markdown_content'); | ||
} | ||
yamlModels[model.name] = yamlModel; | ||
return yamlModels; | ||
}, {}); | ||
if (!lodash_1.default.isEmpty(config.models)) { | ||
yamlConfig.models = lodash_1.default.reduce(config.models, (yamlModels, model) => { | ||
const yamlModel = lodash_1.default.omit(model, ['name', 'invalid']); | ||
if (yamlModel.type === 'page' && !yamlModel.hideContent && yamlModel.fields) { | ||
lodash_1.default.remove(yamlModel.fields, (field) => field.name === 'markdown_content'); | ||
} | ||
yamlModels[model.name] = yamlModel; | ||
return yamlModels; | ||
}, {}); | ||
} | ||
return yamlConfig; | ||
} | ||
exports.convertToYamlConfig = convertToYamlConfig; | ||
//# sourceMappingURL=config-writer.js.map |
@@ -16,2 +16,3 @@ "use strict"; | ||
const content_validator_1 = require("./content-validator"); | ||
const consts_1 = require("../consts"); | ||
async function loadContent({ dirPath, config, skipUnmodeledContent }) { | ||
@@ -54,7 +55,5 @@ const { contentItems: dataItems, errors: dataErrors } = await loadDataFiles({ dirPath, config, skipUnmodeledContent }); | ||
const excludedFiles = ['**/node_modules/**']; | ||
const allowedExtensions = ['yml', 'yaml', 'toml', 'json']; | ||
const dataModels = config.models.filter(schema_utils_1.isDataModel); | ||
if (dataDir === '') { | ||
const rootExcludedFiles = ['stackbit.yaml', 'netlify.toml', 'theme.toml', 'package.json', 'package-lock.json', 'yarn-lock.json']; | ||
excludedFiles.push(...rootExcludedFiles); | ||
excludedFiles.push(...consts_1.EXCLUDED_DATA_FILES); | ||
if (configFilePath) { | ||
@@ -69,3 +68,3 @@ excludedFiles.push(configFilePath); | ||
try { | ||
filePaths = await readDirRecursivelyWithFilter(absDataDirPath, excludedFiles, allowedExtensions); | ||
filePaths = await readDirRecursivelyWithFilter(absDataDirPath, excludedFiles, consts_1.DATA_FILE_EXTENSIONS); | ||
} | ||
@@ -104,7 +103,5 @@ catch (error) { | ||
const excludedFiles = lodash_1.default.castArray(config.excludePages || []).concat(['**/node_modules/**']); | ||
const allowedExtensions = ['md', 'mdx', 'markdown']; | ||
const pageModels = config.models.filter(schema_utils_1.isPageModel); | ||
if (pagesDir === '') { | ||
const rootExcludedFiles = ['LICENSE.md', 'README.md', 'README.theme.md', 'CONTRIBUTING.md', 'CHANGELOG.md']; | ||
excludedFiles.push(...rootExcludedFiles); | ||
excludedFiles.push(...consts_1.EXCLUDED_MARKDOWN_FILES); | ||
if (config.publishDir) { | ||
@@ -116,3 +113,3 @@ excludedFiles.push(config.publishDir); | ||
try { | ||
filePaths = await readDirRecursivelyWithFilter(absPagesDirPath, excludedFiles, allowedExtensions); | ||
filePaths = await readDirRecursivelyWithFilter(absPagesDirPath, excludedFiles, consts_1.MARKDOWN_FILE_EXTENSIONS); | ||
} | ||
@@ -153,4 +150,3 @@ catch (error) { | ||
const extension = path_1.default.extname(filePath).substring(1); | ||
const allowedExtensions = ['yml', 'yaml', 'toml', 'json']; | ||
if (!allowedExtensions.includes(extension)) { | ||
if (!consts_1.DATA_FILE_EXTENSIONS.includes(extension)) { | ||
return { | ||
@@ -249,3 +245,3 @@ error: new content_errors_1.FileReadError({ filePath: filePath, error: new Error(`extension '${extension}' is not supported`) }) | ||
// { ...fields, markdown_content: '...md...' } | ||
if (['md', 'mdx', 'markdown'].includes(extension) && lodash_1.default.has(data, 'frontmatter') && lodash_1.default.has(data, 'markdown')) { | ||
if (consts_1.MARKDOWN_FILE_EXTENSIONS.includes(extension) && lodash_1.default.has(data, 'frontmatter') && lodash_1.default.has(data, 'markdown')) { | ||
data = lodash_1.default.assign(data.frontmatter, { markdown_content: data.markdown }); | ||
@@ -252,0 +248,0 @@ } |
export * from './config/config-schema'; | ||
export * from './content/content-errors'; | ||
export { loadConfig, ObjectModel, DataModel, ConfigModel, PageModel, Model, ConfigLoaderOptions, ConfigLoaderResult, Config, ConfigError, ConfigLoadError, ConfigNormalizedValidationError } from './config/config-loader'; | ||
export { writeConfig } from './config/config-writer'; | ||
export { writeConfig, WriteConfigOptions, convertToYamlConfig } from './config/config-writer'; | ||
export { loadContent, ContentItem, ContentLoaderOptions, ContentLoaderResult } from './content/content-loader'; | ||
@@ -6,0 +6,0 @@ export { matchSSG, SSGMatchResult } from './analyzer/ssg-matcher'; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.matchCMS = exports.matchSSG = exports.loadContent = exports.writeConfig = exports.loadConfig = void 0; | ||
exports.matchCMS = exports.matchSSG = exports.loadContent = exports.convertToYamlConfig = exports.writeConfig = exports.loadConfig = void 0; | ||
__exportStar(require("./config/config-schema"), exports); | ||
@@ -21,2 +21,3 @@ __exportStar(require("./content/content-errors"), exports); | ||
Object.defineProperty(exports, "writeConfig", { enumerable: true, get: function () { return config_writer_1.writeConfig; } }); | ||
Object.defineProperty(exports, "convertToYamlConfig", { enumerable: true, get: function () { return config_writer_1.convertToYamlConfig; } }); | ||
var content_loader_1 = require("./content/content-loader"); | ||
@@ -23,0 +24,0 @@ Object.defineProperty(exports, "loadContent", { enumerable: true, get: function () { return content_loader_1.loadContent; } }); |
{ | ||
"name": "@stackbit/sdk", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Stackbit SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import path from 'path'; | ||
import _ from 'lodash'; | ||
import { reducePromise } from '@stackbit/utils'; | ||
import { FileBrowser } from './file-browser'; | ||
@@ -35,8 +36,4 @@ | ||
const envVars: string[] = []; | ||
const fileExists = fileBrowser.filePathExists(filePath); | ||
if (!fileExists) { | ||
return envVars; | ||
} | ||
const data = await fileBrowser.getFileData(filePath); | ||
if (typeof data !== 'string') { | ||
if (!data || typeof data !== 'string') { | ||
return envVars; | ||
@@ -43,0 +40,0 @@ } |
import path from 'path'; | ||
import _ from 'lodash'; | ||
import { forEachPromise, reducePromise } from '@stackbit/utils'; | ||
import { FileBrowser, FileBrowserAdapterInterface } from './file-browser'; | ||
import { findDirsWithPackageDependency } from './analyzer-utils'; | ||
import { Config } from '../config/config-loader'; | ||
@@ -13,3 +15,3 @@ export interface CMSMatcherOptions { | ||
export interface CMSMatchResult { | ||
cmsName: string; | ||
cmsName: Config['cmsName']; | ||
cmsDir?: string; | ||
@@ -65,3 +67,3 @@ cmsProjectId?: string; | ||
interface CSSMatcher { | ||
name: string; | ||
name: Config['cmsName']; | ||
matchByPackageName?: string; | ||
@@ -88,7 +90,10 @@ match?: (fileBrowser: FileBrowser) => Promise<Omit<CMSMatchResult, 'cmsName'> | null>; | ||
const config = await fileBrowser.getFileData(configFilePaths[0]!); | ||
return _.omitBy({ | ||
cmsDir: dirs[0], | ||
cmsProjectId: _.get(config, 'api.projectId'), | ||
cmsEnvironmentName: _.get(config, 'api.dataset') | ||
}, _.isNil); | ||
return _.omitBy( | ||
{ | ||
cmsDir: dirs[0], | ||
cmsProjectId: _.get(config, 'api.projectId'), | ||
cmsEnvironmentName: _.get(config, 'api.dataset') | ||
}, | ||
_.isNil | ||
); | ||
} else if (dirs.length > 1) { | ||
@@ -95,0 +100,0 @@ return { |
@@ -8,2 +8,4 @@ import path from 'path'; | ||
import { DATA_FILE_EXTENSIONS, MARKDOWN_FILE_EXTENSIONS } from '../consts'; | ||
export interface FileResult { | ||
@@ -211,4 +213,4 @@ filePath: string; | ||
getFilePathsForFileName(fileName: string) { | ||
return _.get(this.filePathsByFileName, fileName); | ||
getFilePathsForFileName(fileName: string): string[] { | ||
return _.get(this.filePathsByFileName, fileName, []); | ||
} | ||
@@ -224,3 +226,3 @@ | ||
async getFileData(filePath: string) { | ||
async getFileData(filePath: string): Promise<any> { | ||
if (!this.filePathExists(filePath)) { | ||
@@ -232,3 +234,3 @@ return null; | ||
const data = await this.fileBrowserAdapter.readFile(filePath); | ||
if (['yml', 'yaml', 'json', 'toml', 'md', 'mdx', 'markdown'].includes(extension)) { | ||
if ([...DATA_FILE_EXTENSIONS, ...MARKDOWN_FILE_EXTENSIONS].includes(extension)) { | ||
this.fileData[filePath] = parseDataByFilePath(data, filePath); | ||
@@ -235,0 +237,0 @@ } else { |
import path from 'path'; | ||
import _ from 'lodash'; | ||
import { FileBrowser, FileBrowserAdapterInterface } from './file-browser'; | ||
import { extractNodeEnvironmentVariablesFromFile, findDirsWithPackageDependency } from './analyzer-utils'; | ||
import { Config } from '../config/config-loader'; | ||
@@ -12,8 +14,9 @@ export interface SSGMatcherOptions { | ||
export interface SSGMatchResult { | ||
ssgName: string; | ||
ssgName: Config['ssgName']; | ||
ssgDir?: string; | ||
isTheme?: boolean; | ||
publishDir?: string; | ||
staticDir?: string; | ||
pagesDir?: string; | ||
dataDir?: string; | ||
staticDir?: string; | ||
envVars?: string[]; | ||
@@ -42,5 +45,6 @@ options?: { | ||
partialMatch = await ssgMatcher.match(fileBrowser!); | ||
break; | ||
} else if (ssgMatcher.matchByPackageName) { | ||
partialMatch = await matchSSGByPackageName(fileBrowser!, ssgMatcher.matchByPackageName); | ||
} | ||
if (partialMatch) { | ||
break; | ||
@@ -54,2 +58,3 @@ } | ||
ssgName: ssgMatcher.name, | ||
...(_.pick(ssgMatcher, ['publishDir', 'staticDir'])), | ||
...partialMatch | ||
@@ -76,4 +81,6 @@ }; | ||
interface SSGMatcher { | ||
name: string; | ||
name: Config['ssgName']; | ||
matchByPackageName?: string; | ||
publishDir?: string; | ||
staticDir?: string; | ||
match?: (fileBrowser: FileBrowser) => Promise<Omit<SSGMatchResult, 'ssgName'> | null>; | ||
@@ -85,2 +92,3 @@ } | ||
name: 'gatsby', | ||
publishDir: 'public', | ||
match: async (fileBrowser) => { | ||
@@ -101,2 +109,4 @@ const partialMatch = await matchSSGByPackageName(fileBrowser, 'gatsby'); | ||
name: 'nextjs', | ||
publishDir: 'out', | ||
staticDir: 'static', | ||
matchByPackageName: 'next' | ||
@@ -106,2 +116,3 @@ }, | ||
name: 'hexo', | ||
publishDir: 'public', | ||
matchByPackageName: 'hexo' | ||
@@ -111,2 +122,4 @@ }, | ||
name: 'eleventy', | ||
// TODO: publishDir can be changed in 11ty config, read it from there | ||
publishDir: '_site', | ||
matchByPackageName: '@11ty/eleventy' | ||
@@ -150,3 +163,4 @@ }, | ||
layoutDir: 'layouts', | ||
staticDir: 'static' | ||
staticDir: 'static', | ||
publishDir: 'public' | ||
}; | ||
@@ -170,3 +184,4 @@ if (configFilePath) { | ||
dataDir: dirMap.dataDir, | ||
staticDir: dirMap.staticDir | ||
staticDir: dirMap.staticDir, | ||
publishDir: dirMap.publishDir | ||
}; | ||
@@ -221,3 +236,4 @@ } | ||
layouts_dir: '_layouts', | ||
includes_dir: '_includes' | ||
includes_dir: '_includes', | ||
destination: '_site' | ||
}; | ||
@@ -230,6 +246,7 @@ if (configFilePath) { | ||
ssgDir: '', | ||
isTheme: hasGemspecWithJekyll, | ||
pagesDir: dirMap.source, | ||
dataDir: dirMap.data_dir, | ||
staticDir: dirMap.source, | ||
isTheme: hasGemspecWithJekyll | ||
publishDir: dirMap.destination | ||
}; | ||
@@ -236,0 +253,0 @@ |
@@ -5,6 +5,7 @@ import path from 'path'; | ||
import _ from 'lodash'; | ||
import { Config, Model } from './config-loader'; | ||
import { YamlConfig, YamlModel, YamlModels } from './config-schema'; | ||
interface WriteConfigOptions { | ||
export interface WriteConfigOptions { | ||
dirPath: string; | ||
@@ -15,3 +16,3 @@ config: Config; | ||
export async function writeConfig({ dirPath, config }: WriteConfigOptions) { | ||
const yamlConfig = convertToYamlConfig(config); | ||
const yamlConfig = convertToYamlConfig({ config }); | ||
const filePath = path.join(dirPath, 'stackbit.yaml'); | ||
@@ -21,17 +22,19 @@ await fse.outputFile(filePath, yaml.dump(yamlConfig)); | ||
function convertToYamlConfig(config: Config) { | ||
export function convertToYamlConfig({ config }: { config: Config }): YamlConfig { | ||
const yamlConfig: YamlConfig = _.cloneDeep(_.omit(config, 'models')); | ||
yamlConfig.models = _.reduce( | ||
config.models, | ||
(yamlModels: YamlModels, model: Model) => { | ||
const yamlModel = _.omit(model, ['name', 'invalid']) as YamlModel; | ||
if (yamlModel.type === 'page' && !yamlModel.hideContent && yamlModel.fields) { | ||
_.remove(yamlModel.fields, (field) => field.name === 'markdown_content'); | ||
} | ||
yamlModels[model.name] = yamlModel; | ||
return yamlModels; | ||
}, | ||
{} | ||
); | ||
if (!_.isEmpty(config.models)) { | ||
yamlConfig.models = _.reduce( | ||
config.models, | ||
(yamlModels: YamlModels, model: Model) => { | ||
const yamlModel = _.omit(model, ['name', 'invalid']) as YamlModel; | ||
if (yamlModel.type === 'page' && !yamlModel.hideContent && yamlModel.fields) { | ||
_.remove(yamlModel.fields, (field) => field.name === 'markdown_content'); | ||
} | ||
yamlModels[model.name] = yamlModel; | ||
return yamlModels; | ||
}, | ||
{} | ||
); | ||
} | ||
return yamlConfig; | ||
} |
@@ -5,10 +5,11 @@ import _ from 'lodash'; | ||
import micromatch from 'micromatch'; | ||
import { parseFile, readDirRecursively, forEachPromise, findPromise } from '@stackbit/utils'; | ||
import { getModelsByQuery, isListField, getListItemsField } from '@stackbit/schema'; | ||
import { findPromise, forEachPromise, parseFile, readDirRecursively } from '@stackbit/utils'; | ||
import { getListItemsField, getModelsByQuery, isListField } from '@stackbit/schema'; | ||
import { ConfigModel, Model, Config } from '../config/config-loader'; | ||
import { Config, ConfigModel, Model } from '../config/config-loader'; | ||
import { Field, FieldModel } from '../config/config-schema'; | ||
import { FileNotMatchedModelError, FileMatchedMultipleModelsError, FileReadError, FileForModelNotFoundError, FolderReadError } from './content-errors'; | ||
import { FileForModelNotFoundError, FileMatchedMultipleModelsError, FileNotMatchedModelError, FileReadError, FolderReadError } from './content-errors'; | ||
import { isConfigModel, isDataModel, isPageModel } from '../schema-utils'; | ||
import { validate } from './content-validator'; | ||
import { DATA_FILE_EXTENSIONS, EXCLUDED_DATA_FILES, EXCLUDED_MARKDOWN_FILES, MARKDOWN_FILE_EXTENSIONS } from '../consts'; | ||
@@ -102,8 +103,6 @@ interface BaseMetadata { | ||
const excludedFiles = ['**/node_modules/**']; | ||
const allowedExtensions = ['yml', 'yaml', 'toml', 'json']; | ||
const dataModels = config.models.filter(isDataModel); | ||
if (dataDir === '') { | ||
const rootExcludedFiles = ['stackbit.yaml', 'netlify.toml', 'theme.toml', 'package.json', 'package-lock.json', 'yarn-lock.json']; | ||
excludedFiles.push(...rootExcludedFiles); | ||
excludedFiles.push(...EXCLUDED_DATA_FILES); | ||
if (configFilePath) { | ||
@@ -119,3 +118,3 @@ excludedFiles.push(configFilePath); | ||
try { | ||
filePaths = await readDirRecursivelyWithFilter(absDataDirPath, excludedFiles, allowedExtensions); | ||
filePaths = await readDirRecursivelyWithFilter(absDataDirPath, excludedFiles, DATA_FILE_EXTENSIONS); | ||
} catch (error) { | ||
@@ -158,8 +157,6 @@ return { | ||
const excludedFiles = _.castArray(config.excludePages || []).concat(['**/node_modules/**']); | ||
const allowedExtensions = ['md', 'mdx', 'markdown']; | ||
const pageModels = config.models.filter(isPageModel); | ||
if (pagesDir === '') { | ||
const rootExcludedFiles = ['LICENSE.md', 'README.md', 'README.theme.md', 'CONTRIBUTING.md', 'CHANGELOG.md']; | ||
excludedFiles.push(...rootExcludedFiles); | ||
excludedFiles.push(...EXCLUDED_MARKDOWN_FILES); | ||
if (config.publishDir) { | ||
@@ -172,3 +169,3 @@ excludedFiles.push(config.publishDir); | ||
try { | ||
filePaths = await readDirRecursivelyWithFilter(absPagesDirPath, excludedFiles, allowedExtensions); | ||
filePaths = await readDirRecursivelyWithFilter(absPagesDirPath, excludedFiles, MARKDOWN_FILE_EXTENSIONS); | ||
} catch (error) { | ||
@@ -209,4 +206,3 @@ return { | ||
const extension = path.extname(filePath).substring(1); | ||
const allowedExtensions = ['yml', 'yaml', 'toml', 'json']; | ||
if (!allowedExtensions.includes(extension)) { | ||
if (!DATA_FILE_EXTENSIONS.includes(extension)) { | ||
return { | ||
@@ -328,3 +324,3 @@ error: new FileReadError({ filePath: filePath, error: new Error(`extension '${extension}' is not supported`) }) | ||
// { ...fields, markdown_content: '...md...' } | ||
if (['md', 'mdx', 'markdown'].includes(extension) && _.has(data, 'frontmatter') && _.has(data, 'markdown')) { | ||
if (MARKDOWN_FILE_EXTENSIONS.includes(extension) && _.has(data, 'frontmatter') && _.has(data, 'markdown')) { | ||
data = _.assign(data.frontmatter, { markdown_content: data.markdown }); | ||
@@ -331,0 +327,0 @@ } |
@@ -17,3 +17,3 @@ export * from './config/config-schema'; | ||
} from './config/config-loader'; | ||
export { writeConfig } from './config/config-writer'; | ||
export { writeConfig, WriteConfigOptions, convertToYamlConfig } from './config/config-writer'; | ||
export { loadContent, ContentItem, ContentLoaderOptions, ContentLoaderResult } from './content/content-loader'; | ||
@@ -20,0 +20,0 @@ export { matchSSG, SSGMatchResult } from './analyzer/ssg-matcher'; |
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
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
443015
112
6476