hereya-cli 0.16.0 → 0.17.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
@@ -20,7 +20,7 @@ $ npm install -g hereya-cli
20
20
  $ hereya COMMAND
21
21
  running command...
22
22
  $ hereya (--version)
23
- hereya-cli/0.16.0 linux-x64 node-v22.13.1
23
+ hereya-cli/0.17.0 linux-x64 node-v22.13.1
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -34,6 +34,7 @@ USAGE
34
34
  * [`hereya deploy`](#hereya-deploy)
35
35
  * [`hereya down`](#hereya-down)
36
36
  * [`hereya env [NAME]`](#hereya-env-name)
37
+ * [`hereya env set [NAME]`](#hereya-env-set-name)
37
38
  * [`hereya help [COMMAND]`](#hereya-help-command)
38
39
  * [`hereya init PROJECT`](#hereya-init-project)
39
40
  * [`hereya remove PACKAGE`](#hereya-remove-package)
@@ -73,7 +74,7 @@ EXAMPLES
73
74
  $ hereya add cloudy/docker_postgres
74
75
  ```
75
76
 
76
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/add/index.ts)_
77
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/add/index.ts)_
77
78
 
78
79
  ## `hereya bootstrap INFRASTRUCTURETYPE`
79
80
 
@@ -98,7 +99,7 @@ EXAMPLES
98
99
  $ hereya bootstrap local
99
100
  ```
100
101
 
101
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/bootstrap/index.ts)_
102
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/bootstrap/index.ts)_
102
103
 
103
104
  ## `hereya deploy`
104
105
 
@@ -120,7 +121,7 @@ EXAMPLES
120
121
  $ hereya deploy
121
122
  ```
122
123
 
123
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/deploy/index.ts)_
124
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/deploy/index.ts)_
124
125
 
125
126
  ## `hereya down`
126
127
 
@@ -143,7 +144,7 @@ EXAMPLES
143
144
  $ hereya down
144
145
  ```
145
146
 
146
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/down/index.ts)_
147
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/down/index.ts)_
147
148
 
148
149
  ## `hereya env [NAME]`
149
150
 
@@ -174,7 +175,32 @@ EXAMPLES
174
175
  $ hereya env -w dev -l
175
176
  ```
176
177
 
177
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/env/index.ts)_
178
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/env/index.ts)_
179
+
180
+ ## `hereya env set [NAME]`
181
+
182
+ Set an environment variable for the current workspace
183
+
184
+ ```
185
+ USAGE
186
+ $ hereya env set [NAME] -v <value> [--chdir <value>] [-w <value>]
187
+
188
+ ARGUMENTS
189
+ NAME name of the environment variable to set
190
+
191
+ FLAGS
192
+ -v, --value=<value> (required) value of the environment variable
193
+ -w, --workspace=<value> name of the workspace to print the env vars for
194
+ --chdir=<value> project root directory
195
+
196
+ DESCRIPTION
197
+ Set an environment variable for the current workspace
198
+
199
+ EXAMPLES
200
+ $ hereya env set FOO bar
201
+ ```
202
+
203
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/env/set/index.ts)_
178
204
 
179
205
  ## `hereya help [COMMAND]`
180
206
 
@@ -220,7 +246,7 @@ EXAMPLES
220
246
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
221
247
  ```
222
248
 
223
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/init/index.ts)_
249
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/init/index.ts)_
224
250
 
225
251
  ## `hereya remove PACKAGE`
226
252
 
@@ -244,7 +270,7 @@ EXAMPLES
244
270
  $ hereya remove cloudy/docker_postgres
245
271
  ```
246
272
 
247
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/remove/index.ts)_
273
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/remove/index.ts)_
248
274
 
249
275
  ## `hereya run CMD`
250
276
 
@@ -270,7 +296,7 @@ EXAMPLES
270
296
  $ hereya run -w uat -- node index.js
271
297
  ```
272
298
 
273
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/run/index.ts)_
299
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/run/index.ts)_
274
300
 
275
301
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
276
302
 
@@ -295,7 +321,7 @@ EXAMPLES
295
321
  $ hereya unbootstrap local
