@graphql-toolkit/graphql-tag-pluck
Advanced tools
Comparing version 0.7.5-alpha-0271fe0.5 to 0.7.5-alpha-068a9db.12
@@ -388,3 +388,3 @@ 'use strict'; | ||
const gqlExtensions = ['.graphqls', '.graphql', '.gqls', '.gql']; | ||
const jsExtensions = ['.js', '.jsx', '.ts', '.tsx', '.flow', '.flow.js', '.flow.jsx']; | ||
const jsExtensions = ['.js', '.jsx', '.ts', '.tsx', '.flow', '.flow.js', '.flow.jsx', '.vue']; | ||
const supportedExtensions = [...gqlExtensions, ...jsExtensions]; | ||
@@ -394,2 +394,8 @@ supportedExtensions.toString = function toString() { | ||
}; | ||
function pluckVueFileScript(fileData) { | ||
const compiler = require('vue-template-compiler'); | ||
const parsed = compiler.parseComponent(fileData); | ||
const script = parsed.script ? parsed.script.content : ''; | ||
return script; | ||
} | ||
const gqlPluckFromFile = async (filePath, options = {}) => { | ||
@@ -411,3 +417,6 @@ if (typeof filePath != 'string') { | ||
options = { ...options, fileExt }; | ||
const code = fs.readFileSync(filePath, { encoding: 'utf8' }); | ||
let code = fs.readFileSync(filePath, { encoding: 'utf8' }); | ||
if (fileExt === '.vue') { | ||
code = pluckVueFileScript(code); | ||
} | ||
return gqlPluckFromCodeString(code, options); | ||
@@ -414,0 +423,0 @@ }; |
@@ -363,3 +363,3 @@ import { parse } from '@babel/parser'; | ||
const gqlExtensions = ['.graphqls', '.graphql', '.gqls', '.gql']; | ||
const jsExtensions = ['.js', '.jsx', '.ts', '.tsx', '.flow', '.flow.js', '.flow.jsx']; | ||
const jsExtensions = ['.js', '.jsx', '.ts', '.tsx', '.flow', '.flow.js', '.flow.jsx', '.vue']; | ||
const supportedExtensions = [...gqlExtensions, ...jsExtensions]; | ||
@@ -369,2 +369,8 @@ supportedExtensions.toString = function toString() { | ||
}; | ||
function pluckVueFileScript(fileData) { | ||
const compiler = require('vue-template-compiler'); | ||
const parsed = compiler.parseComponent(fileData); | ||
const script = parsed.script ? parsed.script.content : ''; | ||
return script; | ||
} | ||
const gqlPluckFromFile = async (filePath, options = {}) => { | ||
@@ -386,3 +392,6 @@ if (typeof filePath != 'string') { | ||
options = { ...options, fileExt }; | ||
const code = readFileSync(filePath, { encoding: 'utf8' }); | ||
let code = readFileSync(filePath, { encoding: 'utf8' }); | ||
if (fileExt === '.vue') { | ||
code = pluckVueFileScript(code); | ||
} | ||
return gqlPluckFromCodeString(code, options); | ||
@@ -389,0 +398,0 @@ }; |
{ | ||
"name": "@graphql-toolkit/graphql-tag-pluck", | ||
"version": "0.7.5-alpha-0271fe0.5+0271fe0", | ||
"version": "0.7.5-alpha-068a9db.12+068a9db", | ||
"description": "Pluck graphql-tag template literals", | ||
@@ -18,3 +18,6 @@ "peerDependencies": { | ||
}, | ||
"optionalDependencies": { | ||
"vue-template-compiler": "^2.6.10" | ||
}, | ||
"sideEffects": false | ||
} |
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
35925
892
5