@graphcommerce/cli 9.1.0-canary.54 → 10.0.0-canary.56
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 +82 -0
- package/dist/bin/codegen.js +5758 -9
- package/dist/bin/graphcommerce.js +2 -0
- package/dist/bin/mesh.js +13 -13
- package/package.json +16 -15
- package/src/bin/codegen.ts +10 -2
- package/src/bin/graphcommerce.ts +4 -0
- package/src/bin/mesh.ts +2 -4
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
const commands = {
|
|
3
3
|
codegen: () => import('@graphcommerce/next-config').then((m) => m.codegen),
|
|
4
4
|
"codegen-config": () => import('@graphcommerce/next-config').then((m) => m.generateConfig),
|
|
5
|
+
"codegen-config-values": () => import('@graphcommerce/next-config').then((m) => m.generateConfigValues),
|
|
5
6
|
"copy-files": () => import('@graphcommerce/next-config').then((m) => m.copyFiles),
|
|
6
7
|
"codegen-interceptors": () => import('@graphcommerce/next-config').then((m) => m.codegenInterceptors),
|
|
8
|
+
"cleanup-interceptors": () => import('@graphcommerce/next-config').then((m) => m.cleanupInterceptors),
|
|
7
9
|
"export-config": () => import('@graphcommerce/next-config').then((m) => m.exportConfig),
|
|
8
10
|
"hygraph-migrate": () => import('@graphcommerce/hygraph-cli').then((m) => m.migrateHygraph)
|
|
9
11
|
};
|
package/dist/bin/mesh.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { promises } from 'node:fs';
|
|
3
|
-
import path
|
|
3
|
+
import path from 'node:path';
|
|
4
4
|
import { exit } from 'node:process';
|
|
5
5
|
import { loadConfig, resolveDependenciesSync, sig, packageRoots, replaceConfigInString } from '@graphcommerce/next-config';
|
|
6
6
|
import { DEFAULT_CLI_PARAMS, graphqlMesh } from '@graphql-mesh/cli';
|
|
@@ -9,7 +9,7 @@ import dotenv from 'dotenv';
|
|
|
9
9
|
import 'tsx/cjs';
|
|
10
10
|
import 'tsx/esm';
|
|
11
11
|
import yaml from 'yaml';
|
|
12
|
-
import
|
|
12
|
+
import require$$0 from 'path';
|
|
13
13
|
import { cosmiconfig, defaultLoaders } from 'cosmiconfig';
|
|
14
14
|
|
|
15
15
|
function customLoader(ext, importFn = defaultImportFn, initialLoggerPrefix = "\u{1F578}\uFE0F Mesh") {
|
|
@@ -41,7 +41,7 @@ function customLoader(ext, importFn = defaultImportFn, initialLoggerPrefix = "\u
|
|
|
41
41
|
}
|
|
42
42
|
async function findConfig(options) {
|
|
43
43
|
const { configName = "mesh", dir: configDir = "", initialLoggerPrefix } = options || {};
|
|
44
|
-
const dir =
|
|
44
|
+
const dir = require$$0.isAbsolute(configDir) ? configDir : require$$0.join(process.cwd(), configDir);
|
|
45
45
|
const explorer = cosmiconfig(configName, {
|
|
46
46
|
searchPlaces: [
|
|
47
47
|
"package.json",
|
|
@@ -72,7 +72,7 @@ async function findConfig(options) {
|
|
|
72
72
|
return config;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
dotenv.config();
|
|
75
|
+
dotenv.config({ quiet: true });
|
|
76
76
|
function resolvePath(pathStr) {
|
|
77
77
|
return fileURLToPath(import.meta.resolve(pathStr));
|
|
78
78
|
}
|
|
@@ -82,14 +82,14 @@ function handleFatalError(e, logger = new DefaultLogger("\u25C8")) {
|
|
|
82
82
|
if (process.env.JEST == null) exit(1);
|
|
83
83
|
}
|
|
84
84
|
const root = process.cwd();
|
|
85
|
-
const meshDir = path
|
|
86
|
-
const relativePath = path
|
|
85
|
+
const meshDir = path.dirname(resolvePath("@graphcommerce/graphql-mesh"));
|
|
86
|
+
const relativePath = path.join(path.relative(meshDir, root), "/");
|
|
87
87
|
const cliParams = {
|
|
88
88
|
...DEFAULT_CLI_PARAMS,
|
|
89
89
|
playgroundTitle: "GraphCommerce\xAE Mesh"
|
|
90
90
|
};
|
|
91
91
|
const tmpMesh = "_tmp_mesh";
|
|
92
|
-
const tmpMeshLocation = path
|
|
92
|
+
const tmpMeshLocation = path.join(root, `.${tmpMesh}rc.yml`);
|
|
93
93
|
async function cleanup() {
|
|
94
94
|
try {
|
|
95
95
|
await promises.stat(tmpMeshLocation).then((r) => {
|
|
@@ -103,7 +103,7 @@ async function cleanup() {
|
|
|
103
103
|
const main = async () => {
|
|
104
104
|
const baseConf = await findConfig({});
|
|
105
105
|
const graphCommerce = loadConfig(root);
|
|
106
|
-
const meshConfigf = await import('@graphcommerce/graphql-mesh/meshConfig
|
|
106
|
+
const meshConfigf = await import('@graphcommerce/graphql-mesh/meshConfig');
|
|
107
107
|
const conf = meshConfigf.default.meshConfig(baseConf, graphCommerce);
|
|
108
108
|
conf.customFetch = "@graphcommerce/graphql-mesh/customFetch";
|
|
109
109
|
conf.serve = { ...conf.serve, endpoint: "/api/graphql" };
|
|
@@ -111,7 +111,7 @@ const main = async () => {
|
|
|
111
111
|
conf.additionalResolvers = conf.additionalResolvers?.map((additionalResolver) => {
|
|
112
112
|
if (typeof additionalResolver !== "string") return additionalResolver;
|
|
113
113
|
if (additionalResolver.startsWith("@"))
|
|
114
|
-
return path
|
|
114
|
+
return path.relative(root, resolvePath(additionalResolver));
|
|
115
115
|
return additionalResolver;
|
|
116
116
|
});
|
|
117
117
|
conf.sources = conf.sources.map((source) => {
|
|
@@ -123,7 +123,7 @@ const main = async () => {
|
|
|
123
123
|
if (key === "openapi" && value) {
|
|
124
124
|
const openapi = value;
|
|
125
125
|
if (openapi.source.startsWith("@")) {
|
|
126
|
-
return [key, { ...openapi, source: path
|
|
126
|
+
return [key, { ...openapi, source: path.relative(root, resolvePath(openapi.source)) }];
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
return [key, value];
|
|
@@ -134,7 +134,7 @@ const main = async () => {
|
|
|
134
134
|
if (!conf.additionalTypeDefs) conf.additionalTypeDefs = [];
|
|
135
135
|
conf.additionalTypeDefs = (Array.isArray(conf.additionalTypeDefs) ? conf.additionalTypeDefs : [conf.additionalTypeDefs]).map((additionalTypeDef) => {
|
|
136
136
|
if (typeof additionalTypeDef === "string" && additionalTypeDef.startsWith("@"))
|
|
137
|
-
return path
|
|
137
|
+
return path.relative(root, resolvePath(additionalTypeDef));
|
|
138
138
|
return additionalTypeDef;
|
|
139
139
|
});
|
|
140
140
|
conf.additionalTypeDefs.push("graphql/**/*.graphqls");
|
|
@@ -169,14 +169,14 @@ const main = async () => {
|
|
|
169
169
|
await promises.writeFile(tmpMeshLocation, yamlString);
|
|
170
170
|
await promises.writeFile(
|
|
171
171
|
`${meshDir}/.mesh.ts`,
|
|
172
|
-
`export type * from '${relativePath.split(path
|
|
172
|
+
`export type * from '${relativePath.split(path.sep).join("/")}.mesh'
|
|
173
173
|
export {
|
|
174
174
|
getBuiltMesh as getBuiltMeshBase,
|
|
175
175
|
execute,
|
|
176
176
|
subscribe,
|
|
177
177
|
createBuiltMeshHTTPHandler as createBuiltMeshHTTPHandlerBase,
|
|
178
178
|
rawServeConfig,
|
|
179
|
-
} from '${relativePath.split(path
|
|
179
|
+
} from '${relativePath.split(path.sep).join("/")}.mesh'`,
|
|
180
180
|
{ encoding: "utf8" }
|
|
181
181
|
);
|
|
182
182
|
await graphqlMesh({ ...cliParams, configName: tmpMesh });
|
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": "
|
|
5
|
+
"version": "10.0.0-canary.56",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "pkgroll --clean-dist --watch",
|
|
8
8
|
"build": "pkgroll --clean-dist",
|
|
@@ -22,29 +22,30 @@
|
|
|
22
22
|
"is-monorepo": "dist/bin/is-monorepo.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@graphql-codegen/cli": "
|
|
25
|
+
"@graphql-codegen/cli": "6.1.0",
|
|
26
26
|
"cosmiconfig": "^8.3.6",
|
|
27
27
|
"detect-package-manager": "^3.0.2",
|
|
28
|
-
"dotenv": "16.
|
|
29
|
-
"graphql": "^16.
|
|
30
|
-
"graphql-codegen-typescript-validation-schema": "^0.
|
|
28
|
+
"dotenv": "16.6.1",
|
|
29
|
+
"graphql": "^16.12.0",
|
|
30
|
+
"graphql-codegen-typescript-validation-schema": "^0.18.1",
|
|
31
31
|
"graphql-tag": "^2.12.6",
|
|
32
32
|
"rimraf": "^5.0.10",
|
|
33
33
|
"tslib": "^2.8.1",
|
|
34
|
-
"tsx": "^4.
|
|
35
|
-
"yaml": "2.
|
|
34
|
+
"tsx": "^4.21.0",
|
|
35
|
+
"yaml": "2.8.2",
|
|
36
|
+
"zod": "^3.25.76"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
39
|
-
"@graphcommerce/graphql-mesh": "^
|
|
40
|
-
"@graphcommerce/hygraph-cli": "^
|
|
41
|
-
"@graphcommerce/next-config": "^
|
|
42
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
43
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
39
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.56",
|
|
40
|
+
"@graphcommerce/graphql-mesh": "^10.0.0-canary.56",
|
|
41
|
+
"@graphcommerce/hygraph-cli": "^10.0.0-canary.56",
|
|
42
|
+
"@graphcommerce/next-config": "^10.0.0-canary.56",
|
|
43
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.56",
|
|
44
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.56",
|
|
44
45
|
"@graphql-mesh/cli": "*",
|
|
45
46
|
"@graphql-mesh/types": "*",
|
|
46
47
|
"@graphql-mesh/utils": "*",
|
|
47
|
-
"react": "^
|
|
48
|
+
"react": "^19.2.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependenciesMeta": {
|
|
50
51
|
"@graphcommerce/hygraph-cli": {
|
|
@@ -63,6 +64,6 @@
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
|
-
"pkgroll": "^2.
|
|
67
|
+
"pkgroll": "^2.21.4"
|
|
67
68
|
}
|
|
68
69
|
}
|
package/src/bin/codegen.ts
CHANGED
|
@@ -7,12 +7,13 @@ import { packageRoots, resolveDependenciesSync } from '@graphcommerce/next-confi
|
|
|
7
7
|
import { cliError, loadCodegenConfig, runCli } from '@graphql-codegen/cli'
|
|
8
8
|
import type { Types } from '@graphql-codegen/plugin-helpers'
|
|
9
9
|
import dotenv from 'dotenv'
|
|
10
|
+
import glob from 'fast-glob'
|
|
10
11
|
import { rimraf } from 'rimraf'
|
|
11
12
|
import yaml from 'yaml'
|
|
12
13
|
|
|
13
14
|
const [, , cmd] = process.argv
|
|
14
15
|
|
|
15
|
-
dotenv.config()
|
|
16
|
+
dotenv.config({ quiet: true })
|
|
16
17
|
|
|
17
18
|
const root = process.cwd()
|
|
18
19
|
const configLocation = path.join(root, '._tmp_codegen.yml')
|
|
@@ -34,7 +35,14 @@ function appendDocumentLocations(
|
|
|
34
35
|
packages: string[],
|
|
35
36
|
): Types.ConfiguredOutput {
|
|
36
37
|
const documents = Array.isArray(conf.documents) ? conf.documents : [conf.documents]
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
// Pre-resolve GraphQL files to avoid graphql-codegen following symlinks into node_modules
|
|
40
|
+
const packagePatterns = packages.map((p) => `${p}/**/*.graphql`)
|
|
41
|
+
const resolvedFiles = glob.sync(packagePatterns, {
|
|
42
|
+
ignore: ['**/node_modules/**'],
|
|
43
|
+
followSymbolicLinks: false,
|
|
44
|
+
})
|
|
45
|
+
documents.push(...resolvedFiles)
|
|
38
46
|
|
|
39
47
|
return conf
|
|
40
48
|
}
|
package/src/bin/graphcommerce.ts
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
const commands = {
|
|
4
4
|
codegen: () => import('@graphcommerce/next-config').then((m) => m.codegen),
|
|
5
5
|
'codegen-config': () => import('@graphcommerce/next-config').then((m) => m.generateConfig),
|
|
6
|
+
'codegen-config-values': () =>
|
|
7
|
+
import('@graphcommerce/next-config').then((m) => m.generateConfigValues),
|
|
6
8
|
'copy-files': () => import('@graphcommerce/next-config').then((m) => m.copyFiles),
|
|
7
9
|
'codegen-interceptors': () =>
|
|
8
10
|
import('@graphcommerce/next-config').then((m) => m.codegenInterceptors),
|
|
11
|
+
'cleanup-interceptors': () =>
|
|
12
|
+
import('@graphcommerce/next-config').then((m) => m.cleanupInterceptors),
|
|
9
13
|
'export-config': () => import('@graphcommerce/next-config').then((m) => m.exportConfig),
|
|
10
14
|
'hygraph-migrate': () => import('@graphcommerce/hygraph-cli').then((m) => m.migrateHygraph),
|
|
11
15
|
}
|
package/src/bin/mesh.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type { Entries, OmitIndexSignature } from 'type-fest'
|
|
|
21
21
|
import yaml from 'yaml'
|
|
22
22
|
import { findConfig } from '../utils/findConfig'
|
|
23
23
|
|
|
24
|
-
dotenv.config()
|
|
24
|
+
dotenv.config({ quiet: true })
|
|
25
25
|
|
|
26
26
|
function resolvePath(pathStr: string) {
|
|
27
27
|
return fileURLToPath(import.meta.resolve(pathStr))
|
|
@@ -62,9 +62,7 @@ const main = async () => {
|
|
|
62
62
|
const baseConf = (await findConfig({})) as YamlConfig.Config
|
|
63
63
|
const graphCommerce = loadConfig(root)
|
|
64
64
|
|
|
65
|
-
const meshConfigf = (await import(
|
|
66
|
-
'@graphcommerce/graphql-mesh/meshConfig.interceptor'
|
|
67
|
-
)) as unknown as {
|
|
65
|
+
const meshConfigf = (await import('@graphcommerce/graphql-mesh/meshConfig')) as unknown as {
|
|
68
66
|
default: {
|
|
69
67
|
meshConfig: typeof meshConfigBase
|
|
70
68
|
}
|