Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
29bb604
feat: cli updates
SkArchon Oct 21, 2025
e1c3dbd
fix: updates
SkArchon Oct 21, 2025
cc08a5b
feat: cli updates
SkArchon Oct 22, 2025
5e68f51
feat: cli updates
SkArchon Oct 22, 2025
c2f32f7
fix: cli
SkArchon Oct 22, 2025
be23381
fix: updates
SkArchon Oct 22, 2025
9053591
fix: updates
SkArchon Oct 22, 2025
7abe72f
fix: updates
SkArchon Oct 23, 2025
009ea52
fix: add health check service and move go router plugin
SkArchon Oct 23, 2025
f962e9d
fix: updates
SkArchon Oct 23, 2025
809ae2e
fix: router plugin
SkArchon Oct 27, 2025
1c480c5
fix: updates
SkArchon Oct 27, 2025
d41a606
fix: updates
SkArchon Oct 27, 2025
f6f7b61
fix: updates
SkArchon Oct 27, 2025
6ea8136
fix: updates
SkArchon Oct 27, 2025
2f4a1cc
fix: updates
SkArchon Oct 27, 2025
81d8e08
fix: updates
SkArchon Oct 27, 2025
1eb5db5
fix: updates
SkArchon Oct 27, 2025
52adc57
fix: updates
SkArchon Oct 27, 2025
11347a8
fix: updates
SkArchon Oct 28, 2025
f423a92
fix: updates
SkArchon Oct 28, 2025
6ab77e9
fix: cleanup
SkArchon Oct 28, 2025
19e1f19
fix: revert
SkArchon Oct 28, 2025
a06c05c
fix: cleanup
SkArchon Oct 28, 2025
a6a1255
fix: cleanup
SkArchon Oct 28, 2025
5cda4dc
fix: cleanup
SkArchon Oct 28, 2025
e0025be
fix: updates
SkArchon Oct 28, 2025
df8c076
fix: templates
SkArchon Oct 28, 2025
6eace15
fix: templates
SkArchon Oct 28, 2025
10be6cb
fix: updates
SkArchon Oct 28, 2025
6c1de9f
fix: lint changes
SkArchon Oct 28, 2025
4897a0f
fix: linting
SkArchon Oct 28, 2025
2a0292e
fix: updates
SkArchon Oct 28, 2025
69c434f
fix: updates
SkArchon Oct 29, 2025
a94f90f
fix: changes
SkArchon Oct 29, 2025
773d616
fix: temp
SkArchon Oct 29, 2025
df92322
fix: updates
SkArchon Oct 29, 2025
f8b2145
fix: updates
SkArchon Oct 29, 2025
c94513f
fix: updates
SkArchon Oct 29, 2025
40a3d48
fix: updates
SkArchon Oct 29, 2025
dc15d41
fix: refactoring
SkArchon Oct 29, 2025
c7229ae
fix: refactoring
SkArchon Oct 29, 2025
5340a19
fix: updates
SkArchon Oct 29, 2025
48831fd
fix: ci changes
SkArchon Oct 29, 2025
5feb446
fix: refactoring
SkArchon Oct 29, 2025
30f48e6
fix: ci updates
SkArchon Oct 29, 2025
7f4d714
fix: ci updates
SkArchon Oct 29, 2025
0f9c289
fix: updates
SkArchon Oct 29, 2025
2dddf0c
fix: refactoring`
SkArchon Oct 29, 2025
4bb7b10
fix: revert
SkArchon Oct 29, 2025
4bb5dd2
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Oct 29, 2025
56f4e28
fix: review comments
SkArchon Oct 29, 2025
f5a7089
fix: updates
SkArchon Oct 29, 2025
ee9307a
fix: recompile templates
SkArchon Oct 29, 2025
a00ed32
fix: cleanup
SkArchon Oct 29, 2025
4e25bd4
fix: cleanup
SkArchon Oct 29, 2025
f20ff83
fix: updates
SkArchon Oct 29, 2025
db1d2f0
fix: refactoring
SkArchon Oct 29, 2025
489b50a
fix: linting
SkArchon Oct 29, 2025
760d277
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Oct 29, 2025
747854a
fix: refactoring
SkArchon Oct 29, 2025
10125cc
fix: templates
SkArchon Oct 29, 2025
fc4bf7f
fix: platform updates
SkArchon Oct 30, 2025
c1580f2
fix: linting
SkArchon Oct 30, 2025
c9340e2
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Oct 30, 2025
c2d0b81
fix: tests
SkArchon Oct 30, 2025
4dce726
fix: templates
SkArchon Oct 30, 2025
a91f3dd
fix: tests
SkArchon Oct 30, 2025
8a5bda0
fix: revert
SkArchon Oct 30, 2025
d4c8b78
fix: formatting
SkArchon Oct 30, 2025
1672582
fix: update imports`
SkArchon Oct 30, 2025
7883122
fix: demonstration
SkArchon Oct 30, 2025
6fbd524
fix: update configuration
SkArchon Oct 30, 2025
e553b06
fix: diff testing
SkArchon Oct 30, 2025
1991bf0
fix: diff updates
SkArchon Oct 30, 2025
349e5b1
fix: project updates
SkArchon Oct 30, 2025
10594aa
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Nov 5, 2025
4a9234b
fix: patch the grpc health check node modules
SkArchon Nov 10, 2025
1291745
fix: template compilation
SkArchon Nov 10, 2025
22f7c5b
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Nov 10, 2025
d27a5f3
fix: local builds
SkArchon Nov 11, 2025
3e523e8
fix: spinner updating
SkArchon Nov 11, 2025
a80cf59
fix: ts tests
SkArchon Nov 15, 2025
770c4ba
fix: tests
SkArchon Nov 15, 2025
49812b6
Merge remote-tracking branch 'origin/main' into milinda/eng-7174-supp…
SkArchon Nov 15, 2025
04b622b
fix: linting
SkArchon Nov 15, 2025
42273e1
fix: update makefile
SkArchon Nov 15, 2025
10ba33e
fix: plugin build
SkArchon Nov 15, 2025
3a08009
fix: workflows
SkArchon Nov 15, 2025
1238bb2
fix: ci updates
SkArchon Nov 15, 2025
9d291a2
fix: courses updates
SkArchon Nov 15, 2025
07437fc
fix: go module
SkArchon Nov 15, 2025
a95f179
fix: enable debugging
SkArchon Nov 15, 2025
acb1628
fix: linting
SkArchon Nov 15, 2025
2b4e469
fix: package updating
SkArchon Nov 15, 2025
6344161
fix: protographic changes
SkArchon Nov 17, 2025
7b53b98
fix: protographic
SkArchon Nov 17, 2025
80c71dd
fix: mutation dirty data
SkArchon Nov 17, 2025
b6242ec
fix: review comments
SkArchon Nov 17, 2025
c757d2e
fix: inquire patch
SkArchon Nov 18, 2025
fe4fe83
fix: tool installation
SkArchon Nov 18, 2025
febcbcc
fix: hash update
SkArchon Nov 18, 2025
66fce76
fix: errors compilation
SkArchon Nov 18, 2025
ba8f5c8
fix: linting
SkArchon Nov 18, 2025
8b77e0b
fix: linting
SkArchon Nov 18, 2025
14702fb
fix: add node for protoc libraries
SkArchon Nov 18, 2025
c0c95fb
fix: new flags
SkArchon Nov 18, 2025
0c4c3ac
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Nov 18, 2025
49f53d4
Merge branch 'main' into milinda/eng-7174-support-grpc-plugins-with-b…
SkArchon Nov 19, 2025
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
45 changes: 29 additions & 16 deletions cli/src/commands/router/commands/plugin/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Spinner from 'ora';
import { BaseCommandOptions } from '../../../../../core/types/types.js';
import { renderResultTree } from '../helper.js';
import {
buildBinaries,
buildGoBinaries,
checkAndInstallTools,
generateGRPCCode,
generateProtoAndMapping,
HOST_PLATFORM,
installGoDependencies,
generateProtoAndMapping, getLanguage,
getHostPlatform,
installGoDependencies, installTsDependencies, buildTsBinaries,
normalizePlatforms,
} from '../toolchain.js';

