@mintlify/link-rot 3.0.1507 → 3.0.1509

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/link-rot",
3
- "version": "3.0.1507",
3
+ "version": "3.0.1509",
4
4
  "description": "Static checking for broken internal links",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -44,11 +44,11 @@
44
44
  "format:check": "oxfmt --check"
45
45
  },
46
46
  "dependencies": {
47
- "@mintlify/common": "1.0.1284",
47
+ "@mintlify/common": "1.0.1285",
48
48
  "@mintlify/models": "0.0.376",
49
- "@mintlify/prebuild": "1.0.1449",
50
- "@mintlify/previewing": "4.0.1527",
51
- "@mintlify/scraping": "4.0.1157",
49
+ "@mintlify/prebuild": "1.0.1450",
50
+ "@mintlify/previewing": "4.0.1528",
51
+ "@mintlify/scraping": "4.0.1158",
52
52
  "@mintlify/validation": "0.1.936",
53
53
  "fs-extra": "11.1.0",
54
54
  "remark-smartypants": "3.0.2",
@@ -71,5 +71,5 @@
71
71
  "typescript": "5.5.3",
72
72
  "vitest": "2.1.9"
73
73
  },
74
- "gitHead": "238d1a724766228376afe202b971b47265a9a035"
74
+ "gitHead": "acd82e9659d523979c67609834ec26e42bfb408d"
75
75
  }
@@ -1,7 +0,0 @@
1
- /**
2
- * Renames a link in the file system. If the link is a directory, all links within the directory will be renamed as well.
3
- * @param oldFilePath - The existing directory or file to rename
4
- * @param newFilePath - The new directory or file name
5
- * @param force
6
- */
7
- export declare const renameFilesAndUpdateLinksInContent: (oldFilePathString: string, newFilePathString: string, force?: boolean) => Promise<void>;
@@ -1,91 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __asyncValues = (this && this.__asyncValues) || function (o) {
11
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
12
- var m = o[Symbol.asyncIterator], i;
13
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
14
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
15
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
16
- };
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- import { addLog, SuccessLog, WarningLog, RenamedLog, ErrorLog } from '@mintlify/previewing';
19
- import { validatePathWithinCwd } from '@mintlify/validation';
20
- import { existsSync, renameSync } from 'fs';
21
- import path from 'path';
22
- import { removeFileExtension, getPagePaths, addLeadingSlash } from '../prebuild.js';
23
- import renameInternalLinksInPage from './renameInternalLinksInPage.js';
24
- /**
25
- * Renames a link in the file system. If the link is a directory, all links within the directory will be renamed as well.
26
- * @param oldFilePath - The existing directory or file to rename
27
- * @param newFilePath - The new directory or file name
28
- * @param force
29
- */
30
- export const renameFilesAndUpdateLinksInContent = (oldFilePathString_1, newFilePathString_1, ...args_1) => __awaiter(void 0, [oldFilePathString_1, newFilePathString_1, ...args_1], void 0, function* (oldFilePathString, newFilePathString, force = false) {
31
- var _a, e_1, _b, _c;
32
- const baseDir = process.cwd();
33
- const oldFilePath = path.parse(path.normalize(oldFilePathString));
34
- const newFilePath = path.parse(path.normalize(newFilePathString));
35
- try {
36
- // Validate paths are within current working directory to prevent path traversal
37
- validatePathWithinCwd(oldFilePathString, baseDir);
38
- validatePathWithinCwd(newFilePathString, baseDir);
39
- if (oldFilePath.dir === newFilePath.dir && oldFilePath.base === newFilePath.base) {
40
- throw new Error('the two file paths are the same.');
41
- }
42
- else if (oldFilePath.ext !== newFilePath.ext) {
43
- if (force) {
44
- addLog(_jsx(WarningLog, { message: "the file extensions are not the same." }));
45
- }
46
- else {
47
- throw new Error('the file extensions are not the same. use the --force flag to override.');
48
- }
49
- }
50
- // if the file or directory hasn't already been manually renamed, rename it
51
- if (existsSync(oldFilePathString)) {
52
- if (!force && existsSync(newFilePathString)) {
53
- throw new Error('the new file path already exists. use the --force flag to overwrite it.');
54
- }
55
- renameSync(oldFilePathString, newFilePathString);
56
- addLog(_jsx(RenamedLog, { before: oldFilePathString, after: newFilePathString }));
57
- }
58
- else if (!force) {
59
- throw new Error(`the file ${oldFilePathString} does not exist. use the --force flag to skip the file system renaming.`);
60
- }
61
- const oldLink = addLeadingSlash(removeFileExtension(oldFilePath));
62
- const newLink = addLeadingSlash(removeFileExtension(newFilePath));
63
- const pagesInDirectory = getPagePaths(process.cwd());
64
- const renameLinkPromises = [];
65
- try {
66
- for (var _d = true, pagesInDirectory_1 = __asyncValues(pagesInDirectory), pagesInDirectory_1_1; pagesInDirectory_1_1 = yield pagesInDirectory_1.next(), _a = pagesInDirectory_1_1.done, !_a; _d = true) {
67
- _c = pagesInDirectory_1_1.value;
68
- _d = false;
69
- const filePath = _c;
70
- renameLinkPromises.push((() => __awaiter(void 0, void 0, void 0, function* () {
71
- const numRenamedLinks = yield renameInternalLinksInPage(path.resolve(process.cwd(), filePath), oldLink, newLink);
72
- if (numRenamedLinks > 0) {
73
- addLog(_jsx(SuccessLog, { message: `updated ${numRenamedLinks} link${numRenamedLinks === 1 ? '' : 's'} in ${filePath}` }));
74
- }
75
- }))());
76
- }
77
- }
78
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
79
- finally {
80
- try {
81
- if (!_d && !_a && (_b = pagesInDirectory_1.return)) yield _b.call(pagesInDirectory_1);
82
- }
83
- finally { if (e_1) throw e_1.error; }
84
- }
85
- yield Promise.all(renameLinkPromises);
86
- return;
87
- }
88
- catch (err) {
89
- addLog(_jsx(ErrorLog, { message: err instanceof Error ? err.message : 'an unknown error occurred' }));
90
- }
91
- });