hereya-cli 0.42.1 → 0.44.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.42.1 linux-x64 node-v22.17.1
23
+ hereya-cli/0.44.0 linux-x64 node-v22.17.1
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -56,6 +56,7 @@ USAGE
56
56
  * [`hereya workspace env unset`](#hereya-workspace-env-unset)
57
57
  * [`hereya workspace install PACKAGE`](#hereya-workspace-install-package)
58
58
  * [`hereya workspace list`](#hereya-workspace-list)
59
+ * [`hereya workspace set-profile PROFILE`](#hereya-workspace-set-profile-profile)
59
60
  * [`hereya workspace uninstall PACKAGE`](#hereya-workspace-uninstall-package)
60
61
 
61
62
  ## `hereya add PACKAGE`
@@ -70,8 +71,8 @@ ARGUMENTS
70
71
  PACKAGE The package to add, specified as a GitHub repository in the format owner/repository.
71
72
  To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to
72
73
  $HEREYA_REGISTRY_URL/owner/repository.
73
- For local packages, use the format local://path/to/package where path/to/package is the path to the package
74
- on your local machine.
74
+ For local packages, use the format local/path/to/package where path/to/package is the path to the package on
75
+ your local machine.
75
76
 
76
77
  FLAGS
77
78
  -p, --parameter=<value>... [default: ] parameter for the package, in the form of 'key=value'. Can be specified
@@ -89,7 +90,7 @@ EXAMPLES
89
90
  $ hereya add cloudy/docker_postgres
90
91
  ```
91
92
 
92
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/add/index.ts)_
93
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/add/index.ts)_
93
94
 
94
95
  ## `hereya bootstrap INFRASTRUCTURETYPE`
95
96
 
@@ -114,7 +115,7 @@ EXAMPLES
114
115
  $ hereya bootstrap local
115
116
  ```
116
117
 
117
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/bootstrap/index.ts)_
118
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/bootstrap/index.ts)_
118
119
 
119
120
  ## `hereya config export-backend [FILE]`
120
121
 
@@ -136,7 +137,7 @@ EXAMPLES
136
137
  $ hereya config export-backend ./path/to/export.json
137
138
  ```
138
139
 
139
- _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/config/export-backend/index.ts)_
140
+ _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/config/export-backend/index.ts)_
140
141
 
141
142
  ## `hereya config get-backend`
142
143
 
@@ -153,7 +154,7 @@ EXAMPLES
153
154
  $ hereya config get-backend
154
155
  ```
155
156
 
156
- _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/config/get-backend/index.ts)_
157
+ _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/config/get-backend/index.ts)_
157
158
 
158
159
  ## `hereya config import-backend FILE`
159
160
 
@@ -173,7 +174,7 @@ EXAMPLES
173
174
  $ hereya config import-backend ./path/to/cloud-backend.json
174
175
  ```
175
176
 
176
- _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/config/import-backend/index.ts)_
177
+ _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/config/import-backend/index.ts)_
177
178
 
178
179
  ## `hereya config use-backend TYPE`
179
180
 
@@ -195,7 +196,7 @@ EXAMPLES
195
196
  $ hereya config use-backend local
196
197
  ```
197
198
 
198
- _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/config/use-backend/index.ts)_
199
+ _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/config/use-backend/index.ts)_
199
200
 
200
201
  ## `hereya deploy`
201
202
 
@@ -220,7 +221,7 @@ EXAMPLES
220
221
  $ hereya deploy
221
222
  ```
222
223
 
223
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/deploy/index.ts)_
224
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/deploy/index.ts)_
224
225
 
225
226
  ## `hereya down`
226
227
 
@@ -247,7 +248,7 @@ EXAMPLES
247
248
  $ hereya down
248
249
  ```
249
250
 
250
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/down/index.ts)_
251
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/down/index.ts)_
251
252
 
252
253
  ## `hereya env [NAME]`
253
254
 
@@ -278,7 +279,7 @@ EXAMPLES
278
279
  $ hereya env -w dev -l
279
280
  ```
280
281
 
281
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/env/index.ts)_
282
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/env/index.ts)_
282
283
 
283
284
  ## `hereya env set [NAME]`
284
285
 
@@ -305,7 +306,7 @@ EXAMPLES
305
306
  $ hereya env set FOO -v bar -w dev
306
307
  ```
307
308
 
308
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/env/set/index.ts)_
309
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/env/set/index.ts)_
309
310
 
310
311
  ## `hereya help [COMMAND]`
311
312
 
@@ -339,8 +340,8 @@ ARGUMENTS
339
340
  PACKAGE The package to import, specified as a GitHub repository in the format owner/repository.
340
341
  To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to
341
342
  $HEREYA_REGISTRY_URL/owner/repository.
342
- For local packages, use the format local://path/to/package where path/to/package is the path to the package
343
- on your local machine.
343
+ For local packages, use the format local/path/to/package where path/to/package is the path to the package on
344
+ your local machine.
344
345
 
345
346
  FLAGS
346
347
  -f, --stateFile=<value> (required) state file to use
@@ -362,7 +363,7 @@ EXAMPLES
362
363
  $ hereya import org/my-package -f state.tfstate -w my-workspace
363
364
  ```
364
365
 
365
- _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/import/index.ts)_
366
+ _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/import/index.ts)_
366
367
 
367
368
  ## `hereya init PROJECT`
368
369
 
@@ -388,7 +389,7 @@ EXAMPLES
388
389
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
389
390
  ```
390
391
 
391
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/init/index.ts)_
392
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/init/index.ts)_
392
393
 
393
394
  ## `hereya login [URL]`
