@manuelp1345/graph-generator 1.2.10 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/dist/cli.js +6 -10
  2. package/package.json +2 -2
  3. package/src/cli.ts +8 -11
package/dist/cli.js CHANGED
@@ -10,21 +10,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  import { exec } from "child_process";
12
12
  import { promisify } from "util";
13
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
14
- if (command === "codegen") {
15
- runCodegen(); // Ejecuta la función de generación del esquema
16
- }
17
- else {
18
- console.log("Comando desconocido");
19
- }
13
+ import path from "path";
14
+ // Promisify exec to use async/await
20
15
  const execPromise = promisify(exec);
16
+ // Función para ejecutar el comando de generación de código
21
17
  function runCodegen() {
22
18
  return __awaiter(this, void 0, void 0, function* () {
23
19
  try {
24
- const { stdout, stderr } = yield execPromise("npx graphql-codegen --config src/codegen.ts");
25
- console.log(stdout);
20
+ const { stdout, stderr } = yield execPromise(`graphql-codegen --config ${path.join(__dirname, "../dist/codegen.js")} `);
21
+ console.log("stdout:", stdout);
26
22
  if (stderr) {
27
- console.error(stderr);
23
+ console.error("stderr:", stderr);
28
24
  }
29
25
  }
30
26
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manuelp1345/graph-generator",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "description": "generador de schema y types de graphql",
5
5
  "scripts": {
6
6
  "codegen": "graphql-codegen --config src/codegen.ts",
@@ -8,7 +8,7 @@
8
8
  "build": "tsc",
9
9
  "prepublishOnly": "npm run codegen && npm run build"
10
10
  },
11
- "main": "dist/index.js",
11
+ "main": "src/index.ts",
12
12
  "type": "module",
13
13
  "keywords": [],
14
14
  "author": "manuelDev",
package/src/cli.ts CHANGED
@@ -1,25 +1,22 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  import { exec } from "child_process";
3
4
  import { promisify } from "util";
5
+ import path from "path";
4
6
 
5
- const command = process.argv[2]; // Esto puede ser el comando 'codegen'
6
-
7
- if (command === "codegen") {
8
- runCodegen(); // Ejecuta la función de generación del esquema
9
- } else {
10
- console.log("Comando desconocido");
11
- }
12
-
7
+ // Promisify exec to use async/await
13
8
  const execPromise = promisify(exec);
14
9
 
10
+ // Función para ejecutar el comando de generación de código
15
11
  async function runCodegen() {
16
12
  try {
17
13
  const { stdout, stderr } = await execPromise(
18
- "npx graphql-codegen --config src/codegen.ts"
14
+ `graphql-codegen --config ${path.join(__dirname, "../dist/codegen.js")} `
19
15
  );
20
- console.log(stdout);
16
+
17
+ console.log("stdout:", stdout);
21
18
  if (stderr) {
22
- console.error(stderr);
19
+ console.error("stderr:", stderr);
23
20
  }
24
21
  } catch (error) {
25
22
  console.error("Error executing graphql-codegen:", error);