hereya-cli 0.46.0 → 0.48.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.46.0 linux-x64 node-v22.17.1
23
+ hereya-cli/0.48.0 linux-x64 node-v22.17.1
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -40,6 +40,9 @@ USAGE
40
40
  * [`hereya down`](#hereya-down)
41
41
  * [`hereya env [NAME]`](#hereya-env-name)
42
42
  * [`hereya env set [NAME]`](#hereya-env-set-name)
43
+ * [`hereya flow down`](#hereya-flow-down)
44
+ * [`hereya flow run CMD`](#hereya-flow-run-cmd)
45
+ * [`hereya flow up`](#hereya-flow-up)
43
46
  * [`hereya help [COMMAND]`](#hereya-help-command)
44
47
  * [`hereya import PACKAGE`](#hereya-import-package)
45
48
  * [`hereya init PROJECT`](#hereya-init-project)
@@ -66,7 +69,7 @@ Add a package to the project.
66
69
 
67
70
  ```
68
71
  USAGE
69
- $ hereya add PACKAGE [--chdir <value>] [--debug] [-p <value>...]
72
+ $ hereya add PACKAGE [--chdir <value>] [--debug] [-p <value>...] [-w <value>]
70
73
 
71
74
  ARGUMENTS
72
75
  PACKAGE The package to add, specified as a GitHub repository in the format owner/repository.
@@ -78,6 +81,7 @@ ARGUMENTS
78
81
  FLAGS
79
82
  -p, --parameter=<value>... [default: ] parameter for the package, in the form of 'key=value'. Can be specified
80
83
  multiple times.
84
+ -w, --workspace=<value> name of the workspace to add the package to (defaults to current workspace)
81
85
  --chdir=<value> Directory where the command will be executed.
82
86
  If not specified, it defaults to the current working directory.
83
87
  Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR
@@ -91,7 +95,7 @@ EXAMPLES
91
95
  $ hereya add cloudy/docker_postgres
92
96
  ```
93
97
 
94
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/add/index.ts)_
98
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/add/index.ts)_
95
99
 
96
100
  ## `hereya bootstrap INFRASTRUCTURETYPE`
97
101
 
@@ -116,7 +120,7 @@ EXAMPLES
116
120
  $ hereya bootstrap local
117
121
  ```
118
122
 
119
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/bootstrap/index.ts)_
123
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/bootstrap/index.ts)_
120
124
 
121
125
  ## `hereya config export-backend [FILE]`
122
126
 
@@ -138,7 +142,7 @@ EXAMPLES
138
142
  $ hereya config export-backend ./path/to/export.json
139
143
  ```
140
144
 
141
- _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/config/export-backend/index.ts)_
145
+ _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/config/export-backend/index.ts)_
142
146
 
143
147
  ## `hereya config get-backend`
144
148
 
@@ -155,7 +159,7 @@ EXAMPLES
155
159
  $ hereya config get-backend
156
160
  ```
157
161
 
158
- _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/config/get-backend/index.ts)_
162
+ _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/config/get-backend/index.ts)_
159
163
 
160
164
  ## `hereya config import-backend FILE`
161
165
 
@@ -175,7 +179,7 @@ EXAMPLES
175
179
  $ hereya config import-backend ./path/to/cloud-backend.json
176
180
  ```
177
181
 
178
- _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/config/import-backend/index.ts)_
182
+ _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/config/import-backend/index.ts)_
179
183
 
180
184
  ## `hereya config use-backend TYPE`
181
185
 
@@ -197,7 +201,7 @@ EXAMPLES
197
201
  $ hereya config use-backend local
198
202
  ```
199
203
 
200
- _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/config/use-backend/index.ts)_
204
+ _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/config/use-backend/index.ts)_
201
205
 
202
206
  ## `hereya delete-state`
203
207
 
@@ -223,7 +227,7 @@ EXAMPLES
223
227
  $ hereya delete-state --workspace staging
224
228
  ```
225
229
 
226
- _See code: [src/commands/delete-state/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/delete-state/index.ts)_
230
+ _See code: [src/commands/delete-state/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/delete-state/index.ts)_
227
231
 
228
232
  ## `hereya deploy`
229
233
 
@@ -248,7 +252,7 @@ EXAMPLES
248
252
  $ hereya deploy
249
253
  ```
250
254
 
251
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/deploy/index.ts)_
255
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/deploy/index.ts)_
252
256
 
253
257
  ## `hereya down`
254
258
 
@@ -275,7 +279,7 @@ EXAMPLES
275
279
  $ hereya down
276
280
  ```
277
281
 
278
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/down/index.ts)_
282
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/down/index.ts)_
279
283
 
280
284
  ## `hereya env [NAME]`
281
285
 
@@ -306,7 +310,7 @@ EXAMPLES
306
310
  $ hereya env -w dev -l
307
311
  ```
308
312
 
309
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/env/index.ts)_
313
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/env/index.ts)_
310
314
 
311
315
  ## `hereya env set [NAME]`
312
316
 
@@ -333,7 +337,104 @@ EXAMPLES
333
337
  $ hereya env set FOO -v bar -w dev
334
338
  ```
335
339
 
336
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/env/set/index.ts)_
340
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/env/set/index.ts)_
341
+
342
+ ## `hereya flow down`
343
+
344
+ Create a git branch-based workspace and destroy all packages
345
+
346
+ ```
347
+ USAGE
348
+ $ hereya flow down [--chdir <value>] [--debug] [--deploy] [--pin] [--profile <value>] [-s <value>...]
349
+
350
+ FLAGS
351
+ -s, --select=<value>... [default: ] select the packages to destroy
352
+ --chdir=<value> Directory where the command will be executed.
353
+ If not specified, it defaults to the current working directory.
354
+ Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR
355
+ environment variable.
356
+ --debug enable debug mode
357
+ --deploy destroy deployment companion packages
358
+ --pin append git commit SHA to workspace name for commit-specific isolation
359
+ --profile=<value> profile to use for the workspace (will be appended to workspace name)
360
+
361
+ DESCRIPTION
362
+ Create a git branch-based workspace and destroy all packages
363
+
364
+ EXAMPLES
365
+ $ hereya flow down
366
+
367
+ $ hereya flow down --debug
368
+
369
+ $ hereya flow down --profile staging
370
+
371
+ $ hereya flow down --pin
372
+ ```
373
+
374
+ _See code: [src/commands/flow/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/flow/down/index.ts)_
375
+
376
+ ## `hereya flow run CMD`
377
+
378
+ Run a command with hereya env vars in a git branch-based workspace
379
+
380
+ ```
381
+ USAGE
382
+ $ hereya flow run CMD... [--chdir <value>] [--pin] [--profile <value>]
383
+
384
+ ARGUMENTS
385
+ CMD... command to run
386
+
387
+ FLAGS
388
+ --chdir=<value> directory to run command in
389
+ --pin append git commit SHA to workspace name for commit-specific isolation
390
+ --profile=<value> profile to use for the workspace (will be appended to workspace name)
391
+
392
+ DESCRIPTION
393
+ Run a command with hereya env vars in a git branch-based workspace
394
+
395
+ EXAMPLES
396
+ $ hereya flow run -- npm run dev
397
+
398
+ $ hereya flow run --profile staging -- node index.js
399
+
400
+ $ hereya flow run --pin -- npm test
401
+ ```
402
+
403
+ _See code: [src/commands/flow/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/flow/run/index.ts)_
404
+
405
+ ## `hereya flow up`
406
+
407
+ Create a git branch-based workspace and provision all packages
408
+
409
+ ```
410
+ USAGE
411
+ $ hereya flow up [--chdir <value>] [--debug] [--deploy] [--pin] [--profile <value>] [-s <value>...]
412
+
413
+ FLAGS
414
+ -s, --select=<value>... [default: ] select the packages to provision
415
+ --chdir=<value> Directory where the command will be executed.
416
+ If not specified, it defaults to the current working directory.
417
+ Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR
418
+ environment variable.
419
+ --debug enable debug mode
420
+ --deploy provision deployment companion packages
421
+ --pin append git commit SHA to workspace name for commit-specific isolation
422
+ --profile=<value> profile to use for the workspace (will be appended to workspace name)
423
+
424
+ DESCRIPTION
425
+ Create a git branch-based workspace and provision all packages
426
+
427
+ EXAMPLES
428
+ $ hereya flow up
429
+
430
+ $ hereya flow up --debug
431
+
432
+ $ hereya flow up --profile staging
433
+
434
+ $ hereya flow up --pin
435
+ ```
436
+
437
+ _See code: [src/commands/flow/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/flow/up/index.ts)_
337
438
 
