docula 0.3.2 → 0.3.4

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 (94) hide show
  1. package/README.md +1 -1
  2. package/dist/config.d.ts +21 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +78 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/docula-plugin.d.ts +9 -0
  7. package/dist/docula-plugin.d.ts.map +1 -0
  8. package/dist/docula-plugin.js +2 -0
  9. package/dist/docula-plugin.js.map +1 -0
  10. package/dist/docula.d.ts +22 -0
  11. package/dist/docula.d.ts.map +1 -0
  12. package/dist/docula.js +192 -0
  13. package/dist/docula.js.map +1 -0
  14. package/dist/eleventy/filters.d.ts +2 -0
  15. package/dist/eleventy/filters.d.ts.map +1 -0
  16. package/dist/eleventy/filters.js +10 -0
  17. package/dist/eleventy/filters.js.map +1 -0
  18. package/dist/eleventy/global-data.d.ts +3 -0
  19. package/dist/eleventy/global-data.d.ts.map +1 -0
  20. package/dist/eleventy/global-data.js +2 -0
  21. package/dist/eleventy/global-data.js.map +1 -0
  22. package/dist/eleventy/shortcodes.d.ts +4 -0
  23. package/dist/eleventy/shortcodes.d.ts.map +1 -0
  24. package/dist/eleventy/shortcodes.js +18 -0
  25. package/dist/eleventy/shortcodes.js.map +1 -0
  26. package/dist/eleventy.d.ts +24 -0
  27. package/dist/eleventy.d.ts.map +1 -0
  28. package/dist/eleventy.js +82 -0
  29. package/dist/eleventy.js.map +1 -0
  30. package/dist/index.d.ts +9 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +53 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/logger.d.ts +4 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/logger.js +20 -0
  37. package/dist/logger.js.map +1 -0
  38. package/dist/plugins/algolia.d.ts +21 -0
  39. package/dist/plugins/algolia.d.ts.map +1 -0
  40. package/dist/plugins/algolia.js +54 -0
  41. package/dist/plugins/algolia.js.map +1 -0
  42. package/dist/plugins/github.d.ts +16 -0
  43. package/dist/plugins/github.d.ts.map +1 -0
  44. package/dist/plugins/github.js +68 -0
  45. package/dist/plugins/github.js.map +1 -0
  46. package/dist/plugins/index.d.ts +18 -0
  47. package/dist/plugins/index.d.ts.map +1 -0
  48. package/dist/plugins/index.js +16 -0
  49. package/dist/plugins/index.js.map +1 -0
  50. package/dist/plugins/npm.d.ts +14 -0
  51. package/dist/plugins/npm.d.ts.map +1 -0
  52. package/dist/plugins/npm.js +36 -0
  53. package/dist/plugins/npm.js.map +1 -0
  54. package/dist/plugins/pagefind.d.ts +10 -0
  55. package/dist/plugins/pagefind.d.ts.map +1 -0
  56. package/dist/plugins/pagefind.js +22 -0
  57. package/dist/plugins/pagefind.js.map +1 -0
  58. package/dist/plugins/robots.d.ts +14 -0
  59. package/dist/plugins/robots.d.ts.map +1 -0
  60. package/dist/plugins/robots.js +34 -0
  61. package/dist/plugins/robots.js.map +1 -0
  62. package/dist/plugins/sitemap.d.ts +11 -0
  63. package/dist/plugins/sitemap.d.ts.map +1 -0
  64. package/dist/plugins/sitemap.js +27 -0
  65. package/dist/plugins/sitemap.js.map +1 -0
  66. package/dist/schemas.d.ts +21 -0
  67. package/dist/schemas.d.ts.map +1 -0
  68. package/dist/schemas.js +25 -0
  69. package/dist/schemas.js.map +1 -0
  70. package/dist/tools/__mocks__/inquirer-prompt.d.ts +20 -0
  71. package/dist/tools/__mocks__/inquirer-prompt.d.ts.map +1 -0
  72. package/dist/tools/__mocks__/inquirer-prompt.js +19 -0
  73. package/dist/tools/__mocks__/inquirer-prompt.js.map +1 -0
  74. package/dist/tools/__mocks__/path.d.ts +5 -0
  75. package/dist/tools/__mocks__/path.d.ts.map +1 -0
  76. package/dist/tools/__mocks__/path.js +7 -0
  77. package/dist/tools/__mocks__/path.js.map +1 -0
  78. package/dist/tools/inquirer-prompt.d.ts +11 -0
  79. package/dist/tools/inquirer-prompt.d.ts.map +1 -0
  80. package/dist/tools/inquirer-prompt.js +139 -0
  81. package/dist/tools/inquirer-prompt.js.map +1 -0
  82. package/dist/tools/path.d.ts +4 -0
  83. package/dist/tools/path.d.ts.map +1 -0
  84. package/dist/tools/path.js +6 -0
  85. package/dist/tools/path.js.map +1 -0
  86. package/dist/tools/tools.d.ts +3 -0
  87. package/dist/tools/tools.d.ts.map +1 -0
  88. package/dist/tools/tools.js +10 -0
  89. package/dist/tools/tools.js.map +1 -0
  90. package/dist/types/config.d.ts +8 -0
  91. package/dist/types/config.d.ts.map +1 -0
  92. package/dist/types/config.js +2 -0
  93. package/dist/types/config.js.map +1 -0
  94. package/package.json +13 -15
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - Zero Config - no config needed
14
14
  - Can run from `npx` or installed globally
15
15
  - Knowledge Base that is easy to setup and manage
16
- - Beautiful and Responsive Design (Like Stripe or 11ty)
16
+ - Beautiful and Responsive Design
17
17
  - Search Engine Optimized and Plugin (Algolia) and local search by default.
18
18
  - Convention over Configuration - just add your files, use a template (or build your own) and you're done.
19
19
  - Will generate a sitemap.xml
