hereya-cli 0.64.1 → 0.64.2

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.64.1 linux-x64 node-v24.13.1
23
+ hereya-cli/0.64.2 linux-x64 node-v24.14.0
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -105,7 +105,7 @@ EXAMPLES
105
105
  $ hereya add cloudy/docker_postgres
106
106
  ```
107
107
 
108
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/add/index.ts)_
108
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/add/index.ts)_
109
109
 
110
110
  ## `hereya bootstrap INFRASTRUCTURETYPE`
111
111
 
@@ -130,7 +130,7 @@ EXAMPLES
130
130
  $ hereya bootstrap local
131
131
  ```
132
132
 
133
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/bootstrap/index.ts)_
133
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/bootstrap/index.ts)_
134
134
 
135
135
  ## `hereya config export-backend [FILE]`
136
136
 
@@ -152,7 +152,7 @@ EXAMPLES
152
152
  $ hereya config export-backend ./path/to/export.json
153
153
  ```
154
154
 
155
- _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/config/export-backend/index.ts)_
155
+ _See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/config/export-backend/index.ts)_
156
156
 
157
157
  ## `hereya config get-backend`
158
158
 
@@ -169,7 +169,7 @@ EXAMPLES
169
169
  $ hereya config get-backend
170
170
  ```
171
171
 
172
- _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/config/get-backend/index.ts)_
172
+ _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/config/get-backend/index.ts)_
173
173
 
174
174
  ## `hereya config import-backend FILE`
175
175
 
@@ -189,7 +189,7 @@ EXAMPLES
189
189
  $ hereya config import-backend ./path/to/cloud-backend.json
190
190
  ```
191
191
 
192
- _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/config/import-backend/index.ts)_
192
+ _See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/config/import-backend/index.ts)_
193
193
 
194
194
  ## `hereya config use-backend TYPE`
195
195
 
@@ -211,7 +211,7 @@ EXAMPLES
211
211
  $ hereya config use-backend local
212
212
  ```
213
213
 
214
- _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/config/use-backend/index.ts)_
214
+ _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/config/use-backend/index.ts)_
215
215
 
216
216
  ## `hereya delete-state`
217
217
 
@@ -237,7 +237,7 @@ EXAMPLES
237
237
  $ hereya delete-state --workspace staging
238
238
  ```
239
239
 
240
- _See code: [src/commands/delete-state/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/delete-state/index.ts)_
240
+ _See code: [src/commands/delete-state/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/delete-state/index.ts)_
241
241
 
242
242
  ## `hereya deploy`
243
243
 
@@ -262,7 +262,7 @@ EXAMPLES
262
262
  $ hereya deploy
263
263
  ```
264
264
 
265
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/deploy/index.ts)_
265
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/deploy/index.ts)_
266
266
 
267
267
  ## `hereya doc PACKAGE`
268
268
 
@@ -295,7 +295,7 @@ EXAMPLES
295
295
  $ hereya doc my-package --no-doc
296
296
  ```
297
297
 
298
- _See code: [src/commands/doc/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/doc/index.ts)_
298
+ _See code: [src/commands/doc/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/doc/index.ts)_
299
299
 
300
300
  ## `hereya docker run IMAGE`
301
301
 
@@ -326,7 +326,7 @@ EXAMPLES
326
326
  $ hereya docker run myapp:latest -- --rm -v ./data:/data
327
327
  ```
328
328
 
329
- _See code: [src/commands/docker/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/docker/run/index.ts)_
329
+ _See code: [src/commands/docker/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/docker/run/index.ts)_
330
330
 
331
331
  ## `hereya down`
332
332
 
@@ -353,7 +353,7 @@ EXAMPLES
353
353
  $ hereya down
354
354
  ```
355
355
 
356
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/down/index.ts)_
356
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/down/index.ts)_
357
357
 
358
358
  ## `hereya env [NAME]`
359
359
 
@@ -384,7 +384,7 @@ EXAMPLES
384
384
  $ hereya env -w dev -l
385
385
  ```
386
386
 
387
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/env/index.ts)_
387
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/env/index.ts)_
388
388
 
389
389
  ## `hereya env set [NAME]`
390
390
 
@@ -411,7 +411,7 @@ EXAMPLES
411
411
  $ hereya env set FOO -v bar -w dev
412
412
  ```
413
413
 
414
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/env/set/index.ts)_
414
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/env/set/index.ts)_
415
415
 
416
416
  ## `hereya flow add PACKAGE`
417
417
 
@@ -449,7 +449,7 @@ EXAMPLES
449
449
  $ hereya flow add cloudy/docker_postgres -p DB_NAME=mydb -p DB_USER=admin
450
450
  ```
