@graphcommerce/cli 1.0.4 → 1.0.7

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,25 @@
1
1
  # @graphcommerce/cli
2
2
 
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1562](https://github.com/graphcommerce-org/graphcommerce/pull/1562) [`01f1588c9`](https://github.com/graphcommerce-org/graphcommerce/commit/01f1588c9200bb39dd61146e260bfa2b32060612) Thanks [@paales](https://github.com/paales)! - The context was missing in apollo client
8
+
9
+ * [#1501](https://github.com/graphcommerce-org/graphcommerce/pull/1501) [`475d23197`](https://github.com/graphcommerce-org/graphcommerce/commit/475d23197a6ce4b08cc325f872834ca592aa28dc) Thanks [@paales](https://github.com/paales)! - Native windows support added: Directory separator differences and package.json interpretation differences
10
+
11
+ ## 1.0.6
12
+
13
+ ### Patch Changes
14
+
15
+ - [#1552](https://github.com/graphcommerce-org/graphcommerce/pull/1552) [`18054c441`](https://github.com/graphcommerce-org/graphcommerce/commit/18054c441962ba750bed3acc39ab46c8d3a341ce) Thanks [@paales](https://github.com/paales)! - Updated to Next.js v12.2.2 and other packages and made compatible
16
+
17
+ ## 1.0.5
18
+
19
+ ### Patch Changes
20
+
21
+ - [#1490](https://github.com/graphcommerce-org/graphcommerce/pull/1490) [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb) Thanks [@paales](https://github.com/paales)! - upgraded packages
22
+
3
23
  ## 1.0.4
4
24
 
5
25
  ### Patch Changes
package/bin/mesh.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
3
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
4
- import { promises as fs } from 'fs'
5
- import path from 'path'
6
- import { exit } from 'process'
4
+ import { promises as fs } from 'node:fs'
5
+ import path from 'node:path'
6
+ import { exit } from 'node:process'
7
7
  import { graphqlMesh, DEFAULT_CLI_PARAMS, GraphQLMeshCLIParams } from '@graphql-mesh/cli'
8
8
  import { Logger, YamlConfig } from '@graphql-mesh/types'
9
9
  import { DefaultLogger } from '@graphql-mesh/utils'
@@ -24,7 +24,7 @@ const root = process.cwd()
24
24
  const meshDir = path.dirname(require.resolve('@graphcommerce/graphql-mesh'))
25
25
  const relativePath = path.join(path.relative(meshDir, root), '/')
26
26
 
27
- const isMonoRepo = relativePath.startsWith('../../examples')
27
+ const isMonoRepo = relativePath.startsWith(`..${path.sep}..${path.sep}examples`)
28
28
 
29
29
  const cliParams: GraphQLMeshCLIParams = {
30
30
  ...DEFAULT_CLI_PARAMS,
@@ -84,9 +84,11 @@ const main = async () => {
84
84
  await fs.writeFile(tmpMeshLocation, yaml.stringify(conf))
85
85
 
86
86
  // Reexport the mesh to is can be used by packages
87
- await fs.writeFile(`${meshDir}/.mesh.ts`, `export * from '${relativePath}.mesh'`, {
88
- encoding: 'utf8',
89
- })
87
+ await fs.writeFile(
88
+ `${meshDir}/.mesh.ts`,
89
+ `export * from '${relativePath.split(path.sep).join('/')}.mesh'`,
90
+ { encoding: 'utf8' },
91
+ )
90
92
 
91
93
  await graphqlMesh({ ...cliParams, configName: tmpMesh })
92
94
 
package/dist/bin/mesh.js CHANGED
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.handleFatalError = void 0;
8
8
  /* eslint-disable import/no-extraneous-dependencies */
9
9
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
10
- const fs_1 = require("fs");
11
- const path_1 = __importDefault(require("path"));
12
- const process_1 = require("process");
10
+ const node_fs_1 = require("node:fs");
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const node_process_1 = require("node:process");
13
13
  const cli_1 = require("@graphql-mesh/cli");
14
14
  const utils_1 = require("@graphql-mesh/utils");
15
15
  const dotenv_1 = __importDefault(require("dotenv"));
@@ -21,24 +21,24 @@ function handleFatalError(e, logger = new utils_1.DefaultLogger('◈')) {
21
21
  // eslint-disable-next-line no-console
22
22
  console.log(e);
23
23
  if (process.env.JEST == null)
24
- (0, process_1.exit)(1);
24
+ (0, node_process_1.exit)(1);
25
25
  }
26
26
  exports.handleFatalError = handleFatalError;
27
27
  const root = process.cwd();
28
- const meshDir = path_1.default.dirname(require.resolve('@graphcommerce/graphql-mesh'));
29
- const relativePath = path_1.default.join(path_1.default.relative(meshDir, root), '/');
30
- const isMonoRepo = relativePath.startsWith('../../examples');
28
+ const meshDir = node_path_1.default.dirname(require.resolve('@graphcommerce/graphql-mesh'));
29
+ const relativePath = node_path_1.default.join(node_path_1.default.relative(meshDir, root), '/');
30
+ const isMonoRepo = relativePath.startsWith(`..${node_path_1.default.sep}..${node_path_1.default.sep}examples`);
31
31
  const cliParams = {
32
32
  ...cli_1.DEFAULT_CLI_PARAMS,
33
33
  playgroundTitle: 'GraphCommerce® Mesh',
34
34
  };
35
35
  const tmpMesh = `_tmp_mesh_${Math.random().toString(36).substring(2, 15)}`;
36
- const tmpMeshLocation = path_1.default.join(root, `.${tmpMesh}rc.yml`);
36
+ const tmpMeshLocation = node_path_1.default.join(root, `.${tmpMesh}rc.yml`);
37
37
  async function cleanup() {
38
38
  try {
39
- await fs_1.promises.stat(tmpMeshLocation).then((r) => {
39
+ await node_fs_1.promises.stat(tmpMeshLocation).then((r) => {
40
40
  if (r.isFile())
41
- return fs_1.promises.unlink(tmpMeshLocation);
41
+ return node_fs_1.promises.unlink(tmpMeshLocation);
42
42
  });
43
43
  }
44
44
  catch (e) {
@@ -54,7 +54,7 @@ const main = async () => {
54
54
  if (typeof additionalResolver !== 'string')
55
55
  return additionalResolver;
56
56
  if (additionalResolver.startsWith('@'))
57
- return path_1.default.relative(root, require.resolve(additionalResolver));
57
+ return node_path_1.default.relative(root, require.resolve(additionalResolver));
58
58
  return additionalResolver;
59
59
  });
60
60
  // Rewrite additionalTypeDefs so we can use module resolution more easily
@@ -62,7 +62,7 @@ const main = async () => {
62
62
  conf.additionalTypeDefs = [];
63
63
  conf.additionalTypeDefs = (Array.isArray(conf.additionalTypeDefs) ? conf.additionalTypeDefs : [conf.additionalTypeDefs]).map((additionalTypeDef) => {
64
64
  if (additionalTypeDef.startsWith('@'))
65
- return path_1.default.relative(root, require.resolve(additionalTypeDef));
65
+ return node_path_1.default.relative(root, require.resolve(additionalTypeDef));
66
66
  return additionalTypeDef;
67
67
  });
68
68
  // Scan the current working directory to also read all graphqls files.
@@ -78,11 +78,9 @@ const main = async () => {
78
78
  conf.serve = {};
79
79
  if (!conf.serve.playgroundTitle)
80
80
  conf.serve.playgroundTitle = 'GraphCommerce® Mesh';
81
- await fs_1.promises.writeFile(tmpMeshLocation, yaml_1.default.stringify(conf));
81
+ await node_fs_1.promises.writeFile(tmpMeshLocation, yaml_1.default.stringify(conf));
82
82
  // Reexport the mesh to is can be used by packages
83
- await fs_1.promises.writeFile(`${meshDir}/.mesh.ts`, `export * from '${relativePath}.mesh'`, {
84
- encoding: 'utf8',
85
- });
83
+ await node_fs_1.promises.writeFile(`${meshDir}/.mesh.ts`, `export * from '${relativePath.split(node_path_1.default.sep).join('/')}.mesh'`, { encoding: 'utf8' });
86
84
  await (0, cli_1.graphqlMesh)({ ...cliParams, configName: tmpMesh });
87
85
  await cleanup();
88
86
  };
@@ -8,7 +8,8 @@ exports.findConfig = void 0;
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const utils_1 = require("@graphql-mesh/utils");
10
10
  const cosmiconfig_1 = require("cosmiconfig");
11
- function customLoader(ext, importFn = utils_1.defaultImportFn) {
11
+ function customLoader(ext, importFn = utils_1.defaultImportFn, initialLoggerPrefix = '🕸️ Mesh') {
12
+ const logger = new utils_1.DefaultLogger(initialLoggerPrefix).child('config');
12
13
  // eslint-disable-next-line consistent-return
13
14
  function loader(filepath, content) {
14
15
  if (process.env) {
@@ -28,7 +29,7 @@ function customLoader(ext, importFn = utils_1.defaultImportFn) {
28
29
  return cosmiconfig_1.defaultLoaders['.json'](filepath, content);
29
30
  }
30
31
  if (ext === 'yaml') {
31
- return (0, utils_1.loadYaml)(filepath, content);
32
+ return (0, utils_1.loadYaml)(filepath, content, logger);
32
33
  }
33
34
  if (ext === 'js') {
34
35
  return importFn(filepath);
@@ -37,7 +38,7 @@ function customLoader(ext, importFn = utils_1.defaultImportFn) {
37
38
  return loader;
38
39
  }
39
40
  async function findConfig(options) {
40
- const { configName = 'mesh', dir: configDir = '' } = options || {};
41
+ const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix } = options || {};
41
42
  const dir = path_1.default.isAbsolute(configDir) ? configDir : path_1.default.join(process.cwd(), configDir);
42
43
  const explorer = (0, cosmiconfig_1.cosmiconfig)(configName, {
43
44
  searchPlaces: [
@@ -53,12 +54,12 @@ async function findConfig(options) {
53
54
  `${configName}.config.cjs`,
54
55
  ],
55
56
  loaders: {
56
- '.json': customLoader('json', options?.importFn),
57
- '.yaml': customLoader('yaml', options?.importFn),
58
- '.yml': customLoader('yaml', options?.importFn),
59
- '.js': customLoader('js', options?.importFn),
60
- '.ts': customLoader('js', options?.importFn),
61
- noExt: customLoader('yaml', options?.importFn),
57
+ '.json': customLoader('json', options?.importFn, initialLoggerPrefix),
58
+ '.yaml': customLoader('yaml', options?.importFn, initialLoggerPrefix),
59
+ '.yml': customLoader('yaml', options?.importFn, initialLoggerPrefix),
60
+ '.js': customLoader('js', options?.importFn, initialLoggerPrefix),
61
+ '.ts': customLoader('js', options?.importFn, initialLoggerPrefix),
62
+ noExt: customLoader('yaml', options?.importFn, initialLoggerPrefix),
62
63
  },
63
64
  });
64
65
  const results = await explorer.search(dir);
@@ -1,10 +1,16 @@
1
1
  /* eslint-disable import/no-extraneous-dependencies */
2
2
  import path from 'path'
3
3
  import { ConfigProcessOptions } from '@graphql-mesh/config'
4
- import { defaultImportFn, loadYaml } from '@graphql-mesh/utils'
4
+ import { defaultImportFn, loadYaml, DefaultLogger } from '@graphql-mesh/utils'
5
5
  import { cosmiconfig, defaultLoaders } from 'cosmiconfig'
6
6
 
7
- function customLoader(ext: 'json' | 'yaml' | 'js', importFn = defaultImportFn) {
7
+ function customLoader(
8
+ ext: 'json' | 'yaml' | 'js',
9
+ importFn = defaultImportFn,
10
+ initialLoggerPrefix = '🕸️ Mesh',
11
+ ) {
12
+ const logger = new DefaultLogger(initialLoggerPrefix).child('config')
13
+
8
14
  // eslint-disable-next-line consistent-return
9
15
  function loader(filepath: string, content: string) {
10
16
  if (process.env) {
@@ -28,7 +34,7 @@ function customLoader(ext: 'json' | 'yaml' | 'js', importFn = defaultImportFn) {
28
34
  }
29
35
 
30
36
  if (ext === 'yaml') {
31
- return loadYaml(filepath, content)
37
+ return loadYaml(filepath, content, logger)
32
38
  }
33
39
 
34
40
  if (ext === 'js') {
@@ -40,9 +46,9 @@ function customLoader(ext: 'json' | 'yaml' | 'js', importFn = defaultImportFn) {
40
46
  }
41
47
 
42
48
  export async function findConfig(
43
- options?: Pick<ConfigProcessOptions, 'configName' | 'dir' | 'importFn'>,
49
+ options?: Pick<ConfigProcessOptions, 'configName' | 'dir' | 'importFn' | 'initialLoggerPrefix'>,
44
50
  ) {
45
- const { configName = 'mesh', dir: configDir = '' } = options || {}
51
+ const { configName = 'mesh', dir: configDir = '', initialLoggerPrefix } = options || {}
46
52
  const dir = path.isAbsolute(configDir) ? configDir : path.join(process.cwd(), configDir)
47
53
  const explorer = cosmiconfig(configName, {
48
54
  searchPlaces: [
@@ -58,12 +64,12 @@ export async function findConfig(
58
64
  `${configName}.config.cjs`,
59
65
  ],
60
66
  loaders: {
61
- '.json': customLoader('json', options?.importFn),
62
- '.yaml': customLoader('yaml', options?.importFn),
63
- '.yml': customLoader('yaml', options?.importFn),
64
- '.js': customLoader('js', options?.importFn),
65
- '.ts': customLoader('js', options?.importFn),
66
- noExt: customLoader('yaml', options?.importFn),
67
+ '.json': customLoader('json', options?.importFn, initialLoggerPrefix),
68
+ '.yaml': customLoader('yaml', options?.importFn, initialLoggerPrefix),
69
+ '.yml': customLoader('yaml', options?.importFn, initialLoggerPrefix),
70
+ '.js': customLoader('js', options?.importFn, initialLoggerPrefix),
71
+ '.ts': customLoader('js', options?.importFn, initialLoggerPrefix),
72
+ noExt: customLoader('yaml', options?.importFn, initialLoggerPrefix),
67
73
  },
68
74
  })
69
75
  const results = await explorer.search(dir)
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": "1.0.4",
5
+ "version": "1.0.7",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "scripts": {
@@ -19,17 +19,17 @@
19
19
  "graphql-code-generator": "dist/bin/codegen.js"
20
20
  },
21
21
  "dependencies": {
22
- "@graphql-codegen/cli": "2.6.2",
23
- "@graphql-mesh/cli": "0.69.2",
24
- "@graphql-mesh/types": "0.72.1",
25
- "@graphql-mesh/utils": "0.34.6"
22
+ "@graphql-codegen/cli": "2.8.0",
23
+ "@graphql-mesh/cli": "0.75.2",
24
+ "@graphql-mesh/types": "0.78.4",
25
+ "@graphql-mesh/utils": "0.37.5"
26
26
  },
27
27
  "devDependencies": {
28
- "@graphcommerce/eslint-config-pwa": "^4.1.6",
28
+ "@graphcommerce/eslint-config-pwa": "^4.1.9",
29
29
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
30
- "@graphcommerce/typescript-config-pwa": "^4.0.2",
30
+ "@graphcommerce/typescript-config-pwa": "^4.0.4",
31
31
  "@playwright/test": "^1.21.1",
32
- "typescript": "4.6.3"
32
+ "typescript": "4.7.4"
33
33
  },
34
34
  "sideEffects": false,
35
35
  "prettier": "@graphcommerce/prettier-config-pwa",