forked from 0no-co/gql.tada
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tada): add Internal tools package (0no-co#149)
- Loading branch information
1 parent
92283ad
commit 0c7178c
Showing
14 changed files
with
183 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@gql.tada/cli-utils": minor | ||
"@gql.tada/internal": minor | ||
"gql.tada": minor | ||
--- | ||
|
||
Add `@gql.tada/internal` package to extract common logic between the CLI and the LSP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ package-lock.json | |
.netlify/ | ||
/tsconfig.vitest-temp.json | ||
/cli | ||
/internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 0no.co | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "@gql.tada/internal", | ||
"version": "0.0.0", | ||
"public": true, | ||
"description": "Internal logic for gql.tada’s CLI tool and GraphQLSP.", | ||
"author": "0no.co <[email protected]>", | ||
"sideEffects": false, | ||
"source": "./src/index.ts", | ||
"main": "./dist/gql-tada-internal", | ||
"module": "./dist/gql-tada-internal.mjs", | ||
"types": "./dist/gql-tada-internal.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/gql-tada-internal.d.ts", | ||
"import": "./dist/gql-tada-internal.mjs", | ||
"require": "./dist/gql-tada-internal.js", | ||
"source": "./src/index.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"CHANGELOG.md", | ||
"LICENSE.md", | ||
"README.md", | ||
"dist/" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/0no-co/gql.tada.git", | ||
"directory": "packages/internal" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/0no-co/gql.tada/issues" | ||
}, | ||
"homepage": "https://gql-tada.0no.co/", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rollup -c ../../scripts/rollup.config.mjs", | ||
"clean": "rimraf dist node_modules/.cache", | ||
"prepublishOnly": "run-s clean build" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.0", | ||
"json5": "^2.2.3", | ||
"rollup": "^4.9.4", | ||
"sade": "^1.8.1", | ||
"type-fest": "^4.10.2", | ||
"typescript": "^5.3.3" | ||
}, | ||
"dependencies": { | ||
"@urql/introspection": "^1.0.3", | ||
"graphql": "^16.8.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { resolveTypeScriptRootDir } from './resolve'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import path from 'path'; | ||
import JSON5 from 'json5'; | ||
import type { TsConfigJson } from 'type-fest'; | ||
|
||
export const resolveTypeScriptRootDir = ( | ||
readFile: (path: string) => string | undefined, | ||
tsconfigPath: string | ||
): string | undefined => { | ||
const tsconfigContents = readFile(tsconfigPath); | ||
const parsed = JSON5.parse<TsConfigJson>(tsconfigContents!); | ||
|
||
if ( | ||
parsed.compilerOptions && | ||
parsed.compilerOptions.plugins && | ||
parsed.compilerOptions.plugins.find( | ||
(x) => x.name === '@0no-co/graphqlsp' || x.name === 'gql.tada/lsp' | ||
) | ||
) { | ||
return path.dirname(tsconfigPath); | ||
} else if (Array.isArray(parsed.extends)) { | ||
return parsed.extends.find((p) => { | ||
const resolved = require.resolve(p, { | ||
paths: [path.dirname(tsconfigPath)], | ||
}); | ||
return resolveTypeScriptRootDir(readFile, resolved); | ||
}); | ||
} else if (parsed.extends) { | ||
const resolved = require.resolve(parsed.extends, { | ||
paths: [path.dirname(tsconfigPath)], | ||
}); | ||
return resolveTypeScriptRootDir(readFile, resolved); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@gql.tada/internal'; |