-
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.
New package: @tylerbu/lilconfig-loader-ts (#177)
- Loading branch information
1 parent
09a6bd4
commit cd3686c
Showing
15 changed files
with
433 additions
and
65 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,8 @@ | ||
--- | ||
"@tylerbu/lilconfig-loader-ts": minor | ||
--- | ||
|
||
New package: @tylerbu/lilconfig-loader-ts | ||
|
||
A TypeScript loader for [lilconfig](https://www.npmjs.com/package/lilconfig), enabling you to load TypeScript | ||
configuration files in lilconfig. |
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 @@ | ||
/esm |
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) Tyler Butler <tyler@tylerbutler.com> | ||
|
||
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. |
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 @@ | ||
# @tylerbu/lilconfig-loader-ts | ||
|
||
A TypeScript loader for [lilconfig](https://www.npmjs.com/package/lilconfig), enabling you to load TypeScript | ||
configuration files in lilconfig. | ||
|
||
## Installation | ||
|
||
``` | ||
npm install @tylerbu/lilconfig-loader-ts | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { lilconfig } from "lilconfig"; | ||
import { TypeScriptLoader } from "@tylerbu/lilconfig-loader-ts"; | ||
|
||
const moduleName = "myModuleName"; | ||
const explorer = lilconfig(moduleName, { | ||
searchPlaces: [ | ||
"package.json", | ||
`.${moduleName}rc`, | ||
`.${moduleName}rc.json`, | ||
`.${moduleName}rc.ts`, | ||
`.${moduleName}rc.js`, | ||
`${moduleName}.config.ts`, | ||
`${moduleName}.config.js`, | ||
], | ||
loaders: { | ||
".ts": TypeScriptLoader, | ||
}, | ||
}); | ||
``` |
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,122 @@ | ||
This file was generated with the generate-license-file npm package! | ||
https://www.npmjs.com/package/generate-license-file | ||
|
||
The following npm package may be included in this product: | ||
|
||
- debug@4.3.5 | ||
|
||
This package contains the following license and notice below: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> | ||
Copyright (c) 2018-2021 Josh Junon | ||
|
||
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. | ||
|
||
----------- | ||
|
||
The following npm package may be included in this product: | ||
|
||
- simple-git@3.25.0 | ||
|
||
This package contains the following license and notice below: | ||
|
||
MIT | ||
|
||
----------- | ||
|
||
The following npm package may be included in this product: | ||
|
||
- @oclif/core@4.0.12 | ||
|
||
This package contains the following license and notice below: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2018 Salesforce.com | ||
|
||
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. | ||
|
||
----------- | ||
|
||
The following npm packages may be included in this product: | ||
|
||
- chalk@5.3.0 | ||
- strip-ansi@7.1.0 | ||
|
||
These packages each contain the following license and notice below: | ||
|
||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com) | ||
|
||
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. | ||
|
||
----------- | ||
|
||
The following npm package may be included in this product: | ||
|
||
- cosmiconfig@9.0.0 | ||
|
||
This package contains the following license and notice below: | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 David Clark | ||
|
||
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. | ||
|
||
----------- | ||
|
||
This file was generated with the generate-license-file npm package! | ||
https://www.npmjs.com/package/generate-license-file |
14 changes: 14 additions & 0 deletions
14
packages/lilconfig-loader-ts/api-docs/lilconfig-loader-ts.api.md
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,14 @@ | ||
## API Report File for "@tylerbu/lilconfig-loader-ts" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
import type { Loader } from 'lilconfig'; | ||
|
||
// @alpha | ||
export const TypeScriptLoader: Loader; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
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 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "../../config/api-extractor.base.json", | ||
} |
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,11 @@ | ||
{ | ||
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json", | ||
"extends": ["../../biome.jsonc"], | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"noNodejsModules": "off", | ||
}, | ||
}, | ||
}, | ||
} |
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,57 @@ | ||
{ | ||
"name": "@tylerbu/lilconfig-loader-ts", | ||
"version": "0.0.1", | ||
"description": "A loader that enables loading TypeScript files in lilconfig.", | ||
"homepage": "https://github.com/tylerbutler/tools-monorepo/tree/main/packages/cli-api#tylerbucli-api", | ||
"bugs": "https://github.com/tylerbutler/tools-monorepo/issues", | ||
"repository": "tylerbutler/tylerbu-cli", | ||
"license": "MIT", | ||
"author": "Tyler Butler <tyler@tylerbutler.com>", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./esm/index.d.ts", | ||
"default": "./esm/index.js" | ||
} | ||
} | ||
}, | ||
"types": "./esm/index.d.ts", | ||
"files": ["/CHANGELOG.md", "/esm", "/THIRD-PARTY-LICENSES.txt"], | ||
"scripts": { | ||
"api": "api-extractor run --local", | ||
"api:markdown": "api-documenter markdown -i _temp/api-extractor -o _temp/docs", | ||
"build": "fluid-build . --task build", | ||
"check": "npm run check:format", | ||
"check:format": "biome format .", | ||
"clean": "rimraf esm _temp *.tsbuildinfo *.done.build.log", | ||
"compile": "tsc --project ./tsconfig.json", | ||
"format": "biome check . --linter-enabled=false --write", | ||
"full": "fluid-build . --task full", | ||
"lint": "biome lint .", | ||
"lint:fix": "biome lint . --write", | ||
"sort-package-json": "sort-package-json" | ||
}, | ||
"dependencies": { | ||
"jiti": "^2.4.2" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.9.4", | ||
"@microsoft/api-documenter": "^7.26.5", | ||
"@microsoft/api-extractor": "^7.49.1", | ||
"@types/node": "^20.12.7", | ||
"concurrently": "^9.1.2", | ||
"rimraf": "^6.0.1", | ||
"tslib": "^2.8.1", | ||
"type-fest": "^4.33.0", | ||
"typescript": "~5.5.4", | ||
"vitest": "^3.0.2" | ||
}, | ||
"peerDependencies": { | ||
"lilconfig": "^3.1.2" | ||
}, | ||
"packageManager": "pnpm@9.11.0", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
} | ||
} |
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,13 @@ | ||
LICENSE | ||
README.md | ||
THIRD-PARTY-LICENSES.txt | ||
package.json | ||
esm/index.d.ts | ||
esm/index.d.ts.map | ||
esm/index.js | ||
esm/index.js.map | ||
esm/loader.d.ts | ||
esm/loader.d.ts.map | ||
esm/loader.js | ||
esm/loader.js.map | ||
esm/tsdoc-metadata.json |
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 { TypeScriptLoader } from "./loader.js"; |
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,27 @@ | ||
import { createJiti } from "jiti"; | ||
import type { Loader, LoaderResult } from "lilconfig"; | ||
|
||
/** | ||
* A jiti instance to import modules. | ||
*/ | ||
const jiti = createJiti(import.meta.url); | ||
|
||
/** | ||
* A barebones TypeScript module importer. It imports and returns the default export from the TypeScript file at | ||
* filepath. | ||
* | ||
* @param filepath - The path to a TypeScript file to load. | ||
* @param _contents - The contents of the config file. **This property is unused. TypeScript modules are always loaded | ||
* from the file system.** | ||
* @throws If the file cannot be found or imported. | ||
* | ||
* @alpha | ||
*/ | ||
export const TypeScriptLoader: Loader = async ( | ||
filepath: string, | ||
_contents: string, | ||
): Promise<LoaderResult> => { | ||
// If the file doesn't exist, this will throw an error. | ||
const modDefault = await jiti.import(filepath, { default: true }); | ||
return modDefault; | ||
}; |
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,9 @@ | ||
{ | ||
"extends": "../../config/tsconfig.strict.json", | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./esm", | ||
}, | ||
"types": ["node"], | ||
} |
Oops, something went wrong.