338
439
  ## `hereya help [COMMAND]`
339
440
 
@@ -390,7 +491,7 @@ EXAMPLES
390
491
  $ hereya import org/my-package -f state.tfstate -w my-workspace
391
492
  ```
392
493
 
393
- _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/import/index.ts)_
494
+ _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/import/index.ts)_
394
495
 
395
496
  ## `hereya init PROJECT`
396
497
 
@@ -416,7 +517,7 @@ EXAMPLES
416
517
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
417
518
  ```
418
519
 
419
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/init/index.ts)_
520
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/init/index.ts)_
420
521
 
421
522
  ## `hereya login [URL]`
422
523
 
@@ -445,7 +546,7 @@ EXAMPLES
445
546
  $ hereya login --token=your-token https://cloud.hereya.dev
446
547
  ```
447
548
 
448
- _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/login/index.ts)_
549
+ _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/login/index.ts)_
449
550
 
450
551
  ## `hereya logout`
451
552
 
@@ -462,7 +563,7 @@ EXAMPLES
462
563
  $ hereya logout
463
564
  ```
464
565
 
465
- _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/logout/index.ts)_
566
+ _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/logout/index.ts)_
466
567
 
467
568
  ## `hereya remove PACKAGE`
468
569
 
@@ -470,17 +571,18 @@ Remove a package from the project.
470
571
 
471
572
  ```
472
573
  USAGE
473
- $ hereya remove PACKAGE [--chdir <value>] [--debug]
574
+ $ hereya remove PACKAGE [--chdir <value>] [--debug] [-w <value>]
474
575
 
475
576
  ARGUMENTS
476
577
  PACKAGE Remove a previously added package.
477
578
 
478
579
  FLAGS
479
- --chdir=<value> Directory where the command will be executed.
480
- If not specified, it defaults to the current working directory.
481
- Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment
482
- variable.
483
- --debug enable debug mode
580
+ -w, --workspace=<value> name of the workspace to remove the package from (defaults to current workspace)
581
+ --chdir=<value> Directory where the command will be executed.
582
+ If not specified, it defaults to the current working directory.
583
+ Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR
584
+ environment variable.
585
+ --debug enable debug mode
484
586
 
485
587
  DESCRIPTION
486
588
  Remove a package from the project.
@@ -489,7 +591,7 @@ EXAMPLES
489
591
  $ hereya remove cloudy/docker_postgres
490
592
  ```
491
593
 
492
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/remove/index.ts)_
594
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/remove/index.ts)_
493
595
 
494
596
  ## `hereya run CMD`
495
597
 
@@ -515,7 +617,7 @@ EXAMPLES
515
617
  $ hereya run -w uat -- node index.js
516
618
  ```
517
619
 
518
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/run/index.ts)_
620
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/run/index.ts)_
519
621
 
520
622
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
521
623
 
@@ -540,7 +642,7 @@ EXAMPLES
540
642
  $ hereya unbootstrap local
541
643
  ```
542
644
 
543
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/unbootstrap/index.ts)_
645
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/unbootstrap/index.ts)_
544
646
 
545
647
  ## `hereya undeploy`
546
648
 
@@ -565,7 +667,7 @@ EXAMPLES
565
667
  $ hereya undeploy
