@graphcommerce/cli 6.2.0-canary.9 → 6.2.0-canary.90
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 +184 -0
- package/dist/bin/codegen.js +15 -7
- package/dist/bin/graphcommerce.js +30 -7
- package/dist/bin/mesh.js +6 -8
- package/package.json +17 -16
- package/src/bin/codegen.ts +19 -9
- package/src/bin/graphcommerce.ts +10 -11
- package/src/bin/mesh.ts +14 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,189 @@
|
|
|
1
1
|
# @graphcommerce/cli
|
|
2
2
|
|
|
3
|
+
## 6.2.0-canary.90
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2034](https://github.com/graphcommerce-org/graphcommerce/pull/2034) [`6fca47484`](https://github.com/graphcommerce-org/graphcommerce/commit/6fca474847fe52f004a6ac0abbd88492512b46ad) - Pre-resolve the customFetch in mesh config ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
## 6.2.0-canary.89
|
|
10
|
+
|
|
11
|
+
## 6.2.0-canary.88
|
|
12
|
+
|
|
13
|
+
## 6.2.0-canary.87
|
|
14
|
+
|
|
15
|
+
## 6.2.0-canary.86
|
|
16
|
+
|
|
17
|
+
## 6.2.0-canary.85
|
|
18
|
+
|
|
19
|
+
## 6.2.0-canary.84
|
|
20
|
+
|
|
21
|
+
## 6.2.0-canary.83
|
|
22
|
+
|
|
23
|
+
## 6.2.0-canary.82
|
|
24
|
+
|
|
25
|
+
## 6.2.0-canary.81
|
|
26
|
+
|
|
27
|
+
## 6.2.0-canary.80
|
|
28
|
+
|
|
29
|
+
## 6.2.0-canary.79
|
|
30
|
+
|
|
31
|
+
## 6.2.0-canary.78
|
|
32
|
+
|
|
33
|
+
## 6.2.0-canary.77
|
|
34
|
+
|
|
35
|
+
## 6.2.0-canary.76
|
|
36
|
+
|
|
37
|
+
## 6.2.0-canary.75
|
|
38
|
+
|
|
39
|
+
## 6.2.0-canary.74
|
|
40
|
+
|
|
41
|
+
## 6.2.0-canary.73
|
|
42
|
+
|
|
43
|
+
## 6.2.0-canary.72
|
|
44
|
+
|
|
45
|
+
## 6.2.0-canary.71
|
|
46
|
+
|
|
47
|
+
## 6.2.0-canary.70
|
|
48
|
+
|
|
49
|
+
## 6.2.0-canary.69
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- [#2012](https://github.com/graphcommerce-org/graphcommerce/pull/2012) [`1dbb3ae13`](https://github.com/graphcommerce-org/graphcommerce/commit/1dbb3ae13553992ee1ed77f375375560f28c418c) - Upgrade graphql to 16.7.1, add graphql as peer dependency ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
54
|
+
|
|
55
|
+
## 6.2.0-canary.68
|
|
56
|
+
|
|
57
|
+
## 6.2.0-canary.67
|
|
58
|
+
|
|
59
|
+
## 6.2.0-canary.66
|
|
60
|
+
|
|
61
|
+
## 6.2.0-canary.65
|
|
62
|
+
|
|
63
|
+
## 6.2.0-canary.64
|
|
64
|
+
|
|
65
|
+
## 6.2.0-canary.63
|
|
66
|
+
|
|
67
|
+
## 6.2.0-canary.62
|
|
68
|
+
|
|
69
|
+
## 6.2.0-canary.61
|
|
70
|
+
|
|
71
|
+
## 6.2.0-canary.60
|
|
72
|
+
|
|
73
|
+
## 6.2.0-canary.59
|
|
74
|
+
|
|
75
|
+
## 6.2.0-canary.58
|
|
76
|
+
|
|
77
|
+
## 6.2.0-canary.57
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#1982](https://github.com/graphcommerce-org/graphcommerce/pull/1982) [`e1fab2f6d`](https://github.com/graphcommerce-org/graphcommerce/commit/e1fab2f6d8f57d0488d8a915596d5c19cb7718e6) - Better detection what the package roots are when a custom node_modules directory is used ([@paales](https://github.com/paales))
|
|
82
|
+
|
|
83
|
+
## 6.2.0-canary.56
|
|
84
|
+
|
|
85
|
+
## 6.2.0-canary.55
|
|
86
|
+
|
|
87
|
+
## 6.2.0-canary.54
|
|
88
|
+
|
|
89
|
+
## 6.2.0-canary.53
|
|
90
|
+
|
|
91
|
+
## 6.2.0-canary.52
|
|
92
|
+
|
|
93
|
+
## 6.2.0-canary.51
|
|
94
|
+
|
|
95
|
+
## 6.2.0-canary.50
|
|
96
|
+
|
|
97
|
+
## 6.2.0-canary.49
|
|
98
|
+
|
|
99
|
+
## 6.2.0-canary.48
|
|
100
|
+
|
|
101
|
+
## 6.2.0-canary.47
|
|
102
|
+
|
|
103
|
+
## 6.2.0-canary.46
|
|
104
|
+
|
|
105
|
+
## 6.2.0-canary.45
|
|
106
|
+
|
|
107
|
+
## 6.2.0-canary.44
|
|
108
|
+
|
|
109
|
+
## 6.2.0-canary.43
|
|
110
|
+
|
|
111
|
+
## 6.2.0-canary.42
|
|
112
|
+
|
|
113
|
+
## 6.2.0-canary.41
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`f78caf5a8`](https://github.com/graphcommerce-org/graphcommerce/commit/f78caf5a83683f1ae4b901fb94bd22d50943fa2f) - Updated packages @apollo/client, react-hook-form, @emotion/\*, @lingui/\*, @mui/\* and various others. ([@paales](https://github.com/paales))
|
|
118
|
+
|
|
119
|
+
- [#1960](https://github.com/graphcommerce-org/graphcommerce/pull/1960) [`86e14569b`](https://github.com/graphcommerce-org/graphcommerce/commit/86e14569b1f68f73be7f93b614e36b382c5debff) - Updated to the latest release of GraphQL codegen and solve compatibility issues with our own generator ([@paales](https://github.com/paales))
|
|
120
|
+
|
|
121
|
+
## 6.2.0-canary.40
|
|
122
|
+
|
|
123
|
+
## 6.2.0-canary.39
|
|
124
|
+
|
|
125
|
+
## 6.2.0-canary.38
|
|
126
|
+
|
|
127
|
+
## 6.2.0-canary.37
|
|
128
|
+
|
|
129
|
+
## 6.2.0-canary.36
|
|
130
|
+
|
|
131
|
+
## 6.2.0-canary.35
|
|
132
|
+
|
|
133
|
+
## 6.2.0-canary.34
|
|
134
|
+
|
|
135
|
+
## 6.2.0-canary.33
|
|
136
|
+
|
|
137
|
+
## 6.2.0-canary.32
|
|
138
|
+
|
|
139
|
+
## 6.2.0-canary.31
|
|
140
|
+
|
|
141
|
+
## 6.2.0-canary.30
|
|
142
|
+
|
|
143
|
+
## 6.2.0-canary.29
|
|
144
|
+
|
|
145
|
+
## 6.2.0-canary.28
|
|
146
|
+
|
|
147
|
+
## 6.2.0-canary.27
|
|
148
|
+
|
|
149
|
+
## 6.2.0-canary.26
|
|
150
|
+
|
|
151
|
+
## 6.2.0-canary.25
|
|
152
|
+
|
|
153
|
+
## 6.2.0-canary.24
|
|
154
|
+
|
|
155
|
+
## 6.2.0-canary.23
|
|
156
|
+
|
|
157
|
+
## 6.2.0-canary.22
|
|
158
|
+
|
|
159
|
+
## 6.2.0-canary.21
|
|
160
|
+
|
|
161
|
+
## 6.2.0-canary.20
|
|
162
|
+
|
|
163
|
+
## 6.2.0-canary.19
|
|
164
|
+
|
|
165
|
+
## 6.2.0-canary.18
|
|
166
|
+
|
|
167
|
+
## 6.2.0-canary.17
|
|
168
|
+
|
|
169
|
+
## 6.2.0-canary.16
|
|
170
|
+
|
|
171
|
+
## 6.2.0-canary.15
|
|
172
|
+
|
|
173
|
+
## 6.2.0-canary.14
|
|
174
|
+
|
|
175
|
+
## 6.2.0-canary.13
|
|
176
|
+
|
|
177
|
+
### Patch Changes
|
|
178
|
+
|
|
179
|
+
- [#1924](https://github.com/graphcommerce-org/graphcommerce/pull/1924) [`04581f619`](https://github.com/graphcommerce-org/graphcommerce/commit/04581f619c609f2f6ca5268ee5effb6a1db3f0eb) - Use the latest branch from graphql-mesh so that all versions are in sync ([@paales](https://github.com/paales))
|
|
180
|
+
|
|
181
|
+
## 6.2.0-canary.12
|
|
182
|
+
|
|
183
|
+
## 6.2.0-canary.11
|
|
184
|
+
|
|
185
|
+
## 6.2.0-canary.10
|
|
186
|
+
|
|
3
187
|
## 6.2.0-canary.9
|
|
4
188
|
|
|
5
189
|
## 6.2.0-canary.8
|
package/dist/bin/codegen.js
CHANGED
|
@@ -10,7 +10,7 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
10
10
|
const next_config_1 = require("@graphcommerce/next-config");
|
|
11
11
|
const cli_1 = require("@graphql-codegen/cli");
|
|
12
12
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
13
|
-
const rimraf_1 =
|
|
13
|
+
const rimraf_1 = require("rimraf");
|
|
14
14
|
const yaml_1 = __importDefault(require("yaml"));
|
|
15
15
|
const [, , cmd] = process.argv;
|
|
16
16
|
dotenv_1.default.config();
|
|
@@ -39,14 +39,19 @@ async function main() {
|
|
|
39
39
|
if (process.argv.includes('--config') || process.argv.includes('-c')) {
|
|
40
40
|
throw Error('--config or -c argument is not supported, modify codegen.yml to make changes');
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const isMono = !!packages.find((p) => p.startsWith('../..'));
|
|
42
|
+
const deps = (0, next_config_1.resolveDependenciesSync)();
|
|
43
|
+
const packages = [...deps.values()].filter((p) => p !== '.');
|
|
45
44
|
// Load the current codegen.yml
|
|
46
45
|
// Todo: implement loading with a custom --config or -c here.
|
|
47
46
|
const conf = await (0, cli_1.loadCodegenConfig)({ configFilePath: root });
|
|
48
47
|
// Get a a list of all generates configurations.
|
|
49
|
-
const generates = Object.entries(conf.config.generates)
|
|
48
|
+
const generates = Object.entries(conf.config.generates).map(([generatedPath, value]) => {
|
|
49
|
+
const found = [...deps.entries()].find((dep) => generatedPath.startsWith(`node_modules/${dep[0]}`));
|
|
50
|
+
if (!found)
|
|
51
|
+
return [generatedPath, value];
|
|
52
|
+
const newPath = generatedPath.replace(`node_modules/${found[0]}`, found[1]);
|
|
53
|
+
return [newPath, value];
|
|
54
|
+
});
|
|
50
55
|
let extension;
|
|
51
56
|
// Find the file extension used for the generated graphql files and cleanup if not used anymore.
|
|
52
57
|
generates.forEach(([, gen]) => {
|
|
@@ -57,13 +62,16 @@ async function main() {
|
|
|
57
62
|
});
|
|
58
63
|
const isWatching = process.argv.includes('--watch') || process.argv.includes('-w');
|
|
59
64
|
if (!isWatching && extension)
|
|
60
|
-
(0, rimraf_1.
|
|
65
|
+
await (0, rimraf_1.rimraf)(node_path_1.default.join(root, `**/*${extension}`));
|
|
61
66
|
// - Prepend the all targets with ../../ if we're running in a monorepo setup.
|
|
62
67
|
// - Append all the Graphcommerce packages to the configuration
|
|
63
68
|
conf.config.generates = Object.fromEntries(generates.map(([generateTarget, generateConf]) => [
|
|
64
|
-
|
|
69
|
+
generateTarget,
|
|
65
70
|
Array.isArray(generateConf) ? generateConf : appendDocumentLocations(generateConf, packages),
|
|
66
71
|
]));
|
|
72
|
+
(0, next_config_1.packageRoots)(packages).forEach((r) => {
|
|
73
|
+
conf.config.generates[r] = conf.config.generates['.'];
|
|
74
|
+
});
|
|
67
75
|
// Reexport the mesh to is can be used by codegen
|
|
68
76
|
await promises_1.default.writeFile(configLocation, yaml_1.default.stringify(conf.config));
|
|
69
77
|
// Append the new cli argument
|
|
@@ -1,20 +1,43 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const hygraph_cli_1 = require("@graphcommerce/hygraph-cli");
|
|
5
|
-
const next_config_1 = require("@graphcommerce/next-config");
|
|
6
27
|
const commands = {
|
|
7
|
-
'codegen-config':
|
|
8
|
-
'export-config':
|
|
9
|
-
'hygraph-migrate':
|
|
28
|
+
'codegen-config': () => Promise.resolve().then(() => __importStar(require('@graphcommerce/next-config'))).then((m) => m.generateConfig),
|
|
29
|
+
'export-config': () => Promise.resolve().then(() => __importStar(require('@graphcommerce/next-config'))).then((m) => m.exportConfig),
|
|
30
|
+
'hygraph-migrate': () => Promise.resolve().then(() => __importStar(require('@graphcommerce/hygraph-cli'))).then((m) => m.migrateHygraph),
|
|
10
31
|
};
|
|
11
32
|
const args = process.argv.slice(2);
|
|
12
33
|
const command = args[0];
|
|
13
|
-
if (!commands
|
|
34
|
+
if (!(command in commands)) {
|
|
14
35
|
console.error(`Unknown command: ${args.join(' ')}, possible commands: ${Object.keys(commands).join(', ')}`);
|
|
15
36
|
process.exit(1);
|
|
16
37
|
}
|
|
17
|
-
commands[command]()
|
|
38
|
+
commands[command]()
|
|
39
|
+
.then((c) => c())
|
|
40
|
+
.catch((e) => {
|
|
18
41
|
console.error(e);
|
|
19
42
|
process.exit(1);
|
|
20
43
|
});
|
package/dist/bin/mesh.js
CHANGED
|
@@ -49,7 +49,7 @@ async function cleanup() {
|
|
|
49
49
|
const main = async () => {
|
|
50
50
|
const conf = (await (0, findConfig_1.findConfig)({}));
|
|
51
51
|
// We're configuring a custom fetch function
|
|
52
|
-
conf.customFetch = '@graphcommerce/graphql-mesh/customFetch';
|
|
52
|
+
conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch');
|
|
53
53
|
conf.serve = { ...conf.serve, endpoint: '/api/graphql' };
|
|
54
54
|
// Rewrite additionalResolvers so we can use module resolution more easily
|
|
55
55
|
conf.additionalResolvers = conf.additionalResolvers ?? [];
|
|
@@ -70,13 +70,11 @@ const main = async () => {
|
|
|
70
70
|
});
|
|
71
71
|
// Scan the current working directory to also read all graphqls files.
|
|
72
72
|
conf.additionalTypeDefs.push('**/*.graphqls');
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
conf.additionalTypeDefs.push('node_modules/@graphcommerce/**/*.graphqls');
|
|
79
|
-
}
|
|
73
|
+
const deps = (0, next_config_1.resolveDependenciesSync)();
|
|
74
|
+
const packages = [...deps.values()].filter((p) => p !== '.');
|
|
75
|
+
(0, next_config_1.packageRoots)(packages).forEach((r) => {
|
|
76
|
+
conf.additionalTypeDefs.push(`${r}/**/*.graphqls`);
|
|
77
|
+
});
|
|
80
78
|
if (!conf.serve)
|
|
81
79
|
conf.serve = {};
|
|
82
80
|
if (!conf.serve.playgroundTitle)
|
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": "6.2.0-canary.
|
|
5
|
+
"version": "6.2.0-canary.90",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"scripts": {
|
|
@@ -24,27 +24,28 @@
|
|
|
24
24
|
"graphcommerce": "dist/bin/graphcommerce.js"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@graphcommerce/
|
|
28
|
-
"@graphcommerce/
|
|
29
|
-
"@graphql-codegen/cli": "
|
|
30
|
-
"@graphql-mesh/cli": "
|
|
31
|
-
"@graphql-mesh/types": "
|
|
32
|
-
"@graphql-mesh/utils": "
|
|
33
|
-
"cosmiconfig": "^8.
|
|
27
|
+
"@graphcommerce/hygraph-cli": "6.2.0-canary.90",
|
|
28
|
+
"@graphcommerce/next-config": "6.2.0-canary.90",
|
|
29
|
+
"@graphql-codegen/cli": "4.0.1",
|
|
30
|
+
"@graphql-mesh/cli": "latest",
|
|
31
|
+
"@graphql-mesh/types": "latest",
|
|
32
|
+
"@graphql-mesh/utils": "latest",
|
|
33
|
+
"cosmiconfig": "^8.2.0",
|
|
34
34
|
"detect-package-manager": "^2.0.1",
|
|
35
|
-
"graphql": "
|
|
36
|
-
"graphql-codegen-typescript-validation-schema": "^0.7.1",
|
|
35
|
+
"graphql-codegen-typescript-validation-schema": "^0.11.1",
|
|
37
36
|
"graphql-tag": "^2.12.6",
|
|
38
|
-
"rimraf": "^
|
|
37
|
+
"rimraf": "^5.0.1",
|
|
39
38
|
"ts-node": "^10.9.1"
|
|
40
39
|
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"graphql": "^16.7.1"
|
|
42
|
+
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@graphcommerce/eslint-config-pwa": "6.2.0-canary.
|
|
43
|
-
"@graphcommerce/prettier-config-pwa": "6.2.0-canary.
|
|
44
|
-
"@graphcommerce/typescript-config-pwa": "6.2.0-canary.
|
|
45
|
-
"@types/rimraf": "^3.0.2",
|
|
44
|
+
"@graphcommerce/eslint-config-pwa": "6.2.0-canary.90",
|
|
45
|
+
"@graphcommerce/prettier-config-pwa": "6.2.0-canary.90",
|
|
46
|
+
"@graphcommerce/typescript-config-pwa": "6.2.0-canary.90",
|
|
46
47
|
"react": "^18.2.0",
|
|
47
|
-
"typescript": "
|
|
48
|
+
"typescript": "5.1.3"
|
|
48
49
|
},
|
|
49
50
|
"sideEffects": false,
|
|
50
51
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
package/src/bin/codegen.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
3
|
import fs from 'node:fs/promises'
|
|
4
4
|
import path from 'node:path'
|
|
5
|
-
import { resolveDependenciesSync } from '@graphcommerce/next-config'
|
|
5
|
+
import { packageRoots, resolveDependenciesSync } from '@graphcommerce/next-config'
|
|
6
6
|
import { runCli, cliError, loadCodegenConfig } from '@graphql-codegen/cli'
|
|
7
7
|
import { Types } from '@graphql-codegen/plugin-helpers'
|
|
8
8
|
import dotenv from 'dotenv'
|
|
9
|
-
import rimraf from 'rimraf'
|
|
9
|
+
import { rimraf } from 'rimraf'
|
|
10
10
|
import yaml from 'yaml'
|
|
11
11
|
|
|
12
12
|
const [, , cmd] = process.argv
|
|
@@ -44,17 +44,23 @@ async function main() {
|
|
|
44
44
|
throw Error('--config or -c argument is not supported, modify codegen.yml to make changes')
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
// Detect if we're operating in the monorepo environment or in an installation
|
|
50
|
-
const isMono = !!packages.find((p) => p.startsWith('../..'))
|
|
47
|
+
const deps = resolveDependenciesSync()
|
|
48
|
+
const packages = [...deps.values()].filter((p) => p !== '.')
|
|
51
49
|
|
|
52
50
|
// Load the current codegen.yml
|
|
53
51
|
// Todo: implement loading with a custom --config or -c here.
|
|
54
52
|
const conf = await loadCodegenConfig({ configFilePath: root })
|
|
55
53
|
|
|
56
54
|
// Get a a list of all generates configurations.
|
|
57
|
-
const generates = Object.entries(conf.config.generates)
|
|
55
|
+
const generates = Object.entries(conf.config.generates).map(([generatedPath, value]) => {
|
|
56
|
+
const found = [...deps.entries()].find((dep) =>
|
|
57
|
+
generatedPath.startsWith(`node_modules/${dep[0]}`),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if (!found) return [generatedPath, value] as const
|
|
61
|
+
const newPath = generatedPath.replace(`node_modules/${found[0]}`, found[1])
|
|
62
|
+
return [newPath, value] as const
|
|
63
|
+
})
|
|
58
64
|
|
|
59
65
|
let extension: string | undefined
|
|
60
66
|
|
|
@@ -65,17 +71,21 @@ async function main() {
|
|
|
65
71
|
})
|
|
66
72
|
|
|
67
73
|
const isWatching = process.argv.includes('--watch') || process.argv.includes('-w')
|
|
68
|
-
if (!isWatching && extension) rimraf(path.join(root, `**/*${extension}`)
|
|
74
|
+
if (!isWatching && extension) await rimraf(path.join(root, `**/*${extension}`))
|
|
69
75
|
|
|
70
76
|
// - Prepend the all targets with ../../ if we're running in a monorepo setup.
|
|
71
77
|
// - Append all the Graphcommerce packages to the configuration
|
|
72
78
|
conf.config.generates = Object.fromEntries(
|
|
73
79
|
generates.map(([generateTarget, generateConf]) => [
|
|
74
|
-
|
|
80
|
+
generateTarget,
|
|
75
81
|
Array.isArray(generateConf) ? generateConf : appendDocumentLocations(generateConf, packages),
|
|
76
82
|
]),
|
|
77
83
|
)
|
|
78
84
|
|
|
85
|
+
packageRoots(packages).forEach((r) => {
|
|
86
|
+
conf.config.generates[r] = conf.config.generates['.']
|
|
87
|
+
})
|
|
88
|
+
|
|
79
89
|
// Reexport the mesh to is can be used by codegen
|
|
80
90
|
await fs.writeFile(configLocation, yaml.stringify(conf.config))
|
|
81
91
|
|
package/src/bin/graphcommerce.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { migrateHygraph } from '@graphcommerce/hygraph-cli'
|
|
4
|
-
import { generateConfig, exportConfig } from '@graphcommerce/next-config'
|
|
5
|
-
|
|
6
3
|
const commands = {
|
|
7
|
-
'codegen-config': generateConfig,
|
|
8
|
-
'export-config': exportConfig,
|
|
9
|
-
'hygraph-migrate': migrateHygraph,
|
|
4
|
+
'codegen-config': () => import('@graphcommerce/next-config').then((m) => m.generateConfig),
|
|
5
|
+
'export-config': () => import('@graphcommerce/next-config').then((m) => m.exportConfig),
|
|
6
|
+
'hygraph-migrate': () => import('@graphcommerce/hygraph-cli').then((m) => m.migrateHygraph),
|
|
10
7
|
}
|
|
11
8
|
|
|
12
9
|
const args = process.argv.slice(2)
|
|
13
10
|
const command = args[0] as keyof typeof commands
|
|
14
11
|
|
|
15
|
-
if (!commands
|
|
12
|
+
if (!(command in commands)) {
|
|
16
13
|
console.error(
|
|
17
14
|
`Unknown command: ${args.join(' ')}, possible commands: ${Object.keys(commands).join(', ')}`,
|
|
18
15
|
)
|
|
19
16
|
process.exit(1)
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
commands[command]()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
commands[command]()
|
|
20
|
+
.then((c) => c())
|
|
21
|
+
.catch((e) => {
|
|
22
|
+
console.error(e)
|
|
23
|
+
process.exit(1)
|
|
24
|
+
})
|
package/src/bin/mesh.ts
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
import { promises as fs } from 'node:fs'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { exit } from 'node:process'
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
isMonorepo,
|
|
8
|
+
loadConfig,
|
|
9
|
+
packageRoots,
|
|
10
|
+
replaceConfigInString,
|
|
11
|
+
resolveDependenciesSync,
|
|
12
|
+
} from '@graphcommerce/next-config'
|
|
7
13
|
import { graphqlMesh, DEFAULT_CLI_PARAMS, GraphQLMeshCLIParams } from '@graphql-mesh/cli'
|
|
8
14
|
import { Logger, YamlConfig } from '@graphql-mesh/types'
|
|
9
15
|
import { DefaultLogger } from '@graphql-mesh/utils'
|
|
@@ -48,7 +54,7 @@ const main = async () => {
|
|
|
48
54
|
const conf = (await findConfig({})) as YamlConfig.Config
|
|
49
55
|
|
|
50
56
|
// We're configuring a custom fetch function
|
|
51
|
-
conf.customFetch = '@graphcommerce/graphql-mesh/customFetch'
|
|
57
|
+
conf.customFetch = require.resolve('@graphcommerce/graphql-mesh/customFetch')
|
|
52
58
|
conf.serve = { ...conf.serve, endpoint: '/api/graphql' }
|
|
53
59
|
|
|
54
60
|
// Rewrite additionalResolvers so we can use module resolution more easily
|
|
@@ -74,12 +80,12 @@ const main = async () => {
|
|
|
74
80
|
|
|
75
81
|
// Scan the current working directory to also read all graphqls files.
|
|
76
82
|
conf.additionalTypeDefs.push('**/*.graphqls')
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
conf.additionalTypeDefs.push(
|
|
82
|
-
}
|
|
83
|
+
|
|
84
|
+
const deps = resolveDependenciesSync()
|
|
85
|
+
const packages = [...deps.values()].filter((p) => p !== '.')
|
|
86
|
+
packageRoots(packages).forEach((r) => {
|
|
87
|
+
conf.additionalTypeDefs.push(`${r}/**/*.graphqls`)
|
|
88
|
+
})
|
|
83
89
|
|
|
84
90
|
if (!conf.serve) conf.serve = {}
|
|
85
91
|
if (!conf.serve.playgroundTitle) conf.serve.playgroundTitle = 'GraphCommerce® Mesh'
|