Expand All @@ -21,9 +21,7 @@ export default (opts: BaseCommandOptions) => {
command.argument('[directory]', 'Directory of the plugin', '.');
command.option('--generate-only', 'Generate only the proto and mapping files, do not compile the plugin');
command.option('--debug', 'Build the binary with debug information', false);
command.option('--platform [platforms...]', 'Platform-architecture combinations (e.g., darwin-arm64 linux-amd64)', [
HOST_PLATFORM,
]);
command.option('--platform [platforms...]', 'Platform-architecture combinations (e.g., darwin-arm64 linux-amd64)', []);
command.option('--all-platforms', 'Build for all supported platforms', false);
command.option('--skip-tools-installation', 'Skip tool installation', false);
command.option(
Expand All @@ -46,29 +44,44 @@ export default (opts: BaseCommandOptions) => {
let platforms: string[] = [];

try {
const language = getLanguage(pluginDir)

// Check and install tools if needed
if (!options.skipToolsInstallation) {
await checkAndInstallTools(options.forceToolsInstallation);
}

// Normalize platform list
platforms = normalizePlatforms(options.platform, options.allPlatforms);

// Start the main build process
spinner.start('Building plugin...');

switch (language) {
case 'ts': {
await installTsDependencies(pluginDir, spinner);
break;
}
}

// Normalize platform list
platforms = normalizePlatforms(options.platform, options.allPlatforms, language);

// Generate proto and mapping files
await generateProtoAndMapping(pluginDir, goModulePath, spinner);

// Generate gRPC code
await generateGRPCCode(pluginDir, spinner);
await generateGRPCCode(pluginDir, spinner, language);

if (!options.generateOnly) {
// Install Go dependencies
await installGoDependencies(pluginDir, spinner);

// Build binaries for all platforms
await buildBinaries(pluginDir, platforms, options.debug, spinner);
switch (language) {
case 'go': {
await installGoDependencies(pluginDir, spinner);
await buildGoBinaries(pluginDir, platforms, options.debug, spinner);
break;
}
case 'ts': {
await buildTsBinaries(pluginDir, platforms, options.debug, spinner);
break;
}
}
}

// Calculate and format elapsed time
Expand Down
23 changes: 18 additions & 5 deletions cli/src/commands/router/commands/plugin/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { renderResultTree } from '../helper.js';
import {
checkAndInstallTools,
generateGRPCCode,
generateProtoAndMapping,
installGoDependencies,
generateProtoAndMapping, getLanguage,
installGoDependencies, installTsDependencies,
} from '../toolchain.js';

export default (opts: BaseCommandOptions) => {
Expand All @@ -36,22 +36,35 @@ export default (opts: BaseCommandOptions) => {
const goModulePath = options.goModulePath;

try {
const language = getLanguage(pluginDir)

// Check and install tools if needed
if (!options.skipToolsInstallation) {
await checkAndInstallTools(options.forceToolsInstallation);
}

switch (language) {
case 'ts': {
await installTsDependencies(pluginDir, spinner);
break;
}
}

// Start the generation process
spinner.start('Generating plugin code...');

// Generate proto and mapping files
await generateProtoAndMapping(pluginDir, goModulePath, spinner);

// Generate gRPC code
await generateGRPCCode(pluginDir, spinner);
await generateGRPCCode(pluginDir, spinner, language);

// Install Go dependencies
await installGoDependencies(pluginDir, spinner);
switch (language) {
case 'go': {
await installGoDependencies(pluginDir, spinner);
break;
}
}

// Calculate and format elapsed time
const endTime = performance.now();
Expand Down
72 changes: 31 additions & 41 deletions cli/src/commands/router/commands/plugin/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { camelCase, upperFirst } from 'lodash-es';
import { BaseCommandOptions } from '../../../../../core/types/types.js';
import PluginTemplates from '../templates/plugin.js';
import ProjectTemplates from '../templates/project.js';
import GoTemplates from '../templates/goplugin.js';
import TsTemplates from '../templates/tsplugin.js';
import { renderResultTree } from '../helper.js';

export default (opts: BaseCommandOptions) => {
Expand Down Expand Up @@ -59,36 +61,44 @@ export default (opts: BaseCommandOptions) => {

spinner.text = 'Checkout templates...';

if (options.language.toLowerCase() !== 'go') {
options.language = options.language.toLowerCase();
if (options.language !== 'go' || options.language !== 'ts') {
spinner.fail(pc.yellow(`Language '${options.language}' is not supported yet. Using 'go' instead.`));
options.language = 'go';
}

const goModulePath = 'github.com/wundergraph/cosmo/plugin';

spinner.text = 'Generating mapping and proto files...';

await writeFile(resolve(srcDir, 'schema.graphql'), pupa(PluginTemplates.schema, { name }));
const mapping = compileGraphQLToMapping(PluginTemplates.schema, serviceName);
await writeFile(resolve(generatedDir, 'mapping.json'), JSON.stringify(mapping, null, 2));
await writeFile(resolve(tempDir, 'Makefile'), pupa(PluginTemplates.makefile, { originalPluginName }));

await writeFile(resolve(tempDir, '.gitignore'), PluginTemplates.gitignore);
await writeFile(resolve(tempDir, '.cursorignore'), PluginTemplates.cursorIgnore);

const proto = compileGraphQLToProto(PluginTemplates.schema, { serviceName, packageName: 'service', goPackage: goModulePath });
await writeFile(resolve(generatedDir, 'service.proto'), proto.proto);
await writeFile(resolve(generatedDir, 'service.proto.lock.json'), JSON.stringify(proto.lockData, null, 2));

switch (options.language) {
case 'go': {
await writeFile(resolve(srcDir, 'main.go'), pupa(GoTemplates.mainGo, { serviceName }));
await writeFile(resolve(srcDir, 'main_test.go'), pupa(GoTemplates.mainGoTest, { serviceName }));
await writeFile(resolve(tempDir, 'go.mod'), pupa(PluginTemplates.goMod, { modulePath: goModulePath }));
break;
}
case 'ts': {
await writeFile(resolve(srcDir, 'plugin.ts'), pupa(TsTemplates.pluginTs, { serviceName }));
await writeFile(resolve(srcDir, 'client.ts'), pupa(TsTemplates.clientTs, { serviceName }));
await writeFile(resolve(tempDir, 'package.json'), pupa(TsTemplates.packageJson, { serviceName }));
}
}
// Language Specific

if (options.project) {
await writeFile(resolve(tempDir, 'README.md'), pupa(ProjectTemplates.readme, { name, originalPluginName }));
await writeFile(resolve(srcDir, 'schema.graphql'), pupa(PluginTemplates.schema, { name }));

const mapping = compileGraphQLToMapping(PluginTemplates.schema, serviceName);
await writeFile(resolve(generatedDir, 'mapping.json'), JSON.stringify(mapping, null, 2));

const proto = compileGraphQLToProto(PluginTemplates.schema, {
serviceName,
packageName: 'service',
goPackage: goModulePath,
});

await writeFile(resolve(generatedDir, 'service.proto'), proto.proto);
await writeFile(resolve(generatedDir, 'service.proto.lock.json'), JSON.stringify(proto.lockData, null, 2));
await writeFile(resolve(srcDir, 'main.go'), pupa(PluginTemplates.mainGo, { serviceName }));
await writeFile(resolve(srcDir, 'main_test.go'), pupa(PluginTemplates.mainGoTest, { serviceName }));
await writeFile(resolve(tempDir, 'go.mod'), pupa(PluginTemplates.goMod, { modulePath: goModulePath }));
await writeFile(resolve(tempDir, 'Makefile'), pupa(PluginTemplates.makefile, { originalPluginName }));
await writeFile(resolve(tempDir, '.gitignore'), PluginTemplates.gitignore);
await writeFile(resolve(tempDir, '.cursorignore'), PluginTemplates.cursorIgnore);

// Create cursor rules in .cursor/rules
await mkdir(resolve(tempDir, '.cursor', 'rules'), { recursive: true });
Expand All @@ -115,11 +125,6 @@ export default (opts: BaseCommandOptions) => {
await rename(tempDir, pluginDir);
} else {
await writeFile(resolve(tempDir, 'README.md'), pupa(PluginTemplates.readme, { name, originalPluginName }));
await writeFile(resolve(tempDir, 'Makefile'), pupa(PluginTemplates.makefile, { originalPluginName }));
await writeFile(resolve(srcDir, 'schema.graphql'), pupa(PluginTemplates.schema, { name }));

const mapping = compileGraphQLToMapping(PluginTemplates.schema, serviceName);
await writeFile(resolve(generatedDir, 'mapping.json'), JSON.stringify(mapping, null, 2));

// Create cursor rules in .cursor/rules
await mkdir(resolve(tempDir, '.cursor', 'rules'), { recursive: true });
Expand All @@ -128,22 +133,7 @@ export default (opts: BaseCommandOptions) => {
pupa(PluginTemplates.cursorRules, { name, originalPluginName, pluginDir }),
);

const proto = compileGraphQLToProto(PluginTemplates.schema, {
serviceName,
packageName: 'service',
goPackage: goModulePath,
});

await writeFile(resolve(generatedDir, 'service.proto'), proto.proto);
await writeFile(resolve(generatedDir, 'service.proto.lock.json'), JSON.stringify(proto.lockData, null, 2));
await writeFile(resolve(srcDir, 'main.go'), pupa(PluginTemplates.mainGo, { serviceName }));
await writeFile(resolve(srcDir, 'main_test.go'), pupa(PluginTemplates.mainGoTest, { serviceName }));
await writeFile(resolve(tempDir, 'go.mod'), pupa(PluginTemplates.goMod, { modulePath: goModulePath }));
await writeFile(resolve(tempDir, '.gitignore'), PluginTemplates.gitignore);
await writeFile(resolve(tempDir, '.cursorignore'), PluginTemplates.cursorIgnore);

await mkdir(projectDir, { recursive: true });

await rename(tempDir, pluginDir);
}

Expand Down
Loading
Loading