@@ -0,0 +1,21 @@
1
+ import type { PluginConfig, PluginConfigs, PluginName, Plugins } from './types/config.js';
2
+ export declare class Config {
3
+ originPath: string;
4
+ outputPath: string;
5
+ dataPath: string;
6
+ templatePath: string;
7
+ searchEngine: string;
8
+ pluginConfig: PluginConfigs;
9
+ plugins: Plugins;
10
+ imagesPath: string;
11
+ assetsPath: string;
12
+ siteUrl: string;
13
+ siteType: string;
14
+ ajv: any;
15
+ private readonly schema;
16
+ constructor(path?: string);
17
+ loadConfig(path: string): void;
18
+ loadPlugins(name: PluginName, config: PluginConfig): void;
19
+ checkConfigFile(path: string): boolean;
20
+ }
21
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAGxF,qBAAa,MAAM;IAClB,UAAU,SAAU;IACpB,UAAU,SAAU;IACpB,QAAQ,SAAU;IAClB,YAAY,SAAc;IAC1B,YAAY,SAAc;IAE1B,YAAY,EAAE,aAAa,CAAuB;IAClD,OAAO,EAAE,OAAO,CAAM;IACtB,UAAU,SAAY;IACtB,UAAU,SAAS;IACnB,OAAO,SAAM;IACb,QAAQ,SAAM;IAEd,GAAG,MAAa;IAEhB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,IAAI,CAAC,EAAE,MAAM;IAczB,UAAU,CAAC,IAAI,EAAE,MAAM;IAwCvB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY;IAWlD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGtC"}
package/dist/config.js ADDED
@@ -0,0 +1,78 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import Ajv from 'ajv';
3
+ import { jsonConfigSchema } from './schemas.js';
4
+ import DoculaPlugins from './plugins/index.js';
5
+ export class Config {
6
+ originPath = 'site';
7
+ outputPath = 'dist';
8
+ dataPath = 'data';
9
+ templatePath = 'template';
10
+ searchEngine = 'pagefind';
11
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
12
+ pluginConfig = {};
13
+ plugins = [];
14
+ imagesPath = 'images';
15
+ assetsPath = 'css';
16
+ siteUrl = '';
17
+ siteType = '';
18
+ // @ts-expect-error - ajv is not callable
19
+ ajv = new Ajv();
20
+ schema;
21
+ constructor(path) {
22
+ this.schema = { ...jsonConfigSchema };
23
+ this.schema.required = [];
24
+ const configPath = path ?? `./${this.originPath}/config.json`;
25
+ const configFileExists = this.checkConfigFile(configPath);
26
+ if (configFileExists) {
27
+ this.loadConfig(configPath);
28
+ }
29
+ if (path && !configFileExists) {
30
+ throw new Error('Config file not found');
31
+ }
32
+ }
33
+ loadConfig(path) {
34
+ const data = readFileSync(path, { encoding: 'utf8' });
35
+ const jsonConfig = JSON.parse(data);
36
+ if (jsonConfig.plugins) {
37
+ for (const name of jsonConfig.plugins) {
38
+ this.loadPlugins(name, jsonConfig[name]);
39
+ }
40
+ }
41
+ this.schema.required = [...new Set(this.schema.required)];
42
+ const validate = this.ajv.compile(this.schema);
43
+ validate(jsonConfig);
44
+ if (validate.errors) {
45
+ const [error] = validate.errors;
46
+ // @ts-expect-error - dataPath exist without error"
47
+ const { dataPath, message, keyword, params } = error;
48
+ if (keyword === 'additionalProperties') {
49
+ const { additionalProperty } = params;
50
+ throw new Error(`The config file has an invalid property: ${additionalProperty}`);
51
+ }
52
+ throw new Error(`${dataPath} ${message}`);
53
+ }
54
+ this.originPath = jsonConfig.originPath ?? this.originPath;
55
+ this.outputPath = jsonConfig.outputPath ?? this.outputPath;
56
+ this.dataPath = jsonConfig.dataPath ?? this.dataPath;
57
+ this.templatePath = jsonConfig.templatePath ?? this.templatePath;
58
+ this.searchEngine = jsonConfig.searchEngine ?? this.searchEngine;
59
+ this.imagesPath = jsonConfig.imagesPath ?? this.imagesPath;
60
+ this.assetsPath = jsonConfig.assetsPath ?? this.assetsPath;
61
+ this.plugins = jsonConfig.plugins ?? this.plugins;
62
+ this.siteUrl = jsonConfig.siteUrl ?? this.siteUrl;
63
+ }
64
+ loadPlugins(name, config) {
65
+ if (config) {
66
+ this.pluginConfig[name] = config;
67
+ const pluginSchema = DoculaPlugins[name].schema;
68
+ this.schema.properties[name] = pluginSchema;
69
+ if (pluginSchema.required?.length) {
70
+ this.schema.required.push(name);
71
+ }
72
+ }
73
+ }
74
+ checkConfigFile(path) {
75
+ return existsSync(path);
76
+ }
77
+ }
78
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,GAAG,MAAM,KAAK,CAA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YAAY,CAAC;QAEjE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IACnD,CAAC;IAED,WAAW,CAAC,IAAgB,EAAE,MAAoB;QACjD,IAAI,MAAM,EAAE;YACX,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;YACjC,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;YAChD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;YAC5C,IAAI,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE;gBAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAChC;SACD;IACF,CAAC;IAED,eAAe,CAAC,IAAY;QAC3B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD","sourcesContent":["import {existsSync, readFileSync} from 'node:fs';\nimport Ajv from 'ajv';\nimport {type ConfigSchema, jsonConfigSchema} from './schemas.js';\nimport type {PluginConfig, PluginConfigs, PluginName, Plugins} from './types/config.js';\nimport DoculaPlugins from './plugins/index.js';\n\nexport class Config {\n\toriginPath = 'site';\n\toutputPath = 'dist';\n\tdataPath = 'data';\n\ttemplatePath = 'template';\n\tsearchEngine = 'pagefind';\n\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\tpluginConfig: PluginConfigs = {} as PluginConfigs;\n\tplugins: Plugins = [];\n\timagesPath = 'images';\n\tassetsPath = 'css';\n\tsiteUrl = '';\n\tsiteType = '';\n\t// @ts-expect-error - ajv is not callable\n\tajv = new Ajv();\n\n\tprivate readonly schema: ConfigSchema;\n\n\tconstructor(path?: string) {\n\t\tthis.schema = {...jsonConfigSchema};\n\t\tthis.schema.required = [];\n\t\tconst configPath = path ?? `./${this.originPath}/config.json`;\n\t\tconst configFileExists = this.checkConfigFile(configPath);\n\t\tif (configFileExists) {\n\t\t\tthis.loadConfig(configPath);\n\t\t}\n\n\t\tif (path && !configFileExists) {\n\t\t\tthrow new Error('Config file not found');\n\t\t}\n\t}\n\n\tloadConfig(path: string) {\n\t\tconst data = readFileSync(path, {encoding: 'utf8'});\n\t\tconst jsonConfig = JSON.parse(data) as Record<string, any>;\n\n\t\tif (jsonConfig.plugins) {\n\t\t\tfor (const name of jsonConfig.plugins) {\n\t\t\t\tthis.loadPlugins(name, jsonConfig[name]);\n\t\t\t}\n\t\t}\n\n\t\tthis.schema.required = [...new Set(this.schema.required)];\n\n\t\tconst validate: Ajv.ValidateFunction = this.ajv.compile(this.schema);\n\n\t\tvalidate(jsonConfig);\n\n\t\tif (validate.errors) {\n\t\t\tconst [error] = validate.errors;\n\t\t\t// @ts-expect-error - dataPath exist without error\"\n\t\t\tconst {dataPath, message, keyword, params} = error;\n\t\t\tif (keyword === 'additionalProperties') {\n\t\t\t\tconst {additionalProperty} = params as Record<string, string>;\n\t\t\t\tthrow new Error(`The config file has an invalid property: ${additionalProperty}`);\n\t\t\t}\n\n\t\t\tthrow new Error(`${dataPath as string} ${message!}`);\n\t\t}\n\n\t\tthis.originPath = jsonConfig.originPath ?? this.originPath;\n\t\tthis.outputPath = jsonConfig.outputPath ?? this.outputPath;\n\t\tthis.dataPath = jsonConfig.dataPath ?? this.dataPath;\n\t\tthis.templatePath = jsonConfig.templatePath ?? this.templatePath;\n\t\tthis.searchEngine = jsonConfig.searchEngine ?? this.searchEngine;\n\n\t\tthis.imagesPath = jsonConfig.imagesPath ?? this.imagesPath;\n\t\tthis.assetsPath = jsonConfig.assetsPath ?? this.assetsPath;\n\t\tthis.plugins = jsonConfig.plugins ?? this.plugins;\n\t\tthis.siteUrl = jsonConfig.siteUrl ?? this.siteUrl;\n\t}\n\n\tloadPlugins(name: PluginName, config: PluginConfig) {\n\t\tif (config) {\n\t\t\tthis.pluginConfig[name] = config;\n\t\t\tconst pluginSchema = DoculaPlugins[name].schema;\n\t\t\tthis.schema.properties[name] = pluginSchema;\n\t\t\tif (pluginSchema.required?.length) {\n\t\t\t\tthis.schema.required.push(name);\n\t\t\t}\n\t\t}\n\t}\n\n\tcheckConfigFile(path: string): boolean {\n\t\treturn existsSync(path);\n\t}\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export type Runtime = 'before' | 'after';
2
+ export type Options = Record<string, string>;
3
+ export type Schema = Record<string, any>;
4
+ export type DoculaPlugin = {
5
+ options: Record<string, string>;
6
+ runtime: Runtime;
7
+ execute(): Promise<void>;
8
+ };
9
+ //# sourceMappingURL=docula-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docula-plugin.d.ts","sourceRoot":"","sources":["../src/docula-plugin.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AACzC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7C,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=docula-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docula-plugin.js","sourceRoot":"","sources":["../src/docula-plugin.ts"],"names":[],"mappings":"","sourcesContent":["\nexport type Runtime = 'before' | 'after';\nexport type Options = Record<string, string>;\nexport type Schema = Record<string, any>;\n\nexport type DoculaPlugin = {\n\toptions: Record<string, string>;\n\truntime: Runtime;\n\texecute(): Promise<void>;\n};\n"]}
@@ -0,0 +1,22 @@
1
+ import { Config } from './config.js';
2
+ import type { CommanderOptions } from './index.js';
3
+ export declare class Docula {
4
+ readonly config: Config;
5
+ private readonly eleventy;
6
+ private pluginInstances;
7
+ private readonly beforePlugins;
8
+ private readonly afterPlugins;
9
+ private readonly landingFilesExceptions;
10
+ constructor(options?: CommanderOptions);
11
+ init(sitePath?: string): Promise<void>;
12
+ build(): Promise<void>;
13
+ serve(): Promise<void>;
14
+ copyLandingFolder(source: string, target: string): void;
15
+ copyFolder(source: string, target: string): void;
16
+ copySearchEngineFiles(): void;
17
+ writeConfigFile(sitePath?: string): Promise<Record<string, unknown>>;
18
+ validateFilePath(source: string, target: string): Record<string, any>;
19
+ private loadPlugins;
20
+ private readonly executePlugins;
21
+ }
22
+ //# sourceMappingURL=docula.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docula.d.ts","sourceRoot":"","sources":["../src/docula.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAMnC,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAEjD,qBAAa,MAAM;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,eAAe,CAAuB;IAE9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;IACtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAyE;gBAEpG,OAAO,CAAC,EAAE,gBAAgB;IASzB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAetC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAc5B,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA4BvD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA4BvD,qBAAqB,IAAI,IAAI;IAsCvB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAuB1E,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAiBrE,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE7B;CACF"}
package/dist/docula.js ADDED
@@ -0,0 +1,192 @@
1
+ import * as path from 'node:path';
2
+ import process from 'node:process';
3
+ import fs from 'fs-extra';
4
+ import express from 'express';
5
+ import { Eleventy } from './eleventy.js';
6
+ import { Config } from './config.js';
7
+ import { setPlugins } from './tools/inquirer-prompt.js';
8
+ import DoculaPlugins from './plugins/index.js';
9
+ import { getConfigPath, getFileName, getSitePath } from './tools/path.js';
10
+ import logger from './logger.js';
11
+ export class Docula {
12
+ config;
13
+ eleventy;
14
+ pluginInstances = {};
15
+ beforePlugins = [];
16
+ afterPlugins = [];
17
+ landingFilesExceptions = ['search-index.md', 'versions.njk', 'index.njk', 'doc.njk'];
18
+ constructor(options) {
19
+ const parameters = options?.opts();
20
+ const defaultConfigPath = getConfigPath();
21
+ const configPath = parameters ? parameters?.config : defaultConfigPath;
22
+ this.config = new Config(configPath);
23
+ this.eleventy = new Eleventy(this.config);
24
+ this.loadPlugins();
25
+ }
26
+ async init(sitePath) {
27
+ const config = await this.writeConfigFile(sitePath);
28
+ const { originPath } = this.config;
29
+ const rootSitePath = path.join(process.cwd(), sitePath ?? originPath);
30
+ if (config.siteType === 'multi page') {
31
+ this.copyFolder('init', rootSitePath);
32
+ this.copySearchEngineFiles();
33
+ }
34
+ if (config.siteType === 'landing') {
35
+ this.copyLandingFolder('init', rootSitePath);
36
+ }
37
+ }
38
+ async build() {
39
+ const { originPath } = this.config;
40
+ const userOriginPath = `${process.cwd()}/${originPath}`;
41
+ if (!fs.existsSync(userOriginPath)) {
42
+ throw new Error(`The origin path "${userOriginPath}" does not exist.`);
43
+ }
44
+ await this.executePlugins(this.beforePlugins);
45
+ await this.eleventy.build();
46
+ await this.executePlugins(this.afterPlugins);
47
+ }
48
+ async serve() {
49
+ const { outputPath } = this.config;
50
+ if (!fs.existsSync(outputPath)) {
51
+ throw new Error(`The origin path "${outputPath}" does not exist.`);
52
+ }
53
+ const app = express();
54
+ const port = 8080;
55
+ app.use(express.static(outputPath));
56
+ app.listen(port, () => {
57
+ logger.info(`Docula is running on http://localhost:${port}`);
58
+ });
59
+ }
60
+ copyLandingFolder(source, target) {
61
+ const { sourcePath, targetExists, isDirectory } = this.validateFilePath(source, target);
62
+ if (isDirectory) {
63
+ const regex = /(search|docs|multipage)+/gi;
64
+ if (regex.test(source)) {
65
+ return;
66
+ }
67
+ if (!targetExists) {
68
+ fs.mkdirSync(target);
69
+ }
70
+ for (const file of fs.readdirSync(sourcePath)) {
71
+ if (!fs.existsSync(path.join(target, file))) {
72
+ this.copyLandingFolder(path.join(source, file), path.join(target, file));
73
+ }
74
+ }
75
+ }
76
+ else if (!fs.existsSync(target)) {
77
+ const isExcepted = this.landingFilesExceptions.some(file => source.includes(file));
78
+ if (isExcepted) {
79
+ return;
80
+ }
81
+ fs.copyFileSync(sourcePath, target);
82
+ }
83
+ }
84
+ copyFolder(source, target) {
85
+ const { sourcePath, targetExists, isDirectory } = this.validateFilePath(source, target);
86
+ if (isDirectory) {
87
+ // Exclude the search folder
88
+ if (source.includes('search') || source.includes('landing')) {
89
+ return;
90
+ }
91
+ if (!targetExists) {
92
+ fs.mkdirSync(target);
93
+ }
94
+ for (const file of fs.readdirSync(sourcePath)) {
95
+ if (!fs.existsSync(path.join(target, file))) {
96
+ this.copyFolder(path.join(source, file), path.join(target, file));
97
+ }
98
+ }
99
+ }
100
+ else if (!fs.existsSync(target)) {
101
+ // Exclude the search-index file
102
+ if (source.includes('search-index.md') || source.includes('releases')) {
103
+ return;
104
+ }
105
+ fs.copyFileSync(sourcePath, target);
106
+ }
107
+ }
108
+ copySearchEngineFiles() {
109
+ const { searchEngine, originPath } = this.config;
110
+ const __filename = getFileName();
111
+ const doculaPath = path.dirname(path.dirname(path.dirname(__filename)));
112
+ const sourcePath = path.join(doculaPath, `init/_includes/search/${searchEngine}.njk`);
113
+ const searchPath = path.join(process.cwd(), `${originPath}/_includes/search`);
114
+ const targetPath = path.join(process.cwd(), `${originPath}/_includes/search/${searchEngine}.njk`);
115
+ const searchStylesPath = path.join(process.cwd(), `${originPath}/_includes/assets/css/styles/search`);
116
+ const sourceSearchStylesPath = path.join(doculaPath, `init/_includes/assets/css/styles/search/${searchEngine}.css`);
117
+ const searchStylesTargetPath = path.join(process.cwd(), `${originPath}/_includes/assets/css/styles/search/${searchEngine}.css`);
118
+ if (!fs.existsSync(searchPath)) {
119
+ fs.mkdirSync(searchPath);
120
+ }
121
+ if (!fs.existsSync(targetPath)) {
122
+ fs.copyFileSync(sourcePath, targetPath);
123
+ }
124
+ // Copy search styles
125
+ if (!fs.existsSync(searchStylesPath)) {
126
+ fs.mkdirSync(searchStylesPath);
127
+ }
128
+ if (!fs.existsSync(searchStylesTargetPath)) {
129
+ fs.copyFileSync(sourceSearchStylesPath, searchStylesTargetPath);
130
+ }
131
+ if (searchEngine === 'algolia') {
132
+ const indexSource = path.join(doculaPath, 'init/search-index.md');
133
+ const indexTarget = path.join(process.cwd(), `${originPath}/search-index.md`);
134
+ if (!fs.existsSync(indexTarget)) {
135
+ fs.copyFileSync(indexSource, indexTarget);
136
+ }
137
+ }
138
+ }
139
+ async writeConfigFile(sitePath) {
140
+ const plugins = await setPlugins();
141
+ for (const plugin in plugins) {
142
+ if (Object.prototype.hasOwnProperty.call(plugins, plugin)) {
143
+ // @ts-expect-error fix later
144
+ this.config[plugin] = plugins[plugin];
145
+ }
146
+ }
147
+ const originPath = getSitePath();
148
+ const configPath = getConfigPath();
149
+ const rootSitePath = sitePath ? path.join(process.cwd(), sitePath) : originPath;
150
+ // Create the <site> folder
151
+ if (!fs.existsSync(rootSitePath)) {
152
+ fs.mkdirSync(rootSitePath);
153
+ }
154
+ fs.writeFileSync(configPath, JSON.stringify(plugins, null, 2));
155
+ return plugins;
156
+ }
157
+ validateFilePath(source, target) {
158
+ const __filename = getFileName();
159
+ const doculaPath = path.dirname(path.dirname(path.dirname(__filename)));
160
+ const sourcePath = path.join(doculaPath, source);
161
+ const sourceExists = fs.existsSync(sourcePath);
162
+ const targetExists = fs.existsSync(target);
163
+ const sourceStats = fs.statSync(sourcePath);
164
+ const isDirectory = sourceExists && sourceStats.isDirectory();
165
+ return {
166
+ sourcePath,
167
+ sourceExists,
168
+ targetExists,
169
+ isDirectory,
170
+ };
171
+ }
172
+ loadPlugins() {
173
+ const { plugins } = this.config;
174
+ for (const plugin of plugins) {
175
+ const pluginClass = DoculaPlugins[plugin];
176
+ // eslint-disable-next-line new-cap
177
+ const pluginInstance = new pluginClass(this.config);
178
+ this.pluginInstances[plugin] = pluginInstance;
179
+ const { runtime } = pluginInstance;
180
+ if (runtime === 'before') {
181
+ this.beforePlugins.push(pluginInstance);
182
+ }
183
+ else if (runtime === 'after') {
184
+ this.afterPlugins.push(pluginInstance);
185
+ }
186
+ }
187
+ }
188
+ executePlugins = async (plugins) => {
189
+ await Promise.all(plugins.map(async (plugin) => plugin.execute()));
190
+ };
191
+ }
192
+ //# sourceMappingURL=docula.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docula.js","sourceRoot":"","sources":["../src/docula.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,C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M,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;CACF","sourcesContent":["import * as path from 'node:path';\nimport process from 'node:process';\nimport fs from 'fs-extra';\nimport express from 'express';\nimport {Eleventy} from './eleventy.js';\nimport {Config} from './config.js';\nimport {setPlugins} from './tools/inquirer-prompt.js';\nimport DoculaPlugins from './plugins/index.js';\nimport type {PluginInstance, PluginInstances} from './types/config.js';\nimport {getConfigPath, getFileName, getSitePath} from './tools/path.js';\nimport logger from './logger.js';\nimport type {CommanderOptions} from './index.js';\n\nexport class Docula {\n\treadonly config: Config;\n\tprivate readonly eleventy: Eleventy;\n\tprivate pluginInstances: PluginInstances = {};\n\n\tprivate readonly beforePlugins: PluginInstance[] = [];\n\tprivate readonly afterPlugins: PluginInstance[] = [];\n\tprivate readonly landingFilesExceptions: string[] = ['search-index.md', 'versions.njk', 'index.njk', 'doc.njk'];\n\n\tconstructor(options?: CommanderOptions) {\n\t\tconst parameters = options?.opts();\n\t\tconst defaultConfigPath = getConfigPath();\n\t\tconst configPath: string = parameters ? parameters?.config : defaultConfigPath;\n\t\tthis.config = new Config(configPath);\n\t\tthis.eleventy = new Eleventy(this.config);\n\t\tthis.loadPlugins();\n\t}\n\n\tpublic async init(sitePath?: string): Promise<void> {\n\t\tconst config = await this.writeConfigFile(sitePath);\n\t\tconst {originPath} = this.config;\n\t\tconst rootSitePath = path.join(process.cwd(), sitePath ?? originPath);\n\n\t\tif (config.siteType === 'multi page') {\n\t\t\tthis.copyFolder('init', rootSitePath);\n\t\t\tthis.copySearchEngineFiles();\n\t\t}\n\n\t\tif (config.siteType === 'landing') {\n\t\t\tthis.copyLandingFolder('init', rootSitePath);\n\t\t}\n\t}\n\n\tpublic async build(): Promise<void> {\n\t\tconst {originPath} = this.config;\n\t\tconst userOriginPath = `${process.cwd()}/${originPath}`;\n\t\tif (!fs.existsSync(userOriginPath)) {\n\t\t\tthrow new Error(`The origin path \"${userOriginPath}\" does not exist.`);\n\t\t}\n\n\t\tawait this.executePlugins(this.beforePlugins);\n\t\tawait this.eleventy.build();\n\t\tawait this.executePlugins(this.afterPlugins);\n\t}\n\n\tpublic async serve(): Promise<void> {\n\t\tconst {outputPath} = this.config;\n\t\tif (!fs.existsSync(outputPath)) {\n\t\t\tthrow new Error(`The origin path \"${outputPath}\" does not exist.`);\n\t\t}\n\n\t\tconst app = express();\n\t\tconst port = 8080;\n\t\tapp.use(express.static(outputPath));\n\t\tapp.listen(port, () => {\n\t\t\tlogger.info(`Docula is running on http://localhost:${port}`);\n\t\t});\n\t}\n\n\tpublic copyLandingFolder(source: string, target: string): void {\n\t\tconst {sourcePath, targetExists, isDirectory} = this.validateFilePath(source, target);\n\n\t\tif (isDirectory) {\n\t\t\tconst regex = /(search|docs|multipage)+/gi;\n\t\t\tif (regex.test(source)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!targetExists) {\n\t\t\t\tfs.mkdirSync(target);\n\t\t\t}\n\n\t\t\tfor (const file of fs.readdirSync(sourcePath)) {\n\t\t\t\tif (!fs.existsSync(path.join(target, file))) {\n\t\t\t\t\tthis.copyLandingFolder(path.join(source, file), path.join(target, file));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!fs.existsSync(target)) {\n\t\t\tconst isExcepted = this.landingFilesExceptions.some(file => source.includes(file));\n\t\t\tif (isExcepted) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfs.copyFileSync(sourcePath, target);\n\t\t}\n\t}\n\n\tpublic copyFolder(source: string, target: string): void {\n\t\tconst {sourcePath, targetExists, isDirectory} = this.validateFilePath(source, target);\n\n\t\tif (isDirectory) {\n\t\t\t// Exclude the search folder\n\t\t\tif (source.includes('search') || source.includes('landing')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!targetExists) {\n\t\t\t\tfs.mkdirSync(target);\n\t\t\t}\n\n\t\t\tfor (const file of fs.readdirSync(sourcePath)) {\n\t\t\t\tif (!fs.existsSync(path.join(target, file))) {\n\t\t\t\t\tthis.copyFolder(path.join(source, file), path.join(target, file));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!fs.existsSync(target)) {\n\t\t\t// Exclude the search-index file\n\t\t\tif (source.includes('search-index.md') || source.includes('releases')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfs.copyFileSync(sourcePath, target);\n\t\t}\n\t}\n\n\tcopySearchEngineFiles(): void {\n\t\tconst {searchEngine, originPath} = this.config;\n\t\tconst __filename = getFileName();\n\t\tconst doculaPath = path.dirname(path.dirname(path.dirname(__filename)));\n\t\tconst sourcePath = path.join(doculaPath, `init/_includes/search/${searchEngine}.njk`);\n\t\tconst searchPath = path.join(process.cwd(), `${originPath}/_includes/search`);\n\t\tconst targetPath = path.join(process.cwd(), `${originPath}/_includes/search/${searchEngine}.njk`);\n\t\tconst searchStylesPath = path.join(process.cwd(), `${originPath}/_includes/assets/css/styles/search`);\n\t\tconst sourceSearchStylesPath = path.join(doculaPath, `init/_includes/assets/css/styles/search/${searchEngine}.css`);\n\t\tconst searchStylesTargetPath = path.join(process.cwd(), `${originPath}/_includes/assets/css/styles/search/${searchEngine}.css`);\n\n\t\tif (!fs.existsSync(searchPath)) {\n\t\t\tfs.mkdirSync(searchPath);\n\t\t}\n\n\t\tif (!fs.existsSync(targetPath)) {\n\t\t\tfs.copyFileSync(sourcePath, targetPath);\n\t\t}\n\n\t\t// Copy search styles\n\t\tif (!fs.existsSync(searchStylesPath)) {\n\t\t\tfs.mkdirSync(searchStylesPath);\n\t\t}\n\n\t\tif (!fs.existsSync(searchStylesTargetPath)) {\n\t\t\tfs.copyFileSync(sourceSearchStylesPath, searchStylesTargetPath);\n\t\t}\n\n\t\tif (searchEngine === 'algolia') {\n\t\t\tconst indexSource = path.join(doculaPath, 'init/search-index.md');\n\t\t\tconst indexTarget = path.join(process.cwd(), `${originPath}/search-index.md`);\n\n\t\t\tif (!fs.existsSync(indexTarget)) {\n\t\t\t\tfs.copyFileSync(indexSource, indexTarget);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync writeConfigFile(sitePath?: string): Promise<Record<string, unknown>> {\n\t\tconst plugins = await setPlugins();\n\t\tfor (const plugin in plugins) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(plugins, plugin)) {\n\t\t\t\t// @ts-expect-error fix later\n\t\t\t\tthis.config[plugin] = plugins[plugin];\n\t\t\t}\n\t\t}\n\n\t\tconst originPath = getSitePath();\n\t\tconst configPath = getConfigPath();\n\n\t\tconst rootSitePath = sitePath ? path.join(process.cwd(), sitePath) : originPath;\n\n\t\t// Create the <site> folder\n\t\tif (!fs.existsSync(rootSitePath)) {\n\t\t\tfs.mkdirSync(rootSitePath);\n\t\t}\n\n\t\tfs.writeFileSync(configPath, JSON.stringify(plugins, null, 2));\n\t\treturn plugins;\n\t}\n\n\tvalidateFilePath(source: string, target: string): Record<string, any> {\n\t\tconst __filename = getFileName();\n\t\tconst doculaPath = path.dirname(path.dirname(path.dirname(__filename)));\n\t\tconst sourcePath = path.join(doculaPath, source);\n\t\tconst sourceExists = fs.existsSync(sourcePath);\n\t\tconst targetExists = fs.existsSync(target);\n\t\tconst sourceStats = fs.statSync(sourcePath);\n\t\tconst isDirectory = sourceExists && sourceStats.isDirectory();\n\n\t\treturn {\n\t\t\tsourcePath,\n\t\t\tsourceExists,\n\t\t\ttargetExists,\n\t\t\tisDirectory,\n\t\t};\n\t}\n\n\tprivate loadPlugins(): void {\n\t\tconst {plugins} = this.config;\n\n\t\tfor (const plugin of plugins) {\n\t\t\tconst pluginClass = DoculaPlugins[plugin];\n\t\t\t// eslint-disable-next-line new-cap\n\t\t\tconst pluginInstance = new pluginClass(this.config);\n\t\t\tthis.pluginInstances[plugin] = pluginInstance;\n\n\t\t\tconst {runtime} = pluginInstance;\n\t\t\tif (runtime === 'before') {\n\t\t\t\tthis.beforePlugins.push(pluginInstance);\n\t\t\t} else if (runtime === 'after') {\n\t\t\t\tthis.afterPlugins.push(pluginInstance);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly executePlugins = async (plugins: PluginInstance[]): Promise<void> => {\n\t\tawait Promise.all(plugins.map(async plugin => plugin.execute()));\n\t};\n}\n\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const squashCallback: (text: string) => string;
2
+ //# sourceMappingURL=filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/eleventy/filters.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,SAAU,MAAM,KAAG,MAU7C,CAAC"}
@@ -0,0 +1,10 @@
1
+ export const squashCallback = (text) => {
2
+ const content = text.toString().toLowerCase();
3
+ // Remove duplicated words
4
+ const words = content.split(' ');
5
+ const deduped = [...(new Set(words))];
6
+ const dedupedString = deduped.join(' ');
7
+ // Remove repeated spaces
8
+ return dedupedString.replaceAll(/ {2,}/g, ' ');
9
+ };
10
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/eleventy/filters.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC;IAE9C,0BAA0B;IAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAExC,yBAAyB;IACzB,OAAO,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["export const squashCallback = (text: string): string => {\n\tconst content = text.toString().toLowerCase();\n\n\t// Remove duplicated words\n\tconst words = content.split(' ');\n\tconst deduped = [...(new Set(words))];\n\tconst dedupedString = deduped.join(' ');\n\n\t// Remove repeated spaces\n\treturn dedupedString.replaceAll(/ {2,}/g, ' ');\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { type Config } from '../config.js';
2
+ export declare const getConfig: (config: Config) => Config;
3
+ //# sourceMappingURL=global-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-data.d.ts","sourceRoot":"","sources":["../../src/eleventy/global-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,SAAS,WAAY,MAAM,KAAG,MAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const getConfig = (config) => config;
2
+ //# sourceMappingURL=global-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-data.js","sourceRoot":"","sources":["../../src/eleventy/global-data.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC","sourcesContent":["import {type Config} from '../config.js';\n\nexport const getConfig = (config: Config): Config => config;\n\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const getYear: () => string;
2
+ export declare const formatDate: (format: string, date?: string) => string;
3
+ export declare const parseRelease: (content: string) => string;
4
+ //# sourceMappingURL=shortcodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcodes.d.ts","sourceRoot":"","sources":["../../src/eleventy/shortcodes.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,QAAO,MAAmD,CAAC;AAE/E,eAAO,MAAM,UAAU,WAAY,MAAM,SAAS,MAAM,KAAG,MAM1D,CAAC;AAEF,eAAO,MAAM,YAAY,YAAa,MAAM,WAO3C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { DateTime } from 'luxon';
2
+ import MarkdownIt from 'markdown-it';
3
+ export const getYear = () => DateTime.local().toUTC().toFormat('yyyy');
4
+ export const formatDate = (format, date) => {
5
+ if (date) {
6
+ return DateTime.fromISO(date).toUTC().toFormat(format);
7
+ }
8
+ return DateTime.now().toUTC().toFormat(format);
9
+ };
10
+ export const parseRelease = (content) => {
11
+ const md = new MarkdownIt({
12
+ html: true,
13
+ linkify: true,
14
+ typographer: true,
15
+ });
16
+ return md.render(content);
17
+ };
18
+ //# sourceMappingURL=shortcodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcodes.js","sourceRoot":"","sources":["../../src/eleventy/shortcodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAE/E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,IAAa,EAAU,EAAE;IACnE,IAAI,IAAI,EAAE;QACT,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KACvD;IAED,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAE,EAAE;IAC/C,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC;QACzB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,IAAI;KACjB,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import {DateTime} from 'luxon';\nimport MarkdownIt from 'markdown-it';\n\nexport const getYear = (): string => DateTime.local().toUTC().toFormat('yyyy');\n\nexport const formatDate = (format: string, date?: string): string => {\n\tif (date) {\n\t\treturn DateTime.fromISO(date).toUTC().toFormat(format);\n\t}\n\n\treturn DateTime.now().toUTC().toFormat(format);\n};\n\nexport const parseRelease = (content: string) => {\n\tconst md = new MarkdownIt({\n\t\thtml: true,\n\t\tlinkify: true,\n\t\ttypographer: true,\n\t});\n\treturn md.render(content);\n};\n"]}
@@ -0,0 +1,24 @@
1
+ import type { Config } from './config.js';
2
+ type ElevJSONOutput = {
3
+ url: string;
4
+ inputPath: string;
5
+ outputPath: string;
6
+ content: string;
7
+ };
8
+ export declare class Eleventy {
9
+ private readonly _config;
10
+ private readonly eleventyConfig;
11
+ private readonly eleventy;
12
+ get config(): Config;
13
+ constructor(config: Config);
14
+ build(): Promise<void>;
15
+ toJSON(): Promise<ElevJSONOutput[]>;
16
+ private addPassthroughCopy;
17
+ private setLibrary;
18
+ private addPlugin;
19
+ private addShortcode;
20
+ private addFilter;
21
+ private addGlobalData;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=eleventy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eleventy.d.ts","sourceRoot":"","sources":["../src/eleventy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAgCxC,KAAK,cAAc,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,QAAQ;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2J;IAC1L,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,IAAI,MAAM,IAAI,MAAM,CAEnB;gBAEW,MAAM,EAAE,MAAM;IA2Bb,KAAK;IASL,MAAM;IAKnB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa;CAIrB"}
@@ -0,0 +1,82 @@
1
+ // @ts-expect-error - 11ty doesn't have types
2
+ import * as pkg from '@11ty/eleventy';
3
+ // @ts-expect-error - 11ty doesn't have types
4
+ import eleventyNavigationPlugin from '@11ty/eleventy-navigation';
5
+ // @ts-expect-error - 11ty doesn't have types
6
+ import pluginTOC from 'eleventy-plugin-toc';
7
+ import markdownIt from 'markdown-it';
8
+ import markdownItAnchor from 'markdown-it-anchor';
9
+ import { squashCallback } from './eleventy/filters.js';
10
+ import { getYear, formatDate, parseRelease } from './eleventy/shortcodes.js';
11
+ import { getConfig } from './eleventy/global-data.js';
12
+ // eslint-disable-next-line @typescript-eslint/naming-convention
13
+ const Elev = pkg.default;
14
+ export class Eleventy {
15
+ _config;
16
+ eleventyConfig;
17
+ eleventy;
18
+ get config() {
19
+ return this._config;
20
+ }
21
+ constructor(config) {
22
+ this._config = config;
23
+ this.eleventyConfig = {
24
+ quietMode: true,
25
+ config: (eleventyConfig) => {
26
+ eleventyConfig.ignores.add(`./${this.config.originPath}/README.md`);
27
+ this.addPassthroughCopy(eleventyConfig);
28
+ this.setLibrary(eleventyConfig);
29
+ this.addPlugin(eleventyConfig);
30
+ this.addShortcode(eleventyConfig);
31
+ this.addFilter(eleventyConfig);
32
+ this.addGlobalData(eleventyConfig);
33
+ eleventyConfig.setTemplateFormats(['njk', 'md', 'html']);
34
+ return {
35
+ markdownTemplateEngine: 'njk',
36
+ htmlTemplateEngine: 'njk',
37
+ passthroughFileCopy: true,
38
+ };
39
+ },
40
+ };
41
+ this.eleventy = new Elev(this.config.originPath, this.config.outputPath, this.eleventyConfig);
42
+ }
43
+ async build() {
44
+ try {
45
+ await this.eleventy.write();
46
+ }
47
+ catch (error) {
48
+ throw new Error(`Eleventy build failed: ${error.message}`);
49
+ }
50
+ }
51
+ // eslint-disable-next-line @typescript-eslint/naming-convention
52
+ async toJSON() {
53
+ const json = await this.eleventy.toJSON();
54
+ return json.filter((element) => element.url);
55
+ }
56
+ addPassthroughCopy(eleventyConfig) {
57
+ const assetsPath = `${this.config.originPath}/_includes/assets`;
58
+ eleventyConfig.addPassthroughCopy({ [assetsPath]: '/assets/' });
59
+ }
60
+ setLibrary(eleventyConfig) {
61
+ eleventyConfig.setLibrary('md', markdownIt().use(markdownItAnchor));
62
+ }
63
+ addPlugin(eleventyConfig) {
64
+ eleventyConfig.addPlugin(eleventyNavigationPlugin);
65
+ eleventyConfig.addPlugin(pluginTOC, {
66
+ tags: ['h2'],
67
+ });
68
+ }
69
+ addShortcode(eleventyConfig) {
70
+ eleventyConfig.addShortcode('year', getYear);
71
+ eleventyConfig.addShortcode('formatDate', formatDate);
72
+ eleventyConfig.addShortcode('parseRelease', parseRelease);
73
+ }
74
+ addFilter(eleventyConfig) {
75
+ eleventyConfig.addFilter('squash', squashCallback);
76
+ }
77
+ addGlobalData(eleventyConfig) {
78
+ // EleventyConfig.addGlobalData('algoliaKeys', () => algoliaKeys(this.config));
79
+ eleventyConfig.addGlobalData('config', () => getConfig(this.config));
80
+ }
81
+ }
82
+ //# sourceMappingURL=eleventy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eleventy.js","sourceRoot":"","sources":["../src/eleventy.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,6CAA6C;AAC7C,OAAO,wBAAwB,MAAM,2BAA2B,CAAC;AACjE,6CAA6C;AAC7C,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAC,c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AY,CAAC,CAAC;IAC3D,CAAC;IAEO,SAAS,CAAC,cAA0B;QAC3C,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;IAEO,aAAa,CAAC,cAA0B;QAC/C,+EAA+E;QAC/E,cAAc,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;CACD","sourcesContent":["// @ts-expect-error - 11ty doesn't have types\nimport * as pkg from '@11ty/eleventy';\n// @ts-expect-error - 11ty doesn't have types\nimport eleventyNavigationPlugin from '@11ty/eleventy-navigation';\n// @ts-expect-error - 11ty doesn't have types\nimport pluginTOC from 'eleventy-plugin-toc';\nimport markdownIt from 'markdown-it';\nimport markdownItAnchor from 'markdown-it-anchor';\nimport type {Config} from './config.js';\nimport {squashCallback} from './eleventy/filters.js';\nimport {getYear, formatDate, parseRelease} from './eleventy/shortcodes.js';\nimport {getConfig} from './eleventy/global-data.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst Elev = pkg.default;\n\ntype ElevConfig = {\n\tignores: {\n\t\tadd: (pattern: string) => void;\n\t};\n\taddPassthroughCopy: (options: Record<string, unknown>) => void;\n\tsetLibrary: (name: string, library: unknown) => void;\n\taddPlugin: (plugin: any, options?: Record<string, unknown>) => void;\n\taddShortcode: (name: string, callback: (...args: any[]) => unknown) => void;\n\taddFilter: (name: string, callback: (text: string) => string) => void;\n\tsetTemplateFormats(strings: string[]): void;\n\taddGlobalData(name: string, config: () => unknown): void;\n};\n\ntype ElevInterface = {\n\tconstructor: (originPath: string, outputPath: string, config: {\n\t\tquietMode?: boolean;\n\t\tconfig: (config: ElevConfig) => Record<string, unknown>;\n\t}) => void;\n\twrite: () => Promise<void>;\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\ttoJSON: () => Promise<ElevJSONOutput[]>;\n};\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype ElevJSONOutput = {\n\turl: string;\n\tinputPath: string;\n\toutputPath: string;\n\tcontent: string;\n};\n\nexport class Eleventy {\n\tprivate readonly _config: Config;\n\tprivate readonly eleventyConfig: {quietMode: boolean; config: (eleventyConfig: ElevConfig) => {htmlTemplateEngine: string; passthroughFileCopy: boolean; markdownTemplateEngine: string}};\n\tprivate readonly eleventy: ElevInterface;\n\tget config(): Config {\n\t\treturn this._config;\n\t}\n\n\tconstructor(config: Config) {\n\t\tthis._config = config;\n\t\tthis.eleventyConfig = {\n\t\t\tquietMode: true,\n\t\t\tconfig: (eleventyConfig: ElevConfig) => {\n\t\t\t\televentyConfig.ignores.add(`./${this.config.originPath}/README.md`);\n\n\t\t\t\tthis.addPassthroughCopy(eleventyConfig);\n\t\t\t\tthis.setLibrary(eleventyConfig);\n\t\t\t\tthis.addPlugin(eleventyConfig);\n\t\t\t\tthis.addShortcode(eleventyConfig);\n\t\t\t\tthis.addFilter(eleventyConfig);\n\t\t\t\tthis.addGlobalData(eleventyConfig);\n\n\t\t\t\televentyConfig.setTemplateFormats(['njk', 'md', 'html']);\n\n\t\t\t\treturn {\n\t\t\t\t\tmarkdownTemplateEngine: 'njk',\n\t\t\t\t\thtmlTemplateEngine: 'njk',\n\t\t\t\t\tpassthroughFileCopy: true,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\n\t\tthis.eleventy = new Elev(this.config.originPath, this.config.outputPath, this.eleventyConfig);\n\t}\n\n\tpublic async build() {\n\t\ttry {\n\t\t\tawait this.eleventy.write();\n\t\t} catch (error: unknown) {\n\t\t\tthrow new Error(`Eleventy build failed: ${(error as Error).message}`);\n\t\t}\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tpublic async toJSON() {\n\t\tconst json: ElevJSONOutput[] = await this.eleventy.toJSON();\n\t\treturn json.filter((element: ElevJSONOutput) => element.url);\n\t}\n\n\tprivate addPassthroughCopy(eleventyConfig: ElevConfig) {\n\t\tconst assetsPath = `${this.config.originPath}/_includes/assets`;\n\t\televentyConfig.addPassthroughCopy({[assetsPath]: '/assets/'});\n\t}\n\n\tprivate setLibrary(eleventyConfig: ElevConfig) {\n\t\televentyConfig.setLibrary(\n\t\t\t'md',\n\t\t\tmarkdownIt().use(markdownItAnchor),\n\t\t);\n\t}\n\n\tprivate addPlugin(eleventyConfig: ElevConfig) {\n\t\televentyConfig.addPlugin(eleventyNavigationPlugin);\n\t\televentyConfig.addPlugin(pluginTOC, {\n\t\t\ttags: ['h2'],\n\t\t});\n\t}\n\n\tprivate addShortcode(eleventyConfig: ElevConfig) {\n\t\televentyConfig.addShortcode('year', getYear);\n\t\televentyConfig.addShortcode('formatDate', formatDate);\n\t\televentyConfig.addShortcode('parseRelease', parseRelease);\n\t}\n\n\tprivate addFilter(eleventyConfig: ElevConfig) {\n\t\televentyConfig.addFilter('squash', squashCallback);\n\t}\n\n\tprivate addGlobalData(eleventyConfig: ElevConfig) {\n\t\t// EleventyConfig.addGlobalData('algoliaKeys', () => algoliaKeys(this.config));\n\t\televentyConfig.addGlobalData('config', () => getConfig(this.config));\n\t}\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { type OptionValues } from 'commander';
3
+ export type CommanderOptions = {
4
+ opts: () => OptionValues;
5
+ };
6
+ export declare class Executable {
7
+ parseCLI(process: NodeJS.Process): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAgB,KAAK,YAAY,EAAC,MAAM,WAAW,CAAC;AAK3D,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,YAAY,CAAC;CACzB,CAAC;AAEF,qBAAa,UAAU;IAEhB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO;CA+CtC"}