+7
-0
| # 0gql | ||
| ## 0.0.8 | ||
| ### Patch Changes | ||
| - 74851a2: Fix non-gql imports from gql modules being wrongly recognised as gql tags | ||
| - 74851a2: Fix missing extension in import lines when handling fragment | ||
| ## 0.0.7 | ||
@@ -4,0 +11,0 @@ |
+6
-13
@@ -48,3 +48,3 @@ "use strict"; | ||
| const targetFilename = (0, changeExtension_1.changeExtension)(file, options.targetExtension); | ||
| const indentifiers = { | ||
| const importIdentifiers = { | ||
| gqlTags: {}, | ||
@@ -58,15 +58,8 @@ others: {}, | ||
| if (typescript_1.default.isImportDeclaration(node)) { | ||
| const identifiers = (0, parseGqlTagImportIdentifiers_1.parseGqlTagImportIdentifiers)({ | ||
| (0, parseGqlTagImportIdentifiers_1.parseGqlTagImportIdentifiers)({ | ||
| node, | ||
| source: sourceFile, | ||
| gqlTagModules: options.gqlTagModules, | ||
| importIdentifiers, | ||
| }); | ||
| Object.entries(identifiers).forEach(([key, moduleMeta]) => { | ||
| if (moduleMeta.isGqlTagModule) { | ||
| indentifiers.gqlTags[key] = moduleMeta; | ||
| } | ||
| else { | ||
| indentifiers.others[key] = moduleMeta; | ||
| } | ||
| }); | ||
| } | ||
@@ -81,3 +74,3 @@ if (typescript_1.default.isVariableStatement(node)) { | ||
| // If tag is not part of gqlTags, do nothing | ||
| if (!indentifiers.gqlTags[tagIdentifier]) { | ||
| if (!importIdentifiers.gqlTags[tagIdentifier]) { | ||
| return; | ||
@@ -98,4 +91,4 @@ } | ||
| const identifier = span.expression.getText(sourceFile); | ||
| if (indentifiers.others[identifier]) { | ||
| convertedGraphqlImportLines.push(`#import "${indentifiers.others[identifier].module}"`); | ||
| if (importIdentifiers.others[identifier]) { | ||
| convertedGraphqlImportLines.push(`#import "${importIdentifiers.others[identifier].moduleName}.graphql"`); | ||
| substitutionsToReplace.push("${" + identifier + "}"); | ||
@@ -102,0 +95,0 @@ } |
| import ts from "typescript"; | ||
| import { IdentifierMeta } from "../types"; | ||
| interface ParseGqlTagImportIdentifiersParams { | ||
| interface ImportIdentifierMeta { | ||
| moduleName: string; | ||
| } | ||
| export interface ParseGqlTagImportIdentifiersParams { | ||
| node: ts.ImportDeclaration; | ||
| source: ts.SourceFile; | ||
| gqlTagModules: string[]; | ||
| importIdentifiers: { | ||
| gqlTags: Record<string, ImportIdentifierMeta>; | ||
| others: Record<string, ImportIdentifierMeta>; | ||
| }; | ||
| } | ||
@@ -12,3 +18,3 @@ /** | ||
| */ | ||
| export declare const parseGqlTagImportIdentifiers: ({ node, source, gqlTagModules, }: ParseGqlTagImportIdentifiersParams) => Record<string, IdentifierMeta>; | ||
| export declare const parseGqlTagImportIdentifiers: ({ node, source, gqlTagModules, importIdentifiers, }: ParseGqlTagImportIdentifiersParams) => void; | ||
| export {}; |
@@ -13,14 +13,11 @@ "use strict"; | ||
| */ | ||
| const parseGqlTagImportIdentifiers = ({ node, source, gqlTagModules, }) => { | ||
| const parseGqlTagImportIdentifiers = ({ node, source, gqlTagModules, importIdentifiers, }) => { | ||
| var _a, _b, _c, _d; | ||
| const module = (0, trimQuotes_1.trimQuotes)(node.moduleSpecifier.getText(source)); | ||
| // TODO: there are other modules to check. Maybe let users pass it in? | ||
| const isGqlTagModule = gqlTagModules.includes(module); | ||
| const identifiers = {}; | ||
| const moduleName = (0, trimQuotes_1.trimQuotes)(node.moduleSpecifier.getText(source)); | ||
| const isGqlTagModule = gqlTagModules.includes(moduleName); | ||
| const defaultImportIdentifier = (_b = (_a = node.importClause) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.getText(source); | ||
| if (defaultImportIdentifier) { | ||
| identifiers[defaultImportIdentifier] = { | ||
| isGqlTag: isGqlTagModule, | ||
| isGqlTagModule, | ||
| module, | ||
| const key = isGqlTagModule ? "gqlTags" : "others"; | ||
| importIdentifiers[key][defaultImportIdentifier] = { | ||
| moduleName, | ||
| }; | ||
@@ -33,11 +30,9 @@ } | ||
| ((_a = cn.propertyName) === null || _a === void 0 ? void 0 : _a.getText(source)) === "gql"; | ||
| identifiers[cn.name.getText(source)] = { | ||
| isGqlTag, | ||
| isGqlTagModule, | ||
| module, | ||
| const key = isGqlTag && isGqlTagModule ? "gqlTags" : "others"; | ||
| importIdentifiers[key][cn.name.getText(source)] = { | ||
| moduleName, | ||
| }; | ||
| } | ||
| }); | ||
| return identifiers; | ||
| }; | ||
| exports.parseGqlTagImportIdentifiers = parseGqlTagImportIdentifiers; |
+1
-1
| { | ||
| "name": "0gql", | ||
| "version": "0.0.7", | ||
| "version": "0.0.8", | ||
| "description": "Migrate from gql tag", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:eddeee888/nogql.git", |
| export interface IdentifierMeta { | ||
| isGqlTag: boolean; | ||
| isGqlTagModule: boolean; | ||
| module: string; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
16926
-1.16%16
-11.11%280
-4.44%