From 5e40979041cfcf6d6e1318d96884a1580026a7e2 Mon Sep 17 00:00:00 2001 From: Meron Ogbai <22526062+meronogbai@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:00:38 +0300 Subject: [PATCH] feat: add typescript declaration --- lib/dotenv-flow-webpack.d.ts | 25 +++++++++++++++++++++++++ package.json | 3 +++ tsconfig.json | 8 ++++++++ yarn.lock | 5 +++++ 4 files changed, 41 insertions(+) create mode 100644 lib/dotenv-flow-webpack.d.ts create mode 100644 tsconfig.json diff --git a/lib/dotenv-flow-webpack.d.ts b/lib/dotenv-flow-webpack.d.ts new file mode 100644 index 0000000..883afad --- /dev/null +++ b/lib/dotenv-flow-webpack.d.ts @@ -0,0 +1,25 @@ +export = DotenvFlow; +declare class DotenvFlow extends DefinePlugin { + /** + * @param {object} [options] - initialization options + * @param {string} [options.node_env=process.env.NODE_ENV] - node environment (development/test/production/etc,.) + * @param {string} [options.default_node_env] - the default node environment + * @param {string} [options.path=process.cwd()] - path to `.env*` files directory + * @param {string} [options.pattern='.env[.node_env][.local]'] - naming + * @param {BufferEncoding|null} [options.encoding='utf8'] - encoding for reading the `.env*` files + * @param {boolean} [options.system_vars=false] - set to `true` to load all the predefined `process.env.*` variables + * @param {boolean} [options.debug=false] - turn on detailed logging to help debug why certain variables are not being set as you expect + * @param {boolean} [options.silent=false] - suppress all kinds of warnings including ".env*" files' loading errors + */ + constructor(options?: { + node_env?: string; + default_node_env?: string; + path?: string; + pattern?: string; + encoding?: BufferEncoding | null; + system_vars?: boolean; + debug?: boolean; + silent?: boolean; + }); +} +import { DefinePlugin } from "webpack"; diff --git a/package.json b/package.json index 8d1c378..335895f 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "url": "https://github.com/kerimdzhanov/dotenv-flow-webpack/issues" }, "main": "lib/dotenv-flow-webpack.js", + "types": "lib/dotenv-flow-webpack.d.ts", "files": [], "peerDependencies": { "webpack": "^1 || ^2 || ^3 || ^4 || ^5" @@ -38,6 +39,7 @@ "mocha": "^10.2.0", "sinon": "^16.0.0", "sinon-chai": "^3.7.0", + "typescript": "^5.5.4", "webpack": "^5.88.2" }, "engines": { @@ -45,6 +47,7 @@ }, "scripts": { "test": "mocha -r mocha.conf.js test/*.spec.js", + "generate-types": "tsc", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" }, "author": "Dan Kerimdzhanov", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5a6aeb3 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "include": ["./lib/**/*.js"], + "compilerOptions": { + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true + } +} diff --git a/yarn.lock b/yarn.lock index 167d96f..4de148d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2033,6 +2033,11 @@ type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + uglify-js@^3.1.4: version "3.6.0" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"