296
322
  ```
297
323
 
298
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/unbootstrap/index.ts)_
324
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/unbootstrap/index.ts)_
299
325
 
300
326
  ## `hereya undeploy`
301
327
 
@@ -317,7 +343,7 @@ EXAMPLES
317
343
  $ hereya undeploy
318
344
  ```
319
345
 
320
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/undeploy/index.ts)_
346
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/undeploy/index.ts)_
321
347
 
322
348
  ## `hereya up`
323
349
 
@@ -340,7 +366,7 @@ EXAMPLES
340
366
  $ hereya up
341
367
  ```
342
368
 
343
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/up/index.ts)_
369
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/up/index.ts)_
344
370
 
345
371
  ## `hereya workspace create NAME`
346
372
 
@@ -360,7 +386,7 @@ EXAMPLES
360
386
  $ hereya workspace create dev
361
387
  ```
362
388
 
363
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/create/index.ts)_
389
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/create/index.ts)_
364
390
 
365
391
  ## `hereya workspace delete NAME`
366
392
 
@@ -380,7 +406,7 @@ EXAMPLES
380
406
  $ hereya workspace delete dev
381
407
  ```
382
408
 
383
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/delete/index.ts)_
409
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/delete/index.ts)_
384
410
 
385
411
  ## `hereya workspace env [NAME]`
386
412
 
@@ -406,7 +432,7 @@ EXAMPLES
406
432
  $ hereya workspace env myEnv -w dev
407
433
  ```
408
434
 
409
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/index.ts)_
435
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/env/index.ts)_
410
436
 
411
437
  ## `hereya workspace env set`
412
438
 
@@ -430,7 +456,7 @@ EXAMPLES
430
456
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
431
457
  ```
432
458
 
433
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/set/index.ts)_
459
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/env/set/index.ts)_
434
460
 
435
461
  ## `hereya workspace env unset`
436
462
 
@@ -451,7 +477,7 @@ EXAMPLES
451
477
  $ hereya workspace env unset -w my-workspace -n myVar
452
478
  ```
453
479
 
454
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/unset/index.ts)_
480
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/env/unset/index.ts)_
455
481
 
456
482
  ## `hereya workspace install PACKAGE`
457
483
 
@@ -478,7 +504,7 @@ EXAMPLES
478
504
  $ hereya workspace install hereya/aws-cognito
479
505
  ```
480
506
 
481
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/install/index.ts)_
507
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/install/index.ts)_
482
508
 
483
509
  ## `hereya workspace uninstall PACKAGE`
484
510
 
@@ -505,5 +531,5 @@ EXAMPLES
505
531
  $ hereya workspace uninstall hereya/aws-cognito
506
532
  ```
507
533
 
