docula 0.12.1 → 0.13.0

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.
Files changed (3) hide show
  1. package/README.md +5 -0
  2. package/dist/docula.js +40 -27
  3. package/package.json +21 -15
package/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - [Getting Started](#getting-started)
14
14
  - [Using Your own Template](#using-your-own-template)
15
15
  - [Building Multiple Pages](#building-multiple-pages)
16
+ - [Using a Github Token](#using-a-github-token)
16
17
  - [Helper Functions for Markdown](#helper-functions-for-markdown)
17
18
  - [Code of Conduct and Contributing](#code-of-conduct-and-contributing)
18
19
  - [License - MIT](#license)
@@ -86,6 +87,10 @@ title: Getting Started
86
87
  order: 2
87
88
  ```
88
89
 
90
+ # Using a Github Token
91
+
92
+ If you want to use the Github token to access the Github API you can do so by setting the `GITHUB_TOKEN` environment variable. This is useful if you want to access private repositories or if you want to access the Github API without hitting the rate limit. This is optional and you can still use docula without it but could hit rate limits and will not be able to access private repositories.
93
+
89
94
  # Helper Functions for Markdown
90
95
 
91
96
  docula comes with some helper functions that you can use in your markdown files.
package/dist/docula.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/docula.ts
2
2
  import http from "http";
3
3
  import path3 from "path";
4
- import process3 from "process";
4
+ import process4 from "process";
5
5
  import fs3 from "fs";
6
6
  import handler from "serve-handler";
7
7
  import updateNotifier from "update-notifier";
@@ -219,6 +219,7 @@ import he from "he";
219
219
  import * as cheerio from "cheerio";
220
220
 
221
221
  // src/github.ts
222
+ import process3 from "process";
222
223
  import axios from "axios";
223
224
  var Github = class {
224
225
  options = {
@@ -240,8 +241,19 @@ var Github = class {
240
241
  }
241
242
  async getReleases() {
242
243
  const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/releases`;
244
+ let config2 = {};
245
+ if (process3.env.GITHUB_TOKEN) {
246
+ config2 = {
247
+ headers: {
248
+ // eslint-disable-next-line @typescript-eslint/naming-convention
249
+ Authorization: `Bearer ${process3.env.GITHUB_TOKEN}`,
250
+ // eslint-disable-next-line @typescript-eslint/naming-convention
251
+ Accept: "application/vnd.github.v3+json"
252
+ }
253
+ };
254
+ }
243
255
  try {
244
- const result = await axios.get(url);
256
+ const result = await axios.get(url, config2);
245
257
  if (result && result.data.length > 0) {
246
258
  return this.addAnchorLink(result.data);
247
259
  }
@@ -256,8 +268,19 @@ var Github = class {
256
268
  }
257
269
  async getContributors() {
258
270
  const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/contributors`;
271
+ let config2 = {};
272
+ if (process3.env.GITHUB_TOKEN) {
273
+ config2 = {
274
+ headers: {
275
+ // eslint-disable-next-line @typescript-eslint/naming-convention
276
+ Authorization: `Bearer ${process3.env.GITHUB_TOKEN}`,
277
+ // eslint-disable-next-line @typescript-eslint/naming-convention
278
+ Accept: "application/vnd.github.v3+json"
279
+ }
280
+ };
281
+ }
259
282
  try {
260
- const result = await axios.get(url);
283
+ const result = await axios.get(url, config2);
261
284
  if (result && result.data.length > 0) {
262
285
  return result.data;
263
286
  }
@@ -606,9 +629,7 @@ var DoculaBuilder = class {
606
629
  }
607
630
  mergeSectionWithOptions(section, options) {
608
631
  if (options.sections) {
609
- const sectionOptions = options.sections.find(
610
- (sectionOption) => sectionOption.path === section.path
611
- );
632
+ const sectionOptions = options.sections.find((sectionOption) => sectionOption.path === section.path);
612
633
  if (sectionOptions) {
613
634
  section.name = sectionOptions.name;
614
635
  section.order = sectionOptions.order;
@@ -634,18 +655,12 @@ var DoculaBuilder = class {
634
655
  }
635
656
  }
636
657
  return {
637
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
638
658
  title: matterData.title,
639
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
640
- navTitle: matterData.navTitle || matterData.title,
641
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
642
- description: matterData.description || "",
643
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
644
- order: matterData.order || void 0,
645
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
646
- section: matterData.section || void 0,
647
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
648
- keywords: matterData.keywords || [],
659
+ navTitle: matterData.navTitle ?? matterData.title,
660
+ description: matterData.description ?? "",
661
+ order: matterData.order ?? void 0,
662
+ section: matterData.section ?? void 0,
663
+ keywords: matterData.keywords ?? [],
649
664
  content: documentContent,
650
665
  markdown: markdownContent,
651
666
  generatedHtml: this._ecto.renderSync(markdownContent, void 0, "markdown"),
@@ -781,7 +796,7 @@ var Docula = class {
781
796
  * @returns {void}
782
797
  */
783
798
  checkForUpdates() {
784
- const packageJsonPath = path3.join(process3.cwd(), "package.json");
799
+ const packageJsonPath = path3.join(process4.cwd(), "package.json");
785
800
  if (fs3.existsSync(packageJsonPath)) {
786
801
  const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf8"));
787
802
  updateNotifier({ pkg: packageJson }).notify();
@@ -792,9 +807,9 @@ var Docula = class {
792
807
  * @param {NodeJS.Process} process
793
808
  * @returns {Promise<void>}
794
809
  */
795
- async execute(process4) {
810
+ async execute(process5) {
796
811
  this.checkForUpdates();
797
- const consoleProcess = this._console.parseProcessArgv(process4.argv);
812
+ const consoleProcess = this._console.parseProcessArgv(process5.argv);
798
813
  this.options.singlePage = this.isSinglePageWebsite(this.options.sitePath);
799
814
  if (consoleProcess.args.sitePath) {
800
815
  this.options.sitePath = consoleProcess.args.sitePath;
@@ -905,15 +920,13 @@ var Docula = class {
905
920
  }
906
921
  const { port } = options;
907
922
  const { outputPath } = options;
908
- const config = {
923
+ const config2 = {
909
924
  public: outputPath
910
925
  };
911
- this._server = http.createServer(
912
- async (request, response) => (
913
- /* c8 ignore next */
914
- handler(request, response, config)
915
- )
916
- );
926
+ this._server = http.createServer(async (request, response) => (
927
+ /* c8 ignore next */
928
+ handler(request, response, config2)
929
+ ));
917
930
  this._server.listen(port, () => {
918
931
  this._console.log(`Docula \u{1F987} at http://localhost:${port}`);
919
932
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docula",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "description": "Beautiful Website for Your Projects",
5
5
  "type": "module",
6
6
  "main": "./dist/docula.js",
@@ -41,38 +41,43 @@
41
41
  "generate-init-file": "tsx scripts/generate-init-file.ts",
42
42
  "website:build": "rimraf ./site/README.md && node bin/docula.mjs build -s ./site -o ./site/dist",
43
43
  "website:serve": "rimraf ./site/README.md && node bin/docula.mjs serve -s ./site -o ./site/dist",
44
- "prepare": "npm run build"
44
+ "prepare": "pnpm build"
45
45
  },
46
46
  "bin": {
47
47
  "docula": "./bin/docula.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "axios": "^1.9.0",
51
- "cheerio": "^1.0.0",
52
- "ecto": "^4.2.3",
53
- "feed": "^5.0.1",
50
+ "axios": "^1.10.0",
51
+ "cheerio": "^1.1.0",
52
+ "ecto": "^4.3.0",
53
+ "feed": "^5.1.0",
54
54
  "he": "^1.2.0",
55
55
  "serve-handler": "^6.1.6",
56
56
  "update-notifier": "^7.3.1",
57
- "writr": "^4.4.3"
57
+ "writr": "^4.4.4"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/express": "^5.0.2",
60
+ "@types/express": "^5.0.3",
61
61
  "@types/he": "^1.2.3",
62
62
  "@types/js-yaml": "^4.0.9",
63
- "@types/node": "^22.15.18",
63
+ "@types/node": "^24.0.3",
64
64
  "@types/serve-handler": "^6.1.4",
65
65
  "@types/update-notifier": "^6.0.8",
66
- "@vitest/coverage-v8": "^3.1.3",
66
+ "@vitest/coverage-v8": "^3.2.4",
67
+ "dotenv": "^16.5.0",
67
68
  "rimraf": "^6.0.1",
68
69
  "tsup": "^8.5.0",
69
- "tsx": "^4.19.4",
70
+ "tsx": "^4.20.3",
70
71
  "typescript": "^5.8.3",
71
- "vitest": "^3.1.3",
72
- "webpack": "^5.99.8",
73
- "xo": "^0.60.0"
72
+ "vitest": "^3.2.4",
73
+ "webpack": "^5.99.9",
74
+ "xo": "^1.1.0"
74
75
  },
75
76
  "xo": {
77
+ "rules": {
78
+ "@typescript-eslint/no-unsafe-call": "off",
79
+ "@typescript-eslint/no-unsafe-assignment": "off"
80
+ },
76
81
  "ignores": [
77
82
  "docula.config.*",
78
83
  "vitest.config.*",
@@ -87,7 +92,8 @@
87
92
  ],
88
93
  "pnpm": {
89
94
  "onlyBuiltDependencies": [
90
- "esbuild"
95
+ "esbuild",
96
+ "unrs-resolver"
91
97
  ]
92
98
  }
93
99
  }