lildocs 0.1.18 → 0.1.19
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/dist/cli.mjs +56 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createRequire } from "node:module";
|
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { command, flag, option, optional, positional, run, string, subcommands } from "cmd-ts";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
-
import { access, copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
7
|
+
import { access, appendFile, copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import matter from "gray-matter";
|
|
10
10
|
import { Lexer, Marked, Parser, Renderer, marked } from "marked";
|
|
@@ -516,7 +516,10 @@ async function frontendViteConfig(cwd, mode) {
|
|
|
516
516
|
clearScreen: false,
|
|
517
517
|
logLevel: "warn",
|
|
518
518
|
plugins: [octaneRuntimeCompatibility(), octane()],
|
|
519
|
-
optimizeDeps: {
|
|
519
|
+
optimizeDeps: {
|
|
520
|
+
exclude: ["octane"],
|
|
521
|
+
...mode === "dev" ? { noDiscovery: true } : {}
|
|
522
|
+
},
|
|
520
523
|
ssr: { noExternal: [/^octane(?:$|\/)/] }
|
|
521
524
|
};
|
|
522
525
|
}
|
|
@@ -1854,6 +1857,7 @@ async function startDevServer(options) {
|
|
|
1854
1857
|
const input = await resolveInput(options.input, options.cwd, { homePagePreference: "readme-first" });
|
|
1855
1858
|
const outDir = path.resolve(options.cwd, options.outDir);
|
|
1856
1859
|
validateDevOutDir(options.cwd, input.docsRoot, outDir, options.outDir);
|
|
1860
|
+
await addGitExclude(options.cwd, outDir);
|
|
1857
1861
|
await mkdir(outDir, { recursive: true });
|
|
1858
1862
|
const vite = await createFrontendDevServer({
|
|
1859
1863
|
cwd: options.cwd,
|
|
@@ -1948,6 +1952,56 @@ function isInside(parent, child) {
|
|
|
1948
1952
|
const relative = path.relative(parent, child);
|
|
1949
1953
|
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
1950
1954
|
}
|
|
1955
|
+
async function addGitExclude(cwd, outDir) {
|
|
1956
|
+
try {
|
|
1957
|
+
const repository = await findGitRepository(cwd);
|
|
1958
|
+
if (!repository || !isInside(repository.root, outDir)) return;
|
|
1959
|
+
const relativeOutDir = path.relative(repository.root, outDir);
|
|
1960
|
+
if (!relativeOutDir) return;
|
|
1961
|
+
const pattern = `${relativeOutDir.split(path.sep).join("/")}/`;
|
|
1962
|
+
let contents = "";
|
|
1963
|
+
try {
|
|
1964
|
+
contents = await readFile(repository.excludePath, "utf8");
|
|
1965
|
+
} catch (error) {
|
|
1966
|
+
if (error.code !== "ENOENT") throw error;
|
|
1967
|
+
await mkdir(path.dirname(repository.excludePath), { recursive: true });
|
|
1968
|
+
}
|
|
1969
|
+
const entries = contents.split(/\r?\n/).map((entry) => entry.trim());
|
|
1970
|
+
const normalizedPattern = pattern.replace(/^\/|\/$/g, "");
|
|
1971
|
+
if (entries.some((entry) => entry.replace(/^\/|\/$/g, "") === normalizedPattern)) return;
|
|
1972
|
+
const separator = contents.length > 0 && !contents.endsWith("\n") ? "\n" : "";
|
|
1973
|
+
await appendFile(repository.excludePath, `${separator}${pattern}\n`);
|
|
1974
|
+
} catch {}
|
|
1975
|
+
}
|
|
1976
|
+
async function findGitRepository(start) {
|
|
1977
|
+
let current = path.resolve(start);
|
|
1978
|
+
while (true) {
|
|
1979
|
+
const dotGit = path.join(current, ".git");
|
|
1980
|
+
try {
|
|
1981
|
+
const metadata = await stat(dotGit);
|
|
1982
|
+
let gitDir = dotGit;
|
|
1983
|
+
if (!metadata.isDirectory()) {
|
|
1984
|
+
const pointer = await readFile(dotGit, "utf8");
|
|
1985
|
+
const match = /^gitdir:\s*(.+)\s*$/im.exec(pointer);
|
|
1986
|
+
if (!match?.[1]) return;
|
|
1987
|
+
gitDir = path.resolve(current, match[1]);
|
|
1988
|
+
}
|
|
1989
|
+
let commonDir = gitDir;
|
|
1990
|
+
try {
|
|
1991
|
+
const pointer = (await readFile(path.join(gitDir, "commondir"), "utf8")).trim();
|
|
1992
|
+
commonDir = path.resolve(gitDir, pointer);
|
|
1993
|
+
} catch {}
|
|
1994
|
+
return {
|
|
1995
|
+
root: current,
|
|
1996
|
+
excludePath: path.join(commonDir, "info", "exclude")
|
|
1997
|
+
};
|
|
1998
|
+
} catch {
|
|
1999
|
+
const parent = path.dirname(current);
|
|
2000
|
+
if (parent === current) return;
|
|
2001
|
+
current = parent;
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
1951
2005
|
//#endregion
|
|
1952
2006
|
//#region src/core/deploy.ts
|
|
1953
2007
|
async function deployGitHubPages(options) {
|
package/package.json
CHANGED