508
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/uninstall/index.ts)_
534
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.0/src/commands/workspace/uninstall/index.ts)_
509
535
  <!-- commandsstop -->
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class EnvSet extends Command {
3
+ static args: {
4
+ name: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ chdir: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
+ value: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
+ workspace: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,54 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import path from 'node:path';
3
+ import { getConfigManager } from '../../../lib/config/index.js';
4
+ import { getAnyPath } from '../../../lib/filesystem.js';
5
+ import { load, save } from '../../../lib/yaml-utils.js';
6
+ export default class EnvSet extends Command {
7
+ static args = {
8
+ name: Args.string({ description: 'name of the environment variable to set' }),
9
+ };
10
+ static description = 'Set an environment variable for the current workspace';
11
+ static examples = ['<%= config.bin %> <%= command.id %> FOO bar'];
12
+ static flags = {
13
+ chdir: Flags.string({
14
+ description: 'project root directory',
15
+ required: false,
16
+ }),
17
+ value: Flags.string({
18
+ char: 'v',
19
+ description: 'value of the environment variable',
20
+ required: true,
21
+ }),
22
+ workspace: Flags.string({
23
+ char: 'w',
24
+ description: 'name of the workspace to print the env vars for',
25
+ required: false,
26
+ }),
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(EnvSet);
30
+ if (!args.name) {
31
+ this.error('Missing required argument name');
32
+ }
33
+ const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
34
+ const configManager = getConfigManager();
35
+ const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
36
+ if (!loadConfigOutput.found) {
37
+ this.warn(`Project not initialized. Run 'hereya init' first.`);
38
+ return;
39
+ }
40
+ const rootDir = projectRootDir ?? process.cwd();
41
+ const candidates = flags.workspace ? [
42
+ path.join(rootDir, 'hereyastaticenv', `env.${flags.workspace}.yaml`),
43
+ path.join(rootDir, 'hereyastaticenv', `env.${flags.workspace}.yml`),
44
+ ] : [
45
+ path.join(rootDir, 'hereyastaticenv', `env.yaml`),
46
+ path.join(rootDir, 'hereyastaticenv', `env.yml`),
47
+ ];
48
+ const envFile = await getAnyPath(...candidates);
49
+ const { data: env, } = await load(envFile);
50
+ env[args.name] = flags.value;
51
+ await save(env, envFile);
52
+ this.log(`Environment variable ${args.name} set to ${flags.value} in ${envFile}`);
53
+ }
54
+ }
@@ -4,6 +4,7 @@ export declare class EnvManager {
4
4
  getProjectEnv(input: GetProjectEnvInput): Promise<GetProjectEnvOutput>;
5
5
  removeProjectEnv(input: RemoveEnvInput): Promise<void>;
6
6
  private getEnvPath;
7
+ private getUserEnvPaths;
7
8
  }
8
9
  export declare const envManager: EnvManager;
9
10
  export declare function getEnvManager(): EnvManager;
@@ -6,19 +6,24 @@ export class EnvManager {
6
6
  async addProjectEnv(input) {
7
7
  const envPath = await this.getEnvPath(input);
8
8
  const { data: existingEnv } = await load(envPath);
9
- const newEnv = Object.fromEntries(Object.entries(input.env)
10
- .map(([key, value]) => [key, `${input.infra}:${value}`]));
9
+ const newEnv = Object.fromEntries(Object.entries(input.env).map(([key, value]) => [key, `${input.infra}:${value}`]));
11
10
  const finalEnv = { ...existingEnv, ...newEnv };
12
11
  await save(finalEnv, envPath);
13
12
  }
14
13
  async getProjectEnv(input) {
15
14
  const envPath = await this.getEnvPath(input);
16
15
  const { data: env, found } = await load(envPath);
17
- if (!found) {
18
- return { env: {} };
16
+ let resolvedEnv = {};
17
+ if (found) {
18
+ resolvedEnv = await resolveEnvValues(env, { markSecret: input.markSecret });
19
+ }
20
+ const userEnvs = await this.getUserEnvPaths(input).then((paths) => Promise.all(paths.map((path) => load(path))));
21
+ let userMergedEnv = {};
22
+ for (const { data } of userEnvs) {
23
+ userMergedEnv = { ...userMergedEnv, ...data };
19
24
  }
20
- const resolvedEnv = await resolveEnvValues(env, { markSecret: input.markSecret });
21
- return { env: resolvedEnv };
25
+ const finalEnv = { ...resolvedEnv, ...userMergedEnv };
26
+ return { env: finalEnv };
22
27
  }
23
28
  async removeProjectEnv(input) {
24
29
  const envPath = await this.getEnvPath(input);
@@ -27,14 +32,19 @@ export class EnvManager {
27
32
  return;
28
33
  }
29
34
  const envKeysToRemove = Object.keys(input.env);
30
- const finalEnv = Object.fromEntries(Object
31
- .entries(existingEnv)
32
- .filter(([key]) => !envKeysToRemove.includes(key)));
35
+ const finalEnv = Object.fromEntries(Object.entries(existingEnv).filter(([key]) => !envKeysToRemove.includes(key)));
33
36
  await save(finalEnv, envPath);
34
37
  }
35
38
  async getEnvPath(input) {
36
39
  return getAnyPath(path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${input.workspace}.yaml`), path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${input.workspace}.yml`));
37
40
  }
41
+ async getUserEnvPaths(input) {
42
+ const paths = await Promise.all([
43
+ getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.yaml`), path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.yml`)),
44
+ getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.${input.workspace}.yaml`), path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.${input.workspace}.yml`)),
45
+ ]);
46
+ return paths;
47
+ }
38
48
  }
39
49
  export const envManager = new EnvManager();
40
50
  export function getEnvManager() {
@@ -540,6 +540,63 @@
540
540
  "index.js"
541
541
  ]
542
542
  },