394
395
 
@@ -417,7 +418,7 @@ EXAMPLES
417
418
  $ hereya login --token=your-token https://cloud.hereya.dev
418
419
  ```
419
420
 
420
- _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/login/index.ts)_
421
+ _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/login/index.ts)_
421
422
 
422
423
  ## `hereya logout`
423
424
 
@@ -434,7 +435,7 @@ EXAMPLES
434
435
  $ hereya logout
435
436
  ```
436
437
 
437
- _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/logout/index.ts)_
438
+ _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/logout/index.ts)_
438
439
 
439
440
  ## `hereya remove PACKAGE`
440
441
 
@@ -461,7 +462,7 @@ EXAMPLES
461
462
  $ hereya remove cloudy/docker_postgres
462
463
  ```
463
464
 
464
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/remove/index.ts)_
465
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/remove/index.ts)_
465
466
 
466
467
  ## `hereya run CMD`
467
468
 
@@ -487,7 +488,7 @@ EXAMPLES
487
488
  $ hereya run -w uat -- node index.js
488
489
  ```
489
490
 
490
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/run/index.ts)_
491
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/run/index.ts)_
491
492
 
492
493
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
493
494
 
@@ -512,7 +513,7 @@ EXAMPLES
512
513
  $ hereya unbootstrap local
513
514
  ```
514
515
 
515
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/unbootstrap/index.ts)_
516
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/unbootstrap/index.ts)_
516
517
 
517
518
  ## `hereya undeploy`
518
519
 
@@ -537,7 +538,7 @@ EXAMPLES
537
538
  $ hereya undeploy
538
539
  ```
539
540
 
540
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/undeploy/index.ts)_
541
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/undeploy/index.ts)_
541
542
 
542
543
  ## `hereya up`
543
544
 
@@ -564,7 +565,7 @@ EXAMPLES
564
565
  $ hereya up
565
566
  ```
566
567
 
567
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/up/index.ts)_
568
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/up/index.ts)_
568
569
 
569
570
  ## `hereya workspace create NAME`
570
571
 
@@ -572,13 +573,14 @@ Create a new workspace if it does not exist.
572
573
 
573
574
  ```
574
575
  USAGE
575
- $ hereya workspace create NAME [--mirror <value>]
576
+ $ hereya workspace create NAME [--mirror <value>] [--profile <value>]
576
577
 
577
578
  ARGUMENTS
578
579
  NAME name of the workspace to create
579
580
 
580
581
  FLAGS
581
- --mirror=<value> workspace to mirror
582
+ --mirror=<value> workspace to mirror
583
+ --profile=<value> workspace profile to set (cloud backend only)
582
584
 
583
585
  DESCRIPTION
584
586
  Create a new workspace if it does not exist.
@@ -587,7 +589,7 @@ EXAMPLES
587
589
  $ hereya workspace create dev
588
590
  ```
589
591
 
590
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/create/index.ts)_
592
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/create/index.ts)_
591
593
 
592
594
  ## `hereya workspace delete NAME`
593
595
 
@@ -607,7 +609,7 @@ EXAMPLES
607
609
  $ hereya workspace delete dev
608
610
  ```
609
611
 
610
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/delete/index.ts)_
612
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/delete/index.ts)_
611
613
 
612
614
  ## `hereya workspace env [NAME]`
613
615
 
@@ -633,7 +635,7 @@ EXAMPLES
633
635
  $ hereya workspace env myEnv -w dev
634
636
  ```
635
637
 
636
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/env/index.ts)_
638
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/env/index.ts)_
637
639
 
638
640
  ## `hereya workspace env set`
639
641
 
@@ -657,7 +659,7 @@ EXAMPLES
657
659
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
658
660
  ```
659
661
 
660
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/env/set/index.ts)_
662
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/env/set/index.ts)_
661
663
 
662
664
  ## `hereya workspace env unset`
663
665
 
@@ -678,7 +680,7 @@ EXAMPLES
678
680
  $ hereya workspace env unset -w my-workspace -n myVar
679
681
  ```
680
682
 
681
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/env/unset/index.ts)_
683
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/env/unset/index.ts)_
682
684
 
683
685
  ## `hereya workspace install PACKAGE`
684
686
 
@@ -705,7 +707,7 @@ EXAMPLES
705
707
  $ hereya workspace install hereya/aws-cognito
706
708
  ```
707
709
 
708
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/install/index.ts)_
710
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/install/index.ts)_
709
711
 
710
712
  ## `hereya workspace list`
711
713
 
@@ -722,7 +724,30 @@ EXAMPLES
722
724
  $ hereya workspace list
723
725
  ```
724
726
 
725
- _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/list/index.ts)_
727
+ _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/list/index.ts)_
728
+
729
+ ## `hereya workspace set-profile PROFILE`
730
+
731
+ Set AWS profile for a workspace (cloud backend only).
732
+
733
+ ```
734
+ USAGE
735
+ $ hereya workspace set-profile PROFILE -w <value>
736
+
737
+ ARGUMENTS
738
+ PROFILE AWS profile name to set for the workspace
739
+
740
+ FLAGS
741
+ -w, --workspace=<value> (required) workspace name
742
+
743
+ DESCRIPTION
744
+ Set AWS profile for a workspace (cloud backend only).
745
+
746
+ EXAMPLES
747
+ $ hereya workspace set-profile prod-profile -w production
748
+ ```
749
+
750
+ _See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/set-profile/index.ts)_
726
751
 
727
752
  ## `hereya workspace uninstall PACKAGE`
728
753
 
@@ -749,5 +774,5 @@ EXAMPLES
749
774
  $ hereya workspace uninstall hereya/aws-cognito
750
775
  ```
