@openupstream/cli 0.5.0 → 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 CHANGED
@@ -97,8 +97,8 @@ oup site deploy dist --bucket my-site
97
97
  storage grows by half once 90% full (decision 111), without a limit
98
98
  unless `--max-storage` sets one; `--no-auto-grow` leaves growing to
99
99
  `oup pg resize`. It waits
100
- until both instances are ready, unless `--no-wait`. The Project's
101
- Services and Jobs get its URL as `DATABASE_URL_<NAME>` (decision 97).
100
+ until both instances are ready, unless `--no-wait`. A Service or Job
101
+ that names it (`--database <name>`) gets its URL as `DATABASE_URL_<NAME>`.
102
102
  - `oup pg restore <source> <name> [--time <RFC 3339>] [--memory <MB>] [--storage <GB>] [--site …] [--no-wait]`:
103
103
  a new Database `<name>` that starts as a copy of `<source>` at `--time`
104
104
  (with its zone, e.g. `2026-11-10T09:30:00Z`), or at the latest point its
@@ -135,7 +135,10 @@ oup site deploy dist --bucket my-site
135
135
  Account token gets roles of its own.
136
136
  - `oup service deploy <name> --image <ref> [--port <n> | --no-port] [--replicas <n>]
137
137
  [--memory <MB>] [--cpu <millicores>] [--site <site>]
138
- [--registry-user <user> --registry-password-stdin] [--no-wait]`: brings
138
+ [--registry-user <user> --registry-password-stdin] [--no-wait]
139
+ [--secret <NAME>]… [--env <NAME>=<value>]… [--env-file <path>]…
140
+ [--no-secrets] [--no-env] [--add-secret <NAME>]… [--remove-secret <NAME>]…
141
+ [--set-env <NAME>=<value>]… [--unset-env <NAME>]…`: brings
139
142
  the Service to what the flags say (ARCHITECTURE.md, decision 94). A new
140
143
  one needs `--port`, or `--no-port` for a worker that serves no HTTP
141
144
  (decision 98), which also removes an existing Service's port; memory, CPU and replicas default to 256 MB, 250
@@ -144,7 +147,44 @@ oup site deploy dist --bucket my-site
144
147
  runs what the tag points at now, pinned by digest. Then it waits until the
145
148
  Service is running (up to 5 minutes), unless `--no-wait`. The registry
146
149
  password comes from stdin.
147
- - `oup service list`, `oup service show <name>` (JSON),
150
+ - The environment of a Service or Job (ARCHITECTURE.md, decision 170): its
151
+ containers get the Secrets its deploy names and its Variables, and
152
+ nothing else of the Project's. `--secret NAME` names a Secret, which must
153
+ exist; `--env NAME=value` sets a Variable, a plain setting that everyone
154
+ who may read the Project can see; `--env-file <path>` reads Variables
155
+ from a file with one `NAME=value` per line (empty lines and lines
156
+ starting with `#` are skipped, `export ` in front of a name is dropped,
157
+ a value in a pair of quotes loses them, and `--env` wins over a file).
158
+ These state the whole list: on a Service or Job that exists, the
159
+ `--secret` flags replace the Secrets it named and `--env` with
160
+ `--env-file` its Variables, and `oup` prints each name that goes;
161
+ `--no-secrets` and `--no-env` empty a list. `--add-secret`,
162
+ `--remove-secret`, `--set-env` and `--unset-env` change one entry and
163
+ keep the rest; the two kinds do not go together for one list. Without
164
+ any of them a deploy leaves both lists as they are.
165
+ - The Databases a Service or Job reaches (ARCHITECTURE.md, decision 173):
166
+ the ones its deploy names, and no others. `--database main` gives it
167
+ `DATABASE_URL` as a Postgres role of its own, `svc_<name>` or
168
+ `job_<name>`, which can connect and nothing else until the Database's
169
+ owner grants it rights in SQL: `GRANT oup_write TO svc_api;` for every
170
+ table, or a grant on single tables. `--database main:owner` gives it the
171
+ owner's connection, for the Job that changes the schema and runs those
172
+ grants. Without `--database` it gets no `DATABASE_URL`. The flags work
173
+ like those for Secrets: `--database` states the whole list and `oup`
174
+ prints what goes, `--no-databases` empties it, `--add-database` and
175
+ `--remove-database` change one entry. The first one named is
176
+ `DATABASE_URL`.
177
+ - `oup service deploy <name> … --pre-deploy <job>` names a Job of the
178
+ Project that is run, and waited for, before each rollout of the Service
179
+ (ARCHITECTURE.md, decision 173): a migration, for example. Deploy the
180
+ Job first, so it runs the new image. `oup` then waits for the run and
181
+ for the rollout. When the run fails, nothing is rolled out, the Service
182
+ runs what it ran before, and `oup` exits 1 and says where the run's
183
+ output is; the next deploy runs it again. `--no-pre-deploy` takes it
184
+ off. A deploy without either leaves it as it is.
185
+ - `oup service list`, `oup service show <name>` (JSON, with the Secrets it
186
+ names, its Variables with their values, and under `overridden` those the
187
+ platform's own variable of that name replaces),
148
188
  `oup service delete <name>` (refused while a Route serves it).
149
189
  - `oup service logs <name> [--tail <n>] [-f | --follow] [--timestamps]`:
150
190
  the last lines (100 by default) of every replica, sorted by time, each
@@ -158,7 +198,7 @@ oup site deploy dist --bucket my-site
158
198
  [--time-zone <IANA name>] [--timeout <seconds>] [--memory <MB>]
159
199
  [--cpu <millicores>] [--site <site>] [--registry-user <user>
160
200
  --registry-password-stdin] [--no-wait] [--no-command | -- <command>
161
- <arg>…]`: brings the
201
+ <arg>…]`, and the flags for its environment as for a Service: brings the
162
202
  Job to what the flags say, as `oup service deploy` does for a Service
163
203
  (ARCHITECTURE.md, decision 95). What follows `--` replaces the image's
164
204
  entrypoint; without it the Job keeps its command (the image's on
@@ -169,7 +209,7 @@ oup site deploy dist --bucket my-site
169
209
  to run (up to 2 minutes), unless `--no-wait`.
170
210
  - `oup job run <name> [--env NAME=value]… [--no-wait] [-- <arg>…]`: starts a
171
211
  One-off job, with the args after `--` instead of the Job's and the
172
- variables added to its environment, and waits until it has finished:
212
+ variables added to its environment (over the Job's own of that name), and waits until it has finished:
173
213
  exit 0 when it succeeded, 1 when it failed or timed out, so a CI step
174
214
  (a migration) fails with it; a run stopped meanwhile ends the wait at
175
215
  once. `--no-wait` prints the run's id and returns.
@@ -180,11 +220,36 @@ oup site deploy dist --bucket my-site
180
220
  - `oup job logs <name> [<run>] [--tail <n>] [-f | --follow] [--timestamps]`:
181
221
  a run's output, the newest run's without `<run>`; `-f` ends once the run
182
222
  has finished. Runs, and so their output, are kept a day.
183
- - `oup secret list` (names only), `oup secret set <NAME>`, `oup secret
184
- delete <NAME>`. The value comes from stdin, never from an argument, which
223
+ - `oup secret list` (names, each with the Services and Jobs that name it,
224
+ or `unused`), `oup secret set <NAME>`, `oup secret
225
+ delete <NAME>` (refused while a Service or Job names it). The value comes from stdin, never from an argument, which
185
226
  shells keep in their history: piped (one trailing line break is dropped,
186
227
  as `echo` adds it) or typed at the prompt, which does not echo it. The
187
- Project's Services restart with the new value.
228
+ Services that name it restart with the new value; one that nothing
229
+ names reaches no container.
230
+ - `oup key list`, `oup key create <name>`, `oup key show <name>`: a
231
+ Project's Keys (encryption keys that stay in the platform; nothing
232
+ prints or takes key material). `oup key rotate <name>` adds a version
233
+ that encrypting uses from then on; what older versions encrypted still
234
+ decrypts. `oup key delete <name>` does not erase anything at once: the
235
+ Key is pending deletion for 7 days, refuses every call, and `oup key
236
+ restore <name>` brings it back; after that it is erased and what it
237
+ encrypted is unreadable for good.
238
+ - `oup key grant <name> --service <service> --access encrypt` (or `--job
239
+ <job>`; `decrypt`, `both`) lets that Service's or Job's containers use
240
+ the Key: they call the address in `OUP_KEYS_URL` with the token in the
241
+ file `OUP_KEYS_TOKEN_FILE` names (`POST /v1/keys/<name>/encrypt` with
242
+ `{"plaintext": "<base64>", "context": {…}}`, `…/decrypt` with
243
+ `{"ciphertext": "…", "context": {…}}`). `encrypt` does not include
244
+ `decrypt`, nor the reverse, so the Service that stores a password need
245
+ not be able to read it back. A Service's first grant restarts it once.
246
+ `oup key revoke <name> --service <service>` takes the grant away; `oup
247
+ key show <name>` lists them. People cannot encrypt or decrypt.
248
+ - `oup key log <name> [--limit <n>] [--json]`: who encrypted and decrypted
249
+ with the Key, newest first: when, which Service or Job, the outcome, the
250
+ Key's version and the context. Kept 30 days; values are never recorded.
251
+ In Node, `@openupstream/sdk/keys` makes the calls: `const result = await
252
+ keys().encrypt('site-passwords', password, { user: id })`.
188
253
  - `oup bucket list`, `oup bucket create <name>`, `oup bucket show <name>`
189
254
  (S3 endpoint, region and access key id), `oup bucket delete <name>` (and
190
255
  every object in it; refused while a Route serves it). A Bucket's name is
@@ -0,0 +1,133 @@
1
+ /**
2
+ * The Secrets a Service or Job names and its Variables, from the flags of
3
+ * `oup service deploy` and `oup job deploy` (ARCHITECTURE.md, decision 170).
4
+ *
5
+ * `--secret`, `--env` and `--env-file` state a whole list: what they give
6
+ * replaces what the definition has, and `--no-secrets` and `--no-env`
7
+ * empty one. `--add-secret`, `--remove-secret`, `--set-env` and
8
+ * `--unset-env` change single entries and leave the rest. Without any of
9
+ * them a list stays as it is. Pure: the files are read by the caller.
10
+ *
11
+ * The Databases it reaches (decision 173) work the same: `--database
12
+ * main` (as a role of its own) or `--database main:owner` state the list,
13
+ * `--no-databases` empties it, `--add-database` and `--remove-database`
14
+ * change one entry.
15
+ */
16
+ import { type NamedDatabase } from '@openupstream/sdk';
17
+ import { type Result } from './result.js';
18
+ export interface EnvironmentFlags {
19
+ readonly secret?: readonly string[] | undefined;
20
+ readonly 'no-secrets'?: boolean | undefined;
21
+ readonly 'add-secret'?: readonly string[] | undefined;
22
+ readonly 'remove-secret'?: readonly string[] | undefined;
23
+ readonly env?: readonly string[] | undefined;
24
+ readonly 'env-file'?: readonly string[] | undefined;
25
+ readonly 'no-env'?: boolean | undefined;
26
+ readonly 'set-env'?: readonly string[] | undefined;
27
+ readonly 'unset-env'?: readonly string[] | undefined;
28
+ readonly database?: readonly string[] | undefined;
29
+ readonly 'no-databases'?: boolean | undefined;
30
+ readonly 'add-database'?: readonly string[] | undefined;
31
+ readonly 'remove-database'?: readonly string[] | undefined;
32
+ }
33
+ /** The flags as `parseArgs` options. */
34
+ export declare const ENVIRONMENT_OPTIONS: {
35
+ readonly secret: {
36
+ readonly type: "string";
37
+ readonly multiple: true;
38
+ };
39
+ readonly 'no-secrets': {
40
+ readonly type: "boolean";
41
+ };
42
+ readonly 'add-secret': {
43
+ readonly type: "string";
44
+ readonly multiple: true;
45
+ };
46
+ readonly 'remove-secret': {
47
+ readonly type: "string";
48
+ readonly multiple: true;
49
+ };
50
+ readonly env: {
51
+ readonly type: "string";
52
+ readonly multiple: true;
53
+ };
54
+ readonly 'env-file': {
55
+ readonly type: "string";
56
+ readonly multiple: true;
57
+ };
58
+ readonly 'no-env': {
59
+ readonly type: "boolean";
60
+ };
61
+ readonly 'set-env': {
62
+ readonly type: "string";
63
+ readonly multiple: true;
64
+ };
65
+ readonly 'unset-env': {
66
+ readonly type: "string";
67
+ readonly multiple: true;
68
+ };
69
+ readonly database: {
70
+ readonly type: "string";
71
+ readonly multiple: true;
72
+ };
73
+ readonly 'no-databases': {
74
+ readonly type: "boolean";
75
+ };
76
+ readonly 'add-database': {
77
+ readonly type: "string";
78
+ readonly multiple: true;
79
+ };
80
+ readonly 'remove-database': {
81
+ readonly type: "string";
82
+ readonly multiple: true;
83
+ };
84
+ };
85
+ export declare const ENVIRONMENT_FLAGS: (keyof EnvironmentFlags)[];
86
+ export interface Environment {
87
+ readonly secrets: readonly string[];
88
+ readonly variables: Readonly<Record<string, string>>;
89
+ readonly databases: readonly NamedDatabase[];
90
+ }
91
+ /** What a deploy asks for; a list left out stays as the definition has it. */
92
+ export interface DesiredEnvironment {
93
+ readonly secrets?: string[];
94
+ readonly variables?: Record<string, string>;
95
+ readonly databases?: NamedDatabase[];
96
+ }
97
+ /** `main` or `main:owner` as a Database to name; `own`, a role of the definition's own, when no access is given. */
98
+ export declare function parseNamedDatabase(text: string, flag: string): Result<NamedDatabase, string>;
99
+ /** The Databases the flags ask for, given what the definition names; undefined: as it is. */
100
+ export declare function desiredDatabases(existing: readonly NamedDatabase[] | undefined, flags: EnvironmentFlags): Result<NamedDatabase[] | undefined, string>;
101
+ /**
102
+ * The Variables of an env file: one `NAME=value` per line. Empty lines and
103
+ * lines starting with `#` are skipped, `export ` in front of a name is
104
+ * dropped, and a value in a pair of single or double quotes loses them.
105
+ * Nothing else is interpreted: no `$NAME`, no escapes, no comment after a
106
+ * value.
107
+ */
108
+ export declare function parseEnvFile(text: string, path: string): Result<[string, string][], string>;
109
+ /**
110
+ * The lists the flags ask for, given what the definition has (`undefined`:
111
+ * a new one). `files` are the contents of the `--env-file`s, in order.
112
+ */
113
+ export declare function desiredEnvironment(existing: Environment | undefined, flags: EnvironmentFlags, files: readonly {
114
+ readonly path: string;
115
+ readonly text: string;
116
+ }[]): Result<DesiredEnvironment, string>;
117
+ /** The part of a change that the desired lists make: only a list that differs from what the definition has. */
118
+ export declare const environmentChange: (existing: Environment, desired: DesiredEnvironment) => DesiredEnvironment;
119
+ /**
120
+ * The names a change takes away from a definition, for `oup` to print:
121
+ * stating a whole list is an easy way to drop the entries not repeated.
122
+ */
123
+ export declare const removedNames: (existing: Environment | undefined, change: {
124
+ readonly secrets?: readonly string[] | undefined;
125
+ readonly variables?: Readonly<Record<string, string>> | undefined;
126
+ readonly databases?: readonly {
127
+ readonly name: string;
128
+ }[] | undefined;
129
+ }) => {
130
+ readonly secrets: string[];
131
+ readonly variables: string[];
132
+ readonly databases: string[];
133
+ };
@@ -0,0 +1,238 @@
1
+ /**
2
+ * The Secrets a Service or Job names and its Variables, from the flags of
3
+ * `oup service deploy` and `oup job deploy` (ARCHITECTURE.md, decision 170).
4
+ *
5
+ * `--secret`, `--env` and `--env-file` state a whole list: what they give
6
+ * replaces what the definition has, and `--no-secrets` and `--no-env`
7
+ * empty one. `--add-secret`, `--remove-secret`, `--set-env` and
8
+ * `--unset-env` change single entries and leave the rest. Without any of
9
+ * them a list stays as it is. Pure: the files are read by the caller.
10
+ *
11
+ * The Databases it reaches (decision 173) work the same: `--database
12
+ * main` (as a role of its own) or `--database main:owner` state the list,
13
+ * `--no-databases` empties it, `--add-database` and `--remove-database`
14
+ * change one entry.
15
+ */
16
+ import { DEFINITION_DATABASE_ACCESS } from '@openupstream/sdk';
17
+ import { err, ok } from './result.js';
18
+ /** The flags as `parseArgs` options. */
19
+ export const ENVIRONMENT_OPTIONS = {
20
+ secret: { type: 'string', multiple: true },
21
+ 'no-secrets': { type: 'boolean' },
22
+ 'add-secret': { type: 'string', multiple: true },
23
+ 'remove-secret': { type: 'string', multiple: true },
24
+ env: { type: 'string', multiple: true },
25
+ 'env-file': { type: 'string', multiple: true },
26
+ 'no-env': { type: 'boolean' },
27
+ 'set-env': { type: 'string', multiple: true },
28
+ 'unset-env': { type: 'string', multiple: true },
29
+ database: { type: 'string', multiple: true },
30
+ 'no-databases': { type: 'boolean' },
31
+ 'add-database': { type: 'string', multiple: true },
32
+ 'remove-database': { type: 'string', multiple: true },
33
+ };
34
+ export const ENVIRONMENT_FLAGS = Object.keys(ENVIRONMENT_OPTIONS);
35
+ /** `main` or `main:owner` as a Database to name; `own`, a role of the definition's own, when no access is given. */
36
+ export function parseNamedDatabase(text, flag) {
37
+ const [name = '', access, ...more] = text.split(':');
38
+ if (name === '' || more.length > 0) {
39
+ return err(`${flag} takes <database> or <database>:owner, not ${text}`);
40
+ }
41
+ if (access !== undefined && !DEFINITION_DATABASE_ACCESS.includes(access)) {
42
+ return err(`${flag} ${text}: the access is ${DEFINITION_DATABASE_ACCESS.join(' or ')}`);
43
+ }
44
+ return ok({ name, access: access ?? 'own' });
45
+ }
46
+ /** The Databases the flags ask for, given what the definition names; undefined: as it is. */
47
+ export function desiredDatabases(existing, flags) {
48
+ const whole = given(flags.database) || flags['no-databases'] === true;
49
+ const single = given(flags['add-database']) || given(flags['remove-database']);
50
+ if (given(flags.database) && flags['no-databases'] === true) {
51
+ return err('--database and --no-databases exclude each other');
52
+ }
53
+ if (whole && single) {
54
+ return err('--database and --no-databases state the whole list; --add-database and --remove-database change one entry: use one kind');
55
+ }
56
+ if (!whole && !single) {
57
+ return ok(undefined);
58
+ }
59
+ const parsed = [];
60
+ for (const text of (whole ? flags.database : flags['add-database']) ?? []) {
61
+ const database = parseNamedDatabase(text, whole ? '--database' : '--add-database');
62
+ if (!database.ok) {
63
+ return database;
64
+ }
65
+ parsed.push(database.value);
66
+ }
67
+ const twice = parsed.find((database, at) => parsed.findIndex((other) => other.name === database.name) !== at);
68
+ if (twice !== undefined) {
69
+ return err(`the Database ${twice.name} is named twice`);
70
+ }
71
+ if (whole) {
72
+ return ok(parsed);
73
+ }
74
+ const had = existing ?? [];
75
+ const removed = flags['remove-database'] ?? [];
76
+ const both = parsed.find((database) => removed.includes(database.name));
77
+ if (both !== undefined) {
78
+ return err(`--add-database and --remove-database both name ${both.name}`);
79
+ }
80
+ const missing = removed.find((name) => !had.some((database) => database.name === name));
81
+ if (missing !== undefined) {
82
+ return err(`--remove-database ${missing}: it does not name that Database`);
83
+ }
84
+ // One that is named already keeps its place and takes the access given now.
85
+ const kept = had.filter((database) => !removed.includes(database.name)).map((database) => parsed.find((added) => added.name === database.name) ?? database);
86
+ return ok([...kept, ...parsed.filter((added) => !had.some((database) => database.name === added.name))]);
87
+ }
88
+ /** `NAME=value` as a pair; the value is everything after the first `=`. */
89
+ const pairOf = (text, flag) => {
90
+ const at = text.indexOf('=');
91
+ return at < 1 ? err(`${flag} takes NAME=value, not ${text}`) : ok([text.slice(0, at), text.slice(at + 1)]);
92
+ };
93
+ const pairsOf = (texts, flag) => {
94
+ const pairs = [];
95
+ for (const text of texts) {
96
+ const pair = pairOf(text, flag);
97
+ if (!pair.ok) {
98
+ return pair;
99
+ }
100
+ pairs.push(pair.value);
101
+ }
102
+ return ok(pairs);
103
+ };
104
+ /**
105
+ * The Variables of an env file: one `NAME=value` per line. Empty lines and
106
+ * lines starting with `#` are skipped, `export ` in front of a name is
107
+ * dropped, and a value in a pair of single or double quotes loses them.
108
+ * Nothing else is interpreted: no `$NAME`, no escapes, no comment after a
109
+ * value.
110
+ */
111
+ export function parseEnvFile(text, path) {
112
+ const pairs = [];
113
+ // Without the byte order mark some editors put in front, which would become part of the first name.
114
+ for (const [index, raw] of text.replace(/^\uFEFF/, '').split(/\r?\n/).entries()) {
115
+ const line = raw.trim();
116
+ if (line === '' || line.startsWith('#')) {
117
+ continue;
118
+ }
119
+ const pair = pairOf(line.replace(/^export\s+/, ''), `${path}, line ${index + 1}:`);
120
+ if (!pair.ok) {
121
+ return err(`${path}, line ${index + 1}: expected NAME=value`);
122
+ }
123
+ const [name, value] = [pair.value[0].trim(), pair.value[1].trim()];
124
+ const quoted = value.length >= 2 && (value.startsWith('"') || value.startsWith("'")) && value.endsWith(value.charAt(0));
125
+ pairs.push([name, quoted ? value.slice(1, -1) : value]);
126
+ }
127
+ return ok(pairs);
128
+ }
129
+ const given = (flag) => flag !== undefined && flag.length > 0;
130
+ /**
131
+ * The lists the flags ask for, given what the definition has (`undefined`:
132
+ * a new one). `files` are the contents of the `--env-file`s, in order.
133
+ */
134
+ export function desiredEnvironment(existing, flags, files) {
135
+ const whole = { secrets: given(flags.secret) || flags['no-secrets'] === true, variables: given(flags.env) || files.length > 0 || flags['no-env'] === true };
136
+ const single = { secrets: given(flags['add-secret']) || given(flags['remove-secret']), variables: given(flags['set-env']) || given(flags['unset-env']) };
137
+ if (given(flags.secret) && flags['no-secrets'] === true) {
138
+ return err('--secret and --no-secrets exclude each other');
139
+ }
140
+ if ((given(flags.env) || files.length > 0) && flags['no-env'] === true) {
141
+ return err('--env and --env-file exclude --no-env');
142
+ }
143
+ if (whole.secrets && single.secrets) {
144
+ return err('--secret and --no-secrets state the whole list; --add-secret and --remove-secret change one entry: use one kind');
145
+ }
146
+ if (whole.variables && single.variables) {
147
+ return err('--env, --env-file and --no-env state all Variables; --set-env and --unset-env change one: use one kind');
148
+ }
149
+ const secrets = (() => {
150
+ if (whole.secrets) {
151
+ return ok([...new Set(flags.secret ?? [])]);
152
+ }
153
+ if (!single.secrets) {
154
+ return ok(undefined);
155
+ }
156
+ const had = existing?.secrets ?? [];
157
+ const both = (flags['add-secret'] ?? []).find((name) => (flags['remove-secret'] ?? []).includes(name));
158
+ if (both !== undefined) {
159
+ return err(`--add-secret and --remove-secret both name ${both}`);
160
+ }
161
+ const missing = (flags['remove-secret'] ?? []).find((name) => !had.includes(name));
162
+ if (missing !== undefined) {
163
+ return err(`--remove-secret ${missing}: it does not name that Secret`);
164
+ }
165
+ const removed = new Set(flags['remove-secret'] ?? []);
166
+ return ok([...new Set([...had, ...(flags['add-secret'] ?? [])])].filter((name) => !removed.has(name)));
167
+ })();
168
+ if (!secrets.ok) {
169
+ return secrets;
170
+ }
171
+ const variables = (() => {
172
+ if (whole.variables) {
173
+ const fromFiles = [];
174
+ for (const file of files) {
175
+ const parsed = parseEnvFile(file.text, file.path);
176
+ if (!parsed.ok) {
177
+ return parsed;
178
+ }
179
+ fromFiles.push(...parsed.value);
180
+ }
181
+ const fromFlags = pairsOf(flags.env ?? [], '--env');
182
+ // A flag wins over a file, a later file over an earlier one.
183
+ return fromFlags.ok ? ok(Object.fromEntries([...fromFiles, ...fromFlags.value])) : fromFlags;
184
+ }
185
+ if (!single.variables) {
186
+ return ok(undefined);
187
+ }
188
+ const had = existing?.variables ?? {};
189
+ const missing = (flags['unset-env'] ?? []).find((name) => !Object.hasOwn(had, name));
190
+ if (missing !== undefined) {
191
+ return err(`--unset-env ${missing}: it has no Variable of that name`);
192
+ }
193
+ const set = pairsOf(flags['set-env'] ?? [], '--set-env');
194
+ if (!set.ok) {
195
+ return set;
196
+ }
197
+ const both = set.value.find(([name]) => (flags['unset-env'] ?? []).includes(name));
198
+ if (both !== undefined) {
199
+ return err(`--set-env and --unset-env both name ${both[0]}`);
200
+ }
201
+ const unset = new Set(flags['unset-env'] ?? []);
202
+ return ok(Object.fromEntries([...Object.entries(had), ...set.value].filter(([name]) => !unset.has(name))));
203
+ })();
204
+ if (!variables.ok) {
205
+ return variables;
206
+ }
207
+ const databases = desiredDatabases(existing?.databases, flags);
208
+ if (!databases.ok) {
209
+ return databases;
210
+ }
211
+ return ok({
212
+ ...(secrets.value === undefined ? {} : { secrets: secrets.value }),
213
+ ...(variables.value === undefined ? {} : { variables: variables.value }),
214
+ ...(databases.value === undefined ? {} : { databases: databases.value }),
215
+ });
216
+ }
217
+ const sorted = (names) => [...names].sort();
218
+ const sameSecrets = (a, b) => JSON.stringify(sorted(a)) === JSON.stringify(sorted(b));
219
+ const sameVariables = (a, b) => JSON.stringify(Object.entries(a).sort()) === JSON.stringify(Object.entries(b).sort());
220
+ /** The part of a change that the desired lists make: only a list that differs from what the definition has. */
221
+ export const environmentChange = (existing, desired) => ({
222
+ ...(desired.secrets === undefined || sameSecrets(existing.secrets, desired.secrets) ? {} : { secrets: desired.secrets }),
223
+ ...(desired.variables === undefined || sameVariables(existing.variables, desired.variables) ? {} : { variables: desired.variables }),
224
+ // The order counts: the first one's URL is DATABASE_URL.
225
+ ...(desired.databases === undefined || JSON.stringify(existing.databases) === JSON.stringify(desired.databases) ? {} : { databases: desired.databases }),
226
+ });
227
+ /**
228
+ * The names a change takes away from a definition, for `oup` to print:
229
+ * stating a whole list is an easy way to drop the entries not repeated.
230
+ */
231
+ export const removedNames = (existing, change) => ({
232
+ secrets: change.secrets === undefined ? [] : (existing?.secrets ?? []).filter((name) => !change.secrets?.includes(name)),
233
+ variables: change.variables === undefined ? [] : Object.keys(existing?.variables ?? {}).filter((name) => !Object.hasOwn(change.variables ?? {}, name)),
234
+ databases: change.databases === undefined
235
+ ? []
236
+ : (existing?.databases ?? []).map((database) => database.name).filter((name) => !change.databases?.some((database) => database.name === name)),
237
+ });
238
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,0BAA0B,EAAqD,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAe,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAkBnD,wCAAwC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC1C,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,YAAY,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IAChD,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IACnD,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;IACvC,UA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