@powerlines/plugin-env 0.16.67 → 0.16.69
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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -2
- package/dist/_virtual/_rolldown/runtime.mjs +2 -31
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +37 -27
- package/dist/components/docs.mjs +37 -27
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +404 -314
- package/dist/components/env-builtin.mjs +404 -314
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/helpers/automd-generator.mjs.map +1 -1
- package/dist/helpers/create-reflection-resource.mjs.map +1 -1
- package/dist/helpers/docs-helper.mjs.map +1 -1
- package/dist/helpers/load.cjs +4 -4
- package/dist/helpers/load.mjs +2 -2
- package/dist/helpers/load.mjs.map +1 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/reflect.mjs.map +1 -1
- package/dist/helpers/source-file-env.mjs.map +1 -1
- package/dist/helpers/template-helpers.mjs.map +1 -1
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +20 -35
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.cjs +0 -346
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs +0 -347
- package/dist/node_modules/.pnpm/c12@3.3.3_magicast@0.5.2/node_modules/c12/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.cjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs +0 -23
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/_format.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.cjs +0 -10
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/json.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.cjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs +0 -1060
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/js-yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.cjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs +0 -761
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.cjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs +0 -388
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/jsonc-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.cjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs +0 -639
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/libs/smol-toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.cjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs +0 -17
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/_chunks/rolldown-runtime.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.cjs +0 -13
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs +0 -14
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/json5.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/jsonc.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/toml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.cjs +0 -11
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs +0 -12
- package/dist/node_modules/.pnpm/confbox@0.2.4/node_modules/confbox/dist/yaml.mjs.map +0 -1
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -46
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.cjs +0 -285
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs +0 -283
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/lib/main.mjs.map +0 -1
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.cjs +0 -71
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs +0 -69
- package/dist/node_modules/.pnpm/dotenv@17.3.1/node_modules/dotenv/package.mjs.map +0 -1
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1008
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.cjs +0 -23
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs +0 -14
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.cjs +0 -2695
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs +0 -2683
- package/dist/node_modules/.pnpm/giget@2.0.0/node_modules/giget/dist/shared/giget.OCaTp9b-.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.cjs +0 -4457
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs +0 -4455
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/dist/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.cjs +0 -29
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs +0 -30
- package/dist/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -181
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -177
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -22
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3967
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3963
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.cjs +0 -11766
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs +0 -11762
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/proxy.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs +0 -25
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs +0 -21
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.mjs.map +0 -1
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.cjs +0 -20
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs +0 -18
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/lib/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.cjs +0 -178
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs +0 -176
- package/dist/node_modules/.pnpm/nypm@0.6.5/node_modules/nypm/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.cjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs +0 -13
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/crypto/node/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.cjs +0 -3
- package/dist/node_modules/.pnpm/ohash@2.0.11/node_modules/ohash/dist/index.mjs +0 -3
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -145
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -139
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs.map +0 -1
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -128
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -127
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.cjs +0 -138
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs +0 -137
- package/dist/node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs.map +0 -1
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.cjs +0 -629
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs +0 -628
- package/dist/node_modules/.pnpm/tinyexec@1.0.2/node_modules/tinyexec/dist/main.mjs.map +0 -1
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_index = require('../../../../destr@2.0.5/node_modules/destr/dist/index.cjs');
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
|
-
let node_os = require("node:os");
|
|
6
|
-
let defu = require("defu");
|
|
7
|
-
|
|
8
|
-
//#region ../../node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
|
|
9
|
-
function isBuffer(obj) {
|
|
10
|
-
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
11
|
-
}
|
|
12
|
-
function keyIdentity(key) {
|
|
13
|
-
return key;
|
|
14
|
-
}
|
|
15
|
-
function flatten(target, opts) {
|
|
16
|
-
opts = opts || {};
|
|
17
|
-
const delimiter = opts.delimiter || ".";
|
|
18
|
-
const maxDepth = opts.maxDepth;
|
|
19
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
20
|
-
const output = {};
|
|
21
|
-
function step(object, prev, currentDepth) {
|
|
22
|
-
currentDepth = currentDepth || 1;
|
|
23
|
-
Object.keys(object).forEach(function(key) {
|
|
24
|
-
const value = object[key];
|
|
25
|
-
const isarray = opts.safe && Array.isArray(value);
|
|
26
|
-
const type = Object.prototype.toString.call(value);
|
|
27
|
-
const isbuffer = isBuffer(value);
|
|
28
|
-
const isobject = type === "[object Object]" || type === "[object Array]";
|
|
29
|
-
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
|
30
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
|
|
31
|
-
output[newKey] = value;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
step(target);
|
|
35
|
-
return output;
|
|
36
|
-
}
|
|
37
|
-
function unflatten(target, opts) {
|
|
38
|
-
opts = opts || {};
|
|
39
|
-
const delimiter = opts.delimiter || ".";
|
|
40
|
-
const overwrite = opts.overwrite || false;
|
|
41
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
42
|
-
const result = {};
|
|
43
|
-
if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
|
|
44
|
-
function getkey(key) {
|
|
45
|
-
const parsedKey = Number(key);
|
|
46
|
-
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
|
47
|
-
}
|
|
48
|
-
function addKeys(keyPrefix, recipient, target) {
|
|
49
|
-
return Object.keys(target).reduce(function(result, key) {
|
|
50
|
-
result[keyPrefix + delimiter + key] = target[key];
|
|
51
|
-
return result;
|
|
52
|
-
}, recipient);
|
|
53
|
-
}
|
|
54
|
-
function isEmpty(val) {
|
|
55
|
-
const type = Object.prototype.toString.call(val);
|
|
56
|
-
const isArray = type === "[object Array]";
|
|
57
|
-
const isObject = type === "[object Object]";
|
|
58
|
-
if (!val) return true;
|
|
59
|
-
else if (isArray) return !val.length;
|
|
60
|
-
else if (isObject) return !Object.keys(val).length;
|
|
61
|
-
}
|
|
62
|
-
target = Object.keys(target).reduce(function(result, key) {
|
|
63
|
-
const type = Object.prototype.toString.call(target[key]);
|
|
64
|
-
if (!(type === "[object Object]" || type === "[object Array]") || isEmpty(target[key])) {
|
|
65
|
-
result[key] = target[key];
|
|
66
|
-
return result;
|
|
67
|
-
} else return addKeys(key, result, flatten(target[key], opts));
|
|
68
|
-
}, {});
|
|
69
|
-
Object.keys(target).forEach(function(key) {
|
|
70
|
-
const split = key.split(delimiter).map(transformKey);
|
|
71
|
-
let key1 = getkey(split.shift());
|
|
72
|
-
let key2 = getkey(split[0]);
|
|
73
|
-
let recipient = result;
|
|
74
|
-
while (key2 !== void 0) {
|
|
75
|
-
if (key1 === "__proto__") return;
|
|
76
|
-
const type = Object.prototype.toString.call(recipient[key1]);
|
|
77
|
-
const isobject = type === "[object Object]" || type === "[object Array]";
|
|
78
|
-
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
|
|
79
|
-
if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
|
80
|
-
recipient = recipient[key1];
|
|
81
|
-
if (split.length > 0) {
|
|
82
|
-
key1 = getkey(split.shift());
|
|
83
|
-
key2 = getkey(split[0]);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
recipient[key1] = unflatten(target[key], opts);
|
|
87
|
-
});
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
|
|
91
|
-
const RE_LINES = /\n|\r|\r\n/;
|
|
92
|
-
const defaults = {
|
|
93
|
-
name: ".conf",
|
|
94
|
-
dir: process.cwd(),
|
|
95
|
-
flat: false
|
|
96
|
-
};
|
|
97
|
-
function withDefaults(options) {
|
|
98
|
-
if (typeof options === "string") options = { name: options };
|
|
99
|
-
return {
|
|
100
|
-
...defaults,
|
|
101
|
-
...options
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function parse(contents, options = {}) {
|
|
105
|
-
const config = {};
|
|
106
|
-
const lines = contents.split(RE_LINES);
|
|
107
|
-
for (const line of lines) {
|
|
108
|
-
const match = line.match(RE_KEY_VAL);
|
|
109
|
-
if (!match) continue;
|
|
110
|
-
const key = match[1];
|
|
111
|
-
if (!key || key === "__proto__" || key === "constructor") continue;
|
|
112
|
-
const value = require_index.destr((match[2] || "").trim());
|
|
113
|
-
if (key.endsWith("[]")) {
|
|
114
|
-
const nkey = key.slice(0, Math.max(0, key.length - 2));
|
|
115
|
-
config[nkey] = (config[nkey] || []).concat(value);
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
config[key] = value;
|
|
119
|
-
}
|
|
120
|
-
return options.flat ? config : unflatten(config, { overwrite: true });
|
|
121
|
-
}
|
|
122
|
-
function parseFile(path, options) {
|
|
123
|
-
if (!(0, node_fs.existsSync)(path)) return {};
|
|
124
|
-
return parse((0, node_fs.readFileSync)(path, "utf8"), options);
|
|
125
|
-
}
|
|
126
|
-
function read(options) {
|
|
127
|
-
options = withDefaults(options);
|
|
128
|
-
return parseFile((0, node_path.resolve)(options.dir, options.name), options);
|
|
129
|
-
}
|
|
130
|
-
function readUser(options) {
|
|
131
|
-
options = withDefaults(options);
|
|
132
|
-
options.dir = process.env.XDG_CONFIG_HOME || (0, node_os.homedir)();
|
|
133
|
-
return read(options);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//#endregion
|
|
137
|
-
exports.read = read;
|
|
138
|
-
exports.readUser = readUser;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { destr } from "../../../../destr@2.0.5/node_modules/destr/dist/index.mjs";
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { defu as defu$1 } from "defu";
|
|
6
|
-
|
|
7
|
-
//#region ../../node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
|
|
8
|
-
function isBuffer(obj) {
|
|
9
|
-
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
10
|
-
}
|
|
11
|
-
function keyIdentity(key) {
|
|
12
|
-
return key;
|
|
13
|
-
}
|
|
14
|
-
function flatten(target, opts) {
|
|
15
|
-
opts = opts || {};
|
|
16
|
-
const delimiter = opts.delimiter || ".";
|
|
17
|
-
const maxDepth = opts.maxDepth;
|
|
18
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
19
|
-
const output = {};
|
|
20
|
-
function step(object, prev, currentDepth) {
|
|
21
|
-
currentDepth = currentDepth || 1;
|
|
22
|
-
Object.keys(object).forEach(function(key) {
|
|
23
|
-
const value = object[key];
|
|
24
|
-
const isarray = opts.safe && Array.isArray(value);
|
|
25
|
-
const type = Object.prototype.toString.call(value);
|
|
26
|
-
const isbuffer = isBuffer(value);
|
|
27
|
-
const isobject = type === "[object Object]" || type === "[object Array]";
|
|
28
|
-
const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
|
|
29
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
|
|
30
|
-
output[newKey] = value;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
step(target);
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
|
-
function unflatten(target, opts) {
|
|
37
|
-
opts = opts || {};
|
|
38
|
-
const delimiter = opts.delimiter || ".";
|
|
39
|
-
const overwrite = opts.overwrite || false;
|
|
40
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
41
|
-
const result = {};
|
|
42
|
-
if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
|
|
43
|
-
function getkey(key) {
|
|
44
|
-
const parsedKey = Number(key);
|
|
45
|
-
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
|
46
|
-
}
|
|
47
|
-
function addKeys(keyPrefix, recipient, target) {
|
|
48
|
-
return Object.keys(target).reduce(function(result, key) {
|
|
49
|
-
result[keyPrefix + delimiter + key] = target[key];
|
|
50
|
-
return result;
|
|
51
|
-
}, recipient);
|
|
52
|
-
}
|
|
53
|
-
function isEmpty(val) {
|
|
54
|
-
const type = Object.prototype.toString.call(val);
|
|
55
|
-
const isArray = type === "[object Array]";
|
|
56
|
-
const isObject = type === "[object Object]";
|
|
57
|
-
if (!val) return true;
|
|
58
|
-
else if (isArray) return !val.length;
|
|
59
|
-
else if (isObject) return !Object.keys(val).length;
|
|
60
|
-
}
|
|
61
|
-
target = Object.keys(target).reduce(function(result, key) {
|
|
62
|
-
const type = Object.prototype.toString.call(target[key]);
|
|
63
|
-
if (!(type === "[object Object]" || type === "[object Array]") || isEmpty(target[key])) {
|
|
64
|
-
result[key] = target[key];
|
|
65
|
-
return result;
|
|
66
|
-
} else return addKeys(key, result, flatten(target[key], opts));
|
|
67
|
-
}, {});
|
|
68
|
-
Object.keys(target).forEach(function(key) {
|
|
69
|
-
const split = key.split(delimiter).map(transformKey);
|
|
70
|
-
let key1 = getkey(split.shift());
|
|
71
|
-
let key2 = getkey(split[0]);
|
|
72
|
-
let recipient = result;
|
|
73
|
-
while (key2 !== void 0) {
|
|
74
|
-
if (key1 === "__proto__") return;
|
|
75
|
-
const type = Object.prototype.toString.call(recipient[key1]);
|
|
76
|
-
const isobject = type === "[object Object]" || type === "[object Array]";
|
|
77
|
-
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
|
|
78
|
-
if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
|
79
|
-
recipient = recipient[key1];
|
|
80
|
-
if (split.length > 0) {
|
|
81
|
-
key1 = getkey(split.shift());
|
|
82
|
-
key2 = getkey(split[0]);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
recipient[key1] = unflatten(target[key], opts);
|
|
86
|
-
});
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
|
|
90
|
-
const RE_LINES = /\n|\r|\r\n/;
|
|
91
|
-
const defaults = {
|
|
92
|
-
name: ".conf",
|
|
93
|
-
dir: process.cwd(),
|
|
94
|
-
flat: false
|
|
95
|
-
};
|
|
96
|
-
function withDefaults(options) {
|
|
97
|
-
if (typeof options === "string") options = { name: options };
|
|
98
|
-
return {
|
|
99
|
-
...defaults,
|
|
100
|
-
...options
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function parse(contents, options = {}) {
|
|
104
|
-
const config = {};
|
|
105
|
-
const lines = contents.split(RE_LINES);
|
|
106
|
-
for (const line of lines) {
|
|
107
|
-
const match = line.match(RE_KEY_VAL);
|
|
108
|
-
if (!match) continue;
|
|
109
|
-
const key = match[1];
|
|
110
|
-
if (!key || key === "__proto__" || key === "constructor") continue;
|
|
111
|
-
const value = destr((match[2] || "").trim());
|
|
112
|
-
if (key.endsWith("[]")) {
|
|
113
|
-
const nkey = key.slice(0, Math.max(0, key.length - 2));
|
|
114
|
-
config[nkey] = (config[nkey] || []).concat(value);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
config[key] = value;
|
|
118
|
-
}
|
|
119
|
-
return options.flat ? config : unflatten(config, { overwrite: true });
|
|
120
|
-
}
|
|
121
|
-
function parseFile(path, options) {
|
|
122
|
-
if (!existsSync(path)) return {};
|
|
123
|
-
return parse(readFileSync(path, "utf8"), options);
|
|
124
|
-
}
|
|
125
|
-
function read(options) {
|
|
126
|
-
options = withDefaults(options);
|
|
127
|
-
return parseFile(resolve(options.dir, options.name), options);
|
|
128
|
-
}
|
|
129
|
-
function readUser(options) {
|
|
130
|
-
options = withDefaults(options);
|
|
131
|
-
options.dir = process.env.XDG_CONFIG_HOME || homedir();
|
|
132
|
-
return read(options);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
export { read, readUser };
|
|
137
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../../node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { homedir } from 'node:os';\nimport destr from 'destr';\nimport { defu } from 'defu';\n\nfunction isBuffer (obj) {\n return obj &&\n obj.constructor &&\n (typeof obj.constructor.isBuffer === 'function') &&\n obj.constructor.isBuffer(obj)\n}\n\nfunction keyIdentity (key) {\n return key\n}\n\nfunction flatten (target, opts) {\n opts = opts || {};\n\n const delimiter = opts.delimiter || '.';\n const maxDepth = opts.maxDepth;\n const transformKey = opts.transformKey || keyIdentity;\n const output = {};\n\n function step (object, prev, currentDepth) {\n currentDepth = currentDepth || 1;\n Object.keys(object).forEach(function (key) {\n const value = object[key];\n const isarray = opts.safe && Array.isArray(value);\n const type = Object.prototype.toString.call(value);\n const isbuffer = isBuffer(value);\n const isobject = (\n type === '[object Object]' ||\n type === '[object Array]'\n );\n\n const newKey = prev\n ? prev + delimiter + transformKey(key)\n : transformKey(key);\n\n if (!isarray && !isbuffer && isobject && Object.keys(value).length &&\n (!opts.maxDepth || currentDepth < maxDepth)) {\n return step(value, newKey, currentDepth + 1)\n }\n\n output[newKey] = value;\n });\n }\n\n step(target);\n\n return output\n}\n\nfunction unflatten (target, opts) {\n opts = opts || {};\n\n const delimiter = opts.delimiter || '.';\n const overwrite = opts.overwrite || false;\n const transformKey = opts.transformKey || keyIdentity;\n const result = {};\n\n const isbuffer = isBuffer(target);\n if (isbuffer || Object.prototype.toString.call(target) !== '[object Object]') {\n return target\n }\n\n // safely ensure that the key is\n // an integer.\n function getkey (key) {\n const parsedKey = Number(key);\n\n return (\n isNaN(parsedKey) ||\n key.indexOf('.') !== -1 ||\n opts.object\n )\n ? key\n : parsedKey\n }\n\n function addKeys (keyPrefix, recipient, target) {\n return Object.keys(target).reduce(function (result, key) {\n result[keyPrefix + delimiter + key] = target[key];\n\n return result\n }, recipient)\n }\n\n function isEmpty (val) {\n const type = Object.prototype.toString.call(val);\n const isArray = type === '[object Array]';\n const isObject = type === '[object Object]';\n\n if (!val) {\n return true\n } else if (isArray) {\n return !val.length\n } else if (isObject) {\n return !Object.keys(val).length\n }\n }\n\n target = Object.keys(target).reduce(function (result, key) {\n const type = Object.prototype.toString.call(target[key]);\n const isObject = (type === '[object Object]' || type === '[object Array]');\n if (!isObject || isEmpty(target[key])) {\n result[key] = target[key];\n return result\n } else {\n return addKeys(\n key,\n result,\n flatten(target[key], opts)\n )\n }\n }, {});\n\n Object.keys(target).forEach(function (key) {\n const split = key.split(delimiter).map(transformKey);\n let key1 = getkey(split.shift());\n let key2 = getkey(split[0]);\n let recipient = result;\n\n while (key2 !== undefined) {\n if (key1 === '__proto__') {\n return\n }\n\n const type = Object.prototype.toString.call(recipient[key1]);\n const isobject = (\n type === '[object Object]' ||\n type === '[object Array]'\n );\n\n // do not write over falsey, non-undefined values if overwrite is false\n if (!overwrite && !isobject && typeof recipient[key1] !== 'undefined') {\n return\n }\n\n if ((overwrite && !isobject) || (!overwrite && recipient[key1] == null)) {\n recipient[key1] = (\n typeof key2 === 'number' &&\n !opts.object\n ? []\n : {}\n );\n }\n\n recipient = recipient[key1];\n if (split.length > 0) {\n key1 = getkey(split.shift());\n key2 = getkey(split[0]);\n }\n }\n\n // unflatten again for 'messy objects'\n recipient[key1] = unflatten(target[key], opts);\n });\n\n return result\n}\n\nconst RE_KEY_VAL = /^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/;\nconst RE_LINES = /\\n|\\r|\\r\\n/;\nconst defaults = {\n name: \".conf\",\n dir: process.cwd(),\n flat: false\n};\nfunction withDefaults(options) {\n if (typeof options === \"string\") {\n options = { name: options };\n }\n return { ...defaults, ...options };\n}\nfunction parse(contents, options = {}) {\n const config = {};\n const lines = contents.split(RE_LINES);\n for (const line of lines) {\n const match = line.match(RE_KEY_VAL);\n if (!match) {\n continue;\n }\n const key = match[1];\n if (!key || key === \"__proto__\" || key === \"constructor\") {\n continue;\n }\n const value = destr(\n (match[2] || \"\").trim()\n /* val */\n );\n if (key.endsWith(\"[]\")) {\n const nkey = key.slice(0, Math.max(0, key.length - 2));\n config[nkey] = (config[nkey] || []).concat(value);\n continue;\n }\n config[key] = value;\n }\n return options.flat ? config : unflatten(config, { overwrite: true });\n}\nfunction parseFile(path, options) {\n if (!existsSync(path)) {\n return {};\n }\n return parse(readFileSync(path, \"utf8\"), options);\n}\nfunction read(options) {\n options = withDefaults(options);\n return parseFile(resolve(options.dir, options.name), options);\n}\nfunction readUser(options) {\n options = withDefaults(options);\n options.dir = process.env.XDG_CONFIG_HOME || homedir();\n return read(options);\n}\nfunction serialize(config) {\n return Object.entries(flatten(config)).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join(\"\\n\");\n}\nfunction write(config, options) {\n options = withDefaults(options);\n writeFileSync(resolve(options.dir, options.name), serialize(config), {\n encoding: \"utf8\"\n });\n}\nfunction writeUser(config, options) {\n options = withDefaults(options);\n options.dir = process.env.XDG_CONFIG_HOME || homedir();\n write(config, options);\n}\nfunction update(config, options) {\n options = withDefaults(options);\n if (!options.flat) {\n config = unflatten(config, { overwrite: true });\n }\n const newConfig = defu(config, read(options));\n write(newConfig, options);\n return newConfig;\n}\nfunction updateUser(config, options) {\n options = withDefaults(options);\n options.dir = process.env.XDG_CONFIG_HOME || homedir();\n return update(config, options);\n}\n\nexport { defaults, parse, parseFile, read, readUser, serialize, update, updateUser, write, writeUser };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;AAMA,SAAS,SAAU,KAAK;AACtB,QAAO,OACL,IAAI,eACH,OAAO,IAAI,YAAY,aAAa,cACrC,IAAI,YAAY,SAAS,IAAI;;AAGjC,SAAS,YAAa,KAAK;AACzB,QAAO;;AAGT,SAAS,QAAS,QAAQ,MAAM;AAC9B,QAAO,QAAQ,EAAE;CAEjB,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,WAAW,KAAK;CACtB,MAAM,eAAe,KAAK,gBAAgB;CAC1C,MAAM,SAAS,EAAE;CAEjB,SAAS,KAAM,QAAQ,MAAM,cAAc;AACzC,iBAAe,gBAAgB;AAC/B,SAAO,KAAK,OAAO,CAAC,QAAQ,SAAU,KAAK;GACzC,MAAM,QAAQ,OAAO;GACrB,MAAM,UAAU,KAAK,QAAQ,MAAM,QAAQ,MAAM;GACjD,MAAM,OAAO,OAAO,UAAU,SAAS,KAAK,MAAM;GAClD,MAAM,WAAW,SAAS,MAAM;GAChC,MA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