getmyenv 0.5.2 → 0.6.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 +57 -13
- package/dist/bin.js +1 -24
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +179 -101
- package/dist/cli.js.map +1 -1
- package/dist/commands/backup.d.ts +2 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +15 -25
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/claim.d.ts +2 -1
- package/dist/commands/claim.d.ts.map +1 -1
- package/dist/commands/claim.js +114 -82
- package/dist/commands/claim.js.map +1 -1
- package/dist/commands/context.d.ts +11 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +53 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/export.d.ts +11 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +67 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/guest.d.ts +9 -3
- package/dist/commands/guest.d.ts.map +1 -1
- package/dist/commands/guest.js +32 -30
- package/dist/commands/guest.js.map +1 -1
- package/dist/commands/import.d.ts +26 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +168 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/lock.d.ts +5 -0
- package/dist/commands/lock.d.ts.map +1 -0
- package/dist/commands/lock.js +18 -0
- package/dist/commands/lock.js.map +1 -0
- package/dist/commands/ls.d.ts +6 -0
- package/dist/commands/ls.d.ts.map +1 -0
- package/dist/commands/ls.js +37 -0
- package/dist/commands/ls.js.map +1 -0
- package/dist/commands/restore.d.ts +7 -2
- package/dist/commands/restore.d.ts.map +1 -1
- package/dist/commands/restore.js +58 -51
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/run.d.ts +7 -5
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +97 -185
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/set.d.ts +16 -0
- package/dist/commands/set.d.ts.map +1 -0
- package/dist/commands/set.js +111 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/start.d.ts +16 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +118 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +40 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/unlink.d.ts +9 -0
- package/dist/commands/unlink.d.ts.map +1 -0
- package/dist/commands/unlink.js +70 -0
- package/dist/commands/unlink.js.map +1 -0
- package/dist/lib/api-url.d.ts +12 -0
- package/dist/lib/api-url.d.ts.map +1 -1
- package/dist/lib/api-url.js +32 -0
- package/dist/lib/api-url.js.map +1 -1
- package/dist/lib/api.d.ts +35 -23
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +23 -59
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/authorize.d.ts +13 -6
- package/dist/lib/authorize.d.ts.map +1 -1
- package/dist/lib/authorize.js +68 -63
- package/dist/lib/authorize.js.map +1 -1
- package/dist/lib/bootstrap.d.ts +18 -15
- package/dist/lib/bootstrap.d.ts.map +1 -1
- package/dist/lib/bootstrap.js +59 -58
- package/dist/lib/bootstrap.js.map +1 -1
- package/dist/lib/confirm.js +4 -4
- package/dist/lib/confirm.js.map +1 -1
- package/dist/lib/context.d.ts +12 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/context.js +43 -0
- package/dist/lib/context.js.map +1 -0
- package/dist/lib/credentials.d.ts +8 -9
- package/dist/lib/credentials.d.ts.map +1 -1
- package/dist/lib/credentials.js +2 -10
- package/dist/lib/credentials.js.map +1 -1
- package/dist/lib/fs.d.ts +26 -37
- package/dist/lib/fs.d.ts.map +1 -1
- package/dist/lib/fs.js +112 -327
- package/dist/lib/fs.js.map +1 -1
- package/dist/lib/guest-key.d.ts +8 -6
- package/dist/lib/guest-key.d.ts.map +1 -1
- package/dist/lib/guest-key.js +26 -3
- package/dist/lib/guest-key.js.map +1 -1
- package/dist/lib/identity.d.ts +9 -11
- package/dist/lib/identity.d.ts.map +1 -1
- package/dist/lib/identity.js +34 -24
- package/dist/lib/identity.js.map +1 -1
- package/dist/lib/keychain.d.ts +21 -0
- package/dist/lib/keychain.d.ts.map +1 -0
- package/dist/lib/keychain.js +124 -0
- package/dist/lib/keychain.js.map +1 -0
- package/dist/lib/pek.d.ts +15 -22
- package/dist/lib/pek.d.ts.map +1 -1
- package/dist/lib/pek.js +31 -51
- package/dist/lib/pek.js.map +1 -1
- package/dist/lib/run-env.d.ts +50 -0
- package/dist/lib/run-env.d.ts.map +1 -0
- package/dist/lib/run-env.js +114 -0
- package/dist/lib/run-env.js.map +1 -0
- package/dist/lib/unlock.d.ts +24 -0
- package/dist/lib/unlock.d.ts.map +1 -0
- package/dist/lib/unlock.js +87 -0
- package/dist/lib/unlock.js.map +1 -0
- package/dist/lib/update-check.d.ts +4 -2
- package/dist/lib/update-check.d.ts.map +1 -1
- package/dist/lib/update-check.js +54 -68
- package/dist/lib/update-check.js.map +1 -1
- package/dist/lib/upload.d.ts +21 -0
- package/dist/lib/upload.d.ts.map +1 -0
- package/dist/lib/upload.js +53 -0
- package/dist/lib/upload.js.map +1 -0
- package/package.json +5 -3
- package/dist/commands/delete.d.ts +0 -6
- package/dist/commands/delete.d.ts.map +0 -1
- package/dist/commands/delete.js +0 -55
- package/dist/commands/delete.js.map +0 -1
- package/dist/commands/link.d.ts +0 -16
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -142
- package/dist/commands/link.js.map +0 -1
- package/dist/commands/pull.d.ts +0 -15
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js +0 -159
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/push.d.ts +0 -15
- package/dist/commands/push.d.ts.map +0 -1
- package/dist/commands/push.js +0 -262
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/remove.d.ts +0 -11
- package/dist/commands/remove.d.ts.map +0 -1
- package/dist/commands/remove.js +0 -39
- package/dist/commands/remove.js.map +0 -1
- package/dist/commands/token.d.ts +0 -14
- package/dist/commands/token.d.ts.map +0 -1
- package/dist/commands/token.js +0 -132
- package/dist/commands/token.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -6
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -46
- package/dist/commands/whoami.js.map +0 -1
- package/dist/lib/env-name.d.ts +0 -3
- package/dist/lib/env-name.d.ts.map +0 -1
- package/dist/lib/env-name.js +0 -5
- package/dist/lib/env-name.js.map +0 -1
- package/dist/lib/guest-key.test.d.ts +0 -2
- package/dist/lib/guest-key.test.d.ts.map +0 -1
- package/dist/lib/guest-key.test.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,31 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
CLI for [getmyenv](https://getmyenv.com) - encrypted environment variables for any language.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Keep using environment variables. Stop managing them as files.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
cd your-project
|
|
9
|
-
npx getmyenv
|
|
9
|
+
npx getmyenv # Start without an account, or Sign in
|
|
10
|
+
npx getmyenv import # encrypt and upload your .env
|
|
11
|
+
npx getmyenv run -- npm run dev # start with the default context
|
|
12
|
+
npx getmyenv run staging -- npm start # or pick one
|
|
10
13
|
```
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
- `getmyenv`: setup in a new folder, status in a linked one. Without a TTY it prints next steps and exits.
|
|
18
|
+
- `run [context] -- <cmd>`: resolve, validate, merge, spawn. A missing value stops the run and prints its name (`--allow-missing` to run anyway). getmyenv values replace the parent env and replaced names are printed (`--keep-existing` to keep parent values). `--explain` lists names and origins, never values.
|
|
19
|
+
- `status`: project, token, contexts and the run command.
|
|
20
|
+
- `context list | create "<name>" [--from <slug>] [--use] | use <slug>`
|
|
21
|
+
- `set KEY[=VALUE]... [--expires <date|never>]`, `set KEY --stdin`, `unset KEY... [--all]`, `ls`
|
|
22
|
+
- `import [file] [--prune] [--dry-run] [--yes]`: `.env.<slug>` goes to that context.
|
|
23
|
+
- `export [-o file | --stdout] [--yes]`: for tools that need a file. The file is added to `.gitignore` and gets owner-only permissions on macOS and Linux.
|
|
24
|
+
- `guest [--name <name>]`: a project without an account. It works for 30 days. Claim it within 60.
|
|
25
|
+
- `claim`: claim a guest project from `.getmyenv/claim.json`.
|
|
26
|
+
- `backup [-o file]`: encrypted backup of open contexts (default `<project>.getmyenv`).
|
|
27
|
+
- `restore <file> [--dry-run] [--yes]`
|
|
28
|
+
- `lock`, `unlink [--yes]`, `help [command]`
|
|
29
|
+
|
|
30
|
+
`run`, `set`, `unset`, `ls`, `import` and `export` take `-c, --context <slug>`. The default is the server token's context, then `context` in `.getmyenv/project.json`, then `development`.
|
|
31
|
+
|
|
32
|
+
`run`, `set`, `import`, `export` and `restore` take `--vault-password-stdin`. Every command takes `--api-url <url>`.
|
|
33
|
+
|
|
34
|
+
Prompts and status lines go to stderr, so `export --stdout > .env` stays clean.
|
|
35
|
+
|
|
36
|
+
## Vault password
|
|
37
|
+
|
|
38
|
+
For open contexts, after you enter the Vault password in a terminal, the unlocked project key stays in your OS keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service) for 8 hours. The password itself is never stored.
|
|
39
|
+
|
|
40
|
+
- `npx getmyenv lock` removes it. `unlink` removes it too.
|
|
41
|
+
- Locked contexts, CI and `--vault-password-stdin` ask on each run.
|
|
42
|
+
- Guest projects unlock with the passphrase in `.getmyenv/claim.json` and never ask.
|
|
43
|
+
- `GETMYENV_KEYCHAIN=0` always asks.
|
|
44
|
+
|
|
45
|
+
## CI and servers
|
|
13
46
|
|
|
14
47
|
```bash
|
|
15
|
-
npx getmyenv run --
|
|
48
|
+
printf %s "$VAULT_PASSWORD" | npx getmyenv run --vault-password-stdin -- node server.js
|
|
49
|
+
printf %s "$VALUE" | npx getmyenv set API_KEY --stdin
|
|
50
|
+
printf '%s\n%s' "$VAULT_PASSWORD" "$VALUE" | npx getmyenv set API_KEY --stdin --vault-password-stdin
|
|
16
51
|
```
|
|
17
52
|
|
|
18
|
-
|
|
53
|
+
Server tokens are read-only, so `set` needs the folder token from browser sign-in (or a guest project). With both `--stdin` and `--vault-password-stdin`, send the password on the first line and the value after it.
|
|
54
|
+
|
|
55
|
+
- `GETMYENV_TOKEN`: a token from the dashboard CLI page.
|
|
56
|
+
- `GETMYENV_CONFIG_DIR`: machine key and cache (default `~/.config/getmyenv`). Use a persistent volume in containers.
|
|
57
|
+
- `GETMYENV_API_URL`: API origin. https only, http for localhost.
|
|
58
|
+
- `GETMYENV_MACHINE_LABEL`: the machine name shown in approval requests.
|
|
59
|
+
- `GETMYENV_SKIP_UPDATE=1`: skip the update notice.
|
|
60
|
+
- `GETMYENV_KEYCHAIN=0`: never use the OS keychain.
|
|
61
|
+
- The update check and the keychain are skipped when `CI` is set (unless it is `false` or `0`).
|
|
19
62
|
|
|
20
|
-
|
|
21
|
-
- Production token: read-only (`run`, `backup`). Set Production values in the dashboard. Create the token with an IP allowlist; set `GETMYENV_TOKEN`. No browser day to day.
|
|
22
|
-
- Environment comes from token scope. Omit `-e` day to day.
|
|
23
|
-
- Forget this folder: `npx getmyenv delete` (local `.getmyenv/` only; vault stays on the server). Then re-run `run` or `push` to authorize again.
|
|
24
|
-
- CI: set `GETMYENV_TOKEN`.
|
|
63
|
+
## Open and Locked
|
|
25
64
|
|
|
26
|
-
|
|
65
|
+
- Open contexts: the CLI can read and write. Browser sign-in gives the folder a token in `.getmyenv/token.json`.
|
|
66
|
+
- Locked contexts: the CLI is read-only. Set values in the dashboard. Use a server token from the CLI page (one context, IP allowlist) with `GETMYENV_TOKEN`. New machines need approval unless trusted.
|
|
27
67
|
|
|
28
|
-
|
|
68
|
+
## Chaining
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
op run -- npx getmyenv run staging -- npm start
|
|
72
|
+
```
|
|
29
73
|
|
|
30
|
-
License: MIT (see [LICENSE](./LICENSE)). The hosted service at getmyenv.com
|
|
74
|
+
License: MIT (see [LICENSE](./LICENSE)). The hosted service at getmyenv.com has its own Terms.
|
|
31
75
|
|
|
32
76
|
See https://getmyenv.com/docs
|
package/dist/bin.js
CHANGED
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import os from "node:os";
|
|
5
2
|
import { runCli } from "./cli.js";
|
|
6
3
|
import { maybeSuggestUpdate } from "./lib/update-check.js";
|
|
7
|
-
/**
|
|
8
|
-
* One-shot retire of the machine-global credentials store from before 0.3.4.
|
|
9
|
-
* Silent: delete the file (secrets do not linger) and print one honest line so
|
|
10
|
-
* the user knows why the first verb in a folder asks to authorize.
|
|
11
|
-
*/
|
|
12
|
-
function retireLegacyCredentials() {
|
|
13
|
-
const base = process.env.GETMYENV_CONFIG_DIR?.trim() ||
|
|
14
|
-
path.join(os.homedir(), ".config", "getmyenv");
|
|
15
|
-
const file = path.join(base, "credentials.json");
|
|
16
|
-
if (!fs.existsSync(file))
|
|
17
|
-
return;
|
|
18
|
-
try {
|
|
19
|
-
fs.unlinkSync(file);
|
|
20
|
-
console.error("getmyenv: retired old ~/.config/getmyenv/credentials.json. Tokens now live in .getmyenv/token.json per folder.");
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
/* ignore */
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
4
|
async function main() {
|
|
27
|
-
retireLegacyCredentials();
|
|
28
5
|
await maybeSuggestUpdate();
|
|
29
6
|
await runCli(process.argv);
|
|
30
7
|
}
|
|
@@ -32,6 +9,6 @@ main().catch((err) => {
|
|
|
32
9
|
const message = err instanceof Error ? err.message : "Unexpected error";
|
|
33
10
|
// Never print secret values - sanitize to message only
|
|
34
11
|
console.error(`getmyenv: ${message}`);
|
|
35
|
-
process.exit(1);
|
|
12
|
+
process.exit(process.exitCode ? Number(process.exitCode) : 1);
|
|
36
13
|
});
|
|
37
14
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,KAAK,UAAU,IAAI;IACjB,MAAM,kBAAkB,EAAE,CAAC;IAC3B,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACxE,uDAAuD;IACvD,OAAO,CAAC,KAAK,CAAC,aAAa,OAAO,EAAE,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split `run` operands around `--`.
|
|
3
|
+
* `run staging -- npm start`: context staging, command npm start.
|
|
4
|
+
* `run -- npm start`: default context.
|
|
5
|
+
* `run npm start` (no `--`): the whole thing is the command.
|
|
6
|
+
*/
|
|
7
|
+
export declare function splitRunArgs(operands: string[], argv: string[], explain: boolean): {
|
|
8
|
+
context?: string;
|
|
9
|
+
command: string[];
|
|
10
|
+
};
|
|
1
11
|
export declare function runCli(argv: string[]): Promise<void>;
|
|
2
12
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AA+BA;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,OAAO,GACf;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CASzC;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8L1D"}
|
package/dist/cli.js
CHANGED
|
@@ -1,131 +1,209 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { backupCommand } from "./commands/backup.js";
|
|
3
|
+
import { claimCommand } from "./commands/claim.js";
|
|
4
|
+
import { contextCreateCommand, contextListCommand, contextUseCommand, } from "./commands/context.js";
|
|
5
|
+
import { exportCommand } from "./commands/export.js";
|
|
6
|
+
import { guestCommand } from "./commands/guest.js";
|
|
7
|
+
import { importCommand } from "./commands/import.js";
|
|
8
|
+
import { lockCommand } from "./commands/lock.js";
|
|
9
|
+
import { lsCommand } from "./commands/ls.js";
|
|
3
10
|
import { restoreCommand } from "./commands/restore.js";
|
|
4
11
|
import { runCommand } from "./commands/run.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function folderEnvOption() {
|
|
19
|
-
const meta = readProjectMeta();
|
|
20
|
-
return meta?.environment ?? "development";
|
|
21
|
-
}
|
|
22
|
-
const ENV_OPTION = [
|
|
23
|
-
"-e, --env <name>",
|
|
24
|
-
"Environment (must match token scope; omit to use the token)",
|
|
12
|
+
import { setCommand, unsetCommand } from "./commands/set.js";
|
|
13
|
+
import { startCommand } from "./commands/start.js";
|
|
14
|
+
import { statusCommand } from "./commands/status.js";
|
|
15
|
+
import { unlinkCommand } from "./commands/unlink.js";
|
|
16
|
+
import { CLI_VERSION } from "./lib/api.js";
|
|
17
|
+
const CONTEXT_OPTION = [
|
|
18
|
+
"-c, --context <slug>",
|
|
19
|
+
"Context to use (default: project.json context, then development)",
|
|
20
|
+
];
|
|
21
|
+
const API_OPTION = ["--api-url <url>", "API base URL"];
|
|
22
|
+
const STDIN_OPTION = [
|
|
23
|
+
"--vault-password-stdin",
|
|
24
|
+
"Read the Vault password from stdin (non-interactive)",
|
|
25
25
|
];
|
|
26
|
+
/**
|
|
27
|
+
* Split `run` operands around `--`.
|
|
28
|
+
* `run staging -- npm start`: context staging, command npm start.
|
|
29
|
+
* `run -- npm start`: default context.
|
|
30
|
+
* `run npm start` (no `--`): the whole thing is the command.
|
|
31
|
+
*/
|
|
32
|
+
export function splitRunArgs(operands, argv, explain) {
|
|
33
|
+
const dash = argv.indexOf("--");
|
|
34
|
+
if (dash >= 0) {
|
|
35
|
+
const command = argv.slice(dash + 1);
|
|
36
|
+
const before = operands.slice(0, Math.max(0, operands.length - command.length));
|
|
37
|
+
return { context: before[0], command };
|
|
38
|
+
}
|
|
39
|
+
if (explain && operands.length <= 1)
|
|
40
|
+
return { context: operands[0], command: [] };
|
|
41
|
+
return { command: operands };
|
|
42
|
+
}
|
|
26
43
|
export async function runCli(argv) {
|
|
27
|
-
const apiDefault = resolveApiUrl();
|
|
28
44
|
const program = new Command();
|
|
29
45
|
program
|
|
30
46
|
.name("getmyenv")
|
|
31
47
|
.description("Keep using environment variables. Stop managing them as files.")
|
|
32
|
-
.version(CLI_VERSION)
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
.version(CLI_VERSION)
|
|
49
|
+
.option(...API_OPTION)
|
|
50
|
+
.addHelpText("after", [
|
|
51
|
+
"",
|
|
52
|
+
"Environment:",
|
|
53
|
+
" GETMYENV_TOKEN Token for CI and servers (instead of .getmyenv/token.json)",
|
|
54
|
+
" GETMYENV_API_URL API base URL (https, or http://localhost)",
|
|
55
|
+
" GETMYENV_CONFIG_DIR Machine identity and cache dir (default ~/.config/getmyenv)",
|
|
56
|
+
" GETMYENV_SKIP_UPDATE Set to 1 to skip the update notice",
|
|
57
|
+
" GETMYENV_KEYCHAIN Set to 0 to always ask for the Vault password",
|
|
58
|
+
" GETMYENV_MACHINE_LABEL Name shown for this machine in access requests",
|
|
59
|
+
].join("\n"))
|
|
60
|
+
.helpCommand(true)
|
|
61
|
+
.action((opts) => startCommand(opts));
|
|
62
|
+
// The root owns --api-url wherever it appears, so hand it to the command that runs.
|
|
63
|
+
program.hook("preAction", (_root, actionCommand) => {
|
|
64
|
+
const apiUrl = program.opts().apiUrl;
|
|
65
|
+
if (apiUrl && actionCommand !== program && !actionCommand.opts().apiUrl) {
|
|
66
|
+
actionCommand.setOptionValue("apiUrl", apiUrl);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
39
69
|
program
|
|
40
70
|
.command("run")
|
|
41
|
-
.description("
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
|
|
71
|
+
.description("Run a command with a context's variables in its environment")
|
|
72
|
+
.usage("[context] [options] -- <command...>")
|
|
73
|
+
.addHelpText("after", [
|
|
74
|
+
"",
|
|
75
|
+
"Examples:",
|
|
76
|
+
" npx getmyenv run -- npm run dev",
|
|
77
|
+
" npx getmyenv run staging -- node server.js",
|
|
78
|
+
' printf %s "$VAULT_PASSWORD" | npx getmyenv run production --vault-password-stdin -- node server.js',
|
|
79
|
+
].join("\n"))
|
|
80
|
+
.argument("[context]", "Context slug (same as -c)")
|
|
81
|
+
.option(...CONTEXT_OPTION)
|
|
82
|
+
.option("--explain", "List each variable and where its value comes from (names only)")
|
|
83
|
+
.option("--keep-existing", "Keep variables already set in the parent environment")
|
|
84
|
+
.option("--allow-missing", "Run even when some variables have no value in this context")
|
|
85
|
+
.option(...STDIN_OPTION)
|
|
86
|
+
.option(...API_OPTION)
|
|
45
87
|
.allowUnknownOption(true)
|
|
46
88
|
.allowExcessArguments(true)
|
|
47
|
-
.action(async (opts, cmd) => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
env: normalizeEnvName(opts.env ?? folderEnvOption()),
|
|
54
|
-
envWasDefault: envWasDefaultFromArgv(),
|
|
55
|
-
apiUrl: opts.apiUrl ?? apiDefault,
|
|
56
|
-
}, childArgs);
|
|
89
|
+
.action(async (_ctx, opts, cmd) => {
|
|
90
|
+
const split = splitRunArgs(cmd.args, argv, opts.explain === true);
|
|
91
|
+
if (opts.context && split.context && opts.context !== split.context) {
|
|
92
|
+
throw new Error(`Two contexts given: ${split.context} and -c ${opts.context}. Pick one.`);
|
|
93
|
+
}
|
|
94
|
+
await runCommand({ ...opts, context: opts.context ?? split.context }, split.command);
|
|
57
95
|
});
|
|
58
96
|
program
|
|
59
|
-
.command("
|
|
60
|
-
.description("
|
|
61
|
-
.option(...
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.
|
|
66
|
-
.
|
|
67
|
-
.option(
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
97
|
+
.command("status")
|
|
98
|
+
.description("Show project, token, contexts and the run command")
|
|
99
|
+
.option(...API_OPTION)
|
|
100
|
+
.action((opts) => statusCommand(opts));
|
|
101
|
+
const context = program.command("context").description("List, create or pick contexts");
|
|
102
|
+
context
|
|
103
|
+
.command("list", { isDefault: true })
|
|
104
|
+
.description("List contexts (* marks this folder's default)")
|
|
105
|
+
.option(...API_OPTION)
|
|
106
|
+
.action((opts) => contextListCommand(opts));
|
|
107
|
+
context
|
|
108
|
+
.command("create <name>")
|
|
109
|
+
.description('Create an open context, e.g. context create "Customer Acme"')
|
|
110
|
+
.option("--from <slug>", "Copy values from an open context")
|
|
111
|
+
.option("--use", "Make it this folder's default")
|
|
112
|
+
.option(...API_OPTION)
|
|
113
|
+
.action((name, opts) => contextCreateCommand(name, opts));
|
|
114
|
+
context
|
|
115
|
+
.command("use <slug>")
|
|
116
|
+
.description("Set this folder's default context (saved in project.json)")
|
|
117
|
+
.option(...API_OPTION)
|
|
118
|
+
.action((slug, opts) => contextUseCommand(slug, opts));
|
|
74
119
|
program
|
|
75
|
-
.command("
|
|
76
|
-
.description("
|
|
77
|
-
.
|
|
78
|
-
.
|
|
120
|
+
.command("set")
|
|
121
|
+
.description("Set values: set KEY=VALUE, or set KEY to be prompted")
|
|
122
|
+
.argument("<pairs...>", "KEY or KEY=VALUE")
|
|
123
|
+
.option(...CONTEXT_OPTION)
|
|
124
|
+
.option("--expires <date>", "Expiry date, e.g. 2026-12-31, or never")
|
|
125
|
+
.option("--stdin", "Read the value of one KEY from stdin (keeps it out of argv)")
|
|
126
|
+
.option(...STDIN_OPTION)
|
|
127
|
+
.option(...API_OPTION)
|
|
128
|
+
.action((pairs, opts) => setCommand(pairs, opts));
|
|
129
|
+
program
|
|
130
|
+
.command("unset")
|
|
131
|
+
.description("Remove values from a context")
|
|
132
|
+
.argument("<names...>", "Variable names")
|
|
133
|
+
.option(...CONTEXT_OPTION)
|
|
134
|
+
.option("--all", "Delete the variable from every context")
|
|
135
|
+
.option(...API_OPTION)
|
|
136
|
+
.action((names, opts) => unsetCommand(names, opts));
|
|
137
|
+
program
|
|
138
|
+
.command("ls")
|
|
139
|
+
.description("Variable names by context with status (never values)")
|
|
140
|
+
.option(...CONTEXT_OPTION)
|
|
141
|
+
.option(...API_OPTION)
|
|
142
|
+
.action((opts) => lsCommand(opts));
|
|
143
|
+
program
|
|
144
|
+
.command("import")
|
|
145
|
+
.description("Encrypt a .env file and upload it (.env.<slug> goes to that context)")
|
|
146
|
+
.argument("[file]", "Env file (default: .env files in this folder)")
|
|
147
|
+
.option(...CONTEXT_OPTION)
|
|
148
|
+
.option("--prune", "Unset values in the context that are not in the file")
|
|
149
|
+
.option("--dry-run", "Show what would change without uploading")
|
|
150
|
+
.option("--yes", "Do not ask for confirmation")
|
|
151
|
+
.option(...STDIN_OPTION)
|
|
152
|
+
.option(...API_OPTION)
|
|
153
|
+
.action((file, opts) => importCommand(file, opts));
|
|
79
154
|
program
|
|
80
|
-
.command("
|
|
81
|
-
.description("
|
|
82
|
-
.option(...
|
|
155
|
+
.command("export")
|
|
156
|
+
.description("Write a context to a plaintext .env file, for tools that need one")
|
|
157
|
+
.option(...CONTEXT_OPTION)
|
|
83
158
|
.option("-o, --output <file>", "Output file", ".env")
|
|
84
|
-
.option("--to <file>", "Alias for --output")
|
|
85
159
|
.option("--stdout", "Write to stdout instead of a file")
|
|
86
|
-
.option("--yes", "
|
|
87
|
-
.option(
|
|
88
|
-
.option(
|
|
89
|
-
.
|
|
90
|
-
.option("--vault-password-stdin", "Read vault password from stdin (non-interactive)")
|
|
91
|
-
.action((opts) => pullCommand({
|
|
92
|
-
...opts,
|
|
93
|
-
env: normalizeEnvName(opts.env ?? folderEnvOption()),
|
|
94
|
-
envWasDefault: envWasDefaultFromArgv(),
|
|
95
|
-
}));
|
|
160
|
+
.option("--yes", "Change an existing file without asking")
|
|
161
|
+
.option(...STDIN_OPTION)
|
|
162
|
+
.option(...API_OPTION)
|
|
163
|
+
.action((opts) => exportCommand(opts));
|
|
96
164
|
program
|
|
97
|
-
.command("
|
|
98
|
-
.description("
|
|
99
|
-
.option("--
|
|
100
|
-
.
|
|
165
|
+
.command("guest")
|
|
166
|
+
.description("Create a guest project without an account. It works for 30 days. Claim it within 60.")
|
|
167
|
+
.option("--name <name>", "Project name (default: folder name)")
|
|
168
|
+
.option(...API_OPTION)
|
|
169
|
+
.action((opts) => guestCommand(opts));
|
|
170
|
+
program
|
|
171
|
+
.command("claim")
|
|
172
|
+
.description("Claim a guest project from .getmyenv/claim.json")
|
|
173
|
+
.option(...API_OPTION)
|
|
174
|
+
.action((opts) => claimCommand(opts));
|
|
101
175
|
program
|
|
102
176
|
.command("backup")
|
|
103
|
-
.description("
|
|
104
|
-
.option("-o, --output <file>", "Output file")
|
|
105
|
-
.option(
|
|
106
|
-
.action(backupCommand);
|
|
177
|
+
.description("Write an encrypted backup of open contexts")
|
|
178
|
+
.option("-o, --output <file>", "Output file (default: <project>.getmyenv)")
|
|
179
|
+
.option(...API_OPTION)
|
|
180
|
+
.action((opts) => backupCommand(opts));
|
|
107
181
|
program
|
|
108
182
|
.command("restore <file>")
|
|
109
|
-
.description("Restore
|
|
110
|
-
.option("--
|
|
111
|
-
.option("--
|
|
112
|
-
.option(
|
|
113
|
-
.
|
|
183
|
+
.description("Restore an encrypted backup into this folder's project")
|
|
184
|
+
.option("--dry-run", "Check the backup and show what would be restored")
|
|
185
|
+
.option("--yes", "Do not ask for confirmation")
|
|
186
|
+
.option(...STDIN_OPTION)
|
|
187
|
+
.option(...API_OPTION)
|
|
188
|
+
.action((file, opts) => restoreCommand(file, opts));
|
|
114
189
|
program
|
|
115
|
-
.command("
|
|
116
|
-
.description("
|
|
117
|
-
.
|
|
118
|
-
.
|
|
119
|
-
.option("--api-url <url>", "API base URL", apiDefault)
|
|
120
|
-
.action((names, opts) => removeCommand(names, {
|
|
121
|
-
...opts,
|
|
122
|
-
env: normalizeEnvName(opts.env ?? folderEnvOption()),
|
|
123
|
-
envWasDefault: envWasDefaultFromArgv(),
|
|
124
|
-
}));
|
|
190
|
+
.command("lock")
|
|
191
|
+
.description("Forget the unlocked project key on this machine (OS keychain)")
|
|
192
|
+
.option(...API_OPTION)
|
|
193
|
+
.action((opts) => lockCommand(opts));
|
|
125
194
|
program
|
|
126
|
-
.command("
|
|
127
|
-
.description("
|
|
128
|
-
.
|
|
195
|
+
.command("unlink")
|
|
196
|
+
.description("Revoke this folder's token and remove local .getmyenv files")
|
|
197
|
+
.option("--yes", "Do not ask for confirmation")
|
|
198
|
+
.option(...API_OPTION)
|
|
199
|
+
.action((opts) => unlinkCommand(opts));
|
|
200
|
+
const first = argv[2];
|
|
201
|
+
if (first &&
|
|
202
|
+
!first.startsWith("-") &&
|
|
203
|
+
first !== "help" &&
|
|
204
|
+
!program.commands.some((c) => c.name() === first || c.aliases().includes(first))) {
|
|
205
|
+
throw new Error(`Unknown command "${first}". See: npx getmyenv --help`);
|
|
206
|
+
}
|
|
129
207
|
await program.parseAsync(argv);
|
|
130
208
|
}
|
|
131
209
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,O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,MAAM,CAAC,CAAC,IAAY,EAAE,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAE9D,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,+DAA+D,CAAC;SAC5E,MAAM,CAAC,GAAG,UAAU,CAAC;SACrB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAEvC,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,6DAA6D,CAAC;SAC1E,MAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC;SAC9C,MAAM,CAAC,GAAG,UAAU,CAAC;SACrB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,IACE,KAAK;QACL,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,KAAK,KAAK,MAAM;QAChB,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAChF,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,KAAK,6BAA6B,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type BackupOpts = {
|
|
2
2
|
output?: string;
|
|
3
|
-
apiUrl
|
|
3
|
+
apiUrl?: string;
|
|
4
4
|
};
|
|
5
|
+
/** Encrypted backup of open contexts. Readable offline with the Vault password. */
|
|
5
6
|
export declare function backupCommand(opts: BackupOpts): Promise<void>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=backup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAaA,KAAK,UAAU,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAaA,KAAK,UAAU,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,mFAAmF;AACnF,wBAAsB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCnE"}
|
package/dist/commands/backup.js
CHANGED
|
@@ -2,38 +2,28 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import { createBackupEnvelope, parsePayload, parseWrappedKey, serializeBackup, } from "@getmyenv/crypto";
|
|
5
|
-
import {
|
|
6
|
-
import { ApiClient } from "../lib/api.js";
|
|
5
|
+
import { slugify } from "@getmyenv/shared";
|
|
7
6
|
import { ensureTokenAndLink } from "../lib/bootstrap.js";
|
|
7
|
+
/** Encrypted backup of open contexts. Readable offline with the Vault password. */
|
|
8
8
|
export async function backupCommand(opts) {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
apiUrl: opts.apiUrl,
|
|
12
|
-
action: "backup",
|
|
13
|
-
});
|
|
14
|
-
const meta = readProjectMeta();
|
|
15
|
-
const client = new ApiClient(apiUrl, token);
|
|
16
|
-
const data = await client.request("GET", `/api/cli/projects/${projectId}/backup`);
|
|
9
|
+
const { client } = await ensureTokenAndLink({ apiUrl: opts.apiUrl });
|
|
10
|
+
const data = await client.request("GET", "/api/cli/backup");
|
|
17
11
|
const envelope = createBackupEnvelope({
|
|
18
12
|
projectName: data.projectName,
|
|
19
13
|
wrappedProjectKey: parseWrappedKey(JSON.stringify(data.wrappedProjectKey)),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
contexts: data.contexts,
|
|
15
|
+
keys: data.keys,
|
|
16
|
+
tags: data.tags,
|
|
17
|
+
values: data.values.map((v) => ({
|
|
18
|
+
key: v.key,
|
|
19
|
+
context: v.context,
|
|
20
|
+
expiresAt: v.expiresAt,
|
|
21
|
+
payload: parsePayload(v.ciphertext),
|
|
28
22
|
})),
|
|
29
23
|
});
|
|
30
|
-
const out = opts.output ??
|
|
31
|
-
path.join(process.cwd(), `${data.projectName.replace(/\s+/g, "-").toLowerCase()}.getmyenv`);
|
|
24
|
+
const out = opts.output ?? path.join(process.cwd(), `${slugify(data.projectName) || "project"}.getmyenv`);
|
|
32
25
|
fs.writeFileSync(out, serializeBackup(envelope), { mode: 0o600 });
|
|
33
|
-
console.log(`${pc.green("✓")}
|
|
34
|
-
|
|
35
|
-
console.log(pc.dim(`Linked environment: ${meta.environment}`));
|
|
36
|
-
}
|
|
37
|
-
console.log(pc.dim("Encrypted. Unlock with your Vault password.\n"));
|
|
26
|
+
console.log(`${pc.green("✓")} Encrypted backup: ${out} (${data.values.length} values, ${data.contexts.length} open contexts)`);
|
|
27
|
+
console.log(pc.dim("Locked contexts are backed up from the dashboard."));
|
|
38
28
|
}
|
|
39
29
|
//# sourceMappingURL=backup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup.js","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL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AAC;KACJ,CAAC,CAAC;IAEH,MAAM,GAAG,GACP,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,SAAS,WAAW,CAAC,CAAC;IAChG,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CACT,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,sBAAsB,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM,YAAY,IAAI,CAAC,QAAQ,CAAC,MAAM,iBAAiB,CAClH,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
package/dist/commands/claim.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export type ClaimOpts = {
|
|
|
2
2
|
apiUrl?: string;
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
5
|
-
* Claim a guest project:
|
|
5
|
+
* Claim a guest project: sign in and take ownership in the browser, then
|
|
6
|
+
* rewrap the project key with a Vault password.
|
|
6
7
|
*/
|
|
7
8
|
export declare function claimCommand(opts?: ClaimOpts): Promise<void>;
|
|
8
9
|
//# sourceMappingURL=claim.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../src/commands/claim.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAqF5C;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA0EtE"}
|