543
+ "env:set": {
544
+ "aliases": [],
545
+ "args": {
546
+ "name": {
547
+ "description": "name of the environment variable to set",
548
+ "name": "name"
549
+ }
550
+ },
551
+ "description": "Set an environment variable for the current workspace",
552
+ "examples": [
553
+ "<%= config.bin %> <%= command.id %> FOO bar"
554
+ ],
555
+ "flags": {
556
+ "chdir": {
557
+ "description": "project root directory",
558
+ "name": "chdir",
559
+ "required": false,
560
+ "hasDynamicHelp": false,
561
+ "multiple": false,
562
+ "type": "option"
563
+ },
564
+ "value": {
565
+ "char": "v",
566
+ "description": "value of the environment variable",
567
+ "name": "value",
568
+ "required": true,
569
+ "hasDynamicHelp": false,
570
+ "multiple": false,
571
+ "type": "option"
572
+ },
573
+ "workspace": {
574
+ "char": "w",
575
+ "description": "name of the workspace to print the env vars for",
576
+ "name": "workspace",
577
+ "required": false,
578
+ "hasDynamicHelp": false,
579
+ "multiple": false,
580
+ "type": "option"
581
+ }
582
+ },
583
+ "hasDynamicHelp": false,
584
+ "hiddenAliases": [],
585
+ "id": "env:set",
586
+ "pluginAlias": "hereya-cli",
587
+ "pluginName": "hereya-cli",
588
+ "pluginType": "core",
589
+ "strict": true,
590
+ "enableJsonFlag": false,
591
+ "isESM": true,
592
+ "relativePath": [
593
+ "dist",
594
+ "commands",
595
+ "env",
596
+ "set",
597
+ "index.js"
598
+ ]
599
+ },
543
600
  "workspace:create": {
544
601
  "aliases": [],
545
602
  "args": {
@@ -571,6 +628,37 @@
571
628
  "index.js"
572
629
  ]
573
630
  },
631
+ "workspace:delete": {
632
+ "aliases": [],
633
+ "args": {
634
+ "name": {
635
+ "description": "name of the workspace to delete",
636
+ "name": "name",
637
+ "required": true
638
+ }
639
+ },
640
+ "description": "Delete a workspace if it exists.",
641
+ "examples": [
642
+ "<%= config.bin %> <%= command.id %> dev"
643
+ ],
644
+ "flags": {},
645
+ "hasDynamicHelp": false,
646
+ "hiddenAliases": [],
647
+ "id": "workspace:delete",
648
+ "pluginAlias": "hereya-cli",
649
+ "pluginName": "hereya-cli",
650
+ "pluginType": "core",
651
+ "strict": true,
652
+ "enableJsonFlag": false,
653
+ "isESM": true,
654
+ "relativePath": [
655
+ "dist",
656
+ "commands",
657
+ "workspace",
658
+ "delete",
659
+ "index.js"
660
+ ]
661
+ },
574
662
  "workspace:env": {
575
663
  "aliases": [],
576
664
  "args": {
@@ -621,37 +709,6 @@
621
709
  "index.js"
622
710
  ]
623
711
  },
624
- "workspace:delete": {
625
- "aliases": [],
626
- "args": {
627
- "name": {
628
- "description": "name of the workspace to delete",
629
- "name": "name",
630
- "required": true
631
- }
632
- },
633
- "description": "Delete a workspace if it exists.",
634
- "examples": [
635
- "<%= config.bin %> <%= command.id %> dev"
636
- ],
637
- "flags": {},
638
- "hasDynamicHelp": false,
639
- "hiddenAliases": [],
640
- "id": "workspace:delete",
641
- "pluginAlias": "hereya-cli",
642
- "pluginName": "hereya-cli",
643
- "pluginType": "core",
644
- "strict": true,
645
- "enableJsonFlag": false,
646
- "isESM": true,
647
- "relativePath": [
648
- "dist",
649
- "commands",
650
- "workspace",
651
- "delete",
652
- "index.js"
653
- ]
654
- },
655
712
  "workspace:install": {
656
713
  "aliases": [],
657
714
  "args": {
@@ -896,5 +953,5 @@
896
953
  ]
897
954
  }
898
955
  },
899
- "version": "0.16.0"
956
+ "version": "0.17.0"
900
957
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.16.0",
4
+ "version": "0.17.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"