@bremmdev/arca-env 0.1.2 → 0.2.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/README.md CHANGED
@@ -53,6 +53,9 @@ arca is installed per project, so in a terminal you run it as `npx arca <command
53
53
  | `arca reveal NAME` / `arca export` | Show one value / print all (`--format dotenv\|json\|shell`, `--output file`) | ❌ person only |
54
54
  | `arca import [files] [--only A,B] [--delete]` | Move secrets from `.env` files into arca | ❌ person only |
55
55
  | `arca init [--yes] [--new-id]` | Set up a project | ✅ without the import |
56
+ | `arca use [profile]` / `arca use --reset` | Show or switch the active profile | ✅ (only when you ask) |
57
+ | `arca profiles` / `profiles add <name> [--extends p]` / `profiles diff <a> <b>` | List, add and compare profiles. Names only. | ✅ |
58
+ | `arca profiles copy <from> <to> [--only A,B]` / `profiles rm <name>` | Copy values between profiles / remove a profile and its values | ❌ person only |
56
59
  | `arca policy set agent-run deny` | Stop agents from getting secrets at all in this project | ❌ person only |
57
60
  | `arca projects [rm <id>]` | Projects with secrets on this machine | list ✅ |
58
61
 
@@ -77,6 +80,40 @@ arca is installed per project, so in a terminal you run it as `npx arca <command
77
80
  - `envFiles` (opt-in) lists `.env` files that arca loads itself, for tools that don't (plain `node`, `tsx`). Leave it empty for frameworks that load their own.
78
81
  - `leakGuard.ignore` silences the leak guard for specific names.
79
82
 
83
+ ## Profiles
84
+
85
+ A profile is a set of values for the project's variables. Say you have `ontwikkel` and `acceptatie`: the same variables, a few different values. All profiles are equal. You switch between them freely.
86
+
87
+ ```json
88
+ {
89
+ "defaultProfile": "ontwikkel",
90
+ "profiles": {
91
+ "ontwikkel": {},
92
+ "acceptatie": { "extends": "ontwikkel", "envFiles": [".env.acceptatie"] }
93
+ }
94
+ }
95
+ ```
96
+
97
+ - `extends` inherits every value the profile doesn't store itself, so `acceptatie` only stores what differs. Without it, seed a full copy with `npx arca profiles copy ontwikkel acceptatie`.
98
+ - `envFiles` lists non-sensitive config that arca loads for that profile. Use names frameworks don't load themselves (`.env.acceptatie`, not `.env.production`).
99
+ - Every value command takes `--profile` / `-p`: `npx arca set DATABASE_URL -p acceptatie`, `npx arca setup -p acceptatie`, `npx arca import .env.acceptatie -p acceptatie`.
100
+
101
+ ```console
102
+ $ npx arca use acceptatie
103
+ ✔ acme-web now uses profile acceptatie for every arca run on this machine
104
+ $ npm run dev
105
+ arca ▸ profile acceptatie (via arca use) · 3 secrets · output masked
106
+ $ npx arca use --reset
107
+ ```
108
+
109
+ `arca use` applies to every `arca run` of the project on this machine: your terminals, IDE tasks, git hooks and the scripts agents run. It's stored outside the repo, so teammates aren't affected. Which profile wins: `--profile` (a script can pin one: `"test": "arca run --profile test -- vitest"`), then `ARCA_PROFILE` for one terminal, then `arca use`, then `defaultProfile`. A run on any profile other than the default starts with the `arca ▸ profile …` line, and the app gets `ARCA_PROFILE=<name>`.
110
+
111
+ A profile only decides which values arca injects. It doesn't set `NODE_ENV` or change `next dev` into `next build`.
112
+
113
+ Output is masked with the values of **every** profile, so an `acceptatie` connection string that shows up during an `ontwikkel` run still prints as `[arca:DATABASE_URL@acceptatie]`. `npx arca list` shows one column per profile, and `npx arca profiles diff ontwikkel acceptatie` shows which values a profile sets itself and which it inherits.
114
+
115
+ `arca init` offers each `.env.<name>` file as a profile. A project that had values before it declared profiles keeps them: they move to the default profile on the first run.
116
+
80
117
  ## Secrets in arca, config in `.env`
81
118
 
82
119
  Who wins when a name is in more than one place: **arca, then your shell, then `.env` files**. When arca overrides a different value from your shell, it says so (by name, never by value). `--no-override` flips that for one run.
@@ -108,4 +145,4 @@ arca can't stop deliberate workarounds: an agent that hides its markers, edits `
108
145
 
109
146
  ## Status
110
147
 
111
- Version 0.1: one set of values per project. Profiles (several sets per project, switched with `arca use`), a PTY mode for fully interactive tools, an in-process loader for IDE test runners, and `arca scan` are planned.
148
+ Profiles (several sets of values per project, switched with `arca use`) are in. A PTY mode for fully interactive tools, an in-process loader for IDE test runners, and `arca scan` are planned.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as main, s as processIO } from "./main-Cy_OrS0c.mjs";
2
+ import { n as main, s as processIO } from "./main-B2iLn7kM.mjs";
3
3
  //#region src/cli.ts
4
4
  const code = await main(process.argv.slice(2), processIO());
5
5
  process.exitCode = code;
package/dist/index.d.mts CHANGED
@@ -106,6 +106,10 @@ interface VarDecl {
106
106
  encoding?: Encoding;
107
107
  };
108
108
  }
109
+ interface ProfileDecl {
110
+ extends?: string;
111
+ envFiles: string[];
112
+ }
109
113
  interface ArcaConfig {
110
114
  id: string;
111
115
  name: string;
@@ -114,6 +118,9 @@ interface ArcaConfig {
114
118
  ignore: string[];
115
119
  };
116
120
  vars: Record<string, VarDecl>;
121
+ /** Always holds at least the default profile. */
122
+ profiles: Record<string, ProfileDecl>;
123
+ defaultProfile: string;
117
124
  }
118
125
  //#endregion
119
126
  export { type AgentInfo, type ArcaConfig, type EnvEntry, type IO, type Needle, type OutStream, type Prompts, Redactor, type Secret, VERSION, type VarDecl, createMaskedWriter, detectAgent, detectCI, main, needlesFor, parseEnv, parseEnvEntries, processIO };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as detectAgent, i as parseEnvEntries, n as main, o as detectCI, r as parseEnv, s as processIO, t as VERSION } from "./main-Cy_OrS0c.mjs";
1
+ import { a as detectAgent, i as parseEnvEntries, n as main, o as detectCI, r as parseEnv, s as processIO, t as VERSION } from "./main-B2iLn7kM.mjs";
2
2
  import { n as createMaskedWriter, r as needlesFor, t as Redactor } from "./redact-D4Txfinc.mjs";
3
3
  export { Redactor, VERSION, createMaskedWriter, detectAgent, detectCI, main, needlesFor, parseEnv, parseEnvEntries, processIO };