@griddo/cx 11.7.12-rc.3 → 11.7.12
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.
- package/README.md +226 -27
- package/build/adapters/gatsby/index.d.ts +4 -0
- package/build/adapters/gatsby/utils.d.ts +22 -0
- package/build/artifacts/index.d.ts +6 -0
- package/build/commands/end-render.d.ts +2 -0
- package/build/commands/move-assets.d.ts +1 -0
- package/build/commands/prepare-domains-render.d.ts +1 -0
- package/build/commands/reset-render.d.ts +2 -0
- package/build/commands/start-render.d.ts +2 -0
- package/build/commands/upload-search-content.d.ts +2 -0
- package/build/constants/endpoints.d.ts +19 -0
- package/build/constants/envs.d.ts +37 -0
- package/build/constants/index.d.ts +57 -0
- package/build/end-render.js +74 -0
- package/build/end-render.js.map +7 -0
- package/build/errors/errors-data.d.ts +22 -0
- package/build/errors/index.d.ts +15 -0
- package/build/index.d.ts +29 -0
- package/build/index.js +73 -0
- package/build/index.js.map +7 -0
- package/build/prepare-domains-render.js +73 -0
- package/build/prepare-domains-render.js.map +7 -0
- package/build/react/Favicon/index.d.ts +5 -0
- package/build/react/Favicon/utils.d.ts +9 -0
- package/build/react/GriddoIntegrations/index.d.ts +20 -0
- package/build/react/GriddoIntegrations/utils.d.ts +26 -0
- package/{react/index.tsx → build/react/index.d.ts} +0 -1
- package/build/react/index.js +3 -0
- package/build/registers/api.d.ts +9 -0
- package/build/registers/gatsby.d.ts +9 -0
- package/build/registers/index.d.ts +3 -0
- package/build/reset-render.js +74 -0
- package/build/reset-render.js.map +7 -0
- package/build/services/auth.d.ts +10 -0
- package/build/services/domains.d.ts +6 -0
- package/build/services/navigation.d.ts +50 -0
- package/build/services/reference-fields.d.ts +20 -0
- package/build/services/register.d.ts +36 -0
- package/build/services/robots.d.ts +19 -0
- package/build/services/settings.d.ts +4 -0
- package/build/services/sites.d.ts +29 -0
- package/build/services/store.d.ts +6 -0
- package/build/start-render.js +100 -0
- package/build/start-render.js.map +7 -0
- package/build/types/api.d.ts +142 -0
- package/build/types/global.d.ts +84 -0
- package/build/types/navigation.d.ts +28 -0
- package/build/types/pages.d.ts +144 -0
- package/build/types/sites.d.ts +57 -0
- package/build/types/templates.d.ts +8 -0
- package/build/upload-search-content.js +74 -0
- package/build/upload-search-content.js.map +7 -0
- package/build/utils/alerts.d.ts +3 -0
- package/build/utils/api.d.ts +23 -0
- package/build/utils/cache.d.ts +35 -0
- package/build/utils/core-utils.d.ts +107 -0
- package/build/utils/create-build-data.d.ts +8 -0
- package/build/utils/domains.d.ts +13 -0
- package/build/utils/folders.d.ts +53 -0
- package/build/utils/health-checks.d.ts +7 -0
- package/build/utils/images.d.ts +16 -0
- package/build/utils/instance.d.ts +21 -0
- package/build/utils/loggin.d.ts +51 -0
- package/build/utils/pages.d.ts +34 -0
- package/build/utils/render.d.ts +13 -0
- package/build/utils/searches.d.ts +15 -0
- package/build/utils/sites.d.ts +31 -0
- package/build/utils/store.d.ts +81 -0
- package/cx.config.d.ts +5 -0
- package/cx.config.js +36 -0
- package/exporter/adapters/gatsby/index.ts +153 -73
- package/exporter/adapters/gatsby/utils.ts +161 -0
- package/exporter/artifacts/README.md +34 -0
- package/exporter/artifacts/index.ts +33 -0
- package/exporter/build.sh +38 -4
- package/exporter/commands/end-render.ts +70 -72
- package/exporter/commands/move-assets.ts +11 -0
- package/exporter/commands/prepare-domains-render.ts +31 -143
- package/exporter/commands/reset-render.ts +3 -10
- package/exporter/commands/start-render.ts +45 -22
- package/exporter/commands/upload-search-content.ts +21 -194
- package/exporter/constants/endpoints.ts +1 -2
- package/exporter/constants/envs.ts +55 -57
- package/exporter/constants/index.ts +129 -0
- package/exporter/{constants/errors.ts → errors/errors-data.ts} +14 -24
- package/exporter/{utils/errors.ts → errors/index.ts} +9 -10
- package/exporter/index.ts +82 -0
- package/{react → exporter/react}/Favicon/index.tsx +7 -1
- package/{react → exporter/react}/GriddoIntegrations/index.tsx +22 -16
- package/{react → exporter/react}/GriddoIntegrations/utils.ts +9 -21
- package/exporter/react/index.tsx +11 -0
- package/exporter/registers/api.ts +14 -0
- package/exporter/registers/gatsby.ts +14 -0
- package/exporter/registers/index.ts +4 -0
- package/exporter/services/auth.ts +6 -7
- package/exporter/services/domains.ts +16 -0
- package/exporter/services/navigation.ts +10 -4
- package/exporter/services/reference-fields.ts +24 -9
- package/exporter/services/register.ts +113 -0
- package/exporter/services/robots.ts +16 -9
- package/exporter/services/settings.ts +17 -0
- package/exporter/services/sites.ts +24 -36
- package/exporter/services/store.ts +96 -107
- package/exporter/types/api.ts +28 -27
- package/exporter/types/global.ts +11 -8
- package/exporter/types/navigation.ts +1 -1
- package/exporter/types/pages.ts +3 -2
- package/exporter/types/sites.ts +2 -1
- package/exporter/utils/alerts.ts +29 -0
- package/exporter/utils/api.ts +75 -55
- package/exporter/utils/cache.ts +62 -37
- package/exporter/utils/core-utils.ts +272 -133
- package/exporter/utils/create-build-data.ts +17 -0
- package/exporter/utils/domains.ts +7 -10
- package/exporter/utils/folders.ts +98 -163
- package/exporter/utils/health-checks.ts +64 -0
- package/exporter/utils/images.ts +6 -1
- package/exporter/utils/instance.ts +13 -9
- package/exporter/utils/loggin.ts +91 -44
- package/exporter/utils/pages.ts +88 -23
- package/exporter/utils/render.ts +48 -180
- package/exporter/utils/searches.ts +156 -0
- package/exporter/utils/sites.ts +197 -19
- package/exporter/utils/store.ts +180 -87
- package/gatsby-browser.tsx +58 -41
- package/gatsby-config.ts +17 -10
- package/gatsby-node.ts +78 -17
- package/gatsby-ssr.tsx +1 -2
- package/package.json +86 -36
- package/src/README.md +7 -0
- package/src/components/Head.tsx +46 -13
- package/src/components/template.tsx +30 -8
- package/src/gatsby-node-utils.ts +2 -73
- package/src/html.tsx +11 -2
- package/src/types.ts +5 -5
- package/start-render.js +7 -0
- package/tsconfig.json +3 -5
- package/build/adapters/gatsby/actions/clean.js +0 -10
- package/build/adapters/gatsby/actions/clean.js.map +0 -1
- package/build/adapters/gatsby/actions/close.js +0 -12
- package/build/adapters/gatsby/actions/close.js.map +0 -1
- package/build/adapters/gatsby/actions/data.js +0 -18
- package/build/adapters/gatsby/actions/data.js.map +0 -1
- package/build/adapters/gatsby/actions/healthCheck.js +0 -10
- package/build/adapters/gatsby/actions/healthCheck.js.map +0 -1
- package/build/adapters/gatsby/actions/init.js +0 -22
- package/build/adapters/gatsby/actions/init.js.map +0 -1
- package/build/adapters/gatsby/actions/logs.js +0 -11
- package/build/adapters/gatsby/actions/logs.js.map +0 -1
- package/build/adapters/gatsby/actions/meta.js +0 -13
- package/build/adapters/gatsby/actions/meta.js.map +0 -1
- package/build/adapters/gatsby/actions/prepare.js +0 -9
- package/build/adapters/gatsby/actions/prepare.js.map +0 -1
- package/build/adapters/gatsby/actions/relocation.js +0 -15
- package/build/adapters/gatsby/actions/relocation.js.map +0 -1
- package/build/adapters/gatsby/actions/restore.js +0 -26
- package/build/adapters/gatsby/actions/restore.js.map +0 -1
- package/build/adapters/gatsby/actions/ssg.js +0 -9
- package/build/adapters/gatsby/actions/ssg.js.map +0 -1
- package/build/adapters/gatsby/actions/sync.js +0 -51
- package/build/adapters/gatsby/actions/sync.js.map +0 -1
- package/build/adapters/gatsby/index.js +0 -78
- package/build/adapters/gatsby/index.js.map +0 -1
- package/build/adapters/gatsby/shared/artifacts.js +0 -20
- package/build/adapters/gatsby/shared/artifacts.js.map +0 -1
- package/build/adapters/gatsby/shared/context.js +0 -31
- package/build/adapters/gatsby/shared/context.js.map +0 -1
- package/build/adapters/gatsby/shared/diff-assets.js +0 -101
- package/build/adapters/gatsby/shared/diff-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/extract-assets.js +0 -58
- package/build/adapters/gatsby/shared/extract-assets.js.map +0 -1
- package/build/adapters/gatsby/shared/gatsby-build.js +0 -55
- package/build/adapters/gatsby/shared/gatsby-build.js.map +0 -1
- package/build/adapters/gatsby/shared/sync-render.js +0 -210
- package/build/adapters/gatsby/shared/sync-render.js.map +0 -1
- package/build/adapters/gatsby/shared/types.js +0 -3
- package/build/adapters/gatsby/shared/types.js.map +0 -1
- package/build/commands/end-render.js +0 -87
- package/build/commands/end-render.js.map +0 -1
- package/build/commands/prepare-assets-directory.js +0 -30
- package/build/commands/prepare-assets-directory.js.map +0 -1
- package/build/commands/prepare-domains-render.js +0 -133
- package/build/commands/prepare-domains-render.js.map +0 -1
- package/build/commands/reset-render.js +0 -21
- package/build/commands/reset-render.js.map +0 -1
- package/build/commands/start-render.js +0 -44
- package/build/commands/start-render.js.map +0 -1
- package/build/commands/upload-search-content.js +0 -180
- package/build/commands/upload-search-content.js.map +0 -1
- package/build/constants/endpoints.js +0 -43
- package/build/constants/endpoints.js.map +0 -1
- package/build/constants/envs.js +0 -68
- package/build/constants/envs.js.map +0 -1
- package/build/constants/errors.js +0 -81
- package/build/constants/errors.js.map +0 -1
- package/build/services/auth.js +0 -40
- package/build/services/auth.js.map +0 -1
- package/build/services/db-class.js +0 -49
- package/build/services/db-class.js.map +0 -1
- package/build/services/db.js +0 -34
- package/build/services/db.js.map +0 -1
- package/build/services/navigation.js +0 -96
- package/build/services/navigation.js.map +0 -1
- package/build/services/reference-fields.js +0 -131
- package/build/services/reference-fields.js.map +0 -1
- package/build/services/robots.js +0 -60
- package/build/services/robots.js.map +0 -1
- package/build/services/sites.js +0 -110
- package/build/services/sites.js.map +0 -1
- package/build/services/store.js +0 -257
- package/build/services/store.js.map +0 -1
- package/build/types/api.js +0 -3
- package/build/types/api.js.map +0 -1
- package/build/types/global.js +0 -3
- package/build/types/global.js.map +0 -1
- package/build/types/navigation.js +0 -3
- package/build/types/navigation.js.map +0 -1
- package/build/types/pages.js +0 -3
- package/build/types/pages.js.map +0 -1
- package/build/types/render.js +0 -10
- package/build/types/render.js.map +0 -1
- package/build/types/sites.js +0 -3
- package/build/types/sites.js.map +0 -1
- package/build/types/templates.js +0 -3
- package/build/types/templates.js.map +0 -1
- package/build/utils/api.js +0 -165
- package/build/utils/api.js.map +0 -1
- package/build/utils/artifacts.js +0 -38
- package/build/utils/artifacts.js.map +0 -1
- package/build/utils/brush.js +0 -30
- package/build/utils/brush.js.map +0 -1
- package/build/utils/cache.js +0 -106
- package/build/utils/cache.js.map +0 -1
- package/build/utils/check-environment-health.js +0 -73
- package/build/utils/check-environment-health.js.map +0 -1
- package/build/utils/core-utils.js +0 -270
- package/build/utils/core-utils.js.map +0 -1
- package/build/utils/domains.js +0 -37
- package/build/utils/domains.js.map +0 -1
- package/build/utils/errors.js +0 -30
- package/build/utils/errors.js.map +0 -1
- package/build/utils/folders.js +0 -341
- package/build/utils/folders.js.map +0 -1
- package/build/utils/images.js +0 -45
- package/build/utils/images.js.map +0 -1
- package/build/utils/instance.js +0 -66
- package/build/utils/instance.js.map +0 -1
- package/build/utils/loggin.js +0 -119
- package/build/utils/loggin.js.map +0 -1
- package/build/utils/npm-deps/find-up-simple.js +0 -75
- package/build/utils/npm-deps/find-up-simple.js.map +0 -1
- package/build/utils/npm-deps/pkg-dir.js +0 -20
- package/build/utils/npm-deps/pkg-dir.js.map +0 -1
- package/build/utils/npm-deps/xml-parser.js +0 -49
- package/build/utils/npm-deps/xml-parser.js.map +0 -1
- package/build/utils/pages.js +0 -359
- package/build/utils/pages.js.map +0 -1
- package/build/utils/render.js +0 -168
- package/build/utils/render.js.map +0 -1
- package/build/utils/sitemaps.js +0 -110
- package/build/utils/sitemaps.js.map +0 -1
- package/build/utils/sites.js +0 -105
- package/build/utils/sites.js.map +0 -1
- package/build/utils/store.js +0 -193
- package/build/utils/store.js.map +0 -1
- package/cli.mjs +0 -136
- package/exporter/adapters/gatsby/actions/clean.ts +0 -14
- package/exporter/adapters/gatsby/actions/close.ts +0 -17
- package/exporter/adapters/gatsby/actions/data.ts +0 -25
- package/exporter/adapters/gatsby/actions/healthCheck.ts +0 -10
- package/exporter/adapters/gatsby/actions/init.ts +0 -26
- package/exporter/adapters/gatsby/actions/logs.ts +0 -12
- package/exporter/adapters/gatsby/actions/meta.ts +0 -16
- package/exporter/adapters/gatsby/actions/prepare.ts +0 -9
- package/exporter/adapters/gatsby/actions/relocation.ts +0 -15
- package/exporter/adapters/gatsby/actions/restore.ts +0 -36
- package/exporter/adapters/gatsby/actions/ssg.ts +0 -12
- package/exporter/adapters/gatsby/actions/sync.ts +0 -71
- package/exporter/adapters/gatsby/shared/artifacts.ts +0 -16
- package/exporter/adapters/gatsby/shared/context.ts +0 -50
- package/exporter/adapters/gatsby/shared/diff-assets.ts +0 -113
- package/exporter/adapters/gatsby/shared/extract-assets.ts +0 -61
- package/exporter/adapters/gatsby/shared/gatsby-build.ts +0 -58
- package/exporter/adapters/gatsby/shared/sync-render.ts +0 -276
- package/exporter/adapters/gatsby/shared/types.ts +0 -35
- package/exporter/build-esbuild.noop +0 -42
- package/exporter/commands/prepare-assets-directory.ts +0 -30
- package/exporter/services/db-class.ts +0 -54
- package/exporter/services/db.ts +0 -32
- package/exporter/types/render.ts +0 -59
- package/exporter/utils/artifacts.ts +0 -38
- package/exporter/utils/brush.ts +0 -34
- package/exporter/utils/check-environment-health.ts +0 -84
- package/exporter/utils/npm-deps/find-up-simple.ts +0 -100
- package/exporter/utils/npm-deps/pkg-dir.ts +0 -17
- package/exporter/utils/npm-deps/xml-parser.ts +0 -57
- package/exporter/utils/sitemaps.ts +0 -129
- package/plugins/gatsby-plugin-svgr-loader/gatsby-node.js +0 -55
- package/plugins/gatsby-plugin-svgr-loader/package.json +0 -8
- package/react/DynamicScript/index.tsx +0 -33
- package/tsconfig.commands.json +0 -36
- package/tsconfig.exporter.json +0 -19
- /package/{react → exporter/react}/Favicon/utils.ts +0 -0
package/build/utils/folders.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.copyDirs = copyDirs;
|
|
7
|
-
exports.createDirs = createDirs;
|
|
8
|
-
exports.deleteDisposableSiteDirs = deleteDisposableSiteDirs;
|
|
9
|
-
exports.deleteEmptyDirectories = deleteEmptyDirectories;
|
|
10
|
-
exports.findFilesBySuffix = findFilesBySuffix;
|
|
11
|
-
exports.moveDirs = moveDirs;
|
|
12
|
-
exports.pathExists = pathExists;
|
|
13
|
-
exports.removeDirs = removeDirs;
|
|
14
|
-
exports.removeVirtualPages = removeVirtualPages;
|
|
15
|
-
exports.renamePath = renamePath;
|
|
16
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
17
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
-
const errors_1 = require("../constants/errors");
|
|
19
|
-
const core_utils_1 = require("./core-utils");
|
|
20
|
-
const errors_2 = require("./errors");
|
|
21
|
-
const loggin_1 = require("./loggin");
|
|
22
|
-
/**
|
|
23
|
-
* Remove an empty directory from the basePath recursively.
|
|
24
|
-
* If the directory has only .xml files it will handle as empty too (empty site)
|
|
25
|
-
*
|
|
26
|
-
* @param baseDir - The base directory.
|
|
27
|
-
*/
|
|
28
|
-
async function deleteDisposableSiteDirs(baseDir) {
|
|
29
|
-
if (!(await pathExists(baseDir))) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const sitesDirs = (await promises_1.default.readdir(baseDir, { withFileTypes: true })).filter((file) => file.isDirectory());
|
|
33
|
-
for (const siteDir of sitesDirs) {
|
|
34
|
-
const sitePath = node_path_1.default.join(baseDir, siteDir.name);
|
|
35
|
-
if (await siteIsEmpty(sitePath)) {
|
|
36
|
-
await promises_1.default.rm(sitePath, { recursive: true });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates multiple artifact directories.
|
|
42
|
-
*
|
|
43
|
-
* @param dirs - An array of directory paths.
|
|
44
|
-
* @param options - Same option as `fs.mkdirSync()`
|
|
45
|
-
*/
|
|
46
|
-
async function createDirs(dirs, options) {
|
|
47
|
-
for (const dir of dirs) {
|
|
48
|
-
try {
|
|
49
|
-
if (!(await pathExists(dir))) {
|
|
50
|
-
await promises_1.default.mkdir(dir, { recursive: true, ...options });
|
|
51
|
-
(0, loggin_1.verboseLog)(`create directory: ${dir}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function renamePath(src, dst) {
|
|
60
|
-
try {
|
|
61
|
-
if (await pathExists(src)) {
|
|
62
|
-
await promises_1.default.rename(src, dst);
|
|
63
|
-
(0, loggin_1.verboseLog)(`rename ${src} to ${dst}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Copy multiple directories with backup option.
|
|
72
|
-
*
|
|
73
|
-
* @param src - Source directory.
|
|
74
|
-
* @param dst - Destination directory.
|
|
75
|
-
* @param dirs - Directories to copy.
|
|
76
|
-
* @param options.withBackup - Create a previous backup before copy.
|
|
77
|
-
*/
|
|
78
|
-
async function copyDirs(src, dst, dirs, options = {
|
|
79
|
-
withBackup: false,
|
|
80
|
-
}) {
|
|
81
|
-
const { withBackup } = options;
|
|
82
|
-
for (const dir of dirs) {
|
|
83
|
-
const srcCompose = node_path_1.default.join(src, dir);
|
|
84
|
-
const dstCompose = node_path_1.default.join(dst, dir);
|
|
85
|
-
// The dir we want to copy, doesn't exist.
|
|
86
|
-
if (!(await pathExists(srcCompose))) {
|
|
87
|
-
console.log(`(Maybe first render) Source directory does not exist: ${srcCompose}`);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
// Create the backup
|
|
91
|
-
if (withBackup) {
|
|
92
|
-
await createBackup(dstCompose);
|
|
93
|
-
(0, loggin_1.verboseLog)(`create backup: ${dstCompose}`);
|
|
94
|
-
}
|
|
95
|
-
// Copy directory
|
|
96
|
-
try {
|
|
97
|
-
// First clean destination
|
|
98
|
-
if (await pathExists(dstCompose)) {
|
|
99
|
-
await promises_1.default.rm(dstCompose, { recursive: true, force: true });
|
|
100
|
-
(0, loggin_1.verboseLog)(`clean destination: ${dstCompose}`);
|
|
101
|
-
}
|
|
102
|
-
// Then copy src to dst
|
|
103
|
-
await promises_1.default.cp(srcCompose, dstCompose, {
|
|
104
|
-
recursive: true,
|
|
105
|
-
preserveTimestamps: true,
|
|
106
|
-
});
|
|
107
|
-
(0, loggin_1.verboseLog)(`copy: ${srcCompose} to ${dstCompose}`);
|
|
108
|
-
if (withBackup) {
|
|
109
|
-
await deleteBackup(dstCompose);
|
|
110
|
-
(0, loggin_1.verboseLog)(`delete backup: ${dstCompose}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
if (withBackup) {
|
|
115
|
-
await restoreBackup(dstCompose);
|
|
116
|
-
(0, loggin_1.verboseLog)("Backup has been restored.");
|
|
117
|
-
}
|
|
118
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Move artifacts between cx-paths
|
|
124
|
-
*
|
|
125
|
-
* @param src - Source directory.
|
|
126
|
-
* @param dst - Destination directory.
|
|
127
|
-
* @param dirs - Directories to move.
|
|
128
|
-
* @param options - Options.
|
|
129
|
-
*/
|
|
130
|
-
async function moveDirs(src, dst, dirs, options) {
|
|
131
|
-
const { override, withBackup } = options || {};
|
|
132
|
-
for (const dir of dirs) {
|
|
133
|
-
const srcCompose = node_path_1.default.join(src, dir);
|
|
134
|
-
const dstCompose = node_path_1.default.join(dst, dir);
|
|
135
|
-
if (!(await pathExists(srcCompose))) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
if (withBackup) {
|
|
139
|
-
await createBackup(dstCompose);
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
// Clean destination
|
|
143
|
-
if (override && (await pathExists(dstCompose))) {
|
|
144
|
-
await promises_1.default.rm(dstCompose, { recursive: true, force: true });
|
|
145
|
-
}
|
|
146
|
-
await promises_1.default.rename(srcCompose, dstCompose);
|
|
147
|
-
(0, loggin_1.verboseLog)(`moved: ${srcCompose} to ${dstCompose}`);
|
|
148
|
-
if (withBackup) {
|
|
149
|
-
await deleteBackup(dstCompose);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
if (withBackup) {
|
|
154
|
-
await restoreBackup(dstCompose);
|
|
155
|
-
console.log("Backup has been restored.");
|
|
156
|
-
}
|
|
157
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Removes multiple artifact directories.
|
|
163
|
-
*
|
|
164
|
-
* @param dirs - An array of directory paths.
|
|
165
|
-
*/
|
|
166
|
-
async function removeDirs(dirs) {
|
|
167
|
-
for (const dir of dirs) {
|
|
168
|
-
try {
|
|
169
|
-
await promises_1.default.rm(dir, { recursive: true, force: true });
|
|
170
|
-
(0, loggin_1.verboseLog)(`artifact removed: ${dir}`);
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async function restoreBackup(src, suffix = "-BACKUP") {
|
|
178
|
-
const dst = src + suffix;
|
|
179
|
-
try {
|
|
180
|
-
await promises_1.default.rename(dst, src);
|
|
181
|
-
console.log(`Backup ${dst} has been restored`);
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
console.log(error);
|
|
185
|
-
throw new Error(`Error while delete ${dst} backup`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async function deleteBackup(src, suffix = "-BACKUP") {
|
|
189
|
-
const dst = src + suffix;
|
|
190
|
-
if (!(await pathExists(dst))) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
try {
|
|
194
|
-
await promises_1.default.rm(dst, { recursive: true, force: true });
|
|
195
|
-
(0, loggin_1.verboseLog)(`Backup ${dst} has been deleted`);
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
console.log(error);
|
|
199
|
-
throw new Error(`Error while delete ${dst} backup`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
async function createBackup(src, suffix = "-BACKUP") {
|
|
203
|
-
const dst = src + suffix;
|
|
204
|
-
if (!(await pathExists(src))) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
if (await pathExists(dst)) {
|
|
208
|
-
console.log(`Destination ${dst} already exists`);
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
try {
|
|
212
|
-
await promises_1.default.rename(src, dst);
|
|
213
|
-
(0, loggin_1.verboseLog)(`Backup of ${src} has been created in ${dst}`);
|
|
214
|
-
}
|
|
215
|
-
catch (error) {
|
|
216
|
-
console.log(`Error while coping ${src} to ${dst} backup`);
|
|
217
|
-
(0, errors_2.throwError)(errors_1.ArtifactError, error);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Elimina todas las páginas del store (de todos los sites) cuyo nombre empiece
|
|
222
|
-
* con un guión "-". Estas páginas son "virtuales" y no tienen ids desde API por
|
|
223
|
-
* lo que mantenerlas en el store es un problema cuando se hacen modificaciones
|
|
224
|
-
* en la página "madre". La solución por ahora es borrarlas del store y
|
|
225
|
-
* rehacerlas en todos los renders.
|
|
226
|
-
*/
|
|
227
|
-
async function removeVirtualPages(dirPath) {
|
|
228
|
-
try {
|
|
229
|
-
// Procesamos archivos uno por uno para evitar cargar todos en memoria
|
|
230
|
-
for await (const filePath of (0, core_utils_1.walkStore)(dirPath)) {
|
|
231
|
-
if (node_path_1.default.basename(filePath).startsWith("-")) {
|
|
232
|
-
await promises_1.default.unlink(filePath);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
console.info(`${dirPath} folder does not exist. Skipping multipage or static list template cleaning.`, error);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Return true if the site folder is empty or only has xml files. (Recursively)
|
|
242
|
-
*/
|
|
243
|
-
async function siteIsEmpty(sitePath) {
|
|
244
|
-
const siteFiles = (await promises_1.default.readdir(sitePath, {
|
|
245
|
-
withFileTypes: true,
|
|
246
|
-
recursive: true,
|
|
247
|
-
})).filter((file) => file.isFile() && !node_path_1.default.basename(file.name).startsWith("."));
|
|
248
|
-
const xmlFiles = siteFiles.filter((file) => file.name.endsWith(".xml"));
|
|
249
|
-
if (siteFiles.length === xmlFiles.length) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Delete empty directories from the given directory in a recursive way.
|
|
255
|
-
*/
|
|
256
|
-
async function deleteEmptyDirectories(dirPath) {
|
|
257
|
-
try {
|
|
258
|
-
const stats = await promises_1.default.stat(dirPath);
|
|
259
|
-
// Si no es un directorio, no hacemos nada
|
|
260
|
-
if (!stats.isDirectory()) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
let filesInDirectory;
|
|
264
|
-
try {
|
|
265
|
-
filesInDirectory = await promises_1.default.readdir(dirPath);
|
|
266
|
-
}
|
|
267
|
-
catch (err) {
|
|
268
|
-
// Si el directorio no existe o no se puede leer (ej. permisos), lo saltamos.
|
|
269
|
-
if (err.code === "ENOENT") {
|
|
270
|
-
console.warn(`The directory "${dirPath}" does not exist, skipping it.`);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
console.error(`Error al leer el directorio "${dirPath}":`, err);
|
|
274
|
-
throw err; // Re-lanza el error para que sea manejado por el llamador
|
|
275
|
-
}
|
|
276
|
-
// Recorrer los contenidos del directorio
|
|
277
|
-
for (const file of filesInDirectory) {
|
|
278
|
-
const fullPath = node_path_1.default.join(dirPath, file);
|
|
279
|
-
await deleteEmptyDirectories(fullPath); // Llamada recursiva síncrona
|
|
280
|
-
}
|
|
281
|
-
// Después de procesar todos los subdirectorios, verifica si el directorio actual está vacío
|
|
282
|
-
const remainingFiles = await promises_1.default.readdir(dirPath);
|
|
283
|
-
if (remainingFiles.length === 0) {
|
|
284
|
-
try {
|
|
285
|
-
await promises_1.default.rmdir(dirPath);
|
|
286
|
-
(0, loggin_1.verboseLog)(`Remove empty directory: ${dirPath}`);
|
|
287
|
-
}
|
|
288
|
-
catch (err) {
|
|
289
|
-
// Puede que haya habido un problema de concurrencia o permisos
|
|
290
|
-
if (err.code === "ENOENT") {
|
|
291
|
-
console.warn(`El directorio "${dirPath}" ya no existe. Posiblemente fue borrado por otra operación.`);
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
console.error(`Error al borrar el directorio "${dirPath}":`, err);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
catch (err) {
|
|
300
|
-
if (err.code === "ENOENT") {
|
|
301
|
-
// El directorio ya no existe, no es un error para nosotros en este contexto
|
|
302
|
-
console.warn(`The directory "${dirPath}" does not exist or has already been processed.`);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
console.error(`General error general while processing "${dirPath}":`, err);
|
|
306
|
-
throw err;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
async function pathExists(dir) {
|
|
311
|
-
try {
|
|
312
|
-
await promises_1.default.access(dir);
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
catch {
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Busca recursivamente archivos que terminen con un sufijo específico dentro de un directorio.
|
|
321
|
-
* Esta función es un generador asíncrono, lo que la hace muy eficiente en uso de memoria.
|
|
322
|
-
*
|
|
323
|
-
* @param dir El directorio base para comenzar la búsqueda.
|
|
324
|
-
* @param suffix El sufijo con el que deben terminar los nombres de archivo (ej: 'page-data.json').
|
|
325
|
-
* @returns Un generador asíncrono que produce la ruta completa de cada archivo encontrado.
|
|
326
|
-
* @throws Si el directorio inicial `dir` no existe o no se puede leer.
|
|
327
|
-
*/
|
|
328
|
-
async function* findFilesBySuffix(dir, suffix) {
|
|
329
|
-
const dirHandle = await promises_1.default.opendir(dir);
|
|
330
|
-
for await (const item of dirHandle) {
|
|
331
|
-
const fullPath = node_path_1.default.join(dir, item.name);
|
|
332
|
-
if (item.isDirectory()) {
|
|
333
|
-
// yield* para encadenar otro generator.
|
|
334
|
-
yield* findFilesBySuffix(fullPath, suffix);
|
|
335
|
-
}
|
|
336
|
-
else if (item.isFile() && item.name.endsWith(suffix)) {
|
|
337
|
-
yield fullPath;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
//# sourceMappingURL=folders.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"folders.js","sourceRoot":"","sources":["../../exporter/utils/folders.ts"],"names":[],"mappings":";;;;;QAsXC,QAAQ;QACR,UAAU;QACV,wBAAwB;QACxB,sBAAsB;QACtB,iBAAiB;QACjB,QAAQ;QACR,UAAU;QACV,UAAU;QACV,kBAAkB;QAClB,UAAU;AA7XX,gEAAmC;AACnC,0DAA6B;AAE7B,gDAAoD;AACpD,6CAAyC;AACzC,qCAAsC;AACtC,qCAAsC;AAEtC;;;;;GAKG;AACH,KAAK,UAAU,wBAAwB,CAAC,OAAe,EAAE;IACxD,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO;IACR,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,MAAM,kBAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAA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AG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,wCAAwC;YACxC,KAAK,CAAC,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACxD,MAAM,QAAQ,CAAC;QAChB,CAAC;IACF,CAAC;AAAA,CACD"}
|
package/build/utils/images.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatImage = formatImage;
|
|
4
|
-
/**
|
|
5
|
-
* Format Cloudinary or DAM URL
|
|
6
|
-
*
|
|
7
|
-
* @param image The image url
|
|
8
|
-
* @param width With of the image
|
|
9
|
-
* @param height Height of the image
|
|
10
|
-
* @param format Format of the image
|
|
11
|
-
* @returns A composed URL for the Cloudinary or DAM service
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* formatImage("https://images.griddo.io/tree", 300, 200, "jpg")
|
|
15
|
-
* // https://images.griddo.io/tree/w/300/h/200/f/jpg
|
|
16
|
-
*/
|
|
17
|
-
function formatImage(image, width, height, format = "jpg") {
|
|
18
|
-
const url = typeof image === "string" ? image : image?.url;
|
|
19
|
-
if (!url) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const isCloudinary = url.split("/")[2].includes("cloudinary.com");
|
|
23
|
-
return isCloudinary
|
|
24
|
-
? addCloudinaryParams(url, `c_fill,w_${width},h_${height}`)
|
|
25
|
-
: addGriddoDamParams(url, `f/${format}/w/${width}/h/${height}`);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Format Griddo DAM image url.
|
|
29
|
-
*/
|
|
30
|
-
function addGriddoDamParams(image, params) {
|
|
31
|
-
const urlParts = image.split("/");
|
|
32
|
-
const imagePath = urlParts.slice(0, -1).join("/");
|
|
33
|
-
const imageName = urlParts.slice(-1)[0];
|
|
34
|
-
return `${imagePath}/${params}/${imageName}`;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Take a cloudinary url and add query params.
|
|
38
|
-
*/
|
|
39
|
-
function addCloudinaryParams(image, params) {
|
|
40
|
-
const plainUrl = image.replace("https://", "");
|
|
41
|
-
const head = plainUrl.split("/").slice(0, 4).join("/");
|
|
42
|
-
const fullId = plainUrl.replace(head, "");
|
|
43
|
-
return `https://${head}/${params}${fullId}`;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=images.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"images.js","sourceRoot":"","sources":["../../exporter/utils/images.ts"],"names":[],"mappings":";;QAmDS,WAAW;AAjDpB;;;;;;;;;;;;GAYG;AACH,SAAS,WAAW,CAAC,KAA4B,EAAE,KAAa,EAAE,MAAc,EAAE,MAAM,GAAG,KAAK,EAAE;IACjG,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC;IAE3D,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAElE,OAAO,YAAY;QAClB,CAAC,CAAC,mBAAmB,CAAC,GAAG,EAAE,YAAY,KAAK,MAAM,MAAM,EAAE,CAAC;QAC3D,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,MAAM,MAAM,KAAK,MAAM,MAAM,EAAE,CAAC,CAAC;AAAA,CACjE;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAAa,EAAE,MAAc,EAAE;IAC1D,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAExC,OAAO,GAAG,SAAS,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;AAAA,CAC7C;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,KAAa,EAAE,MAAc,EAAE;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE1C,OAAO,WAAW,IAAI,IAAI,MAAM,GAAG,MAAM,EAAE,CAAC;AAAA,CAC5C"}
|
package/build/utils/instance.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isComponentLibrary = exports.componentLibraryPathAlias = void 0;
|
|
7
|
-
exports.getComponentsJSConfig = getComponentsJSConfig;
|
|
8
|
-
exports.getComponentsLibAliases = getComponentsLibAliases;
|
|
9
|
-
exports.resolveComponentsPath = resolveComponentsPath;
|
|
10
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
-
const errors_1 = require("../constants/errors");
|
|
12
|
-
const errors_2 = require("./errors");
|
|
13
|
-
const find_up_simple_1 = require("./npm-deps/find-up-simple");
|
|
14
|
-
const pkg_dir_1 = require("./npm-deps/pkg-dir");
|
|
15
|
-
// Consts
|
|
16
|
-
const isComponentLibrary = __dirname.includes("node_modules");
|
|
17
|
-
exports.isComponentLibrary = isComponentLibrary;
|
|
18
|
-
const componentLibraryPathAlias = getComponentsLibAliases();
|
|
19
|
-
exports.componentLibraryPathAlias = componentLibraryPathAlias;
|
|
20
|
-
/**
|
|
21
|
-
* Returns the instance or monorepo paths.
|
|
22
|
-
*
|
|
23
|
-
* @param customPath The path for the instance components
|
|
24
|
-
*/
|
|
25
|
-
function resolveComponentsPath(customPath = "") {
|
|
26
|
-
return isComponentLibrary
|
|
27
|
-
? node_path_1.default.resolve((0, pkg_dir_1.pkgDirSync)({ cwd: __dirname }), "../../../", customPath)
|
|
28
|
-
: node_path_1.default.resolve((0, pkg_dir_1.pkgDirSync)({ cwd: __dirname }), "../griddo-components", customPath);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Return the instance or monorepo components {t|j}sconfig.json file.
|
|
32
|
-
*/
|
|
33
|
-
function getComponentsJSConfig() {
|
|
34
|
-
const jsConfigPath = (0, find_up_simple_1.findUpSync)("jsconfig.json", {
|
|
35
|
-
cwd: resolveComponentsPath(),
|
|
36
|
-
});
|
|
37
|
-
const tsConfigPath = (0, find_up_simple_1.findUpSync)("tsconfig.json", {
|
|
38
|
-
cwd: resolveComponentsPath(),
|
|
39
|
-
});
|
|
40
|
-
return tsConfigPath || jsConfigPath;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the instance webpack aliases
|
|
44
|
-
*/
|
|
45
|
-
function getComponentsLibAliases() {
|
|
46
|
-
const xsConfig = require(getComponentsJSConfig());
|
|
47
|
-
if (!xsConfig) {
|
|
48
|
-
(0, errors_2.throwError)(errors_1.NoJSConfigFileFound);
|
|
49
|
-
}
|
|
50
|
-
return Object.keys(xsConfig.compilerOptions?.paths).reduce((currentAlias, pathKey) => {
|
|
51
|
-
const [aliasKey] = pathKey.split("/");
|
|
52
|
-
const [pathAtJsConfig] = xsConfig.compilerOptions.paths[pathKey];
|
|
53
|
-
const [relativePathToDir] = pathAtJsConfig.split("/*");
|
|
54
|
-
const absolutePath = resolveComponentsPath(relativePathToDir);
|
|
55
|
-
return {
|
|
56
|
-
// biome-ignore lint/performance/noAccumulatingSpread: to be fixed
|
|
57
|
-
...currentAlias,
|
|
58
|
-
[aliasKey]: absolutePath,
|
|
59
|
-
};
|
|
60
|
-
}, {
|
|
61
|
-
// Por este motivo se puede hacer `... import from "@griddo-instance" en
|
|
62
|
-
// los packages del monorepo.
|
|
63
|
-
"@griddo-instance": `${resolveComponentsPath()}/src/index.js`,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=instance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../exporter/utils/instance.ts"],"names":[],"mappings":";;;;;;QAqEC,qBAAqB;QACrB,uBAAuB;QAEvB,qBAAqB;AAxEtB,0DAA6B;AAE7B,gDAA0D;AAC1D,qCAAsC;AACtC,8DAAuD;AACvD,gDAAgD;AAEhD,SAAS;AACT,MAAM,kBAAkB,GAAG,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QA+D7D,kBAAkB;AA9DnB,MAAM,yBAAyB,GAAG,uBAAuB,EAAE,CAAC;QA2D3D,yBAAyB;AAzD1B;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,UAAU,GAAG,EAAE,EAAE;IAC/C,OAAO,kBAAkB;QACxB,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC,IAAA,oBAAU,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAW,EAAE,WAAW,EAAE,UAAU,CAAC;QACjF,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC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AC7D,CACD,CAAC;AAAA,CACF"}
|
package/build/utils/loggin.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.appendLogToFile = appendLogToFile;
|
|
7
|
-
exports.boxLog = boxLog;
|
|
8
|
-
exports.buildLog = buildLog;
|
|
9
|
-
exports.infoLog = infoLog;
|
|
10
|
-
exports.listSitesLog = listSitesLog;
|
|
11
|
-
exports.showExporterVersion = showExporterVersion;
|
|
12
|
-
exports.successLog = successLog;
|
|
13
|
-
exports.verboseLog = verboseLog;
|
|
14
|
-
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
15
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
-
const envs_1 = require("../constants/envs");
|
|
17
|
-
const db_1 = require("../services/db");
|
|
18
|
-
const brush_1 = require("./brush");
|
|
19
|
-
/**
|
|
20
|
-
* Custom basic logging function controlled by a environment variable.
|
|
21
|
-
* @param str The string to be logged.
|
|
22
|
-
*/
|
|
23
|
-
function verboseLog(str) {
|
|
24
|
-
if (envs_1.GRIDDO_VERBOSE_LOGS) {
|
|
25
|
-
console.log(brush_1.brush.yellow("verbose"), brush_1.brush.dim(str.replace(/(\s)\s+/g, "$1").trim()));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Custom log inside a line-box.
|
|
30
|
-
* @param stringValue The string to be logged.
|
|
31
|
-
* @param paddingInline The number of white spaces inside the box at left and right.
|
|
32
|
-
* @param paddingBlock The number of white spaces inside the box at top and bottom.
|
|
33
|
-
*/
|
|
34
|
-
function boxLog(stringValue, title = "", paddingInline = 1, paddingBlock = 1) {
|
|
35
|
-
const lines = stringValue
|
|
36
|
-
.split("\n") // lines
|
|
37
|
-
.map((line) => line.trim()); // remove extra spaces
|
|
38
|
-
const windowTitle = title ? ` ${title} ` : "";
|
|
39
|
-
const windowTitleLength = title ? windowTitle.length : 0;
|
|
40
|
-
const longerContent = Math.max(...lines.map((l) => l.length)) + paddingInline * 2;
|
|
41
|
-
const longerLine = Math.max(longerContent, windowTitleLength);
|
|
42
|
-
const paddingBlockString = `│${" ".repeat(longerLine)}│\n`.repeat(paddingBlock);
|
|
43
|
-
const minWidth = longerLine;
|
|
44
|
-
const borderTop = `╭${windowTitle}${"─".repeat(minWidth - windowTitleLength)}╮\n`;
|
|
45
|
-
const borderBottom = `╰${"─".repeat(minWidth)}╯`;
|
|
46
|
-
const content = lines
|
|
47
|
-
.map((l) => {
|
|
48
|
-
const mr = " ".repeat(longerLine - l.length - paddingInline);
|
|
49
|
-
return `│${" ".repeat(paddingInline)}${l}${mr}│\n`;
|
|
50
|
-
})
|
|
51
|
-
.join("");
|
|
52
|
-
console.log(`${borderTop}${paddingBlockString}${content}${paddingBlockString}${borderBottom}`);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Custom basic logging function controlled by a environment variable.
|
|
56
|
-
* Strip double spaces.
|
|
57
|
-
*
|
|
58
|
-
* @param str The string to be logged.
|
|
59
|
-
*/
|
|
60
|
-
function buildLog(str) {
|
|
61
|
-
if (envs_1.GRIDDO_BUILD_LOGS) {
|
|
62
|
-
console.log(str.replace(/(\s)\s+/g, "$1").trim());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Console log with a blue color in the info prefix.
|
|
67
|
-
* @param str The string to be logged.
|
|
68
|
-
*/
|
|
69
|
-
function infoLog(str) {
|
|
70
|
-
console.log(`${brush_1.brush.blue("info")} ${str}`);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Console log with a green color in the success prefix.
|
|
74
|
-
* @param str The string to be logged.
|
|
75
|
-
*/
|
|
76
|
-
function successLog(str) {
|
|
77
|
-
console.log(`${brush_1.brush.green("success")} ${str}`);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Console log the Griddo exporter version.
|
|
81
|
-
*/
|
|
82
|
-
async function showExporterVersion() {
|
|
83
|
-
console.clear();
|
|
84
|
-
const { version } = JSON.parse(await promises_1.default.readFile(node_path_1.default.resolve(__dirname, "../..", "package.json"), "utf-8"));
|
|
85
|
-
const logo = `\n${brush_1.brush.yellow(`Griddo Exporter ${version}`)}\n`;
|
|
86
|
-
console.log(logo);
|
|
87
|
-
}
|
|
88
|
-
function listSitesLog(title, sites) {
|
|
89
|
-
const maxline = Math.max(...sites.map((s) => s.name.length + (s.shouldBeUpdated ? 1 : 0) + s.id.toString().length));
|
|
90
|
-
const sitesStr = sites.map((s) => {
|
|
91
|
-
const shouldBeUpdated = s.shouldBeUpdated ? "*" : "";
|
|
92
|
-
const lineLen = s.name.length + shouldBeUpdated.length + s.id.toString().length;
|
|
93
|
-
const padding = " ".repeat(maxline - lineLen);
|
|
94
|
-
return `${brush_1.brush.bold(s.name)} ${brush_1.brush.dim(`(${s.id})`)} ${shouldBeUpdated} ${padding}${brush_1.brush.dim("-")} ${brush_1.brush.dim(s.slug)}`;
|
|
95
|
-
});
|
|
96
|
-
const sitesOutput = sitesStr.length > 0 ? `\n\n${sitesStr.join("\n")}` : brush_1.brush.dim("--none--\n");
|
|
97
|
-
console.log(`
|
|
98
|
-
${title} ${sitesOutput}`);
|
|
99
|
-
}
|
|
100
|
-
async function appendLogToFile(lineContent) {
|
|
101
|
-
if (!envs_1.GRIDDO_BUILD_LOGS) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const data = await (0, db_1.readDB)();
|
|
105
|
-
const logFilePath = node_path_1.default.join(data.paths.root, `render-detail-log.txt`);
|
|
106
|
-
try {
|
|
107
|
-
await promises_1.default.appendFile(logFilePath, `${lineContent.toString()}\n`);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
if (error instanceof Error) {
|
|
111
|
-
console.error("Error", error.message);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
console.error(error);
|
|
115
|
-
}
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=loggin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loggin.js","sourceRoot":"","sources":["../../exporter/utils/loggin.ts"],"names":[],"mappings":";;;;;QAgIC,eAAe;QACf,MAAM;QACN,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,mBAAmB;QACnB,UAAU;QACV,UAAU;AArIX,gEAAmC;AACnC,0DAA6B;AAE7B,4CAA2E;AAC3E,uCAAwC;AACxC,mCAAgC;AAEhC;;;GAGG;AACH,SAAS,UAAU,CAAC,GAAW,EAAE;IAChC,IAAI,0BAAmB,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,CAAC,aAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,aAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC;AAAA,CACD;AAED;;;;;GAKG;AACH,SAAS,MAAM,CAAC,WAAmB,EAAE,KAAK,GAAG,EAAE,EAAE,aAAa,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE;IACrF,MAAM,KAAK,GAAG,WAAW;SACvB,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ;SACpB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,sBAAsB;IACpD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9C,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,MAAM,aAAa,G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