451
451
 
452
- _See code: [src/commands/flow/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/add/index.ts)_
452
+ _See code: [src/commands/flow/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/add/index.ts)_
453
453
 
454
454
  ## `hereya flow docker run IMAGE`
455
455
 
@@ -479,7 +479,7 @@ EXAMPLES
479
479
  $ hereya flow docker run --pin myapp:latest -- --rm
480
480
  ```
481
481
 
482
- _See code: [src/commands/flow/docker/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/docker/run/index.ts)_
482
+ _See code: [src/commands/flow/docker/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/docker/run/index.ts)_
483
483
 
484
484
  ## `hereya flow down`
485
485
 
@@ -513,7 +513,7 @@ EXAMPLES
513
513
  $ hereya flow down --pin
514
514
  ```
515
515
 
516
- _See code: [src/commands/flow/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/down/index.ts)_
516
+ _See code: [src/commands/flow/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/down/index.ts)_
517
517
 
518
518
  ## `hereya flow env [NAME]`
519
519
 
@@ -547,7 +547,7 @@ EXAMPLES
547
547
  $ hereya flow env -l
548
548
  ```
549
549
 
550
- _See code: [src/commands/flow/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/env/index.ts)_
550
+ _See code: [src/commands/flow/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/env/index.ts)_
551
551
 
552
552
  ## `hereya flow provid PACKAGE`
553
553
 
@@ -576,7 +576,7 @@ EXAMPLES
576
576
  $ hereya flow provid hereya/postgres --pin
577
577
  ```
578
578
 
579
- _See code: [src/commands/flow/provid/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/provid/index.ts)_
579
+ _See code: [src/commands/flow/provid/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/provid/index.ts)_
580
580
 
581
581
  ## `hereya flow remove PACKAGE`
582
582
 
@@ -606,7 +606,7 @@ EXAMPLES
606
606
  $ hereya flow remove cloudy/docker_postgres --profile staging
607
607
  ```
608
608
 
609
- _See code: [src/commands/flow/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/remove/index.ts)_
609
+ _See code: [src/commands/flow/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/remove/index.ts)_
610
610
 
611
611
  ## `hereya flow run CMD`
612
612
 
@@ -635,7 +635,7 @@ EXAMPLES
635
635
  $ hereya flow run --pin -- npm test
636
636
  ```
637
637
 
638
- _See code: [src/commands/flow/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/run/index.ts)_
638
+ _See code: [src/commands/flow/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/run/index.ts)_
639
639
 
640
640
  ## `hereya flow up`
641
641
 
@@ -669,7 +669,7 @@ EXAMPLES
669
669
  $ hereya flow up --pin
670
670
  ```
671
671
 
672
- _See code: [src/commands/flow/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/flow/up/index.ts)_
672
+ _See code: [src/commands/flow/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/flow/up/index.ts)_
673
673
 
674
674
  ## `hereya help [COMMAND]`
675
675
 
@@ -726,7 +726,7 @@ EXAMPLES
726
726
  $ hereya import org/my-package -f state.tfstate -w my-workspace
727
727
  ```
728
728
 
729
- _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/import/index.ts)_
729
+ _See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/import/index.ts)_
730
730
 
731
731
  ## `hereya init PROJECT`
732
732
 
@@ -752,7 +752,7 @@ EXAMPLES
752
752
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
753
753
  ```
754
754
 
755
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/init/index.ts)_
755
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/init/index.ts)_
756
756
 
757
757
  ## `hereya login [URL]`
758
758
 
@@ -781,7 +781,7 @@ EXAMPLES
781
781
  $ hereya login --token=your-token https://cloud.hereya.dev
782
782
  ```
783
783
 
784
- _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/login/index.ts)_
784
+ _See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/login/index.ts)_
785
785
 
786
786
  ## `hereya logout`
787
787
 
@@ -798,7 +798,7 @@ EXAMPLES
798
798
  $ hereya logout
799
799
  ```
800
800
 
801
- _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/logout/index.ts)_
801
+ _See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/logout/index.ts)_
802
802
 
803
803
  ## `hereya provid PACKAGE`
804
804
 
@@ -826,7 +826,7 @@ EXAMPLES
826
826
  $ hereya provid hereya/postgres --workspace staging
827
827
  ```
828
828
 
829
- _See code: [src/commands/provid/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/provid/index.ts)_
829
+ _See code: [src/commands/provid/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/provid/index.ts)_
830
830
 
831
831
  ## `hereya publish`
832
832
 
@@ -849,7 +849,7 @@ EXAMPLES
849
849
  $ hereya publish --chdir=/path/to/package
