envpkt 0.4.0 → 0.4.2
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 +42 -5
- package/dist/index.js +30 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { Command } from "commander";
|
|
4
6
|
import { Cond, Left, List, Option, Right, Try } from "functype";
|
|
5
|
-
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
8
9
|
import { TomlDate, parse, stringify } from "smol-toml";
|
|
@@ -225,14 +226,40 @@ const expandPath = (p) => {
|
|
|
225
226
|
return process.env[name] ?? "";
|
|
226
227
|
});
|
|
227
228
|
};
|
|
229
|
+
/**
|
|
230
|
+
* Expand a path template that may contain a single `*` glob segment.
|
|
231
|
+
* Returns all matching paths (or empty array if parent doesn't exist).
|
|
232
|
+
* Non-glob paths return a single-element array if they exist.
|
|
233
|
+
*/
|
|
234
|
+
const expandGlobPath = (expanded) => {
|
|
235
|
+
if (!expanded.includes("*")) return existsSync(expanded) ? [expanded] : [];
|
|
236
|
+
const segments = expanded.split("/");
|
|
237
|
+
const globIdx = segments.findIndex((s) => s.includes("*"));
|
|
238
|
+
if (globIdx < 0) return [];
|
|
239
|
+
const parentDir = segments.slice(0, globIdx).join("/");
|
|
240
|
+
const globSegment = segments[globIdx];
|
|
241
|
+
const suffix = segments.slice(globIdx + 1).join("/");
|
|
242
|
+
if (!existsSync(parentDir)) return [];
|
|
243
|
+
const prefix = globSegment.replace(/\*.*$/, "");
|
|
244
|
+
return readdirSync(parentDir).filter((entry) => entry.startsWith(prefix)).map((entry) => join(parentDir, entry, suffix)).filter((p) => existsSync(p));
|
|
245
|
+
};
|
|
228
246
|
/** Ordered candidate paths for config discovery beyond CWD */
|
|
229
247
|
const CONFIG_SEARCH_PATHS = [
|
|
230
248
|
"~/.envpkt/envpkt.toml",
|
|
249
|
+
"~/OneDrive/.envpkt/envpkt.toml",
|
|
250
|
+
"~/Library/CloudStorage/OneDrive-Personal/.envpkt/envpkt.toml",
|
|
251
|
+
"~/Library/CloudStorage/OneDrive-SharedLibraries-*/.envpkt/envpkt.toml",
|
|
231
252
|
"$WINHOME/OneDrive/.envpkt/envpkt.toml",
|
|
232
253
|
"$USERPROFILE/OneDrive/.envpkt/envpkt.toml",
|
|
254
|
+
"$OneDrive/.envpkt/envpkt.toml",
|
|
255
|
+
"$OneDriveConsumer/.envpkt/envpkt.toml",
|
|
256
|
+
"$OneDriveCommercial/.envpkt/envpkt.toml",
|
|
257
|
+
"/mnt/c/Users/$USER/OneDrive/.envpkt/envpkt.toml",
|
|
233
258
|
"~/Library/Mobile Documents/com~apple~CloudDocs/.envpkt/envpkt.toml",
|
|
234
259
|
"~/Dropbox/.envpkt/envpkt.toml",
|
|
235
260
|
"$DROPBOX_PATH/.envpkt/envpkt.toml",
|
|
261
|
+
"~/Google Drive/My Drive/.envpkt/envpkt.toml",
|
|
262
|
+
"~/Library/CloudStorage/GoogleDrive-*/.envpkt/envpkt.toml",
|
|
236
263
|
"$GOOGLE_DRIVE/.envpkt/envpkt.toml",
|
|
237
264
|
"$WINHOME/.envpkt/envpkt.toml",
|
|
238
265
|
"$USERPROFILE/.envpkt/envpkt.toml"
|
|
@@ -247,8 +274,10 @@ const discoverConfig = (cwd) => {
|
|
|
247
274
|
const customPaths = process.env.ENVPKT_SEARCH_PATH?.split(":").filter(Boolean) ?? [];
|
|
248
275
|
for (const template of [...customPaths, ...CONFIG_SEARCH_PATHS]) {
|
|
249
276
|
const expanded = expandPath(template);
|
|
250
|
-
if (expanded
|
|
251
|
-
|
|
277
|
+
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
278
|
+
const matches = expandGlobPath(expanded);
|
|
279
|
+
if (matches.length > 0) return Option({
|
|
280
|
+
path: matches[0],
|
|
252
281
|
source: "search"
|
|
253
282
|
});
|
|
254
283
|
}
|
|
@@ -2815,7 +2844,15 @@ const runShellHook = (shell) => {
|
|
|
2815
2844
|
//#endregion
|
|
2816
2845
|
//#region src/cli/index.ts
|
|
2817
2846
|
const program = new Command();
|
|
2818
|
-
program.name("envpkt").description("Credential lifecycle and fleet management for AI agents\n\n Developer workflow: env scan → catalog → cloud-synced folder → eval $(envpkt env export)\n Agent / CI workflow: catalog → audit --strict → seal → exec --strict → fleet").version(
|
|
2847
|
+
program.name("envpkt").description("Credential lifecycle and fleet management for AI agents\n\n Developer workflow: env scan → catalog → cloud-synced folder → eval $(envpkt env export)\n Agent / CI workflow: catalog → audit --strict → seal → exec --strict → fleet").version((() => {
|
|
2848
|
+
const findPkgJson = (dir) => {
|
|
2849
|
+
if (existsSync(join(dir, "package.json"))) return join(dir, "package.json");
|
|
2850
|
+
const parent = dirname(dir);
|
|
2851
|
+
return parent === dir ? "" : findPkgJson(parent);
|
|
2852
|
+
};
|
|
2853
|
+
const pkgPath = findPkgJson(dirname(fileURLToPath(import.meta.url)));
|
|
2854
|
+
return pkgPath ? JSON.parse(readFileSync(pkgPath, "utf-8")).version : "0.0.0";
|
|
2855
|
+
})());
|
|
2819
2856
|
program.command("init").description("Initialize a new envpkt.toml in the current directory").option("--from-fnox [path]", "Scaffold from fnox.toml (optionally specify path)").option("--catalog <path>", "Path to shared secret catalog").option("--agent", "Include [agent] section").option("--name <name>", "Agent name (requires --agent)").option("--capabilities <caps>", "Comma-separated capabilities (requires --agent)").option("--expires <date>", "Agent credential expiration YYYY-MM-DD (requires --agent)").option("--force", "Overwrite existing envpkt.toml").action((options) => {
|
|
2820
2857
|
runInit(process.cwd(), options);
|
|
2821
2858
|
});
|
package/dist/index.js
CHANGED
|
@@ -129,14 +129,40 @@ const findConfigPath = (dir) => {
|
|
|
129
129
|
const candidate = join(dir, CONFIG_FILENAME$1);
|
|
130
130
|
return existsSync(candidate) ? Option(candidate) : Option(void 0);
|
|
131
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Expand a path template that may contain a single `*` glob segment.
|
|
134
|
+
* Returns all matching paths (or empty array if parent doesn't exist).
|
|
135
|
+
* Non-glob paths return a single-element array if they exist.
|
|
136
|
+
*/
|
|
137
|
+
const expandGlobPath = (expanded) => {
|
|
138
|
+
if (!expanded.includes("*")) return existsSync(expanded) ? [expanded] : [];
|
|
139
|
+
const segments = expanded.split("/");
|
|
140
|
+
const globIdx = segments.findIndex((s) => s.includes("*"));
|
|
141
|
+
if (globIdx < 0) return [];
|
|
142
|
+
const parentDir = segments.slice(0, globIdx).join("/");
|
|
143
|
+
const globSegment = segments[globIdx];
|
|
144
|
+
const suffix = segments.slice(globIdx + 1).join("/");
|
|
145
|
+
if (!existsSync(parentDir)) return [];
|
|
146
|
+
const prefix = globSegment.replace(/\*.*$/, "");
|
|
147
|
+
return readdirSync(parentDir).filter((entry) => entry.startsWith(prefix)).map((entry) => join(parentDir, entry, suffix)).filter((p) => existsSync(p));
|
|
148
|
+
};
|
|
132
149
|
/** Ordered candidate paths for config discovery beyond CWD */
|
|
133
150
|
const CONFIG_SEARCH_PATHS = [
|
|
134
151
|
"~/.envpkt/envpkt.toml",
|
|
152
|
+
"~/OneDrive/.envpkt/envpkt.toml",
|
|
153
|
+
"~/Library/CloudStorage/OneDrive-Personal/.envpkt/envpkt.toml",
|
|
154
|
+
"~/Library/CloudStorage/OneDrive-SharedLibraries-*/.envpkt/envpkt.toml",
|
|
135
155
|
"$WINHOME/OneDrive/.envpkt/envpkt.toml",
|
|
136
156
|
"$USERPROFILE/OneDrive/.envpkt/envpkt.toml",
|
|
157
|
+
"$OneDrive/.envpkt/envpkt.toml",
|
|
158
|
+
"$OneDriveConsumer/.envpkt/envpkt.toml",
|
|
159
|
+
"$OneDriveCommercial/.envpkt/envpkt.toml",
|
|
160
|
+
"/mnt/c/Users/$USER/OneDrive/.envpkt/envpkt.toml",
|
|
137
161
|
"~/Library/Mobile Documents/com~apple~CloudDocs/.envpkt/envpkt.toml",
|
|
138
162
|
"~/Dropbox/.envpkt/envpkt.toml",
|
|
139
163
|
"$DROPBOX_PATH/.envpkt/envpkt.toml",
|
|
164
|
+
"~/Google Drive/My Drive/.envpkt/envpkt.toml",
|
|
165
|
+
"~/Library/CloudStorage/GoogleDrive-*/.envpkt/envpkt.toml",
|
|
140
166
|
"$GOOGLE_DRIVE/.envpkt/envpkt.toml",
|
|
141
167
|
"$WINHOME/.envpkt/envpkt.toml",
|
|
142
168
|
"$USERPROFILE/.envpkt/envpkt.toml"
|
|
@@ -151,8 +177,10 @@ const discoverConfig = (cwd) => {
|
|
|
151
177
|
const customPaths = process.env.ENVPKT_SEARCH_PATH?.split(":").filter(Boolean) ?? [];
|
|
152
178
|
for (const template of [...customPaths, ...CONFIG_SEARCH_PATHS]) {
|
|
153
179
|
const expanded = expandPath(template);
|
|
154
|
-
if (expanded
|
|
155
|
-
|
|
180
|
+
if (!expanded || expanded.startsWith("/.envpkt")) continue;
|
|
181
|
+
const matches = expandGlobPath(expanded);
|
|
182
|
+
if (matches.length > 0) return Option({
|
|
183
|
+
path: matches[0],
|
|
156
184
|
source: "search"
|
|
157
185
|
});
|
|
158
186
|
}
|