@stepzen/transpiler 0.58.0-experimental.0b089b4 → 0.58.0-experimental.267d384
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/lib/actions/configure.d.ts +12 -0
- package/lib/actions/configure.d.ts.map +1 -0
- package/lib/actions/configure.js +131 -0
- package/lib/actions/configure.js.map +1 -0
- package/lib/actions/lint.d.ts +5 -0
- package/lib/actions/lint.d.ts.map +1 -0
- package/lib/actions/lint.js +38 -0
- package/lib/actions/lint.js.map +1 -0
- package/lib/actions/merge.d.ts +16 -0
- package/lib/actions/merge.d.ts.map +1 -0
- package/lib/actions/merge.js +193 -0
- package/lib/actions/merge.js.map +1 -0
- package/lib/actions/print.d.ts +4 -0
- package/lib/actions/print.d.ts.map +1 -0
- package/lib/actions/print.js +9 -0
- package/lib/actions/print.js.map +1 -0
- package/lib/actions/stitch.d.ts +3 -0
- package/lib/actions/stitch.d.ts.map +1 -0
- package/lib/actions/stitch.js +111 -0
- package/lib/actions/stitch.js.map +1 -0
- package/lib/actions/transpile.d.ts +17 -0
- package/lib/actions/transpile.d.ts.map +1 -0
- package/lib/actions/transpile.js +68 -0
- package/lib/actions/transpile.js.map +1 -0
- package/lib/actions/validate.d.ts +5 -0
- package/lib/actions/validate.d.ts.map +1 -0
- package/lib/actions/validate.js +39 -0
- package/lib/actions/validate.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/mutations/config/envvars.d.ts +3 -0
- package/lib/mutations/config/envvars.d.ts.map +1 -0
- package/lib/mutations/config/envvars.js +54 -0
- package/lib/mutations/config/envvars.js.map +1 -0
- package/lib/mutations/config/index.d.ts +3 -0
- package/lib/mutations/config/index.d.ts.map +1 -0
- package/lib/mutations/config/index.js +4 -0
- package/lib/mutations/config/index.js.map +1 -0
- package/lib/utils/constants.d.ts +4 -0
- package/lib/utils/constants.d.ts.map +1 -0
- package/lib/utils/constants.js +17 -0
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/copy-workspace-content.d.ts +15 -0
- package/lib/utils/copy-workspace-content.d.ts.map +1 -0
- package/lib/utils/copy-workspace-content.js +41 -0
- package/lib/utils/copy-workspace-content.js.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.d.ts +3 -0
- package/lib/utils/dedupe-query-and-mutation-types.d.ts.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.js +67 -0
- package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts +4 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.js +48 -0
- package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
- package/lib/utils/graphql-helpers.d.ts +5 -0
- package/lib/utils/graphql-helpers.d.ts.map +1 -0
- package/lib/utils/graphql-helpers.js +3 -0
- package/lib/utils/graphql-helpers.js.map +1 -0
- package/lib/utils/merge-helpers.d.ts +13 -0
- package/lib/utils/merge-helpers.d.ts.map +1 -0
- package/lib/utils/merge-helpers.js +183 -0
- package/lib/utils/merge-helpers.js.map +1 -0
- package/lib/utils/rmtemp.d.ts +11 -0
- package/lib/utils/rmtemp.d.ts.map +1 -0
- package/lib/utils/rmtemp.js +39 -0
- package/lib/utils/rmtemp.js.map +1 -0
- package/lib/utils/set-files-in-sdl.d.ts +6 -0
- package/lib/utils/set-files-in-sdl.d.ts.map +1 -0
- package/lib/utils/set-files-in-sdl.js +121 -0
- package/lib/utils/set-files-in-sdl.js.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts +4 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.js +43 -0
- package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
- package/lib/validators/config-exists/index.d.ts +4 -0
- package/lib/validators/config-exists/index.d.ts.map +1 -0
- package/lib/validators/config-exists/index.js +45 -0
- package/lib/validators/config-exists/index.js.map +1 -0
- package/lib/validators/index.d.ts +3 -0
- package/lib/validators/index.d.ts.map +1 -0
- package/lib/validators/index.js +4 -0
- package/lib/validators/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get effective StepZen endpoint configuration for a directory:
|
|
3
|
+
* Traverse the file system starting at `source` and
|
|
4
|
+
* - merge all `config.yaml` files (discarding unrecognized properties)
|
|
5
|
+
* - merge all `config` sections from `stepzen.config.json` files
|
|
6
|
+
*
|
|
7
|
+
* Possibly, interactive: if `silent` is `false` and there are non-empty
|
|
8
|
+
* `config` sections in `stepzen.config.json` files.
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: (source: string, silent?: boolean, answers?: any) => Promise<Record<string, any> | undefined>;
|
|
11
|
+
export default _default;
|
|
12
|
+
//# sourceMappingURL=configure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../../src/actions/configure.ts"],"names":[],"mappings":"AASA;;;;;;;;GAQG;yBAED,QAAQ,MAAM,EACd,gBAAc,EACd,UAAS,GAAQ,KAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;AAJ3C,wBAmKC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020, 2025
|
|
2
|
+
import debug from 'debug';
|
|
3
|
+
import fsx from 'fs-extra';
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import yaml from 'yaml';
|
|
8
|
+
/**
|
|
9
|
+
* Get effective StepZen endpoint configuration for a directory:
|
|
10
|
+
* Traverse the file system starting at `source` and
|
|
11
|
+
* - merge all `config.yaml` files (discarding unrecognized properties)
|
|
12
|
+
* - merge all `config` sections from `stepzen.config.json` files
|
|
13
|
+
*
|
|
14
|
+
* Possibly, interactive: if `silent` is `false` and there are non-empty
|
|
15
|
+
* `config` sections in `stepzen.config.json` files.
|
|
16
|
+
*/
|
|
17
|
+
export default async (source, silent = false, answers = {}) => {
|
|
18
|
+
const config = {
|
|
19
|
+
configurationset: [],
|
|
20
|
+
ruleset: [],
|
|
21
|
+
access: undefined,
|
|
22
|
+
deployment: undefined,
|
|
23
|
+
};
|
|
24
|
+
debug('stepzen:transpiler:config')(`getting effective config for ${source}`);
|
|
25
|
+
// Now let's parse and add any config.yamls
|
|
26
|
+
let configYamlCount = 0;
|
|
27
|
+
for (const y of globSync('**/config.yaml', { cwd: source })) {
|
|
28
|
+
const filePath = path.join(source, y);
|
|
29
|
+
const file = fsx.readFileSync(filePath, 'utf8');
|
|
30
|
+
let asYAML;
|
|
31
|
+
try {
|
|
32
|
+
asYAML = yaml.parse(file, { schema: 'failsafe' });
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
debug('stepzen:transpiler:config')(`Ignoring an invalid config.yaml ${filePath}.` +
|
|
36
|
+
` YAML parse error: ${error}`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!asYAML) {
|
|
40
|
+
debug('stepzen:transpiler:config')(`ignoring an empty config.yaml ${filePath}`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
configYamlCount += 1;
|
|
44
|
+
debug('stepzen:transpiler:config')(`adding config.yaml ${filePath}:\n${JSON.stringify(asYAML, null, 2)}`);
|
|
45
|
+
// strip away any non-recognized properties
|
|
46
|
+
Object.entries(asYAML).forEach(([keyAsAny, value]) => {
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(config, keyAsAny)) {
|
|
48
|
+
const key = keyAsAny;
|
|
49
|
+
config[key] = Array.isArray(config[key])
|
|
50
|
+
? config[key].concat(value)
|
|
51
|
+
: value;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
debug('stepzen:transpiler:config')(`ignoring unrecognized config property ${keyAsAny}`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
debug('stepzen:transpiler:config')(`done adding **/config.yaml files (processed: ${configYamlCount})`);
|
|
59
|
+
// Now let's build configs from questions
|
|
60
|
+
let configJsonCount = 0;
|
|
61
|
+
for await (const j of globSync('**/stepzen.config.json', {
|
|
62
|
+
cwd: source,
|
|
63
|
+
})) {
|
|
64
|
+
const filePath = path.join(source, j);
|
|
65
|
+
const file = fsx.readFileSync(filePath, 'utf8');
|
|
66
|
+
const asJSON = JSON.parse(file);
|
|
67
|
+
configJsonCount += 1;
|
|
68
|
+
debug('stepzen:transpiler:config')(`adding stepzen.config.json ${filePath}:` +
|
|
69
|
+
`\n${JSON.stringify(asJSON, null, 2)}`);
|
|
70
|
+
if (asJSON.config?.questions) {
|
|
71
|
+
for await (const question of asJSON.config?.questions) {
|
|
72
|
+
const [name, key] = question.name.split('.');
|
|
73
|
+
let answer = {};
|
|
74
|
+
if (silent) {
|
|
75
|
+
answer = {
|
|
76
|
+
[name]: { [key]: answers[name]?.[key] ? answers[name]?.[key] : '' },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
answer = await inquirer.prompt({
|
|
81
|
+
type: 'password',
|
|
82
|
+
...question,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const configset = {
|
|
86
|
+
configuration: {
|
|
87
|
+
name,
|
|
88
|
+
[key]: answer[name][key],
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
debug('stepzen:transpiler:config')(`question: ${JSON.stringify(question, null, 2)}`);
|
|
92
|
+
debug('stepzen:transpiler:config')(`answer: ${JSON.stringify(configset, null, 2)}`);
|
|
93
|
+
config.configurationset.push({ ...configset });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
debug('stepzen:transpiler:config')(`done adding **/stepzen.config.json files (processed: ${configJsonCount})`);
|
|
98
|
+
debug('stepzen:transpiler:config')(`combined content of all config files:` +
|
|
99
|
+
`\n${JSON.stringify(config, null, 2)}`);
|
|
100
|
+
// OK now let's collate everything into shared configurations
|
|
101
|
+
const configurationset = [];
|
|
102
|
+
{
|
|
103
|
+
const obj = {};
|
|
104
|
+
for (const c of config.configurationset) {
|
|
105
|
+
const name = c.configuration.name;
|
|
106
|
+
if (!obj[name])
|
|
107
|
+
obj[name] = {};
|
|
108
|
+
for (const [key, value] of Object.entries(c.configuration)) {
|
|
109
|
+
if (key === name)
|
|
110
|
+
continue;
|
|
111
|
+
obj[name][key] = value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const configuration of Object.keys(obj)) {
|
|
115
|
+
configurationset.push({
|
|
116
|
+
configuration: { ...obj[configuration] },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Now convert back into StepZen format
|
|
121
|
+
const structured = Object.fromEntries(Object.entries({ ...config, configurationset }).filter(([_key, value]) => Array.isArray(value) ? value.length > 0 : value !== undefined));
|
|
122
|
+
// Return YAML, if appropriate
|
|
123
|
+
if (Object.keys(structured).length > 0) {
|
|
124
|
+
debug('stepzen:transpiler:config')(`effective config:\n${yaml.stringify(structured)}`);
|
|
125
|
+
return structured;
|
|
126
|
+
}
|
|
127
|
+
debug('stepzen:transpiler:config')(`Could not find any of the supported properties in the config:` +
|
|
128
|
+
` [ '${Object.keys(config).join(`', '`)}' ].` +
|
|
129
|
+
` Retuning <undefined> meaning 'effective config is empty'.`);
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/actions/configure.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAC,QAAQ,EAAC,M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B,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CACrE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAC9D,CACF,CAAA;IAED,8BAA8B;IAC9B,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,KAAK,CAAC,2BAA2B,CAAC,CAChC,sBAAsB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CACnD,CAAA;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,CAChC,+DAA+D;QAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;QAC7C,4DAA4D,CAC/D,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":"yBAYE,QAAQ,MAAM,EACd,UAAS;IACP,UAAU,EAAE,MAAM,CAAA;CAGnB;AANH,wBAqCC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020, 2025
|
|
2
|
+
import fsx from 'fs-extra';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import shell from 'shelljs';
|
|
6
|
+
import stitch from '../actions/stitch.js';
|
|
7
|
+
import { getExtensions } from '../utils/merge-helpers.js';
|
|
8
|
+
import { rmtemp } from '../utils/rmtemp.js';
|
|
9
|
+
export default async (source, options = {
|
|
10
|
+
extensions: '',
|
|
11
|
+
}) => {
|
|
12
|
+
if (!fsx.existsSync(source)) {
|
|
13
|
+
throw new Error(`Cannot find source directory ${source}`);
|
|
14
|
+
}
|
|
15
|
+
let extensions = options.extensions;
|
|
16
|
+
if (!extensions) {
|
|
17
|
+
extensions = await getExtensions();
|
|
18
|
+
}
|
|
19
|
+
let stitched, tmp;
|
|
20
|
+
try {
|
|
21
|
+
stitched = stitch(source);
|
|
22
|
+
const index = path.join(stitched, 'index.graphql');
|
|
23
|
+
const graphql = fsx.readFileSync(index, 'utf8');
|
|
24
|
+
tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`);
|
|
25
|
+
fsx.ensureDirSync(tmp, 0o700);
|
|
26
|
+
const lintFile = path.join(tmp, 'index.graphql');
|
|
27
|
+
fsx.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`);
|
|
28
|
+
const { stdout } = shell.exec(`npx graphql-schema-linter ${lintFile}`, {
|
|
29
|
+
silent: true,
|
|
30
|
+
});
|
|
31
|
+
console.log(stdout);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
rmtemp(stitched);
|
|
35
|
+
rmtemp(tmp);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAEzC,eAAe,KAAK,EAClB,MAAc,EACd,UAEI;IACF,UAAU,EAAE,EAAE;CACf,EACD,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,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1
|
+
export type MergeOptions = {
|
|
2
|
+
answers: any;
|
|
3
|
+
output: string | null;
|
|
4
|
+
silent: boolean;
|
|
5
|
+
/** when `false` merge only covers config files and updates @sdl directrive */
|
|
6
|
+
mergeTypes?: boolean;
|
|
7
|
+
/** merge behaviour when a schema with the given name exists in the source */
|
|
8
|
+
onConflict?: 'overwrite' | 'append';
|
|
9
|
+
extensions?: string;
|
|
10
|
+
};
|
|
11
|
+
declare const merge: (original: string, imported: {
|
|
12
|
+
name: string;
|
|
13
|
+
source: string;
|
|
14
|
+
}, options?: MergeOptions) => Promise<string>;
|
|
15
|
+
export default merge;
|
|
16
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"AA+CA,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,GAAG,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AA8LD,QAAA,MAAM,KAAK,GACT,UAAU,MAAM,EAChB,UAAU;IACR,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,EACD,UAAS,YAOR,oBAqBF,CAAA;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020, 2025
|
|
2
|
+
import fsx from 'fs-extra';
|
|
3
|
+
import { globSync } from 'glob';
|
|
4
|
+
import { mergeTypeDefs } from '@graphql-tools/merge';
|
|
5
|
+
import { parse, visit } from 'graphql';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import yaml from 'yaml';
|
|
9
|
+
import { dedupeTempFolder, findQueryMutationInSchema, findTypeInSchema, getSchema, mergeQueryMutationIntoSchema, removeQueryMutationFromSchema, mergeTypeIntoSchema, removeTypeFromSchema, getConfiguration, findNextAvailableSubfolder, getExtensions, } from '../utils/merge-helpers.js';
|
|
10
|
+
import print from './print.js';
|
|
11
|
+
import setFilesInSDL from '../utils/set-files-in-sdl.js';
|
|
12
|
+
import stripEmptyQueriesAndMutations from '../utils/strip-empty-queries-and-mutations.js';
|
|
13
|
+
import copyWorkspaceContent from '../utils/copy-workspace-content.js';
|
|
14
|
+
import { ALL_GRAPHQL_FILES } from '../utils/constants.js';
|
|
15
|
+
import { rmtemp } from '../utils/rmtemp.js';
|
|
16
|
+
// It's safe to use this special placeholder value here: in case of a failure
|
|
17
|
+
// in the merge / import process it will not reach the workspace folder.
|
|
18
|
+
// All intermediary steps are carried out in a temp folder, and only when all
|
|
19
|
+
// merge / import steps are completed, the result it copied over to the
|
|
20
|
+
// workspace folder.
|
|
21
|
+
const BLANK_INDEX_TEMPLATE = `
|
|
22
|
+
schema @sdl(files: ["${ALL_GRAPHQL_FILES}"]) {
|
|
23
|
+
query: Query
|
|
24
|
+
}
|
|
25
|
+
`.trim();
|
|
26
|
+
const BLANK_QUERY_TYPE = `
|
|
27
|
+
type Query {
|
|
28
|
+
__query: String
|
|
29
|
+
}
|
|
30
|
+
`.trim();
|
|
31
|
+
const doMerge = async (original, imported, options) => {
|
|
32
|
+
if (!options.answers)
|
|
33
|
+
options.answers = {};
|
|
34
|
+
if (!options.silent)
|
|
35
|
+
options.silent = false;
|
|
36
|
+
if (options.mergeTypes === undefined)
|
|
37
|
+
options.mergeTypes = true;
|
|
38
|
+
if (options.onConflict === undefined)
|
|
39
|
+
options.onConflict = 'append';
|
|
40
|
+
if (!options.extensions)
|
|
41
|
+
options.extensions = await getExtensions();
|
|
42
|
+
// To stop things like
|
|
43
|
+
// C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-config-1638293497187\C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-1638293496286
|
|
44
|
+
options.output = dedupeTempFolder(options.output);
|
|
45
|
+
// Ensure original, importing and output directories exist
|
|
46
|
+
if (!fsx.existsSync(original))
|
|
47
|
+
throw new Error(`Cannot find original directory ${original}`);
|
|
48
|
+
if (!fsx.existsSync(imported.source))
|
|
49
|
+
throw new Error(`Cannot find imported source directory ${imported.source}`);
|
|
50
|
+
fsx.ensureDirSync(options.output, 0o700);
|
|
51
|
+
// Copy the original into the output.
|
|
52
|
+
copyWorkspaceContent(original, options.output);
|
|
53
|
+
// Ensure an index.graphql exists
|
|
54
|
+
const outputIndex = path.join(options.output, 'index.graphql');
|
|
55
|
+
if (!fsx.existsSync(outputIndex)) {
|
|
56
|
+
fsx.writeFileSync(outputIndex, options.mergeTypes
|
|
57
|
+
? // (2022-03-09, vluakshov) Not sure what'd break without the
|
|
58
|
+
// blank Query type, but that's why I do not want to remove it
|
|
59
|
+
// from the default code path.
|
|
60
|
+
BLANK_INDEX_TEMPLATE + BLANK_QUERY_TYPE
|
|
61
|
+
: // In the non-default code path that does NOT merge types
|
|
62
|
+
// the blank Query type causes explicit problems
|
|
63
|
+
// (https://github.com/steprz/stepzen-cli/issues/482).
|
|
64
|
+
BLANK_INDEX_TEMPLATE);
|
|
65
|
+
}
|
|
66
|
+
const targetSubfolder = options.onConflict === 'overwrite'
|
|
67
|
+
? imported.name
|
|
68
|
+
: findNextAvailableSubfolder(original, imported.name);
|
|
69
|
+
let importedGraphQLFiles = [];
|
|
70
|
+
if (options.mergeTypes) {
|
|
71
|
+
const merged = mergeTypeDefs([
|
|
72
|
+
await getSchema(options.output, options.extensions),
|
|
73
|
+
await getSchema(imported.source, options.extensions),
|
|
74
|
+
]);
|
|
75
|
+
let queries = [];
|
|
76
|
+
let mutations = [];
|
|
77
|
+
let types = [];
|
|
78
|
+
visit(merged, {
|
|
79
|
+
ObjectTypeDefinition(node) {
|
|
80
|
+
if (node.name.value === 'Query')
|
|
81
|
+
queries = queries.concat(node.fields);
|
|
82
|
+
else if (node.name.value === 'Mutation')
|
|
83
|
+
mutations = mutations.concat(node.fields);
|
|
84
|
+
else
|
|
85
|
+
types = types.concat(node);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const details = {
|
|
89
|
+
original: globSync('**/*.graphql', { cwd: options.output }).map(file => {
|
|
90
|
+
const content = fsx.readFileSync(path.join(options.output, file), 'utf8');
|
|
91
|
+
return { ast: parse(content), file };
|
|
92
|
+
}),
|
|
93
|
+
imported: globSync('**/*.graphql', { cwd: imported.source }).map(file => {
|
|
94
|
+
const content = fsx.readFileSync(path.join(imported.source, file), 'utf8');
|
|
95
|
+
return { ast: parse(content), file };
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
// Merge Queries and Mutations
|
|
99
|
+
for (const type of [...queries, ...mutations]) {
|
|
100
|
+
const isInOriginal = findQueryMutationInSchema(type.name.value, details.original);
|
|
101
|
+
const isInImported = findQueryMutationInSchema(type.name.value, details.imported);
|
|
102
|
+
if (isInOriginal && isInImported) {
|
|
103
|
+
details.original = mergeQueryMutationIntoSchema(type, details.original);
|
|
104
|
+
details.imported = removeQueryMutationFromSchema(type.name.value, details.imported);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Merge Types
|
|
108
|
+
for (const type of types) {
|
|
109
|
+
const isInOriginal = findTypeInSchema(type.name.value, details.original);
|
|
110
|
+
const isInImported = findTypeInSchema(type.name.value, details.imported);
|
|
111
|
+
if (isInOriginal && isInImported) {
|
|
112
|
+
details.original = mergeTypeIntoSchema(type, details.original);
|
|
113
|
+
details.imported = removeTypeFromSchema(type.name.value, details.imported);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Clean up the files. Remove empty Query / Mutation types, filter out now-empty files
|
|
117
|
+
const cleaned = {
|
|
118
|
+
original: details.original
|
|
119
|
+
.map(item => ({
|
|
120
|
+
...item,
|
|
121
|
+
ast: stripEmptyQueriesAndMutations(item.ast),
|
|
122
|
+
}))
|
|
123
|
+
.filter(item => item.ast.definitions.length > 0),
|
|
124
|
+
imported: details.imported
|
|
125
|
+
.map(item => ({
|
|
126
|
+
...item,
|
|
127
|
+
ast: stripEmptyQueriesAndMutations(item.ast),
|
|
128
|
+
}))
|
|
129
|
+
.filter(item => item.ast.definitions.length > 0),
|
|
130
|
+
};
|
|
131
|
+
// Write the files to the output directory
|
|
132
|
+
cleaned.original.forEach((a) => {
|
|
133
|
+
// eslint-disable-next-line
|
|
134
|
+
const file = path.join(options.output, a.file);
|
|
135
|
+
const deduped = dedupeTempFolder(file);
|
|
136
|
+
fsx.ensureFileSync(deduped);
|
|
137
|
+
fsx.writeFileSync(deduped, print(a.ast));
|
|
138
|
+
});
|
|
139
|
+
cleaned.imported.forEach(a => {
|
|
140
|
+
// eslint-disable-next-line
|
|
141
|
+
const file = path.join(options.output, targetSubfolder, a.file);
|
|
142
|
+
const deduped = dedupeTempFolder(file);
|
|
143
|
+
fsx.ensureFileSync(deduped);
|
|
144
|
+
fsx.writeFileSync(deduped, print(a.ast));
|
|
145
|
+
importedGraphQLFiles.push(path.relative(options.output, deduped));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
globSync('**/*.graphql', { cwd: imported.source }).forEach(relativePath => {
|
|
150
|
+
const importedFullPath = path.join(imported.source, relativePath);
|
|
151
|
+
const targetFullPath = path.join(options.output, targetSubfolder, relativePath);
|
|
152
|
+
fsx.ensureDirSync(path.dirname(targetFullPath));
|
|
153
|
+
fsx.copyFileSync(importedFullPath, targetFullPath);
|
|
154
|
+
importedGraphQLFiles.push(path.relative(options.output, targetFullPath));
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Make sure all files are referenced in @sdl
|
|
158
|
+
setFilesInSDL(options.output, importedGraphQLFiles);
|
|
159
|
+
// Generate configuration
|
|
160
|
+
const config = await getConfiguration([options.output, imported.source], options.silent, options.answers);
|
|
161
|
+
if (config) {
|
|
162
|
+
const configFile = path.join(options.output, 'config.yaml');
|
|
163
|
+
fsx.writeFileSync(configFile, yaml.stringify(config), { mode: 0o600 });
|
|
164
|
+
}
|
|
165
|
+
// Return a merged schema!
|
|
166
|
+
return options.output;
|
|
167
|
+
};
|
|
168
|
+
const merge = (original, imported, options = {
|
|
169
|
+
answers: {},
|
|
170
|
+
output: null,
|
|
171
|
+
silent: false,
|
|
172
|
+
mergeTypes: true,
|
|
173
|
+
onConflict: 'append',
|
|
174
|
+
extensions: '',
|
|
175
|
+
}) => {
|
|
176
|
+
// Make sure there is an output directory
|
|
177
|
+
if (options.output) {
|
|
178
|
+
return doMerge(original, imported, options);
|
|
179
|
+
}
|
|
180
|
+
const output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
181
|
+
try {
|
|
182
|
+
return doMerge(original, imported, { ...options, output });
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
// In case of an error delete the temp output folder created earlier so that
|
|
186
|
+
// it does not "leak". In case of a success, deleting the output folder is
|
|
187
|
+
// the caller responsibility.
|
|
188
|
+
rmtemp(output);
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
export default merge;
|
|
193
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM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AC,YAAY,EAAQ,MAAM,SAAS,CAAA;yBAG3B,KAAK,YAAY,KAAG,MAAM;AAA1C,wBAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020, 2025
|
|
2
|
+
import { print } from 'graphql';
|
|
3
|
+
import prettier from 'prettier';
|
|
4
|
+
export default (ast) => {
|
|
5
|
+
const printed = print(ast);
|
|
6
|
+
const formatted = prettier.format(printed, { parser: 'graphql' });
|
|
7
|
+
return formatted;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../src/actions/print.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAe,KAAK,EAAC,MAAM,SAAS,CAAA;AAC3C,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,eAAe,CAAC,GAAiB,EAAU,EAAE;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;IAC1B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAA;IAC/D,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stitch.d.ts","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"AAkHA,QAAA,MAAM,MAAM,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,WAe9C,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright IBM Corp. 2020, 2025
|
|
2
|
+
import { clone, cloneDeep } from 'lodash-es';
|
|
3
|
+
import { parse, print, visit } from 'graphql';
|
|
4
|
+
import fsx from 'fs-extra';
|
|
5
|
+
import { globSync } from 'glob';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import prettier from 'prettier';
|
|
9
|
+
import dedupeQueryAndMutationTypes from '../utils/dedupe-query-and-mutation-types.js';
|
|
10
|
+
import { ALL_GRAPHQL_FILES } from '../utils/constants.js';
|
|
11
|
+
import { getAllGraphQLFiles } from '../utils/copy-workspace-content.js';
|
|
12
|
+
import { rmtemp } from '../utils/rmtemp.js';
|
|
13
|
+
const doStitch = (source, output) => {
|
|
14
|
+
// Ensure source and output directories exist
|
|
15
|
+
if (!fsx.existsSync(source))
|
|
16
|
+
throw new Error(`Cannot find source directory ${source}`);
|
|
17
|
+
fsx.ensureDirSync(output, 0o700);
|
|
18
|
+
// Get a list of files.
|
|
19
|
+
let ast;
|
|
20
|
+
let files = [];
|
|
21
|
+
// If there's an index.graphQL - get files argument in @sdl directive
|
|
22
|
+
const sourceIndex = path.join(source, 'index.graphql');
|
|
23
|
+
if (fsx.existsSync(sourceIndex)) {
|
|
24
|
+
const index = fsx.readFileSync(sourceIndex, 'utf8');
|
|
25
|
+
ast = parse(index);
|
|
26
|
+
ast = visit(ast, {
|
|
27
|
+
Directive(node) {
|
|
28
|
+
if (node.name.value === 'sdl') {
|
|
29
|
+
const list = node.arguments?.find((arg) => arg.name.value === 'files');
|
|
30
|
+
// If we find a 'files' argument, we copy the list, and remove the argument
|
|
31
|
+
if (list) {
|
|
32
|
+
const copy = clone(list.value);
|
|
33
|
+
for (const file of copy.values) {
|
|
34
|
+
if (file.value === ALL_GRAPHQL_FILES) {
|
|
35
|
+
files = files.concat(getAllGraphQLFiles(source));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
files = files.concat(file.value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const mutated = cloneDeep(node);
|
|
42
|
+
mutated.arguments = mutated.arguments.filter((arg) => arg.name.value !== 'files');
|
|
43
|
+
return mutated;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const content = globSync('**/*.graphql', { cwd: source }).map((file) => {
|
|
51
|
+
const graphql = fsx.readFileSync(`${source}/${file}`, 'utf8');
|
|
52
|
+
return graphql;
|
|
53
|
+
});
|
|
54
|
+
ast = parse(content.join(os.EOL));
|
|
55
|
+
}
|
|
56
|
+
// Strip @sdl directive
|
|
57
|
+
ast = visit(ast, {
|
|
58
|
+
Directive(node) {
|
|
59
|
+
if (node.name.value === 'sdl')
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// Check all the files exist
|
|
64
|
+
for (const file of files) {
|
|
65
|
+
const find = path.join(source, file);
|
|
66
|
+
if (!fsx.existsSync(find)) {
|
|
67
|
+
throw new Error(`Cannot find file ${file} referenced in the @sdl directive in index.graphql`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Get all the files and stitch
|
|
71
|
+
const printed = print(ast);
|
|
72
|
+
let stitched = `${printed}${os.EOL}`;
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const find = path.join(source, file);
|
|
75
|
+
const content = fsx.readFileSync(find, 'utf8');
|
|
76
|
+
stitched += `${content}${os.EOL}`;
|
|
77
|
+
}
|
|
78
|
+
// Dedupe Query and Mutation types
|
|
79
|
+
stitched = dedupeQueryAndMutationTypes(stitched);
|
|
80
|
+
// Format
|
|
81
|
+
stitched = prettier.format(stitched, { parser: 'graphql' });
|
|
82
|
+
// Write to output folder
|
|
83
|
+
const outputIndex = path.join(output, 'index.graphql');
|
|
84
|
+
fsx.writeFileSync(outputIndex, stitched);
|
|
85
|
+
// Copy config if exists, too
|
|
86
|
+
const sourceConfig = path.join(source, 'config.yaml');
|
|
87
|
+
const outputConfig = path.join(output, 'config.yaml');
|
|
88
|
+
if (fsx.existsSync(sourceConfig)) {
|
|
89
|
+
fsx.copyFileSync(sourceConfig, outputConfig);
|
|
90
|
+
}
|
|
91
|
+
// Return output folder
|
|
92
|
+
return output;
|
|
93
|
+
};
|
|
94
|
+
const stitch = (source, output) => {
|
|
95
|
+
if (output) {
|
|
96
|
+
return doStitch(source, output);
|
|
97
|
+
}
|
|
98
|
+
output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
99
|
+
try {
|
|
100
|
+
return doStitch(source, output);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// In case of an error delete the temp output folder created earlier so that
|
|
104
|
+
// it does not "leak". In case of a success, deleting the output folder is
|
|
105
|
+
// the caller responsibility.
|
|
106
|
+
rmtemp(output);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export default stitch;
|
|
111
|
+
//# sourceMappingURL=stitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,SAAS,CAAA;AAC3C,OAAO,GAAG,MAAM,UAAU,CAAA;AAC1B,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,OAAO,2BAA2B,MAAM,6CAA6C,CAAA;AACrF,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAA;AAEzC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IAClD,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QACzB,MAAM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M,EAAE,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAC5D,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,0EAA0E;QAC1E,6BAA6B;QAC7B,MAAM,CAAC,MAAM,CAAC,CAAA;QACd,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
3
|
+
* transformations, and return its effective GraphQL schema and configuration
|
|
4
|
+
* as in-memory strings.
|
|
5
|
+
*
|
|
6
|
+
* @param {*} source absolute path to a schema root folder
|
|
7
|
+
* @return {*} schema, configuration, and a "transpiled" flag indicating
|
|
8
|
+
* whether or not any StepZen-specific transformations have actually
|
|
9
|
+
* been applied.
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: (source: string) => Promise<{
|
|
12
|
+
config: string;
|
|
13
|
+
schema: string;
|
|
14
|
+
transpiled: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=transpile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;yBACmB,QAAQ,MAAM;;;;;AAApC,wBAsDC"}
|