mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
feat(credentials): link directories to team secrets (#129)
This commit is contained in:
parent
e4723f31b1
commit
12a1d7f479
7 changed files with 265 additions and 27 deletions
|
|
@ -16,15 +16,15 @@ export const CLI_DEFAULT_API = "https://app.logicsrc.com";
|
|||
* @param {string} origin - the origin this request arrived on
|
||||
* @returns {string} the card's HTML
|
||||
*/
|
||||
// Vaults are addressed as <team> <project> <env> -- three positionals. Anything
|
||||
// shorter exits with "missing required argument", so a hint that omits one is
|
||||
// not merely stale, it fails on paste. `--env <path>` is the local .env file
|
||||
// and already defaults to .env; spelling it out here only invites confusion
|
||||
// with the <env> positional next to it.
|
||||
// The short workflow is deliberately directory-linked: up/down must never
|
||||
// guess a remote target. The explicit push/pull commands remain available,
|
||||
// but the dashboard teaches the safer link-once flow people use every day.
|
||||
export const CLI_HINT = (origin) => `<div class="card" style="margin-bottom:22px"><div class="card-head"><span class="h">Connect the CLI</span><span class="pill on">end-to-end encrypted</span></div>
|
||||
<div class="card-body">
|
||||
<p class="dim" style="margin-top:0;font-size:.9rem">Secrets are encrypted on your machine — decrypt them with the <code>logicsrc</code> CLI, never here.</p>
|
||||
<pre class="mono" style="background:var(--surface-2);border:1px solid var(--line);border-radius:8px;padding:12px;overflow:auto;font-size:.8rem;margin:0">${origin === CLI_DEFAULT_API ? "" : `LOGICSRC_API=${esc(origin)} `}logicsrc login
|
||||
logicsrc teams push <team> <project> <env> # share
|
||||
logicsrc teams pull <team> <project> <env> # receive</pre>
|
||||
cd /path/to/your/project
|
||||
logicsrc secrets teams link # select team → project → env
|
||||
logicsrc secrets up # share this project's .env
|
||||
logicsrc secrets down [env] # receive default or named env</pre>
|
||||
</div></div>`;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
// The dashboard's "Connect the CLI" card kept printing commands that no longer
|
||||
// ran. It survived two releases of drift: `logicsrc teams push <team> prod` is
|
||||
// two positionals, and since vaults became <team> <project> <env> the CLI exits
|
||||
// with a usage error on paste. It also told everyone to set LOGICSRC_API to the
|
||||
// value the CLI already defaults to, which reads like a required step.
|
||||
//
|
||||
// A card that hands out commands is only useful if the commands run, so these
|
||||
// pin the shape rather than the prose -- restyling the card is free, quietly
|
||||
// dropping an argument is not.
|
||||
// The dashboard's "Connect the CLI" card is the copy/paste entry point for the
|
||||
// directory-linked workflow. Pin the actual commands so the hosted app cannot
|
||||
// drift back to verbose targets or imply that up/down work without a link.
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
|
|
@ -22,16 +16,14 @@ const commands = (origin) =>
|
|||
|
||||
const HOSTED = "https://app.logicsrc.com";
|
||||
|
||||
test("push and pull carry all three vault positionals", () => {
|
||||
for (const verb of ["push", "pull"]) {
|
||||
const line = commands(HOSTED).find((l) => l.includes(`teams ${verb}`));
|
||||
assert.ok(line, `no teams ${verb} line`);
|
||||
assert.match(line, /teams (push|pull) <team> <project> <env>/);
|
||||
// Guards the specific regression: two positionals used to be enough.
|
||||
// Drop "logicsrc teams <verb>" and count only what follows.
|
||||
const args = line.split("#")[0].trim().split(/\s+/).slice(3);
|
||||
assert.equal(args.length, 3, `teams ${verb} needs 3 args, got ${args.join(" ")}`);
|
||||
}
|
||||
test("the dashboard teaches link before up and down", () => {
|
||||
const lines = commands(HOSTED);
|
||||
const link = lines.findIndex((line) => line.includes("secrets teams link"));
|
||||
const up = lines.findIndex((line) => line.includes("secrets up"));
|
||||
const down = lines.findIndex((line) => line.includes("secrets down [env]"));
|
||||
assert.ok(link >= 0, "no secrets teams link line");
|
||||
assert.ok(up > link, "secrets up must appear after link");
|
||||
assert.ok(down > link, "secrets down must appear after link");
|
||||
});
|
||||
|
||||
test("the local .env path is left at its default", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue