@plurnk/plurnk-mimetypes-text-dotenv 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/Dotenv.d.ts +13 -0
- package/dist/Dotenv.d.ts.map +1 -0
- package/dist/Dotenv.js +58 -0
- package/dist/Dotenv.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PossumTech Laboratories, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @plurnk/plurnk-mimetypes-text-dotenv
|
|
2
|
+
|
|
3
|
+
`text/x-dotenv` (`.env`) mimetype handler for the [plurnk](https://github.com/plurnk) ecosystem. Hand-rolled, no parser dependency.
|
|
4
|
+
|
|
5
|
+
## install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm i @plurnk/plurnk-mimetypes-text-dotenv
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## what it does
|
|
12
|
+
|
|
13
|
+
- `extractRaw(content)` — each variable is a `constant` symbol at its line. `export ` prefixes are handled; comments (`#`) and non-variable lines are ignored.
|
|
14
|
+
- `deepJson(content)` — the `{ KEY: value }` map, a jsonpath target (`$.MODEL`). One layer of matching surrounding quotes is stripped; unquoted values are taken verbatim.
|
|
15
|
+
- `query(content, dialect, pattern)` — jsonpath against the value map; regex/glob against the raw text.
|
|
16
|
+
|
|
17
|
+
**Values are exposed, not redacted.** A `.env` file is config; plenty of workflows carry no secrets in it, so the handler treats values like any other configuration. The raw body is directly readable, so there is no content projection. References are not applicable.
|
|
18
|
+
|
|
19
|
+
## license
|
|
20
|
+
|
|
21
|
+
MIT.
|
package/dist/Dotenv.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseHandler } from "@plurnk/plurnk-mimetypes";
|
|
2
|
+
import type { HandlerContent, MimeSymbol } from "@plurnk/plurnk-mimetypes";
|
|
3
|
+
export default class Dotenv extends BaseHandler {
|
|
4
|
+
extractRaw(content: HandlerContent): MimeSymbol[];
|
|
5
|
+
deepJson(content: HandlerContent): unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface DotenvVar {
|
|
8
|
+
key: string;
|
|
9
|
+
value: string;
|
|
10
|
+
line: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseDotenv(text: string): DotenvVar[];
|
|
13
|
+
//# sourceMappingURL=Dotenv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dotenv.d.ts","sourceRoot":"","sources":["../src/Dotenv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAS3E,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IAClC,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,EAAE;IASjD,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;CAKtD;AAED,MAAM,WAAW,SAAS;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,CAcrD"}
|
package/dist/Dotenv.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BaseHandler } from "@plurnk/plurnk-mimetypes";
|
|
2
|
+
// text/x-dotenv (.env) handler — Tier 4, no parser dep.
|
|
3
|
+
//
|
|
4
|
+
// `KEY=value` lines, `#` comments, optional `export ` prefix, optional matching
|
|
5
|
+
// surrounding quotes. Each variable is a `constant` symbol; values are exposed
|
|
6
|
+
// like any other config (no redaction — plenty of .env workflows carry no
|
|
7
|
+
// secrets). deepJson is the `{ KEY: value }` map, a jsonpath target. The raw
|
|
8
|
+
// body is directly readable, so there is no content projection.
|
|
9
|
+
export default class Dotenv extends BaseHandler {
|
|
10
|
+
extractRaw(content) {
|
|
11
|
+
return parseDotenv(toText(content)).map((v) => ({
|
|
12
|
+
name: v.key,
|
|
13
|
+
kind: "constant",
|
|
14
|
+
line: v.line,
|
|
15
|
+
endLine: v.line,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
deepJson(content) {
|
|
19
|
+
const out = {};
|
|
20
|
+
for (const v of parseDotenv(toText(content)))
|
|
21
|
+
out[v.key] = v.value;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function parseDotenv(text) {
|
|
26
|
+
const out = [];
|
|
27
|
+
const lines = text.split("\n");
|
|
28
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
29
|
+
const trimmed = lines[i].trim();
|
|
30
|
+
if (trimmed.length === 0 || trimmed.startsWith("#"))
|
|
31
|
+
continue;
|
|
32
|
+
const body = trimmed.startsWith("export ") ? trimmed.slice(7).trimStart() : trimmed;
|
|
33
|
+
const eq = body.indexOf("=");
|
|
34
|
+
if (eq <= 0)
|
|
35
|
+
continue;
|
|
36
|
+
const key = body.slice(0, eq).trim();
|
|
37
|
+
if (!/^[A-Za-z_][A-Za-z0-9_.]*$/.test(key))
|
|
38
|
+
continue;
|
|
39
|
+
out.push({ key, value: stripQuotes(body.slice(eq + 1).trim()), line: i + 1 });
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
// Strip one layer of matching surrounding quotes (`"x"` / `'x'`). Unquoted
|
|
44
|
+
// values are taken verbatim — inline `#` is left in place (it is value content
|
|
45
|
+
// unless quoted away, and dotenv tools disagree on it; precision over a guess).
|
|
46
|
+
function stripQuotes(value) {
|
|
47
|
+
if (value.length >= 2) {
|
|
48
|
+
const first = value[0];
|
|
49
|
+
if ((first === '"' || first === "'") && value[value.length - 1] === first) {
|
|
50
|
+
return value.slice(1, -1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function toText(content) {
|
|
56
|
+
return typeof content === "string" ? content : new TextDecoder("utf-8").decode(content);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=Dotenv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dotenv.js","sourceRoot":"","sources":["../src/Dotenv.ts"],"names":[],"mappings":"AAAA,OAAO,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,CAAC,CAAC;AAC5F,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plurnk/plurnk-mimetypes-text-dotenv",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "text/x-dotenv (.env) mimetype handler for plurnk-service. Variables as symbols, values exposed. Hand-rolled, no parser dependency.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=25"
|
|
12
|
+
},
|
|
13
|
+
"plurnk": {
|
|
14
|
+
"kind": "mimetype",
|
|
15
|
+
"handlers": [
|
|
16
|
+
{
|
|
17
|
+
"name": "text/x-dotenv",
|
|
18
|
+
"glyph": "🔑",
|
|
19
|
+
"extensions": [
|
|
20
|
+
".env",
|
|
21
|
+
".env.local",
|
|
22
|
+
".env.development",
|
|
23
|
+
".env.production",
|
|
24
|
+
".env.test",
|
|
25
|
+
".env.example"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist/**/*",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test:lint": "tsc --noEmit",
|
|
43
|
+
"test:unit": "node --test src/**/*.test.ts",
|
|
44
|
+
"test": "npm run test:lint && npm run test:unit",
|
|
45
|
+
"build:dist": "tsc -p tsconfig.build.json",
|
|
46
|
+
"build": "npm run build:dist",
|
|
47
|
+
"prepare": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^25.8.0",
|
|
51
|
+
"typescript": "^6.0.3",
|
|
52
|
+
"@plurnk/plurnk-mimetypes": "^0.15.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@plurnk/plurnk-mimetypes": "^0.15.0"
|
|
56
|
+
}
|
|
57
|
+
}
|