566
668
  ```
567
669
 
568
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/undeploy/index.ts)_
670
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/undeploy/index.ts)_
569
671
 
570
672
  ## `hereya up`
571
673
 
@@ -592,7 +694,7 @@ EXAMPLES
592
694
  $ hereya up
593
695
  ```
594
696
 
595
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/up/index.ts)_
697
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/up/index.ts)_
596
698
 
597
699
  ## `hereya workspace create NAME`
598
700
 
@@ -616,7 +718,7 @@ EXAMPLES
616
718
  $ hereya workspace create dev
617
719
  ```
618
720
 
619
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/create/index.ts)_
721
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/create/index.ts)_
620
722
 
621
723
  ## `hereya workspace delete NAME`
622
724
 
@@ -636,7 +738,7 @@ EXAMPLES
636
738
  $ hereya workspace delete dev
637
739
  ```
638
740
 
639
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/delete/index.ts)_
741
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/delete/index.ts)_
640
742
 
641
743
  ## `hereya workspace env [NAME]`
642
744
 
@@ -662,7 +764,7 @@ EXAMPLES
662
764
  $ hereya workspace env myEnv -w dev
663
765
  ```
664
766
 
665
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/env/index.ts)_
767
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/env/index.ts)_
666
768
 
667
769
  ## `hereya workspace env set`
668
770
 
@@ -686,7 +788,7 @@ EXAMPLES
686
788
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
687
789
  ```
688
790
 
689
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/env/set/index.ts)_
791
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/env/set/index.ts)_
690
792
 
691
793
  ## `hereya workspace env unset`
692
794
 
@@ -707,7 +809,7 @@ EXAMPLES
707
809
  $ hereya workspace env unset -w my-workspace -n myVar
708
810
  ```
709
811
 
710
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/env/unset/index.ts)_
812
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/env/unset/index.ts)_
711
813
 
712
814
  ## `hereya workspace install PACKAGE`
713
815
 
@@ -734,7 +836,7 @@ EXAMPLES
734
836
  $ hereya workspace install hereya/aws-cognito
735
837
  ```
736
838
 
737
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/install/index.ts)_
839
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/install/index.ts)_
738
840
 
739
841
  ## `hereya workspace list`
740
842
 
@@ -751,7 +853,7 @@ EXAMPLES
751
853
  $ hereya workspace list
752
854
  ```
753
855
 
754
- _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/list/index.ts)_
856
+ _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/list/index.ts)_
755
857
 
756
858
  ## `hereya workspace set-profile PROFILE`
757
859
 
@@ -774,7 +876,7 @@ EXAMPLES
774
876
  $ hereya workspace set-profile prod-profile -w production
775
877
  ```
776
878
 
777
- _See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/set-profile/index.ts)_
879
+ _See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/set-profile/index.ts)_
778
880
 
779
881
  ## `hereya workspace uninstall PACKAGE`
780
882
 
@@ -801,5 +903,5 @@ EXAMPLES
801
903
  $ hereya workspace uninstall hereya/aws-cognito
