docula 0.0.5 → 0.0.7

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 (86) hide show
  1. package/dist/config.d.ts +21 -0
  2. package/dist/config.d.ts.map +1 -0
  3. package/dist/config.js +75 -0
  4. package/dist/config.js.map +1 -0
  5. package/dist/docula-plugin.d.ts +9 -0
  6. package/dist/docula-plugin.d.ts.map +1 -0
  7. package/dist/docula-plugin.js +2 -0
  8. package/dist/docula-plugin.js.map +1 -0
  9. package/dist/docula.d.ts +17 -0
  10. package/dist/docula.d.ts.map +1 -0
  11. package/dist/docula.js +97 -0
  12. package/dist/docula.js.map +1 -0
  13. package/dist/eleventy/filters.d.ts +2 -0
  14. package/dist/eleventy/filters.d.ts.map +1 -0
  15. package/dist/eleventy/filters.js +10 -0
  16. package/dist/eleventy/filters.js.map +1 -0
  17. package/dist/eleventy/shortcodes.d.ts +4 -0
  18. package/dist/eleventy/shortcodes.d.ts.map +1 -0
  19. package/dist/eleventy/shortcodes.js +18 -0
  20. package/dist/eleventy/shortcodes.js.map +1 -0
  21. package/dist/eleventy.d.ts +23 -0
  22. package/dist/eleventy.d.ts.map +1 -0
  23. package/dist/eleventy.js +69 -0
  24. package/dist/eleventy.js.map +1 -0
  25. package/dist/index.d.ts +9 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +39 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/logger.d.ts +4 -0
  30. package/dist/logger.d.ts.map +1 -0
  31. package/dist/logger.js +20 -0
  32. package/dist/logger.js.map +1 -0
  33. package/dist/plugins/github.d.ts +16 -0
  34. package/dist/plugins/github.d.ts.map +1 -0
  35. package/dist/plugins/github.js +68 -0
  36. package/dist/plugins/github.js.map +1 -0
  37. package/dist/plugins/index.d.ts +16 -0
  38. package/dist/plugins/index.d.ts.map +1 -0
  39. package/dist/plugins/index.js +14 -0
  40. package/dist/plugins/index.js.map +1 -0
  41. package/dist/plugins/npm.d.ts +14 -0
  42. package/dist/plugins/npm.d.ts.map +1 -0
  43. package/dist/plugins/npm.js +36 -0
  44. package/dist/plugins/npm.js.map +1 -0
  45. package/dist/plugins/pagefind.d.ts +10 -0
  46. package/dist/plugins/pagefind.d.ts.map +1 -0
  47. package/dist/plugins/pagefind.js +22 -0
  48. package/dist/plugins/pagefind.js.map +1 -0
  49. package/dist/plugins/robots.d.ts +14 -0
  50. package/dist/plugins/robots.d.ts.map +1 -0
  51. package/dist/plugins/robots.js +34 -0
  52. package/dist/plugins/robots.js.map +1 -0
  53. package/dist/plugins/sitemap.d.ts +11 -0
  54. package/dist/plugins/sitemap.d.ts.map +1 -0
  55. package/dist/plugins/sitemap.js +26 -0
  56. package/dist/plugins/sitemap.js.map +1 -0
  57. package/dist/schemas.d.ts +21 -0
  58. package/dist/schemas.d.ts.map +1 -0
  59. package/dist/schemas.js +24 -0
  60. package/dist/schemas.js.map +1 -0
  61. package/dist/tools/__mocks__/inquirer-prompt.d.ts +18 -0
  62. package/dist/tools/__mocks__/inquirer-prompt.d.ts.map +1 -0
  63. package/dist/tools/__mocks__/inquirer-prompt.js +17 -0
  64. package/dist/tools/__mocks__/inquirer-prompt.js.map +1 -0
  65. package/dist/tools/__mocks__/path.d.ts +4 -0
  66. package/dist/tools/__mocks__/path.d.ts.map +1 -0
  67. package/dist/tools/__mocks__/path.js +5 -0
  68. package/dist/tools/__mocks__/path.js.map +1 -0
  69. package/dist/tools/inquirer-prompt.d.ts +7 -0
  70. package/dist/tools/inquirer-prompt.d.ts.map +1 -0
  71. package/dist/tools/inquirer-prompt.js +62 -0
  72. package/dist/tools/inquirer-prompt.js.map +1 -0
  73. package/dist/tools/path.d.ts +3 -0
  74. package/dist/tools/path.d.ts.map +1 -0
  75. package/dist/tools/path.js +5 -0
  76. package/dist/tools/path.js.map +1 -0
  77. package/dist/tools/tools.d.ts +3 -0
  78. package/dist/tools/tools.d.ts.map +1 -0
  79. package/dist/tools/tools.js +10 -0
  80. package/dist/tools/tools.js.map +1 -0
  81. package/dist/types/config.d.ts +8 -0
  82. package/dist/types/config.d.ts.map +1 -0
  83. package/dist/types/config.js +2 -0
  84. package/dist/types/config.js.map +1 -0
  85. package/init/index.njk +2 -2
  86. package/package.json +3 -4
