@stepzen/transpiler 0.28.0-experimental.fa8aa47 → 0.29.0-beta.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/lib/actions/lint.d.ts.map +1 -1
- package/lib/actions/lint.js +18 -10
- package/lib/actions/lint.js.map +1 -1
- package/lib/actions/merge.d.ts +7 -6
- package/lib/actions/merge.d.ts.map +1 -1
- package/lib/actions/merge.js +29 -13
- package/lib/actions/merge.js.map +1 -1
- package/lib/actions/stitch.d.ts +2 -2
- package/lib/actions/stitch.d.ts.map +1 -1
- package/lib/actions/stitch.js +20 -2
- package/lib/actions/stitch.js.map +1 -1
- package/lib/actions/transpile.d.ts.map +1 -1
- package/lib/actions/transpile.js +9 -3
- package/lib/actions/transpile.js.map +1 -1
- package/lib/utils/merge-helpers.d.ts.map +1 -1
- package/lib/utils/merge-helpers.js +20 -15
- package/lib/utils/merge-helpers.js.map +1 -1
- package/lib/utils/rmtemp.d.ts +11 -0
- package/lib/utils/rmtemp.d.ts.map +1 -0
- package/lib/utils/rmtemp.js +43 -0
- package/lib/utils/rmtemp.js.map +1 -0
- package/package.json +4 -3
- package/src/actions/lint.ts +18 -15
- package/src/actions/merge.ts +57 -26
- package/src/actions/stitch.ts +22 -5
- package/src/actions/transpile.ts +9 -4
- package/src/utils/merge-helpers.ts +20 -16
- package/src/utils/rmtemp.ts +48 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/actions/lint.ts"],"names":[],"mappings":"iCAUU,MAAM,YACL;IACP,UAAU,EAAE,MAAM,CAAA;CACnB;AAJH,wBAqCC"}
|
package/lib/actions/lint.js
CHANGED
|
@@ -6,6 +6,7 @@ const path = require("path");
|
|
|
6
6
|
const shell = require("shelljs");
|
|
7
7
|
const stitch_1 = require("../actions/stitch");
|
|
8
8
|
const merge_helpers_1 = require("../utils/merge-helpers");
|
|
9
|
+
const rmtemp_1 = require("../utils/rmtemp");
|
|
9
10
|
exports.default = async (source, options = {
|
|
10
11
|
extensions: '',
|
|
11
12
|
}) => {
|
|
@@ -16,16 +17,23 @@ exports.default = async (source, options = {
|
|
|
16
17
|
if (!extensions) {
|
|
17
18
|
extensions = await (0, merge_helpers_1.getExtensions)();
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
let stitched, tmp;
|
|
21
|
+
try {
|
|
22
|
+
stitched = (0, stitch_1.default)(source);
|
|
23
|
+
const index = path.join(stitched, 'index.graphql');
|
|
24
|
+
const graphql = fsx.readFileSync(index, 'utf8');
|
|
25
|
+
tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`);
|
|
26
|
+
fsx.ensureDirSync(tmp, 0o700);
|
|
27
|
+
const lintFile = path.join(tmp, 'index.graphql');
|
|
28
|
+
fsx.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`);
|
|
29
|
+
const { stdout } = shell.exec(`npx graphql-schema-linter ${lintFile}`, {
|
|
30
|
+
silent: true,
|
|
31
|
+
});
|
|
27
32
|
console.log(stdout);
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
(0, rmtemp_1.rmtemp)(stitched);
|
|
36
|
+
(0, rmtemp_1.rmtemp)(tmp);
|
|
37
|
+
}
|
|
30
38
|
};
|
|
31
39
|
//# 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,gCAA+B;AAC/B,yBAAwB;AACxB,6BAA4B;AAC5B,iCAAgC;AAEhC,8CAA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AC,GAAG,KAAK,CAAC,IAAI,CAAC,6BAA6B,QAAQ,EAAE,EAAE;YACnE,MAAM,EAAE,IAAI;SACb,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;KACpB;YAAS;QACR,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAA;QAChB,IAAA,eAAM,EAAC,GAAG,CAAC,CAAA;KACZ;AACH,CAAC,CAAA"}
|
package/lib/actions/merge.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
declare
|
|
2
|
-
name: string;
|
|
3
|
-
source: string;
|
|
4
|
-
}, options?: {
|
|
1
|
+
export declare type MergeOptions = {
|
|
5
2
|
answers: any;
|
|
6
3
|
output: string | null;
|
|
7
4
|
silent: boolean;
|
|
@@ -10,6 +7,10 @@ declare const _default: (original: string, imported: {
|
|
|
10
7
|
/** merge behaviour when a schema with the given name exists in the source */
|
|
11
8
|
onConflict?: 'overwrite' | 'append';
|
|
12
9
|
extensions?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
10
|
+
};
|
|
11
|
+
declare const merge: (original: string, imported: {
|
|
12
|
+
name: string;
|
|
13
|
+
source: string;
|
|
14
|
+
}, options?: MergeOptions) => Promise<string>;
|
|
15
|
+
export default merge;
|
|
15
16
|
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":"AA4CA,oBAAY,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;AAwLD,QAAA,MAAM,KAAK,aACC,MAAM,YACN;IACR,MAAM,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,YACQ,YAAY,oBA4BtB,CAAA;AAED,eAAe,KAAK,CAAA"}
|
package/lib/actions/merge.js
CHANGED
|
@@ -12,6 +12,7 @@ const set_files_in_sdl_1 = require("../utils/set-files-in-sdl");
|
|
|
12
12
|
const strip_empty_queries_and_mutations_1 = require("../utils/strip-empty-queries-and-mutations");
|
|
13
13
|
const copy_workspace_content_1 = require("../utils/copy-workspace-content");
|
|
14
14
|
const constants_1 = require("../utils/constants");
|
|
15
|
+
const rmtemp_1 = require("../utils/rmtemp");
|
|
15
16
|
// It's safe to use this special placeholder value here: in case of a failure
|
|
16
17
|
// in the merge / import process it will not reach the workspace folder.
|
|
17
18
|
// All intermediary steps are carried out in a temp folder, and only when all
|
|
@@ -27,19 +28,9 @@ type Query {
|
|
|
27
28
|
__query: String
|
|
28
29
|
}
|
|
29
30
|
`.trim();
|
|
30
|
-
|
|
31
|
-
answers: {},
|
|
32
|
-
output: null,
|
|
33
|
-
silent: false,
|
|
34
|
-
mergeTypes: true,
|
|
35
|
-
onConflict: 'append',
|
|
36
|
-
extensions: '',
|
|
37
|
-
}) => {
|
|
38
|
-
// Make sure there is an output directory
|
|
31
|
+
const doMerge = async (original, imported, options) => {
|
|
39
32
|
if (!options.answers)
|
|
40
33
|
options.answers = {};
|
|
41
|
-
if (!options.output)
|
|
42
|
-
options.output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
43
34
|
if (!options.silent)
|
|
44
35
|
options.silent = false;
|
|
45
36
|
if (options.mergeTypes === undefined)
|
|
@@ -56,7 +47,7 @@ exports.default = async (original, imported, options = {
|
|
|
56
47
|
throw new Error(`Cannot find original directory ${original}`);
|
|
57
48
|
if (!fsx.existsSync(imported.source))
|
|
58
49
|
throw new Error(`Cannot find imported source directory ${imported.source}`);
|
|
59
|
-
fsx.ensureDirSync(options.output);
|
|
50
|
+
fsx.ensureDirSync(options.output, 0o700);
|
|
60
51
|
// Copy the original into the output.
|
|
61
52
|
(0, copy_workspace_content_1.default)(original, options.output);
|
|
62
53
|
// Ensure an index.graphql exists
|
|
@@ -169,9 +160,34 @@ exports.default = async (original, imported, options = {
|
|
|
169
160
|
const config = await (0, merge_helpers_1.getConfiguration)([options.output, imported.source], options.silent, options.answers);
|
|
170
161
|
if (config) {
|
|
171
162
|
const configFile = path.join(options.output, 'config.yaml');
|
|
172
|
-
fsx.writeFileSync(configFile, config);
|
|
163
|
+
fsx.writeFileSync(configFile, config, { mode: 0o600 });
|
|
173
164
|
}
|
|
174
165
|
// Return a merged schema!
|
|
175
166
|
return options.output;
|
|
176
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
|
+
(0, rmtemp_1.rmtemp)(output);
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
exports.default = merge;
|
|
177
193
|
//# sourceMappingURL=merge.js.map
|
package/lib/actions/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AACpD,4CAAsC;AAEtC,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;AAaR,MAAM,OAAO,GAAG,KAAK,EACnB,QAAgB,EAChB,QAGC,EACD,OAAwC,EACxC,EAAE;IACF,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;IAC1C,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAO,CAAC,MAAM,GAAG,KAAK,CAAA;IAC3C,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,CAAC,UAAU,GAAG,IAAI,CAAA;IAC/D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAA;IACnE,IAAI,CAAC,OAAO,CAAC,UAAU;QAAE,OAAO,CAAC,UAAU,GAAG,MAAM,IAAA,6BAAa,GAAE,CAAA;IAEn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|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const stitch: (source: string, output?: string) => string;
|
|
2
|
+
export default stitch;
|
|
3
3
|
//# sourceMappingURL=stitch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stitch.d.ts","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stitch.d.ts","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":"AAgHA,QAAA,MAAM,MAAM,WAAY,MAAM,WAAW,MAAM,WAe9C,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/lib/actions/stitch.js
CHANGED
|
@@ -10,11 +10,12 @@ const prettier = require("prettier");
|
|
|
10
10
|
const dedupe_query_and_mutation_types_1 = require("../utils/dedupe-query-and-mutation-types");
|
|
11
11
|
const constants_1 = require("../utils/constants");
|
|
12
12
|
const copy_workspace_content_1 = require("../utils/copy-workspace-content");
|
|
13
|
-
|
|
13
|
+
const rmtemp_1 = require("../utils/rmtemp");
|
|
14
|
+
const doStitch = (source, output) => {
|
|
14
15
|
// Ensure source and output directories exist
|
|
15
16
|
if (!fsx.existsSync(source))
|
|
16
17
|
throw new Error(`Cannot find source directory ${source}`);
|
|
17
|
-
fsx.ensureDirSync(output);
|
|
18
|
+
fsx.ensureDirSync(output, 0o700);
|
|
18
19
|
// Get a list of files.
|
|
19
20
|
let ast;
|
|
20
21
|
let files = [];
|
|
@@ -93,4 +94,21 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
93
94
|
// Return output folder
|
|
94
95
|
return output;
|
|
95
96
|
};
|
|
97
|
+
const stitch = (source, output) => {
|
|
98
|
+
if (output) {
|
|
99
|
+
return doStitch(source, output);
|
|
100
|
+
}
|
|
101
|
+
output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
102
|
+
try {
|
|
103
|
+
return doStitch(source, output);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
// In case of an error delete the temp output folder created earlier so that
|
|
107
|
+
// it does not "leak". In case of a success, deleting the output folder is
|
|
108
|
+
// the caller responsibility.
|
|
109
|
+
(0, rmtemp_1.rmtemp)(output);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
exports.default = stitch;
|
|
96
114
|
//# sourceMappingURL=stitch.js.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAClE,4CAAsC;AAEtC,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,EAAE;IAClD,6CAA6C;IAC7C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;IAC3D,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAEhC,uBAAuB;IACvB,IAAI,GAAQ,CAAA;IACZ,IAAI,KAAK,GAAa,EAAE,CAAA;IAExB,qEAAqE;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAEtD,IAAI,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,E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"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;iCAC2B,MAAM;;;;;AAApC,wBAsDC"}
|
package/lib/actions/transpile.js
CHANGED
|
@@ -10,6 +10,7 @@ const print_1 = require("../actions/print");
|
|
|
10
10
|
const stitch_1 = require("../actions/stitch");
|
|
11
11
|
const configure_1 = require("./configure");
|
|
12
12
|
const config_1 = require("../mutations/config");
|
|
13
|
+
const rmtemp_1 = require("../utils/rmtemp");
|
|
13
14
|
/**
|
|
14
15
|
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
15
16
|
* transformations, and return its effective GraphQL schema and configuration
|
|
@@ -49,9 +50,14 @@ exports.default = async (source) => {
|
|
|
49
50
|
let schema = '';
|
|
50
51
|
if (graphqlFiles.length > 0) {
|
|
51
52
|
const stitched = await (0, stitch_1.default)(source);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
try {
|
|
54
|
+
const index = path.join(stitched, 'index.graphql');
|
|
55
|
+
const graphql = fs.readFileSync(index, 'utf8');
|
|
56
|
+
schema = (0, print_1.default)((0, graphql_1.parse)(graphql));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
(0, rmtemp_1.rmtemp)(stitched);
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
return {
|
|
57
63
|
config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":";;AAAA,qCAA6B;AAC7B,iCAAgC;AAChC,+BAA8B;AAC9B,yBAAwB;AACxB,6BAA4B;AAC5B,6BAA4B;AAE5B,4CAAoC;AACpC,8CAAsC;AACtC,2CAAmC;AAEnC,gDAAiD;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M,IAAA,gBAAM,EAAC,MAAM,CAAC,CAAA;QACrC,IAAI;YACF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;YAClD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YAC9C,MAAM,GAAG,IAAA,eAAK,EAAC,IAAA,eAAK,EAAC,OAAO,CAAC,CAAC,CAAA;SAC/B;gBAAS;YACR,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAA;SACjB;KACF;IAED,OAAO;QACL,MAAM;QACN,MAAM;QACN,UAAU,EAAE,gBAAgB;KAC7B,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,aAAa,EAAQ,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"merge-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/merge-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,aAAa,EAAQ,MAAM,SAAS,CAAA;AAgBnD,eAAO,MAAM,gBAAgB,YAAa,MAAM,WAQ/C,CAAA;AAED,eAAO,MAAM,0BAA0B,WAAY,MAAM,QAAQ,MAAM,WAStE,CAAA;AAED,eAAO,MAAM,yBAAyB,SAC9B,MAAM,SACL,GAAG,KACT,OAcF,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,MAAM,SAAS,GAAG,KAAG,OAc3D,CAAA;AAED,eAAO,MAAM,gBAAgB,gBACd,MAAM,EAAE,WACb,OAAO,YACN,GAAG,KACX,QAAQ,MAAM,GAAG,OAAO,CA6B1B,CAAA;AAED,eAAO,MAAM,aAAa,QAAa,QAAQ,MAAM,CAuBpD,CAAA;AAED,eAAO,MAAM,SAAS,cACT,MAAM,cACL,MAAM,KACjB,QAAQ,aAAa,CAGvB,CAAA;AAED,eAAO,MAAM,4BAA4B,SAAU,GAAG,SAAS,GAAG,QAiBjE,CAAA;AAED,eAAO,MAAM,mBAAmB,SAAU,GAAG,SAAS,GAAG,QAmBxD,CAAA;AAED,eAAO,MAAM,6BAA6B,SAAU,MAAM,SAAS,GAAG,QAcrE,CAAA;AAED,eAAO,MAAM,oBAAoB,SAAU,MAAM,SAAS,GAAG,QAc5D,CAAA"}
|
|
@@ -14,6 +14,7 @@ const graphql_helpers_1 = require("../utils/graphql-helpers");
|
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const configure_1 = require("../actions/configure");
|
|
16
16
|
const transpile_1 = require("../actions/transpile");
|
|
17
|
+
const rmtemp_1 = require("./rmtemp");
|
|
17
18
|
const dedupeTempFolder = (dirpath) => {
|
|
18
19
|
do {
|
|
19
20
|
dirpath = (0, lodash_1.replace)(dirpath, os.tmpdir(), '');
|
|
@@ -69,23 +70,27 @@ exports.findTypeInSchema = findTypeInSchema;
|
|
|
69
70
|
const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
70
71
|
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`);
|
|
71
72
|
fsx.ensureDirSync(tmp);
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
try {
|
|
74
|
+
for (const directory of directories) {
|
|
75
|
+
const configs = [
|
|
76
|
+
...glob.sync('**/config.yaml', { cwd: directory }),
|
|
77
|
+
...glob.sync('**/stepzen.config.json', { cwd: directory }),
|
|
78
|
+
];
|
|
79
|
+
for (const config of configs) {
|
|
80
|
+
const configFolder = path.join(directory, config);
|
|
81
|
+
let writeFolder = path.join(tmp, directory, config);
|
|
82
|
+
writeFolder = (0, exports.dedupeTempFolder)(writeFolder);
|
|
83
|
+
const content = fsx.readFileSync(configFolder, 'utf8');
|
|
84
|
+
fsx.ensureFileSync(writeFolder);
|
|
85
|
+
fsx.writeFileSync(writeFolder, content, { mode: 0o600 });
|
|
86
|
+
}
|
|
84
87
|
}
|
|
88
|
+
const configuration = await (0, configure_1.default)(tmp, silent, answers);
|
|
89
|
+
return configuration;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
(0, rmtemp_1.rmtemp)(tmp);
|
|
85
93
|
}
|
|
86
|
-
const configuration = await (0, configure_1.default)(tmp, silent, answers);
|
|
87
|
-
fsx.removeSync(tmp);
|
|
88
|
-
return configuration;
|
|
89
94
|
};
|
|
90
95
|
exports.getConfiguration = getConfiguration;
|
|
91
96
|
const getExtensions = async () => {
|
|
@@ -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,gCAA+B;AAC/B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,mCAA8B;AAE9B,8DAAkD;AAClD,2CAA8C;AAE9C,oDAA4C;AAC5C,oDAA4C;
|
|
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,mCAA8B;AAE9B,8DAAkD;AAClD,2CAA8C;AAE9C,oDAA4C;AAC5C,oDAA4C;AAC5C,qCAA+B;AAExB,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAClD,GAAG;QACD,OAAO,GAAG,IAAA,gBAAO,EAAC,OAAO,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;KAC5C,QAAQ,OAAO,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B,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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify that the given path is indeed inside the tmp folder,
|
|
3
|
+
* and delete it recursively suppressing any errors.
|
|
4
|
+
*
|
|
5
|
+
* If the given path is not inside the tmp folder, do nothing.
|
|
6
|
+
*
|
|
7
|
+
* @param {*} fileOrDirPath path to a temp file or folder to delete
|
|
8
|
+
*/
|
|
9
|
+
export declare const rmtemp: (fileOrDirPath?: string) => void;
|
|
10
|
+
export default rmtemp;
|
|
11
|
+
//# sourceMappingURL=rmtemp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rmtemp.d.ts","sourceRoot":"","sources":["../../src/utils/rmtemp.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,mBAAoB,MAAM,SAyB5C,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2020,2021,2022,2023, StepZen, Inc.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.rmtemp = void 0;
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const debug = require("debug");
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
// THIS ENTIRE FILE IS COPIED FROM packages/cli/src/shared/rmtemp.ts
|
|
11
|
+
// (because there is no effective way to share util classes between packages yet)
|
|
12
|
+
// ----------------------------------------------------------------------------
|
|
13
|
+
/**
|
|
14
|
+
* Verify that the given path is indeed inside the tmp folder,
|
|
15
|
+
* and delete it recursively suppressing any errors.
|
|
16
|
+
*
|
|
17
|
+
* If the given path is not inside the tmp folder, do nothing.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} fileOrDirPath path to a temp file or folder to delete
|
|
20
|
+
*/
|
|
21
|
+
const rmtemp = (fileOrDirPath) => {
|
|
22
|
+
if (!fileOrDirPath) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// https://stackoverflow.com/a/45242825
|
|
26
|
+
const relative = path.relative(os.tmpdir(), fileOrDirPath);
|
|
27
|
+
const isInTemp = relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
28
|
+
if (isInTemp) {
|
|
29
|
+
try {
|
|
30
|
+
fs.rmSync(fileOrDirPath, { recursive: true, force: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// ignore errors
|
|
34
|
+
debug('stepzen:rmtemp')(`WARN: caught an exception while deleting ${fileOrDirPath}: `, error);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
debug('stepzen:rmtemp')(`WARN: got a temp path ${fileOrDirPath} out of the TMP folder -- ignoring`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.rmtemp = rmtemp;
|
|
42
|
+
exports.default = exports.rmtemp;
|
|
43
|
+
//# sourceMappingURL=rmtemp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rmtemp.js","sourceRoot":"","sources":["../../src/utils/rmtemp.ts"],"names":[],"mappings":";AAAA,mDAAmD;;;AAEnD,yBAAwB;AACxB,6BAA4B;AAC5B,yBAAwB;AACxB,+BAA8B;AAE9B,+EAA+E;AAC/E,yEAAyE;AACzE,iFAAiF;AACjF,+EAA+E;AAE/E;;;;;;;GAOG;AACI,MAAM,MAAM,GAAG,CAAC,aAAsB,EAAE,EAAE;IAC/C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAM;KACP;IAED,uCAAuC;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,CAAC,CAAA;IAC1D,MAAM,QAAQ,GACZ,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAEtE,IAAI,QAAQ,EAAE;QACZ,IAAI;YACF,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC,CAAA;SACzD;QAAC,OAAO,KAAK,EAAE;YACd,gBAAgB;YAChB,KAAK,CAAC,gBAAgB,CAAC,CACrB,4CAA4C,aAAa,IAAI,EAC7D,KAAK,CACN,CAAA;SACF;KACF;SAAM;QACL,KAAK,CAAC,gBAAgB,CAAC,CACrB,yBAAyB,aAAa,oCAAoC,CAC3E,CAAA;KACF;AACH,CAAC,CAAA;AAzBY,QAAA,MAAM,UAyBlB;AAED,kBAAe,cAAM,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.
|
|
4
|
+
"version": "0.29.0-beta.0",
|
|
5
5
|
"author": "Darren Waddell <darren@stepzen.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@graphql-tools/merge": "^8.3.15",
|
|
26
|
-
"@stepzen/fetch": "0.
|
|
26
|
+
"@stepzen/fetch": "0.29.0-beta.0",
|
|
27
27
|
"debug": "^4.3.4",
|
|
28
28
|
"dotenv": "^16.0.3",
|
|
29
29
|
"fs-extra": "^9.1.0",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@types/lodash": "^4.14.168",
|
|
44
44
|
"@types/mocha": "^8.2.2",
|
|
45
45
|
"@types/mock-fs": "^4.13.0",
|
|
46
|
+
"@types/node": "^14.18.36",
|
|
46
47
|
"@types/node-fetch": "^2.6.2",
|
|
47
48
|
"@types/prettier": "^2.7.2",
|
|
48
49
|
"@types/shelljs": "^0.8.11",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"nyc": "^14.1.1",
|
|
55
56
|
"ts-node": "^10.8.2"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ff2e1913f9590165479fb5d0f59c6917ef67c319"
|
|
58
59
|
}
|
package/src/actions/lint.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as shell from 'shelljs'
|
|
|
5
5
|
|
|
6
6
|
import stitch from '../actions/stitch'
|
|
7
7
|
import {getExtensions} from '../utils/merge-helpers'
|
|
8
|
+
import {rmtemp} from '../utils/rmtemp'
|
|
8
9
|
|
|
9
10
|
export default async (
|
|
10
11
|
source: string,
|
|
@@ -24,21 +25,23 @@ export default async (
|
|
|
24
25
|
extensions = await getExtensions()
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let stitched, tmp
|
|
29
|
+
try {
|
|
30
|
+
stitched = stitch(source)
|
|
31
|
+
const index = path.join(stitched, 'index.graphql')
|
|
32
|
+
const graphql = fsx.readFileSync(index, 'utf8')
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`)
|
|
35
|
+
fsx.ensureDirSync(tmp, 0o700)
|
|
36
|
+
const lintFile = path.join(tmp, 'index.graphql')
|
|
37
|
+
fsx.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`)
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
const {stdout} = shell.exec(`npx graphql-schema-linter ${lintFile}`, {
|
|
40
|
+
silent: true,
|
|
41
|
+
})
|
|
42
|
+
console.log(stdout)
|
|
43
|
+
} finally {
|
|
44
|
+
rmtemp(stitched)
|
|
45
|
+
rmtemp(tmp)
|
|
46
|
+
}
|
|
44
47
|
}
|
package/src/actions/merge.ts
CHANGED
|
@@ -23,6 +23,7 @@ import setFilesInSDL from '../utils/set-files-in-sdl'
|
|
|
23
23
|
import stripEmptyQueriesAndMutations from '../utils/strip-empty-queries-and-mutations'
|
|
24
24
|
import copyWorkspaceContent from '../utils/copy-workspace-content'
|
|
25
25
|
import {ALL_GRAPHQL_FILES} from '../utils/constants'
|
|
26
|
+
import {rmtemp} from '../utils/rmtemp'
|
|
26
27
|
|
|
27
28
|
// It's safe to use this special placeholder value here: in case of a failure
|
|
28
29
|
// in the merge / import process it will not reach the workspace folder.
|
|
@@ -41,34 +42,26 @@ type Query {
|
|
|
41
42
|
}
|
|
42
43
|
`.trim()
|
|
43
44
|
|
|
44
|
-
export
|
|
45
|
+
export type MergeOptions = {
|
|
46
|
+
answers: any
|
|
47
|
+
output: string | null
|
|
48
|
+
silent: boolean
|
|
49
|
+
/** when `false` merge only covers config files and updates @sdl directrive */
|
|
50
|
+
mergeTypes?: boolean
|
|
51
|
+
/** merge behaviour when a schema with the given name exists in the source */
|
|
52
|
+
onConflict?: 'overwrite' | 'append'
|
|
53
|
+
extensions?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const doMerge = async (
|
|
45
57
|
original: string,
|
|
46
58
|
imported: {
|
|
47
59
|
name: string
|
|
48
60
|
source: string
|
|
49
61
|
},
|
|
50
|
-
options: {
|
|
51
|
-
answers: any
|
|
52
|
-
output: string | null
|
|
53
|
-
silent: boolean
|
|
54
|
-
/** when `false` merge only covers config files and updates @sdl directrive */
|
|
55
|
-
mergeTypes?: boolean
|
|
56
|
-
/** merge behaviour when a schema with the given name exists in the source */
|
|
57
|
-
onConflict?: 'overwrite' | 'append'
|
|
58
|
-
extensions?: string
|
|
59
|
-
} = {
|
|
60
|
-
answers: {},
|
|
61
|
-
output: null,
|
|
62
|
-
silent: false,
|
|
63
|
-
mergeTypes: true,
|
|
64
|
-
onConflict: 'append',
|
|
65
|
-
extensions: '',
|
|
66
|
-
},
|
|
62
|
+
options: MergeOptions & {output: string},
|
|
67
63
|
) => {
|
|
68
|
-
// Make sure there is an output directory
|
|
69
64
|
if (!options.answers) options.answers = {}
|
|
70
|
-
if (!options.output)
|
|
71
|
-
options.output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)
|
|
72
65
|
if (!options.silent) options.silent = false
|
|
73
66
|
if (options.mergeTypes === undefined) options.mergeTypes = true
|
|
74
67
|
if (options.onConflict === undefined) options.onConflict = 'append'
|
|
@@ -83,7 +76,7 @@ export default async (
|
|
|
83
76
|
throw new Error(`Cannot find original directory ${original}`)
|
|
84
77
|
if (!fsx.existsSync(imported.source))
|
|
85
78
|
throw new Error(`Cannot find imported source directory ${imported.source}`)
|
|
86
|
-
fsx.ensureDirSync(options.output)
|
|
79
|
+
fsx.ensureDirSync(options.output, 0o700)
|
|
87
80
|
|
|
88
81
|
// Copy the original into the output.
|
|
89
82
|
copyWorkspaceContent(original, options.output)
|
|
@@ -208,19 +201,19 @@ export default async (
|
|
|
208
201
|
|
|
209
202
|
fsx.ensureFileSync(deduped)
|
|
210
203
|
fsx.writeFileSync(deduped, print(a.ast))
|
|
211
|
-
importedGraphQLFiles.push(path.relative(options.output
|
|
204
|
+
importedGraphQLFiles.push(path.relative(options.output, deduped))
|
|
212
205
|
})
|
|
213
206
|
} else {
|
|
214
207
|
glob.sync('**/*.graphql', {cwd: imported.source}).forEach(relativePath => {
|
|
215
208
|
const importedFullPath = path.join(imported.source, relativePath)
|
|
216
209
|
const targetFullPath = path.join(
|
|
217
|
-
options.output
|
|
210
|
+
options.output,
|
|
218
211
|
targetSubfolder,
|
|
219
212
|
relativePath,
|
|
220
213
|
)
|
|
221
214
|
fsx.ensureDirSync(path.dirname(targetFullPath))
|
|
222
215
|
fsx.copyFileSync(importedFullPath, targetFullPath)
|
|
223
|
-
importedGraphQLFiles.push(path.relative(options.output
|
|
216
|
+
importedGraphQLFiles.push(path.relative(options.output, targetFullPath))
|
|
224
217
|
})
|
|
225
218
|
}
|
|
226
219
|
|
|
@@ -235,9 +228,47 @@ export default async (
|
|
|
235
228
|
)
|
|
236
229
|
if (config) {
|
|
237
230
|
const configFile = path.join(options.output, 'config.yaml')
|
|
238
|
-
fsx.writeFileSync(configFile, config as string)
|
|
231
|
+
fsx.writeFileSync(configFile, config as string, {mode: 0o600})
|
|
239
232
|
}
|
|
240
233
|
|
|
241
234
|
// Return a merged schema!
|
|
242
235
|
return options.output
|
|
243
236
|
}
|
|
237
|
+
|
|
238
|
+
const merge = (
|
|
239
|
+
original: string,
|
|
240
|
+
imported: {
|
|
241
|
+
name: string
|
|
242
|
+
source: string
|
|
243
|
+
},
|
|
244
|
+
options: MergeOptions = {
|
|
245
|
+
answers: {},
|
|
246
|
+
output: null,
|
|
247
|
+
silent: false,
|
|
248
|
+
mergeTypes: true,
|
|
249
|
+
onConflict: 'append',
|
|
250
|
+
extensions: '',
|
|
251
|
+
},
|
|
252
|
+
) => {
|
|
253
|
+
// Make sure there is an output directory
|
|
254
|
+
if (options.output) {
|
|
255
|
+
return doMerge(
|
|
256
|
+
original,
|
|
257
|
+
imported,
|
|
258
|
+
options as MergeOptions & {output: string},
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)
|
|
263
|
+
try {
|
|
264
|
+
return doMerge(original, imported, {...options, output})
|
|
265
|
+
} catch (error) {
|
|
266
|
+
// In case of an error delete the temp output folder created earlier so that
|
|
267
|
+
// it does not "leak". In case of a success, deleting the output folder is
|
|
268
|
+
// the caller responsibility.
|
|
269
|
+
rmtemp(output)
|
|
270
|
+
throw error
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export default merge
|
package/src/actions/stitch.ts
CHANGED
|
@@ -9,15 +9,13 @@ import * as prettier from 'prettier'
|
|
|
9
9
|
import dedupeQueryAndMutationTypes from '../utils/dedupe-query-and-mutation-types'
|
|
10
10
|
import {ALL_GRAPHQL_FILES} from '../utils/constants'
|
|
11
11
|
import {getAllGraphQLFiles} from '../utils/copy-workspace-content'
|
|
12
|
+
import {rmtemp} from '../utils/rmtemp'
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
source: string,
|
|
15
|
-
output: string = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`),
|
|
16
|
-
) => {
|
|
14
|
+
const doStitch = (source: string, output: string) => {
|
|
17
15
|
// Ensure source and output directories exist
|
|
18
16
|
if (!fsx.existsSync(source))
|
|
19
17
|
throw new Error(`Cannot find source directory ${source}`)
|
|
20
|
-
fsx.ensureDirSync(output)
|
|
18
|
+
fsx.ensureDirSync(output, 0o700)
|
|
21
19
|
|
|
22
20
|
// Get a list of files.
|
|
23
21
|
let ast: any
|
|
@@ -111,3 +109,22 @@ export default (
|
|
|
111
109
|
// Return output folder
|
|
112
110
|
return output
|
|
113
111
|
}
|
|
112
|
+
|
|
113
|
+
const stitch = (source: string, output?: string) => {
|
|
114
|
+
if (output) {
|
|
115
|
+
return doStitch(source, output)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)
|
|
119
|
+
try {
|
|
120
|
+
return doStitch(source, output)
|
|
121
|
+
} catch (error) {
|
|
122
|
+
// In case of an error delete the temp output folder created earlier so that
|
|
123
|
+
// it does not "leak". In case of a success, deleting the output folder is
|
|
124
|
+
// the caller responsibility.
|
|
125
|
+
rmtemp(output)
|
|
126
|
+
throw error
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export default stitch
|
package/src/actions/transpile.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {parse} from 'graphql'
|
|
2
2
|
import * as dotenv from 'dotenv'
|
|
3
3
|
import * as debug from 'debug'
|
|
4
4
|
import * as fs from 'fs'
|
|
@@ -10,6 +10,7 @@ import stitch from '../actions/stitch'
|
|
|
10
10
|
import configure from './configure'
|
|
11
11
|
|
|
12
12
|
import configMutations from '../mutations/config'
|
|
13
|
+
import {rmtemp} from '../utils/rmtemp'
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Read a StepZen workspace directory, apply StepZen-specific schema and config
|
|
@@ -61,9 +62,13 @@ export default async (source: string) => {
|
|
|
61
62
|
|
|
62
63
|
if (graphqlFiles.length > 0) {
|
|
63
64
|
const stitched = await stitch(source)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
try {
|
|
66
|
+
const index = path.join(stitched, 'index.graphql')
|
|
67
|
+
const graphql = fs.readFileSync(index, 'utf8')
|
|
68
|
+
schema = print(parse(graphql))
|
|
69
|
+
} finally {
|
|
70
|
+
rmtemp(stitched)
|
|
71
|
+
}
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
return {
|
|
@@ -13,6 +13,7 @@ import {STEPZEN_SERVER_URL} from './constants'
|
|
|
13
13
|
|
|
14
14
|
import configure from '../actions/configure'
|
|
15
15
|
import transpile from '../actions/transpile'
|
|
16
|
+
import {rmtemp} from './rmtemp'
|
|
16
17
|
|
|
17
18
|
export const dedupeTempFolder = (dirpath: string) => {
|
|
18
19
|
do {
|
|
@@ -78,28 +79,31 @@ export const getConfiguration = async (
|
|
|
78
79
|
const tmp = path.join(os.tmpdir(), `stepzen-tmp-config-${Date.now()}`)
|
|
79
80
|
fsx.ensureDirSync(tmp)
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
try {
|
|
83
|
+
for (const directory of directories) {
|
|
84
|
+
const configs = [
|
|
85
|
+
...glob.sync('**/config.yaml', {cwd: directory}),
|
|
86
|
+
...glob.sync('**/stepzen.config.json', {cwd: directory}),
|
|
87
|
+
]
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
for (const config of configs) {
|
|
90
|
+
const configFolder = path.join(directory, config)
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
let writeFolder = path.join(tmp, directory, config)
|
|
93
|
+
writeFolder = dedupeTempFolder(writeFolder)
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
const content = fsx.readFileSync(configFolder, 'utf8')
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
fsx.ensureFileSync(writeFolder)
|
|
98
|
+
fsx.writeFileSync(writeFolder, content, {mode: 0o600})
|
|
99
|
+
}
|
|
97
100
|
}
|
|
98
|
-
}
|
|
99
101
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
const configuration = await configure(tmp, silent, answers)
|
|
103
|
+
return configuration
|
|
104
|
+
} finally {
|
|
105
|
+
rmtemp(tmp)
|
|
106
|
+
}
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
export const getExtensions = async (): Promise<string> => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) 2020,2021,2022,2023, StepZen, Inc.
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs'
|
|
4
|
+
import * as path from 'path'
|
|
5
|
+
import * as os from 'os'
|
|
6
|
+
import * as debug from 'debug'
|
|
7
|
+
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
// THIS ENTIRE FILE IS COPIED FROM packages/cli/src/shared/rmtemp.ts
|
|
10
|
+
// (because there is no effective way to share util classes between packages yet)
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Verify that the given path is indeed inside the tmp folder,
|
|
15
|
+
* and delete it recursively suppressing any errors.
|
|
16
|
+
*
|
|
17
|
+
* If the given path is not inside the tmp folder, do nothing.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} fileOrDirPath path to a temp file or folder to delete
|
|
20
|
+
*/
|
|
21
|
+
export const rmtemp = (fileOrDirPath?: string) => {
|
|
22
|
+
if (!fileOrDirPath) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// https://stackoverflow.com/a/45242825
|
|
27
|
+
const relative = path.relative(os.tmpdir(), fileOrDirPath)
|
|
28
|
+
const isInTemp =
|
|
29
|
+
relative && !relative.startsWith('..') && !path.isAbsolute(relative)
|
|
30
|
+
|
|
31
|
+
if (isInTemp) {
|
|
32
|
+
try {
|
|
33
|
+
fs.rmSync(fileOrDirPath, {recursive: true, force: true})
|
|
34
|
+
} catch (error) {
|
|
35
|
+
// ignore errors
|
|
36
|
+
debug('stepzen:rmtemp')(
|
|
37
|
+
`WARN: caught an exception while deleting ${fileOrDirPath}: `,
|
|
38
|
+
error,
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
debug('stepzen:rmtemp')(
|
|
43
|
+
`WARN: got a temp path ${fileOrDirPath} out of the TMP folder -- ignoring`,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default rmtemp
|