wgc 0.57.2 → 0.57.4
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
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
|
-
# Cosmo CLI aka "wgc"
|
|
1
|
+
# WunderGraph Cosmo CLI aka "wgc"
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/wgc)
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
+
Official documentation: [https://cosmo-docs.wundergraph.com/cli](https://cosmo-docs.wundergraph.com/cli)
|
|
8
|
+
|
|
7
9
|
### Prerequisites
|
|
8
10
|
|
|
9
|
-
- [Node.js
|
|
11
|
+
- [Node.js 20 LTS or higher](https://nodejs.dev/en/about/releases/)
|
|
10
12
|
|
|
11
13
|
The cosmo CLI tool `wgc`. Used to manage the cosmo platform e.g. pushing schema, check schemas, creating new projects, managing users, etc. It interacts with the control plane.
|
|
12
14
|
|
|
13
15
|
### Installation
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
|
-
npx wgc
|
|
18
|
+
npx wgc --help
|
|
19
|
+
# or install it globally
|
|
20
|
+
npm install -g wgc --help
|
|
17
21
|
```
|
|
18
22
|
|
|
19
23
|
### Development
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
Ensure that at least Node.js 20.6.0 is installed because we rely on the native .env file support.
|
|
26
|
+
|
|
27
|
+
Replace `env.example` with `.env` and fill in the required values. By default, we point to the services of your local development environment.
|
|
28
|
+
|
|
29
|
+
Run any command with `pnpm wgc` to test your changes locally directly.
|
|
22
30
|
|
|
23
31
|
```bash
|
|
24
|
-
pnpm
|
|
32
|
+
pnpm wgc ...
|
|
25
33
|
```
|
|
26
34
|
|
|
27
|
-
_Everything behind `wgc` is passed to the `wgc` cli._
|
|
35
|
+
_Everything behind `wgc` is passed to the `wgc` cli. This allows you to test your changes locally._
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
#### Run tests:
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- `COSMO_API_URL` - URL of the control plane
|
|
39
|
+
```bash
|
|
40
|
+
pnpm test
|
|
41
|
+
```
|
|
@@ -2,10 +2,11 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { buildRouterConfig, normalizeURL } from '@wundergraph/cosmo-shared';
|
|
4
4
|
import { Command, program } from 'commander';
|
|
5
|
-
import { parse
|
|
5
|
+
import { parse } from 'graphql';
|
|
6
6
|
import * as yaml from 'js-yaml';
|
|
7
7
|
import { dirname, resolve } from 'pathe';
|
|
8
8
|
import pc from 'picocolors';
|
|
9
|
+
import { printSchemaWithDirectives } from '@graphql-tools/utils';
|
|
9
10
|
import { composeSubgraphs, introspectSubgraph } from '../../../utils.js';
|
|
10
11
|
export default (opts) => {
|
|
11
12
|
const command = new Command('compose');
|
|
@@ -54,11 +55,11 @@ export default (opts) => {
|
|
|
54
55
|
program.error('Failed to compose given subgraphs');
|
|
55
56
|
}
|
|
56
57
|
const federatedClientSDL = result.federationResult.shouldIncludeClientSchema
|
|
57
|
-
?
|
|
58
|
+
? printSchemaWithDirectives(result.federationResult.federatedGraphClientSchema)
|
|
58
59
|
: '';
|
|
59
60
|
const routerConfig = buildRouterConfig({
|
|
60
61
|
federatedClientSDL,
|
|
61
|
-
federatedSDL:
|
|
62
|
+
federatedSDL: printSchemaWithDirectives(result.federationResult.federatedGraphSchema),
|
|
62
63
|
fieldConfigurations: result.federationResult.fieldConfigurations,
|
|
63
64
|
schemaVersionId: '',
|
|
64
65
|
subgraphs: config.subgraphs.map((s, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../../src/commands/router/commands/compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,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