@griddo/cx 10.6.5 → 10.6.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.
@@ -85,6 +85,7 @@ declare function pause(title: string): Promise<void> | undefined;
85
85
  * retries.
86
86
  *
87
87
  * @async
88
+ * @param name - The name of the life cycle.
88
89
  * @param options - The arguments object.
89
90
  * @param options.steps - An array of functions to execute.
90
91
  * @param options.delay - Delay between steps functions.
@@ -98,4 +99,12 @@ declare function doLifeCycle(name: LifeCyclesNames, options: {
98
99
  }): Promise<void>;
99
100
  declare function isVersionGreaterThan(versionA: string, versionB: string): boolean;
100
101
  declare function isVersionLowerThan(versionA: string, versionB: string): boolean;
101
- export { delay, doLifeCycle, exporterCleanDisposableDirectories, exporterCreateInitialDirectories, getConfig, instanceRootDir, isTruthy, isVersionGreaterThan, isVersionLowerThan, measureExecutionTime, pause, removeProperties, sanitizeAPICacheDir, siteList, walk, };
102
+ /**
103
+ * Creates additional files after the render: sitemaps, robots and a report of
104
+ * the finished render.
105
+ *
106
+ * @async
107
+ * @param domain
108
+ */
109
+ declare function createRenderMetadata(domain: string): Promise<void>;
110
+ export { createRenderMetadata, delay, doLifeCycle, exporterCleanDisposableDirectories, exporterCreateInitialDirectories, getConfig, instanceRootDir, isTruthy, isVersionGreaterThan, isVersionLowerThan, measureExecutionTime, pause, removeProperties, sanitizeAPICacheDir, siteList, walk, };
@@ -24,18 +24,6 @@ declare function createDirsSync(dirs: Array<string>, options?: MakeDirectoryOpti
24
24
  declare function copyDirsSync(src: string, dst: string, dirs: Array<string>, options?: {
25
25
  withBackup: boolean;
26
26
  }): void;
27
- /**
28
- * Move artifacts between CX valid directories.
29
- *
30
- * @param src - Source directory.
31
- * @param dst - Destination directory.
32
- * @param dirs - Directories to move.
33
- * @param options - Options.
34
- */
35
- declare function moveDirsSync(src: string, dst: string, dirs: Array<string>, options?: {
36
- withBackup?: boolean;
37
- override?: boolean;
38
- }): void;
39
27
  /**
40
28
  * Remove directories from `basePath` directory.
41
29
  *
@@ -49,4 +37,41 @@ declare function removeVirtualPagesFromStore(): Promise<void>;
49
37
  * @param initialFolder - The initial folder to start the searching...
50
38
  */
51
39
  declare function clearSitemapsFromDirs(initialFolder: string): void;
52
- export { clearEmptyDirs, clearSitemapsFromDirs, copyDirsSync, createDirsSync, moveDirsSync, removeDirsSync, removeVirtualPagesFromStore, };
40
+ /**
41
+ * Removes multiple artifact directories.
42
+ *
43
+ * @param artifacts - An array of artifact directory paths.
44
+ */
45
+ declare function removeArtifacts(artifacts: Array<string>): void;
46
+ /**
47
+ * Creates multiple directories.
48
+ *
49
+ * @param dirs - An array of directory paths.
50
+ * @param options - Same option as `fs.mkdirSync()`
51
+ */
52
+ declare function createArtifacts(dirs: Array<string>, options?: MakeDirectoryOptions): void;
53
+ /**
54
+ * Copy multiple directories with backup option.
55
+ *
56
+ * @param src - Source directory.
57
+ * @param dst - Destination directory.
58
+ * @param dirs - Directories to copy.
59
+ * @param options.withBackup - Create a previous backup before copy.
60
+ */
61
+ declare function copyArtifacts(src: string, dst: string, dirs: Array<string>, options?: {
62
+ withBackup: boolean;
63
+ }): void;
64
+ declare function renameArtifact(src: string, dst: string): void;
65
+ /**
66
+ * Move artifacts between cx-paths
67
+ *
68
+ * @param src - Source directory.
69
+ * @param dst - Destination directory.
70
+ * @param dirs - Directories to move.
71
+ * @param options - Options.
72
+ */
73
+ declare function moveArtifacts(src: string, dst: string, dirs: Array<string>, options?: {
74
+ withBackup?: boolean;
75
+ override?: boolean;
76
+ }): void;
77
+ export { clearEmptyDirs, clearSitemapsFromDirs, copyArtifacts, copyDirsSync, createArtifacts, createDirsSync, moveArtifacts, removeArtifacts, removeDirsSync, removeVirtualPagesFromStore, renameArtifact, };
@@ -3,9 +3,9 @@
3
3
  * This file is used to track later if node_modules/@griddo/cx was cleaned by a
4
4
  * npm install from a deploy.
5
5
  */
6
- declare function createSentinelDomainRenderFile(): void;
7
- declare function deleteSentinelFile(): void;
6
+ declare function createSentinelRenderFile(): void;
7
+ declare function deleteSentinelRenderFile(): void;
8
8
  declare function isValidRenderProcessOrThrow(): void;
9
9
  declare function initRender(): void;
10
10
  declare function finishRender(): undefined;
11
- export { finishRender, initRender, isValidRenderProcessOrThrow, createSentinelDomainRenderFile, deleteSentinelFile, };
11
+ export { finishRender, initRender, isValidRenderProcessOrThrow, createSentinelRenderFile, deleteSentinelRenderFile, };
@@ -27,7 +27,6 @@ declare function getBuildPagesFromStore<PageType extends GriddoPageObject>(args?
27
27
  declare function getBuildPagesPath(): string[];
28
28
  /**
29
29
  * Get the build metadata from the Store.
30
- * TODO: Refactorizar para leer un solo archivo: __metadata__.json
31
30
  */
32
31
  declare function getBuildMetadata(): Promise<BuildMetaData>;
33
32
  /**
package/cx.config.d.ts CHANGED
@@ -3,18 +3,3 @@ import { CXConfig } from "./exporter/types/global";
3
3
  declare const config: CXConfig;
4
4
 
5
5
  export default config;
6
-
7
- declare const CXDir: {
8
- EXPORTS: "__exports";
9
- CACHE: "__caches";
10
- CX: "__cx";
11
- SSG: "__ssg";
12
- COMPONENTS: "__components";
13
- ROOT: "__root";
14
- EXPORT_DIST: "__exports_dist";
15
- CX_DIST: "__cx_dist";
16
- };
17
-
18
- export type Artifact = "store" | "apiCache" | "dist" | "assets";
19
-
20
- export { CXDir };
package/cx.config.js CHANGED
@@ -20,16 +20,6 @@ const { version: griddoVersion } = require(
20
20
  const config = {
21
21
  proDomain: "pro-",
22
22
  griddoVersion,
23
- CXDir: {
24
- EXPORTS: "__exports",
25
- CACHE: "__caches",
26
- CX: "__cx",
27
- SSG: "__ssg",
28
- COMPONENTS: "__components",
29
- ROOT: "__root",
30
- EXPORTS_DIST: "__exports_dist",
31
- CX_DIST: "__cx_dist",
32
- },
33
23
  paths: (domain) => ({
34
24
  __caches: path.join(CX_CACHE_DIR, domain || ""),
35
25
  __components: COMPONENTS_DIR,
@@ -43,5 +33,3 @@ const config = {
43
33
  };
44
34
 
45
35
  export default config;
46
- const CXDir = config.CXDir;
47
- export { CXDir };
@@ -1,56 +1,61 @@
1
- import fs from "node:fs";
2
1
  import path from "node:path";
3
2
 
4
- /* prettier-ignore */ import { getGatsbyAssetPrefixWithDomain, legacy__createDistFromGatsbyPublic, runGatsbyBuildCommand, } from "./utils";
5
- /* prettier-ignore */ import { RobotsService } from "../../services/robots";
6
- /* prettier-ignore */ import { doLifeCycle, getConfig, pause } from "../../utils/core-utils";
3
+ /* prettier-ignore */ import { getGatsbyAssetPrefixWithDomain, legacy__createDistFromGatsbyPublic, runGatsbyBuildCommand } from "./utils";
4
+ /* prettier-ignore */ import { getArtifacts } from "../../artifacts";
5
+ /* prettier-ignore */ import { createRenderMetadata, doLifeCycle, getConfig } from "../../utils/core-utils";
7
6
  /* prettier-ignore */ import { createBuildData } from "../../utils/create-build-data";
8
- /* prettier-ignore */ import { clearEmptyDirs, copyDirsSync, createDirsSync, moveDirsSync, removeDirsSync, removeVirtualPagesFromStore, } from "../../utils/folders";
9
- /* prettier-ignore */ import { boxLog, printExporterLogo } from "../../utils/loggin";
10
- /* prettier-ignore */ import { createSentinelDomainRenderFile, isValidRenderProcessOrThrow, } from "../../utils/render";
11
- /* prettier-ignore */ import { generateBuildReport, generateSitemaps } from "../../utils/sites";
7
+ /* prettier-ignore */ import { clearEmptyDirs, copyArtifacts, createArtifacts, moveArtifacts, removeArtifacts, removeVirtualPagesFromStore, renameArtifact } from "../../utils/folders";
8
+ /* prettier-ignore */ import { infoLog, printExporterLogo } from "../../utils/loggin";
9
+ /* prettier-ignore */ import { createSentinelRenderFile, deleteSentinelRenderFile, isValidRenderProcessOrThrow } from "../../utils/render";
12
10
 
13
11
  const config = getConfig();
14
12
 
15
13
  async function renderDomain(domain: string) {
16
- boxLog(`Initializing render for the domain ${domain}`, "", 1, 0);
17
-
18
- createSentinelDomainRenderFile();
19
-
20
- const { __ssg, __exports, __caches, __cx, __components } =
21
- config.paths(domain);
22
-
23
- // This variables are for both, create the dist directory from public
24
- // and pass to the gatsby-build command via spawnSync.
14
+ infoLog(`Initializing render for the domain ${domain}`);
15
+
16
+ createSentinelRenderFile();
17
+
18
+ const cxPaths = config.paths(domain);
19
+ const domainArtifacts = getArtifacts("gatsby", { cxPaths });
20
+ const { __ssg, __exports, __caches, __cx, __components } = cxPaths;
21
+
22
+ const arts = {
23
+ ...domainArtifacts,
24
+ all: {
25
+ disposables: [
26
+ ...domainArtifacts.cx.disposables,
27
+ ...domainArtifacts.ssg.disposables,
28
+ ],
29
+ initials: [
30
+ ...domainArtifacts.cx.initials,
31
+ ...domainArtifacts.ssg.initials,
32
+ ],
33
+ },
34
+ };
35
+
36
+ // This variables are for:
37
+ // - Create the dist directory from public in the Relocation LifeCycle.
38
+ // - Pass to the gatsby-build command via spawnSync in the SSG LifeCycle.
25
39
  const assetPrefix = getGatsbyAssetPrefixWithDomain(domain);
26
40
  const needsAssetPrefix = !!assetPrefix && assetPrefix !== "";
27
41
 
42
+ // LifeCycles
43
+
28
44
  await doLifeCycle("Clean", {
29
- steps: [
30
- () => removeDirsSync(__cx, ["store", "apiCache", "dist"]),
31
- () => removeDirsSync(__ssg, ["dist", "public", "static", ".cache"]),
32
- ],
45
+ steps: [() => removeArtifacts(arts.all.disposables)],
33
46
  });
34
47
 
35
48
  await doLifeCycle("Prepare", {
36
- steps: [
37
- () => createDirsSync([__exports]),
38
- () => createDirsSync([__caches]),
39
- ],
49
+ steps: [() => createArtifacts(arts.all.initials)],
40
50
  });
41
51
 
42
52
  await doLifeCycle("Restore", {
43
53
  steps: [
44
- () => copyDirsSync(__components, __ssg, ["static"]),
45
- () => copyDirsSync(__exports, __cx, ["assets"]),
46
- () => copyDirsSync(__exports, __ssg, ["dist"]),
47
- () => {
48
- if (fs.existsSync(path.join(__ssg, "dist"))) {
49
- fs.renameSync(path.join(__ssg, "dist"), path.join(__ssg, "public"));
50
- }
51
- },
52
- () => moveDirsSync(__caches, __cx, ["apiCache", "store"]),
53
- () => moveDirsSync(__caches, __ssg, [".cache"]),
54
+ () => copyArtifacts(__components, __ssg, ["static"]),
55
+ () => copyArtifacts(__exports, __cx, arts.cx.archivables),
56
+ () => renameArtifact(path.join(__cx, "dist"), path.join(__ssg, "public")),
57
+ () => moveArtifacts(__caches, __cx, arts.cx.cacheables),
58
+ () => moveArtifacts(__caches, __ssg, arts.ssg.cacheables),
54
59
  ],
55
60
  });
56
61
 
@@ -67,12 +72,7 @@ async function renderDomain(domain: string) {
67
72
  });
68
73
 
69
74
  await doLifeCycle("Meta", {
70
- steps: [
71
- () => generateBuildReport(),
72
- () => RobotsService.writeFiles(domain),
73
- () => generateSitemaps(),
74
- () => pause("Meta LifeCycle"),
75
- ],
75
+ steps: [() => createRenderMetadata(domain)],
76
76
  });
77
77
 
78
78
  await doLifeCycle("Archive", {
@@ -80,25 +80,28 @@ async function renderDomain(domain: string) {
80
80
  () => removeVirtualPagesFromStore(),
81
81
  () => clearEmptyDirs(path.join(__cx, "dist")),
82
82
  () =>
83
- moveDirsSync(__cx, __exports, ["dist", "assets"], {
83
+ moveArtifacts(__cx, __exports, arts.cx.archivables, {
84
84
  withBackup: true,
85
85
  }),
86
- () => moveDirsSync(__cx, __caches, ["apiCache", "store"]),
87
- () => moveDirsSync(__ssg, __caches, [".cache"]),
86
+ () => moveArtifacts(__cx, __caches, arts.cx.cacheables),
87
+ () => moveArtifacts(__ssg, __caches, arts.ssg.cacheables),
88
88
  ],
89
89
  });
90
90
 
91
- await doLifeCycle("Clean", {
92
- steps: [() => removeDirsSync(__ssg, ["static", "public", "dist"])],
91
+ await doLifeCycle("Close", {
92
+ steps: [() => removeArtifacts(arts.all.disposables)],
93
93
  });
94
94
 
95
95
  await doLifeCycle("HealthCheck", {
96
96
  steps: [() => isValidRenderProcessOrThrow()],
97
97
  });
98
+
99
+ deleteSentinelRenderFile();
98
100
  }
99
101
 
100
102
  async function runGatsbyAdapter(domains: Array<string>) {
101
103
  printExporterLogo("gatsby");
104
+
102
105
  for (const domain of domains) {
103
106
  await renderDomain(domain);
104
107
  }
@@ -0,0 +1,28 @@
1
+ # CX Artifacs
2
+
3
+ ## How to add an artifact.
4
+
5
+ An artifact is a **full path** to a file or directory if it has a fixed
6
+ location or only a **name** when it is going to be moved (archived/restored)
7
+ between directories in the rendering process and therefore doesn't have a
8
+ single location.
9
+
10
+ Only the exporter knows where the artifacts are archived and restored, so the
11
+ artifacts don't need to know anything other than their own location or name.
12
+
13
+ If you're creating an adapter, its artifacts should go in a separate file (the same as `artifacts/cx.ts`) and export a default function that returns an `Artifacts`. Everything should be exported from `artifacts/index.ts`.
14
+
15
+ **Artifacts have four categories:**
16
+
17
+ - **initials**: Are directories (probably empty) that need to be created for their future use.
18
+
19
+ - **archivables**: Are stored in `__exports` which is the one uploaded to the server as the final render and restored in `__cx` and `__ssg` to be reused in the render. Therefore, they don't have a single location and should be added only with the artifact name (directory/file)
20
+
21
+ - **cacheables**: Are stored in `__cache` and restored in `__cx` and `__ssg` to be reused in each domain render. Therefore, they don't have a single location.
22
+
23
+ - **disposables**: Are generated alwais in `__cx` and `__ssg` or fixed locations.
24
+ These artifacts are discarded (deleted) in each domain render. They are temporary directories and/or files.
25
+
26
+ ## Example
27
+
28
+ Check `cx.ts` inside `./artifacts` directory to see how to add an artifact.
@@ -0,0 +1,26 @@
1
+ import type { Artifacts, PlaceholderPath } from "../types/global";
2
+
3
+ import path from "node:path";
4
+
5
+ /**
6
+ * Returns the artifacts of CX.
7
+ */
8
+ function getCxArtifacts(paths: Record<PlaceholderPath, string>): Artifacts {
9
+ const { __cx, __exports, __caches } = paths;
10
+
11
+ return {
12
+ initials: [
13
+ __exports, // `/exports/<domain>`
14
+ __caches, // `__cx/caches/<domain>`
15
+ ],
16
+ disposables: [
17
+ path.join(__cx, "store"),
18
+ path.join(__cx, "apiCache"),
19
+ path.join(__cx, "dist"),
20
+ ],
21
+ cacheables: ["apiCache", "store"],
22
+ archivables: ["dist", "assets"],
23
+ };
24
+ }
25
+
26
+ export default getCxArtifacts;
@@ -0,0 +1,28 @@
1
+ import type { Artifacts, PlaceholderPath } from "../types/global";
2
+
3
+ import path from "node:path";
4
+
5
+ /**
6
+ * Returns the artifacts of Gatsby.
7
+ */
8
+ function gatsbyArtifacts(paths: Record<PlaceholderPath, string>): Artifacts {
9
+ const { __ssg } = paths;
10
+
11
+ return {
12
+ disposables: [
13
+ path.join(__ssg, "public"),
14
+ path.join(__ssg, "static"),
15
+ path.join(__ssg, ".cache"),
16
+ ],
17
+ cacheables: [".cache"],
18
+
19
+ // Gatsby does not have an initials directories to be created.
20
+ initials: [],
21
+
22
+ // Gatsby does not have any archivable artifacts. The output of Gatsby
23
+ // is moved to the Griddo `dist` artifacts.
24
+ archivables: [],
25
+ };
26
+ }
27
+
28
+ export default gatsbyArtifacts;
@@ -0,0 +1,30 @@
1
+ import type { Adapters } from "../adapters";
2
+ import type { PlaceholderPath } from "../types/global";
3
+
4
+ import getCxArtifacts from "./cx";
5
+ import getGatsbyArtifacts from "./gatsby";
6
+
7
+ /**
8
+ * Returns the artifacts of a specific adapter along with those of CX.
9
+ *
10
+ * @param adapter - The adapter for which to get the artifacts.
11
+ * @param options.cxPaths - The cx-paths.
12
+ */
13
+ function getArtifacts(
14
+ adapter: Adapters,
15
+ options: {
16
+ cxPaths: Record<PlaceholderPath, string>;
17
+ },
18
+ ) {
19
+ const { cxPaths } = options;
20
+ const ssgArtifacts = {
21
+ gatsby: getGatsbyArtifacts(cxPaths),
22
+ };
23
+
24
+ return {
25
+ cx: getCxArtifacts(cxPaths),
26
+ ssg: ssgArtifacts[adapter],
27
+ };
28
+ }
29
+
30
+ export { getArtifacts };
@@ -1,9 +1,6 @@
1
1
  import type { Footer, Header } from "../types/navigation";
2
2
  import type { APIPageObject } from "../types/pages";
3
3
 
4
- /**
5
- * TODO: JSDoc
6
- */
7
4
  class NavigationService {
8
5
  private _defaultHeaders: Record<string, Header>;
9
6
  private _defaultFooters: Record<string, Footer>;
@@ -21,25 +18,16 @@ class NavigationService {
21
18
  this._defaultFooters = {};
22
19
  }
23
20
 
24
- /**
25
- * TODO: JSDoc
26
- */
27
21
  set navigations(navigations) {
28
22
  this._navigations = navigations;
29
23
  this._defaultFooters = this.getDefaultFooters();
30
24
  this._defaultHeaders = this.getDefaultHeaders();
31
25
  }
32
26
 
33
- /**
34
- * TODO: JSDoc
35
- */
36
27
  get navigations() {
37
28
  return this._navigations;
38
29
  }
39
30
 
40
- /**
41
- * TODO: JSDoc
42
- */
43
31
  getDefaultFooters() {
44
32
  const safeFooters = [...this.navigations.footers];
45
33
  const defaultFooters = safeFooters.filter(
@@ -54,9 +42,6 @@ class NavigationService {
54
42
  return defaultFootersByLang;
55
43
  }
56
44
 
57
- /**
58
- * TODO: JSDoc
59
- */
60
45
  getDefaultHeaders() {
61
46
  const safeHeaders = [...this.navigations.headers];
62
47
  const defaultHeaders = safeHeaders.filter(
@@ -71,9 +56,6 @@ class NavigationService {
71
56
  return defaultHeadersByLang;
72
57
  }
73
58
 
74
- /**
75
- * TODO: JSDoc
76
- */
77
59
  getRightLanguage(
78
60
  list: Array<{
79
61
  language: number;
@@ -100,23 +82,14 @@ class NavigationService {
100
82
  return result ? { ...result } : null;
101
83
  }
102
84
 
103
- /**
104
- * TODO: JSDoc
105
- */
106
85
  getPageHeader(id: number, language: number) {
107
86
  return this.getRightLanguage(this.navigations.headers, id, language);
108
87
  }
109
88
 
110
- /**
111
- * TODO: JSDoc
112
- */
113
89
  getPageFooter(id: number, language: number) {
114
90
  return this.getRightLanguage(this.navigations.footers, id, language);
115
91
  }
116
92
 
117
- /**
118
- * TODO: JSDoc
119
- */
120
93
  getPageNavigations(page: APIPageObject) {
121
94
  const {
122
95
  header: pageHeader,
@@ -9,66 +9,47 @@ import { getConfig } from "../utils/core-utils";
9
9
 
10
10
  const config = getConfig();
11
11
 
12
- /**
13
- * TODO: JSDoc
14
- */
15
- class RobotsService {
16
- robots: Robots;
17
- baseURL: string | undefined;
18
- settings: Record<string, unknown>;
19
- endpoint: string;
20
-
21
- constructor() {
22
- this.robots = [];
23
- this.settings = {};
24
- this.endpoint = endpoints.ROBOTS;
12
+ async function getRobots() {
13
+ try {
14
+ const robots = await get<Robots>({ endpoint: endpoints.ROBOTS });
15
+
16
+ return (
17
+ robots
18
+ ?.filter((r) => !!r.path)
19
+ .map(({ path, content }) => ({
20
+ path,
21
+ content: content || "User-agent: *\n\r\n\rAllow: /",
22
+ })) || []
23
+ );
24
+ } catch (e) {
25
+ console.warn(`Robots: ${(e as Error).message}`);
25
26
  }
27
+ }
26
28
 
27
- /**
28
- * TODO: JSDoc
29
- */
30
- private async getRobots() {
31
- try {
32
- const apiRobots = await get<Robots>({
33
- endpoint: this.endpoint,
34
- });
35
- this.robots =
36
- apiRobots
37
- ?.filter((r) => !!r.path)
38
- .map(({ path, content }) => ({
39
- path,
40
- content: content || "User-agent: *\n\r\n\rAllow: /",
41
- })) || [];
42
- } catch (e) {
43
- console.warn(`${this.constructor.name}: ${(e as Error).message}`);
44
- }
45
- }
29
+ async function writeRobots(domain: string) {
30
+ const { __cx } = config.paths(domain);
31
+ const distDirectory = path.join(__cx, "dist");
46
32
 
47
- /**
48
- * Write robots.txt files for the current rendering domain.
49
- */
50
- async writeFiles(domain: string) {
51
- const { __cx } = config.paths(domain);
52
- const distDirectory = path.join(__cx, "dist");
33
+ const robots = await getRobots();
53
34
 
54
- await this.getRobots();
35
+ if (!robots) {
36
+ console.log(`Robots not found for ${domain}`);
37
+ return;
38
+ }
55
39
 
56
- const robot = this.robots.find(({ path }) => path === `/${domain}`);
40
+ const robot = robots.find(({ path }) => path === `/${domain}`);
57
41
 
58
- if (!robot) {
59
- console.log(`Robots not found for ${domain}`);
60
- return;
61
- }
42
+ if (!robot) {
43
+ console.log(`Robots not found for ${domain}`);
44
+ return;
45
+ }
62
46
 
63
- if (fs.existsSync(distDirectory)) {
64
- const fileLocation = path.join(distDirectory, "robots.txt");
65
- fs.writeFileSync(fileLocation, robot?.content);
66
- } else {
67
- console.log(`${distDirectory} not found`);
68
- }
47
+ if (fs.existsSync(distDirectory)) {
48
+ const fileLocation = path.join(distDirectory, "robots.txt");
49
+ fs.writeFileSync(fileLocation, robot?.content);
50
+ } else {
51
+ console.log(`${distDirectory} not found`);
69
52
  }
70
53
  }
71
54
 
72
- const robotsService = new RobotsService();
73
-
74
- export { robotsService as RobotsService };
55
+ export { writeRobots };
@@ -45,9 +45,6 @@ async function getSiteInfo(id: number, cacheKey = "") {
45
45
  });
46
46
  }
47
47
 
48
- /**
49
- * TODO: JSDoc
50
- */
51
48
  async function getSiteLanguages(id: number, cacheKey = "") {
52
49
  const [prefix, suffix] = endpoints.LANGUAGES;
53
50
 
@@ -57,9 +54,6 @@ async function getSiteLanguages(id: number, cacheKey = "") {
57
54
  });
58
55
  }
59
56
 
60
- /**
61
- * TODO: JSDoc
62
- */
63
57
  async function startSiteRender(id: number) {
64
58
  const [prefix, suffix] = endpoints.BUILD_START;
65
59
 
@@ -80,15 +74,12 @@ async function endSiteRender(id: number, body: EndSiteRenderBody) {
80
74
  });
81
75
  }
82
76
 
83
- /**
84
- * TODO: JSDoc
85
- */
86
77
  async function getDistributorData(
87
78
  page: Core.Page,
88
79
  body: DistributorBody,
89
80
  cacheKey: string,
90
81
  dataSiteId?: number,
91
- dataLangID?: number
82
+ dataLangID?: number,
92
83
  ) {
93
84
  const [prefix, suffix] = endpoints.GET_REFERENCE_FIELD_DATA;
94
85
  const site = dataSiteId || page.site;
@@ -102,9 +93,6 @@ async function getDistributorData(
102
93
  });
103
94
  }
104
95
 
105
- /**
106
- * TODO: JSDoc
107
- */
108
96
  async function getSitemap(id: number) {
109
97
  const [prefix, suffix] = endpoints.GET_SITEMAP;
110
98
 
@@ -113,9 +101,6 @@ async function getSitemap(id: number) {
113
101
  });
114
102
  }
115
103
 
116
- /**
117
- * TODO: JSDoc
118
- */
119
104
  async function getSiteSocials(id: number, cacheKey = "") {
120
105
  const [prefix, suffix] = endpoints.SOCIALS;
121
106
 
@@ -174,7 +174,6 @@ export type APIResponses =
174
174
  | PostSearchInfoResponse
175
175
  | PostEmbeddingsResponse;
176
176
 
177
- // TODO: JSDoc
178
177
  export interface ShowApiErrorOptions {
179
178
  callInfo: {
180
179
  endpoint?: string;