@manuelp1345/graph-generator 1.1.6 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cli.js +34 -0
- package/package.json +5 -1
- package/src/cli.ts +28 -0
package/dist/cli.js
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
import { exec } from "child_process";
|
11
|
+
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
|
+
}
|
19
|
+
const execPromise = promisify(exec);
|
20
|
+
function runCodegen() {
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
22
|
+
try {
|
23
|
+
const { stdout, stderr } = yield execPromise("graphql-codegen --config src/codegen.ts");
|
24
|
+
console.log(stdout);
|
25
|
+
if (stderr) {
|
26
|
+
console.error(stderr);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
catch (error) {
|
30
|
+
console.error("Error executing graphql-codegen:", error);
|
31
|
+
}
|
32
|
+
});
|
33
|
+
}
|
34
|
+
runCodegen();
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@manuelp1345/graph-generator",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.2.8",
|
4
4
|
"description": "generador de schema y types de graphql",
|
5
5
|
"scripts": {
|
6
6
|
"codegen": "graphql-codegen --config src/codegen.ts",
|
7
|
+
"start": "echo \"Error: no start specified\" && exit 1",
|
7
8
|
"build": "tsc",
|
8
9
|
"prepublishOnly": "npm run codegen && npm run build"
|
9
10
|
},
|
@@ -22,5 +23,8 @@
|
|
22
23
|
},
|
23
24
|
"devDependencies": {
|
24
25
|
"typescript": "^5.7.3"
|
26
|
+
},
|
27
|
+
"bin": {
|
28
|
+
"graph-generator": "dist/cli.js"
|
25
29
|
}
|
26
30
|
}
|
package/src/cli.ts
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
import { exec } from "child_process";
|
2
|
+
import { promisify } from "util";
|
3
|
+
|
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
|
+
|
12
|
+
const execPromise = promisify(exec);
|
13
|
+
|
14
|
+
async function runCodegen() {
|
15
|
+
try {
|
16
|
+
const { stdout, stderr } = await execPromise(
|
17
|
+
"graphql-codegen --config src/codegen.ts"
|
18
|
+
);
|
19
|
+
console.log(stdout);
|
20
|
+
if (stderr) {
|
21
|
+
console.error(stderr);
|
22
|
+
}
|
23
|
+
} catch (error) {
|
24
|
+
console.error("Error executing graphql-codegen:", error);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
runCodegen();
|