docula 0.3.2 → 0.3.3

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 (93) hide show
  1. package/dist/config.d.ts +21 -0
  2. package/dist/config.d.ts.map +1 -0
  3. package/dist/config.js +78 -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 +22 -0
  10. package/dist/docula.d.ts.map +1 -0
  11. package/dist/docula.js +192 -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/global-data.d.ts +3 -0
  18. package/dist/eleventy/global-data.d.ts.map +1 -0
  19. package/dist/eleventy/global-data.js +2 -0
  20. package/dist/eleventy/global-data.js.map +1 -0
  21. package/dist/eleventy/shortcodes.d.ts +4 -0
  22. package/dist/eleventy/shortcodes.d.ts.map +1 -0
  23. package/dist/eleventy/shortcodes.js +18 -0
  24. package/dist/eleventy/shortcodes.js.map +1 -0
  25. package/dist/eleventy.d.ts +24 -0
  26. package/dist/eleventy.d.ts.map +1 -0
  27. package/dist/eleventy.js +82 -0
  28. package/dist/eleventy.js.map +1 -0
  29. package/dist/index.d.ts +9 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +53 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/logger.d.ts +4 -0
  34. package/dist/logger.d.ts.map +1 -0
  35. package/dist/logger.js +20 -0
  36. package/dist/logger.js.map +1 -0
  37. package/dist/plugins/algolia.d.ts +21 -0
  38. package/dist/plugins/algolia.d.ts.map +1 -0
  39. package/dist/plugins/algolia.js +54 -0
  40. package/dist/plugins/algolia.js.map +1 -0
  41. package/dist/plugins/github.d.ts +16 -0
  42. package/dist/plugins/github.d.ts.map +1 -0
  43. package/dist/plugins/github.js +68 -0
  44. package/dist/plugins/github.js.map +1 -0
  45. package/dist/plugins/index.d.ts +18 -0
  46. package/dist/plugins/index.d.ts.map +1 -0
  47. package/dist/plugins/index.js +16 -0
  48. package/dist/plugins/index.js.map +1 -0
  49. package/dist/plugins/npm.d.ts +14 -0
  50. package/dist/plugins/npm.d.ts.map +1 -0
  51. package/dist/plugins/npm.js +36 -0
  52. package/dist/plugins/npm.js.map +1 -0
  53. package/dist/plugins/pagefind.d.ts +10 -0
  54. package/dist/plugins/pagefind.d.ts.map +1 -0
  55. package/dist/plugins/pagefind.js +22 -0
  56. package/dist/plugins/pagefind.js.map +1 -0
  57. package/dist/plugins/robots.d.ts +14 -0
  58. package/dist/plugins/robots.d.ts.map +1 -0
  59. package/dist/plugins/robots.js +34 -0
  60. package/dist/plugins/robots.js.map +1 -0
  61. package/dist/plugins/sitemap.d.ts +11 -0
  62. package/dist/plugins/sitemap.d.ts.map +1 -0
  63. package/dist/plugins/sitemap.js +27 -0
  64. package/dist/plugins/sitemap.js.map +1 -0
  65. package/dist/schemas.d.ts +21 -0
  66. package/dist/schemas.d.ts.map +1 -0
  67. package/dist/schemas.js +25 -0
  68. package/dist/schemas.js.map +1 -0
  69. package/dist/tools/__mocks__/inquirer-prompt.d.ts +20 -0
  70. package/dist/tools/__mocks__/inquirer-prompt.d.ts.map +1 -0
  71. package/dist/tools/__mocks__/inquirer-prompt.js +19 -0
  72. package/dist/tools/__mocks__/inquirer-prompt.js.map +1 -0
  73. package/dist/tools/__mocks__/path.d.ts +5 -0
  74. package/dist/tools/__mocks__/path.d.ts.map +1 -0
  75. package/dist/tools/__mocks__/path.js +7 -0
  76. package/dist/tools/__mocks__/path.js.map +1 -0
  77. package/dist/tools/inquirer-prompt.d.ts +11 -0
  78. package/dist/tools/inquirer-prompt.d.ts.map +1 -0
  79. package/dist/tools/inquirer-prompt.js +139 -0
  80. package/dist/tools/inquirer-prompt.js.map +1 -0
  81. package/dist/tools/path.d.ts +4 -0
  82. package/dist/tools/path.d.ts.map +1 -0
  83. package/dist/tools/path.js +6 -0
  84. package/dist/tools/path.js.map +1 -0
  85. package/dist/tools/tools.d.ts +3 -0
  86. package/dist/tools/tools.d.ts.map +1 -0
  87. package/dist/tools/tools.js +10 -0
  88. package/dist/tools/tools.js.map +1 -0
  89. package/dist/types/config.d.ts +8 -0
  90. package/dist/types/config.d.ts.map +1 -0
  91. package/dist/types/config.js +2 -0
  92. package/dist/types/config.js.map +1 -0
  93. package/package.json +1 -1
