@stepzen/transpiler 0.0.30 → 0.0.31
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/merge.js
CHANGED
|
@@ -28,14 +28,12 @@ exports.default = async (original, imported, options = {
|
|
|
28
28
|
if (!options.answers)
|
|
29
29
|
options.answers = {};
|
|
30
30
|
if (!options.output)
|
|
31
|
-
options.output = `stepzen-tmp-${Date.now()}
|
|
31
|
+
options.output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
32
32
|
if (!options.silent)
|
|
33
33
|
options.silent = false;
|
|
34
34
|
// To stop things like
|
|
35
35
|
// C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-config-1638293497187\C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-1638293496286
|
|
36
|
-
|
|
37
|
-
options.output = options.output.replace(regex, '');
|
|
38
|
-
options.output = path.join(os.tmpdir(), options.output);
|
|
36
|
+
options.output = merge_helpers_1.dedupeTempFolder(options.output);
|
|
39
37
|
// Ensure original, importing and output directories exist
|
|
40
38
|
if (!fs.existsSync(original))
|
|
41
39
|
throw new Error(`Cannot find original directory ${original}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from "graphql";
|
|
2
|
+
export declare const dedupeTempFolder: (dirpath: string) => string;
|
|
2
3
|
export declare const findQueryMutationInSchema: (name: string, files: any) => Boolean;
|
|
3
4
|
export declare const findTypeInSchema: (name: string, files: any) => Boolean;
|
|
4
5
|
export declare const getConfiguration: (directories: string[], silent?: boolean, answers?: any) => Promise<string | boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeTypeFromSchema = exports.removeQueryMutationFromSchema = exports.mergeTypeIntoSchema = exports.mergeQueryMutationIntoSchema = exports.getSchema = exports.getExtensions = exports.getConfiguration = exports.findTypeInSchema = exports.findQueryMutationInSchema = void 0;
|
|
3
|
+
exports.removeTypeFromSchema = exports.removeQueryMutationFromSchema = exports.mergeTypeIntoSchema = exports.mergeQueryMutationIntoSchema = exports.getSchema = exports.getExtensions = exports.getConfiguration = exports.findTypeInSchema = exports.findQueryMutationInSchema = exports.dedupeTempFolder = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const utilities_1 = require("graphql/utilities");
|
|
6
6
|
const node_fetch_1 = require("node-fetch");
|
|
@@ -12,6 +12,13 @@ const graphql_helpers_1 = require("../utils/graphql-helpers");
|
|
|
12
12
|
const constants_1 = require("./constants");
|
|
13
13
|
const configure_1 = require("../actions/configure");
|
|
14
14
|
const transpile_1 = require("../actions/transpile");
|
|
15
|
+
const dedupeTempFolder = (dirpath) => {
|
|
16
|
+
const regex = new RegExp(os.tmpdir(), 'gi');
|
|
17
|
+
dirpath = dirpath.replace(regex, '');
|
|
18
|
+
dirpath = path.join(os.tmpdir(), dirpath);
|
|
19
|
+
return dirpath;
|
|
20
|
+
};
|
|
21
|
+
exports.dedupeTempFolder = dedupeTempFolder;
|
|
15
22
|
const findQueryMutationInSchema = (name, files) => {
|
|
16
23
|
for (const file of files) {
|
|
17
24
|
let found = false;
|
|
@@ -56,7 +63,8 @@ const getConfiguration = async (directories, silent = false, answers = {}) => {
|
|
|
56
63
|
];
|
|
57
64
|
for (const config of configs) {
|
|
58
65
|
const configFolder = path.join(directory, config);
|
|
59
|
-
|
|
66
|
+
let writeFolder = path.join(tmp, directory, config);
|
|
67
|
+
writeFolder = exports.dedupeTempFolder(writeFolder);
|
|
60
68
|
const content = fs.readFileSync(configFolder, "utf8");
|
|
61
69
|
fs.ensureFileSync(writeFolder);
|
|
62
70
|
fs.writeFileSync(writeFolder, content);
|