@graphql-toolkit/core
Advanced tools
Comparing version 0.6.8-alpha-0aec269.1 to 0.6.8-alpha-0fa63c6.8
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const isValidPath = require("is-valid-path"); | ||
const isGlob = require("is-glob"); | ||
@@ -8,8 +7,3 @@ const common_1 = require("@graphql-toolkit/common"); | ||
const document_from_string_1 = require("./document-from-string"); | ||
function filterFiles(files) { | ||
return files.filter(file => !file.endsWith('.d.ts') && !file.endsWith('.spec.ts') && !file.endsWith('.spec.js') && !file.endsWith('.test.ts') && !file.endsWith('.test.js')); | ||
} | ||
function isUrl(pointer) { | ||
return typeof pointer === 'string' && /^https?\:\/\//i.test(pointer); | ||
} | ||
const globby = require("globby"); | ||
async function loadTypedefsUsingLoaders(loaders, pointerOrPointers, options = {}, filterKinds = [], cwd = process.cwd()) { | ||
@@ -27,3 +21,6 @@ const pointers = common_1.asArray(pointerOrPointers); | ||
} | ||
else if (isUrl(pointer)) { | ||
else if (isGlob(pointer)) { | ||
foundGlobs.push(pointer); | ||
} | ||
else { | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
@@ -40,21 +37,2 @@ let content = await loadSingleFile(loaders, pointer, options); | ||
} | ||
else if (isValidPath(pointer)) { | ||
const fixedPath = common_1.fixWindowsPath(pointer); | ||
const relevantFiles = filterFiles(common_1.asArray(fixedPath)); | ||
for (const filePath of relevantFiles) { | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
let content = await loadSingleFile(loaders, filePath, options); | ||
content = filter_document_kind_1.filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: filePath, | ||
document: content, | ||
}); | ||
} | ||
})); | ||
} | ||
} | ||
else if (isGlob(pointer)) { | ||
foundGlobs.push(pointer); | ||
} | ||
} | ||
@@ -70,14 +48,14 @@ if (foundGlobs.length > 0) { | ||
} | ||
const globby = eval(`require('globby')`); | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
const paths = await globby(foundGlobs, { cwd, absolute: true }); | ||
await Promise.all(paths.map(async (path) => { | ||
const filePath = common_1.fixWindowsPath(path); | ||
let content = await loadSingleFile(loaders, filePath, options); | ||
content = filter_document_kind_1.filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: filePath, | ||
document: content, | ||
}); | ||
if (!path.endsWith('.d.ts') && !path.endsWith('.spec.ts') && !path.endsWith('.spec.js') && !path.endsWith('.test.ts') && !path.endsWith('.test.js')) { | ||
let content = await loadSingleFile(loaders, path, options); | ||
content = filter_document_kind_1.filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: path, | ||
document: content, | ||
}); | ||
} | ||
} | ||
@@ -84,0 +62,0 @@ })); |
@@ -1,2 +0,1 @@ | ||
import * as isValidPath from 'is-valid-path'; | ||
import * as isGlob from 'is-glob'; | ||
@@ -6,8 +5,3 @@ import { asArray, isDocumentString, debugLog, fixWindowsPath } from '@graphql-toolkit/common'; | ||
import { documentFromString } from './document-from-string'; | ||
function filterFiles(files) { | ||
return files.filter(file => !file.endsWith('.d.ts') && !file.endsWith('.spec.ts') && !file.endsWith('.spec.js') && !file.endsWith('.test.ts') && !file.endsWith('.test.js')); | ||
} | ||
function isUrl(pointer) { | ||
return typeof pointer === 'string' && /^https?\:\/\//i.test(pointer); | ||
} | ||
import * as globby from 'globby'; | ||
export async function loadTypedefsUsingLoaders(loaders, pointerOrPointers, options = {}, filterKinds = [], cwd = process.cwd()) { | ||
@@ -25,3 +19,6 @@ const pointers = asArray(pointerOrPointers); | ||
} | ||
else if (isUrl(pointer)) { | ||
else if (isGlob(pointer)) { | ||
foundGlobs.push(pointer); | ||
} | ||
else { | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
@@ -38,21 +35,2 @@ let content = await loadSingleFile(loaders, pointer, options); | ||
} | ||
else if (isValidPath(pointer)) { | ||
const fixedPath = fixWindowsPath(pointer); | ||
const relevantFiles = filterFiles(asArray(fixedPath)); | ||
for (const filePath of relevantFiles) { | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
let content = await loadSingleFile(loaders, filePath, options); | ||
content = filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: filePath, | ||
document: content, | ||
}); | ||
} | ||
})); | ||
} | ||
} | ||
else if (isGlob(pointer)) { | ||
foundGlobs.push(pointer); | ||
} | ||
} | ||
@@ -68,14 +46,14 @@ if (foundGlobs.length > 0) { | ||
} | ||
const globby = eval(`require('globby')`); | ||
loadPromises$.push(Promise.resolve().then(async () => { | ||
const paths = await globby(foundGlobs, { cwd, absolute: true }); | ||
await Promise.all(paths.map(async (path) => { | ||
const filePath = fixWindowsPath(path); | ||
let content = await loadSingleFile(loaders, filePath, options); | ||
content = filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: filePath, | ||
document: content, | ||
}); | ||
if (!path.endsWith('.d.ts') && !path.endsWith('.spec.ts') && !path.endsWith('.spec.js') && !path.endsWith('.test.ts') && !path.endsWith('.test.js')) { | ||
let content = await loadSingleFile(loaders, path, options); | ||
content = filterKind(content, filterKinds); | ||
if (content && content.definitions && content.definitions.length > 0) { | ||
found.push({ | ||
location: path, | ||
document: content, | ||
}); | ||
} | ||
} | ||
@@ -82,0 +60,0 @@ })); |
{ | ||
"name": "@graphql-toolkit/core", | ||
"version": "0.6.8-alpha-0aec269.1+0aec269", | ||
"version": "0.6.8-alpha-0fa63c6.8+0fa63c6", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -26,4 +26,4 @@ "repository": "git@github.com:dotansimha/graphql-toolkit.git", | ||
"@types/is-glob": "4.0.1", | ||
"@types/jest": "24.0.21", | ||
"@types/node": "10.17.3", | ||
"@types/jest": "24.0.22", | ||
"@types/node": "10.17.4", | ||
"@types/valid-url": "1.0.2", | ||
@@ -40,4 +40,4 @@ "graphql": "14.5.8", | ||
"dependencies": { | ||
"@graphql-toolkit/common": "0.6.8-alpha-0aec269.1+0aec269", | ||
"@graphql-toolkit/schema-merging": "0.6.8-alpha-0aec269.1+0aec269", | ||
"@graphql-toolkit/common": "0.6.8-alpha-0fa63c6.8+0fa63c6", | ||
"@graphql-toolkit/schema-merging": "0.6.8-alpha-0fa63c6.8+0fa63c6", | ||
"aggregate-error": "3.0.1", | ||
@@ -47,3 +47,2 @@ "globby": "10.0.1", | ||
"is-glob": "4.0.1", | ||
"is-valid-path": "0.1.1", | ||
"tslib": "^1.9.3", | ||
@@ -55,3 +54,3 @@ "valid-url": "1.0.9" | ||
}, | ||
"gitHead": "0aec269a77e1dd82cfaa778f92766ec79f019717" | ||
"gitHead": "0fa63c6dfa82e8aaab5850752a44a2883f3b3379" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
10
1
33179
376
- Removedis-valid-path@0.1.1
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-invalid-path@0.1.0(transitive)
- Removedis-valid-path@0.1.1(transitive)
Updated@graphql-toolkit/common@0.6.8-alpha-0fa63c6.8+0fa63c6
Updated@graphql-toolkit/schema-merging@0.6.8-alpha-0fa63c6.8+0fa63c6