@@ -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,21 @@
1
+ import { type SearchClient, type SearchIndex } from 'algoliasearch';
2
+ import type { Config } from '../config.js';
3
+ import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
4
+ export type AlgoliaConfig = {
5
+ apiKey: string;
6
+ appId: string;
7
+ indexName: string;
8
+ };
9
+ type SearchOptions = {
10
+ index?: SearchIndex;
11
+ } & Options;
12
+ export declare class AlgoliaPlugin implements DoculaPlugin {
13
+ static schema: Schema;
14
+ readonly options: SearchOptions;
15
+ runtime: Runtime;
16
+ readonly client: SearchClient;
17
+ constructor(config: Config);
18
+ execute(): Promise<void>;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=algolia.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algolia.d.ts","sourceRoot":"","sources":["../../src/plugins/algolia.ts"],"names":[],"mappings":"AACA,OAAsB,EAAC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAC,MAAM,eAAe,CAAC;AAEjF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACpB,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB,GAAG,OAAO,CAAC;AAEZ,qBAAa,aAAc,YAAW,YAAY;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAQnB;IAEF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAK7B;IAEF,OAAO,EAAE,OAAO,CAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;gBAElB,MAAM,EAAE,MAAM;IAWpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAqB9B"}
@@ -0,0 +1,54 @@
1
+ import process from 'node:process';
2
+ import algoliasearch from 'algoliasearch';
3
+ import fs from 'fs-extra';
4
+ export class AlgoliaPlugin {
5
+ static schema = {
6
+ type: 'object',
7
+ required: ['apiKey', 'appId', 'indexName'],
8
+ properties: {
9
+ apiKey: { type: 'string' },
10
+ appId: { type: 'string' },
11
+ indexName: { type: 'string' },
12
+ },
13
+ };
14
+ options = {
15
+ apiKey: '',
16
+ appId: '',
17
+ indexName: '',
18
+ outputPath: '',
19
+ };
20
+ runtime = 'after';
21
+ client;
22
+ constructor(config) {
23
+ const { appId, apiKey, indexName } = config.pluginConfig.algolia;
24
+ this.options.outputPath = config.outputPath;
25
+ this.options.appId = appId;
26
+ this.options.apiKey = apiKey;
27
+ this.options.indexName = indexName;
28
+ // @ts-expect-error - algoliasearch is not callable
29
+ this.client = algoliasearch(this.options.appId, this.options.apiKey);
30
+ this.options.index = this.client.initIndex(this.options.indexName);
31
+ }
32
+ async execute() {
33
+ let jsonContent = [];
34
+ const jsonPath = `${process.cwd()}/${this.options.outputPath}/algolia.json`;
35
+ if (fs.existsSync(jsonPath)) {
36
+ const data = fs.readFileSync(jsonPath, 'utf8');
37
+ const content = JSON.parse(data);
38
+ jsonContent = content.filter(item => item.description.length);
39
+ }
40
+ try {
41
+ // @ts-expect-error - clearObjects
42
+ await this.options.index.clearObjects();
43
+ // @ts-expect-error - saveObjects
44
+ await this.options.index.saveObjects(jsonContent, {
45
+ // eslint-disable-next-line @typescript-eslint/naming-convention
46
+ autoGenerateObjectIDIfNotExist: true,
47
+ });
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Error while indexing to Algolia: ${error.message}`);
51
+ }
52
+ }
53
+ }
54
+ //# sourceMappingURL=algolia.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algolia.js","sourceRoot":"","sources":["../../src/plugins/algolia.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,aAAoD,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,MAAM,UAAU,CAAC;AAc1B,MAAM,OAAO,aAAa;IACzB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC;QAC1C,UAAU,EAAE;YACX,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;YACxB,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;YACvB,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAC3B;KACD,CAAC;IAEO,OAAO,GAAkB;QACjC,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,EAAE;KACd,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IAClB,MAAM,CAAe;IAE9B,YAAY,MAAc;QACzB,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAC,GAAG,MAAM,CAAC,YAAY,CAAC,OAAwB,CAAC;QAChF,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,K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;IACF,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
+ static schema = {
5
+ type: 'object',
6
+ required: ['repo', 'author'],
7
+ properties: {
8
+ repo: { type: 'string' },
9
+ author: { type: 'string' },
10
+ },
11
+ };
12
+ options = {
13
+ api: 'https://api.github.com',
14
+ dataPath: '_data',
15
+ author: '',
16
+ repo: '',
17
+ outputFile: 'github.json',
18
+ sitePath: '',
19
+ };
20
+ runtime = 'before';
21
+ constructor(config) {
22
+ this.options.sitePath = config.originPath;
23
+ const { author, repo } = config.pluginConfig.github;
24
+ this.options.author = author;
25
+ this.options.repo = repo;
26
+ }
27
+ async execute() {
28
+ const data = {
29
+ releases: {},
30
+ contributors: {},
31
+ };
32
+ data.releases = await this.getReleases();
33
+ data.contributors = await this.getContributors();
34
+ const path = `${this.options.sitePath}/${this.options.dataPath}`;
35
+ const filePath = `${path}/${this.options.outputFile}`;
36
+ await fs.ensureDir(path);
37
+ await fs.writeFile(filePath, JSON.stringify(data, null, 2));
38
+ }
39
+ async getReleases() {
40
+ const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/releases`;
41
+ try {
42
+ const result = await axios.get(url);
43
+ return result.data;
44
+ }
45
+ catch (error) {
46
+ const typedError = error;
47
+ if (typedError.response?.status === 404) {
48
+ throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
49
+ }
50
+ throw error;
51
+ }
52
+ }
53
+ async getContributors() {
54
+ const url = `${this.options.api}/repos/${this.options.author}/${this.options.repo}/contributors`;
55
+ try {
56
+ const result = await axios.get(url);
57
+ return result.data;
58
+ }
59
+ catch (error) {
60
+ const typedError = error;
61
+ if (typedError.response?.status === 404) {
62
+ throw new Error(`Repository ${this.options.author}/${this.options.repo} not found.`);
63
+ }
64
+ throw error;
65
+ }
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;IACxB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC5B,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ithubPlugin } 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
+ import { type AlgoliaConfig, AlgoliaPlugin } from './algolia.js';
7
+ declare const plugins: {
8
+ github: typeof GithubPlugin;
9
+ npm: typeof NpmPlugin;
10
+ robots: typeof RobotsPlugin;
11
+ sitemap: typeof SitemapPlugin;
12
+ pagefind: typeof PagefindPlugin;
13
+ algolia: typeof AlgoliaPlugin;
14
+ };
15
+ export type PluginConfig = GithubConfig | NpmConfig | RobotsConfig | AlgoliaConfig;
16
+ export type PluginInstance = GithubPlugin | NpmPlugin | RobotsPlugin | SitemapPlugin | PagefindPlugin | AlgoliaPlugin;
17
+ export default plugins;
18
+ //# 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;AAC7C,OAAO,EAAC,KAAK,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAE/D,QAAA,MAAM,OAAO;;;;;;;CAOZ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC;AAEnF,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC;AAEtH,eAAe,OAAO,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { GithubPlugin } from './github.js';
2
+ import { NpmPlugin } from './npm.js';
3
+ import { RobotsPlugin } from './robots.js';
4
+ import { SitemapPlugin } from './sitemap.js';
5
+ import { PagefindPlugin } from './pagefind.js';
6
+ import { AlgoliaPlugin } from './algolia.js';
7
+ const plugins = {
8
+ github: GithubPlugin,
9
+ npm: NpmPlugin,
10
+ robots: RobotsPlugin,
11
+ sitemap: SitemapPlugin,
12
+ pagefind: PagefindPlugin,
13
+ algolia: AlgoliaPlugin,
14
+ };
15
+ export default plugins;
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAiB,SAAS,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAoB,YAAY,EAAC,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAqB,aAAa,EAAC,MAAM,cAAc,CAAC;AAE/D,MAAM,OAAO,GAAG;IACf,MAAM,EAAE,YAAY;IACpB,GAAG,EAAE,SAAS;IACd,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;IACxB,OAAO,EAAE,aAAa;CACtB,CAAC;AAMF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
2
+ import type { Config } from '../config.js';
3
+ export type NpmConfig = {
4
+ moduleName: string;
5
+ };
6
+ export declare class NpmPlugin implements DoculaPlugin {
7
+ static schema: Schema;
8
+ readonly options: Options;
9
+ runtime: Runtime;
10
+ constructor(config: Config);
11
+ execute(): Promise<void>;
12
+ getMonthlyDownloads(): Promise<any>;
13
+ }
14
+ //# sourceMappingURL=npm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/plugins/npm.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,SAAS,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,qBAAa,SAAU,YAAW,YAAY;IAC7C,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAKvB;IAEF,OAAO,EAAE,OAAO,CAAY;gBAEhB,MAAM,EAAE,MAAM;IAMpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQxB,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;CAKzC"}
@@ -0,0 +1,36 @@
1
+ import axios from 'axios';
2
+ import fs from 'fs-extra';
3
+ export class NpmPlugin {
4
+ static schema = {
5
+ type: 'object',
6
+ required: ['moduleName'],
7
+ properties: {
8
+ moduleName: { type: 'string' },
9
+ },
10
+ };
11
+ options = {
12
+ dataPath: '_data',
13
+ moduleName: '',
14
+ outputFile: 'npm.json',
15
+ sitePath: '',
16
+ };
17
+ runtime = 'before';
18
+ constructor(config) {
19
+ this.options.sitePath = config.originPath;
20
+ const { moduleName } = config.pluginConfig.npm;
21
+ this.options.moduleName = moduleName;
22
+ }
23
+ async execute() {
24
+ const data = await this.getMonthlyDownloads();
25
+ const path = `${this.options.sitePath}/${this.options.dataPath}`;
26
+ const filePath = `${this.options.sitePath}/${this.options.dataPath}/${this.options.outputFile}`;
27
+ await fs.ensureDir(path);
28
+ await fs.writeFile(filePath, JSON.stringify(data, null, 2));
29
+ }
30
+ async getMonthlyDownloads() {
31
+ const url = `https://api.npmjs.org/downloads/point/last-month/${this.options.moduleName}`;
32
+ const result = await axios.get(url);
33
+ return result.data;
34
+ }
35
+ }
36
+ //# sourceMappingURL=npm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm.js","sourceRoot":"","sources":["../../src/plugins/npm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;AAQ1B,MAAM,OAAO,SAAS;IACrB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,YAAY,CAAC;QACxB,UAAU,EAAE;YACX,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAC5B;KACD,CAAC;IAEO,OAAO,GAAY;QAC3B,QAAQ,EAAE,OAAO;QACjB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,UAAU;QACtB,QAAQ,EAAE,EAAE;KACZ,CAAC;IAEF,OAAO,GAAY,QAAQ,CAAC;IAE5B,YAAY,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC;QAC1C,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,CAAC,YAAY,CAAC,GAAgB,CAAC;QAC1D,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjE,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAChG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,mBAAmB;QACxB,MAAM,GAAG,GAAG,oDAAoD,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC1F,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC;IACpB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
2
+ import type { Config } from '../config.js';
3
+ export declare class PagefindPlugin implements DoculaPlugin {
4
+ static schema: Schema;
5
+ readonly options: Options;
6
+ runtime: Runtime;
7
+ constructor(config: Config);
8
+ execute(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=pagefind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagefind.d.ts","sourceRoot":"","sources":["../../src/plugins/pagefind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,qBAAa,cAAe,YAAW,YAAY;IAClD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAE3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAEvB;IAEF,OAAO,EAAE,OAAO,CAAW;gBAEf,MAAM,EAAE,MAAM;IAIpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAW9B"}
@@ -0,0 +1,22 @@
1
+ import { exec } from 'node:child_process';
2
+ export class PagefindPlugin {
3
+ static schema = {};
4
+ options = {
5
+ outputPath: '',
6
+ };
7
+ runtime = 'after';
8
+ constructor(config) {
9
+ this.options.outputPath = config.outputPath;
10
+ }
11
+ async execute() {
12
+ await new Promise((resolve, reject) => {
13
+ exec(`npx pagefind --source ${this.options.outputPath}`, (error, stdout) => {
14
+ if (error) {
15
+ reject(error);
16
+ }
17
+ resolve(stdout);
18
+ });
19
+ });
20
+ }
21
+ }
22
+ //# sourceMappingURL=pagefind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagefind.js","sourceRoot":"","sources":["../../src/plugins/pagefind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AAIxC,MAAM,OAAO,cAAc;IAC1B,MAAM,CAAC,MAAM,GAAW,EAAE,CAAC;IAElB,OAAO,GAAY;QAC3B,UAAU,EAAE,EAAE;KACd,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IAE3B,YAAY,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,yBAAyB,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,KAAU,EAAE,MAAW,EAAE,EAAE;gBACpF,IAAI,KAAK,EAAE;oBACV,MAAM,CAAC,KAAK,CAAC,CAAC;iBACd;gBAED,OAAO,CAAC,MAAM,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { DoculaPlugin, Options, Runtime, Schema } from '../docula-plugin.js';
2
+ import type { Config } from '../config.js';
3
+ export type RobotsConfig = {
4
+ allowedUrl: string;
5
+ disallowedUrl: string;
6
+ };
7
+ export declare class RobotsPlugin implements DoculaPlugin {
8
+ static schema: Schema;
9
+ readonly options: Options;
10
+ runtime: Runtime;
11
+ constructor(config: Config);
12
+ execute(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=robots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"robots.d.ts","sourceRoot":"","sources":["../../src/plugins/robots.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,qBAAa,YAAa,YAAW,YAAY;IAChD,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnB;IAEF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAGvB;IAEF,OAAO,EAAE,OAAO,CAAW;gBAEf,MAAM,EAAE,MAAM;IAYpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAS9B"}
@@ -0,0 +1,34 @@
1
+ import fs from 'fs-extra';
2
+ export class RobotsPlugin {
3
+ static schema = {
4
+ type: 'object',
5
+ properties: {
6
+ allowedUrl: { type: 'string' },
7
+ disallowedUrl: { type: 'string' },
8
+ },
9
+ };
10
+ options = {
11
+ sitemapPath: 'sitemap.xml',
12
+ outputFile: 'robots.txt',
13
+ };
14
+ runtime = 'after';
15
+ constructor(config) {
16
+ this.options.outputPath = config.outputPath;
17
+ const { allowedUrl, disallowedUrl } = config.pluginConfig.robots || {};
18
+ if (allowedUrl) {
19
+ this.options.allowedUrl = allowedUrl;
20
+ }
21
+ if (disallowedUrl) {
22
+ this.options.disallowedUrl = disallowedUrl;
23
+ }
24
+ }
25
+ async execute() {
26
+ const isAllowed = this.options.allowedUrl ? `Allow: ${this.options.allowedUrl}` : '';
27
+ const isDisallowed = this.options.disallowedUrl ? `Disallow: ${this.options.disallowedUrl}` : '';
28
+ const data = `User-agent: * \n${isAllowed} \n${isDisallowed} \nSitemap: ${this.options.sitemapPath}`;
29
+ const filePath = `${this.options.outputPath}/${this.options.outputFile}`;
30
+ await fs.ensureDir(this.options.outputPath);
31
+ await fs.writeFile(filePath, data);
32
+ }
33
+ }
34
+ //# sourceMappingURL=robots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"robots.js","sourceRoot":"","sources":["../../src/plugins/robots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAS1B,MAAM,OAAO,YAAY;IACxB,MAAM,CAAC,MAAM,GAAW;QACvB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACX,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;YAC5B,aAAa,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAC/B;KACD,CAAC;IAEO,OAAO,GAAY;QAC3B,WAAW,EAAE,aAAa;QAC1B,UAAU,EAAE,YAAY;KACxB,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IAE3B,YAAY,MAAc;QACzB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAC5C,MAAM,EAAC,UAAU,EAAE,aAAa,EAAC,GAAG,MAAM,CAAC,YAAY,CAAC,MAAiC,IAAI,EAAE,CAAC;QAChG,IAAI,UAAU,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACrC;QAED,IAAI,aAAa,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;SAC3C;IACF,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrF,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEjG,MAAM,IAAI,GAAG,mBAAmB,SAAS,MAAM,YAAY,eAAe,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACrG,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACzE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { DoculaPlugin, Options, Schema, Runtime } from '../docula-plugin.js';
2
+ import type { Config } from '../config.js';
3
+ export declare class SitemapPlugin implements DoculaPlugin {
4
+ static schema: Schema;
5
+ readonly options: Options;
6
+ runtime: Runtime;
7
+ private readonly eleventy;
8
+ constructor(config: Config);
9
+ execute(): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=sitemap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/plugins/sitemap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AAGzC,qBAAa,aAAc,YAAW,YAAY;IACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAE3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAIvB;IAEF,OAAO,EAAE,OAAO,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;gBAExB,MAAM,EAAE,MAAM;IAQpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAS9B"}
@@ -0,0 +1,27 @@
1
+ import fs from 'fs-extra';
2
+ import { Eleventy } from '../eleventy.js';
3
+ export class SitemapPlugin {
4
+ static schema = {};
5
+ options = {
6
+ siteUrl: '',
7
+ outputFile: 'sitemap.xml',
8
+ outputPath: '',
9
+ };
10
+ runtime = 'after';
11
+ eleventy;
12
+ constructor(config) {
13
+ this.eleventy = new Eleventy(config);
14
+ this.options.outputPath = config.outputPath;
15
+ const { siteUrl } = config;
16
+ this.options.siteUrl = siteUrl;
17
+ }
18
+ async execute() {
19
+ const jsonContent = await this.eleventy.toJSON();
20
+ const content = `<?xml version="1.0" encoding="utf-8"?>
21
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
22
+ ${jsonContent.map(item => (`<url><loc>${this.options.siteUrl}${item.url}</loc></url>`)).join('')}
23
+ </urlset>`;
24
+ fs.writeFileSync(`${this.options.outputPath}/${this.options.outputFile}`, content);
25
+ }
26
+ }
27
+ //# sourceMappingURL=sitemap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/plugins/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,MAAM,OAAO,aAAa;IACzB,MAAM,CAAC,MAAM,GAAW,EAAE,CAAC;IAElB,OAAO,GAAY;QAC3B,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,EAAE;KACd,CAAC;IAEF,OAAO,GAAY,OAAO,CAAC;IACV,QAAQ,CAAW;IAEpC,YAAY,MAAc;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QAC5C,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,CAAC;QAEzB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO;QACZ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG;;QAEV,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;cACxF,CAAC;QAEb,EAAE,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type Plugins } from './types/config.js';
2
+ type Property = Record<string, string | string[]>;
3
+ type PluginsType = {
4
+ type: string;
5
+ items: {
6
+ type: string;
7
+ enum: Plugins;
8
+ };
9
+ };
10
+ export type ConfigSchema = {
11
+ type: 'object';
12
+ additionalProperties: boolean;
13
+ properties: {
14
+ [key: string]: Property | PluginsType;
15
+ plugins: PluginsType;
16
+ };
17
+ required: string[];
18
+ };
19
+ export declare const jsonConfigSchema: ConfigSchema;
20
+ export {};
21
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE/C,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAElD,KAAK,WAAW,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,CAAC;KACd,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,oBAAoB,EAAE,OAAO,CAAC;IAC9B,UAAU,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC;QACtC,OAAO,EAAE,WAAW,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAsB9B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import DoculaPlugins from './plugins/index.js';
2
+ export const jsonConfigSchema = {
3
+ type: 'object',
4
+ additionalProperties: false,
5
+ properties: {
6
+ originPath: { type: 'string' },
7
+ outputPath: { type: 'string' },
8
+ dataPath: { type: 'string' },
9
+ templatePath: { type: 'string' },
10
+ searchEngine: { type: 'string', enum: ['algolia', 'pagefind'] },
11
+ plugins: {
12
+ type: 'array',
13
+ items: {
14
+ type: 'string',
15
+ enum: Object.keys(DoculaPlugins),
16
+ },
17
+ },
18
+ imagesPath: { type: 'string' },
19
+ assetsPath: { type: 'string' },
20
+ siteUrl: { type: 'string' },
21
+ siteType: { type: 'string', enum: ['landing', 'multi page'] },
22
+ },
23
+ required: [],
24
+ };
25
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAuB/C,MAAM,CAAC,MAAM,gBAAgB,GAAiB;IAC7C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACX,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,QAAQ,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC1B,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC9B,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAC;QAC7D,OAAO,EAAE;YACR,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAY;aAC3C;SACD;QACD,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,UAAU,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QAC5B,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;QACzB,QAAQ,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC,EAAC;KAC3D;IACD,QAAQ,EAAE,EAAE;CACZ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /// <reference types="jest" />
2
+ export declare const getGithubInfo: jest.Mock<{
3
+ author: string;
4
+ repo: string;
5
+ }, [], any>;
6
+ export declare const validateUrl: jest.Mock<boolean, [], any>;
7
+ export declare const getSiteUrl: jest.Mock<string, [], any>;
8
+ export declare const getUserPlugins: jest.Mock<{
9
+ plugins: string[];
10
+ }, [], any>;
11
+ export declare const setPlugins: jest.Mock<{
12
+ siteUrl: string;
13
+ searchEngine: string;
14
+ plugins: string[];
15
+ github: {
16
+ author: string;
17
+ repo: string;
18
+ };
19
+ }, [], any>;
20
+ //# sourceMappingURL=inquirer-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inquirer-prompt.d.ts","sourceRoot":"","sources":["../../../src/tools/__mocks__/inquirer-prompt.ts"],"names":[],"mappings":";AAAA,eAAO,MAAM,aAAa;;;WAGvB,CAAC;AAEJ,eAAO,MAAM,WAAW,6BAAsB,CAAC;AAE/C,eAAO,MAAM,UAAU,4BAA2C,CAAC;AAEnE,eAAO,MAAM,cAAc;;WAExB,CAAC;AAEJ,eAAO,MAAM,UAAU;;;;;;;;WAQpB,CAAC"}
@@ -0,0 +1,19 @@
1
+ export const getGithubInfo = jest.fn(() => ({
2
+ author: 'jaredwray',
3
+ repo: 'docula',
4
+ }));
5
+ export const validateUrl = jest.fn(() => true);
6
+ export const getSiteUrl = jest.fn(() => 'https://www.example.com');
7
+ export const getUserPlugins = jest.fn(() => ({
8
+ plugins: ['robots.txt', 'npm'],
9
+ }));
10
+ export const setPlugins = jest.fn(() => ({
11
+ siteUrl: 'https://www.example.com',
12
+ searchEngine: 'pagefind',
13
+ plugins: ['github'],
14
+ github: {
15
+ author: 'jaredwray',
16
+ repo: 'docula',
17
+ },
18
+ }));
19
+ //# sourceMappingURL=inquirer-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inquirer-prompt.js","sourceRoot":"","sources":["../../../src/tools/__mocks__/inquirer-prompt.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,EAAE,WAAW;IACnB,IAAI,EAAE,QAAQ;CACd,CAAC,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC;CAC9B,CAAC,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACxC,OAAO,EAAE,yBAAyB;IAClC,YAAY,EAAE,UAAU;IACxB,OAAO,EAAE,CAAC,QAAQ,CAAC;IACnB,MAAM,EAAE;QACP,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,QAAQ;KACd;CACD,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="jest" />
2
+ export declare const getFileName: jest.Mock<string, [], any>;
3
+ export declare const getConfigPath: jest.Mock<string, [], any>;
4
+ export declare const getSitePath: jest.Mock<string, [], any>;
5
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/tools/__mocks__/path.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,WAAW,4BAA2B,CAAC;AAEpD,eAAO,MAAM,aAAa,4BAA+D,CAAC;AAE1F,eAAO,MAAM,WAAW,4BAAmD,CAAC"}
@@ -0,0 +1,7 @@
1
+ // eslint-disable-next-line unicorn/prefer-module
2
+ export const getFileName = jest.fn(() => __dirname);
3
+ // eslint-disable-next-line n/prefer-global/process
4
+ export const getConfigPath = jest.fn(() => `${process.cwd()}/test/data/site/config.json`);
5
+ // eslint-disable-next-line n/prefer-global/process
6
+ export const getSitePath = jest.fn(() => `${process.cwd()}/test/data/site`);
7
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/tools/__mocks__/path.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACpD,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,6BAA6B,CAAC,CAAC;AAC1F,mDAAmD;AACnD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const getGithubInfo: () => Promise<Record<string, string>>;
2
+ export declare const validateUrl: (value: string) => boolean | string;
3
+ export declare const getSiteUrl: () => Promise<string>;
4
+ export declare const getUserPlugins: () => Promise<string[]>;
5
+ export declare const getSearchEngine: () => Promise<'algolia' | 'pagefind'>;
6
+ export declare const getAlgoliaInfo: () => Promise<Record<string, string>>;
7
+ export declare const getSiteType: () => Promise<'landing' | 'multipage'>;
8
+ export declare const buildLandingPage: () => Promise<Record<string, unknown>>;
9
+ export declare const buildMultipageSite: () => Promise<Record<string, unknown>>;
10
+ export declare const setPlugins: () => Promise<Record<string, unknown>>;
11
+ //# sourceMappingURL=inquirer-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inquirer-prompt.d.ts","sourceRoot":"","sources":["../../src/tools/inquirer-prompt.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,QAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC,CAUnE,CAAC;AAEH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,OAAO,GAAG,MAOrD,CAAC;AAEF,eAAO,MAAM,UAAU,QAAa,QAAQ,MAAM,CAUjD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,MAAM,EAAE,CAqBvD,CAAC;AAEF,eAAO,MAAM,eAAe,QAAa,QAAQ,SAAS,GAAG,UAAU,CActE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC,CAgBpE,CAAC;AAEH,eAAO,MAAM,WAAW,QAAa,QAAQ,SAAS,GAAG,WAAW,CAcnE,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAa,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,CAcxE,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAa,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,CAsB1E,CAAC;AAEF,eAAO,MAAM,UAAU,QAAa,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,CAKlE,CAAC"}