From 2f19975517508f8afdb8951d2eaa756455d9f7fd Mon Sep 17 00:00:00 2001 From: StarpTech Date: Sat, 23 Aug 2025 16:39:45 +0200 Subject: [PATCH 1/3] fix(cli): fix link in plugin docs and npm workspace issue --- .../commands/plugin/templates/plugin.ts | 34 ++++++++++++++----- .../commands/plugin/templates/project.ts | 29 +++++++++------- router/__schemas/plugin.sh | 2 +- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/cli/src/commands/router/commands/plugin/templates/plugin.ts b/cli/src/commands/router/commands/plugin/templates/plugin.ts index b0821e16a3..e06807dfac 100644 --- a/cli/src/commands/router/commands/plugin/templates/plugin.ts +++ b/cli/src/commands/router/commands/plugin/templates/plugin.ts @@ -17,21 +17,24 @@ require ( `; const makefile = ` -.PHONY: build test generate +.PHONY: build test generate install-wgc + +install-wgc: +\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest make: build -test: - npx wgc@latest router plugin test . +test: install-wgc +\twgc router plugin test . -generate: - npx wgc@latest router plugin generate . +generate: install-wgc +\twgc router plugin generate . publish: generate - npx wgc@latest router plugin publish . +\twgc router plugin publish . -build: - npx wgc@latest router plugin build . --debug +build: install-wgc +\twgc router plugin build . --debug `; const mainGo = `package main @@ -253,7 +256,20 @@ The plugin demonstrates: ## Getting Started -For plugin structure and detailed workflow see the [Plugin Development Guide] in the Cursor Rules tab. +Plugin structure: + + \`\`\` + plugins/{originalPluginName}/ + ├── go.mod # Go module file with dependencies + ├── go.sum # Go checksums file + ├── src/ + │ ├── main.go # Main plugin implementation + │ ├── main_test.go # Tests for the plugin + │ └── schema.graphql # GraphQL schema defining the API + ├── generated/ # Generated code (created during build) + └── bin/ # Compiled binaries (created during build) + └── plugin # The compiled plugin binary + \`\`\` ## 🔧 Customizing Your Plugin diff --git a/cli/src/commands/router/commands/plugin/templates/project.ts b/cli/src/commands/router/commands/plugin/templates/project.ts index 23b38dd546..0cb795b33c 100644 --- a/cli/src/commands/router/commands/plugin/templates/project.ts +++ b/cli/src/commands/router/commands/plugin/templates/project.ts @@ -8,25 +8,28 @@ release/ `; const makefile = ` -.PHONY: build download start compose +.PHONY: build download start compose install-wgc -make: download build compose start +make: install-wgc download build compose start + +install-wgc: +\t@which wgc > /dev/null 2>&1 || npm install -g wgc@latest start: - ./release/router +\t./release/router -compose: - npx wgc@latest router compose -i graph.yaml -o config.json +compose: install-wgc +\twgc router compose -i graph.yaml -o config.json -download: - @if [ ! -f release/router ]; then \\ - rm -rf release && npx wgc@latest router download-binary -o release && chmod +x release/router; \\ - else \\ - echo "Router binary already exists, skipping download"; \\ - fi +download: install-wgc +\t@if [ ! -f release/router ]; then \\ +\t\trm -rf release && wgc router download-binary -o release && chmod +x release/router; \\ +\telse \\ +\t\techo "Router binary already exists, skipping download"; \\ +\tfi build: - cd plugins/{originalPluginName} && make build +\tcd plugins/{originalPluginName} && make build `; const graphConfig = `version: 1 @@ -140,7 +143,7 @@ query { For more information about Cosmo and building router plugins: - [Cosmo Documentation](https://cosmo-docs.wundergraph.com/) -- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/router/plugins) +- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins) --- diff --git a/router/__schemas/plugin.sh b/router/__schemas/plugin.sh index 7a881a0df1..c4698d4d05 100755 --- a/router/__schemas/plugin.sh +++ b/router/__schemas/plugin.sh @@ -2,7 +2,7 @@ rm -rf ../plugins -pnpx tsx --env-file ../../cli/.env ../../cli/src/index.ts router plugin init hello-world --only-plugin -d ../ +pnpx tsx --env-file ../../cli/.env ../../cli/src/index.ts router plugin init hello-world -d ../ pnpx tsx --env-file ../../cli/.env ../../cli/src/index.ts router plugin build ../plugins/hello-world --debug From e75fd9b0739cddfdbde163962ff36beabec981c2 Mon Sep 17 00:00:00 2001 From: StarpTech Date: Sat, 23 Aug 2025 16:41:28 +0200 Subject: [PATCH 2/3] chore: fix order --- cli/src/commands/router/commands/plugin/templates/project.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/commands/router/commands/plugin/templates/project.ts b/cli/src/commands/router/commands/plugin/templates/project.ts index 0cb795b33c..35277096d7 100644 --- a/cli/src/commands/router/commands/plugin/templates/project.ts +++ b/cli/src/commands/router/commands/plugin/templates/project.ts @@ -8,7 +8,7 @@ release/ `; const makefile = ` -.PHONY: build download start compose install-wgc +.PHONY: install-wgc build download start compose make: install-wgc download build compose start From e5cc21073b9b3c707b2aa4f548dd4c7df5502969 Mon Sep 17 00:00:00 2001 From: StarpTech Date: Sat, 23 Aug 2025 16:57:00 +0200 Subject: [PATCH 3/3] chore: update links --- cli/src/commands/router/commands/plugin/commands/init.ts | 2 +- cli/src/commands/router/commands/plugin/templates/plugin.ts | 2 +- cli/src/commands/router/commands/plugin/templates/project.ts | 2 +- router-plugin/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/router/commands/plugin/commands/init.ts b/cli/src/commands/router/commands/plugin/commands/init.ts index d816554b86..0a7f75868c 100644 --- a/cli/src/commands/router/commands/plugin/commands/init.ts +++ b/cli/src/commands/router/commands/plugin/commands/init.ts @@ -163,7 +163,7 @@ export default (opts: BaseCommandOptions) => { console.log( ` For more information, checkout the ${pc.bold(pc.italic('README.md'))} file for instructions on how to build and run your plugin.`, ); - console.log(` Go to https://cosmo-docs.wundergraph.com/router/plugins to learn more about it.`); + console.log(` Go to https://cosmo-docs.wundergraph.com/connect/plugins to learn more about it.`); console.log(''); } catch (error: any) { // Clean up the temp directory in case of error diff --git a/cli/src/commands/router/commands/plugin/templates/plugin.ts b/cli/src/commands/router/commands/plugin/templates/plugin.ts index e06807dfac..2d987191f6 100644 --- a/cli/src/commands/router/commands/plugin/templates/plugin.ts +++ b/cli/src/commands/router/commands/plugin/templates/plugin.ts @@ -281,7 +281,7 @@ Plugin structure: For more information about Cosmo and building router plugins: - [Cosmo Documentation](https://cosmo-docs.wundergraph.com/) -- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/router/plugins) +- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins) --- diff --git a/cli/src/commands/router/commands/plugin/templates/project.ts b/cli/src/commands/router/commands/plugin/templates/project.ts index 35277096d7..8406b6b313 100644 --- a/cli/src/commands/router/commands/plugin/templates/project.ts +++ b/cli/src/commands/router/commands/plugin/templates/project.ts @@ -195,7 +195,7 @@ Plugin structure: For more information about Cosmo and building router plugins: - [Cosmo Documentation](https://cosmo-docs.wundergraph.com/) -- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/router/plugins) +- [Cosmo Router Plugins Guide](https://cosmo-docs.wundergraph.com/connect/plugins) --- diff --git a/router-plugin/README.md b/router-plugin/README.md index 626d5b4de6..1b7eda0058 100644 --- a/router-plugin/README.md +++ b/router-plugin/README.md @@ -8,7 +8,7 @@ The Router Plugin system allows you to extend the Cosmo router with custom gRPC ## Getting Started -Read the official [documentation](https://cosmo-docs.wundergraph.com/router/plugins) for the Cosmo router to understand how to set up your environment and build a plugin. +Read the official [documentation](https://cosmo-docs.wundergraph.com/connect/plugins) for the Cosmo router to understand how to set up your environment and build a plugin. ## API Reference