850
850
  ```
851
851
 
852
- _See code: [src/commands/publish/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/publish/index.ts)_
852
+ _See code: [src/commands/publish/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/publish/index.ts)_
853
853
 
854
854
  ## `hereya remove PACKAGE`
855
855
 
@@ -877,7 +877,7 @@ EXAMPLES
877
877
  $ hereya remove cloudy/docker_postgres
878
878
  ```
879
879
 
880
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/remove/index.ts)_
880
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/remove/index.ts)_
881
881
 
882
882
  ## `hereya run CMD`
883
883
 
@@ -903,7 +903,7 @@ EXAMPLES
903
903
  $ hereya run -w uat -- node index.js
904
904
  ```
905
905
 
906
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/run/index.ts)_
906
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/run/index.ts)_
907
907
 
908
908
  ## `hereya search QUERY`
909
909
 
@@ -934,7 +934,7 @@ EXAMPLES
934
934
  $ hereya search database --json
935
935
  ```
936
936
 
937
- _See code: [src/commands/search/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/search/index.ts)_
937
+ _See code: [src/commands/search/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/search/index.ts)_
938
938
 
939
939
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
940
940
 
@@ -959,7 +959,7 @@ EXAMPLES
959
959
  $ hereya unbootstrap local
960
960
  ```
961
961
 
962
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/unbootstrap/index.ts)_
962
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/unbootstrap/index.ts)_
963
963
 
964
964
  ## `hereya undeploy`
965
965
 
@@ -984,7 +984,7 @@ EXAMPLES
984
984
  $ hereya undeploy
985
985
  ```
986
986
 
987
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/undeploy/index.ts)_
987
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/undeploy/index.ts)_
988
988
 
989
989
  ## `hereya up`
990
990
 
@@ -1011,7 +1011,7 @@ EXAMPLES
1011
1011
  $ hereya up
1012
1012
  ```
1013
1013
 
1014
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/up/index.ts)_
1014
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/up/index.ts)_
1015
1015
 
1016
1016
  ## `hereya workspace create NAME`
1017
1017
 
@@ -1036,7 +1036,7 @@ EXAMPLES
1036
1036
  $ hereya workspace create dev
1037
1037
  ```
1038
1038
 
1039
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/create/index.ts)_
1039
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/create/index.ts)_
1040
1040
 
1041
1041
  ## `hereya workspace delete NAME`
1042
1042
 
@@ -1056,7 +1056,7 @@ EXAMPLES
1056
1056
  $ hereya workspace delete dev
1057
1057
  ```
1058
1058
 
1059
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/delete/index.ts)_
1059
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/delete/index.ts)_
1060
1060
 
1061
1061
  ## `hereya workspace env [NAME]`
1062
1062
 
@@ -1082,7 +1082,7 @@ EXAMPLES
1082
1082
  $ hereya workspace env myEnv -w dev
1083
1083
  ```
1084
1084
 
1085
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/env/index.ts)_
1085
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/env/index.ts)_
1086
1086
 
1087
1087
  ## `hereya workspace env set`
1088
1088
 
@@ -1106,7 +1106,7 @@ EXAMPLES
1106
1106
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
1107
1107
  ```
1108
1108
 
1109
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/env/set/index.ts)_
1109
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/env/set/index.ts)_
1110
1110
 
1111
1111
  ## `hereya workspace env unset`
1112
1112
 
@@ -1127,7 +1127,7 @@ EXAMPLES
1127
1127
  $ hereya workspace env unset -w my-workspace -n myVar
1128
1128
  ```
1129
1129
 
1130
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/env/unset/index.ts)_
1130
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/env/unset/index.ts)_
1131
1131
 
1132
1132
  ## `hereya workspace install PACKAGE`
1133
1133
 
@@ -1154,7 +1154,7 @@ EXAMPLES
1154
1154
  $ hereya workspace install hereya/aws-cognito
1155
1155
  ```
1156
1156
 
1157
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/install/index.ts)_
1157
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/install/index.ts)_
1158
1158
 
1159
1159
  ## `hereya workspace list`
1160
1160
 
@@ -1178,7 +1178,7 @@ EXAMPLES
1178
1178
  $ hereya workspace list --org personal
1179
1179
  ```
1180
1180
 
1181
- _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/list/index.ts)_
1181
+ _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/list/index.ts)_
1182
1182
 
1183
1183
  ## `hereya workspace set-profile PROFILE`
1184
1184
 
@@ -1202,7 +1202,7 @@ EXAMPLES
1202
1202
  $ hereya workspace set-profile prod-profile -w production
