@graphcommerce/cli 1.0.1 → 1.0.2

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,15 @@
1
1
  # @graphcommerce/cli
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1394](https://github.com/graphcommerce-org/graphcommerce/pull/1394) [`b6b8bb5b3`](https://github.com/graphcommerce-org/graphcommerce/commit/b6b8bb5b31b0891ea24733de34a3bd5c0a9604e4) Thanks [@paales](https://github.com/paales)! - Added support for additionalTypeResolvers to be loaded from packages
8
+
9
+ * [#1426](https://github.com/graphcommerce-org/graphcommerce/pull/1426) [`100f4c38c`](https://github.com/graphcommerce-org/graphcommerce/commit/100f4c38c8fcda4bc6e0425e38028b550b60adc2) Thanks [@paales](https://github.com/paales)! - Upgrade packages
10
+
11
+ - [#1427](https://github.com/graphcommerce-org/graphcommerce/pull/1427) [`cbbbcab55`](https://github.com/graphcommerce-org/graphcommerce/commit/cbbbcab55bfccff95e779fd18a49412127adcd78) Thanks [@paales](https://github.com/paales)! - Change mesh generation strategy where mesh paths could't be found when using the mock store
12
+
3
13
  ## 1.0.1
4
14
 
5
15
  ### Patch Changes
package/bin/mesh.ts CHANGED
@@ -1,10 +1,10 @@
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 fs, { read } from 'fs'
4
+ import { promises as fs } from 'fs'
5
5
  import path from 'path'
6
6
  import { exit } from 'process'
7
- import { graphqlMesh, DEFAULT_CLI_PARAMS } from '@graphql-mesh/cli'
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'
10
10
  import dotenv from 'dotenv'
@@ -22,41 +22,74 @@ export function handleFatalError(e: Error, logger: Logger = new DefaultLogger('
22
22
 
23
23
  const root = process.cwd()
24
24
  const meshDir = path.dirname(require.resolve('@graphcommerce/graphql-mesh'))
25
-
26
25
  const relativePath = path.join(path.relative(meshDir, root), '/')
27
26
 
28
27
  const isMonoRepo = relativePath.startsWith('../../examples')
29
28
 
29
+ const artifactsDir = path.join(path.relative(root, meshDir), '/.mesh')
30
+
31
+ const cliParams: GraphQLMeshCLIParams = {
32
+ ...DEFAULT_CLI_PARAMS,
33
+ artifactsDir,
34
+ playgroundTitle: 'GraphCommerce® Mesh',
35
+ }
36
+
37
+ const tmpMesh = `_tmp_mesh_${Math.random().toString(36).substring(2, 15)}`
38
+ const tmpMeshLocation = path.join(root, `.${tmpMesh}rc.yml`)
39
+
40
+ function cleanup() {
41
+ try {
42
+ return fs.unlink(tmpMeshLocation)
43
+ } catch (e) {
44
+ // ignore
45
+ }
46
+ return undefined
47
+ }
48
+
30
49
  const main = async () => {
31
50
  const conf = (await findConfig({})) as YamlConfig.Config
32
51
 
52
+ // Rewrite additionalResolvers so we can use module resolution more easily
33
53
  conf.additionalResolvers = conf.additionalResolvers ?? []
34
-
35
- // Rewrite string directives
36
54
  conf.additionalResolvers = conf.additionalResolvers?.map((additionalResolver) => {
37
- if (typeof additionalResolver === 'string') return `${relativePath}${additionalResolver}`
55
+ if (typeof additionalResolver !== 'string') return additionalResolver
56
+ if (additionalResolver.startsWith('@'))
57
+ return path.relative(root, require.resolve(additionalResolver))
58
+
38
59
  return additionalResolver
39
60
  })
40
61
 
62
+ // Rewrite additionalTypeDefs so we can use module resolution more easily
41
63
  if (!conf.additionalTypeDefs) conf.additionalTypeDefs = []
42
- // Add additionalTypeDefs
43
- conf.additionalTypeDefs = Array.isArray(conf.additionalTypeDefs)
44
- ? conf.additionalTypeDefs
45
- : [conf.additionalTypeDefs]
64
+ conf.additionalTypeDefs = (
65
+ Array.isArray(conf.additionalTypeDefs) ? conf.additionalTypeDefs : [conf.additionalTypeDefs]
66
+ ).map((additionalTypeDef) => {
67
+ if (additionalTypeDef.startsWith('@'))
68
+ return path.relative(root, require.resolve(additionalTypeDef))
69
+
70
+ return additionalTypeDef
71
+ })
46
72
 
47
- conf.additionalTypeDefs.push('../../**/*.graphqls')
73
+ // Scan the current working directory to also read all graphqls files.
74
+ conf.additionalTypeDefs.push('**/*.graphqls')
48
75
  if (isMonoRepo) {
49
- conf.additionalTypeDefs.push('../../packages/magento-*/**/*.graphqls')
76
+ conf.additionalTypeDefs.push('../../packages/**/*.graphqls')
50
77
  conf.additionalTypeDefs.push('../../packagesDev/**/*.graphqls')
51
78
  } else {
52
- conf.additionalTypeDefs.push('../../@graphcommerce/**/*.graphqls')
79
+ conf.additionalTypeDefs.push('node_modules/@graphcommerce/**/*.graphqls')
53
80
  }
54
81
 
55
- fs.writeFileSync(path.join(meshDir, '.meshrc.yml'), yaml.stringify(conf))
82
+ if (!conf.serve) conf.serve = {}
83
+ if (!conf.serve.playgroundTitle) conf.serve.playgroundTitle = 'GraphCommerce® Mesh'
56
84
 
57
- graphqlMesh(DEFAULT_CLI_PARAMS, undefined, `${meshDir}/`).catch((e) =>
58
- handleFatalError(e, new DefaultLogger(DEFAULT_CLI_PARAMS.initialLoggerPrefix)),
59
- )
85
+ await fs.writeFile(tmpMeshLocation, yaml.stringify(conf))
86
+
87
+ await graphqlMesh({ ...cliParams, configName: tmpMesh })
88
+
89
+ await cleanup()
60
90
  }
61
91
 
62
- main().catch(console.error)
92
+ process.on('SIGINT', cleanup)
93
+ process.on('SIGTERM', cleanup)
94
+
95
+ main().catch((e) => handleFatalError(e, new DefaultLogger(DEFAULT_CLI_PARAMS.initialLoggerPrefix)))
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- var cli_1 = require("@graphql-codegen/cli");
5
- var _a = process.argv, cmd = _a[2];
4
+ const cli_1 = require("@graphql-codegen/cli");
5
+ const [, , cmd] = process.argv;
6
6
  // console.log(process.argv)
7
7
  (0, cli_1.runCli)(cmd)
8
- .then(function () {
8
+ .then(() => {
9
9
  process.exit(0);
10
10
  })
11
- .catch(function (error) {
11
+ .catch((error) => {
12
12
  (0, cli_1.cliError)(error);
13
13
  });
package/dist/bin/mesh.js CHANGED
@@ -1,41 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- var __generator = (this && this.__generator) || function (thisArg, body) {
13
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
- function verb(n) { return function (v) { return step([n, v]); }; }
16
- function step(op) {
17
- if (f) throw new TypeError("Generator is already executing.");
18
- while (_) try {
19
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
- if (y = 0, t) op = [op[0] & 2, t.value];
21
- switch (op[0]) {
22
- case 0: case 1: t = op; break;
23
- case 4: _.label++; return { value: op[1], done: false };
24
- case 5: _.label++; y = op[1]; op = [0]; continue;
25
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
- default:
27
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
- if (t[2]) _.ops.pop();
32
- _.trys.pop(); continue;
33
- }
34
- op = body.call(thisArg, _);
35
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
- }
38
- };
39
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
40
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
41
5
  };
@@ -43,17 +7,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
7
  exports.handleFatalError = void 0;
44
8
  /* eslint-disable import/no-extraneous-dependencies */
45
9
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
46
- var fs_1 = __importDefault(require("fs"));
47
- var path_1 = __importDefault(require("path"));
48
- var process_1 = require("process");
49
- var cli_1 = require("@graphql-mesh/cli");
50
- var utils_1 = require("@graphql-mesh/utils");
51
- var dotenv_1 = __importDefault(require("dotenv"));
52
- var yaml_1 = __importDefault(require("yaml"));
53
- var findConfig_1 = require("../mesh/findConfig");
10
+ const fs_1 = require("fs");
11
+ const path_1 = __importDefault(require("path"));
12
+ const process_1 = require("process");
13
+ const cli_1 = require("@graphql-mesh/cli");
14
+ const utils_1 = require("@graphql-mesh/utils");
15
+ const dotenv_1 = __importDefault(require("dotenv"));
16
+ const yaml_1 = __importDefault(require("yaml"));
17
+ const findConfig_1 = require("../mesh/findConfig");
54
18
  dotenv_1.default.config();
55
- function handleFatalError(e, logger) {
56
- if (logger === void 0) { logger = new utils_1.DefaultLogger('◈'); }
19
+ function handleFatalError(e, logger = new utils_1.DefaultLogger('◈')) {
57
20
  logger.error(e.stack || e.message);
58
21
  // eslint-disable-next-line no-console
59
22
  console.log(e);
@@ -61,45 +24,63 @@ function handleFatalError(e, logger) {
61
24
  (0, process_1.exit)(1);
62
25
  }
63
26
  exports.handleFatalError = handleFatalError;
64
- var root = process.cwd();
65
- var meshDir = path_1.default.dirname(require.resolve('@graphcommerce/graphql-mesh'));
66
- var relativePath = path_1.default.join(path_1.default.relative(meshDir, root), '/');
67
- var isMonoRepo = relativePath.startsWith('../../examples');
68
- var main = function () { return __awaiter(void 0, void 0, void 0, function () {
69
- var conf;
70
- var _a, _b;
71
- return __generator(this, function (_c) {
72
- switch (_c.label) {
73
- case 0: return [4 /*yield*/, (0, findConfig_1.findConfig)({})];
74
- case 1:
75
- conf = (_c.sent());
76
- conf.additionalResolvers = (_a = conf.additionalResolvers) !== null && _a !== void 0 ? _a : [];
77
- // Rewrite string directives
78
- conf.additionalResolvers = (_b = conf.additionalResolvers) === null || _b === void 0 ? void 0 : _b.map(function (additionalResolver) {
79
- if (typeof additionalResolver === 'string')
80
- return "".concat(relativePath).concat(additionalResolver);
81
- return additionalResolver;
82
- });
83
- if (!conf.additionalTypeDefs)
84
- conf.additionalTypeDefs = [];
85
- // Add additionalTypeDefs
86
- conf.additionalTypeDefs = Array.isArray(conf.additionalTypeDefs)
87
- ? conf.additionalTypeDefs
88
- : [conf.additionalTypeDefs];
89
- conf.additionalTypeDefs.push('../../**/*.graphqls');
90
- if (isMonoRepo) {
91
- conf.additionalTypeDefs.push('../../packages/magento-*/**/*.graphqls');
92
- conf.additionalTypeDefs.push('../../packagesDev/**/*.graphqls');
93
- }
94
- else {
95
- conf.additionalTypeDefs.push('../../@graphcommerce/**/*.graphqls');
96
- }
97
- fs_1.default.writeFileSync(path_1.default.join(meshDir, '.meshrc.yml'), yaml_1.default.stringify(conf));
98
- (0, cli_1.graphqlMesh)(cli_1.DEFAULT_CLI_PARAMS, undefined, "".concat(meshDir, "/")).catch(function (e) {
99
- return handleFatalError(e, new utils_1.DefaultLogger(cli_1.DEFAULT_CLI_PARAMS.initialLoggerPrefix));
100
- });
101
- return [2 /*return*/];
102
- }
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');
31
+ const artifactsDir = path_1.default.join(path_1.default.relative(root, meshDir), '/.mesh');
32
+ const cliParams = {
33
+ ...cli_1.DEFAULT_CLI_PARAMS,
34
+ artifactsDir,
35
+ playgroundTitle: 'GraphCommerce® Mesh',
36
+ };
37
+ const tmpMesh = `_tmp_mesh_${Math.random().toString(36).substring(2, 15)}`;
38
+ const tmpMeshLocation = path_1.default.join(root, `.${tmpMesh}rc.yml`);
39
+ function cleanup() {
40
+ try {
41
+ return fs_1.promises.unlink(tmpMeshLocation);
42
+ }
43
+ catch (e) {
44
+ // ignore
45
+ }
46
+ return undefined;
47
+ }
48
+ const main = async () => {
49
+ const conf = (await (0, findConfig_1.findConfig)({}));
50
+ // Rewrite additionalResolvers so we can use module resolution more easily
51
+ conf.additionalResolvers = conf.additionalResolvers ?? [];
52
+ conf.additionalResolvers = conf.additionalResolvers?.map((additionalResolver) => {
53
+ if (typeof additionalResolver !== 'string')
54
+ return additionalResolver;
55
+ if (additionalResolver.startsWith('@'))
56
+ return path_1.default.relative(root, require.resolve(additionalResolver));
57
+ return additionalResolver;
58
+ });
59
+ // Rewrite additionalTypeDefs so we can use module resolution more easily
60
+ if (!conf.additionalTypeDefs)
61
+ conf.additionalTypeDefs = [];
62
+ conf.additionalTypeDefs = (Array.isArray(conf.additionalTypeDefs) ? conf.additionalTypeDefs : [conf.additionalTypeDefs]).map((additionalTypeDef) => {
63
+ if (additionalTypeDef.startsWith('@'))
64
+ return path_1.default.relative(root, require.resolve(additionalTypeDef));
65
+ return additionalTypeDef;
103
66
  });
104
- }); };
105
- main().catch(console.error);
67
+ // Scan the current working directory to also read all graphqls files.
68
+ conf.additionalTypeDefs.push('**/*.graphqls');
69
+ if (isMonoRepo) {
70
+ conf.additionalTypeDefs.push('../../packages/**/*.graphqls');
71
+ conf.additionalTypeDefs.push('../../packagesDev/**/*.graphqls');
72
+ }
73
+ else {
74
+ conf.additionalTypeDefs.push('node_modules/@graphcommerce/**/*.graphqls');
75
+ }
76
+ if (!conf.serve)
77
+ conf.serve = {};
78
+ if (!conf.serve.playgroundTitle)
79
+ conf.serve.playgroundTitle = 'GraphCommerce® Mesh';
80
+ await fs_1.promises.writeFile(tmpMeshLocation, yaml_1.default.stringify(conf));
81
+ await (0, cli_1.graphqlMesh)({ ...cliParams, configName: tmpMesh });
82
+ await cleanup();
83
+ };
84
+ process.on('SIGINT', cleanup);
85
+ process.on('SIGTERM', cleanup);
86
+ main().catch((e) => handleFatalError(e, new utils_1.DefaultLogger(cli_1.DEFAULT_CLI_PARAMS.initialLoggerPrefix)));
@@ -1,60 +1,23 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
6
  exports.findConfig = void 0;
43
7
  /* eslint-disable import/no-extraneous-dependencies */
44
- var path_1 = __importDefault(require("path"));
45
- var utils_1 = require("@graphql-mesh/utils");
46
- var cosmiconfig_1 = require("cosmiconfig");
47
- function customLoader(ext, importFn) {
48
- if (importFn === void 0) { importFn = utils_1.defaultImportFn; }
8
+ const path_1 = __importDefault(require("path"));
9
+ const utils_1 = require("@graphql-mesh/utils");
10
+ const cosmiconfig_1 = require("cosmiconfig");
11
+ function customLoader(ext, importFn = utils_1.defaultImportFn) {
49
12
  // eslint-disable-next-line consistent-return
50
13
  function loader(filepath, content) {
51
14
  if (process.env) {
52
15
  // eslint-disable-next-line no-param-reassign
53
- content = content.replace(/\$\{(.*?)\}/g, function (_, variable) {
54
- var varName = variable;
55
- var defaultValue = '';
16
+ content = content.replace(/\$\{(.*?)\}/g, (_, variable) => {
17
+ let varName = variable;
18
+ let defaultValue = '';
56
19
  if (variable.includes(':')) {
57
- var spl = variable.split(':');
20
+ const spl = variable.split(':');
58
21
  varName = spl.shift();
59
22
  defaultValue = spl.join(':');
60
23
  }
@@ -73,46 +36,36 @@ function customLoader(ext, importFn) {
73
36
  }
74
37
  return loader;
75
38
  }
76
- function findConfig(options) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var _a, _b, configName, _c, configDir, dir, explorer, results, config;
79
- return __generator(this, function (_d) {
80
- switch (_d.label) {
81
- case 0:
82
- _a = options || {}, _b = _a.configName, configName = _b === void 0 ? 'mesh' : _b, _c = _a.dir, configDir = _c === void 0 ? '' : _c;
83
- dir = path_1.default.isAbsolute(configDir) ? configDir : path_1.default.join(process.cwd(), configDir);
84
- explorer = (0, cosmiconfig_1.cosmiconfig)(configName, {
85
- searchPlaces: [
86
- 'package.json',
87
- ".".concat(configName, "rc"),
88
- ".".concat(configName, "rc.json"),
89
- ".".concat(configName, "rc.yaml"),
90
- ".".concat(configName, "rc.yml"),
91
- ".".concat(configName, "rc.js"),
92
- ".".concat(configName, "rc.ts"),
93
- ".".concat(configName, "rc.cjs"),
94
- "".concat(configName, ".config.js"),
95
- "".concat(configName, ".config.cjs"),
96
- ],
97
- loaders: {
98
- '.json': customLoader('json', options === null || options === void 0 ? void 0 : options.importFn),
99
- '.yaml': customLoader('yaml', options === null || options === void 0 ? void 0 : options.importFn),
100
- '.yml': customLoader('yaml', options === null || options === void 0 ? void 0 : options.importFn),
101
- '.js': customLoader('js', options === null || options === void 0 ? void 0 : options.importFn),
102
- '.ts': customLoader('js', options === null || options === void 0 ? void 0 : options.importFn),
103
- noExt: customLoader('yaml', options === null || options === void 0 ? void 0 : options.importFn),
104
- },
105
- });
106
- return [4 /*yield*/, explorer.search(dir)];
107
- case 1:
108
- results = _d.sent();
109
- if (!results) {
110
- throw new Error("No ".concat(configName, " config file found in \"").concat(dir, "\"!"));
111
- }
112
- config = results.config;
113
- return [2 /*return*/, config];
114
- }
115
- });
39
+ async function findConfig(options) {
40
+ const { configName = 'mesh', dir: configDir = '' } = options || {};
41
+ const dir = path_1.default.isAbsolute(configDir) ? configDir : path_1.default.join(process.cwd(), configDir);
42
+ const explorer = (0, cosmiconfig_1.cosmiconfig)(configName, {
43
+ searchPlaces: [
44
+ 'package.json',
45
+ `.${configName}rc`,
46
+ `.${configName}rc.json`,
47
+ `.${configName}rc.yaml`,
48
+ `.${configName}rc.yml`,
49
+ `.${configName}rc.js`,
50
+ `.${configName}rc.ts`,
51
+ `.${configName}rc.cjs`,
52
+ `${configName}.config.js`,
53
+ `${configName}.config.cjs`,
54
+ ],
55
+ 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),
62
+ },
116
63
  });
64
+ const results = await explorer.search(dir);
65
+ if (!results) {
66
+ throw new Error(`No ${configName} config file found in "${dir}"!`);
67
+ }
68
+ const { config } = results;
69
+ return config;
117
70
  }
118
71
  exports.findConfig = findConfig;
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@graphcommerce/cli",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "1.0.1",
5
+ "version": "1.0.2",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "scripts": {
9
- "dev": "tsc --preserveWatchOutput --watch --sourceMap --outDir dist",
10
- "build": "tsc --target es5 --outDir dist",
9
+ "dev": "tsc --preserveWatchOutput --watch --outDir dist",
10
+ "build": "tsc --outDir dist",
11
11
  "prepack": "yarn build"
12
12
  },
13
13
  "bin": {
@@ -20,12 +20,12 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@graphql-codegen/cli": "2.6.2",
23
- "@graphql-mesh/cli": "0.67.4",
24
- "@graphql-mesh/types": "0.70.5",
25
- "@graphql-mesh/utils": "0.33.5"
23
+ "@graphql-mesh/cli": "0.68.4",
24
+ "@graphql-mesh/types": "0.71.3",
25
+ "@graphql-mesh/utils": "0.34.3"
26
26
  },
27
27
  "devDependencies": {
28
- "@graphcommerce/eslint-config-pwa": "^4.1.5",
28
+ "@graphcommerce/eslint-config-pwa": "^4.1.6",
29
29
  "@graphcommerce/prettier-config-pwa": "^4.0.6",
30
30
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
31
31
  "@playwright/test": "^1.21.1",
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "extends": "@graphcommerce/typescript-config-pwa/node.json",
5
5
  "compilerOptions": {
6
6
  "noEmit": false,
7
- "outDir": "dist"
7
+ "outDir": "dist",
8
+ "sourceMap": false
8
9
  }
9
10
  }