@graphql-codegen/cli 2.16.4-alpha-20230107200104-a63e3c9d9 → 2.16.4-alpha-20230107200253-00a4e4db2
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/cjs/codegen.js +2 -2
- package/cjs/config.js +4 -4
- package/cjs/graphql-config.js +1 -1
- package/cjs/init/helpers.js +6 -2
- package/cjs/presets.js +2 -2
- package/cjs/utils/logger.js +1 -1
- package/cjs/utils/watcher.js +1 -2
- package/esm/codegen.js +2 -2
- package/esm/config.js +4 -4
- package/esm/graphql-config.js +1 -1
- package/esm/init/helpers.js +6 -2
- package/esm/presets.js +2 -2
- package/esm/utils/logger.js +1 -1
- package/esm/utils/watcher.js +1 -2
- package/package.json +1 -1
- package/typings/config.d.cts +1 -1
- package/typings/config.d.ts +1 -1
package/cjs/codegen.js
CHANGED
|
@@ -169,7 +169,7 @@ async function executeCodegen(input) {
|
|
|
169
169
|
? await (0, presets_js_1.getPresetByName)(outputConfig.preset, makeDefaultLoader(context.cwd))
|
|
170
170
|
: outputConfig.preset
|
|
171
171
|
: null;
|
|
172
|
-
if (preset
|
|
172
|
+
if (preset && preset.prepareDocuments) {
|
|
173
173
|
outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
|
|
174
174
|
}
|
|
175
175
|
return subTask.newListr([
|
|
@@ -241,7 +241,7 @@ async function executeCodegen(input) {
|
|
|
241
241
|
...(typeof outputFileTemplateConfig === 'string'
|
|
242
242
|
? { value: outputFileTemplateConfig }
|
|
243
243
|
: outputFileTemplateConfig),
|
|
244
|
-
emitLegacyCommonJSImports: (0, config_js_1.shouldEmitLegacyCommonJSImports)(config),
|
|
244
|
+
emitLegacyCommonJSImports: (0, config_js_1.shouldEmitLegacyCommonJSImports)(config, filename),
|
|
245
245
|
};
|
|
246
246
|
const outputs = preset
|
|
247
247
|
? await context.profiler.run(async () => preset.buildGeneratesSection({
|
package/cjs/config.js
CHANGED
|
@@ -55,9 +55,9 @@ function customLoader(ext) {
|
|
|
55
55
|
return loader;
|
|
56
56
|
}
|
|
57
57
|
async function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }) {
|
|
58
|
-
configFilePath
|
|
59
|
-
moduleName
|
|
60
|
-
packageProp
|
|
58
|
+
configFilePath = configFilePath || process.cwd();
|
|
59
|
+
moduleName = moduleName || 'codegen';
|
|
60
|
+
packageProp = packageProp || moduleName;
|
|
61
61
|
const cosmi = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
62
62
|
searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
|
|
63
63
|
packageProp,
|
|
@@ -345,7 +345,7 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
345
345
|
return doc;
|
|
346
346
|
}));
|
|
347
347
|
}
|
|
348
|
-
function shouldEmitLegacyCommonJSImports(config) {
|
|
348
|
+
function shouldEmitLegacyCommonJSImports(config, outputPath) {
|
|
349
349
|
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : Boolean(config.emitLegacyCommonJSImports);
|
|
350
350
|
// const outputConfig = config.generates[outputPath];
|
|
351
351
|
// if (!outputConfig) {
|
package/cjs/graphql-config.js
CHANGED
|
@@ -56,7 +56,7 @@ function isGraphQLConfig(config) {
|
|
|
56
56
|
catch (e) { }
|
|
57
57
|
try {
|
|
58
58
|
for (const projectName in config.projects) {
|
|
59
|
-
if (
|
|
59
|
+
if (config.projects.hasOwnProperty(projectName)) {
|
|
60
60
|
const project = config.projects[projectName];
|
|
61
61
|
if (project.hasExtension('codegen')) {
|
|
62
62
|
return true;
|
package/cjs/init/helpers.js
CHANGED
|
@@ -60,10 +60,14 @@ async function writePackage(answers, configLocation) {
|
|
|
60
60
|
const pkgContent = (0, fs_1.readFileSync)(pkgPath, 'utf8');
|
|
61
61
|
const pkg = JSON.parse(pkgContent);
|
|
62
62
|
const { indent } = (0, detect_indent_1.default)(pkgContent);
|
|
63
|
-
|
|
63
|
+
if (!pkg.scripts) {
|
|
64
|
+
pkg.scripts = {};
|
|
65
|
+
}
|
|
64
66
|
pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
|
|
65
67
|
// plugin
|
|
66
|
-
|
|
68
|
+
if (!pkg.devDependencies) {
|
|
69
|
+
pkg.devDependencies = {};
|
|
70
|
+
}
|
|
67
71
|
await Promise.all((answers.plugins || []).map(async (plugin) => {
|
|
68
72
|
pkg.devDependencies[plugin.package] = await (0, get_latest_version_js_1.getLatestVersion)(plugin.package);
|
|
69
73
|
}));
|
package/cjs/presets.js
CHANGED
|
@@ -12,10 +12,10 @@ async function getPresetByName(name, loader) {
|
|
|
12
12
|
for (const moduleName of possibleNames) {
|
|
13
13
|
try {
|
|
14
14
|
const loaded = await loader(moduleName);
|
|
15
|
-
if (loaded
|
|
15
|
+
if (loaded && loaded.preset) {
|
|
16
16
|
return loaded.preset;
|
|
17
17
|
}
|
|
18
|
-
if (loaded
|
|
18
|
+
if (loaded && loaded.default) {
|
|
19
19
|
return loaded.default;
|
|
20
20
|
}
|
|
21
21
|
return loaded;
|
package/cjs/utils/logger.js
CHANGED
package/cjs/utils/watcher.js
CHANGED
|
@@ -68,9 +68,8 @@ const createWatcher = (initalContext, onNext) => {
|
|
|
68
68
|
Object.keys(config.generates)
|
|
69
69
|
.map(filename => ({ filename, config: (0, plugin_helpers_1.normalizeOutputParam)(config.generates[filename]) }))
|
|
70
70
|
.forEach(entry => {
|
|
71
|
-
var _a;
|
|
72
71
|
if (entry.config.preset) {
|
|
73
|
-
const extension =
|
|
72
|
+
const extension = entry.config.presetConfig && entry.config.presetConfig.extension;
|
|
74
73
|
if (extension) {
|
|
75
74
|
ignored.push((0, path_1.join)(entry.filename, '**', '*' + extension));
|
|
76
75
|
}
|
package/esm/codegen.js
CHANGED
|
@@ -165,7 +165,7 @@ export async function executeCodegen(input) {
|
|
|
165
165
|
? await getPresetByName(outputConfig.preset, makeDefaultLoader(context.cwd))
|
|
166
166
|
: outputConfig.preset
|
|
167
167
|
: null;
|
|
168
|
-
if (preset
|
|
168
|
+
if (preset && preset.prepareDocuments) {
|
|
169
169
|
outputSpecificDocuments = await preset.prepareDocuments(filename, outputSpecificDocuments);
|
|
170
170
|
}
|
|
171
171
|
return subTask.newListr([
|
|
@@ -237,7 +237,7 @@ export async function executeCodegen(input) {
|
|
|
237
237
|
...(typeof outputFileTemplateConfig === 'string'
|
|
238
238
|
? { value: outputFileTemplateConfig }
|
|
239
239
|
: outputFileTemplateConfig),
|
|
240
|
-
emitLegacyCommonJSImports: shouldEmitLegacyCommonJSImports(config),
|
|
240
|
+
emitLegacyCommonJSImports: shouldEmitLegacyCommonJSImports(config, filename),
|
|
241
241
|
};
|
|
242
242
|
const outputs = preset
|
|
243
243
|
? await context.profiler.run(async () => preset.buildGeneratesSection({
|
package/esm/config.js
CHANGED
|
@@ -50,9 +50,9 @@ function customLoader(ext) {
|
|
|
50
50
|
return loader;
|
|
51
51
|
}
|
|
52
52
|
export async function loadCodegenConfig({ configFilePath, moduleName, searchPlaces: additionalSearchPlaces, packageProp, loaders: customLoaders, }) {
|
|
53
|
-
configFilePath
|
|
54
|
-
moduleName
|
|
55
|
-
packageProp
|
|
53
|
+
configFilePath = configFilePath || process.cwd();
|
|
54
|
+
moduleName = moduleName || 'codegen';
|
|
55
|
+
packageProp = packageProp || moduleName;
|
|
56
56
|
const cosmi = cosmiconfig(moduleName, {
|
|
57
57
|
searchPlaces: generateSearchPlaces(moduleName).concat(additionalSearchPlaces || []),
|
|
58
58
|
packageProp,
|
|
@@ -332,7 +332,7 @@ function addHashToDocumentFiles(documentFilesPromise) {
|
|
|
332
332
|
return doc;
|
|
333
333
|
}));
|
|
334
334
|
}
|
|
335
|
-
export function shouldEmitLegacyCommonJSImports(config) {
|
|
335
|
+
export function shouldEmitLegacyCommonJSImports(config, outputPath) {
|
|
336
336
|
const globalValue = config.emitLegacyCommonJSImports === undefined ? true : Boolean(config.emitLegacyCommonJSImports);
|
|
337
337
|
// const outputConfig = config.generates[outputPath];
|
|
338
338
|
// if (!outputConfig) {
|
package/esm/graphql-config.js
CHANGED
|
@@ -51,7 +51,7 @@ function isGraphQLConfig(config) {
|
|
|
51
51
|
catch (e) { }
|
|
52
52
|
try {
|
|
53
53
|
for (const projectName in config.projects) {
|
|
54
|
-
if (
|
|
54
|
+
if (config.projects.hasOwnProperty(projectName)) {
|
|
55
55
|
const project = config.projects[projectName];
|
|
56
56
|
if (project.hasExtension('codegen')) {
|
|
57
57
|
return true;
|
package/esm/init/helpers.js
CHANGED
|
@@ -55,10 +55,14 @@ export async function writePackage(answers, configLocation) {
|
|
|
55
55
|
const pkgContent = readFileSync(pkgPath, 'utf8');
|
|
56
56
|
const pkg = JSON.parse(pkgContent);
|
|
57
57
|
const { indent } = detectIndent(pkgContent);
|
|
58
|
-
|
|
58
|
+
if (!pkg.scripts) {
|
|
59
|
+
pkg.scripts = {};
|
|
60
|
+
}
|
|
59
61
|
pkg.scripts[answers.script] = `graphql-codegen --config ${configLocation}`;
|
|
60
62
|
// plugin
|
|
61
|
-
|
|
63
|
+
if (!pkg.devDependencies) {
|
|
64
|
+
pkg.devDependencies = {};
|
|
65
|
+
}
|
|
62
66
|
await Promise.all((answers.plugins || []).map(async (plugin) => {
|
|
63
67
|
pkg.devDependencies[plugin.package] = await getLatestVersion(plugin.package);
|
|
64
68
|
}));
|
package/esm/presets.js
CHANGED
|
@@ -9,10 +9,10 @@ export async function getPresetByName(name, loader) {
|
|
|
9
9
|
for (const moduleName of possibleNames) {
|
|
10
10
|
try {
|
|
11
11
|
const loaded = await loader(moduleName);
|
|
12
|
-
if (loaded
|
|
12
|
+
if (loaded && loaded.preset) {
|
|
13
13
|
return loaded.preset;
|
|
14
14
|
}
|
|
15
|
-
if (loaded
|
|
15
|
+
if (loaded && loaded.default) {
|
|
16
16
|
return loaded.default;
|
|
17
17
|
}
|
|
18
18
|
return loaded;
|
package/esm/utils/logger.js
CHANGED
package/esm/utils/watcher.js
CHANGED
|
@@ -64,9 +64,8 @@ export const createWatcher = (initalContext, onNext) => {
|
|
|
64
64
|
Object.keys(config.generates)
|
|
65
65
|
.map(filename => ({ filename, config: normalizeOutputParam(config.generates[filename]) }))
|
|
66
66
|
.forEach(entry => {
|
|
67
|
-
var _a;
|
|
68
67
|
if (entry.config.preset) {
|
|
69
|
-
const extension =
|
|
68
|
+
const extension = entry.config.presetConfig && entry.config.presetConfig.extension;
|
|
70
69
|
if (extension) {
|
|
71
70
|
ignored.push(join(entry.filename, '**', '*' + extension));
|
|
72
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/cli",
|
|
3
|
-
"version": "2.16.4-alpha-
|
|
3
|
+
"version": "2.16.4-alpha-20230107200253-00a4e4db2",
|
|
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 || ^16.0.0",
|
|
6
6
|
"ts-node": ">=10"
|
package/typings/config.d.cts
CHANGED
|
@@ -136,4 +136,4 @@ export declare class CodegenContext {
|
|
|
136
136
|
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
137
137
|
}
|
|
138
138
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
139
|
-
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean;
|
|
139
|
+
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config, outputPath: string): boolean;
|
package/typings/config.d.ts
CHANGED
|
@@ -136,4 +136,4 @@ export declare class CodegenContext {
|
|
|
136
136
|
loadDocuments(pointer: Types.OperationDocument[]): Promise<Types.DocumentFile[]>;
|
|
137
137
|
}
|
|
138
138
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
139
|
-
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config): boolean;
|
|
139
|
+
export declare function shouldEmitLegacyCommonJSImports(config: Types.Config, outputPath: string): boolean;
|