@griddo/cx 11.7.12-rc.2 → 11.7.12-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logsAction = logsAction;
4
+ const envs_1 = require("../../../constants/envs");
4
5
  const core_utils_1 = require("../../../utils/core-utils");
5
6
  async function logsAction(context) {
6
7
  const { domain } = context;
7
- if (process.env.GRIDDO_BUILD_LOGS) {
8
+ if (envs_1.GRIDDO_BUILD_LOGS) {
8
9
  await (0, core_utils_1.saveDetailRenderLog)(domain);
9
10
  }
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../../exporter/adapters/gatsby/actions/logs.ts"],"names":[],"mappings":";;;AAGA,0DAAgE;AAEzD,KAAK,qBAAqB,OAA2B,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC;QACnC,MAAM,IAAA,gCAAmB,EAAC,MAAM,CAAC,CAAC;IACnC,CAAC;AAAA,CACD"}
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../../exporter/adapters/gatsby/actions/logs.ts"],"names":[],"mappings":";;;AAGA,kDAA4D;AAC5D,0DAAgE;AAEzD,KAAK,qBAAqB,OAA2B,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,IAAI,wBAAiB,EAAE,CAAC;QACvB,MAAM,IAAA,gCAAmB,EAAC,MAAM,CAAC,CAAC;IACnC,CAAC;AAAA,CACD"}
package/cli.mjs ADDED
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from "node:child_process";
4
+ import { dirname } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+
9
+ export const AVAILABLE_COMMANDS = [
10
+ {
11
+ name: "prepare-domains-render",
12
+ description: "Prepare domains for rendering",
13
+ requiresDomain: false,
14
+ script: "prepare-domains-render",
15
+ },
16
+ {
17
+ name: "prepare-assets-directory",
18
+ description: "Prepare assets directory (internal local only)",
19
+ requiresDomain: true,
20
+ script: "prepare-assets-directory",
21
+ },
22
+ {
23
+ name: "start-render",
24
+ description: "Start rendering for a domain",
25
+ requiresDomain: true,
26
+ script: "start-render",
27
+ },
28
+ {
29
+ name: "end-render",
30
+ description: "End rendering for a domain",
31
+ requiresDomain: true,
32
+ script: "end-render",
33
+ },
34
+ {
35
+ name: "upload-search-content",
36
+ description: "Upload search content for a domain",
37
+ requiresDomain: false,
38
+ script: "upload-search-content",
39
+ },
40
+ {
41
+ name: "reset-render",
42
+ description: "Reset render state",
43
+ requiresDomain: false,
44
+ script: "reset-render",
45
+ },
46
+ ];
47
+
48
+ function showHelp() {
49
+ console.log("Griddo CX CLI - Available commands:\n");
50
+
51
+ AVAILABLE_COMMANDS.forEach((cmd) => {
52
+ const domainArg = cmd.requiresDomain ? " <domain>" : "";
53
+ console.log(` ${cmd.name}${domainArg} - ${cmd.description}`);
54
+ });
55
+
56
+ console.log("\nUsage:");
57
+ console.log(" node exporter/commands/cli.mjs <command> [domain]");
58
+ console.log(" node exporter/commands/cli.mjs --help");
59
+ console.log("\nExamples:");
60
+ console.log(" node exporter/commands/cli.mjs start-render mydomain.com");
61
+ console.log(" node exporter/commands/cli.mjs get-design-system");
62
+ console.log(" node exporter/commands/cli.mjs --help");
63
+ }
64
+
65
+ function findCommand(commandName) {
66
+ return AVAILABLE_COMMANDS.find((cmd) => cmd.name === commandName);
67
+ }
68
+
69
+ function validateCommand(commandName, domain) {
70
+ const command = findCommand(commandName);
71
+
72
+ if (!command) {
73
+ console.error(`Error: Unknown command '${commandName}'`);
74
+ console.error("Use 'node exporter/commands/cli.mjs --help' to see available commands");
75
+ process.exit(1);
76
+ }
77
+
78
+ if (command.requiresDomain && !domain) {
79
+ console.error(`Error: Command '${commandName}' requires a domain argument`);
80
+ console.error(`Usage: node exporter/commands/cli.mjs ${commandName} <domain>`);
81
+ process.exit(1);
82
+ }
83
+
84
+ if (!command.requiresDomain && domain) {
85
+ console.warn(
86
+ `Warning: Command '${commandName}' doesn't require a domain, ignoring '${domain}'`,
87
+ );
88
+ }
89
+
90
+ return { command, domain: command.requiresDomain ? domain : undefined };
91
+ }
92
+
93
+ function executeCommand(command, domain) {
94
+ try {
95
+ const scriptPath = `${__dirname}/build/commands/${command.script}`;
96
+ const env = { ...process.env };
97
+
98
+ if (domain) {
99
+ execSync(`node ${scriptPath} ${domain}`, {
100
+ stdio: "inherit",
101
+ env,
102
+ cwd: process.cwd(),
103
+ });
104
+ } else {
105
+ execSync(`node ${scriptPath}`, {
106
+ stdio: "inherit",
107
+ env,
108
+ cwd: process.cwd(),
109
+ });
110
+ }
111
+ } catch (_error) {
112
+ console.error(`Error executing command ${command.name}`);
113
+ process.exit(1);
114
+ }
115
+ }
116
+
117
+ function main() {
118
+ const args = process.argv.slice(2);
119
+
120
+ // Show help if no arguments or --help flag
121
+ if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
122
+ showHelp();
123
+ return;
124
+ }
125
+
126
+ const commandName = args[0];
127
+ const domain = args[1];
128
+
129
+ // Validate command and arguments
130
+ const { command, domain: validatedDomain } = validateCommand(commandName, domain);
131
+
132
+ // Execute the command
133
+ executeCommand(command, validatedDomain);
134
+ }
135
+
136
+ main();
@@ -1,12 +1,13 @@
1
1
  import type { RenderContext } from "../shared/context";
2
2
  import type { SSG } from "../shared/types";
3
3
 
4
+ import { GRIDDO_BUILD_LOGS } from "../../../constants/envs";
4
5
  import { saveDetailRenderLog } from "../../../utils/core-utils";
5
6
 
6
7
  export async function logsAction(context: RenderContext<SSG>) {
7
8
  const { domain } = context;
8
9
 
9
- if (process.env.GRIDDO_BUILD_LOGS) {
10
+ if (GRIDDO_BUILD_LOGS) {
10
11
  await saveDetailRenderLog(domain);
11
12
  }
12
13
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/cx",
3
3
  "description": "Griddo SSG based on Gatsby",
4
- "version": "11.7.12-rc.2",
4
+ "version": "11.7.12-rc.4",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -74,10 +74,11 @@
74
74
  "tsconfig.commands.json",
75
75
  "tsconfig.exporter.json",
76
76
  "tsconfig.json",
77
- "plugins"
77
+ "plugins",
78
+ "cli.mjs"
78
79
  ],
79
80
  "publishConfig": {
80
81
  "access": "public"
81
82
  },
82
- "gitHead": "93a83dfbb0c050237289360129014587368a01a5"
83
+ "gitHead": "96f4a36f82c95316a44143e8eeec2b0d8fae9ed6"
83
84
  }