Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/commands/router/commands/plugin/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 26 additions & 10 deletions cli/src/commands/router/commands/plugin/templates/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -265,7 +281,7 @@ For plugin structure and detailed workflow see the [Plugin Development Guide] in

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)

---

Expand Down
31 changes: 17 additions & 14 deletions cli/src/commands/router/commands/plugin/templates/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ release/
`;

const makefile = `
.PHONY: build download start compose
.PHONY: install-wgc build download start compose

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
Expand Down Expand Up @@ -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)

---

Expand Down Expand Up @@ -192,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)

---

Expand Down
2 changes: 1 addition & 1 deletion router-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion router/__schemas/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading