@graphcommerce/cli 6.2.0-canary.56 → 6.2.0-canary.58

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @graphcommerce/cli
2
2
 
3
+ ## 6.2.0-canary.58
4
+
5
+ ## 6.2.0-canary.57
6
+
7
+ ### Patch Changes
8
+
9
+ - [#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))
10
+
3
11
  ## 6.2.0-canary.56
4
12
 
5
13
  ## 6.2.0-canary.55
@@ -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 packages = [...(0, next_config_1.resolveDependenciesSync)().values()].filter((p) => p !== '.');
43
- // Detect if we're operating in the monorepo environment or in an installation
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]) => {
@@ -61,9 +66,12 @@ async function main() {
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
- isMono ? `../../${generateTarget}` : generateTarget,
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
package/dist/bin/mesh.js CHANGED
@@ -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
- if ((0, next_config_1.isMonorepo)()) {
74
- conf.additionalTypeDefs.push('../../packages/**/*.graphqls');
75
- conf.additionalTypeDefs.push('../../packagesDev/**/*.graphqls');
76
- }
77
- else {
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.56",
5
+ "version": "6.2.0-canary.58",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "scripts": {
@@ -24,8 +24,8 @@
24
24
  "graphcommerce": "dist/bin/graphcommerce.js"
25
25
  },
26
26
  "dependencies": {
27
- "@graphcommerce/hygraph-cli": "6.2.0-canary.56",
28
- "@graphcommerce/next-config": "6.2.0-canary.56",
27
+ "@graphcommerce/hygraph-cli": "6.2.0-canary.58",
28
+ "@graphcommerce/next-config": "6.2.0-canary.58",
29
29
  "@graphql-codegen/cli": "4.0.1",
30
30
  "@graphql-mesh/cli": "latest",
31
31
  "@graphql-mesh/types": "latest",
@@ -39,9 +39,9 @@
39
39
  "ts-node": "^10.9.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@graphcommerce/eslint-config-pwa": "6.2.0-canary.56",
43
- "@graphcommerce/prettier-config-pwa": "6.2.0-canary.56",
44
- "@graphcommerce/typescript-config-pwa": "6.2.0-canary.56",
42
+ "@graphcommerce/eslint-config-pwa": "6.2.0-canary.58",
43
+ "@graphcommerce/prettier-config-pwa": "6.2.0-canary.58",
44
+ "@graphcommerce/typescript-config-pwa": "6.2.0-canary.58",
45
45
  "@types/rimraf": "^4.0.5",
46
46
  "react": "^18.2.0",
47
47
  "typescript": "5.1.3"
@@ -2,7 +2,7 @@
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'
@@ -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 packages = [...resolveDependenciesSync().values()].filter((p) => p !== '.')
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
 
@@ -71,11 +77,15 @@ async function main() {
71
77
  // - Append all the Graphcommerce packages to the configuration
72
78
  conf.config.generates = Object.fromEntries(
73
79
  generates.map(([generateTarget, generateConf]) => [
74
- isMono ? `../../${generateTarget}` : generateTarget,
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/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 { isMonorepo, loadConfig, replaceConfigInString } from '@graphcommerce/next-config'
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'
@@ -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
- if (isMonorepo()) {
78
- conf.additionalTypeDefs.push('../../packages/**/*.graphqls')
79
- conf.additionalTypeDefs.push('../../packagesDev/**/*.graphqls')
80
- } else {
81
- conf.additionalTypeDefs.push('node_modules/@graphcommerce/**/*.graphqls')
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'