lildocs 0.1.0 → 0.1.2

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 CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { n as renderGitHubPagesWorkflow, r as repoRelativeInputPath, t as normalizeBasePath } from "./github-pages-0s3VHkYL.mjs";
2
+ import { n as renderGitHubPagesWorkflow, r as repoRelativeInputPath, t as normalizeBasePath } from "./github-pages-clWLKtga.mjs";
3
3
  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
- import { createReadStream, existsSync, watch } from "node:fs";
6
+ import { createReadStream, existsSync, readFileSync, watch } from "node:fs";
7
7
  import { access, copyFile, mkdir, mkdtemp, readFile, readdir, rm, stat, writeFile } from "node:fs/promises";
8
8
  import path from "node:path";
9
9
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -740,7 +740,7 @@ function escapeHtml(value) {
740
740
  //#endregion
741
741
  //#region src/core/nav.ts
742
742
  function buildNavigation(model, activePage) {
743
- return nestNavItems(model.pages.map((page) => pageToNavItem(page, activePage)));
743
+ return nestNavItems(model.pages.filter((page) => page.sourcePath !== model.homePage).map((page) => pageToNavItem(page, activePage)));
744
744
  }
745
745
  function pageToNavItem(page, activePage) {
746
746
  return {
@@ -2000,15 +2000,32 @@ async function initGitHubPagesWorkflow(options) {
2000
2000
  async function prepareWorkflow(options) {
2001
2001
  const workflowPath = path.join(options.cwd, ".github", "workflows", "lildocs-pages.yml");
2002
2002
  if (await pathExists(workflowPath)) throw new Error(`Refusing to overwrite existing workflow at ${workflowPath}.`);
2003
+ const workflowInput = repoRelativeInputPath(options.input, options.cwd);
2004
+ const workflowOutDir = path.relative(options.cwd, path.resolve(options.cwd, options.outDir));
2005
+ const hasPackageManager = nearestPackageJsonHasPackageManager(options.cwd);
2003
2006
  return {
2004
2007
  path: workflowPath,
2005
2008
  contents: renderGitHubPagesWorkflow({
2006
- input: repoRelativeInputPath(options.input, options.cwd),
2007
- outDir: path.relative(options.cwd, path.resolve(options.cwd, options.outDir)) || ".",
2008
- basePath: options.basePath
2009
+ input: workflowInput,
2010
+ outDir: workflowOutDir || ".",
2011
+ basePath: options.basePath,
2012
+ pnpmVersion: hasPackageManager ? false : void 0
2009
2013
  })
2010
2014
  };
2011
2015
  }
2016
+ function nearestPackageJsonHasPackageManager(cwd) {
2017
+ let current = path.resolve(cwd);
2018
+ while (true) {
2019
+ const packageJsonPath = path.join(current, "package.json");
2020
+ if (existsSync(packageJsonPath)) {
2021
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
2022
+ return typeof packageJson.packageManager === "string" && packageJson.packageManager.length > 0;
2023
+ }
2024
+ const parent = path.dirname(current);
2025
+ if (parent === current) return false;
2026
+ current = parent;
2027
+ }
2028
+ }
2012
2029
  async function pathExists(filePath) {
2013
2030
  try {
2014
2031
  await access(filePath);
@@ -1,2 +1,2 @@
1
- import { n as renderGitHubPagesWorkflow, r as repoRelativeInputPath, t as normalizeBasePath } from "../github-pages-0s3VHkYL.mjs";
1
+ import { n as renderGitHubPagesWorkflow, r as repoRelativeInputPath, t as normalizeBasePath } from "../github-pages-clWLKtga.mjs";
2
2
  export { normalizeBasePath, renderGitHubPagesWorkflow, repoRelativeInputPath };
@@ -1,5 +1,6 @@
1
1
  import path from "node:path";
2
2
  //#region src/core/github-pages.ts
3
+ const DEFAULT_PNPM_VERSION = "10.29.3";
3
4
  function normalizeBasePath(value) {
4
5
  const basePath = value ?? "/";
5
6
  if (/^[a-z][a-z\d+.-]*:\/\//i.test(basePath)) throw new Error("GitHub Pages base path must be a path, not a URL.");
@@ -14,6 +15,7 @@ function repoRelativeInputPath(input, cwd) {
14
15
  return relativeInput.startsWith(".") ? relativeInput : `./${relativeInput}`;
15
16
  }
16
17
  function renderGitHubPagesWorkflow(options) {
18
+ const pnpmVersion = options.pnpmVersion ?? DEFAULT_PNPM_VERSION;
17
19
  return `name: Deploy lildocs to GitHub Pages
18
20
 
19
21
  on:
@@ -34,11 +36,11 @@ jobs:
34
36
  build:
35
37
  runs-on: ubuntu-latest
36
38
  steps:
37
- - uses: actions/checkout@v4
38
- - uses: pnpm/action-setup@v4
39
- with:
40
- version: 10.29.3
41
- - uses: actions/setup-node@v4
39
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
40
+ - uses: pnpm/action-setup@7088e561eb65bb68695d245aa206f005ef30921d
41
+ ${pnpmVersion === false ? "" : ` with:
42
+ version: ${pnpmVersion}
43
+ `} - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
42
44
  with:
43
45
  node-version: 24
44
46
  cache: pnpm
@@ -51,8 +53,8 @@ jobs:
51
53
  options.outDir,
52
54
  ...options.basePath ? ["--base", normalizeBasePath(options.basePath)] : []
53
55
  ].map(shellQuote).join(" ")}
54
- - uses: actions/configure-pages@v5
55
- - uses: actions/upload-pages-artifact@v3
56
+ - uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
57
+ - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa
56
58
  with:
57
59
  path: ${options.outDir}
58
60
  deploy:
@@ -63,7 +65,7 @@ jobs:
63
65
  needs: build
64
66
  steps:
65
67
  - id: deployment
66
- uses: actions/deploy-pages@v4
68
+ uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
67
69
  `;
68
70
  }
69
71
  function shellQuote(value) {
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "lildocs",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A lightweight CLI that turns Markdown docs into a static searchable documentation site.",
5
+ "homepage": "https://aleclarson.github.io/lildocs/",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/aleclarson/lildocs"
@@ -28,7 +29,7 @@
28
29
  "beautiful-mermaid": "^1.1.3",
29
30
  "cmd-ts": "^0.15.0",
30
31
  "culori": "^4.0.2",
31
- "exports-md": "^0.1.3",
32
+ "exports-md": "^0.1.7",
32
33
  "gray-matter": "^4.0.3",
33
34
  "jiti": "^2.7.0",
34
35
  "marked": "^18.0.3",