@stepzen/transpiler 0.0.27 → 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/lint.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.default = async (source, options = {
|
|
|
20
20
|
const stitched = stitch_1.default(source);
|
|
21
21
|
const index = path.join(stitched, 'index.graphql');
|
|
22
22
|
const graphql = fs.readFileSync(index, 'utf8');
|
|
23
|
-
const tmp = path.join(os.tmpdir(),
|
|
23
|
+
const tmp = path.join(os.tmpdir(), `stepzen-lint-${Date.now()}`);
|
|
24
24
|
fs.ensureDirSync(tmp);
|
|
25
25
|
const lintFile = path.join(tmp, 'index.graphql');
|
|
26
26
|
fs.writeFileSync(lintFile, `${extensions}${os.EOL}${os.EOL}${graphql}`);
|
package/lib/actions/merge.js
CHANGED
|
@@ -31,6 +31,9 @@ exports.default = async (original, imported, options = {
|
|
|
31
31
|
options.output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`);
|
|
32
32
|
if (!options.silent)
|
|
33
33
|
options.silent = false;
|
|
34
|
+
// To stop things like
|
|
35
|
+
// C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-config-1638293497187\C:\Users\Darren\AppData\Local\Temp\stepzen-tmp-1638293496286
|
|
36
|
+
options.output = merge_helpers_1.dedupeTempFolder(options.output);
|
|
34
37
|
// Ensure original, importing and output directories exist
|
|
35
38
|
if (!fs.existsSync(original))
|
|
36
39
|
throw new Error(`Cannot find original directory ${original}`);
|
package/lib/actions/stitch.js
CHANGED
|
@@ -8,7 +8,7 @@ const os = require("os");
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const prettier = require("prettier");
|
|
10
10
|
const dedupe_query_and_mutation_types_1 = require("../utils/dedupe-query-and-mutation-types");
|
|
11
|
-
exports.default = (source, output = path.join(os.tmpdir(),
|
|
11
|
+
exports.default = (source, output = path.join(os.tmpdir(), `stepzen-tmp-${Date.now()}`)) => {
|
|
12
12
|
// Ensure source and output directories exist
|
|
13
13
|
if (!fs.existsSync(source))
|
|
14
14
|
throw new Error(`Cannot find source directory ${source}`);
|
package/lib/actions/validate.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const graphql_1 = require("graphql");
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
|
+
const os = require("os");
|
|
5
6
|
const path = require("path");
|
|
6
7
|
const ensure_query_and_mutation_types_1 = require("../utils/ensure-query-and-mutation-types");
|
|
7
8
|
const constants_1 = require("../utils/constants");
|
|
@@ -21,7 +22,7 @@ exports.default = (source, options = {
|
|
|
21
22
|
const file = path.join(source, 'index.graphql');
|
|
22
23
|
const index = fs.readFileSync(file, "utf8");
|
|
23
24
|
// Parse
|
|
24
|
-
let ast = graphql_1.parse(`${constants_1.EXPERIMENTAL_EXTENSIONS}
|
|
25
|
+
let ast = graphql_1.parse(`${constants_1.EXPERIMENTAL_EXTENSIONS}${os.EOL}${options.extensions}${os.EOL}${index}`, {
|
|
25
26
|
noLocation: true,
|
|
26
27
|
});
|
|
27
28
|
// We make an exception for 'no type Query' or 'no type Mutation'
|
|
@@ -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);
|