@import-meta-env/typescript
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -84,10 +84,5 @@ var __create = Object.create; | ||
__export(src_exports, { | ||
default: () => src_default | ||
createDeclaration: () => create_declaration_default | ||
}); | ||
// src/core/index.ts | ||
var import_fs2 = require("fs"); | ||
var import_path2 = require("path"); | ||
var import_unplugin = require("unplugin"); | ||
// src/core/parse-env-example-keys.ts | ||
@@ -101,3 +96,3 @@ var import_fs = require("fs"); | ||
if ((0, import_fs.existsSync)(path) === false) { | ||
console.error((0, import_picocolors.red)("[import-meta-env] No .env.example file found.")); | ||
console.error((0, import_picocolors.red)("[@import-meta-env/typescript] No .env.example file found.")); | ||
return []; | ||
@@ -111,39 +106,23 @@ } | ||
// src/core/index.ts | ||
var createPlugin = (0, import_unplugin.createUnplugin)((options) => { | ||
return { | ||
name: "@import-meta-env/typescript", | ||
buildStart() { | ||
const dts = (() => { | ||
var _a; | ||
const outDir = (_a = options == null ? void 0 : options.outDir) != null ? _a : "."; | ||
return (0, import_path2.resolve)(process.cwd(), outDir, "import-meta-env.d.ts"); | ||
})(); | ||
if (dts === null) | ||
return; | ||
const envExampleKeys = parseEnvExampleKeys(options == null ? void 0 : options.example); | ||
const content = [ | ||
"// Generated by '@import-meta-env/typescript'", | ||
"", | ||
"interface ImportMetaEnv {", | ||
...envExampleKeys.map((key) => ` readonly ${key}: string;`), | ||
"}", | ||
"", | ||
"interface ImportMeta {", | ||
" readonly env: ImportMetaEnv;", | ||
"}", | ||
"" | ||
].join("\n"); | ||
const outputPath = (0, import_path2.resolve)(process.cwd(), dts); | ||
(0, import_fs2.writeFileSync)(outputPath, content, "utf8"); | ||
} | ||
}; | ||
// src/core/create-declaration.ts | ||
var createDeclaration = (options) => { | ||
const envExampleKeys = parseEnvExampleKeys(options.example); | ||
return [ | ||
"// Generated by '@import-meta-env/typescript'", | ||
"", | ||
"interface ImportMetaEnv {", | ||
...envExampleKeys.map((key) => ` readonly ${key}: string;`), | ||
"}", | ||
"", | ||
"interface ImportMeta {", | ||
" readonly env: ImportMetaEnv;", | ||
"}", | ||
"" | ||
].join("\n"); | ||
}; | ||
var create_declaration_default = createDeclaration; | ||
module.exports = __toCommonJS(src_exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
createDeclaration | ||
}); | ||
var core_default = createPlugin; | ||
// src/index.ts | ||
var src_default = core_default; | ||
module.exports = createPlugin; | ||
createPlugin['default'] = createPlugin; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = {}); |
{ | ||
"name": "@import-meta-env/typescript", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Automatically generate .d.ts from .env.example", | ||
"license": "MIT", | ||
"author": "Ernest", | ||
"keywords": [ | ||
"typescript", | ||
"unplugin", | ||
"rollup-plugin", | ||
"vite-plugin", | ||
"webpack-plugin", | ||
"twelve-factor", | ||
"dotenv" | ||
], | ||
"bin": { | ||
"import-meta-env-typescript": "bin/import-meta-env-typescript.js" | ||
}, | ||
"files": [ | ||
@@ -20,3 +14,3 @@ "dist" | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"types": "dist/src/index.d.ts", | ||
"engines": { | ||
@@ -42,12 +36,12 @@ "node": ">= 14" | ||
"dependencies": { | ||
"picocolors": "^1.0.0", | ||
"unplugin": "^0.3.2" | ||
"commander": "^9.0.0", | ||
"picocolors": "^1.0.0" | ||
}, | ||
"scripts": { | ||
"build": "rimraf dist bin && pnpm build-types && pnpm build-bundle", | ||
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:unplugin --external:dotenv --external:webpack --outfile=dist/index.js && pnpm run patch-dist", | ||
"build": "rimraf dist bin && pnpm build-types && pnpm build-bundle && pnpm build-bin", | ||
"build-bin": "esbuild src/bin.ts --bundle --platform=node --target=node12 --external:dotenv --external:webpack --outfile=bin/import-meta-env-typescript.js && node ./scripts/patchBin.js", | ||
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:dotenv --outfile=dist/index.js", | ||
"build-types": "tsc -p . --emitDeclarationOnly --outDir dist", | ||
"patch-dist": "node ./scripts/patchEsbuildDist.mjs", | ||
"release": "standard-version -t typescript --preset=conventionalcommits --releaseCommitMessageFormat 'chore(release): @import-meta-env/typescript@{{currentTag}}' --path . && pnpm build" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
78885
11
1905
15
2
+ Addedcommander@^9.0.0
+ Addedcommander@9.5.0(transitive)
- Removedunplugin@^0.3.2
- Removedunplugin@0.3.3(transitive)
- Removedwebpack-virtual-modules@0.4.6(transitive)