@seekrit/cli 0.3.0 → 0.4.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/dist/index.js +15 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -315,7 +315,7 @@ async function unwrapDek(wrapped, privateKey) {
|
|
|
315
315
|
}
|
|
316
316
|
//#endregion
|
|
317
317
|
//#region package.json
|
|
318
|
-
var version = "0.
|
|
318
|
+
var version = "0.4.0";
|
|
319
319
|
const PROJECT_FILE = "seekrit.json";
|
|
320
320
|
function globalConfigPath() {
|
|
321
321
|
return join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "seekrit", "config.json");
|
|
@@ -563,12 +563,19 @@ async function readStdin() {
|
|
|
563
563
|
* Build the client context from configured credentials, or return null when
|
|
564
564
|
* none are set. `seekrit run` uses this to degrade to a plain launcher instead
|
|
565
565
|
* of exiting; every other command goes through `buildContext`, which fails.
|
|
566
|
+
*
|
|
567
|
+
* `dotenvVars` supplies `SEEKRIT_*` values read from a `.env` file. They sit
|
|
568
|
+
* below the live `process.env` but above the saved config, so a project-local
|
|
569
|
+
* `.env` can carry the token / API URL — matching `seekrit-run`'s
|
|
570
|
+
* `flag > env > .env` credential resolution. Empty for every command but
|
|
571
|
+
* `seekrit run`, which loads `.env` before authenticating.
|
|
566
572
|
*/
|
|
567
|
-
function tryBuildContext() {
|
|
573
|
+
function tryBuildContext(dotenvVars = {}) {
|
|
568
574
|
const config = readGlobalConfig();
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
const
|
|
575
|
+
const fromEnv = (key) => process.env[key] ?? dotenvVars[key];
|
|
576
|
+
const apiUrl = fromEnv("SEEKRIT_API_URL") ?? config.apiUrl ?? "https://api.seekrit.dev";
|
|
577
|
+
const token = fromEnv("SEEKRIT_TOKEN") ?? config.token;
|
|
578
|
+
const devUser = fromEnv("SEEKRIT_DEV_USER") ?? config.devUser;
|
|
572
579
|
let auth;
|
|
573
580
|
if (token) auth = {
|
|
574
581
|
type: "bearer",
|
|
@@ -1028,8 +1035,10 @@ async function materialize(ctx, options) {
|
|
|
1028
1035
|
*/
|
|
1029
1036
|
async function materializeForRun(options) {
|
|
1030
1037
|
const envFiles = options.envFile ?? [".env"];
|
|
1038
|
+
const dotenvVars = {};
|
|
1039
|
+
overlayEnvFiles(dotenvVars, {}, envFiles);
|
|
1031
1040
|
try {
|
|
1032
|
-
const ctx = tryBuildContext();
|
|
1041
|
+
const ctx = tryBuildContext(dotenvVars);
|
|
1033
1042
|
if (!ctx) throw new Error("no credentials found (set SEEKRIT_TOKEN / SEEKRIT_DEV_USER or run `seekrit login`)");
|
|
1034
1043
|
return await materialize(ctx, options);
|
|
1035
1044
|
} catch (err) {
|