Skip to content

Commit 5117ec2

Browse files
authored
Merge branch 'main' into suvij/eng-6412-add-an-option-for-the-user-to-configure-the-number-of-cache
2 parents b7cf7f7 + f1723ed commit 5117ec2

File tree

10 files changed

+288
-57
lines changed

10 files changed

+288
-57
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build wgc binaries
2+
on:
3+
pull_request:
4+
paths:
5+
- "cli/**/*"
6+
- "connect/**/*"
7+
- ".github/workflows/cli-ci.yaml"
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
13+
jobs:
14+
build_test:
15+
name: Build wgc binaries
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
19+
strategy:
20+
matrix:
21+
target: [bun-linux-x64, bun-linux-arm64, bun-darwin-x64, bun-darwin-arm64, bun-windows-x64]
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- uses: oven-sh/setup-bun@v2
28+
29+
- uses: ./.github/actions/node
30+
31+
- name: Install dependencies
32+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition install --frozen-lockfile
33+
34+
- name: Build
35+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition run build
36+
37+
- name: "Build wgc binary"
38+
working-directory: cli
39+
run: bun build --compile --target ${{ matrix.target }} src/index.ts --outfile out/wgc-${{ github.sha }}-${{ matrix.target }}
40+
41+
- name: "Upload builds as artifacts"
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: wgc-${{ github.sha }}-${{ matrix.target }}
45+
path: cli/out/wgc-${{ github.sha }}-${{ matrix.target }}*
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and release wgc binaries
2+
on:
3+
release:
4+
types: [published]
5+
6+
permissions:
7+
contents: write
8+
packages: write
9+
10+
jobs:
11+
wgc-releases-matrix:
12+
if: startsWith(github.event.release.tag_name, 'wgc@')
13+
name: Build and release wgc binaries
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 30
16+
17+
strategy:
18+
matrix:
19+
target: [bun-linux-x64, bun-linux-arm64, bun-darwin-x64, bun-darwin-arm64]
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- uses: oven-sh/setup-bun@v2
26+
27+
- uses: ./.github/actions/node
28+
29+
- name: Install dependencies
30+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition install --frozen-lockfile
31+
32+
- name: Build
33+
run: pnpm --filter ./cli --filter ./connect --filter ./shared --filter ./composition run build
34+
35+
- uses: winterjung/split@v2
36+
id: split
37+
with:
38+
separator: "@"
39+
msg: "${{ github.event.release.tag_name }}"
40+
41+
- name: Set BUILD_TIME env
42+
run: echo BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') >> ${GITHUB_ENV}
43+
44+
- name: "Build wgc binary"
45+
working-directory: cli
46+
run: bun build --compile --target ${{ matrix.target }} src/index.ts --outfile out/wgc-${{ steps.split.outputs._1 }}-${{ matrix.target }}
47+
48+
- name: "Upload build to release"
49+
working-directory: cli
50+
env:
51+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
shell: bash
53+
run: gh release upload ${{ github.event.release.tag_name }} out/wgc-${{ steps.split.outputs._1 }}-${{ matrix.target }} --clobber

cli/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
dist
2+
wgc
3+
out
24
node_modules
35
.env
46
.eslintcache