1203
1203
  ```
1204
1204
 
1205
- _See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/set-profile/index.ts)_
1205
+ _See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/set-profile/index.ts)_
1206
1206
 
1207
1207
  ## `hereya workspace uninstall PACKAGE`
1208
1208
 
@@ -1229,5 +1229,5 @@ EXAMPLES
1229
1229
  $ hereya workspace uninstall hereya/aws-cognito
1230
1230
  ```
1231
1231
 
1232
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.1/src/commands/workspace/uninstall/index.ts)_
1232
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.64.2/src/commands/workspace/uninstall/index.ts)_
1233
1233
  <!-- commandsstop -->
@@ -6,6 +6,49 @@ import { LocalFileBackend } from './local.js';
6
6
  import { S3FileBackend } from './s3.js';
7
7
  let backend;
8
8
  let currentBackendType;
9
+ function sleep(ms) {
10
+ return new Promise(resolve => {
11
+ setTimeout(resolve, ms);
12
+ });
13
+ }
14
+ async function refreshCloudCredentials(cloudConfig) {
15
+ const maxAttempts = 3;
16
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
17
+ // Re-read credentials from disk on each attempt, as another process may have refreshed them
18
+ // eslint-disable-next-line no-await-in-loop
19
+ const credentials = await getCloudCredentials(cloudConfig.clientId);
20
+ if (!credentials) {
21
+ throw new Error('Cloud credentials not found. Please run `hereya login` first.');
22
+ }
23
+ let { accessToken, refreshToken: refreshTokenValue } = credentials;
24
+ // If token is still valid (possibly refreshed by another process), we're done
25
+ if (!isTokenExpired(accessToken)) {
26
+ return { accessToken, refreshToken: refreshTokenValue };
27
+ }
28
+ // Token is expired, attempt to refresh
29
+ // eslint-disable-next-line no-await-in-loop
30
+ const refreshResult = await refreshToken(cloudConfig.url, refreshTokenValue);
31
+ if (refreshResult.success) {
32
+ accessToken = refreshResult.accessToken;
33
+ refreshTokenValue = refreshResult.refreshToken;
34
+ // eslint-disable-next-line no-await-in-loop
35
+ await saveCloudCredentials({
36
+ accessToken,
37
+ clientId: cloudConfig.clientId,
38
+ refreshToken: refreshTokenValue,
39
+ url: cloudConfig.url,
40
+ });
41
+ return { accessToken, refreshToken: refreshTokenValue };
42
+ }
43
+ // Refresh failed — another process may have consumed the refresh token.
44
+ // Wait with backoff before retrying so the other process can finish saving new credentials.
45
+ if (attempt < maxAttempts) {
46
+ // eslint-disable-next-line no-await-in-loop
47
+ await sleep(attempt * 500);
48
+ }
49
+ }
50
+ throw new Error('Failed to refresh token. Please run `hereya login` again.');
51
+ }
9
52
  function isTokenExpired(token) {
10
53
  try {
11
54
  const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
@@ -30,26 +73,7 @@ export async function getBackend(type) {
30
73
  if (!backendConfig.cloud) {
31
74
  throw new Error('Cloud credentials not found. Please run `hereya login` first.');
32
75
  }
33
- const credentials = await getCloudCredentials(backendConfig.cloud.clientId);
34
- if (!credentials) {
35
- throw new Error('Cloud credentials not found. Please run `hereya login` first.');
36
- }
37
- let { accessToken, refreshToken: refreshTokenValue } = credentials;
38
- // Check if token is expired and refresh if necessary
39
- if (isTokenExpired(accessToken)) {
40
- const refreshResult = await refreshToken(backendConfig.cloud.url, refreshTokenValue);
41
- if (!refreshResult.success) {
42
- throw new Error('Failed to refresh token. Please run `hereya login` again.');
43
- }
44
- accessToken = refreshResult.accessToken;
45
- refreshTokenValue = refreshResult.refreshToken;
46
- await saveCloudCredentials({
47
- accessToken,
48
- clientId: backendConfig.cloud.clientId,
49
- refreshToken: refreshTokenValue,
50
- url: backendConfig.cloud.url,
51
- });
52
- }
76
+ const { accessToken, refreshToken: refreshTokenValue } = await refreshCloudCredentials(backendConfig.cloud);
53
77
  backend = new CloudBackend({
54
78
  accessToken,
55
79
  clientId: backendConfig.cloud.clientId,
@@ -2187,5 +2187,5 @@
2187
2187
  ]
2188
2188
  }
2189
2189
  },
2190
- "version": "0.64.1"
2190
+ "version": "0.64.2"
2191
2191
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.64.1",
4
+ "version": "0.64.2",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"