@graphql-codegen/cli 2.2.1-alpha-e04750ad3.0 → 2.3.0-alpha-5ed8c1163.0
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/bin.js +8 -5
- package/config.d.ts +6 -0
- package/index.js +9 -5
- package/index.mjs +9 -6
- package/package.json +3 -3
package/bin.js
CHANGED
|
@@ -579,7 +579,7 @@ function customLoader(ext) {
|
|
|
579
579
|
}
|
|
580
580
|
return loader;
|
|
581
581
|
}
|
|
582
|
-
|
|
582
|
+
function loadCodegenConfig(configFilePath) {
|
|
583
583
|
const moduleName = 'codegen';
|
|
584
584
|
const cosmi = cosmiconfig.cosmiconfig(moduleName, {
|
|
585
585
|
searchPlaces: generateSearchPlaces(moduleName),
|
|
@@ -592,25 +592,28 @@ async function loadContext(configFilePath) {
|
|
|
592
592
|
noExt: customLoader('yaml'),
|
|
593
593
|
},
|
|
594
594
|
});
|
|
595
|
+
return configFilePath ? cosmi.load(configFilePath) : cosmi.search(process.cwd());
|
|
596
|
+
}
|
|
597
|
+
async function loadContext(configFilePath) {
|
|
595
598
|
const graphqlConfig = await findAndLoadGraphQLConfig(configFilePath);
|
|
596
599
|
if (graphqlConfig) {
|
|
597
600
|
return new CodegenContext({
|
|
598
601
|
graphqlConfig,
|
|
599
602
|
});
|
|
600
603
|
}
|
|
601
|
-
const result = await (configFilePath
|
|
604
|
+
const result = await loadCodegenConfig(configFilePath);
|
|
602
605
|
if (!result) {
|
|
603
606
|
if (configFilePath) {
|
|
604
607
|
throw new pluginHelpers.DetailedError(`Config ${configFilePath} does not exist`, `
|
|
605
608
|
Config ${configFilePath} does not exist.
|
|
606
|
-
|
|
609
|
+
|
|
607
610
|
$ graphql-codegen --config ${configFilePath}
|
|
608
|
-
|
|
611
|
+
|
|
609
612
|
Please make sure the --config points to a correct file.
|
|
610
613
|
`);
|
|
611
614
|
}
|
|
612
615
|
throw new pluginHelpers.DetailedError(`Unable to find Codegen config file!`, `
|
|
613
|
-
Please make sure that you have a configuration file under the current directory!
|
|
616
|
+
Please make sure that you have a configuration file under the current directory!
|
|
614
617
|
`);
|
|
615
618
|
}
|
|
616
619
|
if (result.isEmpty) {
|
package/config.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare type YamlCliFlags = {
|
|
|
10
10
|
silent: boolean;
|
|
11
11
|
errorsOnly: boolean;
|
|
12
12
|
};
|
|
13
|
+
export interface LoadedCodegenConfig {
|
|
14
|
+
filepath: string;
|
|
15
|
+
config: Types.Config;
|
|
16
|
+
isEmpty?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function loadCodegenConfig(configFilePath?: string): Promise<LoadedCodegenConfig>;
|
|
13
19
|
export declare function loadContext(configFilePath?: string): Promise<CodegenContext> | never;
|
|
14
20
|
export declare function buildOptions(): {
|
|
15
21
|
c: {
|
package/index.js
CHANGED
|
@@ -497,7 +497,7 @@ function customLoader(ext) {
|
|
|
497
497
|
}
|
|
498
498
|
return loader;
|
|
499
499
|
}
|
|
500
|
-
|
|
500
|
+
function loadCodegenConfig(configFilePath) {
|
|
501
501
|
const moduleName = 'codegen';
|
|
502
502
|
const cosmi = cosmiconfig.cosmiconfig(moduleName, {
|
|
503
503
|
searchPlaces: generateSearchPlaces(moduleName),
|
|
@@ -510,25 +510,28 @@ async function loadContext(configFilePath) {
|
|
|
510
510
|
noExt: customLoader('yaml'),
|
|
511
511
|
},
|
|
512
512
|
});
|
|
513
|
+
return configFilePath ? cosmi.load(configFilePath) : cosmi.search(process.cwd());
|
|
514
|
+
}
|
|
515
|
+
async function loadContext(configFilePath) {
|
|
513
516
|
const graphqlConfig = await findAndLoadGraphQLConfig(configFilePath);
|
|
514
517
|
if (graphqlConfig) {
|
|
515
518
|
return new CodegenContext({
|
|
516
519
|
graphqlConfig,
|
|
517
520
|
});
|
|
518
521
|
}
|
|
519
|
-
const result = await (configFilePath
|
|
522
|
+
const result = await loadCodegenConfig(configFilePath);
|
|
520
523
|
if (!result) {
|
|
521
524
|
if (configFilePath) {
|
|
522
525
|
throw new pluginHelpers.DetailedError(`Config ${configFilePath} does not exist`, `
|
|
523
526
|
Config ${configFilePath} does not exist.
|
|
524
|
-
|
|
527
|
+
|
|
525
528
|
$ graphql-codegen --config ${configFilePath}
|
|
526
|
-
|
|
529
|
+
|
|
527
530
|
Please make sure the --config points to a correct file.
|
|
528
531
|
`);
|
|
529
532
|
}
|
|
530
533
|
throw new pluginHelpers.DetailedError(`Unable to find Codegen config file!`, `
|
|
531
|
-
Please make sure that you have a configuration file under the current directory!
|
|
534
|
+
Please make sure that you have a configuration file under the current directory!
|
|
532
535
|
`);
|
|
533
536
|
}
|
|
534
537
|
if (result.isEmpty) {
|
|
@@ -1779,6 +1782,7 @@ exports.executeCodegen = executeCodegen;
|
|
|
1779
1782
|
exports.findAndLoadGraphQLConfig = findAndLoadGraphQLConfig;
|
|
1780
1783
|
exports.generate = generate;
|
|
1781
1784
|
exports.init = init;
|
|
1785
|
+
exports.loadCodegenConfig = loadCodegenConfig;
|
|
1782
1786
|
exports.loadContext = loadContext;
|
|
1783
1787
|
exports.parseArgv = parseArgv;
|
|
1784
1788
|
exports.runCli = runCli;
|
package/index.mjs
CHANGED
|
@@ -470,7 +470,7 @@ function customLoader(ext) {
|
|
|
470
470
|
}
|
|
471
471
|
return loader;
|
|
472
472
|
}
|
|
473
|
-
|
|
473
|
+
function loadCodegenConfig(configFilePath) {
|
|
474
474
|
const moduleName = 'codegen';
|
|
475
475
|
const cosmi = cosmiconfig(moduleName, {
|
|
476
476
|
searchPlaces: generateSearchPlaces(moduleName),
|
|
@@ -483,25 +483,28 @@ async function loadContext(configFilePath) {
|
|
|
483
483
|
noExt: customLoader('yaml'),
|
|
484
484
|
},
|
|
485
485
|
});
|
|
486
|
+
return configFilePath ? cosmi.load(configFilePath) : cosmi.search(process.cwd());
|
|
487
|
+
}
|
|
488
|
+
async function loadContext(configFilePath) {
|
|
486
489
|
const graphqlConfig = await findAndLoadGraphQLConfig(configFilePath);
|
|
487
490
|
if (graphqlConfig) {
|
|
488
491
|
return new CodegenContext({
|
|
489
492
|
graphqlConfig,
|
|
490
493
|
});
|
|
491
494
|
}
|
|
492
|
-
const result = await (configFilePath
|
|
495
|
+
const result = await loadCodegenConfig(configFilePath);
|
|
493
496
|
if (!result) {
|
|
494
497
|
if (configFilePath) {
|
|
495
498
|
throw new DetailedError(`Config ${configFilePath} does not exist`, `
|
|
496
499
|
Config ${configFilePath} does not exist.
|
|
497
|
-
|
|
500
|
+
|
|
498
501
|
$ graphql-codegen --config ${configFilePath}
|
|
499
|
-
|
|
502
|
+
|
|
500
503
|
Please make sure the --config points to a correct file.
|
|
501
504
|
`);
|
|
502
505
|
}
|
|
503
506
|
throw new DetailedError(`Unable to find Codegen config file!`, `
|
|
504
|
-
Please make sure that you have a configuration file under the current directory!
|
|
507
|
+
Please make sure that you have a configuration file under the current directory!
|
|
505
508
|
`);
|
|
506
509
|
}
|
|
507
510
|
if (result.isEmpty) {
|
|
@@ -1741,4 +1744,4 @@ async function ensureGraphQlPackage() {
|
|
|
1741
1744
|
}
|
|
1742
1745
|
}
|
|
1743
1746
|
|
|
1744
|
-
export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, init, loadContext, parseArgv, runCli, updateContextWithCliFlags };
|
|
1747
|
+
export { CodegenContext, CodegenExtension, buildOptions, cliError, createContext, ensureContext, ensureGraphQlPackage, executeCodegen, findAndLoadGraphQLConfig, generate, init, loadCodegenConfig, loadContext, parseArgv, runCli, updateContextWithCliFlags };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha-5ed8c1163.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@graphql-codegen/core": "2.2.0
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "2.2.0
|
|
8
|
+
"@graphql-codegen/core": "2.2.0",
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.2.0",
|
|
10
10
|
"@graphql-tools/apollo-engine-loader": "^7.0.5",
|
|
11
11
|
"@graphql-tools/code-file-loader": "^7.0.6",
|
|
12
12
|
"@graphql-tools/git-loader": "^7.0.5",
|