@graphql-toolkit/file-loading
Advanced tools
Comparing version 0.6.8-alpha-a3fdc9c.4 to 0.6.8-alpha-aa0b7b9.7
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const graphql_1 = require("graphql"); | ||
const fs_1 = require("fs"); | ||
const glob = require("glob"); | ||
const path_1 = require("path"); | ||
const DEFAULT_IGNORED_SCHEMA_EXTENSIONS = ['spec', 'test', 'd', 'map']; | ||
@@ -11,8 +14,6 @@ const DEFAULT_SCHEMA_EXTENSIONS = ['gql', 'graphql', 'graphqls', 'ts', 'js']; | ||
function isDirectory(path) { | ||
const fs = eval(`require('fs')`); | ||
return fs.existsSync(path) && fs.statSync(path).isDirectory(); | ||
return fs_1.existsSync(path) && fs_1.statSync(path).isDirectory(); | ||
} | ||
function scanForFiles(globStr, globOptions = {}) { | ||
const { sync } = eval(`require('glob')`); | ||
return sync(globStr, { absolute: true, ...globOptions }); | ||
return glob.sync(globStr, { absolute: true, ...globOptions }); | ||
} | ||
@@ -62,6 +63,5 @@ function buildGlob(basePath, extensions, ignoredExtensions = [], recursive) { | ||
} | ||
const { extname } = eval(`require('path')`); | ||
const extension = extname(path); | ||
const extension = path_1.extname(path); | ||
if (extension.endsWith('.js') || extension.endsWith('.ts') || execOptions.useRequire) { | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : eval('require'))(path); | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : require)(path); | ||
const extractedExport = extractExports(fileExports, execOptions.exportNames); | ||
@@ -74,4 +74,3 @@ if (extractedExport && extractedExport.kind === 'Document') { | ||
else { | ||
const { readFileSync } = eval(`require('fs')`); | ||
return readFileSync(path, { encoding: 'utf-8' }); | ||
return fs_1.readFileSync(path, { encoding: 'utf-8' }); | ||
} | ||
@@ -103,3 +102,3 @@ }) | ||
try { | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : eval('require'))(path); | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : require)(path); | ||
return extractExports(fileExports, execOptions.exportNames); | ||
@@ -115,3 +114,2 @@ } | ||
function scanForFilesAsync(globStr, globOptions = {}) { | ||
const glob = eval(`require('glob')`); | ||
return new Promise((resolve, reject) => glob(globStr, { absolute: true, ...globOptions }, (err, matches) => { | ||
@@ -147,3 +145,3 @@ if (err) { | ||
const relevantPaths = await scanForFilesAsync(isDirectory(path) ? buildGlob(path, execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive) : path, options.globOptions); | ||
const require$ = (path) => Promise.resolve().then(() => eval(`require('${path}')`)); | ||
const require$ = (path) => Promise.resolve().then(() => require(path)); | ||
return Promise.all(relevantPaths | ||
@@ -157,4 +155,3 @@ .map(async (path) => { | ||
} | ||
const { extname } = eval(`require('path')`); | ||
const extension = extname(path); | ||
const extension = path_1.extname(path); | ||
if (extension.endsWith('.js') || extension.endsWith('.ts') || execOptions.useRequire) { | ||
@@ -170,4 +167,3 @@ const fileExports = await (execOptions.requireMethod ? execOptions.requireMethod : require$)(path); | ||
return new Promise((resolve, reject) => { | ||
const { readFile } = eval(`require('fs')`); | ||
readFile(path, { encoding: 'utf-8' }, (err, data) => { | ||
fs_1.readFile(path, { encoding: 'utf-8' }, (err, data) => { | ||
if (err) { | ||
@@ -187,3 +183,3 @@ reject(err); | ||
const relevantPaths = await scanForFilesAsync(isDirectory(path) ? buildGlob(path, execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive) : path, options.globOptions); | ||
const require$ = (path) => Promise.resolve().then(() => eval(`require('${path}')`)); | ||
const require$ = (path) => Promise.resolve().then(() => require(path)); | ||
return Promise.all(relevantPaths.map(async (path) => { | ||
@@ -190,0 +186,0 @@ if (!checkExtension(path, options)) { |
import { print } from 'graphql'; | ||
import { existsSync, statSync, readFileSync, readFile } from 'fs'; | ||
import * as glob from 'glob'; | ||
import { extname } from 'path'; | ||
const DEFAULT_IGNORED_SCHEMA_EXTENSIONS = ['spec', 'test', 'd', 'map']; | ||
@@ -9,8 +12,6 @@ const DEFAULT_SCHEMA_EXTENSIONS = ['gql', 'graphql', 'graphqls', 'ts', 'js']; | ||
function isDirectory(path) { | ||
const fs = eval(`require('fs')`); | ||
return fs.existsSync(path) && fs.statSync(path).isDirectory(); | ||
return existsSync(path) && statSync(path).isDirectory(); | ||
} | ||
function scanForFiles(globStr, globOptions = {}) { | ||
const { sync } = eval(`require('glob')`); | ||
return sync(globStr, { absolute: true, ...globOptions }); | ||
return glob.sync(globStr, { absolute: true, ...globOptions }); | ||
} | ||
@@ -60,6 +61,5 @@ function buildGlob(basePath, extensions, ignoredExtensions = [], recursive) { | ||
} | ||
const { extname } = eval(`require('path')`); | ||
const extension = extname(path); | ||
if (extension.endsWith('.js') || extension.endsWith('.ts') || execOptions.useRequire) { | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : eval('require'))(path); | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : require)(path); | ||
const extractedExport = extractExports(fileExports, execOptions.exportNames); | ||
@@ -72,3 +72,2 @@ if (extractedExport && extractedExport.kind === 'Document') { | ||
else { | ||
const { readFileSync } = eval(`require('fs')`); | ||
return readFileSync(path, { encoding: 'utf-8' }); | ||
@@ -100,3 +99,3 @@ } | ||
try { | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : eval('require'))(path); | ||
const fileExports = (execOptions.requireMethod ? execOptions.requireMethod : require)(path); | ||
return extractExports(fileExports, execOptions.exportNames); | ||
@@ -111,3 +110,2 @@ } | ||
function scanForFilesAsync(globStr, globOptions = {}) { | ||
const glob = eval(`require('glob')`); | ||
return new Promise((resolve, reject) => glob(globStr, { absolute: true, ...globOptions }, (err, matches) => { | ||
@@ -143,3 +141,3 @@ if (err) { | ||
const relevantPaths = await scanForFilesAsync(isDirectory(path) ? buildGlob(path, execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive) : path, options.globOptions); | ||
const require$ = (path) => Promise.resolve().then(() => eval(`require('${path}')`)); | ||
const require$ = (path) => import(path); | ||
return Promise.all(relevantPaths | ||
@@ -153,3 +151,2 @@ .map(async (path) => { | ||
} | ||
const { extname } = eval(`require('path')`); | ||
const extension = extname(path); | ||
@@ -166,3 +163,2 @@ if (extension.endsWith('.js') || extension.endsWith('.ts') || execOptions.useRequire) { | ||
return new Promise((resolve, reject) => { | ||
const { readFile } = eval(`require('fs')`); | ||
readFile(path, { encoding: 'utf-8' }, (err, data) => { | ||
@@ -182,3 +178,3 @@ if (err) { | ||
const relevantPaths = await scanForFilesAsync(isDirectory(path) ? buildGlob(path, execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive) : path, options.globOptions); | ||
const require$ = (path) => Promise.resolve().then(() => eval(`require('${path}')`)); | ||
const require$ = (path) => import(path); | ||
return Promise.all(relevantPaths.map(async (path) => { | ||
@@ -185,0 +181,0 @@ if (!checkExtension(path, options)) { |
{ | ||
"name": "@graphql-toolkit/file-loading", | ||
"version": "0.6.8-alpha-a3fdc9c.4+a3fdc9c", | ||
"version": "0.6.8-alpha-aa0b7b9.7+aa0b7b9", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -25,3 +25,3 @@ "repository": "git@github.com:dotansimha/graphql-toolkit.git", | ||
"@types/glob": "7.1.1", | ||
"@types/jest": "24.0.21", | ||
"@types/jest": "24.0.22", | ||
"@types/node": "12.12.6", | ||
@@ -34,3 +34,3 @@ "graphql": "14.5.8", | ||
"dependencies": { | ||
"@graphql-toolkit/common": "0.6.8-alpha-a3fdc9c.4+a3fdc9c", | ||
"@graphql-toolkit/common": "0.6.8-alpha-aa0b7b9.7+aa0b7b9", | ||
"@kamilkisiela/graphql-tools": "4.0.6", | ||
@@ -42,3 +42,3 @@ "glob": "7.1.5" | ||
}, | ||
"gitHead": "a3fdc9cd16e3e2d7833d663fbbe3ab860162f668" | ||
"gitHead": "aa0b7b913da8b728a64cbd28374276c45df406fc" | ||
} |
Sorry, the diff of this file is not supported yet
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
1
41720
444
9