@graphcommerce/cli 9.0.0-canary.58 → 9.0.0-canary.59
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/CHANGELOG.md +6 -0
- package/dist/bin/mesh.js +48 -1
- package/package.json +6 -6
- package/src/bin/mesh.ts +37 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @graphcommerce/cli
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.59
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2309](https://github.com/graphcommerce-org/graphcommerce/pull/2309) [`b46e17e`](https://github.com/graphcommerce-org/graphcommerce/commit/b46e17ebe390b4d0040639dfdac33c36a60576ac) - When generating the mesh the configuration is passed through `@graphcommerce/graphql-mesh/meshConfig` allowing plugins to modify the mesh configuration without having to change the `.meshrc.yaml` itself. ([@Renzovh](https://github.com/Renzovh))
|
|
8
|
+
|
|
3
9
|
## 9.0.0-canary.58
|
|
4
10
|
|
|
5
11
|
## 9.0.0-canary.57
|
package/dist/bin/mesh.js
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
3
26
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
28
|
};
|
|
@@ -15,7 +38,9 @@ const utils_1 = require("@graphql-mesh/utils");
|
|
|
15
38
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
16
39
|
const yaml_1 = __importDefault(require("yaml"));
|
|
17
40
|
const findConfig_1 = require("../utils/findConfig");
|
|
41
|
+
// eslint-disable-next-line import/no-unresolved
|
|
18
42
|
require("tsx/cjs"); // support importing typescript configs in CommonJS
|
|
43
|
+
// eslint-disable-next-line import/no-unresolved
|
|
19
44
|
require("tsx/esm"); // support importing typescript configs in ESM
|
|
20
45
|
dotenv_1.default.config();
|
|
21
46
|
function handleFatalError(e, logger = new utils_1.DefaultLogger('◈')) {
|
|
@@ -48,8 +73,12 @@ async function cleanup() {
|
|
|
48
73
|
return undefined;
|
|
49
74
|
}
|
|
50
75
|
const main = async () => {
|
|
51
|
-
const
|
|
76
|
+
const baseConf = (await (0, findConfig_1.findConfig)({}));
|
|
52
77
|
const graphCommerce = (0, next_config_1.loadConfig)(root);
|
|
78
|
+
// eslint-disable-next-line global-require
|
|
79
|
+
// @ts-ignore Might not exist
|
|
80
|
+
const { meshConfig } = (await Promise.resolve().then(() => __importStar(require('@graphcommerce/graphql-mesh/meshConfig.interceptor'))));
|
|
81
|
+
const conf = meshConfig(baseConf, graphCommerce);
|
|
53
82
|
// We're configuring a custom fetch function
|
|
54
83
|
conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch');
|
|
55
84
|
conf.serve = { ...conf.serve, endpoint: '/api/graphql' };
|
|
@@ -62,6 +91,24 @@ const main = async () => {
|
|
|
62
91
|
return node_path_1.default.relative(root, require.resolve(additionalResolver));
|
|
63
92
|
return additionalResolver;
|
|
64
93
|
});
|
|
94
|
+
conf.sources = conf.sources.map((source) => {
|
|
95
|
+
const definedHandlers = Object.entries(source.handler);
|
|
96
|
+
return {
|
|
97
|
+
...source,
|
|
98
|
+
handler: Object.fromEntries(definedHandlers.map(([key, value]) => {
|
|
99
|
+
if (key === 'openapi' && value) {
|
|
100
|
+
const openapi = value;
|
|
101
|
+
if (openapi.source.startsWith('@')) {
|
|
102
|
+
return [
|
|
103
|
+
key,
|
|
104
|
+
{ ...openapi, source: node_path_1.default.relative(root, require.resolve(openapi.source)) },
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return [key, value];
|
|
109
|
+
})),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
65
112
|
// Rewrite additionalTypeDefs so we can use module resolution more easily
|
|
66
113
|
if (!conf.additionalTypeDefs)
|
|
67
114
|
conf.additionalTypeDefs = [];
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/cli",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.59",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "tsc --preserveWatchOutput --watch",
|
|
8
8
|
"build": "tsc",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"tsx": "^4.16.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
43
|
-
"@graphcommerce/hygraph-cli": "^9.0.0-canary.
|
|
44
|
-
"@graphcommerce/next-config": "^9.0.0-canary.
|
|
45
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
46
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
42
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.59",
|
|
43
|
+
"@graphcommerce/hygraph-cli": "^9.0.0-canary.59",
|
|
44
|
+
"@graphcommerce/next-config": "^9.0.0-canary.59",
|
|
45
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.59",
|
|
46
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.59",
|
|
47
47
|
"graphql": "^16.7.1",
|
|
48
48
|
"react": "^18.2.0"
|
|
49
49
|
},
|
package/src/bin/mesh.ts
CHANGED
|
@@ -11,12 +11,16 @@ import {
|
|
|
11
11
|
} from '@graphcommerce/next-config'
|
|
12
12
|
import { graphqlMesh, DEFAULT_CLI_PARAMS, GraphQLMeshCLIParams } from '@graphql-mesh/cli'
|
|
13
13
|
import { Logger, YamlConfig } from '@graphql-mesh/types'
|
|
14
|
+
import { Handler } from '@graphql-mesh/types/typings/config'
|
|
14
15
|
import { DefaultLogger } from '@graphql-mesh/utils'
|
|
15
16
|
import dotenv from 'dotenv'
|
|
17
|
+
import type { OmitIndexSignature, Entries } from 'type-fest'
|
|
16
18
|
import yaml from 'yaml'
|
|
17
19
|
import { findConfig } from '../utils/findConfig'
|
|
18
|
-
|
|
20
|
+
import type { meshConfig as meshConfigBase } from '@graphcommerce/graphql-mesh/meshConfig'
|
|
21
|
+
// eslint-disable-next-line import/no-unresolved
|
|
19
22
|
import 'tsx/cjs' // support importing typescript configs in CommonJS
|
|
23
|
+
// eslint-disable-next-line import/no-unresolved
|
|
20
24
|
import 'tsx/esm' // support importing typescript configs in ESM
|
|
21
25
|
|
|
22
26
|
dotenv.config()
|
|
@@ -53,9 +57,16 @@ async function cleanup() {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
const main = async () => {
|
|
56
|
-
const
|
|
60
|
+
const baseConf = (await findConfig({})) as YamlConfig.Config
|
|
57
61
|
const graphCommerce = loadConfig(root)
|
|
58
62
|
|
|
63
|
+
// eslint-disable-next-line global-require
|
|
64
|
+
// @ts-ignore Might not exist
|
|
65
|
+
const { meshConfig } = (await import('@graphcommerce/graphql-mesh/meshConfig.interceptor')) as {
|
|
66
|
+
meshConfig: typeof meshConfigBase
|
|
67
|
+
}
|
|
68
|
+
const conf = meshConfig(baseConf, graphCommerce)
|
|
69
|
+
|
|
59
70
|
// We're configuring a custom fetch function
|
|
60
71
|
conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch')
|
|
61
72
|
conf.serve = { ...conf.serve, endpoint: '/api/graphql' }
|
|
@@ -70,6 +81,30 @@ const main = async () => {
|
|
|
70
81
|
return additionalResolver
|
|
71
82
|
})
|
|
72
83
|
|
|
84
|
+
type DefinedHandler = OmitIndexSignature<Handler>
|
|
85
|
+
|
|
86
|
+
conf.sources = conf.sources.map((source) => {
|
|
87
|
+
const definedHandlers = Object.entries(source.handler) as Entries<DefinedHandler>
|
|
88
|
+
return {
|
|
89
|
+
...source,
|
|
90
|
+
handler: Object.fromEntries(
|
|
91
|
+
definedHandlers.map(([key, value]) => {
|
|
92
|
+
if (key === 'openapi' && value) {
|
|
93
|
+
const openapi = value as NonNullable<DefinedHandler['openapi']>
|
|
94
|
+
if (openapi.source.startsWith('@')) {
|
|
95
|
+
return [
|
|
96
|
+
key,
|
|
97
|
+
{ ...openapi, source: path.relative(root, require.resolve(openapi.source)) },
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return [key, value]
|
|
103
|
+
}),
|
|
104
|
+
),
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
|
|
73
108
|
// Rewrite additionalTypeDefs so we can use module resolution more easily
|
|
74
109
|
if (!conf.additionalTypeDefs) conf.additionalTypeDefs = []
|
|
75
110
|
conf.additionalTypeDefs = (
|