802
904
  ```
803
905
 
804
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/workspace/uninstall/index.ts)_
906
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.48.0/src/commands/workspace/uninstall/index.ts)_
805
907
  <!-- commandsstop -->
@@ -9,6 +9,7 @@ export default class Add extends Command {
9
9
  chdir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
11
  parameter: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
12
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
13
  };
13
14
  run(): Promise<void>;
14
15
  }
@@ -42,6 +42,11 @@ export default class Add extends Command {
42
42
  description: "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
43
43
  multiple: true,
44
44
  }),
45
+ workspace: Flags.string({
46
+ char: 'w',
47
+ description: 'name of the workspace to add the package to (defaults to current workspace)',
48
+ required: false,
49
+ }),
45
50
  };
46
51
  async run() {
47
52
  const { args, flags } = await this.parse(Add);
@@ -66,6 +71,8 @@ export default class Add extends Command {
66
71
  throw new Error("Project not initialized. Run 'hereya init' first.");
67
72
  }
68
73
  ctx.configOutput = loadConfigOutput;
74
+ // Use workspace from flag if provided, otherwise use config workspace
75
+ ctx.workspace = flags.workspace || loadConfigOutput.config.workspace;
69
76
  task.output = `Loaded project config`;
70
77
  await delay(500);
71
78
  },
@@ -76,7 +83,7 @@ export default class Add extends Command {
76
83
  const userSpecifiedParameters = arrayOfStringToObject(ctx.userSpecifiedParameters);
77
84
  const parameterManager = getParameterManager();
78
85
  const backend = await getBackend();
79
- const profile = await getProfileFromWorkspace(backend, ctx.configOutput.config.workspace);
86
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
80
87
  const parametersOutput = await parameterManager.getPackageParameters({
81
88
  package: ctx.package,
82
89
  profile,
@@ -105,7 +112,7 @@ export default class Add extends Command {
105
112
  project: ctx.configOutput.config.project,
106
113
  projectRootDir,
107
114
  skipDeploy: true,
108
- workspace: ctx.configOutput.config.workspace,
115
+ workspace: ctx.workspace,
109
116
  });
110
117
  if (!provisionOutput.success) {
111
118
  throw new Error(provisionOutput.reason);
@@ -122,7 +129,7 @@ export default class Add extends Command {
122
129
  env,
123
130
  infra: metadata.originalInfra ?? metadata.infra,
124
131
  projectRootDir,
125
- workspace: ctx.configOutput.config.workspace,
132
+ workspace: ctx.workspace,
126
133
  });
127
134
  await delay(500);
128
135
  },
@@ -145,13 +152,13 @@ export default class Add extends Command {
145
152
  const backend = await getBackend();
146
153
  const configManager = getConfigManager();
147
154
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
148
- await backend.saveState(newConfig);
155
+ await backend.saveState(newConfig, ctx.workspace);
149
156
  const parameterManager = getParameterManager();
150
157
  const { filePath, saved } = await parameterManager.savePackageParameters({
151
158
  package: ctx.package,
152
159
  parameters: ctx.parametersOutput.parameters,
153
160
  projectRootDir,
154
- workspace: ctx.configOutput.config.workspace,
161
+ workspace: ctx.workspace,
155
162
  });
156
163
  await delay(500);
157
164
  if (saved) {
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { getConfigManager } from '../../../lib/config/index.js';
4
4
  import { getEnvManager } from '../../../lib/env/index.js';
5
5
  import { getAnyPath } from '../../../lib/filesystem.js';
6
+ import { stripOrgPrefix } from '../../../lib/org-utils.js';
6
7
  import { load, save } from '../../../lib/yaml-utils.js';
7
8
  export default class EnvSet extends Command {
8
9
  static args = {
@@ -43,8 +44,9 @@ export default class EnvSet extends Command {
43
44
  }
44
45
  const envManager = getEnvManager();
45
46
  const envDir = await envManager.getStaticEnvDir(projectRootDir);
46
- const candidates = flags.workspace
47
- ? [path.join(envDir, `env.${flags.workspace}.yaml`), path.join(envDir, `env.${flags.workspace}.yml`)]
47
+ const workspaceName = flags.workspace ? stripOrgPrefix(flags.workspace) : null;
48
+ const candidates = workspaceName
49
+ ? [path.join(envDir, `env.${workspaceName}.yaml`), path.join(envDir, `env.${workspaceName}.yml`)]
48
50
  : [path.join(envDir, `env.yaml`), path.join(envDir, `env.yml`)];
49
51
  const envFile = await getAnyPath(...candidates);
50
52
  const { data: env } = await load(envFile);
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class FlowDown extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ chdir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ deploy: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ pin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ select: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,110 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { getConfigManager } from '../../../lib/config/index.js';
3
+ import { gitUtils } from '../../../lib/git-utils.js';
4
+ import { setDebug } from '../../../lib/log.js';
5
+ import DeleteState from '../../delete-state/index.js';
6
+ import Down from '../../down/index.js';
7
+ import WorkspaceCreate from '../../workspace/create/index.js';
8
+ import WorkspaceDelete from '../../workspace/delete/index.js';
9
+ export default class FlowDown extends Command {
10
+ static description = 'Create a git branch-based workspace and destroy all packages';
11
+ static examples = [
12
+ '<%= config.bin %> <%= command.id %>',
13
+ '<%= config.bin %> <%= command.id %> --debug',
14
+ '<%= config.bin %> <%= command.id %> --profile staging',
15
+ '<%= config.bin %> <%= command.id %> --pin',
16
+ ];
17
+ static flags = {
18
+ chdir: Flags.string({
19
+ description: `
20
+ Directory where the command will be executed.
21
+ If not specified, it defaults to the current working directory.
22
+ Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.
23
+ `,
24
+ required: false,
25
+ }),
26
+ debug: Flags.boolean({
27
+ default: false,
28
+ description: 'enable debug mode',
29
+ }),
30
+ deploy: Flags.boolean({
31
+ description: 'destroy deployment companion packages',
32
+ required: false,
33
+ }),
34
+ pin: Flags.boolean({
35
+ description: 'append git commit SHA to workspace name for commit-specific isolation',
36
+ required: false,
37
+ }),
38
+ profile: Flags.string({
39
+ description: 'profile to use for the workspace (will be appended to workspace name)',
40
+ required: false,
41
+ }),
42
+ select: Flags.string({
43
+ char: 's',
44
+ default: [],
45
+ description: 'select the packages to destroy',
46
+ multiple: true,
47
+ }),
48
+ };
49
+ async run() {
50
+ const { flags } = await this.parse(FlowDown);
51
+ setDebug(flags.debug);
52
+ const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
53
+ // Load project config
54
+ const configManager = getConfigManager();
55
+ const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
56
+ if (!loadConfigOutput.found) {
57
+ this.error("Project not initialized. Run 'hereya init' first.");
58
+ }
59
+ // Get current git branch
60
+ const gitBranch = await gitUtils.getCurrentGitBranch(projectRootDir);
61
+ // Sanitize branch name
62
+ const sanitizedBranch = gitUtils.sanitizeBranchName(gitBranch);
63
+ if (!sanitizedBranch) {
64
+ this.error('Branch name contains only special characters and cannot be used for workspace name');
65
+ }
66
+ // Get commit SHA if pin flag is set
67
+ const commitSHA = flags.pin ? await gitUtils.getShortCommitSHA(projectRootDir) : null;
68
+ // Build workspace name parts
69
+ const parts = [loadConfigOutput.config.project, sanitizedBranch];
70
+ if (flags.profile)
71
+ parts.push(flags.profile);
72
+ if (commitSHA)
73
+ parts.push(commitSHA);
74
+ const workspaceName = parts.join('---');
75
+ // Create workspace with mirror
76
+ const createArgs = [workspaceName, '--mirror', loadConfigOutput.config.workspace];
77
+ if (projectRootDir) {
78
+ createArgs.push('--chdir', projectRootDir);
79
+ }
80
+ if (flags.debug) {
81
+ createArgs.push('--debug');
82
+ }
83
+ if (flags.profile) {
84
+ createArgs.push('--profile', flags.profile);
85
+ }
86
+ await WorkspaceCreate.run(createArgs);
87
+ // Run down command with the new workspace and all flags
88
+ const downArgs = ['--workspace', workspaceName];
89
+ // Pass through all flags
90
+ if (flags.chdir)
91
+ downArgs.push('--chdir', flags.chdir);
92
+ if (flags.debug)
93
+ downArgs.push('--debug');
94
+ if (flags.deploy)
95
+ downArgs.push('--deploy');
96
+ for (const pkg of flags.select) {
97
+ downArgs.push('--select', pkg);
98
+ }
99
+ await Down.run(downArgs);
100
+ // Delete state
101
+ const deleteStateArgs = ['--workspace', workspaceName];
102
+ if (projectRootDir) {
103
+ deleteStateArgs.push('--chdir', projectRootDir);
104
+ }
105
+ await DeleteState.run(deleteStateArgs);
106
+ // Delete workspace
107
+ const deleteWorkspaceArgs = [workspaceName];
108
+ await WorkspaceDelete.run(deleteWorkspaceArgs);
109
+ }
110
+ }
@@ -0,0 +1,15 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class FlowRun extends Command {
3
+ static args: {
4
+ cmd: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ chdir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ pin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ static strict: boolean;
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,66 @@
1
+ import { Args, Command, Flags } from '@oclif/core';
2
+ import { getConfigManager } from '../../../lib/config/index.js';
3
+ import { gitUtils } from '../../../lib/git-utils.js';
4
+ import Run from '../../run/index.js';
5
+ export default class FlowRun extends Command {
6
+ static args = {
7
+ cmd: Args.string({ description: 'command to run', required: true }),
8
+ };
9
+ static description = 'Run a command with hereya env vars in a git branch-based workspace';
10
+ static examples = [
11
+ '<%= config.bin %> <%= command.id %> -- npm run dev',
12
+ '<%= config.bin %> <%= command.id %> --profile staging -- node index.js',
13
+ '<%= config.bin %> <%= command.id %> --pin -- npm test',
14
+ ];
15
+ static flags = {
16
+ chdir: Flags.string({
17
+ description: 'directory to run command in',
18
+ required: false,
19
+ }),
20
+ pin: Flags.boolean({
21
+ description: 'append git commit SHA to workspace name for commit-specific isolation',
22
+ required: false,
23
+ }),
24
+ profile: Flags.string({
25
+ description: 'profile to use for the workspace (will be appended to workspace name)',
26
+ required: false,
27
+ }),
28
+ };
29
+ static strict = false;
30
+ async run() {
31
+ const { argv, flags } = await this.parse(FlowRun);
32
+ const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
33
+ // Load project config
34
+ const configManager = getConfigManager();
35
+ const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
36
+ if (!loadConfigOutput.found) {
37
+ this.error("Project not initialized. Run 'hereya init' first.");
38
+ }
39
+ // Get current git branch
40
+ const gitBranch = await gitUtils.getCurrentGitBranch(projectRootDir);
41
+ // Sanitize branch name
42
+ const sanitizedBranch = gitUtils.sanitizeBranchName(gitBranch);
43
+ if (!sanitizedBranch) {
44
+ this.error('Branch name contains only special characters and cannot be used for workspace name');
45
+ }
46
+ // Get commit SHA if pin flag is set
47
+ const commitSHA = flags.pin ? await gitUtils.getShortCommitSHA(projectRootDir) : null;
48
+ // Build workspace name parts
49
+ const parts = [loadConfigOutput.config.project, sanitizedBranch];
50
+ if (flags.profile)
51
+ parts.push(flags.profile);
52
+ if (commitSHA)
53
+ parts.push(commitSHA);
54
+ const workspaceName = parts.join('---');
55
+ // Build args for run command
56
+ const runArgs = ['--workspace', workspaceName];
57
+ // Pass through chdir flag
58
+ if (flags.chdir)
59
+ runArgs.push('--chdir', flags.chdir);
60
+ // Add the command and its arguments
61
+ // argv contains all the arguments after the double dash
62
+ const allCmdArgs = argv;
63
+ runArgs.push('--', ...allCmdArgs);
64
+ await Run.run(runArgs);
65
+ }
66
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class FlowUp extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ chdir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ deploy: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ pin: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ select: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<void>;
14
+ }
@@ -0,0 +1,99 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { getConfigManager } from '../../../lib/config/index.js';
3
+ import { gitUtils } from '../../../lib/git-utils.js';
4
+ import { setDebug } from '../../../lib/log.js';
5
+ import Up from '../../up/index.js';
6
+ import WorkspaceCreate from '../../workspace/create/index.js';
7
+ export default class FlowUp extends Command {
8
+ static description = 'Create a git branch-based workspace and provision all packages';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %>',
11
+ '<%= config.bin %> <%= command.id %> --debug',
12
+ '<%= config.bin %> <%= command.id %> --profile staging',
13
+ '<%= config.bin %> <%= command.id %> --pin',
14
+ ];
15
+ static flags = {
16
+ chdir: Flags.string({
17
+ description: `
18
+ Directory where the command will be executed.
19
+ If not specified, it defaults to the current working directory.
20
+ Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.
21
+ `,
22
+ required: false,
23
+ }),
24
+ debug: Flags.boolean({
25
+ default: false,
26
+ description: 'enable debug mode',
27
+ }),
28
+ deploy: Flags.boolean({
29
+ description: 'provision deployment companion packages',
30
+ required: false,
31
+ }),
32
+ pin: Flags.boolean({
33
+ description: 'append git commit SHA to workspace name for commit-specific isolation',
34
+ required: false,
35
+ }),
36
+ profile: Flags.string({
37
+ description: 'profile to use for the workspace (will be appended to workspace name)',
38
+ required: false,
39
+ }),
40
+ select: Flags.string({
41
+ char: 's',
42
+ default: [],
43
+ description: 'select the packages to provision',
44
+ multiple: true,
45
+ }),
46
+ };
47
+ async run() {
48
+ const { flags } = await this.parse(FlowUp);
49
+ setDebug(flags.debug);
50
+ const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
51
+ // Load project config
52
+ const configManager = getConfigManager();
53
+ const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
54
+ if (!loadConfigOutput.found) {
55
+ this.error("Project not initialized. Run 'hereya init' first.");
56
+ }
57
+ // Get current git branch
58
+ const gitBranch = await gitUtils.getCurrentGitBranch(projectRootDir);
59
+ // Sanitize branch name
60
+ const sanitizedBranch = gitUtils.sanitizeBranchName(gitBranch);
61
+ if (!sanitizedBranch) {
62
+ this.error('Branch name contains only special characters and cannot be used for workspace name');
63
+ }
64
+ // Get commit SHA if pin flag is set
65
+ const commitSHA = flags.pin ? await gitUtils.getShortCommitSHA(projectRootDir) : null;
66
+ // Build workspace name parts
67
+ const parts = [loadConfigOutput.config.project, sanitizedBranch];
68
+ if (flags.profile)
69
+ parts.push(flags.profile);
70
+ if (commitSHA)
71
+ parts.push(commitSHA);
72
+ const workspaceName = parts.join('---');
73
+ // Create workspace with mirror
74
+ const createArgs = [workspaceName, '--mirror', loadConfigOutput.config.workspace];
75
+ if (projectRootDir) {
76
+ createArgs.push('--chdir', projectRootDir);
77
+ }
78
+ if (flags.debug) {
79
+ createArgs.push('--debug');
80
+ }
81
+ if (flags.profile) {
82
+ createArgs.push('--profile', flags.profile);
83
+ }
84
+ await WorkspaceCreate.run(createArgs);
85
+ // Run up command with the new workspace and all flags
86
+ const upArgs = ['--workspace', workspaceName];
87
+ // Pass through all flags
88
+ if (flags.chdir)
89
+ upArgs.push('--chdir', flags.chdir);
90
+ if (flags.debug)
91
+ upArgs.push('--debug');
92
+ if (flags.deploy)
93
+ upArgs.push('--deploy');
94
+ for (const pkg of flags.select) {
95
+ upArgs.push('--select', pkg);
96
+ }
97
+ await Up.run(upArgs);
98
+ }
99
+ }
@@ -8,6 +8,7 @@ export default class Remove extends Command {
8
8
  static flags: {
9
9
  chdir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  debug: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
12
  };
12
13
  run(): Promise<void>;
13
14
  }
@@ -30,6 +30,11 @@ export default class Remove extends Command {
30
30
  default: false,
31
31
  description: 'enable debug mode',
32
32
  }),
33
+ workspace: Flags.string({
34
+ char: 'w',
35
+ description: 'name of the workspace to remove the package from (defaults to current workspace)',
36
+ required: false,
37
+ }),
33
38
  };
34
39
  async run() {
35
40
  const { args, flags } = await this.parse(Remove);
@@ -53,6 +58,8 @@ export default class Remove extends Command {
53
58
  throw new Error("Project not initialized. Run 'hereya init' first.");
54
59
  }
55
60
  ctx.configOutput = loadConfigOutput;
61
+ // Use workspace from flag if provided, otherwise use config workspace
62
+ ctx.workspace = flags.workspace || loadConfigOutput.config.workspace;
56
63
  const { config } = loadConfigOutput;
57
64
  if (!(ctx.package in (config.packages ?? {})) && !(ctx.package in (config.deploy ?? {}))) {
58
65
  throw new Error(`Package ${ctx.package} not found in the project.`);
@@ -65,7 +72,7 @@ export default class Remove extends Command {
65
72
  async task(ctx) {
66
73
  const parameterManager = getParameterManager();
67
74
  const backend = await getBackend();
68
- const profile = await getProfileFromWorkspace(backend, ctx.configOutput.config.workspace);
75
+ const profile = await getProfileFromWorkspace(backend, ctx.workspace);
69
76
  const parametersOutput = await parameterManager.getPackageParameters({
70
77
  package: ctx.package,
71
78
  profile,
@@ -93,7 +100,7 @@ export default class Remove extends Command {
93
100
  project: ctx.configOutput.config.project,
94
101
  projectRootDir,
95
102
  skipDeploy: true,
96
- workspace: ctx.configOutput.config.workspace,
103
+ workspace: ctx.workspace,
97
104
  });
98
105
  if (!destroyOutput.success) {
99
106
  throw new Error(destroyOutput.reason);
@@ -109,7 +116,7 @@ export default class Remove extends Command {
109
116
  env: ctx.destroyOutput.env,
110
117
  infra: ctx.destroyOutput.metadata.infra,
111
118
  projectRootDir,
112
- workspace: ctx.configOutput.config.workspace,
119
+ workspace: ctx.workspace,
113
120
  });
114
121
  await delay(500);
115
122
  },
@@ -128,11 +135,11 @@ export default class Remove extends Command {
128
135
  title: 'Removing package from hereya manifest',
129
136
  },
130
137
  {
131
- async task() {
138
+ async task(ctx) {
132
139
  const backend = await getBackend();
133
140
  const configManager = getConfigManager();
134
141
  const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
135
- await backend.saveState(newConfig);
142
+ await backend.saveState(newConfig, ctx.workspace);
136
143
  await delay(500);
137
144
  },
138
145
  title: 'Saving state',
@@ -2,6 +2,7 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { getExecutor } from '../../executor/index.js';
4
4
  import { getAnyPath } from '../filesystem.js';
5
+ import { stripOrgPrefix } from '../org-utils.js';
5
6
  import { load, parseYaml, save } from '../yaml-utils.js';
6
7
  export class EnvManager {
7
8
  async addProjectEnv(input) {
@@ -92,7 +93,8 @@ export class EnvManager {
92
93
  return null;
93
94
  }
94
95
  async getEnvPath(input) {
95
- return getAnyPath(path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${input.workspace}.yaml`), path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${input.workspace}.yml`));
96
+ const workspaceName = stripOrgPrefix(input.workspace);
97
+ return getAnyPath(path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${workspaceName}.yaml`), path.join(input.projectRootDir ?? process.cwd(), '.hereya', `env.${workspaceName}.yml`));
96
98
  }
