envpkt 0.6.5 → 0.6.7
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/dist/cli.js +44 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -14
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
7
7
|
import { Cond, Left, List, Option, Right, Try } from "functype";
|
|
8
|
-
import { Env, Fs, Path } from "functype-os";
|
|
8
|
+
import { Env, Fs, Path, Platform } from "functype-os";
|
|
9
9
|
import { TomlDate, parse, stringify } from "smol-toml";
|
|
10
10
|
import { FormatRegistry, Type } from "@sinclair/typebox";
|
|
11
11
|
import { execFileSync } from "node:child_process";
|
|
@@ -145,28 +145,26 @@ const expandGlobPath = (expanded) => {
|
|
|
145
145
|
const prefix = globSegment.replace(/\*.*$/, "");
|
|
146
146
|
return Fs.readdirSync(parentDir).fold(() => [], (entries) => entries.filter((entry) => entry.startsWith(prefix)).map((entry) => join(parentDir, entry, suffix)).filter((p) => Fs.existsSync(p)).toArray());
|
|
147
147
|
};
|
|
148
|
-
/**
|
|
149
|
-
const
|
|
150
|
-
"~/.envpkt/envpkt.toml",
|
|
151
|
-
"~/OneDrive/.envpkt/envpkt.toml",
|
|
152
|
-
"~/Library/CloudStorage/OneDrive-Personal/.envpkt/envpkt.toml",
|
|
153
|
-
"~/Library/CloudStorage/OneDrive-SharedLibraries-*/.envpkt/envpkt.toml",
|
|
148
|
+
/** Env-var fallback paths for cases where Platform detection misses */
|
|
149
|
+
const ENV_FALLBACK_PATHS = [
|
|
154
150
|
"$WINHOME/OneDrive/.envpkt/envpkt.toml",
|
|
155
151
|
"$USERPROFILE/OneDrive/.envpkt/envpkt.toml",
|
|
156
152
|
"$OneDrive/.envpkt/envpkt.toml",
|
|
157
153
|
"$OneDriveConsumer/.envpkt/envpkt.toml",
|
|
158
154
|
"$OneDriveCommercial/.envpkt/envpkt.toml",
|
|
159
|
-
"/mnt/c/Users/$USER/OneDrive/.envpkt/envpkt.toml",
|
|
160
|
-
"~/Library/Mobile Documents/com~apple~CloudDocs/.envpkt/envpkt.toml",
|
|
161
|
-
"~/Dropbox/.envpkt/envpkt.toml",
|
|
162
155
|
"$DROPBOX_PATH/.envpkt/envpkt.toml",
|
|
163
|
-
"~/Google Drive/My Drive/.envpkt/envpkt.toml",
|
|
164
|
-
"~/Library/CloudStorage/GoogleDrive-*/.envpkt/envpkt.toml",
|
|
165
156
|
"$GOOGLE_DRIVE/.envpkt/envpkt.toml",
|
|
166
157
|
"$WINHOME/.envpkt/envpkt.toml",
|
|
167
158
|
"$USERPROFILE/.envpkt/envpkt.toml"
|
|
168
159
|
];
|
|
169
|
-
/**
|
|
160
|
+
/** Build discovery paths dynamically from Platform home and cloud storage detection */
|
|
161
|
+
const buildSearchPaths = () => {
|
|
162
|
+
const paths = [];
|
|
163
|
+
for (const home of Platform.homeDirs().toArray()) paths.push(join(home, ".envpkt", CONFIG_FILENAME$2));
|
|
164
|
+
for (const cloud of Platform.cloudStorageDirs().toArray()) paths.push(join(cloud.path, ".envpkt", CONFIG_FILENAME$2));
|
|
165
|
+
return paths;
|
|
166
|
+
};
|
|
167
|
+
/** Discover config by checking CWD, then ENVPKT_SEARCH_PATH, then dynamic Platform paths */
|
|
170
168
|
const discoverConfig = (cwd) => {
|
|
171
169
|
const cwdCandidate = join(cwd ?? process.cwd(), CONFIG_FILENAME$2);
|
|
172
170
|
if (Fs.existsSync(cwdCandidate)) return Option({
|
|
@@ -174,7 +172,7 @@ const discoverConfig = (cwd) => {
|
|
|
174
172
|
source: "cwd"
|
|
175
173
|
});
|
|
176
174
|
const customPaths = Env.get("ENVPKT_SEARCH_PATH").fold(() => [], (v) => v.split(":").filter(Boolean));
|
|
177
|
-
for (const template of
|
|
175
|
+
for (const template of customPaths) {
|
|
178
176
|
const expanded = expandPath(template);
|
|
179
177
|
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
180
178
|
const matches = expandGlobPath(expanded);
|
|
@@ -183,6 +181,18 @@ const discoverConfig = (cwd) => {
|
|
|
183
181
|
source: "search"
|
|
184
182
|
});
|
|
185
183
|
}
|
|
184
|
+
for (const p of buildSearchPaths()) if (Fs.existsSync(p)) return Option({
|
|
185
|
+
path: p,
|
|
186
|
+
source: "search"
|
|
187
|
+
});
|
|
188
|
+
for (const template of ENV_FALLBACK_PATHS) {
|
|
189
|
+
const expanded = expandPath(template);
|
|
190
|
+
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
191
|
+
if (Fs.existsSync(expanded)) return Option({
|
|
192
|
+
path: expanded,
|
|
193
|
+
source: "search"
|
|
194
|
+
});
|
|
195
|
+
}
|
|
186
196
|
return Option(void 0);
|
|
187
197
|
};
|
|
188
198
|
/** Read a config file, returning Either<ConfigError, string> */
|
|
@@ -2440,10 +2450,7 @@ const printConfig = (config, path, resolveResult, opts) => {
|
|
|
2440
2450
|
console.log("");
|
|
2441
2451
|
console.log(`${BOLD}Environment Defaults:${RESET} ${envKeys.length}`);
|
|
2442
2452
|
for (const [key, entry] of Object.entries(envEntries)) {
|
|
2443
|
-
|
|
2444
|
-
const statusIcon = currentValue === void 0 ? `${RED}!${RESET}` : currentValue === entry.value ? `${GREEN}=${RESET}` : `${YELLOW}~${RESET}`;
|
|
2445
|
-
const statusLabel = currentValue === void 0 ? `${DIM}not set${RESET}` : currentValue === entry.value ? `${DIM}using default${RESET}` : `${YELLOW}overridden${RESET}`;
|
|
2446
|
-
console.log(` ${statusIcon} ${BOLD}${key}${RESET} = "${entry.value}" ${statusLabel}`);
|
|
2453
|
+
console.log(` ${BOLD}${key}${RESET} = "${entry.value}"`);
|
|
2447
2454
|
if (entry.purpose) console.log(` purpose: ${entry.purpose}`);
|
|
2448
2455
|
if (entry.comment) console.log(` comment: ${DIM}${entry.comment}${RESET}`);
|
|
2449
2456
|
}
|
|
@@ -2475,7 +2482,8 @@ const runInspect = (options) => {
|
|
|
2475
2482
|
console.error(formatError(err));
|
|
2476
2483
|
process.exit(2);
|
|
2477
2484
|
}, (config) => {
|
|
2478
|
-
|
|
2485
|
+
const configDir = dirname(path);
|
|
2486
|
+
resolveConfig(config, configDir).fold((err) => {
|
|
2479
2487
|
console.error(formatError(err));
|
|
2480
2488
|
process.exit(2);
|
|
2481
2489
|
}, (resolveResult) => {
|
|
@@ -2486,10 +2494,23 @@ const runInspect = (options) => {
|
|
|
2486
2494
|
return;
|
|
2487
2495
|
}
|
|
2488
2496
|
const showSecrets = showConfig.secret ?? {};
|
|
2489
|
-
const printOpts = options.secrets ? {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2497
|
+
const printOpts = options.secrets ? (() => {
|
|
2498
|
+
const sealedEntries = Object.fromEntries(Object.entries(showSecrets).filter(([, meta]) => meta.encrypted_value));
|
|
2499
|
+
return {
|
|
2500
|
+
secrets: Object.keys(sealedEntries).length > 0 ? (() => {
|
|
2501
|
+
const identityPath = showConfig.identity?.key_file ? resolve(configDir, expandPath(showConfig.identity.key_file)) : (() => {
|
|
2502
|
+
const defaultPath = resolveKeyPath();
|
|
2503
|
+
return existsSync(defaultPath) ? defaultPath : void 0;
|
|
2504
|
+
})();
|
|
2505
|
+
if (!identityPath) return {};
|
|
2506
|
+
return unsealSecrets(sealedEntries, identityPath).fold((err) => {
|
|
2507
|
+
console.error(`${YELLOW}Warning:${RESET} Could not decrypt sealed secrets: ${err.message}`);
|
|
2508
|
+
return {};
|
|
2509
|
+
}, (d) => d);
|
|
2510
|
+
})() : {},
|
|
2511
|
+
secretDisplay: options.plaintext ? "plaintext" : "encrypted"
|
|
2512
|
+
};
|
|
2513
|
+
})() : void 0;
|
|
2493
2514
|
printConfig(showConfig, path, showResolved ? resolveResult : void 0, printOpts);
|
|
2494
2515
|
});
|
|
2495
2516
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -315,7 +315,7 @@ type DiscoveredConfig = {
|
|
|
315
315
|
readonly path: string;
|
|
316
316
|
readonly source: "cwd" | "search";
|
|
317
317
|
};
|
|
318
|
-
/** Discover config by checking CWD, then ENVPKT_SEARCH_PATH, then
|
|
318
|
+
/** Discover config by checking CWD, then ENVPKT_SEARCH_PATH, then dynamic Platform paths */
|
|
319
319
|
declare const discoverConfig: (cwd?: string) => Option<DiscoveredConfig>;
|
|
320
320
|
/** Read a config file, returning Either<ConfigError, string> */
|
|
321
321
|
declare const readConfigFile: (path: string) => Either<ConfigError, string>;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { FormatRegistry, Type } from "@sinclair/typebox";
|
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
4
4
|
import { Cond, Left, List, None, Option, Right, Some, Try } from "functype";
|
|
5
|
-
import { Env, Fs, Path } from "functype-os";
|
|
5
|
+
import { Env, Fs, Path, Platform } from "functype-os";
|
|
6
6
|
import { TomlDate, parse } from "smol-toml";
|
|
7
7
|
import { chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { execFileSync } from "node:child_process";
|
|
@@ -149,28 +149,26 @@ const expandGlobPath = (expanded) => {
|
|
|
149
149
|
const prefix = globSegment.replace(/\*.*$/, "");
|
|
150
150
|
return Fs.readdirSync(parentDir).fold(() => [], (entries) => entries.filter((entry) => entry.startsWith(prefix)).map((entry) => join(parentDir, entry, suffix)).filter((p) => Fs.existsSync(p)).toArray());
|
|
151
151
|
};
|
|
152
|
-
/**
|
|
153
|
-
const
|
|
154
|
-
"~/.envpkt/envpkt.toml",
|
|
155
|
-
"~/OneDrive/.envpkt/envpkt.toml",
|
|
156
|
-
"~/Library/CloudStorage/OneDrive-Personal/.envpkt/envpkt.toml",
|
|
157
|
-
"~/Library/CloudStorage/OneDrive-SharedLibraries-*/.envpkt/envpkt.toml",
|
|
152
|
+
/** Env-var fallback paths for cases where Platform detection misses */
|
|
153
|
+
const ENV_FALLBACK_PATHS = [
|
|
158
154
|
"$WINHOME/OneDrive/.envpkt/envpkt.toml",
|
|
159
155
|
"$USERPROFILE/OneDrive/.envpkt/envpkt.toml",
|
|
160
156
|
"$OneDrive/.envpkt/envpkt.toml",
|
|
161
157
|
"$OneDriveConsumer/.envpkt/envpkt.toml",
|
|
162
158
|
"$OneDriveCommercial/.envpkt/envpkt.toml",
|
|
163
|
-
"/mnt/c/Users/$USER/OneDrive/.envpkt/envpkt.toml",
|
|
164
|
-
"~/Library/Mobile Documents/com~apple~CloudDocs/.envpkt/envpkt.toml",
|
|
165
|
-
"~/Dropbox/.envpkt/envpkt.toml",
|
|
166
159
|
"$DROPBOX_PATH/.envpkt/envpkt.toml",
|
|
167
|
-
"~/Google Drive/My Drive/.envpkt/envpkt.toml",
|
|
168
|
-
"~/Library/CloudStorage/GoogleDrive-*/.envpkt/envpkt.toml",
|
|
169
160
|
"$GOOGLE_DRIVE/.envpkt/envpkt.toml",
|
|
170
161
|
"$WINHOME/.envpkt/envpkt.toml",
|
|
171
162
|
"$USERPROFILE/.envpkt/envpkt.toml"
|
|
172
163
|
];
|
|
173
|
-
/**
|
|
164
|
+
/** Build discovery paths dynamically from Platform home and cloud storage detection */
|
|
165
|
+
const buildSearchPaths = () => {
|
|
166
|
+
const paths = [];
|
|
167
|
+
for (const home of Platform.homeDirs().toArray()) paths.push(join(home, ".envpkt", CONFIG_FILENAME$1));
|
|
168
|
+
for (const cloud of Platform.cloudStorageDirs().toArray()) paths.push(join(cloud.path, ".envpkt", CONFIG_FILENAME$1));
|
|
169
|
+
return paths;
|
|
170
|
+
};
|
|
171
|
+
/** Discover config by checking CWD, then ENVPKT_SEARCH_PATH, then dynamic Platform paths */
|
|
174
172
|
const discoverConfig = (cwd) => {
|
|
175
173
|
const cwdCandidate = join(cwd ?? process.cwd(), CONFIG_FILENAME$1);
|
|
176
174
|
if (Fs.existsSync(cwdCandidate)) return Option({
|
|
@@ -178,7 +176,7 @@ const discoverConfig = (cwd) => {
|
|
|
178
176
|
source: "cwd"
|
|
179
177
|
});
|
|
180
178
|
const customPaths = Env.get("ENVPKT_SEARCH_PATH").fold(() => [], (v) => v.split(":").filter(Boolean));
|
|
181
|
-
for (const template of
|
|
179
|
+
for (const template of customPaths) {
|
|
182
180
|
const expanded = expandPath(template);
|
|
183
181
|
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
184
182
|
const matches = expandGlobPath(expanded);
|
|
@@ -187,6 +185,18 @@ const discoverConfig = (cwd) => {
|
|
|
187
185
|
source: "search"
|
|
188
186
|
});
|
|
189
187
|
}
|
|
188
|
+
for (const p of buildSearchPaths()) if (Fs.existsSync(p)) return Option({
|
|
189
|
+
path: p,
|
|
190
|
+
source: "search"
|
|
191
|
+
});
|
|
192
|
+
for (const template of ENV_FALLBACK_PATHS) {
|
|
193
|
+
const expanded = expandPath(template);
|
|
194
|
+
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
195
|
+
if (Fs.existsSync(expanded)) return Option({
|
|
196
|
+
path: expanded,
|
|
197
|
+
source: "search"
|
|
198
|
+
});
|
|
199
|
+
}
|
|
190
200
|
return Option(void 0);
|
|
191
201
|
};
|
|
192
202
|
/** Read a config file, returning Either<ConfigError, string> */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envpkt",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Credential lifecycle and fleet management for AI agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"credentials",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"@sinclair/typebox": "^0.34.48",
|
|
44
44
|
"commander": "^14.0.3",
|
|
45
45
|
"functype": "^0.49.0",
|
|
46
|
-
"functype-os": "^0.
|
|
46
|
+
"functype-os": "^0.3.0",
|
|
47
47
|
"smol-toml": "^1.6.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/node": "^24.
|
|
50
|
+
"@types/node": "^24.12.0",
|
|
51
51
|
"ts-builds": "^2.5.0",
|
|
52
52
|
"tsdown": "^0.20.3",
|
|
53
53
|
"tsx": "^4.21.0"
|