@docs.page/cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
302
dist/cli.js
#!/usr/bin/env node | ||
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name); | ||
var __typeError = (msg) => { | ||
throw TypeError(msg); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __async = (__this, __arguments, generator) => { | ||
return new Promise((resolve, reject) => { | ||
var fulfilled = (value) => { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}; | ||
var rejected = (value) => { | ||
try { | ||
step(generator.throw(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}; | ||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); | ||
step((generator = generator.apply(__this, __arguments)).next()); | ||
}); | ||
}; | ||
var __await = function(promise, isYieldStar) { | ||
this[0] = promise; | ||
this[1] = isYieldStar; | ||
}; | ||
var __asyncGenerator = (__this, __arguments, generator) => { | ||
var resume = (k, v, yes, no) => { | ||
try { | ||
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done; | ||
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no)); | ||
} catch (e) { | ||
no(e); | ||
} | ||
}, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {}; | ||
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it; | ||
}; | ||
var __yieldStar = (value) => { | ||
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {}; | ||
if (obj == null) { | ||
obj = value[__knownSymbol("iterator")](); | ||
method = (k) => it[k] = (x) => obj[k](x); | ||
} else { | ||
obj = obj.call(value); | ||
method = (k) => it[k] = (v) => { | ||
if (isAwait) { | ||
isAwait = false; | ||
if (k === "throw") throw v; | ||
return v; | ||
} | ||
isAwait = true; | ||
return { | ||
done: false, | ||
value: new __await(new Promise((resolve) => { | ||
var x = obj[k](v); | ||
if (!(x instanceof Object)) __typeError("Object expected"); | ||
resolve(x); | ||
}), 1) | ||
}; | ||
}; | ||
} | ||
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => { | ||
throw x; | ||
}, "return" in obj && method("return"), it; | ||
}; | ||
var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it); | ||
import { | ||
__async, | ||
__forAwait, | ||
check | ||
} from "./chunk-KHUOP5OK.js"; | ||
// src/cli.ts | ||
var import_commander = require("commander"); | ||
import { program } from "commander"; | ||
// src/commands/check.ts | ||
var import_node_fs = __toESM(require("fs")); | ||
var import_node_path = __toESM(require("path")); | ||
var import_chalk = __toESM(require("chalk")); | ||
// src/check/configuration.ts | ||
function* checkConfiguration(routes, configuration) { | ||
} | ||
// src/check/relative-links.ts | ||
var CODE_BLOCK = /```[\s\S]*?```/g; | ||
var IDENTIFIERS = { | ||
// Matches all markdown links (e.g. [text](href)) | ||
MD_LINK: /\[.*?\]\((.*?)\)/g, | ||
// Matches all markdown images (e.g. ![alt](src)) | ||
MDX_IMAGE: /!\[.*?\]\((.*?)\)/g, | ||
// Matches all anchor html tags (e.g. <a href="href">) | ||
ANCHOR_HREF: /<a\s+(?:[^>]*?\s+)?href="(.*?)"/g, | ||
// Matches all image html tags (e.g. <img src="src">) | ||
IMAGE_SRC: /<img\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all MDX Image components (e.g. <Image src="src">) | ||
MDX_IMAGE_SRC: /<Image\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all video html tags (e.g. <video src="src">) | ||
VIDEO_SRC: /<video\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all MDX Video components (e.g. <Video src="src">) | ||
MDX_VIDEO_SRC: /<Video\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all card html tags (e.g. <Card href="href">) | ||
MDX_CARD_HREF: /<Card\s+(?:[^>]*?\s+)?href="(.*?)"/g | ||
}; | ||
function* checkRelativeLinks(routes) { | ||
for (const [, route] of routes) { | ||
const { content } = route; | ||
let cursor = 0; | ||
const matches = [...content.matchAll(CODE_BLOCK)]; | ||
for (const match of matches) { | ||
const start = match.index; | ||
const end = match.index + match[0].length; | ||
yield* __yieldStar(processMarkdownBlock( | ||
content.substring(cursor, start), | ||
route, | ||
routes | ||
)); | ||
cursor = end; | ||
} | ||
yield* __yieldStar(processMarkdownBlock(content.substring(cursor), route, routes)); | ||
} | ||
} | ||
function* processMarkdownBlock(content, route, routes) { | ||
const lines = content.split("\n"); | ||
for (let i = 0; i < lines.length; i++) { | ||
const lineNumber = i + 1; | ||
const line = lines[i]; | ||
for (const [, regex] of Object.entries(IDENTIFIERS)) { | ||
regex.lastIndex = 0; | ||
let match = null; | ||
while ((match = regex.exec(line)) !== null) { | ||
const link = match[1]; | ||
const column = match.index + 1; | ||
if (link.startsWith("/")) { | ||
const [linkPath] = link.split("#"); | ||
if (!routes.has(linkPath)) { | ||
yield { | ||
type: "error", | ||
message: `Documentation contains a broken link ('${linkPath}').`, | ||
filePath: route.filePath, | ||
line: lineNumber, | ||
column | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// src/check/index.ts | ||
function check(files, getFile) { | ||
return __asyncGenerator(this, null, function* () { | ||
if (!files.has("docs.json") && !files.has("docs.yaml")) { | ||
yield { | ||
type: "error", | ||
message: "Directory is missing a configuration file. Expected a `docs.json` file in the root of the directory." | ||
}; | ||
} | ||
const routes = /* @__PURE__ */ new Map(); | ||
for (const filePath of files) { | ||
if (!filePath.startsWith("docs/")) { | ||
continue; | ||
} | ||
let normalizedFilePath = filePath.replace(/^docs\//, ""); | ||
normalizedFilePath = normalizedFilePath.replace(/\.(mdx)$/i, ""); | ||
normalizedFilePath = normalizedFilePath.replace(/\/index$/i, ""); | ||
if (normalizedFilePath === "index") { | ||
normalizedFilePath = ""; | ||
} | ||
normalizedFilePath = normalizedFilePath ? `/${normalizedFilePath}` : "/"; | ||
if (routes.has(normalizedFilePath)) { | ||
yield { | ||
type: "error", | ||
message: `There are multiple files which resolve to the same route "${normalizedFilePath}".`, | ||
filePath, | ||
line: 0, | ||
column: 0 | ||
}; | ||
} | ||
routes.set(normalizedFilePath, { | ||
filePath, | ||
// Don't bother reading none .mdx files, since we don't care about their content. | ||
content: filePath.endsWith(".mdx") ? yield new __await(getFile(filePath)) : "" | ||
}); | ||
} | ||
try { | ||
const configFile = yield new __await(getFile( | ||
files.has("docs.json") ? "docs.json" : "docs.yaml" | ||
)); | ||
yield* __yieldStar(checkConfiguration(routes, JSON.parse(configFile))); | ||
} catch (e) { | ||
yield { | ||
type: "error", | ||
message: "Failed to parse the configuration file.", | ||
filePath: files.has("docs.json") ? "docs.json" : "docs.yaml", | ||
line: 0, | ||
column: 0 | ||
}; | ||
} | ||
yield* __yieldStar(checkRelativeLinks(routes)); | ||
}); | ||
} | ||
// src/commands/check.ts | ||
import fs from "fs"; | ||
import path from "path"; | ||
import chalk from "chalk"; | ||
function registerCheckCommand(program2) { | ||
@@ -233,7 +21,7 @@ program2.command("check").description("Check the validity of the docs").argument( | ||
const relativePath = String(input || "."); | ||
const absolutePath = import_node_path.default.resolve(relativePath); | ||
const absolutePath = path.resolve(relativePath); | ||
let error = false; | ||
function getFile(filePath) { | ||
return __async(this, null, function* () { | ||
return import_node_fs.default.readFileSync(import_node_path.default.join(absolutePath, filePath), "utf-8") || ""; | ||
return fs.readFileSync(path.join(absolutePath, filePath), "utf-8") || ""; | ||
}); | ||
@@ -251,9 +39,9 @@ } | ||
const message = [ | ||
`${import_chalk.default.blueBright(result.filePath)}`, | ||
`${chalk.blueBright(result.filePath)}`, | ||
":", | ||
`${import_chalk.default.yellow(result.line)}`, | ||
`${chalk.yellow(result.line)}`, | ||
":", | ||
`${import_chalk.default.yellow(result.column)}`, | ||
`${chalk.yellow(result.column)}`, | ||
" - ", | ||
result.type === "error" ? import_chalk.default.red("error") : import_chalk.default.yellow("warn"), | ||
result.type === "error" ? chalk.red("error") : chalk.yellow("warn"), | ||
": ", | ||
@@ -278,3 +66,3 @@ result.message | ||
function getFilesFromDisk(absolutePath) { | ||
const exists = import_node_fs.default.existsSync(absolutePath); | ||
const exists = fs.existsSync(absolutePath); | ||
if (!exists) { | ||
@@ -284,3 +72,3 @@ throw new Error(`The path "${absolutePath}" does not exist.`); | ||
const files = /* @__PURE__ */ new Set(); | ||
const nodes = import_node_fs.default.readdirSync(absolutePath, { | ||
const nodes = fs.readdirSync(absolutePath, { | ||
withFileTypes: true, | ||
@@ -298,13 +86,13 @@ recursive: true | ||
// src/commands/init.ts | ||
var import_node_fs2 = __toESM(require("fs")); | ||
var import_node_path2 = __toESM(require("path")); | ||
var import_chalk2 = __toESM(require("chalk")); | ||
import fs2 from "fs"; | ||
import path2 from "path"; | ||
import chalk2 from "chalk"; | ||
function registerInitCommand(program2) { | ||
program2.command("init").description("Initializes new docs.page files").argument("[path]", "Path to the relative directory to initilize in.").action((input, o) => __async(this, null, function* () { | ||
const relativePath = String(input || "."); | ||
const absolutePath = import_node_path2.default.resolve(relativePath); | ||
if (!import_node_fs2.default.existsSync(absolutePath)) { | ||
const absolutePath = path2.resolve(relativePath); | ||
if (!fs2.existsSync(absolutePath)) { | ||
console.log( | ||
import_chalk2.default.red( | ||
`Directory "${import_chalk2.default.yellow(absolutePath)}" does not exist.` | ||
chalk2.red( | ||
`Directory "${chalk2.yellow(absolutePath)}" does not exist.` | ||
) | ||
@@ -314,8 +102,8 @@ ); | ||
} | ||
console.log(import_chalk2.default.green("Initializing docs.page files...")); | ||
const configurationFilePath = import_node_path2.default.join(absolutePath, "docs.json"); | ||
const documentationPath = import_node_path2.default.join(absolutePath, "docs"); | ||
if (import_node_fs2.default.existsSync(configurationFilePath)) { | ||
console.log(chalk2.green("Initializing docs.page files...")); | ||
const configurationFilePath = path2.join(absolutePath, "docs.json"); | ||
const documentationPath = path2.join(absolutePath, "docs"); | ||
if (fs2.existsSync(configurationFilePath)) { | ||
console.log( | ||
import_chalk2.default.red("Configuration file 'docs.json' already exists.") | ||
chalk2.red("Configuration file 'docs.json' already exists.") | ||
); | ||
@@ -325,10 +113,10 @@ process.exit(1); | ||
const createdFiles = [ | ||
` - ${import_chalk2.default.green( | ||
` - ${chalk2.green( | ||
"docs.json" | ||
)}: Configuration file for your documentation site` | ||
]; | ||
const docsDirectoryExists = import_node_fs2.default.existsSync(documentationPath); | ||
const docsDirectoryExists = fs2.existsSync(documentationPath); | ||
if (docsDirectoryExists) { | ||
console.log( | ||
import_chalk2.default.yellow( | ||
chalk2.yellow( | ||
"A 'docs/' directory already exists, this command will not overwrite existing files." | ||
@@ -338,5 +126,5 @@ ) | ||
} else { | ||
import_node_fs2.default.mkdirSync(documentationPath, { recursive: true }); | ||
fs2.mkdirSync(documentationPath, { recursive: true }); | ||
} | ||
import_node_fs2.default.writeFileSync( | ||
fs2.writeFileSync( | ||
configurationFilePath, | ||
@@ -348,14 +136,14 @@ jsonConfiguration({ | ||
if (!docsDirectoryExists) { | ||
import_node_fs2.default.writeFileSync(import_node_path2.default.join(documentationPath, "index.mdx"), indexPage); | ||
fs2.writeFileSync(path2.join(documentationPath, "index.mdx"), indexPage); | ||
createdFiles.push( | ||
` - ${import_chalk2.default.green( | ||
` - ${chalk2.green( | ||
"docs/index.mdx" | ||
)}: The home page of your documentation site` | ||
); | ||
import_node_fs2.default.writeFileSync( | ||
import_node_path2.default.join(documentationPath, "next-steps.mdx"), | ||
fs2.writeFileSync( | ||
path2.join(documentationPath, "next-steps.mdx"), | ||
nextStepsPage | ||
); | ||
createdFiles.push( | ||
` - ${import_chalk2.default.green( | ||
` - ${chalk2.green( | ||
"docs/next-steps.mdx" | ||
@@ -365,7 +153,7 @@ )}: A page to help you get started with docs.page` | ||
} | ||
console.log(import_chalk2.default.green("Files created:")); | ||
console.log(chalk2.green("Files created:")); | ||
console.log(createdFiles.join("\n")); | ||
console.log("\n"); | ||
console.log( | ||
import_chalk2.default.green( | ||
chalk2.green( | ||
"Initialization complete. To preview your documentation site, vist https://docs.page/preview in your browser." | ||
@@ -453,5 +241,5 @@ ) | ||
// src/cli.ts | ||
import_commander.program.name("docs.page").version("0.1.0").description("docs.page CLI"); | ||
registerInitCommand(import_commander.program); | ||
registerCheckCommand(import_commander.program); | ||
import_commander.program.parse(process.argv); | ||
program.name("docs.page").version("0.1.0").description("docs.page CLI"); | ||
registerInitCommand(program); | ||
registerCheckCommand(program); | ||
program.parse(process.argv); |
@@ -1,200 +0,6 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name); | ||
var __typeError = (msg) => { | ||
throw TypeError(msg); | ||
import { | ||
check | ||
} from "./chunk-KHUOP5OK.js"; | ||
export { | ||
check | ||
}; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var __await = function(promise, isYieldStar) { | ||
this[0] = promise; | ||
this[1] = isYieldStar; | ||
}; | ||
var __asyncGenerator = (__this, __arguments, generator) => { | ||
var resume = (k, v, yes, no) => { | ||
try { | ||
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done; | ||
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no)); | ||
} catch (e) { | ||
no(e); | ||
} | ||
}, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {}; | ||
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it; | ||
}; | ||
var __yieldStar = (value) => { | ||
var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {}; | ||
if (obj == null) { | ||
obj = value[__knownSymbol("iterator")](); | ||
method = (k) => it[k] = (x) => obj[k](x); | ||
} else { | ||
obj = obj.call(value); | ||
method = (k) => it[k] = (v) => { | ||
if (isAwait) { | ||
isAwait = false; | ||
if (k === "throw") throw v; | ||
return v; | ||
} | ||
isAwait = true; | ||
return { | ||
done: false, | ||
value: new __await(new Promise((resolve) => { | ||
var x = obj[k](v); | ||
if (!(x instanceof Object)) __typeError("Object expected"); | ||
resolve(x); | ||
}), 1) | ||
}; | ||
}; | ||
} | ||
return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => { | ||
throw x; | ||
}, "return" in obj && method("return"), it; | ||
}; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
check: () => check | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// src/check/configuration.ts | ||
function* checkConfiguration(routes, configuration) { | ||
} | ||
// src/check/relative-links.ts | ||
var CODE_BLOCK = /```[\s\S]*?```/g; | ||
var IDENTIFIERS = { | ||
// Matches all markdown links (e.g. [text](href)) | ||
MD_LINK: /\[.*?\]\((.*?)\)/g, | ||
// Matches all markdown images (e.g. ![alt](src)) | ||
MDX_IMAGE: /!\[.*?\]\((.*?)\)/g, | ||
// Matches all anchor html tags (e.g. <a href="href">) | ||
ANCHOR_HREF: /<a\s+(?:[^>]*?\s+)?href="(.*?)"/g, | ||
// Matches all image html tags (e.g. <img src="src">) | ||
IMAGE_SRC: /<img\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all MDX Image components (e.g. <Image src="src">) | ||
MDX_IMAGE_SRC: /<Image\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all video html tags (e.g. <video src="src">) | ||
VIDEO_SRC: /<video\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all MDX Video components (e.g. <Video src="src">) | ||
MDX_VIDEO_SRC: /<Video\s+(?:[^>]*?\s+)?src="(.*?)"/g, | ||
// Matches all card html tags (e.g. <Card href="href">) | ||
MDX_CARD_HREF: /<Card\s+(?:[^>]*?\s+)?href="(.*?)"/g | ||
}; | ||
function* checkRelativeLinks(routes) { | ||
for (const [, route] of routes) { | ||
const { content } = route; | ||
let cursor = 0; | ||
const matches = [...content.matchAll(CODE_BLOCK)]; | ||
for (const match of matches) { | ||
const start = match.index; | ||
const end = match.index + match[0].length; | ||
yield* __yieldStar(processMarkdownBlock( | ||
content.substring(cursor, start), | ||
route, | ||
routes | ||
)); | ||
cursor = end; | ||
} | ||
yield* __yieldStar(processMarkdownBlock(content.substring(cursor), route, routes)); | ||
} | ||
} | ||
function* processMarkdownBlock(content, route, routes) { | ||
const lines = content.split("\n"); | ||
for (let i = 0; i < lines.length; i++) { | ||
const lineNumber = i + 1; | ||
const line = lines[i]; | ||
for (const [, regex] of Object.entries(IDENTIFIERS)) { | ||
regex.lastIndex = 0; | ||
let match = null; | ||
while ((match = regex.exec(line)) !== null) { | ||
const link = match[1]; | ||
const column = match.index + 1; | ||
if (link.startsWith("/")) { | ||
const [linkPath] = link.split("#"); | ||
if (!routes.has(linkPath)) { | ||
yield { | ||
type: "error", | ||
message: `Documentation contains a broken link ('${linkPath}').`, | ||
filePath: route.filePath, | ||
line: lineNumber, | ||
column | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// src/check/index.ts | ||
function check(files, getFile) { | ||
return __asyncGenerator(this, null, function* () { | ||
if (!files.has("docs.json") && !files.has("docs.yaml")) { | ||
yield { | ||
type: "error", | ||
message: "Directory is missing a configuration file. Expected a `docs.json` file in the root of the directory." | ||
}; | ||
} | ||
const routes = /* @__PURE__ */ new Map(); | ||
for (const filePath of files) { | ||
if (!filePath.startsWith("docs/")) { | ||
continue; | ||
} | ||
let normalizedFilePath = filePath.replace(/^docs\//, ""); | ||
normalizedFilePath = normalizedFilePath.replace(/\.(mdx)$/i, ""); | ||
normalizedFilePath = normalizedFilePath.replace(/\/index$/i, ""); | ||
if (normalizedFilePath === "index") { | ||
normalizedFilePath = ""; | ||
} | ||
normalizedFilePath = normalizedFilePath ? `/${normalizedFilePath}` : "/"; | ||
if (routes.has(normalizedFilePath)) { | ||
yield { | ||
type: "error", | ||
message: `There are multiple files which resolve to the same route "${normalizedFilePath}".`, | ||
filePath, | ||
line: 0, | ||
column: 0 | ||
}; | ||
} | ||
routes.set(normalizedFilePath, { | ||
filePath, | ||
// Don't bother reading none .mdx files, since we don't care about their content. | ||
content: filePath.endsWith(".mdx") ? yield new __await(getFile(filePath)) : "" | ||
}); | ||
} | ||
try { | ||
const configFile = yield new __await(getFile( | ||
files.has("docs.json") ? "docs.json" : "docs.yaml" | ||
)); | ||
yield* __yieldStar(checkConfiguration(routes, JSON.parse(configFile))); | ||
} catch (e) { | ||
yield { | ||
type: "error", | ||
message: "Failed to parse the configuration file.", | ||
filePath: files.has("docs.json") ? "docs.json" : "docs.yaml", | ||
line: 0, | ||
column: 0 | ||
}; | ||
} | ||
yield* __yieldStar(checkRelativeLinks(routes)); | ||
}); | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
check | ||
}); |
{ | ||
"name": "@docs.page/cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Invertase <oss@invertase.io> (http://invertase.io)", | ||
"license": "Apache-2.0", | ||
"type": "module", | ||
"bin": { | ||
@@ -16,4 +17,3 @@ "@docs.page/cli": "dist/cli.js" | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
@@ -23,4 +23,4 @@ } | ||
"scripts": { | ||
"build": "rimraf dist && npx tsup src/index.ts src/cli.ts --format esm,cjs --dts", | ||
"watch": "npx tsup src/index.ts src/cli.ts --format esm,cjs --dts --watch", | ||
"build": "rimraf dist && npx tsup src/index.ts src/cli.ts --format esm --dts", | ||
"watch": "npx tsup src/index.ts src/cli.ts --format esm --dts --watch", | ||
"postinstall": "npm run build" | ||
@@ -27,0 +27,0 @@ }, |
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
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
3
Yes
28191
8
429
1