97
99
  async getUserEnvPaths(profile, projectRootDir) {
98
100
  const paths = await Promise.all([
@@ -0,0 +1,29 @@
1
+ export declare const gitUtils: {
2
+ /**
3
+ * Gets the current git branch name.
4
+ * @param cwd The working directory to execute git command in
5
+ * @returns The current branch name
6
+ * @throws Error if not in a git repository or git command fails
7
+ */
8
+ getCurrentGitBranch(cwd?: string): Promise<string>;
9
+ /**
10
+ * Gets the short commit SHA of the current HEAD.
11
+ * @param cwd The working directory to execute git command in
12
+ * @returns The short commit SHA (7 characters by default)
13
+ * @throws Error if not in a git repository or git command fails
14
+ */
15
+ getShortCommitSHA(cwd?: string): Promise<string>;
16
+ /**
17
+ * Checks if the current directory is a git repository.
18
+ * @param cwd The working directory to check
19
+ * @returns true if in a git repository, false otherwise
20
+ */
21
+ isGitRepository(cwd?: string): Promise<boolean>;
22
+ /**
23
+ * Sanitizes a git branch name for use in workspace names.
24
+ * Keeps only alphanumeric characters, hyphens (-), and underscores (_).
25
+ * @param branch The branch name to sanitize
26
+ * @returns The sanitized branch name
27
+ */
28
+ sanitizeBranchName(branch: string): string;
29
+ };
@@ -0,0 +1,62 @@
1
+ import { runShell } from './shell.js';
2
+ export const gitUtils = {
3
+ /**
4
+ * Gets the current git branch name.
5
+ * @param cwd The working directory to execute git command in
6
+ * @returns The current branch name
7
+ * @throws Error if not in a git repository or git command fails
8
+ */
9
+ async getCurrentGitBranch(cwd) {
10
+ try {
11
+ const { stdout } = await runShell('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { directory: cwd });
12
+ return stdout.trim();
13
+ }
14
+ catch (error) {
15
+ if (error.message.includes('not a git repository') || error.message.includes('exit code "128"')) {
16
+ throw new Error('Not in a git repository. The flow commands require git integration.');
17
+ }
18
+ throw new Error(`Failed to get current git branch: ${error.message}`);
19
+ }
20
+ },
21
+ /**
22
+ * Gets the short commit SHA of the current HEAD.
23
+ * @param cwd The working directory to execute git command in
24
+ * @returns The short commit SHA (7 characters by default)
25
+ * @throws Error if not in a git repository or git command fails
26
+ */
27
+ async getShortCommitSHA(cwd) {
28
+ try {
29
+ const { stdout } = await runShell('git', ['rev-parse', '--short', 'HEAD'], { directory: cwd });
30
+ return stdout.trim();
31
+ }
32
+ catch (error) {
33
+ if (error.message.includes('not a git repository') || error.message.includes('exit code "128"')) {
34
+ throw new Error('Not in a git repository. The flow commands require git integration.');
35
+ }
36
+ throw new Error(`Failed to get commit SHA: ${error.message}`);
37
+ }
38
+ },
39
+ /**
40
+ * Checks if the current directory is a git repository.
41
+ * @param cwd The working directory to check
42
+ * @returns true if in a git repository, false otherwise
43
+ */
44
+ async isGitRepository(cwd) {
45
+ try {
46
+ await runShell('git', ['rev-parse', '--git-dir'], { directory: cwd });
47
+ return true;
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ },
53
+ /**
54
+ * Sanitizes a git branch name for use in workspace names.
55
+ * Keeps only alphanumeric characters, hyphens (-), and underscores (_).
56
+ * @param branch The branch name to sanitize
57
+ * @returns The sanitized branch name
58
+ */
59
+ sanitizeBranchName(branch) {
60
+ return branch.replaceAll(/[^a-zA-Z0-9_-]/g, '');
61
+ }
62
+ };
@@ -36,6 +36,15 @@
36
36
  "hasDynamicHelp": false,
37
37
  "multiple": true,
38
38
  "type": "option"
39
+ },
40
+ "workspace": {
41
+ "char": "w",
42
+ "description": "name of the workspace to add the package to (defaults to current workspace)",
43
+ "name": "workspace",
44
+ "required": false,
45
+ "hasDynamicHelp": false,
46
+ "multiple": false,
47
+ "type": "option"
39
48
  }
40
49
  },
41
50
  "hasDynamicHelp": false,
@@ -525,6 +534,15 @@
525
534
  "name": "debug",
526
535
  "allowNo": false,
527
536
  "type": "boolean"
537
+ },
538
+ "workspace": {
539
+ "char": "w",
540
+ "description": "name of the workspace to remove the package from (defaults to current workspace)",
541
+ "name": "workspace",
542
+ "required": false,
543
+ "hasDynamicHelp": false,
544
+ "multiple": false,
545
+ "type": "option"
528
546
  }
529
547
  },
530
548
  "hasDynamicHelp": false,
@@ -921,6 +939,211 @@
921
939
  "index.js"
922
940
  ]
