@stepzen/transpiler 0.0.33 → 0.0.36
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/LICENSE +1 -1
- package/lib/actions/configure.js +15 -14
- package/lib/actions/configure.js.map +1 -0
- package/lib/actions/lint.js +6 -5
- package/lib/actions/lint.js.map +1 -0
- package/lib/actions/merge.d.ts +2 -0
- package/lib/actions/merge.js +80 -70
- package/lib/actions/merge.js.map +1 -0
- package/lib/actions/print.d.ts +1 -1
- package/lib/actions/print.js +2 -1
- package/lib/actions/print.js.map +1 -0
- package/lib/actions/stitch.js +14 -13
- package/lib/actions/stitch.js.map +1 -0
- package/lib/actions/transpile.js +7 -6
- package/lib/actions/transpile.js.map +1 -0
- package/lib/actions/validate.js +4 -3
- package/lib/actions/validate.js.map +1 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +16 -16
- package/lib/index.js.map +1 -0
- package/lib/mutations/config/envvars.js +3 -2
- package/lib/mutations/config/envvars.js.map +1 -0
- package/lib/mutations/config/index.js +1 -0
- package/lib/mutations/config/index.js.map +1 -0
- package/lib/utils/constants.js +2 -1
- package/lib/utils/constants.js.map +1 -0
- package/lib/utils/dedupe-query-and-mutation-types.js +7 -6
- package/lib/utils/dedupe-query-and-mutation-types.js.map +1 -0
- package/lib/utils/ensure-query-and-mutation-types.d.ts +1 -1
- package/lib/utils/ensure-query-and-mutation-types.js +7 -6
- package/lib/utils/ensure-query-and-mutation-types.js.map +1 -0
- package/lib/utils/graphql-helpers.js +1 -0
- package/lib/utils/graphql-helpers.js.map +1 -0
- package/lib/utils/merge-helpers.d.ts +2 -1
- package/lib/utils/merge-helpers.js +16 -5
- package/lib/utils/merge-helpers.js.map +1 -0
- package/lib/utils/set-files-in-sdl.js +9 -8
- package/lib/utils/set-files-in-sdl.js.map +1 -0
- package/lib/utils/strip-empty-queries-and-mutations.d.ts +1 -1
- package/lib/utils/strip-empty-queries-and-mutations.js +7 -6
- package/lib/utils/strip-empty-queries-and-mutations.js.map +1 -0
- package/lib/validators/config-exists/index.d.ts +1 -1
- package/lib/validators/config-exists/index.js +11 -10
- package/lib/validators/config-exists/index.js.map +1 -0
- package/lib/validators/index.js +1 -0
- package/lib/validators/index.js.map +1 -0
- package/package.json +24 -16
- package/src/actions/configure.ts +120 -0
- package/src/actions/lint.ts +45 -0
- package/src/actions/merge.ts +202 -0
- package/src/actions/print.ts +8 -0
- package/src/actions/stitch.ts +105 -0
- package/src/actions/transpile.ts +70 -0
- package/src/actions/validate.ts +54 -0
- package/src/index.ts +7 -0
- package/src/mutations/config/envvars.ts +17 -0
- package/src/mutations/config/index.ts +3 -0
- package/src/utils/constants.ts +16 -0
- package/src/utils/dedupe-query-and-mutation-types.ts +74 -0
- package/src/utils/ensure-query-and-mutation-types.ts +52 -0
- package/src/utils/graphql-helpers.ts +3 -0
- package/src/utils/merge-helpers.ts +187 -0
- package/src/utils/set-files-in-sdl.ts +40 -0
- package/src/utils/strip-empty-queries-and-mutations.ts +43 -0
- package/src/validators/config-exists/index.ts +54 -0
- package/src/validators/index.ts +3 -0
package/LICENSE
CHANGED
package/lib/actions/configure.js
CHANGED
|
@@ -15,12 +15,12 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
15
15
|
ruleset: [],
|
|
16
16
|
};
|
|
17
17
|
// Now let's parse and add any config.yamls
|
|
18
|
-
for (const y of glob.sync(
|
|
18
|
+
for (const y of glob.sync('**/config.yaml', { cwd: source })) {
|
|
19
19
|
const filePath = path.join(source, y);
|
|
20
|
-
const file = fs.readFileSync(filePath,
|
|
20
|
+
const file = fs.readFileSync(filePath, 'utf8');
|
|
21
21
|
const asYAML = yaml.parse(file);
|
|
22
|
-
debug(
|
|
23
|
-
debug(
|
|
22
|
+
debug('stepzen:transpiler')(`Adding config.yaml ${filePath}`);
|
|
23
|
+
debug('stepzen:transpiler')(`Contents: ${JSON.stringify(asYAML, null, 2)}`);
|
|
24
24
|
if (asYAML.configurationset) {
|
|
25
25
|
config.configurationset = config.configurationset.concat(asYAML.configurationset);
|
|
26
26
|
}
|
|
@@ -30,28 +30,28 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
32
|
// Now let's build configs from questions
|
|
33
|
-
for (var _g = tslib_1.__asyncValues(glob.sync(
|
|
33
|
+
for (var _g = tslib_1.__asyncValues(glob.sync('**/stepzen.config.json', {
|
|
34
34
|
cwd: source,
|
|
35
35
|
})), _h; _h = await _g.next(), !_h.done;) {
|
|
36
36
|
const j = _h.value;
|
|
37
37
|
const filePath = path.join(source, j);
|
|
38
|
-
const file = fs.readFileSync(filePath,
|
|
38
|
+
const file = fs.readFileSync(filePath, 'utf8');
|
|
39
39
|
const asJSON = JSON.parse(file);
|
|
40
|
-
debug(
|
|
41
|
-
debug(
|
|
40
|
+
debug('stepzen:transpiler')(`Adding stepzen.config.json ${filePath}`);
|
|
41
|
+
debug('stepzen:transpiler')(`Contents: ${JSON.stringify(asJSON, null, 2)}`);
|
|
42
42
|
if ((_c = asJSON.config) === null || _c === void 0 ? void 0 : _c.questions) {
|
|
43
43
|
try {
|
|
44
44
|
for (var _j = (e_2 = void 0, tslib_1.__asyncValues((_d = asJSON.config) === null || _d === void 0 ? void 0 : _d.questions)), _k; _k = await _j.next(), !_k.done;) {
|
|
45
45
|
const question = _k.value;
|
|
46
|
-
const [name, key] = question.name.split(
|
|
46
|
+
const [name, key] = question.name.split('.');
|
|
47
47
|
let answer = {};
|
|
48
48
|
if (silent) {
|
|
49
49
|
answer = {
|
|
50
|
-
[name]: { [key]: ((_e = answers[name]) === null || _e === void 0 ? void 0 : _e[key]) ? (_f = answers[name]) === null || _f === void 0 ? void 0 : _f[key] :
|
|
50
|
+
[name]: { [key]: ((_e = answers[name]) === null || _e === void 0 ? void 0 : _e[key]) ? (_f = answers[name]) === null || _f === void 0 ? void 0 : _f[key] : '' },
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
answer = await inquirer.prompt(Object.assign({ type:
|
|
54
|
+
answer = await inquirer.prompt(Object.assign({ type: 'password' }, question));
|
|
55
55
|
}
|
|
56
56
|
const configset = {
|
|
57
57
|
configuration: {
|
|
@@ -59,8 +59,8 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
59
59
|
[key]: answer[name][key],
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
|
-
debug(
|
|
63
|
-
debug(
|
|
62
|
+
debug('stepzen:transpiler')(`Question: ${JSON.stringify(question, null, 2)}`);
|
|
63
|
+
debug('stepzen:transpiler')(`Answer: ${JSON.stringify(configset, null, 2)}`);
|
|
64
64
|
config.configurationset.push(Object.assign({}, configset));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -81,7 +81,7 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
81
81
|
}
|
|
82
82
|
finally { if (e_1) throw e_1.error; }
|
|
83
83
|
}
|
|
84
|
-
debug(
|
|
84
|
+
debug('stepzen:transpiler')(`Configuration: ${JSON.stringify(config, null, 2)}`);
|
|
85
85
|
// OK now let's collate everything into shared configurations
|
|
86
86
|
const obj = {};
|
|
87
87
|
for (const c of config.configurationset) {
|
|
@@ -115,3 +115,4 @@ exports.default = async (source, silent = false, answers = {}) => {
|
|
|
115
115
|
}
|
|
116
116
|
return false;
|
|
117
117
|
};
|
|
118
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/actions/configure.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,+BAA8B;AAC9B,6BAA4B;AAC5B,qCAAoC;AACpC,6BAA4B;AAC5B,6BAA4B;AAE5B,kBAAe,KAAK,EAAE,MAAc,EAAE,MAAM,GAAG,KAAK,EAAE,UAAe,EAAE,EAAE,EAAE;;;IACzE,IAAI,MAAM,GAAQ;QAChB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EAAE,EAA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C;QAC1C,OAAO,UAAU,CAAC,gBAAgB,CAAA;IACpC,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,OAAO,CAAA;IAE9D,IAAI,UAAU,CAAC,gBAAgB,IAAI,UAAU,CAAC,OAAO,EAAE;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;KAClC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/lib/actions/lint.js
CHANGED
|
@@ -7,25 +7,26 @@ const path = require("path");
|
|
|
7
7
|
const shell = require("shelljs");
|
|
8
8
|
const stitch_1 = require("../actions/stitch");
|
|
9
9
|
exports.default = async (source, options = {
|
|
10
|
-
extensions:
|
|
10
|
+
extensions: '',
|
|
11
11
|
}) => {
|
|
12
12
|
if (!fs.existsSync(source)) {
|
|
13
13
|
throw new Error(`Cannot find source directory ${source}`);
|
|
14
14
|
}
|
|
15
15
|
let extensions = options.extensions;
|
|
16
16
|
if (!extensions) {
|
|
17
|
-
const response = await node_fetch_1.default(
|
|
17
|
+
const response = await node_fetch_1.default('https://www.steprz.net/directives.graphql');
|
|
18
18
|
extensions = await response.text();
|
|
19
19
|
}
|
|
20
20
|
const stitched = stitch_1.default(source);
|
|
21
|
-
const index = path.join(stitched,
|
|
22
|
-
const graphql = fs.readFileSync(index,
|
|
21
|
+
const index = path.join(stitched, 'index.graphql');
|
|
22
|
+
const graphql = fs.readFileSync(index, 'utf8');
|
|
23
23
|
const tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`);
|
|
24
24
|
fs.ensureDirSync(tmp);
|
|
25
|
-
const lintFile = path.join(tmp,
|
|
25
|
+
const lintFile = path.join(tmp, 'index.graphql');
|
|
26
26
|
fs.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`);
|
|
27
27
|
shell.exec(`npx graphql-schema-linter ${lintFile}`, { silent: true }, (code, stdout, stderr) => {
|
|
28
28
|
console.log(std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G,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,OAAO,EAAE,CAAC,CAAA;IAEvE,KAAK,CAAC,IAAI,CACR,6BAA6B,QAAQ,EAAE,EACvC,EAAC,MAAM,EAAE,IAAI,EAAC,EACd,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACnB,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC,CACF,CAAA;AACH,CAAC,CAAA"}
|
package/lib/actions/merge.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ declare const _default: (original: string, imported: {
|
|
|
5
5
|
answers: any;
|
|
6
6
|
output: string | null;
|
|
7
7
|
silent: boolean;
|
|
8
|
+
/** when `false` merge only covers config files and updates @sdl directrive */
|
|
9
|
+
mergeTypes?: boolean;
|
|
8
10
|
}) => Promise<string>;
|
|
9
11
|
export default _default;
|
package/lib/actions/merge.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.default = async (original, imported, options = {
|
|
|
23
23
|
answers: {},
|
|
24
24
|
output: null,
|
|
25
25
|
silent: false,
|
|
26
|
+
mergeTypes: true,
|
|
26
27
|
}) => {
|
|
27
28
|
// Make sure there is an output directory
|
|
28
29
|
if (!options.answers)
|
|
@@ -31,6 +32,8 @@ exports.default = async (original, imported, options = {
|
|
|
31
32
|
options.output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
32
33
|
if (!options.silent)
|
|
33
34
|
options.silent = false;
|
|
35
|
+
if (options.mergeTypes === undefined)
|
|
36
|
+
options.mergeTypes = true;
|
|
34
37
|
// To stop things like
|
|
35
38
|
// C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-config-1638293497187\C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-1638293496286
|
|
36
39
|
options.output = merge_helpers_1.dedupeTempFolder(options.output);
|
|
@@ -43,89 +46,96 @@ exports.default = async (original, imported, options = {
|
|
|
43
46
|
// Copy the original into the output.
|
|
44
47
|
fs.copySync(original, options.output);
|
|
45
48
|
// Ensure an index.graphql exists
|
|
46
|
-
const outputIndex = path.join(options.output,
|
|
49
|
+
const outputIndex = path.join(options.output, 'index.graphql');
|
|
47
50
|
if (!fs.existsSync(outputIndex)) {
|
|
48
51
|
fs.writeFileSync(outputIndex, BLANK_INDEX_TEMPLATE);
|
|
49
52
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.map(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
const targetSubfolder = merge_helpers_1.findNextAvailableSubfolder(original, imported.name);
|
|
54
|
+
if (options.mergeTypes) {
|
|
55
|
+
const merged = merge_1.mergeTypeDefs([
|
|
56
|
+
await merge_helpers_1.getSchema(options.output),
|
|
57
|
+
await merge_helpers_1.getSchema(imported.source),
|
|
58
|
+
]);
|
|
59
|
+
let queries = [];
|
|
60
|
+
let mutations = [];
|
|
61
|
+
let types = [];
|
|
62
|
+
graphql_1.visit(merged, {
|
|
63
|
+
ObjectTypeDefinition(node) {
|
|
64
|
+
if (node.name.value === 'Query')
|
|
65
|
+
queries = queries.concat(node.fields);
|
|
66
|
+
else if (node.name.value === 'Mutation')
|
|
67
|
+
mutations = mutations.concat(node.fields);
|
|
68
|
+
else
|
|
69
|
+
types = types.concat(node);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
const details = {
|
|
73
|
+
original: glob.sync('**/*.graphql', { cwd: options.output }).map(file => {
|
|
74
|
+
const content = fs.readFileSync(`${options.output}/${file}`, 'utf8');
|
|
75
|
+
return { ast: graphql_1.parse(content), file };
|
|
76
|
+
}),
|
|
77
|
+
imported: glob.sync('**/*.graphql', { cwd: imported.source }).map(file => {
|
|
78
|
+
const content = fs.readFileSync(`${imported.source}/${file}`, 'utf8');
|
|
79
|
+
return { ast: graphql_1.parse(content), file };
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
// Merge Queries and Mutations
|
|
83
|
+
for (const type of [...queries, ...mutations]) {
|
|
84
|
+
const isInOriginal = merge_helpers_1.findQueryMutationInSchema(type.name.value, details.original);
|
|
85
|
+
const isInImported = merge_helpers_1.findQueryMutationInSchema(type.name.value, details.imported);
|
|
86
|
+
if (isInOriginal && isInImported) {
|
|
87
|
+
details.original = merge_helpers_1.mergeQueryMutationIntoSchema(type, details.original);
|
|
88
|
+
details.imported = merge_helpers_1.removeQueryMutationFromSchema(type.name.value, details.imported);
|
|
89
|
+
}
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
// Merge Types
|
|
92
|
+
for (const type of types) {
|
|
93
|
+
const isInOriginal = merge_helpers_1.findTypeInSchema(type.name.value, details.original);
|
|
94
|
+
const isInImported = merge_helpers_1.findTypeInSchema(type.name.value, details.imported);
|
|
95
|
+
if (isInOriginal && isInImported) {
|
|
96
|
+
details.original = merge_helpers_1.mergeTypeIntoSchema(type, details.original);
|
|
97
|
+
details.imported = merge_helpers_1.removeTypeFromSchema(type.name.value, details.imported);
|
|
98
|
+
}
|
|
95
99
|
}
|
|
100
|
+
// Clean up the files. Remove empty Query / Mutation types, filter out now-empty files
|
|
101
|
+
const cleaned = {
|
|
102
|
+
original: details.original
|
|
103
|
+
.map(item => (Object.assign(Object.assign({}, item), { ast: strip_empty_queries_and_mutations_1.default(item.ast) })))
|
|
104
|
+
.filter(item => item.ast.definitions.length > 0),
|
|
105
|
+
imported: details.imported
|
|
106
|
+
.map(item => (Object.assign(Object.assign({}, item), { ast: strip_empty_queries_and_mutations_1.default(item.ast) })))
|
|
107
|
+
.filter(item => item.ast.definitions.length > 0),
|
|
108
|
+
};
|
|
109
|
+
// Write the files to the output directory
|
|
110
|
+
cleaned.original.forEach((a) => {
|
|
111
|
+
// eslint-disable-next-line
|
|
112
|
+
const file = path.join(options.output, a.file);
|
|
113
|
+
const deduped = merge_helpers_1.dedupeTempFolder(file);
|
|
114
|
+
fs.ensureFileSync(deduped);
|
|
115
|
+
fs.writeFileSync(deduped, print_1.default(a.ast));
|
|
116
|
+
});
|
|
117
|
+
cleaned.imported.forEach(a => {
|
|
118
|
+
// eslint-disable-next-line
|
|
119
|
+
const file = path.join(options.output, targetSubfolder, a.file);
|
|
120
|
+
const deduped = merge_helpers_1.dedupeTempFolder(file);
|
|
121
|
+
fs.ensureFileSync(deduped);
|
|
122
|
+
fs.writeFileSync(deduped, print_1.default(a.ast));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Write the files to the output directory
|
|
127
|
+
fs.copySync(original, options.output);
|
|
128
|
+
fs.copySync(imported.source, path.join(options.output, targetSubfolder));
|
|
96
129
|
}
|
|
97
|
-
// Clean up the files. Remove empty Query / Mutation types, filter out now-empty files
|
|
98
|
-
const cleaned = {
|
|
99
|
-
original: details.original
|
|
100
|
-
.map((item) => (Object.assign(Object.assign({}, item), { ast: strip_empty_queries_and_mutations_1.default(item.ast) })))
|
|
101
|
-
.filter((item) => item.ast.definitions.length > 0),
|
|
102
|
-
imported: details.imported
|
|
103
|
-
.map((item) => (Object.assign(Object.assign({}, item), { ast: strip_empty_queries_and_mutations_1.default(item.ast) })))
|
|
104
|
-
.filter((item) => item.ast.definitions.length > 0),
|
|
105
|
-
};
|
|
106
|
-
// Write the files to the output directory
|
|
107
|
-
cleaned.original.forEach((a) => {
|
|
108
|
-
// eslint-disable-next-line
|
|
109
|
-
const file = path.join(options.output, a.file);
|
|
110
|
-
const deduped = merge_helpers_1.dedupeTempFolder(file);
|
|
111
|
-
fs.ensureFileSync(deduped);
|
|
112
|
-
fs.writeFileSync(deduped, print_1.default(a.ast));
|
|
113
|
-
});
|
|
114
|
-
cleaned.imported.forEach((a) => {
|
|
115
|
-
// eslint-disable-next-line
|
|
116
|
-
const file = path.join(options.output, imported.name, a.file);
|
|
117
|
-
const deduped = merge_helpers_1.dedupeTempFolder(file);
|
|
118
|
-
fs.ensureFileSync(deduped);
|
|
119
|
-
fs.writeFileSync(deduped, print_1.default(a.ast));
|
|
120
|
-
});
|
|
121
130
|
// Make sure all files are referenced in @sdl
|
|
122
131
|
set_files_in_sdl_1.default(options.output);
|
|
123
132
|
// Generate configuration
|
|
124
133
|
const config = await merge_helpers_1.getConfiguration([options.output, imported.source], options.silent, options.answers);
|
|
125
134
|
if (config) {
|
|
126
|
-
const configFile = path.join(options.output,
|
|
135
|
+
const configFile = path.join(options.output, 'config.yaml');
|
|
127
136
|
fs.writeFileSync(configFile, config);
|
|
128
137
|
}
|
|
129
138
|
// Return a merged schema!
|
|
130
139
|
return options.output;
|
|
131
140
|
};
|
|
141
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/actions/merge.ts"],"names":[],"mappings":";;AAAA,+BAA8B;AAC9B,6BAA4B;AAC5B,gDAAkD;AAClD,qCAAoC;AACpC,yBAAwB;AACxB,6BAA4B;AAE5B,0DAW+B;AAC/B,mCAA2B;AAC3B,gEAAqD;AACrD,kGAAsF;AAEtF,MAAM,oBAAoB,GAAG;;;;;;;;CAQ5B,CAAC,IAAI,EAAE,CAAA;AAER,kBAAe,KAAK,EAClB,QAAgB,EAChB,QAGC,EACD,UAMI;IACF,OAAO,EAAE,EAAE;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C,CAAC,EAAE;YAC3B,2BAA2B;YAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAa,EAAE,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;YACtE,MAAM,OAAO,GAAG,gCAAgB,CAAC,IAAI,CAAC,CAAA;YAEtC,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YAC1B,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,eAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;KACH;SAAM;QACL,0CAA0C;QAC1C,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACrC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAA;KACzE;IAED,6CAA6C;IAC7C,0BAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAE7B,yBAAyB;IACzB,MAAM,MAAM,GAAG,MAAM,gCAAgB,CACnC,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,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAgB,CAAC,CAAA;KAC/C;IAED,0BAA0B;IAC1B,OAAO,OAAO,CAAC,MAAM,CAAA;AACvB,CAAC,CAAA"}
|
package/lib/actions/print.d.ts
CHANGED
package/lib/actions/print.js
CHANGED
|
@@ -4,6 +4,7 @@ const graphql_1 = require("graphql");
|
|
|
4
4
|
const prettier = require("prettier");
|
|
5
5
|
exports.default = (ast) => {
|
|
6
6
|
const printed = graphql_1.print(ast);
|
|
7
|
-
const formatted = prettier.format(printed, { parser:
|
|
7
|
+
const formatted = prettier.format(printed, { parser: 'graphql' });
|
|
8
8
|
return formatted;
|
|
9
9
|
};
|
|
10
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../src/actions/print.ts"],"names":[],"mappings":";;AAAA,qCAA2C;AAC3C,qCAAoC;AAEpC,kBAAe,CAAC,GAAiB,EAAU,EAAE;IAC3C,MAAM,OAAO,GAAG,eAAK,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"}
|
package/lib/actions/stitch.js
CHANGED
|
@@ -17,15 +17,15 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
17
17
|
let ast;
|
|
18
18
|
let files = [];
|
|
19
19
|
// If there's an index.graphQL - get files argument in @sdl directive
|
|
20
|
-
const sourceIndex = path.join(source,
|
|
20
|
+
const sourceIndex = path.join(source, 'index.graphql');
|
|
21
21
|
if (fs.existsSync(sourceIndex)) {
|
|
22
|
-
const index = fs.readFileSync(sourceIndex,
|
|
22
|
+
const index = fs.readFileSync(sourceIndex, 'utf8');
|
|
23
23
|
ast = graphql_1.parse(index);
|
|
24
24
|
ast = graphql_1.visit(ast, {
|
|
25
25
|
Directive(node) {
|
|
26
26
|
var _a;
|
|
27
|
-
if (node.name.value ===
|
|
28
|
-
const list = (_a = node.arguments) === null || _a === void 0 ? void 0 : _a.find((arg) => arg.name.value ===
|
|
27
|
+
if (node.name.value === 'sdl') {
|
|
28
|
+
const list = (_a = node.arguments) === null || _a === void 0 ? void 0 : _a.find((arg) => arg.name.value === 'files');
|
|
29
29
|
// If we find a 'files' argument, we copy the list, and remove the argument
|
|
30
30
|
if (list) {
|
|
31
31
|
const copy = lodash_1.clone(list.value);
|
|
@@ -33,7 +33,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
33
33
|
files = files.concat(file.value);
|
|
34
34
|
}
|
|
35
35
|
const mutated = lodash_1.cloneDeep(node);
|
|
36
|
-
mutated.arguments = mutated.arguments.filter((arg) => arg.name.value !==
|
|
36
|
+
mutated.arguments = mutated.arguments.filter((arg) => arg.name.value !== 'files');
|
|
37
37
|
return mutated;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -42,9 +42,9 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
44
|
const content = glob
|
|
45
|
-
.sync(
|
|
45
|
+
.sync('**/*.graphql', { cwd: source })
|
|
46
46
|
.map((file) => {
|
|
47
|
-
const graphql = fs.readFileSync(`${source}/${file}`,
|
|
47
|
+
const graphql = fs.readFileSync(`${source}/${file}`, 'utf8');
|
|
48
48
|
return graphql;
|
|
49
49
|
});
|
|
50
50
|
ast = graphql_1.parse(content.join(os.EOL));
|
|
@@ -52,7 +52,7 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
52
52
|
// Strip @sdl directive
|
|
53
53
|
ast = graphql_1.visit(ast, {
|
|
54
54
|
Directive(node) {
|
|
55
|
-
if (node.name.value ===
|
|
55
|
+
if (node.name.value === 'sdl')
|
|
56
56
|
return null;
|
|
57
57
|
},
|
|
58
58
|
});
|
|
@@ -68,22 +68,23 @@ exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.n
|
|
|
68
68
|
let stitched = `${printed}${os.EOL}`;
|
|
69
69
|
for (const file of files) {
|
|
70
70
|
const find = path.join(source, file);
|
|
71
|
-
const content = fs.readFileSync(find,
|
|
71
|
+
const content = fs.readFileSync(find, 'utf8');
|
|
72
72
|
stitched += `${content}${os.EOL}`;
|
|
73
73
|
}
|
|
74
74
|
// Dedupe Query and Mutation types
|
|
75
75
|
stitched = dedupe_query_and_mutation_types_1.default(stitched);
|
|
76
76
|
// Format
|
|
77
|
-
stitched = prettier.format(stitched, { parser:
|
|
77
|
+
stitched = prettier.format(stitched, { parser: 'graphql' });
|
|
78
78
|
// Write to output folder
|
|
79
|
-
const outputIndex = path.join(output,
|
|
79
|
+
const outputIndex = path.join(output, 'index.graphql');
|
|
80
80
|
fs.writeFileSync(outputIndex, stitched);
|
|
81
81
|
// Copy config if exists, too
|
|
82
|
-
const sourceConfig = path.join(source,
|
|
83
|
-
const outputConfig = path.join(output,
|
|
82
|
+
const sourceConfig = path.join(source, 'config.yaml');
|
|
83
|
+
const outputConfig = path.join(output, 'config.yaml');
|
|
84
84
|
if (fs.existsSync(sourceConfig)) {
|
|
85
85
|
fs.copyFileSync(sourceConfig, outputConfig);
|
|
86
86
|
}
|
|
87
87
|
// Return output folder
|
|
88
88
|
return output;
|
|
89
89
|
};
|
|
90
|
+
//# sourceMappingURL=stitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stitch.js","sourceRoot":"","sources":["../../src/actions/stitch.ts"],"names":[],"mappings":";;AAAA,mCAAuC;AACvC,qCAA2C;AAC3C,+BAA8B;AAC9B,6BAA4B;AAC5B,yBAAwB;AACxB,6BAA4B;AAC5B,qCAAoC;AAEpC,8FAAkF;AAElF,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,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;IAC3D,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;I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,CAAC,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,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAEvC,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,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QAC/B,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;KAC5C;IAED,uBAAuB;IACvB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/lib/actions/transpile.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.default = async (source) => {
|
|
|
18
18
|
}
|
|
19
19
|
// Load env vars, from working and source directories
|
|
20
20
|
dotenv.config();
|
|
21
|
-
dotenv.config({ path: path.resolve(source,
|
|
21
|
+
dotenv.config({ path: path.resolve(source, '.env') });
|
|
22
22
|
// State of whether we've transpiled or not
|
|
23
23
|
let transpiledConfig = false;
|
|
24
24
|
let transpiledGraphQL = false;
|
|
@@ -44,13 +44,13 @@ exports.default = async (source) => {
|
|
|
44
44
|
transpiledConfig = true;
|
|
45
45
|
}
|
|
46
46
|
// See whether to transpile GraphQL
|
|
47
|
-
const graphqlFiles = glob.sync(
|
|
48
|
-
let original =
|
|
49
|
-
let mutated =
|
|
47
|
+
const graphqlFiles = glob.sync('**/*.graphql', { cwd: source });
|
|
48
|
+
let original = '';
|
|
49
|
+
let mutated = '';
|
|
50
50
|
if (graphqlFiles.length > 0) {
|
|
51
51
|
const stitched = await stitch_1.default(source);
|
|
52
|
-
const index = path.join(stitched,
|
|
53
|
-
const graphql = fs.readFileSync(index,
|
|
52
|
+
const index = path.join(stitched, 'index.graphql');
|
|
53
|
+
const graphql = fs.readFileSync(index, 'utf8');
|
|
54
54
|
let ast = graphql_1.parse(graphql);
|
|
55
55
|
original = graphql_1.parse(graphql);
|
|
56
56
|
// you can transpile schema ast here
|
|
@@ -65,3 +65,4 @@ exports.default = async (source) => {
|
|
|
65
65
|
transpiled: transpiledConfig || transpiledGraphQL,
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
+
//# sourceMappingURL=transpile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transpile.js","sourceRoot":"","sources":["../../src/actions/transpile.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAC3C,iCAAgC;AAChC,yBAAwB;AACxB,6BAA4B;AAC5B,6BAA4B;AAE5B,4CAAoC;AACpC,8CAAsC;AACtC,2CAAmC;AAEnC,gDAAiD;AAEjD,kBAAe,KAAK,EAAE,MAAc,EAAE,EAAE;;IACtC,6CAA6C;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;KAC1D;IAED,qDAAqD;IACrD,MAAM,CAAC,MAAM,EAAE,CAAA;IACf,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAC,CAAC,CAAA;IAEnD,2CAA2C;IAC3C,IAAI,gBAAgB,GAAG,KAAK,CAAA;IAC5B,IAAI,iBAAiB,GAAG,KAAK,CAAA;IAE7B,kCAAkC;IAClC,IAAI,MAAM,GAAQ,MAAM,mBAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAA;IAEzB,IAAI,MAAM,EAAE;;YACV,KAA6B,IAAA,oBAAA,sBAAA,gBAAe,CAAA,qBAAA;gBAAjC,MAAM,QAAQ,4BAAA,CAAA;gBACvB,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAA;aAChC;;;;;;;;;KACF;IAED,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,gBAAgB,GAAG,IAAI,CAAA;KACxB;IAED,mCAAmC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC,CAAA;IAC7D,IAAI,QAAQ,GAAQ,EAAE,CAAA;IACtB,IAAI,OAAO,GAAQ,EAAE,CAAA;IAErB,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,MAAM,QAAQ,GAAG,MAAM,gBAAM,CAAC,MAAM,CAAC,CAAA;QAErC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;QAElD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE9C,IAAI,GAAG,GAAiB,eAAK,CAAC,OAAO,CAAC,CAAA;QACtC,QAAQ,GAAG,eAAK,CAAC,OAAO,CAAC,CAAA;QAEzB,oCAAoC;QAEpC,OAAO,GAAG,eAAK,CAAC,GAAG,CAAC,CAAA;QAEpB,IAAI,eAAK,CAAC,QAAQ,CAAC,KAAK,OAAO,EAAE;YAC/B,iBAAiB,GAAG,IAAI,CAAA;SACzB;KACF;IAED,OAAO;QACL,MAAM;QACN,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,gBAAgB,IAAI,iBAAiB;KAClD,CAAA;AACH,CAAC,CAAA"}
|
package/lib/actions/validate.js
CHANGED
|
@@ -8,7 +8,7 @@ const ensure_query_and_mutation_types_1 = require("../utils/ensure-query-and-mut
|
|
|
8
8
|
const constants_1 = require("../utils/constants");
|
|
9
9
|
const validators_1 = require("../validators");
|
|
10
10
|
exports.default = (source, options = {
|
|
11
|
-
extensions:
|
|
11
|
+
extensions: '',
|
|
12
12
|
}) => {
|
|
13
13
|
// Ensure source and output directories exist
|
|
14
14
|
if (!fs.existsSync(source)) {
|
|
@@ -19,8 +19,8 @@ exports.default = (source, options = {
|
|
|
19
19
|
throw new Error(`Cannot find index.graphql in ${source}`);
|
|
20
20
|
}
|
|
21
21
|
// Get the index.graphql file
|
|
22
|
-
const file = path.join(source,
|
|
23
|
-
const index = fs.readFileSync(file,
|
|
22
|
+
const file = path.join(source, 'index.graphql');
|
|
23
|
+
const index = fs.readFileSync(file, 'utf8');
|
|
24
24
|
// Parse
|
|
25
25
|
let ast = graphql_1.parse(`${constants_1.EXPERIMENTAL_EXTENSIONS}${os.EOL}${options.extensions}${os.EOL}${index}`, {
|
|
26
26
|
noLocation: true,
|
|
@@ -37,3 +37,4 @@ exports.default = (source, options = {
|
|
|
37
37
|
// Return true
|
|
38
38
|
return true;
|
|
39
39
|
};
|
|
40
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/actions/validate.ts"],"names":[],"mappings":";;AAAA,qCAAkE;AAClE,+BAA8B;AAC9B,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,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAA;KAC1D;IAED,8BAA8B;IAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,MAAM,gBAAgB,CAAC,EAAE;QAC7C,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,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAE3C,QAAQ;IACR,IAAI,GAAG,GAAiB,eAAK,CAC3B,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,yCAA2B,CAAC,GAAG,CAAC,CAAA;IAEtC,+BAA+B;IAC/B,wBAAc,CAAC,GAAG,CAAC,CAAA;IACnB,eAAK,CAAC,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"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { default as configure } from './actions/configure';
|
|
2
|
+
export { default as lint } from './actions/lint';
|
|
3
|
+
export { default as merge } from './actions/merge';
|
|
4
|
+
export { default as print } from './actions/print';
|
|
5
|
+
export { default as stitch } from './actions/stitch';
|
|
6
|
+
export { default as transpile } from './actions/transpile';
|
|
7
|
+
export { default as validate } from './actions/validate';
|
package/lib/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.validate = exports.transpile = exports.stitch = exports.print = exports.merge = exports.lint = exports.configure = void 0;
|
|
4
|
+
var configure_1 = require("./actions/configure");
|
|
5
|
+
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return configure_1.default; } });
|
|
6
|
+
var lint_1 = require("./actions/lint");
|
|
7
|
+
Object.defineProperty(exports, "lint", { enumerable: true, get: function () { return lint_1.default; } });
|
|
8
|
+
var merge_1 = require("./actions/merge");
|
|
9
|
+
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return merge_1.default; } });
|
|
10
|
+
var print_1 = require("./actions/print");
|
|
11
|
+
Object.defineProperty(exports, "print", { enumerable: true, get: function () { return print_1.default; } });
|
|
12
|
+
var stitch_1 = require("./actions/stitch");
|
|
13
|
+
Object.defineProperty(exports, "stitch", { enumerable: true, get: function () { return stitch_1.default; } });
|
|
14
|
+
var transpile_1 = require("./actions/transpile");
|
|
15
|
+
Object.defineProperty(exports, "transpile", { enumerable: true, get: function () { return transpile_1.default; } });
|
|
16
|
+
var validate_1 = require("./actions/validate");
|
|
17
|
+
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return validate_1.default; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAwD;AAAhD,sGAAA,OAAO,OAAa;AAC5B,uCAA8C;AAAtC,4FAAA,OAAO,OAAQ;AACvB,yCAAgD;AAAxC,8FAAA,OAAO,OAAS;AACxB,yCAAgD;AAAxC,8FAAA,OAAO,OAAS;AACxB,2CAAkD;AAA1C,gGAAA,OAAO,OAAU;AACzB,iDAAwD;AAAhD,sGAAA,OAAO,OAAa;AAC5B,+CAAsD;AAA9C,oGAAA,OAAO,OAAY"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = async (config) => {
|
|
4
4
|
const envvars = Object.keys(process.env)
|
|
5
|
-
.filter(
|
|
5
|
+
.filter(key => {
|
|
6
6
|
return key.startsWith(`STEPZEN_`);
|
|
7
7
|
})
|
|
8
8
|
.reduce((obj, key) => {
|
|
@@ -10,8 +10,9 @@ exports.default = async (config) => {
|
|
|
10
10
|
return obj;
|
|
11
11
|
}, {});
|
|
12
12
|
for (const [key, value] of Object.entries(envvars)) {
|
|
13
|
-
const regex = new RegExp(key,
|
|
13
|
+
const regex = new RegExp(key, 'g');
|
|
14
14
|
config = config.replace(regex, `${value}`);
|
|
15
15
|
}
|
|
16
16
|
return config;
|
|
17
17
|
};
|
|
18
|
+
//# sourceMappingURL=envvars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envvars.js","sourceRoot":"","sources":["../../../src/mutations/config/envvars.ts"],"names":[],"mappings":";;AAAA,kBAAe,KAAK,EAAE,MAAc,EAAmB,EAAE;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;SACrC,MAAM,CAAC,GAAG,CAAC,EAAE;QACZ,OAAO,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE;QACxB,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;IAER,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAClD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QAClC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;KAC3C;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mutations/config/index.ts"],"names":[],"mappings":";;AAAA,uCAA+B;AAE/B,kBAAe,CAAC,iBAAO,CAAC,CAAA"}
|
package/lib/utils/constants.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,EAAC,cAAc,EAAE,sBAAsB,EAAC,GAAG,OAAO,CAAC,GAAG,CAAA;AAE/C,QAAA,uBAAuB,GAAG;;;;;;;CAOtC,CAAA;AAEY,QAAA,cAAc,GAAG,sBAAsB,IAAI,YAAY,CAAA"}
|