nitro-graphql 2.0.0-beta.7 → 2.0.0-beta.70
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 +31 -1196
- package/dist/cli/adapter.d.mts +13 -0
- package/dist/cli/adapter.mjs +69 -0
- package/dist/cli/commands/build.d.mts +21 -0
- package/dist/cli/commands/build.mjs +52 -0
- package/dist/cli/commands/dev.d.mts +40 -0
- package/dist/cli/commands/dev.mjs +76 -0
- package/dist/cli/commands/generate.d.mts +25 -0
- package/dist/cli/commands/generate.mjs +198 -0
- package/dist/cli/commands/index.d.mts +5 -0
- package/dist/cli/commands/index.mjs +6 -0
- package/dist/cli/commands/init.d.mts +45 -0
- package/dist/cli/commands/init.mjs +195 -0
- package/dist/cli/commands/validate.d.mts +9 -0
- package/dist/cli/commands/validate.mjs +67 -0
- package/dist/cli/completions.d.mts +6 -0
- package/dist/cli/completions.mjs +34 -0
- package/dist/cli/config.d.mts +18 -0
- package/dist/cli/config.mjs +20 -0
- package/dist/cli/index.d.mts +26 -0
- package/dist/cli/index.mjs +317 -0
- package/dist/cli/server/debug-handler.d.mts +9 -0
- package/dist/cli/server/debug-handler.mjs +71 -0
- package/dist/cli/server/dev-server.d.mts +29 -0
- package/dist/cli/server/dev-server.mjs +64 -0
- package/dist/cli/server/graphql-handler.d.mts +21 -0
- package/dist/cli/server/graphql-handler.mjs +45 -0
- package/dist/cli/server/health-handler.d.mts +12 -0
- package/dist/cli/server/health-handler.mjs +30 -0
- package/dist/cli/server/loader.d.mts +33 -0
- package/dist/cli/server/loader.mjs +146 -0
- package/dist/cli/server/sandbox-handler.d.mts +12 -0
- package/dist/cli/server/sandbox-handler.mjs +19 -0
- package/dist/cli/server/watcher.d.mts +20 -0
- package/dist/cli/server/watcher.mjs +66 -0
- package/dist/cli/server/ws-handler.d.mts +28 -0
- package/dist/cli/server/ws-handler.mjs +50 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +3 -0
- package/dist/core/codegen/client.d.mts +42 -0
- package/dist/core/codegen/client.mjs +553 -0
- package/dist/core/codegen/document-loader.d.mts +9 -0
- package/dist/core/codegen/document-loader.mjs +18 -0
- package/dist/core/codegen/index.d.mts +8 -0
- package/dist/core/codegen/index.mjs +9 -0
- package/dist/core/codegen/plugin.d.mts +19 -0
- package/dist/core/codegen/plugin.mjs +30 -0
- package/dist/core/codegen/runtime.d.mts +19 -0
- package/dist/core/codegen/runtime.mjs +60 -0
- package/dist/core/codegen/schema-loader.d.mts +27 -0
- package/dist/core/codegen/schema-loader.mjs +128 -0
- package/dist/core/codegen/server.d.mts +27 -0
- package/dist/core/codegen/server.mjs +144 -0
- package/dist/core/codegen/validation.d.mts +17 -0
- package/dist/core/codegen/validation.mjs +35 -0
- package/dist/core/config.d.mts +45 -0
- package/dist/core/config.mjs +78 -0
- package/dist/core/constants.d.mts +188 -0
- package/dist/core/constants.mjs +210 -0
- package/dist/core/debug/index.d.mts +2 -0
- package/dist/core/debug/index.mjs +3 -0
- package/dist/core/debug/template.d.mts +52 -0
- package/dist/core/debug/template.mjs +383 -0
- package/dist/core/extend/index.d.mts +2 -0
- package/dist/core/extend/index.mjs +3 -0
- package/dist/core/extend/loader.d.mts +40 -0
- package/dist/core/extend/loader.mjs +198 -0
- package/dist/core/index.d.mts +37 -0
- package/dist/core/index.mjs +29 -0
- package/dist/core/manifest.d.mts +56 -0
- package/dist/core/manifest.mjs +102 -0
- package/dist/core/pubsub/index.d.mts +109 -0
- package/dist/core/pubsub/index.mjs +148 -0
- package/dist/core/scanning/ast-scanner.d.mts +27 -0
- package/dist/core/scanning/ast-scanner.mjs +116 -0
- package/dist/core/scanning/common.d.mts +25 -0
- package/dist/core/scanning/common.mjs +59 -0
- package/dist/core/scanning/directives.d.mts +13 -0
- package/dist/core/scanning/directives.mjs +29 -0
- package/dist/core/scanning/documents.d.mts +20 -0
- package/dist/core/scanning/documents.mjs +37 -0
- package/dist/core/scanning/index.d.mts +7 -0
- package/dist/core/scanning/index.mjs +8 -0
- package/dist/core/scanning/resolvers.d.mts +14 -0
- package/dist/core/scanning/resolvers.mjs +59 -0
- package/dist/core/scanning/schemas.d.mts +13 -0
- package/dist/core/scanning/schemas.mjs +52 -0
- package/dist/core/schema/builder.d.mts +59 -0
- package/dist/core/schema/builder.mjs +78 -0
- package/dist/core/schema/federation.d.mts +33 -0
- package/dist/core/schema/federation.mjs +40 -0
- package/dist/core/schema/index.d.mts +3 -0
- package/dist/core/schema/index.mjs +4 -0
- package/dist/core/server/index.d.mts +4 -0
- package/dist/core/server/index.mjs +4 -0
- package/dist/core/server/sandbox.d.mts +18 -0
- package/dist/core/server/sandbox.mjs +39 -0
- package/dist/core/server/types.d.mts +54 -0
- package/dist/core/server/yoga.d.mts +42 -0
- package/dist/core/server/yoga.mjs +89 -0
- package/dist/core/types/adapter.d.mts +57 -0
- package/dist/core/types/codegen.d.mts +136 -0
- package/dist/core/types/codegen.mjs +1 -0
- package/dist/core/types/config.d.mts +188 -0
- package/dist/core/types/config.mjs +1 -0
- package/dist/{utils/define.d.ts → core/types/define.d.mts} +2 -30
- package/dist/core/types/define.mjs +1 -0
- package/dist/core/types/index.d.mts +5 -0
- package/dist/core/types/index.mjs +1 -0
- package/dist/core/types/scanning.d.mts +64 -0
- package/dist/core/types/scanning.mjs +1 -0
- package/dist/{utils/directive-parser.d.ts → core/utils/directive-parser.d.mts} +18 -4
- package/dist/{utils/directive-parser.js → core/utils/directive-parser.mjs} +28 -34
- package/dist/core/utils/errors.d.mts +77 -0
- package/dist/core/utils/errors.mjs +93 -0
- package/dist/core/utils/file-io.d.mts +24 -0
- package/dist/core/utils/file-io.mjs +47 -0
- package/dist/core/utils/imports.d.mts +15 -0
- package/dist/core/utils/imports.mjs +25 -0
- package/dist/core/utils/index.d.mts +7 -0
- package/dist/core/utils/index.mjs +8 -0
- package/dist/core/utils/logger.d.mts +18 -0
- package/dist/core/utils/logger.mjs +38 -0
- package/dist/core/utils/ofetch-templates.d.mts +30 -0
- package/dist/core/utils/ofetch-templates.mjs +135 -0
- package/dist/core/utils/runtime.d.mts +74 -0
- package/dist/core/utils/runtime.mjs +111 -0
- package/dist/core/utils/subscribe-templates.d.mts +8 -0
- package/dist/core/utils/subscribe-templates.mjs +59 -0
- package/dist/core/validation/external-services.d.mts +11 -0
- package/dist/core/validation/external-services.mjs +33 -0
- package/dist/core/validation/index.d.mts +2 -0
- package/dist/core/validation/index.mjs +3 -0
- package/dist/core/watcher/index.d.mts +107 -0
- package/dist/core/watcher/index.mjs +141 -0
- package/dist/define.d.mts +294 -0
- package/dist/define.mjs +325 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +6 -0
- package/dist/nitro/adapter.d.mts +29 -0
- package/dist/nitro/adapter.mjs +93 -0
- package/dist/{utils/apollo.d.ts → nitro/apollo.d.mts} +3 -3
- package/dist/nitro/apollo.mjs +59 -0
- package/dist/nitro/codegen.d.mts +18 -0
- package/dist/nitro/codegen.mjs +173 -0
- package/dist/nitro/config.d.mts +50 -0
- package/dist/nitro/config.mjs +57 -0
- package/dist/nitro/index.d.mts +45 -0
- package/dist/nitro/index.mjs +65 -0
- package/dist/{utils/path-resolver.d.ts → nitro/paths.d.mts} +8 -25
- package/dist/{utils/path-resolver.js → nitro/paths.mjs} +14 -49
- package/dist/nitro/rollup.d.mts +6 -0
- package/dist/nitro/rollup.mjs +53 -0
- package/dist/nitro/routes/apollo-sandbox-script.d.mts +6 -0
- package/dist/nitro/routes/apollo-sandbox-script.mjs +14 -0
- package/dist/nitro/routes/apollo-server-ws.d.mts +15 -0
- package/dist/nitro/routes/apollo-server-ws.mjs +53 -0
- package/dist/nitro/routes/apollo-server.d.mts +6 -0
- package/dist/nitro/routes/apollo-server.mjs +71 -0
- package/dist/{routes/debug.d.ts → nitro/routes/debug.d.mts} +12 -19
- package/dist/nitro/routes/debug.mjs +102 -0
- package/dist/nitro/routes/graphql-yoga-ws.d.mts +12 -0
- package/dist/nitro/routes/graphql-yoga-ws.mjs +53 -0
- package/dist/nitro/routes/graphql-yoga.d.mts +12 -0
- package/dist/nitro/routes/graphql-yoga.mjs +41 -0
- package/dist/nitro/routes/health.d.mts +10 -0
- package/dist/{routes/health.js → nitro/routes/health.mjs} +4 -3
- package/dist/nitro/setup/extend-loader.d.mts +16 -0
- package/dist/nitro/setup/extend-loader.mjs +82 -0
- package/dist/nitro/setup/file-watcher.d.mts +18 -0
- package/dist/nitro/setup/file-watcher.mjs +63 -0
- package/dist/nitro/setup/logging.d.mts +16 -0
- package/dist/nitro/setup/logging.mjs +66 -0
- package/dist/nitro/setup/rollup-integration.d.mts +24 -0
- package/dist/nitro/setup/rollup-integration.mjs +63 -0
- package/dist/nitro/setup/routes.d.mts +13 -0
- package/dist/nitro/setup/routes.mjs +71 -0
- package/dist/nitro/setup/scanner.d.mts +59 -0
- package/dist/nitro/setup/scanner.mjs +120 -0
- package/dist/nitro/setup/ts-config.d.mts +10 -0
- package/dist/nitro/setup/ts-config.mjs +69 -0
- package/dist/nitro/setup.d.mts +11 -0
- package/dist/nitro/setup.mjs +191 -0
- package/dist/nitro/types.d.mts +549 -0
- package/dist/nitro/types.mjs +1 -0
- package/dist/nitro/virtual/generators.d.mts +38 -0
- package/dist/nitro/virtual/generators.mjs +192 -0
- package/dist/nitro/virtual/stubs.d.mts +21 -0
- package/dist/nitro/virtual/stubs.mjs +32 -0
- package/dist/{ecosystem/nuxt.d.ts → nuxt.d.mts} +1 -1
- package/dist/nuxt.mjs +112 -0
- package/dist/{graphql/server.d.ts → stubs/index.d.mts} +5 -1
- package/dist/stubs/index.mjs +1 -0
- package/dist/subscribe/index.d.mts +78 -0
- package/dist/subscribe/index.mjs +206 -0
- package/native/index.d.ts +20 -0
- package/native/index.js +585 -0
- package/package.json +201 -111
- package/dist/ecosystem/nuxt.js +0 -67
- package/dist/graphql/index.d.ts +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -318
- package/dist/rollup.js +0 -277
- package/dist/routes/apollo-server.d.ts +0 -6
- package/dist/routes/apollo-server.js +0 -89
- package/dist/routes/debug.js +0 -449
- package/dist/routes/graphql-yoga.d.ts +0 -6
- package/dist/routes/graphql-yoga.js +0 -91
- package/dist/routes/health.d.ts +0 -10
- package/dist/types/index.d.ts +0 -246
- package/dist/types/standard-schema.d.ts +0 -59
- package/dist/utils/apollo.js +0 -61
- package/dist/utils/client-codegen.d.ts +0 -38
- package/dist/utils/client-codegen.js +0 -290
- package/dist/utils/define.js +0 -57
- package/dist/utils/file-generator.d.ts +0 -37
- package/dist/utils/file-generator.js +0 -72
- package/dist/utils/index.d.ts +0 -39
- package/dist/utils/index.js +0 -278
- package/dist/utils/server-codegen.d.ts +0 -7
- package/dist/utils/server-codegen.js +0 -136
- package/dist/utils/type-generation.d.ts +0 -7
- package/dist/utils/type-generation.js +0 -360
- package/dist/virtual/debug-info.d.ts +0 -9
- package/dist/virtual/debug-info.js +0 -26
- package/dist/virtual/graphql-config.d.ts +0 -9
- package/dist/virtual/graphql-config.js +0 -10
- package/dist/virtual/module-config.d.ts +0 -9
- package/dist/virtual/module-config.js +0 -10
- package/dist/virtual/server-directives.d.ts +0 -11
- package/dist/virtual/server-directives.js +0 -10
- package/dist/virtual/server-resolvers.d.ts +0 -11
- package/dist/virtual/server-resolvers.js +0 -10
- package/dist/virtual/server-schemas.d.ts +0 -11
- package/dist/virtual/server-schemas.js +0 -10
- package/dist/vite.d.ts +0 -25
- package/dist/vite.js +0 -40
- /package/dist/{graphql/index.js → core/server/types.mjs} +0 -0
- /package/dist/{graphql/server.js → core/types/adapter.mjs} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
+
import consola from "consola";
|
|
3
|
+
import { basename, join, relative, resolve } from "pathe";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { downloadTemplate } from "giget";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/commands/init.ts
|
|
8
|
+
const logger = consola.withTag(LOG_TAG);
|
|
9
|
+
/**
|
|
10
|
+
* Available templates from the examples directory
|
|
11
|
+
*/
|
|
12
|
+
const AVAILABLE_TEMPLATES = [
|
|
13
|
+
{
|
|
14
|
+
name: "nitro",
|
|
15
|
+
description: "Minimal Nitro + GraphQL starter"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "drizzle-orm",
|
|
19
|
+
description: "Nitro + GraphQL + Drizzle ORM with PostgreSQL"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "vite",
|
|
23
|
+
description: "Vite + Nitro GraphQL integration"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "vite-react",
|
|
27
|
+
description: "Vite + React + Nitro GraphQL"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "vite-vue",
|
|
31
|
+
description: "Vite + Vue + Nitro GraphQL"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "better-auth",
|
|
35
|
+
description: "Nitro + GraphQL + Better Auth integration"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Default GitHub template source
|
|
40
|
+
*/
|
|
41
|
+
const DEFAULT_TEMPLATE_REGISTRY = "github:productdevbook/nitro-graphql/examples";
|
|
42
|
+
/**
|
|
43
|
+
* List available templates
|
|
44
|
+
*/
|
|
45
|
+
function listTemplates() {
|
|
46
|
+
logger.info("Available templates:\n");
|
|
47
|
+
for (const template of AVAILABLE_TEMPLATES) console.log(` ${template.name.padEnd(15)} - ${template.description}`);
|
|
48
|
+
console.log("\nUsage:");
|
|
49
|
+
console.log(" nitro-graphql init <project-name> --template <template-name>");
|
|
50
|
+
console.log(" nitro-graphql init my-app -t drizzle-orm");
|
|
51
|
+
console.log("\nCustom templates:");
|
|
52
|
+
console.log(" nitro-graphql init my-app -t gh:user/repo");
|
|
53
|
+
console.log(" nitro-graphql init my-app -t github:user/repo/subdir");
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize project from template
|
|
57
|
+
*/
|
|
58
|
+
async function initFromTemplate(projectName, templateName, options = {}) {
|
|
59
|
+
const { force, cwd = process.cwd() } = options;
|
|
60
|
+
const targetDir = resolve(cwd, projectName);
|
|
61
|
+
if (existsSync(targetDir) && !force) {
|
|
62
|
+
logger.error(`Directory "${projectName}" already exists. Use --force to overwrite.`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
let templateSource;
|
|
66
|
+
if (templateName.includes(":") || templateName.includes("/")) templateSource = templateName;
|
|
67
|
+
else {
|
|
68
|
+
if (!AVAILABLE_TEMPLATES.find((t) => t.name === templateName)) {
|
|
69
|
+
logger.error(`Unknown template: "${templateName}"`);
|
|
70
|
+
logger.info("Use --list to see available templates");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
templateSource = `${DEFAULT_TEMPLATE_REGISTRY}/${templateName}`;
|
|
74
|
+
}
|
|
75
|
+
logger.info(`Downloading template: ${templateName}`);
|
|
76
|
+
logger.debug(`Source: ${templateSource}`);
|
|
77
|
+
try {
|
|
78
|
+
const result = await downloadTemplate(templateSource, {
|
|
79
|
+
dir: targetDir,
|
|
80
|
+
force
|
|
81
|
+
});
|
|
82
|
+
logger.success(`Template downloaded to: ${result.dir}`);
|
|
83
|
+
const packageJsonPath = join(targetDir, "package.json");
|
|
84
|
+
if (existsSync(packageJsonPath)) try {
|
|
85
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
86
|
+
packageJson.name = basename(projectName).replace(/[^a-z0-9-]/gi, "-").replace(/^-+|-+$/g, "").toLowerCase() || "my-graphql-app";
|
|
87
|
+
writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, "utf-8");
|
|
88
|
+
logger.debug(`Updated package.json name to: ${packageJson.name}`);
|
|
89
|
+
} catch {
|
|
90
|
+
logger.warn("Could not update package.json name");
|
|
91
|
+
}
|
|
92
|
+
console.log("");
|
|
93
|
+
logger.info("Next steps:");
|
|
94
|
+
console.log(` cd ${projectName}`);
|
|
95
|
+
console.log(" pnpm install");
|
|
96
|
+
console.log(" pnpm dev");
|
|
97
|
+
console.log("");
|
|
98
|
+
} catch (error) {
|
|
99
|
+
logger.error("Failed to download template:", error);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Initialize project structure (basic scaffolding)
|
|
105
|
+
*/
|
|
106
|
+
async function init(ctx, options = {}) {
|
|
107
|
+
const { force } = options;
|
|
108
|
+
const dirs = [ctx.config.serverDir, ctx.config.clientDir];
|
|
109
|
+
for (const dir of dirs) if (!existsSync(dir)) {
|
|
110
|
+
mkdirSync(dir, { recursive: true });
|
|
111
|
+
logger.info(`Created directory: ${dir}`);
|
|
112
|
+
}
|
|
113
|
+
const configPath = join(ctx.config.rootDir, "nitro-graphql.config.ts");
|
|
114
|
+
if (force || !existsSync(configPath)) {
|
|
115
|
+
const relativeServerDir = relative(ctx.config.rootDir, ctx.config.serverDir) || "server/graphql";
|
|
116
|
+
const relativeClientDir = relative(ctx.config.rootDir, ctx.config.clientDir) || "graphql";
|
|
117
|
+
writeFileSync(configPath, `import { defineConfig } from 'nitro-graphql/cli'
|
|
118
|
+
|
|
119
|
+
export default defineConfig({
|
|
120
|
+
framework: '${ctx.config.framework}',
|
|
121
|
+
serverDir: './${relativeServerDir}',
|
|
122
|
+
clientDir: './${relativeClientDir}',
|
|
123
|
+
})
|
|
124
|
+
`, "utf-8");
|
|
125
|
+
logger.success(`Created config file: ${configPath}`);
|
|
126
|
+
} else logger.info(`Config file already exists: ${configPath}`);
|
|
127
|
+
const tsconfigPath = join(ctx.config.rootDir, "tsconfig.json");
|
|
128
|
+
if (force || !existsSync(tsconfigPath)) {
|
|
129
|
+
const relativeBuildDir = relative(ctx.config.rootDir, ctx.config.buildDir) || ".graphql";
|
|
130
|
+
writeFileSync(tsconfigPath, `{
|
|
131
|
+
"compilerOptions": {
|
|
132
|
+
"target": "ESNext",
|
|
133
|
+
"module": "ESNext",
|
|
134
|
+
"moduleResolution": "Bundler",
|
|
135
|
+
"resolveJsonModule": true,
|
|
136
|
+
"allowSyntheticDefaultImports": true,
|
|
137
|
+
"strict": true,
|
|
138
|
+
"noEmit": true,
|
|
139
|
+
"skipLibCheck": true,
|
|
140
|
+
"forceConsistentCasingInFileNames": true,
|
|
141
|
+
"paths": {
|
|
142
|
+
"#graphql/server": ["./${relativeBuildDir}/types/nitro-graphql-server.d.ts"],
|
|
143
|
+
"#graphql/client": ["./${relativeBuildDir}/types/nitro-graphql-client.d.ts"],
|
|
144
|
+
"#graphql/schema": ["./${relative(ctx.config.rootDir, ctx.config.serverDir) || "server/graphql"}/schema.ts"]
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"include": ["**/*.ts"],
|
|
148
|
+
"exclude": ["node_modules", "${relativeBuildDir}"]
|
|
149
|
+
}
|
|
150
|
+
`, "utf-8");
|
|
151
|
+
logger.success(`Created tsconfig.json: ${tsconfigPath}`);
|
|
152
|
+
} else logger.info(`tsconfig.json already exists: ${tsconfigPath}`);
|
|
153
|
+
const schemaPath = join(ctx.config.serverDir, "schema.graphql");
|
|
154
|
+
if (force || !existsSync(schemaPath)) {
|
|
155
|
+
writeFileSync(schemaPath, `# GraphQL Schema
|
|
156
|
+
# Add your type definitions here
|
|
157
|
+
|
|
158
|
+
type Query {
|
|
159
|
+
hello: String!
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
type Mutation {
|
|
163
|
+
# Add your mutations here
|
|
164
|
+
_empty: String
|
|
165
|
+
}
|
|
166
|
+
`, "utf-8");
|
|
167
|
+
logger.success(`Created example schema: ${schemaPath}`);
|
|
168
|
+
} else logger.info(`Schema file already exists: ${schemaPath}`);
|
|
169
|
+
const resolverPath = join(ctx.config.serverDir, "hello.resolver.ts");
|
|
170
|
+
if (force || !existsSync(resolverPath)) {
|
|
171
|
+
writeFileSync(resolverPath, `import { defineQuery } from 'nitro-graphql/define'
|
|
172
|
+
|
|
173
|
+
export const helloQueries = defineQuery({
|
|
174
|
+
hello: () => 'Hello, world!',
|
|
175
|
+
})
|
|
176
|
+
`, "utf-8");
|
|
177
|
+
logger.success(`Created example resolver: ${resolverPath}`);
|
|
178
|
+
} else logger.info(`Resolver file already exists: ${resolverPath}`);
|
|
179
|
+
const queryPath = join(ctx.config.clientDir, "hello.graphql");
|
|
180
|
+
if (force || !existsSync(queryPath)) {
|
|
181
|
+
writeFileSync(queryPath, `query Hello {
|
|
182
|
+
hello
|
|
183
|
+
}
|
|
184
|
+
`, "utf-8");
|
|
185
|
+
logger.success(`Created example query: ${queryPath}`);
|
|
186
|
+
} else logger.info(`Query file already exists: ${queryPath}`);
|
|
187
|
+
logger.info("");
|
|
188
|
+
logger.info("Next steps:");
|
|
189
|
+
logger.info(" 1. Run \"nitro-graphql generate\" to generate types");
|
|
190
|
+
logger.info(" 2. Add more schemas to your server directory");
|
|
191
|
+
logger.info(" 3. Add more queries/mutations to your client directory");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//#endregion
|
|
195
|
+
export { AVAILABLE_TEMPLATES, init, initFromTemplate, listTemplates };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LOG_TAG } from "../../core/constants.mjs";
|
|
2
|
+
import { validateNoDuplicateTypes } from "../../core/codegen/validation.mjs";
|
|
3
|
+
import { scanSchemasCore } from "../../core/scanning/schemas.mjs";
|
|
4
|
+
import consola from "consola";
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/commands/validate.ts
|
|
8
|
+
const logger = consola.withTag(LOG_TAG);
|
|
9
|
+
/**
|
|
10
|
+
* Validate GraphQL schemas
|
|
11
|
+
*/
|
|
12
|
+
async function validate(ctx) {
|
|
13
|
+
const schemaResult = await scanSchemasCore({
|
|
14
|
+
rootDir: ctx.config.rootDir,
|
|
15
|
+
serverDir: ctx.config.serverDir,
|
|
16
|
+
clientDir: ctx.config.clientDir,
|
|
17
|
+
ignorePatterns: ctx.config.ignore,
|
|
18
|
+
isDev: false,
|
|
19
|
+
logger: {
|
|
20
|
+
info: (msg, ...args) => logger.info(msg, ...args),
|
|
21
|
+
warn: (msg, ...args) => logger.warn(msg, ...args),
|
|
22
|
+
error: (msg, ...args) => logger.error(msg, ...args),
|
|
23
|
+
success: (msg, ...args) => logger.success(msg, ...args),
|
|
24
|
+
debug: (msg, ...args) => logger.debug(msg, ...args)
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (schemaResult.errors.length > 0) {
|
|
28
|
+
for (const error of schemaResult.errors) logger.error(error);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (schemaResult.items.length === 0) {
|
|
32
|
+
logger.warn("No GraphQL schemas found to validate");
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const schemaContents = [];
|
|
36
|
+
for (const schemaPath of schemaResult.items) {
|
|
37
|
+
if (!existsSync(schemaPath)) {
|
|
38
|
+
logger.error(`Schema file not found: ${schemaPath}`);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const content = readFileSync(schemaPath, "utf-8");
|
|
43
|
+
schemaContents.push(content);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
logger.error(`Failed to read schema file ${schemaPath}:`, error);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!validateNoDuplicateTypes(schemaResult.items, schemaContents)) {
|
|
50
|
+
logger.error("Schema validation failed");
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const { buildSchema, print } = await import("graphql");
|
|
55
|
+
const { mergeTypeDefs } = await import("@graphql-tools/merge");
|
|
56
|
+
const mergedTypeDefs = mergeTypeDefs(schemaContents);
|
|
57
|
+
buildSchema(typeof mergedTypeDefs === "string" ? mergedTypeDefs : print(mergedTypeDefs));
|
|
58
|
+
logger.info(`Validated ${schemaResult.items.length} schema file(s)`);
|
|
59
|
+
return true;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
logger.error("Schema syntax error:", error);
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { validate };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AVAILABLE_TEMPLATES } from "./commands/init.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/completions.ts
|
|
4
|
+
async function initCompletions(command) {
|
|
5
|
+
const { default: tab } = await import("@bomb.sh/tab/citty");
|
|
6
|
+
await tab(command, { subCommands: {
|
|
7
|
+
"init": { options: {
|
|
8
|
+
template: (complete) => {
|
|
9
|
+
for (const template of AVAILABLE_TEMPLATES) complete(template.name, template.description);
|
|
10
|
+
complete("gh:", "GitHub shorthand (gh:user/repo)");
|
|
11
|
+
complete("github:", "GitHub template (github:user/repo/path)");
|
|
12
|
+
complete("gitlab:", "GitLab template (gitlab:user/repo)");
|
|
13
|
+
},
|
|
14
|
+
cwd: (complete) => {
|
|
15
|
+
complete(".", "Current directory");
|
|
16
|
+
}
|
|
17
|
+
} },
|
|
18
|
+
"generate": { options: { cwd: (complete) => {
|
|
19
|
+
complete(".", "Current directory");
|
|
20
|
+
} } },
|
|
21
|
+
"generate:server": { options: { cwd: (complete) => {
|
|
22
|
+
complete(".", "Current directory");
|
|
23
|
+
} } },
|
|
24
|
+
"generate:client": { options: { cwd: (complete) => {
|
|
25
|
+
complete(".", "Current directory");
|
|
26
|
+
} } },
|
|
27
|
+
"validate": { options: { cwd: (complete) => {
|
|
28
|
+
complete(".", "Current directory");
|
|
29
|
+
} } }
|
|
30
|
+
} });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { initCompletions };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NitroGraphQLOptions } from "../nitro/types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/config.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* CLI configuration options
|
|
6
|
+
* Now unified with NitroGraphQLOptions - all options available in both CLI and module context
|
|
7
|
+
*/
|
|
8
|
+
type CLIConfig = NitroGraphQLOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Define CLI configuration with type safety
|
|
11
|
+
*/
|
|
12
|
+
declare function defineConfig(config: CLIConfig): CLIConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Default CLI configuration values
|
|
15
|
+
*/
|
|
16
|
+
declare const DEFAULT_CLI_CONFIG: CLIConfig;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CLIConfig, DEFAULT_CLI_CONFIG, defineConfig };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/cli/config.ts
|
|
2
|
+
/**
|
|
3
|
+
* Define CLI configuration with type safety
|
|
4
|
+
*/
|
|
5
|
+
function defineConfig(config) {
|
|
6
|
+
return config;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Default CLI configuration values
|
|
10
|
+
*/
|
|
11
|
+
const DEFAULT_CLI_CONFIG = {
|
|
12
|
+
framework: "graphql-yoga",
|
|
13
|
+
serverDir: "server/graphql",
|
|
14
|
+
clientDir: "graphql",
|
|
15
|
+
buildDir: ".graphql",
|
|
16
|
+
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { DEFAULT_CLI_CONFIG, defineConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NitroGraphQLOptions } from "../nitro/types.mjs";
|
|
2
|
+
import { CLIConfig, defineConfig } from "./config.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/index.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* CLI context with resolved configuration
|
|
7
|
+
* Uses NitroGraphQLOptions directly as CLI and module options are now unified
|
|
8
|
+
*/
|
|
9
|
+
interface CLIContext {
|
|
10
|
+
config: Required<Pick<NitroGraphQLOptions, 'rootDir' | 'buildDir' | 'serverDir' | 'clientDir' | 'typesDir' | 'framework'>> & {
|
|
11
|
+
ignore: string[];
|
|
12
|
+
} & NitroGraphQLOptions;
|
|
13
|
+
cwd: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load CLI configuration from file or defaults
|
|
17
|
+
*/
|
|
18
|
+
declare function loadConfig(cwd?: string): Promise<NitroGraphQLOptions>;
|
|
19
|
+
/**
|
|
20
|
+
* Create CLI context from configuration
|
|
21
|
+
*/
|
|
22
|
+
declare function createCLIContext(options?: {
|
|
23
|
+
cwd?: string;
|
|
24
|
+
}): Promise<CLIContext>;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { type CLIConfig, CLIContext, createCLIContext, defineConfig, loadConfig };
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { DEFAULT_CLI_CONFIG, defineConfig } from "./config.mjs";
|
|
3
|
+
import { LOG_TAG } from "../core/constants.mjs";
|
|
4
|
+
import { existsSync_, exit, getCwd } from "../core/utils/runtime.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { resolve } from "pathe";
|
|
7
|
+
import { defineCommand, runMain } from "citty";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/index.ts
|
|
10
|
+
const logger = consola.withTag(LOG_TAG);
|
|
11
|
+
/**
|
|
12
|
+
* Load CLI configuration from file or defaults
|
|
13
|
+
*/
|
|
14
|
+
async function loadConfig(cwd = getCwd()) {
|
|
15
|
+
for (const file of [
|
|
16
|
+
"nitro-graphql.config.ts",
|
|
17
|
+
"nitro-graphql.config.js",
|
|
18
|
+
"nitro-graphql.config.mjs",
|
|
19
|
+
"graphql.config.ts"
|
|
20
|
+
]) {
|
|
21
|
+
const configPath = resolve(cwd, file);
|
|
22
|
+
if (existsSync_(configPath)) try {
|
|
23
|
+
const module = await import(configPath);
|
|
24
|
+
const config = module.default || module;
|
|
25
|
+
logger.info(`Loaded config from ${file}`);
|
|
26
|
+
return {
|
|
27
|
+
...DEFAULT_CLI_CONFIG,
|
|
28
|
+
...config
|
|
29
|
+
};
|
|
30
|
+
} catch (error) {
|
|
31
|
+
logger.warn(`Failed to load config from ${file}:`, error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
logger.debug("Using default configuration");
|
|
35
|
+
return { ...DEFAULT_CLI_CONFIG };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create CLI context from configuration
|
|
39
|
+
*/
|
|
40
|
+
async function createCLIContext(options = {}) {
|
|
41
|
+
const cwd = options.cwd || getCwd();
|
|
42
|
+
const config = await loadConfig(cwd);
|
|
43
|
+
const rootDir = config.rootDir ? resolve(cwd, config.rootDir) : cwd;
|
|
44
|
+
const buildDir = config.buildDir ? resolve(rootDir, config.buildDir) : resolve(rootDir, ".nitro-graphql");
|
|
45
|
+
const serverDir = config.serverDir ? resolve(rootDir, config.serverDir) : resolve(rootDir, "server/graphql");
|
|
46
|
+
const clientDir = config.clientDir ? resolve(rootDir, config.clientDir) : resolve(rootDir, "graphql");
|
|
47
|
+
const typesDir = config.typesDir ? resolve(rootDir, config.typesDir) : resolve(buildDir, "types");
|
|
48
|
+
return {
|
|
49
|
+
cwd,
|
|
50
|
+
config: {
|
|
51
|
+
...config,
|
|
52
|
+
rootDir,
|
|
53
|
+
buildDir,
|
|
54
|
+
serverDir,
|
|
55
|
+
clientDir,
|
|
56
|
+
typesDir,
|
|
57
|
+
framework: config.framework || "graphql-yoga",
|
|
58
|
+
ignore: config.ignore || ["**/node_modules/**", "**/dist/**"]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const generateCommand = defineCommand({
|
|
63
|
+
meta: {
|
|
64
|
+
name: "generate",
|
|
65
|
+
description: "Generate all GraphQL types"
|
|
66
|
+
},
|
|
67
|
+
args: {
|
|
68
|
+
cwd: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "Set working directory"
|
|
71
|
+
},
|
|
72
|
+
silent: {
|
|
73
|
+
type: "boolean",
|
|
74
|
+
alias: "s",
|
|
75
|
+
description: "Suppress output"
|
|
76
|
+
},
|
|
77
|
+
watch: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
alias: "w",
|
|
80
|
+
description: "Watch mode"
|
|
81
|
+
},
|
|
82
|
+
runtime: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
alias: "r",
|
|
85
|
+
description: "Generate runtime files (resolvers.ts, schema.ts)"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
async run({ args }) {
|
|
89
|
+
const ctx = await createCLIContext({ cwd: args.cwd });
|
|
90
|
+
const silent = Boolean(args.silent);
|
|
91
|
+
const watch = Boolean(args.watch);
|
|
92
|
+
const runtime = Boolean(args.runtime) || Boolean(ctx.config.runtime);
|
|
93
|
+
if (!silent) logger.info("Generating GraphQL types...");
|
|
94
|
+
const { generateAll } = await import("./commands/generate.mjs");
|
|
95
|
+
await generateAll(ctx, {
|
|
96
|
+
silent,
|
|
97
|
+
watch,
|
|
98
|
+
runtime
|
|
99
|
+
});
|
|
100
|
+
if (!silent) logger.success("Type generation complete!");
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const generateServerCommand = defineCommand({
|
|
104
|
+
meta: {
|
|
105
|
+
name: "generate:server",
|
|
106
|
+
description: "Generate server types only"
|
|
107
|
+
},
|
|
108
|
+
args: {
|
|
109
|
+
cwd: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "Set working directory"
|
|
112
|
+
},
|
|
113
|
+
silent: {
|
|
114
|
+
type: "boolean",
|
|
115
|
+
alias: "s",
|
|
116
|
+
description: "Suppress output"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async run({ args }) {
|
|
120
|
+
const ctx = await createCLIContext({ cwd: args.cwd });
|
|
121
|
+
const silent = Boolean(args.silent);
|
|
122
|
+
if (!silent) logger.info("Generating server types...");
|
|
123
|
+
const { generateServer } = await import("./commands/generate.mjs");
|
|
124
|
+
await generateServer(ctx, { silent });
|
|
125
|
+
if (!silent) logger.success("Server type generation complete!");
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const generateClientCommand = defineCommand({
|
|
129
|
+
meta: {
|
|
130
|
+
name: "generate:client",
|
|
131
|
+
description: "Generate client types only"
|
|
132
|
+
},
|
|
133
|
+
args: {
|
|
134
|
+
cwd: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "Set working directory"
|
|
137
|
+
},
|
|
138
|
+
silent: {
|
|
139
|
+
type: "boolean",
|
|
140
|
+
alias: "s",
|
|
141
|
+
description: "Suppress output"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
async run({ args }) {
|
|
145
|
+
const ctx = await createCLIContext({ cwd: args.cwd });
|
|
146
|
+
const silent = Boolean(args.silent);
|
|
147
|
+
if (!silent) logger.info("Generating client types...");
|
|
148
|
+
const { generateClient } = await import("./commands/generate.mjs");
|
|
149
|
+
await generateClient(ctx, { silent });
|
|
150
|
+
if (!silent) logger.success("Client type generation complete!");
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const validateCommand = defineCommand({
|
|
154
|
+
meta: {
|
|
155
|
+
name: "validate",
|
|
156
|
+
description: "Validate GraphQL schemas"
|
|
157
|
+
},
|
|
158
|
+
args: { cwd: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "Set working directory"
|
|
161
|
+
} },
|
|
162
|
+
async run({ args }) {
|
|
163
|
+
const ctx = await createCLIContext({ cwd: args.cwd });
|
|
164
|
+
logger.info("Validating GraphQL schemas...");
|
|
165
|
+
const { validate } = await import("./commands/validate.mjs");
|
|
166
|
+
if (await validate(ctx)) logger.success("Schema validation passed!");
|
|
167
|
+
else {
|
|
168
|
+
logger.error("Schema validation failed!");
|
|
169
|
+
exit(1);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const initCommand = defineCommand({
|
|
174
|
+
meta: {
|
|
175
|
+
name: "init",
|
|
176
|
+
description: "Initialize project structure or download a template"
|
|
177
|
+
},
|
|
178
|
+
args: {
|
|
179
|
+
projectName: {
|
|
180
|
+
type: "positional",
|
|
181
|
+
description: "Project name (directory to create)",
|
|
182
|
+
required: false
|
|
183
|
+
},
|
|
184
|
+
cwd: {
|
|
185
|
+
type: "string",
|
|
186
|
+
description: "Set working directory"
|
|
187
|
+
},
|
|
188
|
+
force: {
|
|
189
|
+
type: "boolean",
|
|
190
|
+
alias: "f",
|
|
191
|
+
description: "Force overwrite existing files"
|
|
192
|
+
},
|
|
193
|
+
template: {
|
|
194
|
+
type: "string",
|
|
195
|
+
alias: "t",
|
|
196
|
+
description: "Template to use (e.g., drizzle-orm, vite-react)"
|
|
197
|
+
},
|
|
198
|
+
list: {
|
|
199
|
+
type: "boolean",
|
|
200
|
+
alias: "l",
|
|
201
|
+
description: "List available templates"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
async run({ args }) {
|
|
205
|
+
const { listTemplates, initFromTemplate, init } = await import("./commands/init.mjs");
|
|
206
|
+
if (args.list) {
|
|
207
|
+
listTemplates();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (args.template) {
|
|
211
|
+
const projectName = args.projectName || args.template;
|
|
212
|
+
logger.info(`Creating project "${projectName}" from template "${args.template}"...`);
|
|
213
|
+
await initFromTemplate(projectName, args.template, {
|
|
214
|
+
force: Boolean(args.force),
|
|
215
|
+
cwd: args.cwd || getCwd()
|
|
216
|
+
});
|
|
217
|
+
logger.success("Project created successfully!");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const ctx = await createCLIContext({ cwd: args.cwd });
|
|
221
|
+
logger.info("Initializing nitro-graphql project...");
|
|
222
|
+
await init(ctx, { force: Boolean(args.force) });
|
|
223
|
+
logger.success("Project initialized!");
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
const buildCmd = defineCommand({
|
|
227
|
+
meta: {
|
|
228
|
+
name: "build",
|
|
229
|
+
description: "Build GraphQL types for production"
|
|
230
|
+
},
|
|
231
|
+
args: {
|
|
232
|
+
cwd: {
|
|
233
|
+
type: "string",
|
|
234
|
+
description: "Working directory"
|
|
235
|
+
},
|
|
236
|
+
skipValidation: {
|
|
237
|
+
type: "boolean",
|
|
238
|
+
description: "Skip schema validation",
|
|
239
|
+
default: false
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
async run(ctx) {
|
|
243
|
+
const { buildCommand } = await import("./commands/build.mjs");
|
|
244
|
+
return buildCommand.run(ctx);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
const devCommand = defineCommand({
|
|
248
|
+
meta: {
|
|
249
|
+
name: "dev",
|
|
250
|
+
description: "Start GraphQL development server"
|
|
251
|
+
},
|
|
252
|
+
args: {
|
|
253
|
+
cwd: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "Working directory"
|
|
256
|
+
},
|
|
257
|
+
port: {
|
|
258
|
+
type: "string",
|
|
259
|
+
alias: "p",
|
|
260
|
+
default: "4000",
|
|
261
|
+
description: "Server port"
|
|
262
|
+
},
|
|
263
|
+
host: {
|
|
264
|
+
type: "string",
|
|
265
|
+
alias: "H",
|
|
266
|
+
default: "localhost",
|
|
267
|
+
description: "Server host"
|
|
268
|
+
},
|
|
269
|
+
open: {
|
|
270
|
+
type: "boolean",
|
|
271
|
+
alias: "o",
|
|
272
|
+
description: "Open browser"
|
|
273
|
+
},
|
|
274
|
+
watch: {
|
|
275
|
+
type: "boolean",
|
|
276
|
+
alias: "w",
|
|
277
|
+
default: true,
|
|
278
|
+
description: "Enable file watching for hot reload"
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
async run(ctx) {
|
|
282
|
+
const { devCommand: devCommandImpl } = await import("./commands/dev.mjs");
|
|
283
|
+
return devCommandImpl.run(ctx);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
const main = defineCommand({
|
|
287
|
+
meta: {
|
|
288
|
+
name: "nitro-graphql",
|
|
289
|
+
version: "2.0.0",
|
|
290
|
+
description: "GraphQL CLI for Nitro - type generation and dev server"
|
|
291
|
+
},
|
|
292
|
+
subCommands: {
|
|
293
|
+
"dev": devCommand,
|
|
294
|
+
"d": devCommand,
|
|
295
|
+
"build": buildCmd,
|
|
296
|
+
"b": buildCmd,
|
|
297
|
+
"generate": generateCommand,
|
|
298
|
+
"gen": generateCommand,
|
|
299
|
+
"g": generateCommand,
|
|
300
|
+
"generate:server": generateServerCommand,
|
|
301
|
+
"gen:server": generateServerCommand,
|
|
302
|
+
"generate:client": generateClientCommand,
|
|
303
|
+
"gen:client": generateClientCommand,
|
|
304
|
+
"validate": validateCommand,
|
|
305
|
+
"v": validateCommand,
|
|
306
|
+
"init": initCommand
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
async function run() {
|
|
310
|
+
const { initCompletions } = await import("./completions.mjs");
|
|
311
|
+
await initCompletions(main);
|
|
312
|
+
return runMain(main);
|
|
313
|
+
}
|
|
314
|
+
run();
|
|
315
|
+
|
|
316
|
+
//#endregion
|
|
317
|
+
export { createCLIContext, defineConfig, loadConfig };
|