@mintlify/prebuild
Advanced tools
Comparing version 1.0.26 to 1.0.27
@@ -1,19 +0,4 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./fs"), exports); | ||
__exportStar(require("./generate"), exports); | ||
__exportStar(require("./utils"), exports); | ||
export * from './fs/index.js'; | ||
export * from './generate.js'; | ||
export * from './utils.js'; | ||
export * from './prebuild/index.js'; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
@@ -64,22 +63,17 @@ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getFileList = exports.getFileListWithDirectories = exports.getFileListSync = void 0; | ||
var fs_1 = require("fs"); | ||
var promises_1 = require("fs/promises"); | ||
var path_1 = __importDefault(require("path")); | ||
var getFileListSync = function (dirName, og) { | ||
import { readdirSync } from 'fs'; | ||
import { readdir } from 'fs/promises'; | ||
import path from 'path'; | ||
export var getFileListSync = function (dirName, og) { | ||
if (og === void 0) { og = dirName; } | ||
var files = []; | ||
var items = (0, fs_1.readdirSync)(dirName, { withFileTypes: true }); | ||
var items = readdirSync(dirName, { withFileTypes: true }); | ||
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { | ||
var item = items_1[_i]; | ||
var fullPath = path_1.default.join(dirName, item.name); | ||
var fullPath = path.join(dirName, item.name); | ||
if (item.isDirectory()) { | ||
files.push.apply(files, (0, exports.getFileListSync)(fullPath, og)); | ||
files.push.apply(files, getFileListSync(fullPath, og)); | ||
} | ||
else { | ||
files.push(path_1.default.relative(og, fullPath)); | ||
files.push(path.relative(og, fullPath)); | ||
} | ||
@@ -89,20 +83,19 @@ } | ||
}; | ||
exports.getFileListSync = getFileListSync; | ||
// TODO consolidate this function | ||
var getFileListWithDirectories = function (dirName, og) { | ||
export var getFileListWithDirectories = function (dirName, og) { | ||
if (og === void 0) { og = dirName; } | ||
var files = []; | ||
var items = (0, fs_1.readdirSync)(dirName, { withFileTypes: true }); | ||
var items = readdirSync(dirName, { withFileTypes: true }); | ||
for (var _i = 0, items_2 = items; _i < items_2.length; _i++) { | ||
var item = items_2[_i]; | ||
var fullPath = path_1.default.join(dirName, item.name); | ||
var fullPath = path.join(dirName, item.name); | ||
if (item.isDirectory()) { | ||
var relativeDir = path_1.default.relative(og, fullPath); | ||
var relativeDir = path.relative(og, fullPath); | ||
if (relativeDir !== '.git') { | ||
files.push(relativeDir); | ||
files.push.apply(files, (0, exports.getFileListWithDirectories)(fullPath, og)); | ||
files.push.apply(files, getFileListWithDirectories(fullPath, og)); | ||
} | ||
} | ||
else { | ||
files.push(path_1.default.relative(og, fullPath)); | ||
files.push(path.relative(og, fullPath)); | ||
} | ||
@@ -112,11 +105,10 @@ } | ||
}; | ||
exports.getFileListWithDirectories = getFileListWithDirectories; | ||
function getFileList(dirName, og, ignored) { | ||
export function getFileList(dirName, og, ignored) { | ||
if (og === void 0) { og = dirName; } | ||
if (ignored === void 0) { ignored = new Set(); } | ||
return __asyncGenerator(this, arguments, function getFileList_1() { | ||
var items, _i, items_3, item, path_2; | ||
var items, _i, items_3, item, path_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, __await((0, promises_1.readdir)(dirName, { withFileTypes: true }))]; | ||
case 0: return [4 /*yield*/, __await(readdir(dirName, { withFileTypes: true }))]; | ||
case 1: | ||
@@ -140,4 +132,4 @@ items = _a.sent(); | ||
case 5: | ||
path_2 = "".concat(dirName, "/").concat(item.name); | ||
return [4 /*yield*/, __await(path_2.startsWith(og) ? path_2.substring(og.length) : path_2)]; | ||
path_1 = "".concat(dirName, "/").concat(item.name); | ||
return [4 /*yield*/, __await(path_1.startsWith(og) ? path_1.substring(og.length) : path_1)]; | ||
case 6: return [4 /*yield*/, _a.sent()]; | ||
@@ -155,2 +147,1 @@ case 7: | ||
} | ||
exports.getFileList = getFileList; |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optionallyAddLeadingSlash = exports.slugToTitle = exports.generateDecoratedMintNavigationFromPages = void 0; | ||
var generateDecoratedMintNavigationFromPages = function (filenamePageMetadataMap, mintConfigNav) { | ||
export var generateDecoratedMintNavigationFromPages = function (filenamePageMetadataMap, mintConfigNav) { | ||
var filenames = Object.keys(filenamePageMetadataMap); | ||
@@ -18,3 +15,3 @@ var createNav = function (nav) { | ||
return { | ||
title: (0, exports.slugToTitle)(page), | ||
title: slugToTitle(page), | ||
href: optionallyAddLeadingSlash(page), | ||
@@ -30,4 +27,3 @@ }; | ||
}; | ||
exports.generateDecoratedMintNavigationFromPages = generateDecoratedMintNavigationFromPages; | ||
var slugToTitle = function (slug) { | ||
export var slugToTitle = function (slug) { | ||
var slugArr = slug.split('/'); | ||
@@ -39,4 +35,3 @@ var defaultTitle = slugArr[slugArr.length - 1].split('-').join(' '); //replace all dashes | ||
}; | ||
exports.slugToTitle = slugToTitle; | ||
function optionallyAddLeadingSlash(path) { | ||
export function optionallyAddLeadingSlash(path) { | ||
if (path.startsWith('/')) { | ||
@@ -47,2 +42,1 @@ return path; | ||
} | ||
exports.optionallyAddLeadingSlash = optionallyAddLeadingSlash; |
@@ -1,3 +0,4 @@ | ||
export * from './fs'; | ||
export * from './generate'; | ||
export * from './utils'; | ||
export * from './fs/index.js'; | ||
export * from './generate.js'; | ||
export * from './utils.js'; | ||
export * from './prebuild/index.js'; |
@@ -1,19 +0,4 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./fs"), exports); | ||
__exportStar(require("./generate"), exports); | ||
__exportStar(require("./utils"), exports); | ||
export * from './fs/index.js'; | ||
export * from './generate.js'; | ||
export * from './utils.js'; | ||
export * from './prebuild/index.js'; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -49,17 +48,11 @@ __assign = Object.assign || function(t) { | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getConfigObj = exports.getConfigPath = exports.loadOpenApi = exports.filterOutNullInGroup = exports.openApiCheck = exports.getFileExtension = void 0; | ||
var swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser")); | ||
var fs_extra_1 = require("fs-extra"); | ||
var js_yaml_1 = __importDefault(require("js-yaml")); | ||
var path_1 = __importDefault(require("path")); | ||
var getFileExtension = function (filename) { | ||
var parsed = path_1.default.parse(filename); | ||
import SwaggerParser from '@apidevtools/swagger-parser'; | ||
import fse from 'fs-extra'; | ||
import yaml from 'js-yaml'; | ||
import pathUtil from 'path'; | ||
export var getFileExtension = function (filename) { | ||
var parsed = pathUtil.parse(filename); | ||
return parsed.ext ? parsed.ext.slice(1) : filename; | ||
}; | ||
exports.getFileExtension = getFileExtension; | ||
var openApiCheck = function (path) { return __awaiter(void 0, void 0, void 0, function () { | ||
export var openApiCheck = function (path) { return __awaiter(void 0, void 0, void 0, function () { | ||
var spec, isOpenApi, _a; | ||
@@ -73,3 +66,3 @@ return __generator(this, function (_b) { | ||
_b.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, swagger_parser_1.default.validate(path)]; | ||
return [4 /*yield*/, SwaggerParser.validate(path)]; | ||
case 2: | ||
@@ -86,8 +79,6 @@ spec = _b.sent(); | ||
}); }; | ||
exports.openApiCheck = openApiCheck; | ||
var filterOutNullInGroup = function (group) { | ||
export var filterOutNullInGroup = function (group) { | ||
var newPages = filterOutNullInPages(group.pages); | ||
return __assign(__assign({}, group), { pages: newPages }); | ||
}; | ||
exports.filterOutNullInGroup = filterOutNullInGroup; | ||
var filterOutNullInPages = function (pages) { | ||
@@ -104,3 +95,3 @@ if (!Array.isArray(pages)) { | ||
if (page.hasOwnProperty('pages')) { | ||
newPages.push((0, exports.filterOutNullInGroup)(page)); | ||
newPages.push(filterOutNullInGroup(page)); | ||
continue; | ||
@@ -112,11 +103,10 @@ } | ||
}; | ||
var loadOpenApi = function (openApiSrc, openApiString) { | ||
export var loadOpenApi = function (openApiSrc, openApiString) { | ||
// Load yaml | ||
if (openApiSrc.endsWith('.yaml') || openApiSrc.endsWith('.yml')) { | ||
return js_yaml_1.default.load(openApiString); | ||
return yaml.load(openApiString); | ||
} | ||
return JSON.parse(openApiString); | ||
}; | ||
exports.loadOpenApi = loadOpenApi; | ||
var getConfigPath = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () { | ||
export var getConfigPath = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () { | ||
var path; | ||
@@ -126,4 +116,4 @@ return __generator(this, function (_a) { | ||
case 0: | ||
path = path_1.default.join(contentDirectoryPath, 'mint.json'); | ||
return [4 /*yield*/, (0, fs_extra_1.pathExists)(path)]; | ||
path = pathUtil.join(contentDirectoryPath, 'mint.json'); | ||
return [4 /*yield*/, fse.pathExists(path)]; | ||
case 1: | ||
@@ -136,8 +126,7 @@ if (!(_a.sent())) | ||
}); }; | ||
exports.getConfigPath = getConfigPath; | ||
var getConfigObj = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () { | ||
export var getConfigObj = function (contentDirectoryPath) { return __awaiter(void 0, void 0, void 0, function () { | ||
var configPath, configContents; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, exports.getConfigPath)(contentDirectoryPath)]; | ||
case 0: return [4 /*yield*/, getConfigPath(contentDirectoryPath)]; | ||
case 1: | ||
@@ -147,3 +136,3 @@ configPath = _a.sent(); | ||
return [2 /*return*/, null]; | ||
return [4 /*yield*/, (0, fs_extra_1.readFile)(configPath)]; | ||
return [4 /*yield*/, fse.readFile(configPath)]; | ||
case 2: | ||
@@ -156,2 +145,1 @@ configContents = _a.sent(); | ||
}); }; | ||
exports.getConfigObj = getConfigObj; |
{ | ||
"name": "@mintlify/prebuild", | ||
"version": "1.0.26", | ||
"type": "module", | ||
"version": "1.0.27", | ||
"description": "Helpful functions for Mintlify's prebuild step", | ||
@@ -31,4 +32,4 @@ "author": "Mintlify, Inc.", | ||
"prepare": "npm run build", | ||
"build": "tsc", | ||
"watch": "tsc --watch", | ||
"build": "tsc --project tsconfig.build.json", | ||
"watch": "tsc --project tsconfig.build.json --watch", | ||
"lint": "eslint . --cache", | ||
@@ -42,8 +43,14 @@ "test": "jest", | ||
"@mintlify/models": ">= 0.0.15 < 1", | ||
"@mintlify/validation": ">= 0.1.57 < 1", | ||
"fs-extra": "11.x", | ||
"openapi-types": "12.x" | ||
"gray-matter": "^4.0.3", | ||
"openapi-types": "12.x", | ||
"unist-util-visit": "^4.1.1" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
"resolver": "ts-jest-resolver", | ||
"setupFilesAfterEnv": [ | ||
"<rootDir>/setup-jest.ts" | ||
] | ||
}, | ||
@@ -53,3 +60,3 @@ "devDependencies": { | ||
"@mintlify/eslint-config-typescript": "1.0.7", | ||
"@mintlify/models": "0.0.24", | ||
"@mintlify/models": "0.0.25", | ||
"@mintlify/prettier-config": "1.0.1", | ||
@@ -71,3 +78,3 @@ "@mintlify/ts-config": "1.0.7", | ||
}, | ||
"gitHead": "a8b993690e58fcbfa7bfac58ad4f0f041d2d1b9c" | ||
"gitHead": "d354a7173a23eb86d3416785ce3e40cabaacb7ac" | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances 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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
182460
23
1455
Yes
7
7
1