923
941
  },
942
+ "flow:down": {
943
+ "aliases": [],
944
+ "args": {},
945
+ "description": "Create a git branch-based workspace and destroy all packages",
946
+ "examples": [
947
+ "<%= config.bin %> <%= command.id %>",
948
+ "<%= config.bin %> <%= command.id %> --debug",
949
+ "<%= config.bin %> <%= command.id %> --profile staging",
950
+ "<%= config.bin %> <%= command.id %> --pin"
951
+ ],
952
+ "flags": {
953
+ "chdir": {
954
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
955
+ "name": "chdir",
956
+ "required": false,
957
+ "hasDynamicHelp": false,
958
+ "multiple": false,
959
+ "type": "option"
960
+ },
961
+ "debug": {
962
+ "description": "enable debug mode",
963
+ "name": "debug",
964
+ "allowNo": false,
965
+ "type": "boolean"
966
+ },
967
+ "deploy": {
968
+ "description": "destroy deployment companion packages",
969
+ "name": "deploy",
970
+ "required": false,
971
+ "allowNo": false,
972
+ "type": "boolean"
973
+ },
974
+ "pin": {
975
+ "description": "append git commit SHA to workspace name for commit-specific isolation",
976
+ "name": "pin",
977
+ "required": false,
978
+ "allowNo": false,
979
+ "type": "boolean"
980
+ },
981
+ "profile": {
982
+ "description": "profile to use for the workspace (will be appended to workspace name)",
983
+ "name": "profile",
984
+ "required": false,
985
+ "hasDynamicHelp": false,
986
+ "multiple": false,
987
+ "type": "option"
988
+ },
989
+ "select": {
990
+ "char": "s",
991
+ "description": "select the packages to destroy",
992
+ "name": "select",
993
+ "default": [],
994
+ "hasDynamicHelp": false,
995
+ "multiple": true,
996
+ "type": "option"
997
+ }
998
+ },
999
+ "hasDynamicHelp": false,
1000
+ "hiddenAliases": [],
1001
+ "id": "flow:down",
1002
+ "pluginAlias": "hereya-cli",
1003
+ "pluginName": "hereya-cli",
1004
+ "pluginType": "core",
1005
+ "strict": true,
1006
+ "enableJsonFlag": false,
1007
+ "isESM": true,
1008
+ "relativePath": [
1009
+ "dist",
1010
+ "commands",
1011
+ "flow",
1012
+ "down",
1013
+ "index.js"
1014
+ ]
1015
+ },
1016
+ "flow:run": {
1017
+ "aliases": [],
1018
+ "args": {
1019
+ "cmd": {
1020
+ "description": "command to run",
1021
+ "name": "cmd",
1022
+ "required": true
1023
+ }
1024
+ },
1025
+ "description": "Run a command with hereya env vars in a git branch-based workspace",
1026
+ "examples": [
1027
+ "<%= config.bin %> <%= command.id %> -- npm run dev",
1028
+ "<%= config.bin %> <%= command.id %> --profile staging -- node index.js",
1029
+ "<%= config.bin %> <%= command.id %> --pin -- npm test"
1030
+ ],
1031
+ "flags": {
1032
+ "chdir": {
1033
+ "description": "directory to run command in",
1034
+ "name": "chdir",
1035
+ "required": false,
1036
+ "hasDynamicHelp": false,
1037
+ "multiple": false,
1038
+ "type": "option"
1039
+ },
1040
+ "pin": {
1041
+ "description": "append git commit SHA to workspace name for commit-specific isolation",
1042
+ "name": "pin",
1043
+ "required": false,
1044
+ "allowNo": false,
1045
+ "type": "boolean"
1046
+ },
1047
+ "profile": {
1048
+ "description": "profile to use for the workspace (will be appended to workspace name)",
1049
+ "name": "profile",
1050
+ "required": false,
1051
+ "hasDynamicHelp": false,
1052
+ "multiple": false,
1053
+ "type": "option"
1054
+ }
1055
+ },
1056
+ "hasDynamicHelp": false,
1057
+ "hiddenAliases": [],
1058
+ "id": "flow:run",
1059
+ "pluginAlias": "hereya-cli",
1060
+ "pluginName": "hereya-cli",
1061
+ "pluginType": "core",
1062
+ "strict": false,
1063
+ "enableJsonFlag": false,
1064
+ "isESM": true,
1065
+ "relativePath": [
1066
+ "dist",
1067
+ "commands",
1068
+ "flow",
1069
+ "run",
1070
+ "index.js"
1071
+ ]
1072
+ },
1073
+ "flow:up": {
1074
+ "aliases": [],
1075
+ "args": {},
1076
+ "description": "Create a git branch-based workspace and provision all packages",
1077
+ "examples": [
1078
+ "<%= config.bin %> <%= command.id %>",
1079
+ "<%= config.bin %> <%= command.id %> --debug",
1080
+ "<%= config.bin %> <%= command.id %> --profile staging",
1081
+ "<%= config.bin %> <%= command.id %> --pin"
1082
+ ],
1083
+ "flags": {
1084
+ "chdir": {
1085
+ "description": "\n Directory where the command will be executed.\n If not specified, it defaults to the current working directory.\n Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.\n ",
1086
+ "name": "chdir",
1087
+ "required": false,
1088
+ "hasDynamicHelp": false,
1089
+ "multiple": false,
1090
+ "type": "option"
1091
+ },
1092
+ "debug": {
1093
+ "description": "enable debug mode",
1094
+ "name": "debug",
1095
+ "allowNo": false,
1096
+ "type": "boolean"
1097
+ },
1098
+ "deploy": {
1099
+ "description": "provision deployment companion packages",
1100
+ "name": "deploy",
1101
+ "required": false,
1102
+ "allowNo": false,
1103
+ "type": "boolean"
1104
+ },
1105
+ "pin": {
1106
+ "description": "append git commit SHA to workspace name for commit-specific isolation",
1107
+ "name": "pin",
1108
+ "required": false,
1109
+ "allowNo": false,
1110
+ "type": "boolean"
1111
+ },
1112
+ "profile": {
1113
+ "description": "profile to use for the workspace (will be appended to workspace name)",
1114
+ "name": "profile",
1115
+ "required": false,
1116
+ "hasDynamicHelp": false,
1117
+ "multiple": false,
1118
+ "type": "option"
1119
+ },
1120
+ "select": {
1121
+ "char": "s",
1122
+ "description": "select the packages to provision",
1123
+ "name": "select",
1124
+ "default": [],
1125
+ "hasDynamicHelp": false,
1126
+ "multiple": true,
1127
+ "type": "option"
1128
+ }
1129
+ },
1130
+ "hasDynamicHelp": false,
1131
+ "hiddenAliases": [],
1132
+ "id": "flow:up",
1133
+ "pluginAlias": "hereya-cli",
1134
+ "pluginName": "hereya-cli",
1135
+ "pluginType": "core",
1136
+ "strict": true,
1137
+ "enableJsonFlag": false,
1138
+ "isESM": true,
1139
+ "relativePath": [
1140
+ "dist",
1141
+ "commands",
1142
+ "flow",
1143
+ "up",
1144
+ "index.js"
1145
+ ]
1146
+ },
924
1147
  "workspace:create": {
925
1148
  "aliases": [],
926
1149
  "args": {
@@ -1360,5 +1583,5 @@
1360
1583
  ]
1361
1584
  }
1362
1585
  },
1363
- "version": "0.46.0"
1586
+ "version": "0.48.0"
1364
1587
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.46.0",
4
+ "version": "0.48.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"