From f2c8e55349a7bf6121ca85001a5322492ecf8f31 Mon Sep 17 00:00:00 2001 From: tal Date: Sun, 12 Nov 2023 10:50:47 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=94=A5=20allow=20TypeScript=20con?= =?UTF-8?q?figuration=20for=20the=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit allow TypeScript configuration for the package --- README.md | 4 +--- package.json | 5 +++-- pnpm-lock.yaml | 25 ++++++++++++++++++------- src/utils/configuration.ts | 2 ++ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 825034ca..51983364 100644 --- a/README.md +++ b/README.md @@ -88,9 +88,7 @@ Configuration can be set in environment variables or in the following files (the - a `package.json` property: `"czvinyl": {...}` or in `~/package.json`, for example - a `.czvinylrc` file in JSON or YAML format - a `.czvinylrc.json`, `.czvinylrc.yaml`, `.czvinylrc.yml`, `.czvinylrc.js`, or `.czvinylrc.cjs` file -- a `czvinyl.config.js`, or `czvinyl.config.cjs` CommonJS module exporting an object - -Currently, a TypeScript configuration file is not supported: https://github.com/Codex-/cosmiconfig-typescript-loader/issues/60 +- a `inflint.config.ts`, `czvinyl.config.js`, or `czvinyl.config.cjs` CommonJS module exporting an object The default commit types, descriptions and emoji that are used are: diff --git a/package.json b/package.json index 06ef1188..11903669 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ }, "dependencies": { "cosmiconfig": "8.3.6", + "cosmiconfig-typescript-loader": "5.0.0", "fuse.js": "7.0.0", "inquirer-autocomplete-prompt": "2.0.1", "inquirer-maxlength-input-prompt": "1.0.2", @@ -76,13 +77,13 @@ "@exlint.io/inflint": "2.0.0", "@types/inquirer": "9.0.6", "@types/inquirer-autocomplete-prompt": "3.0.0", - "@vitest/coverage-v8": "0.34.6", "@types/json-diff": "1.0.1", "@types/node": "20.8.10", "@types/string-template": "1.0.4", "@types/webpack-node-externals": "3.0.3", "@typescript-eslint/eslint-plugin": "6.9.1", "@typescript-eslint/parser": "6.9.1", + "@vitest/coverage-v8": "0.34.6", "chalk": "5.3.0", "commitizen": "4.3.0", "commitlint": "18.2.0", @@ -107,10 +108,10 @@ "rimraf": "5.0.5", "ts-loader": "9.5.0", "ts-node": "10.9.1", - "vitest": "0.34.6", "tsconfig-paths-webpack-plugin": "4.1.0", "typescript": "5.2.2", "vite-tsconfig-paths": "4.2.1", + "vitest": "0.34.6", "webpack": "5.89.0", "webpack-cli": "5.1.4", "webpack-node-externals": "3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c5d345a6..deb30068 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ dependencies: cosmiconfig: specifier: 8.3.6 version: 8.3.6(typescript@5.2.2) + cosmiconfig-typescript-loader: + specifier: 5.0.0 + version: 5.0.0(@types/node@20.8.10)(cosmiconfig@8.3.6)(typescript@5.2.2) fuse.js: specifier: 7.0.0 version: 7.0.0 @@ -2484,10 +2487,24 @@ packages: dependencies: '@types/node': 18.18.7 cosmiconfig: 8.3.6(typescript@5.2.2) - jiti: 1.19.3 + jiti: 1.21.0 typescript: 5.2.2 dev: true + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.8.10)(cosmiconfig@8.3.6)(typescript@5.2.2): + resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} + engines: {node: '>=v16'} + peerDependencies: + '@types/node': '*' + cosmiconfig: '>=8.2' + typescript: '>=4' + dependencies: + '@types/node': 20.8.10 + cosmiconfig: 8.3.6(typescript@5.2.2) + jiti: 1.21.0 + typescript: 5.2.2 + dev: false + /cosmiconfig@7.0.1: resolution: {integrity: sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==} engines: {node: '>=10'} @@ -4470,15 +4487,9 @@ packages: supports-color: 8.1.1 dev: true - /jiti@1.19.3: - resolution: {integrity: sha512-5eEbBDQT/jF1xg6l36P+mWGGoH9Spuy0PCdSr2dtWRDGC6ph/w9ZCL4lmESW8f8F7MwT3XKescfP0wnZWAKL9w==} - hasBin: true - dev: true - /jiti@1.21.0: resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} hasBin: true - dev: true /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} diff --git a/src/utils/configuration.ts b/src/utils/configuration.ts index 6b3bb809..276b44a2 100644 --- a/src/utils/configuration.ts +++ b/src/utils/configuration.ts @@ -1,4 +1,5 @@ import { cosmiconfig } from 'cosmiconfig'; +import { TypeScriptLoader } from 'cosmiconfig-typescript-loader'; import { DEFAULT_CONFIGURATION } from '../constants/configuration'; import { CONFIGURATION_MODULE_NAME, SEARCH_PLACES } from '../constants/cosmiconfig'; @@ -18,6 +19,7 @@ export const getConfiguration = async () => { const explorer = cosmiconfig(CONFIGURATION_MODULE_NAME, { searchPlaces: SEARCH_PLACES, + loaders: { '.ts': TypeScriptLoader() }, }); try {