@manuelp1345/graph-generator 1.2.9 → 1.2.11

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 (3) hide show
  1. package/dist/cli.js +6 -10
  2. package/package.json +1 -1
  3. package/src/cli.ts +8 -11
package/dist/cli.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -9,21 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
10
  };
10
11
  import { exec } from "child_process";
11
12
  import { promisify } from "util";
12
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
13
- if (command === "codegen") {
14
- runCodegen(); // Ejecuta la función de generación del esquema
15
- }
16
- else {
17
- console.log("Comando desconocido");
18
- }
13
+ // Promisify exec to use async/await
19
14
  const execPromise = promisify(exec);
15
+ // Función para ejecutar el comando de generación de código
20
16
  function runCodegen() {
21
17
  return __awaiter(this, void 0, void 0, function* () {
22
18
  try {
23
- const { stdout, stderr } = yield execPromise("npx graphql-codegen --config src/codegen.ts");
24
- console.log(stdout);
19
+ const { stdout, stderr } = yield execPromise("graphql-codegen --config dist/codegen.js");
20
+ console.log("stdout:", stdout);
25
21
  if (stderr) {
26
- console.error(stderr);
22
+ console.error("stderr:", stderr);
27
23
  }
28
24
  }
29
25
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuelp1345/graph-generator",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "generador de schema y types de graphql",
5
5
  "scripts": {
6
6
  "codegen": "graphql-codegen --config src/codegen.ts",
package/src/cli.ts CHANGED
@@ -1,24 +1,21 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { exec } from "child_process";
2
4
  import { promisify } from "util";
3
5
 
4
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
5
-
6
- if (command === "codegen") {
7
- runCodegen(); // Ejecuta la función de generación del esquema
8
- } else {
9
- console.log("Comando desconocido");
10
- }
11
-
6
+ // Promisify exec to use async/await
12
7
  const execPromise = promisify(exec);
13
8
 
9
+ // Función para ejecutar el comando de generación de código
14
10
  async function runCodegen() {
15
11
  try {
16
12
  const { stdout, stderr } = await execPromise(
17
- "npx graphql-codegen --config src/codegen.ts"
13
+ "graphql-codegen --config dist/codegen.js"
18
14
  );
19
- console.log(stdout);
15
+
16
+ console.log("stdout:", stdout);
20
17
  if (stderr) {
21
- console.error(stderr);
18
+ console.error("stderr:", stderr);
22
19
  }
23
20
  } catch (error) {
24
21
  console.error("Error executing graphql-codegen:", error);