hereya-cli 0.45.0 → 0.46.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 +56 -29
- package/dist/backend/cloud/cloud-backend.d.ts +2 -1
- package/dist/backend/cloud/cloud-backend.js +18 -0
- package/dist/backend/common.d.ts +12 -0
- package/dist/backend/file-storage/local.js +10 -2
- package/dist/backend/file.d.ts +2 -1
- package/dist/backend/file.js +17 -0
- package/dist/commands/delete-state/index.d.ts +10 -0
- package/dist/commands/delete-state/index.js +49 -0
- package/oclif.manifest.json +44 -1
- package/package.json +1 -1
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.
|
|
23
|
+
hereya-cli/0.46.0 linux-x64 node-v22.17.1
|
|
24
24
|
$ hereya --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ hereya COMMAND
|
|
@@ -35,6 +35,7 @@ USAGE
|
|
|
35
35
|
* [`hereya config get-backend`](#hereya-config-get-backend)
|
|
36
36
|
* [`hereya config import-backend FILE`](#hereya-config-import-backend-file)
|
|
37
37
|
* [`hereya config use-backend TYPE`](#hereya-config-use-backend-type)
|
|
38
|
+
* [`hereya delete-state`](#hereya-delete-state)
|
|
38
39
|
* [`hereya deploy`](#hereya-deploy)
|
|
39
40
|
* [`hereya down`](#hereya-down)
|
|
40
41
|
* [`hereya env [NAME]`](#hereya-env-name)
|
|
@@ -90,7 +91,7 @@ EXAMPLES
|
|
|
90
91
|
$ hereya add cloudy/docker_postgres
|
|
91
92
|
```
|
|
92
93
|
|
|
93
|
-
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
94
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/add/index.ts)_
|
|
94
95
|
|
|
95
96
|
## `hereya bootstrap INFRASTRUCTURETYPE`
|
|
96
97
|
|
|
@@ -115,7 +116,7 @@ EXAMPLES
|
|
|
115
116
|
$ hereya bootstrap local
|
|
116
117
|
```
|
|
117
118
|
|
|
118
|
-
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
119
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/bootstrap/index.ts)_
|
|
119
120
|
|
|
120
121
|
## `hereya config export-backend [FILE]`
|
|
121
122
|
|
|
@@ -137,7 +138,7 @@ EXAMPLES
|
|
|
137
138
|
$ hereya config export-backend ./path/to/export.json
|
|
138
139
|
```
|
|
139
140
|
|
|
140
|
-
_See code: [src/commands/config/export-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
141
142
|
|
|
142
143
|
## `hereya config get-backend`
|
|
143
144
|
|
|
@@ -154,7 +155,7 @@ EXAMPLES
|
|
|
154
155
|
$ hereya config get-backend
|
|
155
156
|
```
|
|
156
157
|
|
|
157
|
-
_See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
158
159
|
|
|
159
160
|
## `hereya config import-backend FILE`
|
|
160
161
|
|
|
@@ -174,7 +175,7 @@ EXAMPLES
|
|
|
174
175
|
$ hereya config import-backend ./path/to/cloud-backend.json
|
|
175
176
|
```
|
|
176
177
|
|
|
177
|
-
_See code: [src/commands/config/import-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
178
179
|
|
|
179
180
|
## `hereya config use-backend TYPE`
|
|
180
181
|
|
|
@@ -196,7 +197,33 @@ EXAMPLES
|
|
|
196
197
|
$ hereya config use-backend local
|
|
197
198
|
```
|
|
198
199
|
|
|
199
|
-
_See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
201
|
+
|
|
202
|
+
## `hereya delete-state`
|
|
203
|
+
|
|
204
|
+
Delete the remote state of a project for a given workspace
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
USAGE
|
|
208
|
+
$ hereya delete-state -w <value> [--chdir <value>]
|
|
209
|
+
|
|
210
|
+
FLAGS
|
|
211
|
+
-w, --workspace=<value> (required) workspace name
|
|
212
|
+
--chdir=<value> Directory where the command will be executed.
|
|
213
|
+
If not specified, it defaults to the current working directory.
|
|
214
|
+
Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR
|
|
215
|
+
environment variable.
|
|
216
|
+
|
|
217
|
+
DESCRIPTION
|
|
218
|
+
Delete the remote state of a project for a given workspace
|
|
219
|
+
|
|
220
|
+
EXAMPLES
|
|
221
|
+
$ hereya delete-state -w dev
|
|
222
|
+
|
|
223
|
+
$ hereya delete-state --workspace staging
|
|
224
|
+
```
|
|
225
|
+
|
|
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)_
|
|
200
227
|
|
|
201
228
|
## `hereya deploy`
|
|
202
229
|
|
|
@@ -221,7 +248,7 @@ EXAMPLES
|
|
|
221
248
|
$ hereya deploy
|
|
222
249
|
```
|
|
223
250
|
|
|
224
|
-
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
251
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/deploy/index.ts)_
|
|
225
252
|
|
|
226
253
|
## `hereya down`
|
|
227
254
|
|
|
@@ -248,7 +275,7 @@ EXAMPLES
|
|
|
248
275
|
$ hereya down
|
|
249
276
|
```
|
|
250
277
|
|
|
251
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
278
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/down/index.ts)_
|
|
252
279
|
|
|
253
280
|
## `hereya env [NAME]`
|
|
254
281
|
|
|
@@ -279,7 +306,7 @@ EXAMPLES
|
|
|
279
306
|
$ hereya env -w dev -l
|
|
280
307
|
```
|
|
281
308
|
|
|
282
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
309
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/env/index.ts)_
|
|
283
310
|
|
|
284
311
|
## `hereya env set [NAME]`
|
|
285
312
|
|
|
@@ -306,7 +333,7 @@ EXAMPLES
|
|
|
306
333
|
$ hereya env set FOO -v bar -w dev
|
|
307
334
|
```
|
|
308
335
|
|
|
309
|
-
_See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
310
337
|
|
|
311
338
|
## `hereya help [COMMAND]`
|
|
312
339
|
|
|
@@ -363,7 +390,7 @@ EXAMPLES
|
|
|
363
390
|
$ hereya import org/my-package -f state.tfstate -w my-workspace
|
|
364
391
|
```
|
|
365
392
|
|
|
366
|
-
_See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
393
|
+
_See code: [src/commands/import/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/import/index.ts)_
|
|
367
394
|
|
|
368
395
|
## `hereya init PROJECT`
|
|
369
396
|
|
|
@@ -389,7 +416,7 @@ EXAMPLES
|
|
|
389
416
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
390
417
|
```
|
|
391
418
|
|
|
392
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
419
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/init/index.ts)_
|
|
393
420
|
|
|
394
421
|
## `hereya login [URL]`
|
|
395
422
|
|
|
@@ -418,7 +445,7 @@ EXAMPLES
|
|
|
418
445
|
$ hereya login --token=your-token https://cloud.hereya.dev
|
|
419
446
|
```
|
|
420
447
|
|
|
421
|
-
_See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
448
|
+
_See code: [src/commands/login/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/login/index.ts)_
|
|
422
449
|
|
|
423
450
|
## `hereya logout`
|
|
424
451
|
|
|
@@ -435,7 +462,7 @@ EXAMPLES
|
|
|
435
462
|
$ hereya logout
|
|
436
463
|
```
|
|
437
464
|
|
|
438
|
-
_See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
465
|
+
_See code: [src/commands/logout/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/logout/index.ts)_
|
|
439
466
|
|
|
440
467
|
## `hereya remove PACKAGE`
|
|
441
468
|
|
|
@@ -462,7 +489,7 @@ EXAMPLES
|
|
|
462
489
|
$ hereya remove cloudy/docker_postgres
|
|
463
490
|
```
|
|
464
491
|
|
|
465
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
492
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/remove/index.ts)_
|
|
466
493
|
|
|
467
494
|
## `hereya run CMD`
|
|
468
495
|
|
|
@@ -488,7 +515,7 @@ EXAMPLES
|
|
|
488
515
|
$ hereya run -w uat -- node index.js
|
|
489
516
|
```
|
|
490
517
|
|
|
491
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
518
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/run/index.ts)_
|
|
492
519
|
|
|
493
520
|
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
494
521
|
|
|
@@ -513,7 +540,7 @@ EXAMPLES
|
|
|
513
540
|
$ hereya unbootstrap local
|
|
514
541
|
```
|
|
515
542
|
|
|
516
|
-
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
543
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/unbootstrap/index.ts)_
|
|
517
544
|
|
|
518
545
|
## `hereya undeploy`
|
|
519
546
|
|
|
@@ -538,7 +565,7 @@ EXAMPLES
|
|
|
538
565
|
$ hereya undeploy
|
|
539
566
|
```
|
|
540
567
|
|
|
541
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
568
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/undeploy/index.ts)_
|
|
542
569
|
|
|
543
570
|
## `hereya up`
|
|
544
571
|
|
|
@@ -565,7 +592,7 @@ EXAMPLES
|
|
|
565
592
|
$ hereya up
|
|
566
593
|
```
|
|
567
594
|
|
|
568
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
595
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.46.0/src/commands/up/index.ts)_
|
|
569
596
|
|
|
570
597
|
## `hereya workspace create NAME`
|
|
571
598
|
|
|
@@ -589,7 +616,7 @@ EXAMPLES
|
|
|
589
616
|
$ hereya workspace create dev
|
|
590
617
|
```
|
|
591
618
|
|
|
592
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
593
620
|
|
|
594
621
|
## `hereya workspace delete NAME`
|
|
595
622
|
|
|
@@ -609,7 +636,7 @@ EXAMPLES
|
|
|
609
636
|
$ hereya workspace delete dev
|
|
610
637
|
```
|
|
611
638
|
|
|
612
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
613
640
|
|
|
614
641
|
## `hereya workspace env [NAME]`
|
|
615
642
|
|
|
@@ -635,7 +662,7 @@ EXAMPLES
|
|
|
635
662
|
$ hereya workspace env myEnv -w dev
|
|
636
663
|
```
|
|
637
664
|
|
|
638
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
639
666
|
|
|
640
667
|
## `hereya workspace env set`
|
|
641
668
|
|
|
@@ -659,7 +686,7 @@ EXAMPLES
|
|
|
659
686
|
$ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
|
|
660
687
|
```
|
|
661
688
|
|
|
662
|
-
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
663
690
|
|
|
664
691
|
## `hereya workspace env unset`
|
|
665
692
|
|
|
@@ -680,7 +707,7 @@ EXAMPLES
|
|
|
680
707
|
$ hereya workspace env unset -w my-workspace -n myVar
|
|
681
708
|
```
|
|
682
709
|
|
|
683
|
-
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
684
711
|
|
|
685
712
|
## `hereya workspace install PACKAGE`
|
|
686
713
|
|
|
@@ -707,7 +734,7 @@ EXAMPLES
|
|
|
707
734
|
$ hereya workspace install hereya/aws-cognito
|
|
708
735
|
```
|
|
709
736
|
|
|
710
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
711
738
|
|
|
712
739
|
## `hereya workspace list`
|
|
713
740
|
|
|
@@ -724,7 +751,7 @@ EXAMPLES
|
|
|
724
751
|
$ hereya workspace list
|
|
725
752
|
```
|
|
726
753
|
|
|
727
|
-
_See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
728
755
|
|
|
729
756
|
## `hereya workspace set-profile PROFILE`
|
|
730
757
|
|
|
@@ -747,7 +774,7 @@ EXAMPLES
|
|
|
747
774
|
$ hereya workspace set-profile prod-profile -w production
|
|
748
775
|
```
|
|
749
776
|
|
|
750
|
-
_See code: [src/commands/workspace/set-profile/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
751
778
|
|
|
752
779
|
## `hereya workspace uninstall PACKAGE`
|
|
753
780
|
|
|
@@ -774,5 +801,5 @@ EXAMPLES
|
|
|
774
801
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
775
802
|
```
|
|
776
803
|
|
|
777
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
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)_
|
|
778
805
|
<!-- 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, UpdateWorkspaceInput, UpdateWorkspaceOutput } from '../common.js';
|
|
2
|
+
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteStateInput, DeleteStateOutput, 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;
|
|
@@ -11,6 +11,7 @@ export declare class CloudBackend implements Backend {
|
|
|
11
11
|
constructor(config: CloudBackendConfig);
|
|
12
12
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
13
13
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
14
|
+
deleteState(input: DeleteStateInput): Promise<DeleteStateOutput>;
|
|
14
15
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
15
16
|
exportBackend(): Promise<ExportBackendOutput>;
|
|
16
17
|
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
|
@@ -60,6 +60,24 @@ export class CloudBackend {
|
|
|
60
60
|
workspace: this.convertWorkspace(result.workspace),
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
async deleteState(input) {
|
|
64
|
+
const response = await fetch(`${this.config.url}/api/projects/${encodeURIComponent(input.project)}/state/${encodeURIComponent(input.workspace)}`, {
|
|
65
|
+
headers: {
|
|
66
|
+
'Authorization': `Bearer ${this.config.accessToken}`,
|
|
67
|
+
},
|
|
68
|
+
method: 'DELETE',
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
return {
|
|
72
|
+
reason: JSON.stringify(await response.json()),
|
|
73
|
+
success: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
message: `State for project ${input.project} in workspace ${input.workspace} deleted successfully`,
|
|
78
|
+
success: true,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
63
81
|
async deleteWorkspace(input) {
|
|
64
82
|
const response = await fetch(`${this.config.url}/api/workspaces/${encodeURIComponent(input.name)}`, {
|
|
65
83
|
headers: {
|
package/dist/backend/common.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Config } from '../lib/config/common.js';
|
|
|
4
4
|
export interface Backend {
|
|
5
5
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
6
6
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
7
|
+
deleteState(input: DeleteStateInput): Promise<DeleteStateOutput>;
|
|
7
8
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
8
9
|
exportBackend(): Promise<ExportBackendOutput>;
|
|
9
10
|
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
|
@@ -159,6 +160,17 @@ export type DeleteWorkspaceOutput = {
|
|
|
159
160
|
reason: string;
|
|
160
161
|
success: false;
|
|
161
162
|
};
|
|
163
|
+
export type DeleteStateInput = {
|
|
164
|
+
project: string;
|
|
165
|
+
workspace: string;
|
|
166
|
+
};
|
|
167
|
+
export type DeleteStateOutput = {
|
|
168
|
+
message?: string;
|
|
169
|
+
success: true;
|
|
170
|
+
} | {
|
|
171
|
+
reason: string;
|
|
172
|
+
success: false;
|
|
173
|
+
};
|
|
162
174
|
export type GetProvisioningIdInput = {
|
|
163
175
|
logicalId: string;
|
|
164
176
|
packageCanonicalName: string;
|
|
@@ -8,7 +8,7 @@ export class LocalFileStorage {
|
|
|
8
8
|
}
|
|
9
9
|
async deleteFile(input) {
|
|
10
10
|
const filePaths = input.paths.map((p) => path.join(this.basePath, p));
|
|
11
|
-
await Promise.all(filePaths.map(async (filePath) => {
|
|
11
|
+
const results = await Promise.all(filePaths.map(async (filePath) => {
|
|
12
12
|
try {
|
|
13
13
|
if (await fileExists(filePath)) {
|
|
14
14
|
await fs.unlink(filePath);
|
|
@@ -18,8 +18,16 @@ export class LocalFileStorage {
|
|
|
18
18
|
catch {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
+
return false;
|
|
21
22
|
}));
|
|
22
|
-
|
|
23
|
+
const anyDeleted = results.includes(true);
|
|
24
|
+
if (anyDeleted) {
|
|
25
|
+
return { success: true };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
error: 'No files found to delete',
|
|
29
|
+
success: false
|
|
30
|
+
};
|
|
23
31
|
}
|
|
24
32
|
async getFileContent(input) {
|
|
25
33
|
const filePaths = input.paths.map((p) => path.join(this.basePath, p));
|
package/dist/backend/file.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
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, UpdateWorkspaceInput, UpdateWorkspaceOutput } from './common.js';
|
|
2
|
+
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteStateInput, DeleteStateOutput, 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;
|
|
6
6
|
constructor(fileStorage: FileStorage);
|
|
7
7
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
8
8
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
9
|
+
deleteState(input: DeleteStateInput): Promise<DeleteStateOutput>;
|
|
9
10
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
10
11
|
exportBackend(): Promise<ExportBackendOutput>;
|
|
11
12
|
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
package/dist/backend/file.js
CHANGED
|
@@ -104,6 +104,23 @@ export class FileBackend {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
async deleteState(input) {
|
|
108
|
+
const paths = [
|
|
109
|
+
['state', 'projects', input.workspace, `${input.project}.yaml`].join('/'),
|
|
110
|
+
['state', 'projects', input.workspace, `${input.project}.yml`].join('/'),
|
|
111
|
+
];
|
|
112
|
+
const result = await this.fileStorage.deleteFile({ paths });
|
|
113
|
+
if (result.success) {
|
|
114
|
+
return {
|
|
115
|
+
message: `State for project ${input.project} in workspace ${input.workspace} deleted successfully`,
|
|
116
|
+
success: true,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
reason: result.error ?? 'Failed to delete state file',
|
|
121
|
+
success: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
107
124
|
async deleteWorkspace(input) {
|
|
108
125
|
const workspace$ = await this.getWorkspace(input.name);
|
|
109
126
|
if (!workspace$.found) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class DeleteState 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
|
+
workspace: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { getBackend } from '../../backend/index.js';
|
|
3
|
+
import { getConfigManager } from '../../lib/config/index.js';
|
|
4
|
+
export default class DeleteState extends Command {
|
|
5
|
+
static description = 'Delete the remote state of a project for a given workspace';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %> -w dev',
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --workspace staging',
|
|
9
|
+
];
|
|
10
|
+
static flags = {
|
|
11
|
+
chdir: Flags.string({
|
|
12
|
+
description: `
|
|
13
|
+
Directory where the command will be executed.
|
|
14
|
+
If not specified, it defaults to the current working directory.
|
|
15
|
+
Alternatively, you can define the project root by setting the HEREYA_PROJECT_ROOT_DIR environment variable.
|
|
16
|
+
`,
|
|
17
|
+
required: false,
|
|
18
|
+
}),
|
|
19
|
+
workspace: Flags.string({
|
|
20
|
+
char: 'w',
|
|
21
|
+
description: 'workspace name',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { flags } = await this.parse(DeleteState);
|
|
27
|
+
const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
|
|
28
|
+
const configManager = getConfigManager();
|
|
29
|
+
const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
|
|
30
|
+
if (!loadConfigOutput.found) {
|
|
31
|
+
this.error("Project not initialized. Run 'hereya init' first.");
|
|
32
|
+
}
|
|
33
|
+
const { config } = loadConfigOutput;
|
|
34
|
+
const backend = await getBackend();
|
|
35
|
+
const output = await backend.deleteState({
|
|
36
|
+
project: config.project,
|
|
37
|
+
workspace: flags.workspace,
|
|
38
|
+
});
|
|
39
|
+
if (!output.success) {
|
|
40
|
+
this.error(`Failed to delete state: ${output.reason}`);
|
|
41
|
+
}
|
|
42
|
+
if (output.message) {
|
|
43
|
+
this.log(output.message);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.log(`State for project ${config.project} in workspace ${flags.workspace} deleted successfully`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -93,6 +93,49 @@
|
|
|
93
93
|
"index.js"
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
|
+
"delete-state": {
|
|
97
|
+
"aliases": [],
|
|
98
|
+
"args": {},
|
|
99
|
+
"description": "Delete the remote state of a project for a given workspace",
|
|
100
|
+
"examples": [
|
|
101
|
+
"<%= config.bin %> <%= command.id %> -w dev",
|
|
102
|
+
"<%= config.bin %> <%= command.id %> --workspace staging"
|
|
103
|
+
],
|
|
104
|
+
"flags": {
|
|
105
|
+
"chdir": {
|
|
106
|
+
"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 ",
|
|
107
|
+
"name": "chdir",
|
|
108
|
+
"required": false,
|
|
109
|
+
"hasDynamicHelp": false,
|
|
110
|
+
"multiple": false,
|
|
111
|
+
"type": "option"
|
|
112
|
+
},
|
|
113
|
+
"workspace": {
|
|
114
|
+
"char": "w",
|
|
115
|
+
"description": "workspace name",
|
|
116
|
+
"name": "workspace",
|
|
117
|
+
"required": true,
|
|
118
|
+
"hasDynamicHelp": false,
|
|
119
|
+
"multiple": false,
|
|
120
|
+
"type": "option"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"hasDynamicHelp": false,
|
|
124
|
+
"hiddenAliases": [],
|
|
125
|
+
"id": "delete-state",
|
|
126
|
+
"pluginAlias": "hereya-cli",
|
|
127
|
+
"pluginName": "hereya-cli",
|
|
128
|
+
"pluginType": "core",
|
|
129
|
+
"strict": true,
|
|
130
|
+
"enableJsonFlag": false,
|
|
131
|
+
"isESM": true,
|
|
132
|
+
"relativePath": [
|
|
133
|
+
"dist",
|
|
134
|
+
"commands",
|
|
135
|
+
"delete-state",
|
|
136
|
+
"index.js"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
96
139
|
"deploy": {
|
|
97
140
|
"aliases": [],
|
|
98
141
|
"args": {},
|
|
@@ -1317,5 +1360,5 @@
|
|
|
1317
1360
|
]
|
|
1318
1361
|
}
|
|
1319
1362
|
},
|
|
1320
|
-
"version": "0.
|
|
1363
|
+
"version": "0.46.0"
|
|
1321
1364
|
}
|