@@ -0,0 +1,21 @@
1
+ import Ajv from 'ajv';
2
+ import type { PluginConfig, PluginConfigs, PluginName, Plugins } from './types/config.js';
3
+ export declare class Config {
4
+ originPath: string;
5
+ outputPath: string;
6
+ dataPath: string;
7
+ templatePath: string;
8
+ searchEngine: string;
9
+ pluginConfig: PluginConfigs;
10
+ plugins: Plugins;
11
+ imagesPath: string;
12
+ assetsPath: string;
13
+ siteUrl: string;
14
+ ajv: Ajv.Ajv;
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":"AACA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,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,GAAG,UAAa;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,75 @@
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
+ constructor(path) {
7
+ this.originPath = 'site';
8
+ this.outputPath = 'dist';
9
+ this.dataPath = 'data';
10
+ this.templatePath = 'template';
11
+ this.searchEngine = 'pagefind';
12
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
13
+ this.pluginConfig = {};
14
+ this.plugins = [];
15
+ this.imagesPath = 'images';
16
+ this.assetsPath = 'css';
17
+ this.siteUrl = '';
18
+ this.ajv = new Ajv();
19
+ this.schema = { ...jsonConfigSchema };
20
+ this.schema.required = [];
21
+ const configPath = path ?? `./${this.originPath}/config.json`;
22
+ const configFileExists = this.checkConfigFile(configPath);
23
+ if (configFileExists) {
24
+ this.loadConfig(configPath);
25
+ }
26
+ if (path && !configFileExists) {
27
+ throw new Error('Config file not found');
28
+ }
29
+ }
30
+ loadConfig(path) {
31
+ const data = readFileSync(path, { encoding: 'utf8' });
32
+ const jsonConfig = JSON.parse(data);
33
+ if (jsonConfig.plugins) {
34
+ for (const name of jsonConfig.plugins) {
35
+ this.loadPlugins(name, jsonConfig[name]);
36
+ }
37
+ }
38
+ this.schema.required = [...new Set(this.schema.required)];
39
+ const validate = this.ajv.compile(this.schema);
40
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
41
+ validate(jsonConfig);
42
+ if (validate.errors) {
43
+ const [error] = validate.errors;
44
+ const { dataPath, message, keyword, params } = error;
45
+ if (keyword === 'additionalProperties') {
46
+ const { additionalProperty } = params;
47
+ throw new Error(`The config file has an invalid property: ${additionalProperty}`);
48
+ }
49
+ throw new Error(`${dataPath} ${message}`);
50
+ }
51
+ this.originPath = jsonConfig.originPath ?? this.originPath;
52
+ this.outputPath = jsonConfig.outputPath ?? this.outputPath;
53
+ this.dataPath = jsonConfig.dataPath ?? this.dataPath;
54
+ this.templatePath = jsonConfig.templatePath ?? this.templatePath;
55
+ this.searchEngine = jsonConfig.searchEngine ?? this.searchEngine;
56
+ this.imagesPath = jsonConfig.imagesPath ?? this.imagesPath;
57
+ this.assetsPath = jsonConfig.assetsPath ?? this.assetsPath;
58
+ this.plugins = jsonConfig.plugins ?? this.plugins;
59
+ this.siteUrl = jsonConfig.siteUrl ?? this.siteUrl;
60
+ }
61
+ loadPlugins(name, config) {
62
+ if (config) {
63
+ this.pluginConfig[name] = config;
64
+ const pluginSchema = DoculaPlugins[name].schema;
65
+ this.schema.properties[name] = pluginSchema;
66
+ if (pluginSchema.required?.length) {
67
+ this.schema.required.push(name);
68
+ }
69
+ }
70
+ }
71
+ checkConfigFile(path) {
72
+ return existsSync(path);
73
+ }
74
+ }
75
+ //# 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,CAAC;AACtB,OAAO,EAAoB,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAEjE,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,OAAO,MAAM;IAgBlB,YAAY,IAAa;QAfzB,eAAU,GAAG,MAAM,CAAC;QACpB,eAAU,GAAG,MAAM,CAAC;QACpB,aAAQ,GAAG,MAAM,CAAC;QAClB,iBAAY,GAAG,UAAU,CAAC;QAC1B,iBAAY,GAAG,UAAU,CAAC;QAC1B,0EAA0E;QAC1E,iBAAY,GAAkB,EAAmB,CAAC;QAClD,YAAO,GAAY,EAAE,CAAC;QACtB,eAAU,GAAG,QAAQ,CAAC;QACtB,eAAU,GAAG,KAAK,CAAC;QACnB,YAAO,GAAG,EAAE,CAAC;QACb,QAAG,GAAG,IAAI,GAA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,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"}
@@ -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":""}
@@ -0,0 +1,17 @@
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
+ constructor(options?: CommanderOptions);
10
+ init(sitePath?: string): Promise<void>;
11
+ build(): Promise<void>;
12
+ copyFolder(source: string, target: string): void;
13
+ private buildConfigFile;
14
+ private loadPlugins;
15
+ private readonly executePlugins;
16
+ }
17
+ //# sourceMappingURL=docula.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docula.d.ts","sourceRoot":"","sources":["../src/docula.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAKnC,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;gBAEzC,OAAO,CAAC,EAAE,gBAAgB;IASzB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;YAwBzC,eAAe;IAiB7B,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE7B;CACF"}
package/dist/docula.js ADDED
@@ -0,0 +1,97 @@
1
+ import * as path from 'node:path';
2
+ import process from 'node:process';
3
+ import fs from 'fs-extra';
4
+ import { Eleventy } from './eleventy.js';
5
+ import { Config } from './config.js';
6
+ import { getSiteUrl, getUserPlugins, parsePluginsData } from './tools/inquirer-prompt.js';
7
+ import DoculaPlugins from './plugins/index.js';
8
+ import { getConfigPath, getFileName } from './tools/path.js';
9
+ export class Docula {
10
+ constructor(options) {
11
+ this.pluginInstances = {};
12
+ this.beforePlugins = [];
13
+ this.afterPlugins = [];
14
+ this.executePlugins = async (plugins) => {
15
+ await Promise.all(plugins.map(async (plugin) => plugin.execute()));
16
+ };
17
+ const parameters = options?.opts();
18
+ const configPath = getConfigPath();
19
+ const config = parameters ? parameters?.config : configPath;
20
+ this.config = new Config(config);
21
+ this.eleventy = new Eleventy(this.config);
22
+ this.loadPlugins();
23
+ }
24
+ async init(sitePath) {
25
+ await this.buildConfigFile();
26
+ const { originPath } = this.config;
27
+ const rootSitePath = path.join(process.cwd(), sitePath ?? originPath);
28
+ // Create the <site> folder
29
+ if (!fs.existsSync(rootSitePath)) {
30
+ fs.mkdirSync(rootSitePath);
31
+ }
32
+ this.copyFolder('init', rootSitePath);
33
+ }
34
+ async build() {
35
+ const { originPath } = this.config;
36
+ const userOriginPath = `${process.cwd()}/${originPath}`;
37
+ if (!fs.existsSync(userOriginPath)) {
38
+ throw new Error(`The origin path "${userOriginPath}" does not exist.`);
39
+ }
40
+ await this.executePlugins(this.beforePlugins);
41
+ await this.eleventy.build();
42
+ await this.executePlugins(this.afterPlugins);
43
+ }
44
+ copyFolder(source, target) {
45
+ const __filename = getFileName();
46
+ const doculaPath = path.dirname(path.dirname(path.dirname(__filename)));
47
+ const sourcePath = path.join(doculaPath, source);
48
+ const sourceExists = fs.existsSync(sourcePath);
49
+ const targetExists = fs.existsSync(target);
50
+ const sourceStats = fs.statSync(sourcePath);
51
+ const isDirectory = sourceExists && sourceStats.isDirectory();
52
+ if (isDirectory) {
53
+ if (!targetExists) {
54
+ fs.mkdirSync(target);
55
+ }
56
+ for (const file of fs.readdirSync(sourcePath)) {
57
+ if (!fs.existsSync(path.join(target, file))) {
58
+ this.copyFolder(path.join(source, file), path.join(target, file));
59
+ }
60
+ }
61
+ }
62
+ else if (!fs.existsSync(target)) {
63
+ fs.copyFileSync(sourcePath, target);
64
+ }
65
+ }
66
+ async buildConfigFile() {
67
+ const userConfig = {};
68
+ const siteUrl = await getSiteUrl();
69
+ const plugins = await getUserPlugins();
70
+ const parsedPlugins = await parsePluginsData(plugins);
71
+ userConfig.siteUrl = siteUrl;
72
+ for (const plugin in parsedPlugins) {
73
+ if (Object.prototype.hasOwnProperty.call(parsedPlugins, plugin)) {
74
+ userConfig[plugin] = parsedPlugins[plugin];
75
+ }
76
+ }
77
+ const configPath = getConfigPath();
78
+ fs.writeFileSync(configPath, JSON.stringify(userConfig, null, 2));
79
+ }
80
+ loadPlugins() {
81
+ const { plugins } = this.config;
82
+ for (const plugin of plugins) {
83
+ const pluginClass = DoculaPlugins[plugin];
84
+ // eslint-disable-next-line new-cap
85
+ const pluginInstance = new pluginClass(this.config);
86
+ this.pluginInstances[plugin] = pluginInstance;
87
+ const { runtime } = pluginInstance;
88
+ if (runtime === 'before') {
89
+ this.beforePlugins.push(pluginInstance);
90
+ }
91
+ else if (runtime === 'after') {
92
+ this.afterPlugins.push(pluginInstance);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ //# 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,CAAC;AAClC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AACxF,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAG3D,MAAM,OAAO,MAAM;IAQlB,YAAY,OAA0B;QAL9B,oBAAe,GAAoB,EAAE,CAAC;QAE7B,kBAAa,GA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CAAC;YAE9C,MAAM,EAAC,OAAO,EAAC,GAAG,cAAc,CAAC;YACjC,IAAI,OAAO,KAAK,QAAQ,EAAE;gBACzB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aACxC;iBAAM,IAAI,OAAO,KAAK,OAAO,EAAE;gBAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;aACvC;SACD;IACF,CAAC;CAKD"}
@@ -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.replace(/ {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,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const getYear: () => string;
2
+ export declare const formatDate: (format: string, date?: Date) => 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,IAAI,KAAG,MAMxD,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.fromJSDate(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,IAAW,EAAU,EAAE;IACjE,IAAI,IAAI,EAAE;QACT,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAC1D;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"}
@@ -0,0 +1,23 @@
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
+ }
22
+ export {};
23
+ //# 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;AA6BxC,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;IAKL,MAAM;IAKnB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,SAAS;CAGjB"}
@@ -0,0 +1,69 @@
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
+ // eslint-disable-next-line @typescript-eslint/naming-convention
12
+ const Elev = pkg.default;
13
+ export class Eleventy {
14
+ get config() {
15
+ return this._config;
16
+ }
17
+ constructor(config) {
18
+ this._config = config;
19
+ this.eleventyConfig = {
20
+ quietMode: true,
21
+ config: (eleventyConfig) => {
22
+ eleventyConfig.ignores.add(`./${this.config.originPath}/README.md`);
23
+ this.addPassthroughCopy(eleventyConfig);
24
+ this.setLibrary(eleventyConfig);
25
+ this.addPlugin(eleventyConfig);
26
+ this.addShortcode(eleventyConfig);
27
+ this.addFilter(eleventyConfig);
28
+ eleventyConfig.setTemplateFormats(['njk', 'md', 'html']);
29
+ return {
30
+ markdownTemplateEngine: 'njk',
31
+ htmlTemplateEngine: 'njk',
32
+ passthroughFileCopy: true,
33
+ };
34
+ },
35
+ };
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
37
+ this.eleventy = new Elev(this.config.originPath, this.config.outputPath, this.eleventyConfig);
38
+ }
39
+ async build() {
40
+ await this.eleventy.write();
41
+ }
42
+ // eslint-disable-next-line @typescript-eslint/naming-convention
43
+ async toJSON() {
44
+ const json = await this.eleventy.toJSON();
45
+ return json.filter((element) => element.url);
46
+ }
47
+ addPassthroughCopy(eleventyConfig) {
48
+ const assetsPath = `${this.config.originPath}/_includes/assets`;
49
+ eleventyConfig.addPassthroughCopy({ [assetsPath]: '/assets/' });
50
+ }
51
+ setLibrary(eleventyConfig) {
52
+ eleventyConfig.setLibrary('md', markdownIt().use(markdownItAnchor));
53
+ }
54
+ addPlugin(eleventyConfig) {
55
+ eleventyConfig.addPlugin(eleventyNavigationPlugin);
56
+ eleventyConfig.addPlugin(pluginTOC, {
57
+ tags: ['h2'],
58
+ });
59
+ }
60
+ addShortcode(eleventyConfig) {
61
+ eleventyConfig.addShortcode('year', getYear);
62
+ eleventyConfig.addShortcode('formatDate', formatDate);
63
+ eleventyConfig.addShortcode('parseRelease', parseRelease);
64
+ }
65
+ addFilter(eleventyConfig) {
66
+ eleventyConfig.addFilter('squash', squashCallback);
67
+ }
68
+ }
69
+ //# 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,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,0BAA0B,CAAC;AA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C,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAuB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;IAEO,kBAAkB,CAAC,cAA0B;QACpD,MAAM,UAAU,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,mBAAmB,CAAC;QAChE,cAAc,CAAC,kBAAkB,CAAC,EAAC,CAAC,UAAU,CAAC,EAAE,UAAU,EAAC,CAAC,CAAC;IAC/D,CAAC;IAEO,UAAU,CAAC,cAA0B;QAC5C,cAAc,CAAC,UAAU,CACxB,IAAI,EACJ,UAAU,EAAE,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAClC,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,cAA0B;QAC3C,cAAc,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QACnD,cAAc,CAAC,SAAS,CAAC,SAAS,EAAE;YACnC,IAAI,EAAE,CAAC,IAAI,CAAC;SACZ,CAAC,CAAC;IACJ,CAAC;IAEO,YAAY,CAAC,cAA0B;QAC9C,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7C,cAAc,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACtD,cAAc,CAAC,YAAY,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC;IAEO,SAAS,CAAC,cAA0B;QAC3C,cAAc,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC;CACD"}
@@ -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;CAiCtC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ import { createCommand } from 'commander';
2
+ import { Docula } from './docula.js';
3
+ import { reportError } from './tools/tools.js';
4
+ import logger from './logger.js';
5
+ export class Executable {
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ async parseCLI(process) {
8
+ const program = createCommand();
9
+ program.storeOptionsAsProperties(true);
10
+ program.command('build', { isDefault: true })
11
+ .description('Build the site')
12
+ .option('-c, --config <config>', 'Path of where the config file is located')
13
+ .action(async (options) => {
14
+ try {
15
+ logger.info('Building your documentation...');
16
+ const docula = new Docula(options);
17
+ await docula.build();
18
+ logger.info('Site was built successfully!');
19
+ }
20
+ catch (error) {
21
+ reportError(error);
22
+ }
23
+ });
24
+ program.command('init')
25
+ .description('Initialize the site')
26
+ .action(async (options) => {
27
+ try {
28
+ logger.info('Initializing Docula...');
29
+ const docula = new Docula(options);
30
+ await docula.init();
31
+ }
32
+ catch (error) {
33
+ reportError(error);
34
+ }
35
+ });
36
+ program.parse(process.argv);
37
+ }
38
+ }
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAoB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC,MAAM,OAAO,UAAU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ingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAU9B,QAAA,MAAM,MAAM,gBAaV,CAAC;AAEH,eAAe,MAAM,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,20 @@
1
+ import winston from 'winston';
2
+ const logFormat = winston.format.printf(({ level, message }) => {
3
+ if (level === 'error') {
4
+ return `[Docula] Error: ${message}`;
5
+ }
6
+ return `[Docula] ${message}`;
7
+ });
8
+ const logger = winston.createLogger({
9
+ level: 'info',
10
+ format: winston.format.json(),
11
+ transports: [
12
+ new winston.transports.Console({
13
+ format: winston.format.combine(logFormat, winston.format.colorize({
14
+ all: true,
15
+ })),
16
+ }),
17
+ ],
18
+ });
19
+ export default logger;
20
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAC,KAAK,EAAE,OAAO,EAAyB,EAAE,EAAE;IACpF,IAAI,KAAK,KAAK,OAAO,EAAE;QACtB,OAAO,mBAAmB,OAAO,EAAE,CAAC;KACpC;IAED,OAAO,YAAY,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;IAC7B,UAAU,EAAE;QACX,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAC7B,SAAS,EACT,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACvB,GAAG,EAAE,IAAI;aACT,CAAC,CACF;SACD,CAAC;KACF;CACD,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
2
+ import type { Config } from '../config.js';
3
+ export type GithubConfig = {
4
+ repo: string;
5
+ author: string;
6
+ };
7
+ export declare class GithubPlugin implements DoculaPlugin {
8
+ static schema: Schema;
9
+ readonly options: Options;
10
+ runtime: Runtime;
11
+ constructor(config: Config);
12
+ execute(): Promise<void>;
13
+ getReleases(): Promise<any>;
14
+ getContributors(): Promise<any>;
15
+ }
16
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/plugins/github.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,YAAa,YAAW,YAAY;IAChD,MAAM,CAAC,MAAM,EAAE,MAAM,CAOnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAOvB;IAEF,OAAO,EAAE,OAAO,CAAY;gBAEhB,MAAM,EAAE,MAAM;IAOpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAaxB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAe3B,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAcrC"}
@@ -0,0 +1,68 @@
1
+ import fs from 'fs-extra';
2
+ import axios from 'axios';
3
+ export class GithubPlugin {
4
+ constructor(config) {
5
+ this.options = {
6
+ api: 'https://api.github.com',
7
+ dataPath: '_data',
8
+ author: '',
9
+ repo: '',
10
+ outputFile: 'github.json',
11
+ sitePath: '',
12
+ };
13
+ this.runtime = 'before';
14
+ this.options.sitePath = config.originPath;
15
+ const { author, repo } = config.pluginConfig.github;
16
+ this.options.author = author;
17
+ this.options.repo = repo;
18
+ }
19
+ async execute() {
20
+ const data = {
21
+ releases: {},
22
+ contributors: {},
23
+ };
24
+ data.releases = await this.getReleases();
25
+ data.contributors = await this.getContributors();
26
+ const path = `${this.options.sitePath}/${this.options.dataPath}`;
27
+ const filePath = `${path}/${this.options.outputFile}`;
28
+ await fs.ensureDir(path);
29
+ await fs.writeFile(filePath, JSON.stringify(data, null, 2));
30
+ }
31
+ async getReleases() {
32
+ const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/releases`;
33
+ try {
34
+ const result = await axios.get(url);
35
+ return result.data;
36
+ }
37
+ catch (error) {
38
+ const typedError = error;
39
+ if (typedError.response?.status === 404) {
40
+ throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
41
+ }
42
+ throw error;
43
+ }
44
+ }
45
+ async getContributors() {
46
+ const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/contributors`;
47
+ try {
48
+ const result = await axios.get(url);
49
+ return result.data;
50
+ }
51
+ catch (error) {
52
+ const typedError = error;
53
+ if (typedError.response?.status === 404) {
54
+ throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
55
+ }
56
+ throw error;
57
+ }
58
+ }
59
+ }
60
+ GithubPlugin.schema = {
61
+ type: 'object',
62
+ required: ['repo', 'author'],
63
+ properties: {
64
+ repo: { type: 'string' },
65
+ author: { type: 'string' },
66
+ },
67
+ };
68
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/plugins/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,OAAO,YAAY;IAqBxB,YAAY,MA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,EAAC,IAAI,EAAE,QAAQ,EAAC;KACxB;CACD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type GithubConfig, GithubPlugin } from './github.js';
2
+ import { type NpmConfig, NpmPlugin } from './npm.js';
3
+ import { type RobotsConfig, RobotsPlugin } from './robots.js';
4
+ import { SitemapPlugin } from './sitemap.js';
5
+ import { PagefindPlugin } from './pagefind.js';
6
+ declare const plugins: {
7
+ github: typeof GithubPlugin;
8
+ npm: typeof NpmPlugin;
9
+ robots: typeof RobotsPlugin;
10
+ sitemap: typeof SitemapPlugin;
11
+ pagefind: typeof PagefindPlugin;
12
+ };
13
+ export type PluginConfig = GithubConfig | NpmConfig | RobotsConfig;
14
+ export type PluginInstance = GithubPlugin | NpmPlugin | RobotsPlugin | SitemapPlugin | PagefindPlugin;
15
+ export default plugins;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,KAAK,SAAS,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,KAAK,YAAY,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAE7C,QAAA,MAAM,OAAO;;;;;;CAMZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC;AAEnE,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,CAAC;AAEtG,eAAe,OAAO,CAAC"}