cli/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Binaries are attached to the github release otherwise all images can be found [h
44
All notable changes to this project will be documented in this file.
55
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
66

7+
## [0.75.1](https://github.com/wundergraph/cosmo/compare/wgc@0.75.0...wgc@0.75.1) (2025-02-25)
8+
9+
### Bug Fixes
10+
11+
* correct and deterministic dist folder structure ([#1628](https://github.com/wundergraph/cosmo/issues/1628)) ([f9600d4](https://github.com/wundergraph/cosmo/commit/f9600d4fd8f090968f38b9628034cdd97156e42a)) (@endigma)
12+
13+
# [0.75.0](https://github.com/wundergraph/cosmo/compare/wgc@0.74.0...wgc@0.75.0) (2025-02-25)
14+
15+
### Features
16+
17+
* include client schema in the output of federated-graph fetch command ([#1619](https://github.com/wundergraph/cosmo/issues/1619)) ([5c87126](https://github.com/wundergraph/cosmo/commit/5c8712621ae7651317f85b2d12d1c128b54a5f75)) (@JivusAyrus)
18+
* release bun based single file executables ([#1620](https://github.com/wundergraph/cosmo/issues/1620)) ([7cda142](https://github.com/wundergraph/cosmo/commit/7cda1423b711224de2e8d0a4ce514340a2d4757f)) (@endigma)
19+
720
# [0.74.0](https://github.com/wundergraph/cosmo/compare/wgc@0.73.0...wgc@0.74.0) (2025-02-17)
821

922
### Features

cli/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "wgc",
3-
"version": "0.74.0",
3+
"version": "0.75.1",
44
"description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
55
"type": "module",
6-
"main": "dist/index.js",
7-
"bin": "dist/index.js",
6+
"main": "dist/src/index.js",
7+
"bin": "dist/src/index.js",
88
"author": {
99
"name": "WunderGraph Maintainers",
1010
"email": "info@wundergraph.com"
@@ -20,6 +20,7 @@
2020
},
2121
"scripts": {
2222
"build": "del dist && tsc",
23+
"build:bun": "bun build --compile src/index.ts --outfile wgc",
2324
"wgc": "tsx --env-file .env src/index.ts",
2425
"test": "pnpm lint && vitest run",
2526
"coverage": "vitest run --coverage",
@@ -77,7 +78,7 @@
7778
"eslint": "^8.57.1",
7879
"eslint-config-unjs": "^0.2.1",
7980
"eslint-plugin-require-extensions": "^0.1.3",
80-
"prettier": "^3.0.3",
81+
"prettier": "^3.5.2",
8182
"tsx": "^4.17.0",
8283
"typescript": "5.5.2",
8384
"vitest": "^2.1.8"

cli/src/commands/graph/federated-graph/commands/fetch.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import yaml from 'js-yaml';
44
import { join, resolve } from 'pathe';
55
import pc from 'picocolors';
66
import { BaseCommandOptions } from '../../../../core/types/types.js';
7-
import { fetchRouterConfig, getFederatedGraphSDL, getSubgraphSDL, getSubgraphsOfFedGraph } from '../utils.js';
7+
import { fetchRouterConfig, getFederatedGraphSchemas, getSubgraphSDL, getSubgraphsOfFedGraph } from '../utils.js';
88

99
export default (opts: BaseCommandOptions) => {
1010
const cmd = new Command('fetch');
@@ -23,7 +23,11 @@ export default (opts: BaseCommandOptions) => {
2323

2424
cmd.action(async (name, options) => {
2525
try {
26-
const fedGraphSDL = await getFederatedGraphSDL({ client: opts.client, name, namespace: options.namespace });
26+
const fedGraphSchemas = await getFederatedGraphSchemas({
27+
client: opts.client,
28+
name,
29+
namespace: options.namespace,
30+
});
2731

2832
const basePath = resolve(options.out, `${name}${options.namespace ? `-${options.namespace}` : ''}`);
2933
const superGraphPath = join(basePath, '/supergraph/');
@@ -47,7 +51,11 @@ export default (opts: BaseCommandOptions) => {
4751
});
4852
writeFileSync(join(superGraphPath, `cosmoConfig.json`), routerConfig);
4953

50-
writeFileSync(join(superGraphPath, `cosmoSchema.graphql`), fedGraphSDL);
54+
writeFileSync(join(superGraphPath, `cosmoSchema.graphql`), fedGraphSchemas.sdl);
55+
56+
if (fedGraphSchemas.clientSchema) {
57+
writeFileSync(join(superGraphPath, `cosmoClientSchema.graphql`), fedGraphSchemas.clientSchema);
58+
}
5159

5260
const subgraphs = await getSubgraphsOfFedGraph({ client: opts.client, name, namespace: options.namespace });
5361

cli/src/commands/graph/federated-graph/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export const getSubgraphsOfFedGraph = async ({
118118
});
119119
};
120120

121-
export const getFederatedGraphSDL = async ({
121+
export const getFederatedGraphSchemas = async ({
122122
client,
123123
name,
124124
namespace,
@@ -145,9 +145,10 @@ export const getFederatedGraphSDL = async ({
145145
);
146146
}
147147

148-
const sdl = await resp.sdl;
149-
150-
return sdl;
148+
return {
149+
sdl: resp.sdl,
150+
clientSchema: resp.clientSchema,
151+
};
151152
};
152153

153154
// Returns the latest valid schema version of a subgraph that was composed to form the provided federated graph.

cli/src/core/config.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import { readFileSync } from 'node:fs';
2-
import { readFile } from 'node:fs/promises';
32
import { join } from 'pathe';
43
import yaml from 'js-yaml';
54
import envPaths from 'env-paths';
65

7-
const info = JSON.parse(
8-
await readFile(new URL('../../package.json', import.meta.url), {
9-
encoding: 'utf8',
10-
}),
11-
);
6+
import info from '../../package.json' with { type: 'json' };
127

138
const paths = envPaths('cosmo', { suffix: '' });
149
export const configDir = paths.config;
@@ -25,6 +20,7 @@ const getLoginDetails = (): { accessToken: string; organizationSlug: string } |
2520
};
2621

2722
export const config = {
23+
version: info.version,
2824
baseURL: process.env.COSMO_API_URL || 'https://cosmo-cp.wundergraph.com',
2925
// environment var first to allow overriding
3026
apiKey: process.env.COSMO_API_KEY,
@@ -33,7 +29,6 @@ export const config = {
3329
kcClientId: process.env.KC_CLIENT_ID || 'cosmo-cli',
3430
kcRealm: process.env.KC_REALM || 'cosmo',
3531
cdnURL: process.env.CDN_URL || 'https://cosmo-cdn.wundergraph.com',
36-
version: info.version,
3732
disableUpdateCheck: process.env.DISABLE_UPDATE_CHECK || 'false',
3833
checkAuthor: process.env.COSMO_VCS_AUTHOR || '',
3934
checkCommitSha: process.env.COSMO_VCS_COMMIT || '',

cli/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"moduleResolution": "node",
77
"declarationDir": "./dist",
88
"outDir": "./dist",
9-
"typeRoots": ["./node_modules/@types", "./src/typedefinitions"]
9+
"typeRoots": ["./node_modules/@types", "./src/typedefinitions"],
10+
"rootDir": "."
1011
},
1112
"include": ["src/**/*"],
1213
"exclude": ["node_modules", "dist"]

0 commit comments

Comments
 (0)