751
776
 
752
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.42.1/src/commands/workspace/uninstall/index.ts)_
777
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.44.0/src/commands/workspace/uninstall/index.ts)_
753
778
  <!-- commandsstop -->
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../../lib/config/common.js';
2
- import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, ExportBackendOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, ImportBackendInput, ImportBackendOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput } from '../common.js';
2
+ import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, ExportBackendOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, ImportBackendInput, ImportBackendOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput, UpdateWorkspaceInput, UpdateWorkspaceOutput } from '../common.js';
3
3
  interface CloudBackendConfig {
4
4
  accessToken: string;
5
5
  clientId: string;
@@ -24,6 +24,7 @@ export declare class CloudBackend implements Backend {
24
24
  saveState(config: Config, workspace?: string): Promise<void>;
25
25
  setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
26
26
  unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
27
+ updateWorkspace(input: UpdateWorkspaceInput): Promise<UpdateWorkspaceOutput>;
27
28
  private convertWorkspace;
28
29
  }
29
30
  export {};
@@ -37,6 +37,9 @@ export class CloudBackend {
37
37
  if (input.mirrorOf) {
38
38
  formData.append('mirrorOf', input.mirrorOf);
39
39
  }
40
+ if (input.profile) {
41
+ formData.append('profile', input.profile);
42
+ }
40
43
  const response = await fetch(`${this.config.url}/api/workspaces`, {
41
44
  body: formData,
42
45
  headers: {
@@ -54,10 +57,7 @@ export class CloudBackend {
54
57
  return {
55
58
  isNew: true,
56
59
  success: true,
57
- workspace: {
58
- id: result.workspace.id,
59
- name: result.workspace.name,
60
- },
60
+ workspace: this.convertWorkspace(result.workspace),
61
61
  };
62
62
  }
63
63
  async deleteWorkspace(input) {
@@ -360,22 +360,54 @@ export class CloudBackend {
360
360
  success: true,
361
361
  };
362
362
  }
363
+ async updateWorkspace(input) {
364
+ const formData = new FormData();
365
+ if (input.profile !== undefined) {
366
+ formData.append('profile', input.profile === null ? '' : input.profile);
367
+ }
368
+ const response = await fetch(`${this.config.url}/api/workspaces/${encodeURIComponent(input.name)}`, {
369
+ body: formData,
370
+ headers: {
371
+ 'Authorization': `Bearer ${this.config.accessToken}`,
372
+ },
373
+ method: 'PATCH',
374
+ });
375
+ if (!response.ok) {
376
+ return {
377
+ reason: JSON.stringify(await response.json()),
378
+ success: false,
379
+ };
380
+ }
381
+ const result = await response.json();
382
+ return {
383
+ success: true,
384
+ workspace: this.convertWorkspace(result.workspace),
385
+ };
386
+ }
363
387
  convertWorkspace(workspace) {
364
388
  const env = {};
365
- for (const pkg of workspace.packages) {
366
- for (const e of pkg.env) {
367
- env[e.key] = `${e.infrastructure}:${e.value}`;
389
+ if (workspace.packages) {
390
+ for (const pkg of workspace.packages) {
391
+ if (pkg.env) {
392
+ for (const e of pkg.env) {
393
+ env[e.key] = `${e.infrastructure}:${e.value}`;
394
+ }
395
+ }
368
396
  }
369
397
  }
370
- for (const e of workspace.env) {
371
- env[e.key] = `${e.infrastructure}:${e.value}`;
398
+ if (workspace.env) {
399
+ for (const e of workspace.env) {
400
+ env[e.key] = `${e.infrastructure}:${e.value}`;
401
+ }
372
402
  }
373
403
  const packages = {};
374
- for (const pkg of workspace.packages) {
375
- packages[pkg.name] = {
376
- parameters: pkg.parameters,
377
- version: pkg.version,
378
- };
404
+ if (workspace.packages) {
405
+ for (const pkg of workspace.packages) {
406
+ packages[pkg.name] = {
407
+ parameters: pkg.parameters,
408
+ version: pkg.version,
409
+ };
410
+ }
379
411
  }
380
412
  return {
381
413
  env,
@@ -383,6 +415,7 @@ export class CloudBackend {
383
415
  mirrorOf: workspace.mirrorOf?.name,
384
416
  name: workspace.name,
385
417
  packages,
418
+ profile: workspace.profile === null ? undefined : workspace.profile,
386
419
  };
387
420
  }
388
421
  }
@@ -17,6 +17,7 @@ export interface Backend {
17
17
  saveState(config: Config, workspace?: string): Promise<void>;
18
18
  setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
19
19
  unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
20
+ updateWorkspace(input: UpdateWorkspaceInput): Promise<UpdateWorkspaceOutput>;
20
21
  }
21
22
  export declare const WorkspaceSchema: z.ZodObject<{
22
23
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -33,6 +34,7 @@ export declare const WorkspaceSchema: z.ZodObject<{
33
34
  version: string;
34
35
  parameters?: Record<string, any> | undefined;
35
36
  }>>>;
37
+ profile: z.ZodOptional<z.ZodString>;
36
38
  }, "strip", z.ZodTypeAny, {
37
39
  name: string;
38
40
  id: string;
@@ -42,6 +44,7 @@ export declare const WorkspaceSchema: z.ZodObject<{
42
44
  parameters?: Record<string, any> | undefined;
43
45
  }> | undefined;
44
46
  mirrorOf?: string | undefined;
47
+ profile?: string | undefined;
45
48
  }, {
46
49
  name: string;
47
50
  id: string;
@@ -51,6 +54,7 @@ export declare const WorkspaceSchema: z.ZodObject<{
51
54
  parameters?: Record<string, any> | undefined;
52
55
  }> | undefined;
53
56
  mirrorOf?: string | undefined;
57
+ profile?: string | undefined;
54
58
  }>;
55
59
  export type Workspace = z.infer<typeof WorkspaceSchema>;
56
60
  export type AddPackageToWorkspaceInput = {
@@ -90,6 +94,7 @@ export interface InitProjectOutput {
90
94
  export interface CreateWorkspaceInput {
91
95
  mirrorOf?: string;
92
96
  name: string;
97
+ profile?: string;
93
98
  }
94
99
  export type CreateWorkspaceOutput = {
95
100
  isNew: boolean;
@@ -194,3 +199,14 @@ export type UnsetEnvVarInput = {
194
199
  workspace: string;
195
200
  };
196
201
  export type UnsetEnvVarOutput = SetEnvVarOutput;
202
+ export type UpdateWorkspaceInput = {
203
+ name: string;
204
+ profile?: null | string;
205
+ };
206
+ export type UpdateWorkspaceOutput = {
207
+ reason: string;
208
+ success: false;
209
+ } | {
210
+ success: true;
211
+ workspace: Workspace;
212
+ };
@@ -10,4 +10,5 @@ export const WorkspaceSchema = z.object({
10
10
  version: z.string(),
11
11
  }))
12
12
  .optional(),
13
+ profile: z.string().optional(),
13
14
  });
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../lib/config/common.js';
2
- import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, ExportBackendOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, ImportBackendInput, ImportBackendOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput } from './common.js';
2
+ import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, ExportBackendOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, ImportBackendInput, ImportBackendOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput, UpdateWorkspaceInput, UpdateWorkspaceOutput } from './common.js';
3
3
  import { FileStorage } from './file-storage/common.js';
4
4
  export declare class FileBackend implements Backend {
5
5
  private readonly fileStorage;
@@ -19,5 +19,6 @@ export declare class FileBackend implements Backend {
19
19
  saveState(config: Config, workspace?: string): Promise<void>;
20
20
  setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
21
21
  unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
22
+ updateWorkspace(_: UpdateWorkspaceInput): Promise<UpdateWorkspaceOutput>;
22
23
  private saveWorkspace;
23
24
  }
@@ -427,6 +427,12 @@ export class FileBackend {
427
427
  success: true,
428
428
  };
429
429
  }
430
+ async updateWorkspace(_) {
431
+ return {
432
+ reason: 'Profile feature is not supported in file backend',
433
+ success: false,
434
+ };
435
+ }
430
436
  async saveWorkspace(data, name) {
431
437
  const paths = [['state', 'workspaces', `${name}.yaml`].join('/'), ['state', 'workspaces', `${name}.yml`].join('/')];
432
438
  await this.fileStorage.saveFileContent({ content: stringify(data), paths });
@@ -8,6 +8,7 @@ import { getEnvManager } from '../../lib/env/index.js';
8
8
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
9
9
  import { arrayOfStringToObject } from '../../lib/object-utils.js';
10
10
  import { getParameterManager } from '../../lib/parameter/index.js';
11
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
11
12
  import { delay } from '../../lib/shell.js';
12
13
  export default class Add extends Command {
13
14
  static args = {
@@ -15,7 +16,7 @@ export default class Add extends Command {
15
16
  description: `
16
17
  The package to add, specified as a GitHub repository in the format owner/repository.
17
18
  To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.
18
- For local packages, use the format local://path/to/package where path/to/package is the path to the package on your local machine.
19
+ For local packages, use the format local/path/to/package where path/to/package is the path to the package on your local machine.
19
20
  `,
20
21
  required: true,
21
22
  }),
@@ -74,11 +75,13 @@ export default class Add extends Command {
74
75
  async task(ctx) {
75
76
  const userSpecifiedParameters = arrayOfStringToObject(ctx.userSpecifiedParameters);
76
77
  const parameterManager = getParameterManager();
78
+ const backend = await getBackend();
79
+ const profile = await getProfileFromWorkspace(backend, ctx.configOutput.config.workspace);
77
80
  const parametersOutput = await parameterManager.getPackageParameters({
78
81
  package: ctx.package,
82
+ profile,
79
83
  projectRootDir,
80
84
  userSpecifiedParameters,
81
- workspace: ctx.configOutput.config.workspace,
82
85
  });
83
86
  ctx.parametersOutput = parametersOutput;
84
87
  await delay(500);
@@ -7,6 +7,7 @@ import { getConfigManager } from '../../lib/config/index.js';
7
7
  import { getEnvManager } from '../../lib/env/index.js';
8
8
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
9
9
  import { getParameterManager } from '../../lib/parameter/index.js';
10
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
10
11
  import { delay } from '../../lib/shell.js';
11
12
  export default class Deploy extends Command {
12
13
  static description = 'Deploy a hereya project using the project deployment package';
@@ -101,10 +102,12 @@ export default class Deploy extends Command {
101
102
  },
102
103
  async task(_, task) {
103
104
  const parameterManager = getParameterManager();
105
+ const backend = await getBackend();
106
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
104
107
  const { parameters } = await parameterManager.getPackageParameters({
105
108
  package: packageName,
109
+ profile,
106
110
  projectRootDir,
107
- workspace: ctx.workspace,
108
111
  });
109
112
  const executor$ = getExecutor();
110
113
  if (!executor$.success) {
@@ -139,10 +142,12 @@ export default class Deploy extends Command {
139
142
  },
140
143
  async task(_, task) {
141
144
  const parameterManager = getParameterManager();
145
+ const backend = await getBackend();
146
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
142
147
  const { parameters } = await parameterManager.getPackageParameters({
143
148
  package: packageName,
149
+ profile,
144
150
  projectRootDir,
145
- workspace: ctx.workspace,
146
151
  });
147
152
  const executor$ = getExecutor();
148
153
  if (!executor$.success) {
@@ -183,10 +188,12 @@ export default class Deploy extends Command {
183
188
  },
184
189
  async task(_, task) {
185
190
  const parameterManager = getParameterManager();
191
+ const backend = await getBackend();
192
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
186
193
  const { parameters } = await parameterManager.getPackageParameters({
187
194
  package: packageName,
195
+ profile,
188
196
  projectRootDir,
189
- workspace: ctx.workspace,
190
197
  });
191
198
  const executor$ = getExecutor();
192
199
  if (!executor$.success) {
@@ -284,10 +291,12 @@ export default class Deploy extends Command {
284
291
  },
285
292
  async task(_, task) {
286
293
  const parameterManager = getParameterManager();
294
+ const backend = await getBackend();
295
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
287
296
  const { parameters } = await parameterManager.getPackageParameters({
288
297
  package: packageName,
298
+ profile,
289
299
  projectRootDir,
290
- workspace: ctx.workspace,
291
300
  });
292
301
  const executor$ = getExecutor();
293
302
  if (!executor$.success) {
@@ -6,6 +6,7 @@ import { getConfigManager } from '../../lib/config/index.js';
6
6
  import { getEnvManager } from '../../lib/env/index.js';
7
7
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
8
8
  import { getParameterManager } from '../../lib/parameter/index.js';
9
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
9
10
  import { delay } from '../../lib/shell.js';
10
11
  export default class Down extends Command {
11
12
  static description = 'Destroy all packages in the project.';
@@ -94,10 +95,12 @@ export default class Down extends Command {
94
95
  },
95
96
  async task(_, task) {
96
97
  const parameterManager = getParameterManager();
98
+ const backend = await getBackend();
99
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
97
100
  const { parameters } = await parameterManager.getPackageParameters({
98
101
  package: packageName,
102
+ profile,
99
103
  projectRootDir,
100
- workspace: ctx.workspace,
101
104
  });
102
105
  const executor$ = getExecutor();
103
106
  if (!executor$.success) {
@@ -7,6 +7,7 @@ import { logEnv } from '../../lib/env-utils.js';
7
7
  import { getLogPath, isDebug, setDebug } from '../../lib/log.js';
8
8
  import { arrayOfStringToObject } from '../../lib/object-utils.js';
9
9
  import { getParameterManager } from '../../lib/parameter/index.js';
10
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
10
11
  import { delay } from '../../lib/shell.js';
11
12
  export default class Import extends Command {
12
13
  static args = {
@@ -14,7 +15,7 @@ export default class Import extends Command {
14
15
  description: `
15
16
  The package to import, specified as a GitHub repository in the format owner/repository.
16
17
  To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.
17
- For local packages, use the format local://path/to/package where path/to/package is the path to the package on your local machine.
18
+ For local packages, use the format local/path/to/package where path/to/package is the path to the package on your local machine.
18
19
  `,
19
20
  required: true,
20
21
  }),
@@ -88,11 +89,13 @@ export default class Import extends Command {
88
89
  async task(ctx) {
89
90
  const userSpecifiedParameters = arrayOfStringToObject(ctx.userSpecifiedParameters);
90
91
  const parameterManager = getParameterManager();
92
+ const backend = await getBackend();
93
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
91
94
  const parametersOutput = await parameterManager.getPackageParameters({
92
95
  package: ctx.package,
96
+ profile,
93
97
  projectRootDir,
94
98
  userSpecifiedParameters,
95
- workspace: ctx.workspace,
96
99
  });
97
100
  ctx.parametersOutput = parametersOutput;
98
101
  await delay(500);
@@ -6,6 +6,7 @@ import { getConfigManager } from '../../lib/config/index.js';
6
6
  import { getEnvManager } from '../../lib/env/index.js';
7
7
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
8
8
  import { getParameterManager } from '../../lib/parameter/index.js';
9
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
9
10
  import { delay } from '../../lib/shell.js';
10
11
  export default class Remove extends Command {
11
12
  static args = {
@@ -63,10 +64,12 @@ export default class Remove extends Command {
63
64
  {
64
65
  async task(ctx) {
65
66
  const parameterManager = getParameterManager();
67
+ const backend = await getBackend();
68
+ const profile = await getProfileFromWorkspace(backend, ctx.configOutput.config.workspace);
66
69
  const parametersOutput = await parameterManager.getPackageParameters({
67
70
  package: ctx.package,
71
+ profile,
68
72
  projectRootDir,
69
- workspace: ctx.configOutput.config.workspace,
70
73
  });
71
74
  ctx.parametersOutput = parametersOutput;
72
75
  await delay(500);
@@ -7,6 +7,7 @@ import { getConfigManager } from '../../lib/config/index.js';
7
7
  import { getEnvManager } from '../../lib/env/index.js';
8
8
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
9
9
  import { getParameterManager } from '../../lib/parameter/index.js';
10
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
10
11
  import { delay } from '../../lib/shell.js';
11
12
  export default class Undeploy extends Command {
12
13
  static description = 'Undeploy a hereya project by removing all resources.';
@@ -106,10 +107,12 @@ export default class Undeploy extends Command {
106
107
  },
107
108
  async task(_, task) {
108
109
  const parameterManager = getParameterManager();
110
+ const backend = await getBackend();
111
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
109
112
  const { parameters } = await parameterManager.getPackageParameters({
110
113
  package: packageName,
114
+ profile,
111
115
  projectRootDir,
112
- workspace: ctx.workspace,
113
116
  });
114
117
  const executor$ = getExecutor();
115
118
  if (!executor$.success) {
@@ -144,10 +147,12 @@ export default class Undeploy extends Command {
144
147
  },
145
148
  async task(_, task) {
146
149
  const parameterManager = getParameterManager();
150
+ const backend = await getBackend();
151
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
147
152
  const { parameters } = await parameterManager.getPackageParameters({
148
153
  package: packageName,
154
+ profile,
149
155
  projectRootDir,
150
- workspace: ctx.workspace,
151
156
  });
152
157
  const executor$ = getExecutor();
153
158
  if (!executor$.success) {
@@ -6,6 +6,7 @@ import { getConfigManager } from '../../lib/config/index.js';
6
6
  import { getEnvManager } from '../../lib/env/index.js';
7
7
  import { getLogger, getLogPath, isDebug, setDebug } from '../../lib/log.js';
8
8
  import { getParameterManager } from '../../lib/parameter/index.js';
9
+ import { getProfileFromWorkspace } from '../../lib/profile-utils.js';
9
10
  import { delay } from '../../lib/shell.js';
10
11
  export default class Up extends Command {
11
12
  static description = 'Provision all packages in the project.';
@@ -102,10 +103,12 @@ export default class Up extends Command {
102
103
  },
103
104
  async task(_, task) {
104
105
  const parameterManager = getParameterManager();
106
+ const backend = await getBackend();
107
+ const profile = await getProfileFromWorkspace(backend, workspace);
105
108
  const { parameters } = await parameterManager.getPackageParameters({
106
109
  package: packageName,
110
+ profile,
107
111
  projectRootDir,
108
- workspace,
109
112
  });
110
113
  const executor$ = getExecutor();
111
114
  if (!executor$.success) {
@@ -146,10 +149,12 @@ export default class Up extends Command {
146
149
  },
147
150
  async task(_, task) {
148
151
  const parameterManager = getParameterManager();
152
+ const backend = await getBackend();
153
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
149
154
  const { parameters } = await parameterManager.getPackageParameters({
150
155
  package: packageName,
156
+ profile,
151
157
  projectRootDir,
152
- workspace: ctx.workspace,
153
158
  });
154
159
  const executor$ = getExecutor();
155
160
  if (!executor$.success) {
@@ -7,6 +7,7 @@ export default class WorkspaceCreate extends Command {
7
7
  static examples: string[];
8
8
  static flags: {
9
9
  mirror: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
11
  };
11
12
  run(): Promise<void>;
12
13
  }
@@ -8,6 +8,7 @@ export default class WorkspaceCreate extends Command {
8
8
  static examples = ['<%= config.bin %> <%= command.id %> dev'];
9
9
  static flags = {
10
10
  mirror: Flags.string({ description: 'workspace to mirror', required: false }),
11
+ profile: Flags.string({ description: 'workspace profile to set (cloud backend only)', required: false }),
11
12
  };
12
13
  async run() {
13
14
  const { args, flags } = await this.parse(WorkspaceCreate);
@@ -15,6 +16,7 @@ export default class WorkspaceCreate extends Command {
15
16
  const createWorkspaceOutput = await backend.createWorkspace({
16
17
  mirrorOf: flags.mirror,
17
18
  name: args.name,
19
+ profile: flags.profile,
18
20
  });
19
21
  if (!createWorkspaceOutput.success) {
20
22
  this.error(`Failed to create workspace: ${createWorkspaceOutput.reason}`);
@@ -5,8 +5,53 @@ export default class WorkspaceList extends Command {
5
5
  static examples = ['<%= config.bin %> <%= command.id %>'];
6
6
  async run() {
7
7
  await this.parse(WorkspaceList);
8
- const backend = await getBackend();
9
- const output = await backend.listWorkspaces();
10
- this.log(output.join('\n'));
8
+ try {
9
+ const backend = await getBackend();
10
+ const workspaceNames = await backend.listWorkspaces();
11
+ // If no workspaces, show a message
12
+ if (workspaceNames.length === 0) {
13
+ this.log('No workspaces found.');
14
+ return;
15
+ }
16
+ // Fetch details for each workspace
17
+ const workspaceDetails = await Promise.all(workspaceNames.map(async (name) => {
18
+ try {
19
+ const result = await backend.getWorkspace(name);
20
+ if (result.found && !result.hasError) {
21
+ return {
22
+ mirrorOf: result.workspace.mirrorOf || '-',
23
+ name,
24
+ profile: result.workspace.profile || '-',
25
+ };
26
+ }
27
+ return {
28
+ mirrorOf: '-',
29
+ name,
30
+ profile: '-',
31
+ };
32
+ }
33
+ catch {
34
+ return {
35
+ mirrorOf: '-',
36
+ name,
37
+ profile: '-',
38
+ };
39
+ }
40
+ }));
41
+ // Calculate column widths for alignment
42
+ const nameWidth = Math.max(4, ...workspaceDetails.map(w => w.name.length)); // min 4 for "Name"
43
+ const profileWidth = Math.max(7, ...workspaceDetails.map(w => w.profile.length)); // min 7 for "Profile"
44
+ const mirrorWidth = Math.max(9, ...workspaceDetails.map(w => w.mirrorOf.length)); // min 9 for "Mirror Of"
45
+ // Display header
46
+ this.log(`${'Name'.padEnd(nameWidth)} ${'Profile'.padEnd(profileWidth)} ${'Mirror Of'.padEnd(mirrorWidth)}`);
47
+ this.log('-'.repeat(nameWidth + profileWidth + mirrorWidth + 4));
48
+ // Display rows
49
+ for (const workspace of workspaceDetails) {
50
+ this.log(`${workspace.name.padEnd(nameWidth)} ${workspace.profile.padEnd(profileWidth)} ${workspace.mirrorOf.padEnd(mirrorWidth)}`);
51
+ }
52
+ }
53
+ catch (error) {
54
+ this.error(`Failed to list workspaces: ${error}`);
55
+ }
11
56
  }
12
57
  }
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class WorkspaceSetProfile extends Command {
3
+ static args: {
4
+ profile: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ workspace: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,24 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import { getBackend } from '../../../backend/index.js';
3
+ export default class WorkspaceSetProfile extends Command {
4
+ static args = {
5
+ profile: Args.string({ description: 'AWS profile name to set for the workspace', required: true }),
6
+ };
7
+ static description = 'Set AWS profile for a workspace (cloud backend only).';
8
+ static examples = ['<%= config.bin %> <%= command.id %> prod-profile -w production'];
9
+ static flags = {
10
+ workspace: Flags.string({ char: 'w', description: 'workspace name', required: true }),
11
+ };
12
+ async run() {
13
+ const { args, flags } = await this.parse(WorkspaceSetProfile);
14
+ const backend = await getBackend();
15
+ const updateResult = await backend.updateWorkspace({
16
+ name: flags.workspace,
17
+ profile: args.profile,
18
+ });
19
+ if (!updateResult.success) {
20
+ this.error(`Failed to set profile: ${updateResult.reason}`);
21
+ }
22
+ this.log(`Profile '${args.profile}' set for workspace '${flags.workspace}' successfully!`);
23
+ }
24
+ }
@@ -1,17 +1,18 @@
1
1
  export declare class ParameterManager {
2
2
  getPackageParameters(input: GetPackageParametersInput): Promise<GetPackageParametersOutput>;
3
3
  savePackageParameters(input: SavePackageParametersInput): Promise<SavePackageParametersOutput>;
4
+ private extractProfileSections;
4
5
  private getParametersFolder;
5
6
  }
6
7
  export declare const parameterManager: ParameterManager;
7
8
  export declare function getParameterManager(): ParameterManager;
8
9
  export type GetPackageParametersInput = {
9
10
  package: string;
11
+ profile: string;
10
12
  projectRootDir?: string;
11
13
  userSpecifiedParameters?: {
12
14
  [key: string]: string;
13
15
  };
14
- workspace: string;
15
16
  };
16
17
  export type GetPackageParametersOutput = {
17
18
  parameters: {
@@ -1,20 +1,40 @@
1
+ import fs from 'node:fs/promises';
1
2
  import path from 'node:path';
2
3
  import { getAnyPath } from '../filesystem.js';
3
4
  import { getPackageCanonicalName } from '../package/index.js';
4
- import { load, save } from '../yaml-utils.js';
5
+ import { load, parseYaml, save } from '../yaml-utils.js';
5
6
  export class ParameterManager {
6
7
  async getPackageParameters(input) {
7
8
  const pkgName = getPackageCanonicalName(input.package);
8
- const fromFiles = await Promise.all([
9
- [`${pkgName}.yaml`, `${pkgName}.yml`],
10
- [`${pkgName}.${input.workspace}.yaml`, `${pkgName}.${input.workspace}.yml`],
11
- ].map(async ([filename, altFilename]) => {
12
- const filePath = await getAnyPath(path.join(await this.getParametersFolder(input.projectRootDir), filename), path.join(await this.getParametersFolder(input.projectRootDir), altFilename));
13
- const { data: parameters } = await load(filePath);
14
- return parameters;
15
- }));
16
- const fromUser = input.userSpecifiedParameters;
17
- const parameters = Object.assign({}, ...fromFiles, fromUser ?? {});
9
+ const paramsFolder = await this.getParametersFolder(input.projectRootDir);
10
+ // Load base file
11
+ const baseFilePath = await getAnyPath(path.join(paramsFolder, `${pkgName}.yaml`), path.join(paramsFolder, `${pkgName}.yml`));
12
+ // For base file, we need to extract just the first document (before any ---)
13
+ let baseParams = null;
14
+ if (baseFilePath) {
15
+ try {
16
+ const content = await fs.readFile(baseFilePath, 'utf8');
17
+ const firstDocIndex = content.indexOf('\n---');
18
+ const baseContent = firstDocIndex === -1 ? content : content.slice(0, Math.max(0, firstDocIndex));
19
+ const { data } = await parseYaml(baseContent);
20
+ baseParams = data;
21
+ }
22
+ catch {
23
+ baseParams = null;
24
+ }
25
+ }
26
+ // Load profile-specific file
27
+ const profileFilePath = await getAnyPath(path.join(paramsFolder, `${pkgName}.${input.profile}.yaml`), path.join(paramsFolder, `${pkgName}.${input.profile}.yml`));
28
+ const { data: profileParams } = await load(profileFilePath);
29
+ // Extract profile sections from base file
30
+ const profileSections = await this.extractProfileSections(baseFilePath, input.profile);
31
+ // Merge all parameters (order matters for precedence)
32
+ const parameters = {
33
+ ...baseParams,
34
+ ...profileParams,
35
+ ...profileSections,
36
+ ...input.userSpecifiedParameters
37
+ };
18
38
  return { parameters };
19
39
  }
20
40
  async savePackageParameters(input) {
@@ -46,6 +66,34 @@ export class ParameterManager {
46
66
  saved: true,
47
67
  };
48
68
  }
69
+ async extractProfileSections(filePath, targetProfile) {
70
+ if (!filePath)
71
+ return null;
72
+ try {
73
+ const content = await fs.readFile(filePath, 'utf8');
74
+ const documents = content.split(/^---$/m);
75
+ // Parse all documents in parallel
76
+ const parsedDocs = await Promise.all(documents.map(async (doc) => {
77
+ if (!doc.trim())
78
+ return null;
79
+ const { data } = await parseYaml(doc);
80
+ return data;
81
+ }));
82
+ // Find matching profile document
83
+ for (const data of parsedDocs) {
84
+ if (data && data.profile === targetProfile) {
85
+ // Remove the profile field and return the rest
86
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
+ const { profile, ...params } = data;
88
+ return params;
89
+ }
90
+ }
91
+ }
92
+ catch {
93
+ // Ignore errors, return null
94
+ }
95
+ return null;
96
+ }
49
97
  async getParametersFolder(projectRootDir) {
50
98
  return path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyavars');
51
99
  }
@@ -0,0 +1,2 @@
1
+ import { Backend } from '../backend/common.js';
2
+ export declare function getProfileFromWorkspace(backend: Backend, workspaceName: string): Promise<string>;
@@ -0,0 +1,9 @@
1
+ export async function getProfileFromWorkspace(backend, workspaceName) {
2
+ const workspace$ = await backend.getWorkspace(workspaceName);
3
+ if (!workspace$.found || workspace$.hasError) {
4
+ // Fallback to workspace name if workspace not found
5
+ return workspaceName;
6
+ }
7
+ // Use profile if defined, otherwise use workspace name
8
+ return workspace$.workspace.profile ?? workspaceName;
9
+ }
@@ -4,7 +4,7 @@
4
4
  "aliases": [],
5
5
  "args": {
6
6
  "package": {
7
- "description": "\n The package to add, specified as a GitHub repository in the format owner/repository.\n To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.\n For local packages, use the format local://path/to/package where path/to/package is the path to the package on your local machine.\n ",
7
+ "description": "\n The package to add, specified as a GitHub repository in the format owner/repository.\n To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.\n For local packages, use the format local/path/to/package where path/to/package is the path to the package on your local machine.\n ",
8
8
  "name": "package",
9
9
  "required": true
10
10
  }
@@ -268,7 +268,7 @@
268
268
  "aliases": [],
269
269
  "args": {
270
270
  "package": {
271
- "description": "\n The package to import, specified as a GitHub repository in the format owner/repository.\n To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.\n For local packages, use the format local://path/to/package where path/to/package is the path to the package on your local machine.\n ",
271
+ "description": "\n The package to import, specified as a GitHub repository in the format owner/repository.\n To change the registry URL, set the HEREYA_REGISTRY_URL environment variable, so that it points to $HEREYA_REGISTRY_URL/owner/repository.\n For local packages, use the format local/path/to/package where path/to/package is the path to the package on your local machine.\n ",
272
272
  "name": "package",
273
273
  "required": true
274
274
  }
@@ -899,6 +899,14 @@
899
899
  "hasDynamicHelp": false,
900
900
  "multiple": false,
901
901
  "type": "option"
902
+ },
903
+ "profile": {
904
+ "description": "workspace profile to set (cloud backend only)",
905
+ "name": "profile",
906
+ "required": false,
907
+ "hasDynamicHelp": false,
908
+ "multiple": false,
909
+ "type": "option"
902
910
  }
903
911
  },
904
912
  "hasDynamicHelp": false,
@@ -1088,6 +1096,47 @@
1088
1096
  "index.js"
1089
1097
  ]
1090
1098
  },
1099
+ "workspace:set-profile": {
1100
+ "aliases": [],
1101
+ "args": {
1102
+ "profile": {
1103
+ "description": "AWS profile name to set for the workspace",
1104
+ "name": "profile",
1105
+ "required": true
1106
+ }
1107
+ },
1108
+ "description": "Set AWS profile for a workspace (cloud backend only).",
1109
+ "examples": [
1110
+ "<%= config.bin %> <%= command.id %> prod-profile -w production"
1111
+ ],
1112
+ "flags": {
1113
+ "workspace": {
1114
+ "char": "w",
1115
+ "description": "workspace name",
1116
+ "name": "workspace",
1117
+ "required": true,
1118
+ "hasDynamicHelp": false,
1119
+ "multiple": false,
1120
+ "type": "option"
1121
+ }
1122
+ },
1123
+ "hasDynamicHelp": false,
1124
+ "hiddenAliases": [],
1125
+ "id": "workspace:set-profile",
1126
+ "pluginAlias": "hereya-cli",
1127
+ "pluginName": "hereya-cli",
1128
+ "pluginType": "core",
1129
+ "strict": true,
1130
+ "enableJsonFlag": false,
1131
+ "isESM": true,
1132
+ "relativePath": [
1133
+ "dist",
1134
+ "commands",
1135
+ "workspace",
1136
+ "set-profile",
1137
+ "index.js"
1138
+ ]
1139
+ },
1091
1140
  "workspace:uninstall": {
1092
1141
  "aliases": [],
1093
1142
  "args": {
@@ -1268,5 +1317,5 @@
1268
1317
  ]
1269
1318
  }
1270
1319
  },
1271
- "version": "0.42.1"
1320
+ "version": "0.44.0"
1272
1321
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.42.1",
4
+ "version": "0.44.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"