@stepzen/transpiler 0.28.0-beta.0 → 0.28.0-experimental.fa8aa47
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.js +3 -3
- package/lib/actions/configure.js.map +1 -1
- package/lib/actions/lint.js +6 -6
- package/lib/actions/lint.js.map +1 -1
- package/lib/actions/merge.js +15 -15
- package/lib/actions/merge.js.map +1 -1
- package/lib/actions/stitch.js +11 -11
- package/lib/actions/stitch.js.map +1 -1
- package/lib/actions/validate.js +4 -4
- package/lib/actions/validate.js.map +1 -1
- package/lib/utils/copy-workspace-content.js +4 -4
- package/lib/utils/copy-workspace-content.js.map +1 -1
- package/lib/utils/merge-helpers.js +7 -7
- package/lib/utils/merge-helpers.js.map +1 -1
- package/lib/utils/set-files-in-sdl.d.ts +2 -2
- package/lib/utils/set-files-in-sdl.d.ts.map +1 -1
- package/lib/utils/set-files-in-sdl.js +12 -12
- package/lib/utils/set-files-in-sdl.js.map +1 -1
- package/package.json +13 -12
- package/src/actions/configure.ts +3 -3
- package/src/actions/lint.ts +6 -6
- package/src/actions/merge.ts +15 -15
- package/src/actions/stitch.ts +11 -11
- package/src/actions/validate.ts +4 -4
- package/src/utils/copy-workspace-content.ts +4 -4
- package/src/utils/merge-helpers.ts +7 -7
- package/src/utils/set-files-in-sdl.ts +16 -13
package/lib/actions/configure.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const debug = require("debug");
|
|
4
|
-
const
|
|
4
|
+
const fsx = require("fs-extra");
|
|
5
5
|
const glob = require("glob");
|
|
6
6
|
const inquirer = require("inquirer");
|
|
7
7
|
const path = require("path");
|
|
@@ -27,7 +27,7 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
27
27
|
let configYamlCount = 0;
|
|
28
28
|
for (const y of glob.sync('**/config.yaml', { cwd: source })) {
|
|
29
29
|
const filePath = path.join(source, y);
|
|
30
|
-
const file =
|
|
30
|
+
const file = fsx.readFileSync(filePath, 'utf8');
|
|
31
31
|
let asYAML;
|
|
32
32
|
try {
|
|
33
33
|
asYAML = yaml.parse(file, { schema: 'failsafe' });
|
|
@@ -63,7 +63,7 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
63
63
|
cwd: source,
|
|
64
64
|
})) {
|
|
65
65
|
const filePath = path.join(source, j);
|
|
66
|
-
const file =
|
|
66
|
+
const file = fsx.readFileSync(filePath, 'utf8');
|
|
67
67
|
const asJSON = JSON.parse(file);
|
|
68
68
|
configJsonCount += 1;
|
|
69
69
|
debug('stepzen:transpiler:config')(`adding stepzen.config.json ${filePath}:` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/actions/configure.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/actions/configure.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,gCAA+B;AAC/B,6BAA4B;AAC5B,qCAAoC;AACpC,6BAA4B;AAC5B,6BAA4B;AAE5B;;;;;;;;GAQG;AACH,kBAAe,KAAK,EAAE,MAAc,EAAE,MAAM,GAAG,KAAK,EAAE,UAAe,EAAE,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG;QACb,gBAAgB,EAAE,EAAW;QAC7B,OAAO,EAAE,EAAW;QACpB,MAAM,EAAE,SAAgB;QACxB,UAAU,EAAE,SAAgB;KAC7B,CAAA;IAED,KAAK,CAAC,2BAA2B,CAAC,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;IAE5E,2CAA2C;IAC3C,IAAI,eAAe,GAAG,CAAC,CAAA;IACvB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC,EAAE;QAC1D,MAA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ports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const fsx = require("fs-extra");
|
|
4
4
|
const os = require("os");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const shell = require("shelljs");
|
|
@@ -9,7 +9,7 @@ const merge_helpers_1 = require("../utils/merge-helpers");
|
|
|
9
9
|
exports.default = async (source, options = {
|
|
10
10
|
extensions: '',
|
|
11
11
|
}) => {
|
|
12
|
-
if (!
|
|
12
|
+
if (!fsx.existsSync(source)) {
|
|
13
13
|
throw new Error(`Cannot find source directory ${source}`);
|
|
14
14
|
}
|
|
15
15
|
let extensions = options.extensions;
|
|
@@ -18,14 +18,14 @@ exports.default = async (source, options = {
|
|
|
18
18
|
}
|
|
19
19
|
const stitched = (0, stitch_1.default)(source);
|
|
20
20
|
const index = path.join(stitched, 'index.graphql');
|
|
21
|
-
const graphql =
|
|
21
|
+
const graphql = fsx.readFileSync(index, 'utf8');
|
|
22
22
|
const tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`);
|
|
23
|
-
|
|
23
|
+
fsx.ensureDirSync(tmp);
|
|
24
24
|
const lintFile = path.join(tmp, 'index.graphql');
|
|
25
|
-
|
|
25
|
+
fsx.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`);
|
|
26
26
|
shell.exec(`npx graphql-schema-linter ${lintFile}`, { silent: true }, (code, stdout, stderr) => {
|
|
27
27
|
console.log(stdout);
|
|
28
|
-
|
|
28
|
+
fsx.removeSync(tmp);
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=lint.js.map
|
package/lib/actions/lint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":";;AAAA,gCAA+B;AAC/B,yBAAwB;AACxB,6BAA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C,CAAA;IACrB,CAAC,CACF,CAAA;AACH,CAAC,CAAA"}
|
package/lib/actions/merge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const fsx = require("fs-extra");
|
|
4
4
|
const glob = require("glob");
|
|
5
5
|
const merge_1 = require("@graphql-tools/merge");
|
|
6
6
|
const graphql_1 = require("graphql");
|
|
@@ -52,17 +52,17 @@ exports.default = async (original, imported, options = {
|
|
|
52
52
|
// C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-config-1638293497187\C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-1638293496286
|
|
53
53
|
options.output = (0, merge_helpers_1.dedupeTempFolder)(options.output);
|
|
54
54
|
// Ensure original, importing and output directories exist
|
|
55
|
-
if (!
|
|
55
|
+
if (!fsx.existsSync(original))
|
|
56
56
|
throw new Error(`Cannot find original directory ${original}`);
|
|
57
|
-
if (!
|
|
57
|
+
if (!fsx.existsSync(imported.source))
|
|
58
58
|
throw new Error(`Cannot find imported source directory ${imported.source}`);
|
|
59
|
-
|
|
59
|
+
fsx.ensureDirSync(options.output);
|
|
60
60
|
// Copy the original into the output.
|
|
61
61
|
(0, copy_workspace_content_1.default)(original, options.output);
|
|
62
62
|
// Ensure an index.graphql exists
|
|
63
63
|
const outputIndex = path.join(options.output, 'index.graphql');
|
|
64
|
-
if (!
|
|
65
|
-
|
|
64
|
+
if (!fsx.existsSync(outputIndex)) {
|
|
65
|
+
fsx.writeFileSync(outputIndex, options.mergeTypes
|
|
66
66
|
? // (2022-03-09, vluakshov) Not sure what'd break without the
|
|
67
67
|
// blank Query type, but that's why I do not want to remove it
|
|
68
68
|
// from the default code path.
|
|
@@ -96,11 +96,11 @@ exports.default = async (original, imported, options = {
|
|
|
96
96
|
});
|
|
97
97
|
const details = {
|
|
98
98
|
original: glob.sync('**/*.graphql', { cwd: options.output }).map(file => {
|
|
99
|
-
const content =
|
|
99
|
+
const content = fsx.readFileSync(`${options.output}/${file}`, 'utf8');
|
|
100
100
|
return { ast: (0, graphql_1.parse)(content), file };
|
|
101
101
|
}),
|
|
102
102
|
imported: glob.sync('**/*.graphql', { cwd: imported.source }).map(file => {
|
|
103
|
-
const content =
|
|
103
|
+
const content = fsx.readFileSync(`${imported.source}/${file}`, 'utf8');
|
|
104
104
|
return { ast: (0, graphql_1.parse)(content), file };
|
|
105
105
|
}),
|
|
106
106
|
};
|
|
@@ -142,15 +142,15 @@ exports.default = async (original, imported, options = {
|
|
|
142
142
|
// eslint-disable-next-line
|
|
143
143
|
const file = path.join(options.output, a.file);
|
|
144
144
|
const deduped = (0, merge_helpers_1.dedupeTempFolder)(file);
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
fsx.ensureFileSync(deduped);
|
|
146
|
+
fsx.writeFileSync(deduped, (0, print_1.default)(a.ast));
|
|
147
147
|
});
|
|
148
148
|
cleaned.imported.forEach(a => {
|
|
149
149
|
// eslint-disable-next-line
|
|
150
150
|
const file = path.join(options.output, targetSubfolder, a.file);
|
|
151
151
|
const deduped = (0, merge_helpers_1.dedupeTempFolder)(file);
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
fsx.ensureFileSync(deduped);
|
|
153
|
+
fsx.writeFileSync(deduped, (0, print_1.default)(a.ast));
|
|
154
154
|
importedGraphQLFiles.push(path.relative(options.output, deduped));
|
|
155
155
|
});
|
|
156
156
|
}
|
|
@@ -158,8 +158,8 @@ exports.default = async (original, imported, options = {
|
|
|
158
158
|
glob.sync('**/*.graphql', { cwd: imported.source }).forEach(relativePath => {
|
|
159
159
|
const importedFullPath = path.join(imported.source, relativePath);
|
|
160
160
|
const targetFullPath = path.join(options.output, targetSubfolder, relativePath);
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
fsx.ensureDirSync(path.dirname(targetFullPath));
|
|
162
|
+
fsx.copyFileSync(importedFullPath, targetFullPath);
|
|
163
163
|
importedGraphQLFiles.push(path.relative(options.output, targetFullPath));
|
|
164
164
|
});
|
|
165
165
|
}
|
|
@@ -169,7 +169,7 @@ exports.default = async (original, imported, options = {
|
|
|
169
169
|
const config = await (0, merge_helpers_1.getConfiguration)([options.output, imported.source], options.silent, options.answers);
|
|
170
170
|
if (config) {
|
|
171
171
|
const configFile = path.join(options.output, 'config.yaml');
|
|
172
|
-
|
|
172
|
+
fsx.writeFileSync(configFile, config);
|
|
173
173
|
}
|
|
174
174
|
// Return a merged schema!
|
|
175
175
|
return options.output;
|
package/lib/actions/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":";;AAAA,gCAA+B;AAC/B,6BAA4B;AAC5B,gDAAkD;AAClD,qCAAoC;AACpC,yBAAwB;AACxB,6BAA4B;AAE5B,0DAY+B;AAC/B,mCAA2B;AAC3B,gEAAqD;AACrD,kGAAsF;AACtF,4EAAkE;AAClE,kDAAoD;AAEpD,6EAA6E;AAC7E,wEAAwE;AACxE,6EAA6E;AAC7E,uEAAuE;AACvE,oBAAoB;AACpB,MAAM,oBAAoB,GAAG;uBACN,6BAAiB;;;CAGvC,CAAC,IAAI,EAAE,CAAA;AAER,MAAM,gBAAgB,GAAG;;;;CAIxB,CAAC,IAAI,EAAE,CAAA;AAER,kBAAe,KAAK,EAClB,QAAgB,EAChB,QAGC,EACD,UASI;IACF,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,EAAE;CACf,EACD,EAAE;IACF,yCAAyC;IACzC,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;IAC1C,I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AG,IAAI,CAAC,IAAI,CAC9B,OAAO,CAAC,MAAO,EACf,eAAe,EACf,YAAY,CACb,CAAA;YACD,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAA;YAC/C,GAAG,CAAC,YAAY,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;YAClD,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAO,EAAE,cAAc,CAAC,CAAC,CAAA;QAC3E,CAAC,CAAC,CAAA;KACH;IAED,6CAA6C;IAC7C,IAAA,0BAAa,EAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IAEnD,yBAAyB;IACzB,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAgB,EACnC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACjC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,CAChB,CAAA;IACD,IAAI,MAAM,EAAE;QACV,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;QAC3D,GAAG,CAAC,aAAa,CAAC,UAAU,EAAE,MAAgB,CAAC,CAAA;KAChD;IAED,0BAA0B;IAC1B,OAAO,OAAO,CAAC,MAAM,CAAA;AACvB,CAAC,CAAA"}
|
package/lib/actions/stitch.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const lodash_1 = require("lodash");
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
-
const
|
|
5
|
+
const fsx = require("fs-extra");
|
|
6
6
|
const glob = require("glob");
|
|
7
7
|
const os = require("os");
|
|
8
8
|
const path = require("path");
|
|
@@ -12,16 +12,16 @@ const constants_1 = require("../utils/constants");
|
|
|
12
12
|
const copy_workspace_content_1 = require("../utils/copy-workspace-content");
|
|
13
13
|
exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)) => {
|
|
14
14
|
// Ensure source and output directories exist
|
|
15
|
-
if (!
|
|
15
|
+
if (!fsx.existsSync(source))
|
|
16
16
|
throw new Error(`Cannot find source directory ${source}`);
|
|
17
|
-
|
|
17
|
+
fsx.ensureDirSync(output);
|
|
18
18
|
// Get a list of files.
|
|
19
19
|
let ast;
|
|
20
20
|
let files = [];
|
|
21
21
|
// If there's an index.graphQL - get files argument in @sdl directive
|
|
22
22
|
const sourceIndex = path.join(source, 'index.graphql');
|
|
23
|
-
if (
|
|
24
|
-
const index =
|
|
23
|
+
if (fsx.existsSync(sourceIndex)) {
|
|
24
|
+
const index = fsx.readFileSync(sourceIndex, 'utf8');
|
|
25
25
|
ast = (0, graphql_1.parse)(index);
|
|
26
26
|
ast = (0, graphql_1.visit)(ast, {
|
|
27
27
|
Directive(node) {
|
|
@@ -50,7 +50,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
50
50
|
const content = glob
|
|
51
51
|
.sync('**/*.graphql', { cwd: source })
|
|
52
52
|
.map((file) => {
|
|
53
|
-
const graphql =
|
|
53
|
+
const graphql = fsx.readFileSync(`${source}/${file}`, 'utf8');
|
|
54
54
|
return graphql;
|
|
55
55
|
});
|
|
56
56
|
ast = (0, graphql_1.parse)(content.join(os.EOL));
|
|
@@ -65,7 +65,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
65
65
|
// Check all the files exist
|
|
66
66
|
for (const file of files) {
|
|
67
67
|
const find = path.join(source, file);
|
|
68
|
-
if (!
|
|
68
|
+
if (!fsx.existsSync(find)) {
|
|
69
69
|
throw new Error(`Cannot find file ${file} referenced in the @sdl directive in index.graphql`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -74,7 +74,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
74
74
|
let stitched = `${printed}${os.EOL}`;
|
|
75
75
|
for (const file of files) {
|
|
76
76
|
const find = path.join(source, file);
|
|
77
|
-
const content =
|
|
77
|
+
const content = fsx.readFileSync(find, 'utf8');
|
|
78
78
|
stitched += `${content}${os.EOL}`;
|
|
79
79
|
}
|
|
80
80
|
// Dedupe Query and Mutation types
|
|
@@ -83,12 +83,12 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
83
83
|
stitched = prettier.format(stitched, { parser: 'graphql' });
|
|
84
84
|
// Write to output folder
|
|
85
85
|
const outputIndex = path.join(output, 'index.graphql');
|
|
86
|
-
|
|
86
|
+
fsx.writeFileSync(outputIndex, stitched);
|
|
87
87
|
// Copy config if exists, too
|
|
88
88
|
const sourceConfig = path.join(source, 'config.yaml');
|
|
89
89
|
const outputConfig = path.join(output, 'config.yaml');
|
|
90
|
-
if (
|
|
91
|
-
|
|
90
|
+
if (fsx.existsSync(sourceConfig)) {
|
|
91
|
+
fsx.copyFileSync(sourceConfig, outputConfig);
|
|
92
92
|
}
|
|
93
93
|
// Return output folder
|
|
94
94
|
return output;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":";;AAAA,mCAAuC;AACvC,qCAA2C;AAC3C
|
|
1
|
+
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":";;AAAA,mCAAuC;AACvC,qCAA2C;AAC3C,gCAA+B;AAC/B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,qCAAoC;AAEpC,8FAAkF;AAClF,kDAAoD;AACpD,4EAAkE;AAElE,kBAAe,CACb,MAAc,EACd,SAAiB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,EACpE,EAAE;IACF,6CAA6C;IAC7C,IAA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O,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;IACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACpC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC9C,QAAQ,IAAI,GAAG,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,CAAA;KAClC;IAED,kCAAkC;IAClC,QAAQ,GAAG,IAAA,yCAA2B,EAAC,QAAQ,CAAC,CAAA;IAEhD,SAAS;IACT,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAA;IAEzD,yBAAyB;IACzB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IACtD,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAExC,6BAA6B;IAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAErD,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAChC,GAAG,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;KAC7C;IAED,uBAAuB;IACvB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/lib/actions/validate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const graphql_1 = require("graphql");
|
|
4
|
-
const
|
|
4
|
+
const fsx = require("fs-extra");
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const ensure_query_and_mutation_types_1 = require("../utils/ensure-query-and-mutation-types");
|
|
@@ -11,16 +11,16 @@ exports.default = (source, options = {
|
|
|
11
11
|
extensions: '',
|
|
12
12
|
}) => {
|
|
13
13
|
// Ensure source and output directories exist
|
|
14
|
-
if (!
|
|
14
|
+
if (!fsx.existsSync(source)) {
|
|
15
15
|
throw new Error(`Cannot find source directory ${source}`);
|
|
16
16
|
}
|
|
17
17
|
// Ensure index.graphql exists
|
|
18
|
-
if (!
|
|
18
|
+
if (!fsx.existsSync(`${source}/index.graphql`)) {
|
|
19
19
|
throw new Error(`Cannot find index.graphql in ${source}`);
|
|
20
20
|
}
|
|
21
21
|
// Get the index.graphql file
|
|
22
22
|
const file = path.join(source, 'index.graphql');
|
|
23
|
-
const index =
|
|
23
|
+
const index = fsx.readFileSync(file, 'utf8');
|
|
24
24
|
// Parse
|
|
25
25
|
let ast = (0, graphql_1.parse)(`${constants_1.EXPERIMENTAL_EXTENSIONS}${os.EOL}${options.extensions}${os.EOL}${index}`, {
|
|
26
26
|
noLocation: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/actions/validate.ts"],"names":[],"mappings":";;AAAA,qCAAkE;AAClE
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/actions/validate.ts"],"names":[],"mappings":";;AAAA,qCAAkE;AAClE,gCAA+B;AAC/B,yBAAwB;AACxB,6BAA4B;AAE5B,8FAAkF;AAClF,kDAA0D;AAC1D,8CAAsC;AAEtC,kBAAe,CACb,MAAc,EACd,UAEI;IACF,UAAU,EAAE,EAAE;CACf,EACD,EAAE;IACF,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;KAC1D;IAED,8BAA8B;IAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,gBAAgB,CAAC,EAAE;QAC9C,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;KAC1D;IAED,6BAA6B;IAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAE5C,QAAQ;IACR,IAAI,GAAG,GAAiB,IAAA,eAAK,EAC3B,GAAG,mCAAuB,GAAG,EAAE,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,EAC3E;QACE,UAAU,EAAE,IAAI;KACjB,CACF,CAAA;IAED,iEAAiE;IACjE,GAAG,GAAG,IAAA,yCAA2B,EAAC,GAAG,CAAC,CAAA;IAEtC,+BAA+B;IAC/B,IAAA,wBAAc,EAAC,GAAG,CAAC,CAAA;IACnB,IAAA,eAAK,EAAC,GAAG,CAAC,CAAA;IAEV,oBAAoB;IACpB,KAAK,MAAM,SAAS,IAAI,oBAAU,EAAE;QAClC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;KACvB;IAED,cAAc;IACd,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllGraphQLFiles = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fsx = require("fs-extra");
|
|
5
5
|
const glob = require("glob");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
@@ -24,7 +24,7 @@ const IGNORED_PATTERNS = ['node_modules/**'];
|
|
|
24
24
|
* Exclude special folders, e.g. node_modules
|
|
25
25
|
*/
|
|
26
26
|
exports.default = (srcPath, dstPath) => {
|
|
27
|
-
if (!
|
|
27
|
+
if (!fsx.existsSync(srcPath)) {
|
|
28
28
|
throw new Error(`Cannot find source directory ${srcPath}`);
|
|
29
29
|
}
|
|
30
30
|
(0, lodash_1.flatMap)(WORKSPACE_FILE_PATTERNS, pattern => glob.sync(pattern, {
|
|
@@ -33,8 +33,8 @@ exports.default = (srcPath, dstPath) => {
|
|
|
33
33
|
})).forEach(relativePath => {
|
|
34
34
|
const srcFileFullPath = path.join(srcPath, relativePath);
|
|
35
35
|
const dstFileFullPath = path.join(dstPath, relativePath);
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
fsx.ensureDirSync(path.dirname(dstFileFullPath));
|
|
37
|
+
fsx.copyFileSync(srcFileFullPath, dstFileFullPath);
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
const getAllGraphQLFiles = (srcPath) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"copy-workspace-content.js","sourceRoot":"","sources":["../../src/utils/copy-workspace-content.ts"],"names":[],"mappings":";;;AAAA,gCAA+B;AAC/B,6BAA4B;AAC5B,6BAA4B;AAC5B,mCAA8B;AAC9B,2CAA6C;AAE7C,MAAM,uBAAuB,GAAG;IAC9B,cAAc;IACd,qBAAqB;IACrB,aAAa;CACd,CAAA;AAED,MAAM,gBAAgB,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,kBAAe,CAAC,OAAe,EAAE,OAAe,EAAE,EAAE;IAClD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAA;KAC3D;IAED,IAAA,gBAAO,EAAC,uBAAuB,EAAE,OAAO,CAAC,EAAE,CACzC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjB,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,gBAAgB;KACzB,CAAC,CACH,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QACvB,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QACxD,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAA;QAChD,GAAG,CAAC,YAAY,CAAC,eAAe,EAAE,eAAe,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAEM,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,EAAE;IACpD,OAAO,IAAI;SACR,IAAI,CAAC,6BAAiB,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC;SACvC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;AAC7C,CAAC,CAAA;AAJY,QAAA,kBAAkB,sBAI9B"}
|
|
@@ -5,7 +5,7 @@ const debug = require("debug");
|
|
|
5
5
|
const graphql_1 = require("graphql");
|
|
6
6
|
const utilities_1 = require("graphql/utilities");
|
|
7
7
|
const fetch_1 = require("@stepzen/fetch");
|
|
8
|
-
const
|
|
8
|
+
const fsx = require("fs-extra");
|
|
9
9
|
const glob = require("glob");
|
|
10
10
|
const os = require("os");
|
|
11
11
|
const path = require("path");
|
|
@@ -25,7 +25,7 @@ exports.dedupeTempFolder = dedupeTempFolder;
|
|
|
25
25
|
const findNextAvailableSubfolder = (folder, name) => {
|
|
26
26
|
let subfolder = name;
|
|
27
27
|
let counter = 1;
|
|
28
|
-
while (
|
|
28
|
+
while (fsx.existsSync(path.join(folder, subfolder))) {
|
|
29
29
|
const suffix = `${counter++}`.padStart(2, '0');
|
|
30
30
|
subfolder = `${name}-${suffix}`;
|
|
31
31
|
}
|
|
@@ -68,7 +68,7 @@ const findTypeInSchema = (name, files) => {
|
|
|
68
68
|
exports.findTypeInSchema = findTypeInSchema;
|
|
69
69
|
const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
70
70
|
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`);
|
|
71
|
-
|
|
71
|
+
fsx.ensureDirSync(tmp);
|
|
72
72
|
for (const directory of directories) {
|
|
73
73
|
const configs = [
|
|
74
74
|
...glob.sync('**/config.yaml', { cwd: directory }),
|
|
@@ -78,13 +78,13 @@ const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
|
78
78
|
const configFolder = path.join(directory, config);
|
|
79
79
|
let writeFolder = path.join(tmp, directory, config);
|
|
80
80
|
writeFolder = (0, exports.dedupeTempFolder)(writeFolder);
|
|
81
|
-
const content =
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const content = fsx.readFileSync(configFolder, 'utf8');
|
|
82
|
+
fsx.ensureFileSync(writeFolder);
|
|
83
|
+
fsx.writeFileSync(writeFolder, content);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
const configuration = await (0, configure_1.default)(tmp, silent, answers);
|
|
87
|
-
|
|
87
|
+
fsx.removeSync(tmp);
|
|
88
88
|
return configuration;
|
|
89
89
|
};
|
|
90
90
|
exports.getConfiguration = getConfiguration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-helpers.js","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,qCAAmD;AACnD,iDAA6C;AAC7C,0CAAkC;AAClC
|
|
1
|
+
{"version":3,"file":"merge-helpers.js","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,qCAAmD;AACnD,iDAA6C;AAC7C,0CAAkC;AAClC,gCAA+B;AAC/B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,mCAA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,OAAO;YACL,GAAG,IAAI;YACP,GAAG,EAAE,IAAA,eAAK,EAAC,IAAI,CAAC,GAAG,EAAE;gBACnB,oBAAoB,CAAC,IAAI;oBACvB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE;wBAC5B,OAAO,IAAI,CAAA;qBACZ;gBACH,CAAC;aACF,CAAC;SACH,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAdY,QAAA,oBAAoB,wBAchC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DirectiveNode, SchemaDefinitionNode } from 'graphql';
|
|
1
|
+
import { ConstDirectiveNode, DirectiveNode, SchemaDefinitionNode } from 'graphql';
|
|
2
2
|
import { DeepWriteable } from './graphql-helpers';
|
|
3
|
-
export declare const createOrUpdateSdlDirective: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[], origSdlDirective?: DeepWriteable<DirectiveNode>) => DeepWriteable<
|
|
3
|
+
export declare const createOrUpdateSdlDirective: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[], origSdlDirective?: DeepWriteable<DirectiveNode>) => DeepWriteable<ConstDirectiveNode>;
|
|
4
4
|
export declare const createSchemaElement: (importedGraphQLFiles: readonly string[], allGraphQLFiles: readonly string[]) => DeepWriteable<SchemaDefinitionNode>;
|
|
5
5
|
declare const _default: (source: string, importedGraphQLFiles: readonly string[]) => void;
|
|
6
6
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-files-in-sdl.d.ts","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.d.ts","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,aAAa,EAIb,oBAAoB,EAIrB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAY,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAQ1D,eAAO,MAAM,0BAA0B,yBACf,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,qBACf,cAAc,aAAa,CAAC,sCA2DhD,CAAA;AAED,eAAO,MAAM,mBAAmB,yBACR,SAAS,MAAM,EAAE,mBACtB,SAAS,MAAM,EAAE,wCAuBnC,CAAA;iCAEuB,MAAM,wBAAwB,SAAS,MAAM,EAAE;AAAvE,wBA4CC"}
|
|
@@ -16,23 +16,23 @@ const createOrUpdateSdlDirective = (importedGraphQLFiles, allGraphQLFiles, origS
|
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
sdlDirective = {
|
|
19
|
-
kind:
|
|
19
|
+
kind: graphql_1.Kind.DIRECTIVE,
|
|
20
20
|
name: {
|
|
21
|
-
kind:
|
|
21
|
+
kind: graphql_1.Kind.NAME,
|
|
22
22
|
value: 'sdl',
|
|
23
23
|
},
|
|
24
24
|
arguments: [
|
|
25
25
|
{
|
|
26
|
-
kind:
|
|
26
|
+
kind: graphql_1.Kind.ARGUMENT,
|
|
27
27
|
name: {
|
|
28
|
-
kind:
|
|
28
|
+
kind: graphql_1.Kind.NAME,
|
|
29
29
|
value: 'files',
|
|
30
30
|
},
|
|
31
31
|
value: {
|
|
32
|
-
kind:
|
|
32
|
+
kind: graphql_1.Kind.LIST,
|
|
33
33
|
values: [
|
|
34
34
|
{
|
|
35
|
-
kind:
|
|
35
|
+
kind: graphql_1.Kind.STRING,
|
|
36
36
|
value: constants_1.ALL_GRAPHQL_FILES,
|
|
37
37
|
},
|
|
38
38
|
],
|
|
@@ -55,7 +55,7 @@ const createOrUpdateSdlDirective = (importedGraphQLFiles, allGraphQLFiles, origS
|
|
|
55
55
|
allGraphQLFiles.forEach(file => fileset.add(normalizePathSep(file)));
|
|
56
56
|
}
|
|
57
57
|
filesValueNodes.values = [...fileset].map(file => ({
|
|
58
|
-
kind:
|
|
58
|
+
kind: graphql_1.Kind.STRING,
|
|
59
59
|
value: file,
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
@@ -66,18 +66,18 @@ const createOrUpdateSdlDirective = (importedGraphQLFiles, allGraphQLFiles, origS
|
|
|
66
66
|
exports.createOrUpdateSdlDirective = createOrUpdateSdlDirective;
|
|
67
67
|
const createSchemaElement = (importedGraphQLFiles, allGraphQLFiles) => {
|
|
68
68
|
const schemaElement = {
|
|
69
|
-
kind:
|
|
69
|
+
kind: graphql_1.Kind.SCHEMA_DEFINITION,
|
|
70
70
|
directives: [
|
|
71
71
|
(0, exports.createOrUpdateSdlDirective)(importedGraphQLFiles, allGraphQLFiles),
|
|
72
72
|
],
|
|
73
73
|
operationTypes: [
|
|
74
74
|
{
|
|
75
|
-
kind:
|
|
76
|
-
operation:
|
|
75
|
+
kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
|
|
76
|
+
operation: graphql_1.OperationTypeNode.QUERY,
|
|
77
77
|
type: {
|
|
78
|
-
kind:
|
|
78
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
79
79
|
name: {
|
|
80
|
-
kind:
|
|
80
|
+
kind: graphql_1.Kind.NAME,
|
|
81
81
|
value: 'Query',
|
|
82
82
|
},
|
|
83
83
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-files-in-sdl.js","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"set-files-in-sdl.js","sourceRoot":"","sources":["../../src/utils/set-files-in-sdl.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,qCAUgB;AAChB,6BAA4B;AAE5B,uDAA0D;AAC1D,4CAAoC;AACpC,2CAA6C;AAC7C,qEAA2D;AAE3D,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC5C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE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SACF,CAAC,CAAA;KACH;IAED,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAA,eAAK,EAAC,GAAG,CAAC,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stepzen/transpiler",
|
|
3
3
|
"description": "The StepZen transpiler",
|
|
4
|
-
"version": "0.28.0-
|
|
4
|
+
"version": "0.28.0-experimental.fa8aa47",
|
|
5
5
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -22,29 +22,30 @@
|
|
|
22
22
|
"posttest": "prettier . --check"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@graphql-tools/merge": "^
|
|
26
|
-
"@stepzen/fetch": "0.28.0-
|
|
25
|
+
"@graphql-tools/merge": "^8.3.15",
|
|
26
|
+
"@stepzen/fetch": "0.28.0-experimental.fa8aa47",
|
|
27
27
|
"debug": "^4.3.4",
|
|
28
|
-
"dotenv": "^
|
|
28
|
+
"dotenv": "^16.0.3",
|
|
29
29
|
"fs-extra": "^9.1.0",
|
|
30
30
|
"glob": "^7.2.3",
|
|
31
|
-
"graphql": "^
|
|
32
|
-
"inquirer": "^8.2.
|
|
31
|
+
"graphql": "^16.6.0",
|
|
32
|
+
"inquirer": "^8.2.5",
|
|
33
33
|
"lodash": "^4.17.21",
|
|
34
|
-
"prettier": "^2.
|
|
34
|
+
"prettier": "^2.8.3",
|
|
35
35
|
"shelljs": "^0.8.5",
|
|
36
36
|
"yaml": "^1.10.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/debug": "^4.1.7",
|
|
40
|
-
"@types/fs-extra": "^9.0.
|
|
40
|
+
"@types/fs-extra": "^9.0.13",
|
|
41
41
|
"@types/glob": "^7.2.0",
|
|
42
|
-
"@types/inquirer": "^
|
|
42
|
+
"@types/inquirer": "^8.2.5",
|
|
43
43
|
"@types/lodash": "^4.14.168",
|
|
44
44
|
"@types/mocha": "^8.2.2",
|
|
45
45
|
"@types/mock-fs": "^4.13.0",
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
46
|
+
"@types/node-fetch": "^2.6.2",
|
|
47
|
+
"@types/prettier": "^2.7.2",
|
|
48
|
+
"@types/shelljs": "^0.8.11",
|
|
48
49
|
"chai": "^4.3.4",
|
|
49
50
|
"fancy-test": "^1.4.10",
|
|
50
51
|
"mocha": "^9.0.1",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"nyc": "^14.1.1",
|
|
54
55
|
"ts-node": "^10.8.2"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "fa8aa47d7356a29e7673f62fe432a86e0d3c36b3"
|
|
57
58
|
}
|
package/src/actions/configure.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as debug from 'debug'
|
|
2
|
-
import * as
|
|
2
|
+
import * as fsx from 'fs-extra'
|
|
3
3
|
import * as glob from 'glob'
|
|
4
4
|
import * as inquirer from 'inquirer'
|
|
5
5
|
import * as path from 'path'
|
|
@@ -29,7 +29,7 @@ export default async (source: string, silent = false, answers: any = {}) => {
|
|
|
29
29
|
for (const y of glob.sync('**/config.yaml', {cwd: source})) {
|
|
30
30
|
const filePath = path.join(source, y)
|
|
31
31
|
|
|
32
|
-
const file =
|
|
32
|
+
const file = fsx.readFileSync(filePath, 'utf8')
|
|
33
33
|
let asYAML
|
|
34
34
|
try {
|
|
35
35
|
asYAML = yaml.parse(file, {schema: 'failsafe'})
|
|
@@ -79,7 +79,7 @@ export default async (source: string, silent = false, answers: any = {}) => {
|
|
|
79
79
|
})) {
|
|
80
80
|
const filePath = path.join(source, j)
|
|
81
81
|
|
|
82
|
-
const file =
|
|
82
|
+
const file = fsx.readFileSync(filePath, 'utf8')
|
|
83
83
|
const asJSON = JSON.parse(file)
|
|
84
84
|
|
|
85
85
|
configJsonCount += 1
|
package/src/actions/lint.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as fsx from 'fs-extra'
|
|
2
2
|
import * as os from 'os'
|
|
3
3
|
import * as path from 'path'
|
|
4
4
|
import * as shell from 'shelljs'
|
|
@@ -14,7 +14,7 @@ export default async (
|
|
|
14
14
|
extensions: '',
|
|
15
15
|
},
|
|
16
16
|
) => {
|
|
17
|
-
if (!
|
|
17
|
+
if (!fsx.existsSync(source)) {
|
|
18
18
|
throw new Error(`Cannot find source directory ${source}`)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -26,19 +26,19 @@ export default async (
|
|
|
26
26
|
|
|
27
27
|
const stitched = stitch(source)
|
|
28
28
|
const index = path.join(stitched, 'index.graphql')
|
|
29
|
-
const graphql =
|
|
29
|
+
const graphql = fsx.readFileSync(index, 'utf8')
|
|
30
30
|
|
|
31
31
|
const tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`)
|
|
32
|
-
|
|
32
|
+
fsx.ensureDirSync(tmp)
|
|
33
33
|
const lintFile = path.join(tmp, 'index.graphql')
|
|
34
|
-
|
|
34
|
+
fsx.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`)
|
|
35
35
|
|
|
36
36
|
shell.exec(
|
|
37
37
|
`npx graphql-schema-linter ${lintFile}`,
|
|
38
38
|
{silent: true},
|
|
39
39
|
(code, stdout, stderr) => {
|
|
40
40
|
console.log(stdout)
|
|
41
|
-
|
|
41
|
+
fsx.removeSync(tmp)
|
|
42
42
|
},
|
|
43
43
|
)
|
|
44
44
|
}
|
package/src/actions/merge.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as fsx from 'fs-extra'
|
|
2
2
|
import * as glob from 'glob'
|
|
3
3
|
import {mergeTypeDefs} from '@graphql-tools/merge'
|
|
4
4
|
import {parse, visit} from 'graphql'
|
|
@@ -79,19 +79,19 @@ export default async (
|
|
|
79
79
|
options.output = dedupeTempFolder(options.output)
|
|
80
80
|
|
|
81
81
|
// Ensure original, importing and output directories exist
|
|
82
|
-
if (!
|
|
82
|
+
if (!fsx.existsSync(original))
|
|
83
83
|
throw new Error(`Cannot find original directory ${original}`)
|
|
84
|
-
if (!
|
|
84
|
+
if (!fsx.existsSync(imported.source))
|
|
85
85
|
throw new Error(`Cannot find imported source directory ${imported.source}`)
|
|
86
|
-
|
|
86
|
+
fsx.ensureDirSync(options.output)
|
|
87
87
|
|
|
88
88
|
// Copy the original into the output.
|
|
89
89
|
copyWorkspaceContent(original, options.output)
|
|
90
90
|
|
|
91
91
|
// Ensure an index.graphql exists
|
|
92
92
|
const outputIndex = path.join(options.output, 'index.graphql')
|
|
93
|
-
if (!
|
|
94
|
-
|
|
93
|
+
if (!fsx.existsSync(outputIndex)) {
|
|
94
|
+
fsx.writeFileSync(
|
|
95
95
|
outputIndex,
|
|
96
96
|
options.mergeTypes
|
|
97
97
|
? // (2022-03-09, vluakshov) Not sure what'd break without the
|
|
@@ -132,11 +132,11 @@ export default async (
|
|
|
132
132
|
|
|
133
133
|
const details = {
|
|
134
134
|
original: glob.sync('**/*.graphql', {cwd: options.output}).map(file => {
|
|
135
|
-
const content =
|
|
135
|
+
const content = fsx.readFileSync(`${options.output}/${file}`, 'utf8')
|
|
136
136
|
return {ast: parse(content), file}
|
|
137
137
|
}),
|
|
138
138
|
imported: glob.sync('**/*.graphql', {cwd: imported.source}).map(file => {
|
|
139
|
-
const content =
|
|
139
|
+
const content = fsx.readFileSync(`${imported.source}/${file}`, 'utf8')
|
|
140
140
|
return {ast: parse(content), file}
|
|
141
141
|
}),
|
|
142
142
|
}
|
|
@@ -197,8 +197,8 @@ export default async (
|
|
|
197
197
|
const file = path.join(options.output as any, a.file)
|
|
198
198
|
const deduped = dedupeTempFolder(file)
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
fsx.ensureFileSync(deduped)
|
|
201
|
+
fsx.writeFileSync(deduped, print(a.ast))
|
|
202
202
|
})
|
|
203
203
|
|
|
204
204
|
cleaned.imported.forEach(a => {
|
|
@@ -206,8 +206,8 @@ export default async (
|
|
|
206
206
|
const file = path.join(options.output as any, targetSubfolder, a.file)
|
|
207
207
|
const deduped = dedupeTempFolder(file)
|
|
208
208
|
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
fsx.ensureFileSync(deduped)
|
|
210
|
+
fsx.writeFileSync(deduped, print(a.ast))
|
|
211
211
|
importedGraphQLFiles.push(path.relative(options.output!, deduped))
|
|
212
212
|
})
|
|
213
213
|
} else {
|
|
@@ -218,8 +218,8 @@ export default async (
|
|
|
218
218
|
targetSubfolder,
|
|
219
219
|
relativePath,
|
|
220
220
|
)
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
fsx.ensureDirSync(path.dirname(targetFullPath))
|
|
222
|
+
fsx.copyFileSync(importedFullPath, targetFullPath)
|
|
223
223
|
importedGraphQLFiles.push(path.relative(options.output!, targetFullPath))
|
|
224
224
|
})
|
|
225
225
|
}
|
|
@@ -235,7 +235,7 @@ export default async (
|
|
|
235
235
|
)
|
|
236
236
|
if (config) {
|
|
237
237
|
const configFile = path.join(options.output, 'config.yaml')
|
|
238
|
-
|
|
238
|
+
fsx.writeFileSync(configFile, config as string)
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// Return a merged schema!
|
package/src/actions/stitch.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {clone, cloneDeep} from 'lodash'
|
|
2
2
|
import {parse, print, visit} from 'graphql'
|
|
3
|
-
import * as
|
|
3
|
+
import * as fsx from 'fs-extra'
|
|
4
4
|
import * as glob from 'glob'
|
|
5
5
|
import * as os from 'os'
|
|
6
6
|
import * as path from 'path'
|
|
@@ -15,9 +15,9 @@ export default (
|
|
|
15
15
|
output: string = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`),
|
|
16
16
|
) => {
|
|
17
17
|
// Ensure source and output directories exist
|
|
18
|
-
if (!
|
|
18
|
+
if (!fsx.existsSync(source))
|
|
19
19
|
throw new Error(`Cannot find source directory ${source}`)
|
|
20
|
-
|
|
20
|
+
fsx.ensureDirSync(output)
|
|
21
21
|
|
|
22
22
|
// Get a list of files.
|
|
23
23
|
let ast: any
|
|
@@ -26,8 +26,8 @@ export default (
|
|
|
26
26
|
// If there's an index.graphQL - get files argument in @sdl directive
|
|
27
27
|
const sourceIndex = path.join(source, 'index.graphql')
|
|
28
28
|
|
|
29
|
-
if (
|
|
30
|
-
const index =
|
|
29
|
+
if (fsx.existsSync(sourceIndex)) {
|
|
30
|
+
const index = fsx.readFileSync(sourceIndex, 'utf8')
|
|
31
31
|
ast = parse(index)
|
|
32
32
|
ast = visit(ast, {
|
|
33
33
|
Directive(node) {
|
|
@@ -58,7 +58,7 @@ export default (
|
|
|
58
58
|
const content = glob
|
|
59
59
|
.sync('**/*.graphql', {cwd: source})
|
|
60
60
|
.map((file: string) => {
|
|
61
|
-
const graphql =
|
|
61
|
+
const graphql = fsx.readFileSync(`${source}/${file}`, 'utf8')
|
|
62
62
|
return graphql
|
|
63
63
|
})
|
|
64
64
|
ast = parse(content.join(os.EOL))
|
|
@@ -74,7 +74,7 @@ export default (
|
|
|
74
74
|
// Check all the files exist
|
|
75
75
|
for (const file of files) {
|
|
76
76
|
const find = path.join(source, file)
|
|
77
|
-
if (!
|
|
77
|
+
if (!fsx.existsSync(find)) {
|
|
78
78
|
throw new Error(
|
|
79
79
|
`Cannot find file ${file} referenced in the @sdl directive in index.graphql`,
|
|
80
80
|
)
|
|
@@ -86,7 +86,7 @@ export default (
|
|
|
86
86
|
let stitched = `${printed}${os.EOL}`
|
|
87
87
|
for (const file of files) {
|
|
88
88
|
const find = path.join(source, file)
|
|
89
|
-
const content =
|
|
89
|
+
const content = fsx.readFileSync(find, 'utf8')
|
|
90
90
|
stitched += `${content}${os.EOL}`
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -98,14 +98,14 @@ export default (
|
|
|
98
98
|
|
|
99
99
|
// Write to output folder
|
|
100
100
|
const outputIndex = path.join(output, 'index.graphql')
|
|
101
|
-
|
|
101
|
+
fsx.writeFileSync(outputIndex, stitched)
|
|
102
102
|
|
|
103
103
|
// Copy config if exists, too
|
|
104
104
|
const sourceConfig = path.join(source, 'config.yaml')
|
|
105
105
|
const outputConfig = path.join(output, 'config.yaml')
|
|
106
106
|
|
|
107
|
-
if (
|
|
108
|
-
|
|
107
|
+
if (fsx.existsSync(sourceConfig)) {
|
|
108
|
+
fsx.copyFileSync(sourceConfig, outputConfig)
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// Return output folder
|
package/src/actions/validate.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {buildASTSchema, DocumentNode, parse, print} from 'graphql'
|
|
2
|
-
import * as
|
|
2
|
+
import * as fsx from 'fs-extra'
|
|
3
3
|
import * as os from 'os'
|
|
4
4
|
import * as path from 'path'
|
|
5
5
|
|
|
@@ -16,18 +16,18 @@ export default (
|
|
|
16
16
|
},
|
|
17
17
|
) => {
|
|
18
18
|
// Ensure source and output directories exist
|
|
19
|
-
if (!
|
|
19
|
+
if (!fsx.existsSync(source)) {
|
|
20
20
|
throw new Error(`Cannot find source directory ${source}`)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Ensure index.graphql exists
|
|
24
|
-
if (!
|
|
24
|
+
if (!fsx.existsSync(`${source}/index.graphql`)) {
|
|
25
25
|
throw new Error(`Cannot find index.graphql in ${source}`)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Get the index.graphql file
|
|
29
29
|
const file = path.join(source, 'index.graphql')
|
|
30
|
-
const index =
|
|
30
|
+
const index = fsx.readFileSync(file, 'utf8')
|
|
31
31
|
|
|
32
32
|
// Parse
|
|
33
33
|
let ast: DocumentNode = parse(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as fsx from 'fs-extra'
|
|
2
2
|
import * as glob from 'glob'
|
|
3
3
|
import * as path from 'path'
|
|
4
4
|
import {flatMap} from 'lodash'
|
|
@@ -24,7 +24,7 @@ const IGNORED_PATTERNS = ['node_modules/**']
|
|
|
24
24
|
* Exclude special folders, e.g. node_modules
|
|
25
25
|
*/
|
|
26
26
|
export default (srcPath: string, dstPath: string) => {
|
|
27
|
-
if (!
|
|
27
|
+
if (!fsx.existsSync(srcPath)) {
|
|
28
28
|
throw new Error(`Cannot find source directory ${srcPath}`)
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -36,8 +36,8 @@ export default (srcPath: string, dstPath: string) => {
|
|
|
36
36
|
).forEach(relativePath => {
|
|
37
37
|
const srcFileFullPath = path.join(srcPath, relativePath)
|
|
38
38
|
const dstFileFullPath = path.join(dstPath, relativePath)
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
fsx.ensureDirSync(path.dirname(dstFileFullPath))
|
|
40
|
+
fsx.copyFileSync(srcFileFullPath, dstFileFullPath)
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -2,7 +2,7 @@ import * as debug from 'debug'
|
|
|
2
2
|
import {BREAK, GraphQLSchema, visit} from 'graphql'
|
|
3
3
|
import {buildSchema} from 'graphql/utilities'
|
|
4
4
|
import fetch from '@stepzen/fetch'
|
|
5
|
-
import * as
|
|
5
|
+
import * as fsx from 'fs-extra'
|
|
6
6
|
import * as glob from 'glob'
|
|
7
7
|
import * as os from 'os'
|
|
8
8
|
import * as path from 'path'
|
|
@@ -27,7 +27,7 @@ export const dedupeTempFolder = (dirpath: string) => {
|
|
|
27
27
|
export const findNextAvailableSubfolder = (folder: string, name: string) => {
|
|
28
28
|
let subfolder = name
|
|
29
29
|
let counter = 1
|
|
30
|
-
while (
|
|
30
|
+
while (fsx.existsSync(path.join(folder, subfolder))) {
|
|
31
31
|
const suffix = `${counter++}`.padStart(2, '0')
|
|
32
32
|
subfolder = `${name}-${suffix}`
|
|
33
33
|
}
|
|
@@ -76,7 +76,7 @@ export const getConfiguration = async (
|
|
|
76
76
|
answers: any = {},
|
|
77
77
|
): Promise<string | boolean> => {
|
|
78
78
|
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`)
|
|
79
|
-
|
|
79
|
+
fsx.ensureDirSync(tmp)
|
|
80
80
|
|
|
81
81
|
for (const directory of directories) {
|
|
82
82
|
const configs = [
|
|
@@ -90,15 +90,15 @@ export const getConfiguration = async (
|
|
|
90
90
|
let writeFolder = path.join(tmp, directory, config)
|
|
91
91
|
writeFolder = dedupeTempFolder(writeFolder)
|
|
92
92
|
|
|
93
|
-
const content =
|
|
93
|
+
const content = fsx.readFileSync(configFolder, 'utf8')
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
fsx.ensureFileSync(writeFolder)
|
|
96
|
+
fsx.writeFileSync(writeFolder, content)
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
const configuration = await configure(tmp, silent, answers)
|
|
101
|
-
|
|
101
|
+
fsx.removeSync(tmp)
|
|
102
102
|
return configuration
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as fs from 'fs'
|
|
2
2
|
import * as glob from 'glob'
|
|
3
3
|
import {
|
|
4
|
+
ConstDirectiveNode,
|
|
4
5
|
DirectiveNode,
|
|
6
|
+
Kind,
|
|
5
7
|
ListValueNode,
|
|
6
8
|
parse,
|
|
7
9
|
SchemaDefinitionNode,
|
|
8
10
|
StringValueNode,
|
|
11
|
+
OperationTypeNode,
|
|
9
12
|
visit,
|
|
10
13
|
} from 'graphql'
|
|
11
14
|
import * as path from 'path'
|
|
@@ -23,28 +26,28 @@ export const createOrUpdateSdlDirective = (
|
|
|
23
26
|
allGraphQLFiles: readonly string[],
|
|
24
27
|
origSdlDirective?: DeepWriteable<DirectiveNode>,
|
|
25
28
|
) => {
|
|
26
|
-
let sdlDirective: DeepWriteable<
|
|
29
|
+
let sdlDirective: DeepWriteable<ConstDirectiveNode>
|
|
27
30
|
if (origSdlDirective) {
|
|
28
31
|
sdlDirective = cloneDeep(origSdlDirective)
|
|
29
32
|
} else {
|
|
30
33
|
sdlDirective = {
|
|
31
|
-
kind:
|
|
34
|
+
kind: Kind.DIRECTIVE,
|
|
32
35
|
name: {
|
|
33
|
-
kind:
|
|
36
|
+
kind: Kind.NAME,
|
|
34
37
|
value: 'sdl',
|
|
35
38
|
},
|
|
36
39
|
arguments: [
|
|
37
40
|
{
|
|
38
|
-
kind:
|
|
41
|
+
kind: Kind.ARGUMENT,
|
|
39
42
|
name: {
|
|
40
|
-
kind:
|
|
43
|
+
kind: Kind.NAME,
|
|
41
44
|
value: 'files',
|
|
42
45
|
},
|
|
43
46
|
value: {
|
|
44
|
-
kind:
|
|
47
|
+
kind: Kind.LIST,
|
|
45
48
|
values: [
|
|
46
49
|
{
|
|
47
|
-
kind:
|
|
50
|
+
kind: Kind.STRING,
|
|
48
51
|
value: ALL_GRAPHQL_FILES,
|
|
49
52
|
},
|
|
50
53
|
],
|
|
@@ -72,7 +75,7 @@ export const createOrUpdateSdlDirective = (
|
|
|
72
75
|
allGraphQLFiles.forEach(file => fileset.add(normalizePathSep(file)))
|
|
73
76
|
}
|
|
74
77
|
filesValueNodes.values = [...fileset].map(file => ({
|
|
75
|
-
kind:
|
|
78
|
+
kind: Kind.STRING,
|
|
76
79
|
value: file,
|
|
77
80
|
}))
|
|
78
81
|
}
|
|
@@ -87,18 +90,18 @@ export const createSchemaElement = (
|
|
|
87
90
|
allGraphQLFiles: readonly string[],
|
|
88
91
|
) => {
|
|
89
92
|
const schemaElement: DeepWriteable<SchemaDefinitionNode> = {
|
|
90
|
-
kind:
|
|
93
|
+
kind: Kind.SCHEMA_DEFINITION,
|
|
91
94
|
directives: [
|
|
92
95
|
createOrUpdateSdlDirective(importedGraphQLFiles, allGraphQLFiles),
|
|
93
96
|
],
|
|
94
97
|
operationTypes: [
|
|
95
98
|
{
|
|
96
|
-
kind:
|
|
97
|
-
operation:
|
|
99
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
100
|
+
operation: OperationTypeNode.QUERY,
|
|
98
101
|
type: {
|
|
99
|
-
kind:
|
|
102
|
+
kind: Kind.NAMED_TYPE,
|
|
100
103
|
name: {
|
|
101
|
-
kind:
|
|
104
|
+
kind: Kind.NAME,
|
|
102
105
|
value: 'Query',
|
|
103
106
|
},
|
|
104
107
|
},
|