hereya-cli 0.9.2 → 0.11.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 +64 -42
- package/dist/backend/common.d.ts +24 -4
- package/dist/backend/local.d.ts +3 -1
- package/dist/backend/local.js +112 -18
- package/dist/commands/workspace/env/set/index.d.ts +13 -0
- package/dist/commands/workspace/env/set/index.js +39 -0
- package/dist/commands/workspace/env/unset/index.d.ts +10 -0
- package/dist/commands/workspace/env/unset/index.js +33 -0
- package/dist/iac/common.d.ts +5 -0
- package/dist/iac/terraform.js +62 -19
- package/dist/infrastructure/aws.d.ts +5 -6
- package/dist/infrastructure/aws.js +114 -244
- package/dist/infrastructure/common.d.ts +24 -0
- package/dist/infrastructure/local.d.ts +3 -3
- package/dist/infrastructure/local.js +12 -28
- package/dist/lib/filesystem.d.ts +1 -0
- package/dist/lib/filesystem.js +10 -1
- package/dist/lib/package/index.d.ts +1 -0
- package/dist/lib/package/index.js +26 -8
- package/oclif.manifest.json +147 -82
- package/package.json +1 -1
- package/dist/commands/remote/exec/index.d.ts +0 -13
- package/dist/commands/remote/exec/index.js +0 -89
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.11.0 linux-x64 node-v22.12.0
|
|
24
24
|
$ hereya --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ hereya COMMAND
|
|
@@ -36,7 +36,6 @@ USAGE
|
|
|
36
36
|
* [`hereya env [NAME]`](#hereya-env-name)
|
|
37
37
|
* [`hereya help [COMMAND]`](#hereya-help-command)
|
|
38
38
|
* [`hereya init PROJECT`](#hereya-init-project)
|
|
39
|
-
* [`hereya remote exec [PKGPATH]`](#hereya-remote-exec-pkgpath)
|
|
40
39
|
* [`hereya remove PACKAGE`](#hereya-remove-package)
|
|
41
40
|
* [`hereya run CMD`](#hereya-run-cmd)
|
|
42
41
|
* [`hereya unbootstrap INFRASTRUCTURETYPE`](#hereya-unbootstrap-infrastructuretype)
|
|
@@ -45,6 +44,8 @@ USAGE
|
|
|
45
44
|
* [`hereya workspace create NAME`](#hereya-workspace-create-name)
|
|
46
45
|
* [`hereya workspace delete NAME`](#hereya-workspace-delete-name)
|
|
47
46
|
* [`hereya workspace env [NAME]`](#hereya-workspace-env-name)
|
|
47
|
+
* [`hereya workspace env set`](#hereya-workspace-env-set)
|
|
48
|
+
* [`hereya workspace env unset`](#hereya-workspace-env-unset)
|
|
48
49
|
* [`hereya workspace install PACKAGE`](#hereya-workspace-install-package)
|
|
49
50
|
* [`hereya workspace uninstall PACKAGE`](#hereya-workspace-uninstall-package)
|
|
50
51
|
|
|
@@ -71,7 +72,7 @@ EXAMPLES
|
|
|
71
72
|
$ hereya add cloudy/docker_postgres
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
75
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/add/index.ts)_
|
|
75
76
|
|
|
76
77
|
## `hereya bootstrap INFRASTRUCTURETYPE`
|
|
77
78
|
|
|
@@ -96,7 +97,7 @@ EXAMPLES
|
|
|
96
97
|
$ hereya bootstrap local
|
|
97
98
|
```
|
|
98
99
|
|
|
99
|
-
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
100
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/bootstrap/index.ts)_
|
|
100
101
|
|
|
101
102
|
## `hereya deploy`
|
|
102
103
|
|
|
@@ -117,7 +118,7 @@ EXAMPLES
|
|
|
117
118
|
$ hereya deploy
|
|
118
119
|
```
|
|
119
120
|
|
|
120
|
-
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
121
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/deploy/index.ts)_
|
|
121
122
|
|
|
122
123
|
## `hereya down`
|
|
123
124
|
|
|
@@ -139,7 +140,7 @@ EXAMPLES
|
|
|
139
140
|
$ hereya down
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
143
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/down/index.ts)_
|
|
143
144
|
|
|
144
145
|
## `hereya env [NAME]`
|
|
145
146
|
|
|
@@ -170,7 +171,7 @@ EXAMPLES
|
|
|
170
171
|
$ hereya env -w dev -l
|
|
171
172
|
```
|
|
172
173
|
|
|
173
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
174
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/env/index.ts)_
|
|
174
175
|
|
|
175
176
|
## `hereya help [COMMAND]`
|
|
176
177
|
|
|
@@ -216,31 +217,7 @@ EXAMPLES
|
|
|
216
217
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
217
218
|
```
|
|
218
219
|
|
|
219
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
220
|
-
|
|
221
|
-
## `hereya remote exec [PKGPATH]`
|
|
222
|
-
|
|
223
|
-
remotely provision or destroy a package
|
|
224
|
-
|
|
225
|
-
```
|
|
226
|
-
USAGE
|
|
227
|
-
$ hereya remote exec [PKGPATH] [-o <value>] [-s <value>]
|
|
228
|
-
|
|
229
|
-
ARGUMENTS
|
|
230
|
-
PKGPATH The path to the package to provision or destroy
|
|
231
|
-
|
|
232
|
-
FLAGS
|
|
233
|
-
-o, --output=<value> The path to store the output env in
|
|
234
|
-
-s, --source=<value> The source of the project to provision or destroy the package for
|
|
235
|
-
|
|
236
|
-
DESCRIPTION
|
|
237
|
-
remotely provision or destroy a package
|
|
238
|
-
|
|
239
|
-
EXAMPLES
|
|
240
|
-
$ hereya remote exec
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
_See code: [src/commands/remote/exec/index.ts](https://github.com/hereya/hereya-cli/blob/v0.9.2/src/commands/remote/exec/index.ts)_
|
|
220
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/init/index.ts)_
|
|
244
221
|
|
|
245
222
|
## `hereya remove PACKAGE`
|
|
246
223
|
|
|
@@ -263,7 +240,7 @@ EXAMPLES
|
|
|
263
240
|
$ hereya remove cloudy/docker_postgres
|
|
264
241
|
```
|
|
265
242
|
|
|
266
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
243
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/remove/index.ts)_
|
|
267
244
|
|
|
268
245
|
## `hereya run CMD`
|
|
269
246
|
|
|
@@ -289,7 +266,7 @@ EXAMPLES
|
|
|
289
266
|
$ hereya run -w uat -- node index.js
|
|
290
267
|
```
|
|
291
268
|
|
|
292
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
269
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/run/index.ts)_
|
|
293
270
|
|
|
294
271
|
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
295
272
|
|
|
@@ -314,7 +291,7 @@ EXAMPLES
|
|
|
314
291
|
$ hereya unbootstrap local
|
|
315
292
|
```
|
|
316
293
|
|
|
317
|
-
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
294
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/unbootstrap/index.ts)_
|
|
318
295
|
|
|
319
296
|
## `hereya undeploy`
|
|
320
297
|
|
|
@@ -335,7 +312,7 @@ EXAMPLES
|
|
|
335
312
|
$ hereya undeploy
|
|
336
313
|
```
|
|
337
314
|
|
|
338
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
315
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/undeploy/index.ts)_
|
|
339
316
|
|
|
340
317
|
## `hereya up`
|
|
341
318
|
|
|
@@ -357,7 +334,7 @@ EXAMPLES
|
|
|
357
334
|
$ hereya up
|
|
358
335
|
```
|
|
359
336
|
|
|
360
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
337
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/up/index.ts)_
|
|
361
338
|
|
|
362
339
|
## `hereya workspace create NAME`
|
|
363
340
|
|
|
@@ -377,7 +354,7 @@ EXAMPLES
|
|
|
377
354
|
$ hereya workspace create dev
|
|
378
355
|
```
|
|
379
356
|
|
|
380
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
357
|
+
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/create/index.ts)_
|
|
381
358
|
|
|
382
359
|
## `hereya workspace delete NAME`
|
|
383
360
|
|
|
@@ -397,7 +374,7 @@ EXAMPLES
|
|
|
397
374
|
$ hereya workspace delete dev
|
|
398
375
|
```
|
|
399
376
|
|
|
400
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
377
|
+
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/delete/index.ts)_
|
|
401
378
|
|
|
402
379
|
## `hereya workspace env [NAME]`
|
|
403
380
|
|
|
@@ -423,7 +400,52 @@ EXAMPLES
|
|
|
423
400
|
$ hereya workspace env myEnv -w dev
|
|
424
401
|
```
|
|
425
402
|
|
|
426
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
403
|
+
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/env/index.ts)_
|
|
404
|
+
|
|
405
|
+
## `hereya workspace env set`
|
|
406
|
+
|
|
407
|
+
set an env var for a workspace
|
|
408
|
+
|
|
409
|
+
```
|
|
410
|
+
USAGE
|
|
411
|
+
$ hereya workspace env set -i <value> -n <value> -v <value> -w <value> [-s]
|
|
412
|
+
|
|
413
|
+
FLAGS
|
|
414
|
+
-i, --infra=<value> (required) the infrastructure to store the env var in
|
|
415
|
+
-n, --name=<value> (required) name of the env var to set
|
|
416
|
+
-s, --sensitive whether the env var is sensitive
|
|
417
|
+
-v, --value=<value> (required) value of the env var to set
|
|
418
|
+
-w, --workspace=<value> (required) name of the workspace to set an env var for
|
|
419
|
+
|
|
420
|
+
DESCRIPTION
|
|
421
|
+
set an env var for a workspace
|
|
422
|
+
|
|
423
|
+
EXAMPLES
|
|
424
|
+
$ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/env/set/index.ts)_
|
|
428
|
+
|
|
429
|
+
## `hereya workspace env unset`
|
|
430
|
+
|
|
431
|
+
unset an env var for a workspace
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
USAGE
|
|
435
|
+
$ hereya workspace env unset -n <value> -w <value>
|
|
436
|
+
|
|
437
|
+
FLAGS
|
|
438
|
+
-n, --name=<value> (required) name of the env var to unset
|
|
439
|
+
-w, --workspace=<value> (required) name of the workspace to unset an env var for
|
|
440
|
+
|
|
441
|
+
DESCRIPTION
|
|
442
|
+
unset an env var for a workspace
|
|
443
|
+
|
|
444
|
+
EXAMPLES
|
|
445
|
+
$ hereya workspace env unset -w my-workspace -n myVar
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/env/unset/index.ts)_
|
|
427
449
|
|
|
428
450
|
## `hereya workspace install PACKAGE`
|
|
429
451
|
|
|
@@ -449,7 +471,7 @@ EXAMPLES
|
|
|
449
471
|
$ hereya workspace install hereya/aws-cognito
|
|
450
472
|
```
|
|
451
473
|
|
|
452
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
474
|
+
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/install/index.ts)_
|
|
453
475
|
|
|
454
476
|
## `hereya workspace uninstall PACKAGE`
|
|
455
477
|
|
|
@@ -475,5 +497,5 @@ EXAMPLES
|
|
|
475
497
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
476
498
|
```
|
|
477
499
|
|
|
478
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
500
|
+
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.11.0/src/commands/workspace/uninstall/index.ts)_
|
|
479
501
|
<!-- commandsstop -->
|
package/dist/backend/common.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export interface Backend {
|
|
|
11
11
|
init(options: InitProjectInput): Promise<InitProjectOutput>;
|
|
12
12
|
removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
|
|
13
13
|
saveState(config: Omit<Config, 'workspace'>): Promise<void>;
|
|
14
|
+
setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
|
|
15
|
+
unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
|
|
14
16
|
}
|
|
15
17
|
export type AddPackageToWorkspaceInput = {
|
|
16
18
|
env: {
|
|
@@ -81,7 +83,9 @@ export type GetWorkspaceEnvOutput = {
|
|
|
81
83
|
reason: string;
|
|
82
84
|
success: false;
|
|
83
85
|
};
|
|
84
|
-
export type GetWorkspaceOutput =
|
|
86
|
+
export type GetWorkspaceOutput = {
|
|
87
|
+
found: false;
|
|
88
|
+
} | ({
|
|
85
89
|
found: true;
|
|
86
90
|
hasError: false;
|
|
87
91
|
workspace: {
|
|
@@ -103,9 +107,7 @@ export type GetWorkspaceOutput = ({
|
|
|
103
107
|
error: string;
|
|
104
108
|
found: true;
|
|
105
109
|
hasError: true;
|
|
106
|
-
})
|
|
107
|
-
found: false;
|
|
108
|
-
};
|
|
110
|
+
});
|
|
109
111
|
export type GetStateInput = {
|
|
110
112
|
project: string;
|
|
111
113
|
};
|
|
@@ -137,3 +139,21 @@ export type GetProvisioningIdOutput = {
|
|
|
137
139
|
reason: string;
|
|
138
140
|
success: false;
|
|
139
141
|
};
|
|
142
|
+
export type SetEnvVarInput = {
|
|
143
|
+
infra: InfrastructureType;
|
|
144
|
+
name: string;
|
|
145
|
+
sensitive?: boolean;
|
|
146
|
+
value: string;
|
|
147
|
+
workspace: string;
|
|
148
|
+
};
|
|
149
|
+
export type SetEnvVarOutput = {
|
|
150
|
+
reason: string;
|
|
151
|
+
success: false;
|
|
152
|
+
} | {
|
|
153
|
+
success: true;
|
|
154
|
+
};
|
|
155
|
+
export type UnsetEnvVarInput = {
|
|
156
|
+
name: string;
|
|
157
|
+
workspace: string;
|
|
158
|
+
};
|
|
159
|
+
export type UnsetEnvVarOutput = SetEnvVarOutput;
|
package/dist/backend/local.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from '../lib/config/common.js';
|
|
2
|
-
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput } from './common.js';
|
|
2
|
+
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput, SetEnvVarInput, SetEnvVarOutput, UnsetEnvVarInput, UnsetEnvVarOutput } from './common.js';
|
|
3
3
|
export declare class LocalBackend implements Backend {
|
|
4
4
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
5
5
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
@@ -11,6 +11,8 @@ export declare class LocalBackend implements Backend {
|
|
|
11
11
|
init(options: InitProjectInput): Promise<InitProjectOutput>;
|
|
12
12
|
removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
|
|
13
13
|
saveState(config: Omit<Config, 'workspace'>): Promise<void>;
|
|
14
|
+
setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
|
|
15
|
+
unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
|
|
14
16
|
private getProjectStatePath;
|
|
15
17
|
private getWorkspacePath;
|
|
16
18
|
private saveWorkspace;
|
package/dist/backend/local.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
+
import { getInfrastructure } from '../infrastructure/index.js';
|
|
5
6
|
import { resolveEnvValues } from '../lib/env-utils.js';
|
|
6
7
|
import { getAnyPath } from '../lib/filesystem.js';
|
|
7
8
|
import { load, save } from '../lib/yaml-utils.js';
|
|
@@ -9,10 +10,12 @@ const WorkspaceSchema = z.object({
|
|
|
9
10
|
env: z.record(z.string()).optional(),
|
|
10
11
|
id: z.string().min(2),
|
|
11
12
|
name: z.string().min(2),
|
|
12
|
-
packages: z
|
|
13
|
+
packages: z
|
|
14
|
+
.record(z.object({
|
|
13
15
|
parameters: z.record(z.any()).optional(),
|
|
14
16
|
version: z.string(),
|
|
15
|
-
}))
|
|
17
|
+
}))
|
|
18
|
+
.optional(),
|
|
16
19
|
});
|
|
17
20
|
export class LocalBackend {
|
|
18
21
|
async addPackageToWorkspace(input) {
|
|
@@ -37,8 +40,7 @@ export class LocalBackend {
|
|
|
37
40
|
version: '',
|
|
38
41
|
},
|
|
39
42
|
};
|
|
40
|
-
const newEnv = Object.fromEntries(Object.entries(input.env)
|
|
41
|
-
.map(([key, value]) => [key, `${input.infra}:${value}`]));
|
|
43
|
+
const newEnv = Object.fromEntries(Object.entries(input.env).map(([key, value]) => [key, `${input.infra}:${value}`]));
|
|
42
44
|
workspace.env = {
|
|
43
45
|
...workspace.env,
|
|
44
46
|
...newEnv,
|
|
@@ -60,14 +62,16 @@ export class LocalBackend {
|
|
|
60
62
|
async createWorkspace(input) {
|
|
61
63
|
const workspace$ = await this.getWorkspace(input.name);
|
|
62
64
|
if (workspace$.found) {
|
|
63
|
-
return workspace$.hasError
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
return workspace$.hasError
|
|
66
|
+
? {
|
|
67
|
+
reason: workspace$.error,
|
|
68
|
+
success: false,
|
|
69
|
+
}
|
|
70
|
+
: {
|
|
71
|
+
isNew: false,
|
|
72
|
+
success: true,
|
|
73
|
+
workspace: workspace$.workspace,
|
|
74
|
+
};
|
|
71
75
|
}
|
|
72
76
|
const workspace = {
|
|
73
77
|
id: input.name,
|
|
@@ -116,8 +120,11 @@ export class LocalBackend {
|
|
|
116
120
|
};
|
|
117
121
|
}
|
|
118
122
|
async getProvisioningId(input) {
|
|
119
|
-
const id = (
|
|
120
|
-
.
|
|
123
|
+
const id = (input.project || input.workspace
|
|
124
|
+
? [input.project, input.workspace, input.packageCanonicalName]
|
|
125
|
+
: [input.packageCanonicalName])
|
|
126
|
+
.filter(Boolean)
|
|
127
|
+
.join('')
|
|
121
128
|
.replaceAll(/[^\dA-Za-z]/g, '');
|
|
122
129
|
return {
|
|
123
130
|
id,
|
|
@@ -205,10 +212,8 @@ export class LocalBackend {
|
|
|
205
212
|
};
|
|
206
213
|
}
|
|
207
214
|
const { workspace } = workspace$;
|
|
208
|
-
workspace.packages = Object.fromEntries(Object.entries(workspace.packages ?? {})
|
|
209
|
-
|
|
210
|
-
workspace.env = Object.fromEntries(Object.entries(workspace.env ?? {})
|
|
211
|
-
.filter(([key]) => !(key in input.env)));
|
|
215
|
+
workspace.packages = Object.fromEntries(Object.entries(workspace.packages ?? {}).filter(([key]) => key !== input.package));
|
|
216
|
+
workspace.env = Object.fromEntries(Object.entries(workspace.env ?? {}).filter(([key]) => !(key in input.env)));
|
|
212
217
|
try {
|
|
213
218
|
await this.saveWorkspace(workspace, input.workspace);
|
|
214
219
|
return {
|
|
@@ -227,6 +232,95 @@ export class LocalBackend {
|
|
|
227
232
|
const projectStatePath = await this.getProjectStatePath(config.project);
|
|
228
233
|
await save(config, projectStatePath);
|
|
229
234
|
}
|
|
235
|
+
async setEnvVar(input) {
|
|
236
|
+
const workspace$ = await this.getWorkspace(input.workspace);
|
|
237
|
+
if (!workspace$.found) {
|
|
238
|
+
return {
|
|
239
|
+
reason: `Workspace ${input.workspace} not found`,
|
|
240
|
+
success: false,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (workspace$.hasError) {
|
|
244
|
+
return {
|
|
245
|
+
reason: workspace$.error,
|
|
246
|
+
success: false,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const { workspace } = workspace$;
|
|
250
|
+
const infrastructure$ = getInfrastructure({ type: input.infra });
|
|
251
|
+
if (!infrastructure$.supported) {
|
|
252
|
+
return {
|
|
253
|
+
reason: `Infrastructure ${input.infra} not found`,
|
|
254
|
+
success: false,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
const { infrastructure } = infrastructure$;
|
|
258
|
+
const setEnvVarOutput = await infrastructure.storeEnv({
|
|
259
|
+
name: input.name,
|
|
260
|
+
oldValue: workspace.env?.[input.name]?.split(':').slice(1).join(':'),
|
|
261
|
+
sensitive: input.sensitive,
|
|
262
|
+
value: input.value,
|
|
263
|
+
});
|
|
264
|
+
if (!setEnvVarOutput.success) {
|
|
265
|
+
return {
|
|
266
|
+
reason: setEnvVarOutput.reason,
|
|
267
|
+
success: false,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
workspace.env = {
|
|
271
|
+
...workspace.env,
|
|
272
|
+
[input.name]: `${input.infra}:${setEnvVarOutput.value}`,
|
|
273
|
+
};
|
|
274
|
+
await this.saveWorkspace(workspace, input.workspace);
|
|
275
|
+
return {
|
|
276
|
+
success: true,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
async unsetEnvVar(input) {
|
|
280
|
+
const workspace$ = await this.getWorkspace(input.workspace);
|
|
281
|
+
if (!workspace$.found) {
|
|
282
|
+
return {
|
|
283
|
+
reason: `Workspace ${input.workspace} not found`,
|
|
284
|
+
success: false,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
if (workspace$.hasError) {
|
|
288
|
+
return {
|
|
289
|
+
reason: workspace$.error,
|
|
290
|
+
success: false,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const { workspace } = workspace$;
|
|
294
|
+
const value = workspace.env?.[input.name];
|
|
295
|
+
if (!value) {
|
|
296
|
+
return {
|
|
297
|
+
success: true,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
const infra = value.split(':')[0];
|
|
301
|
+
const infrastructure$ = getInfrastructure({ type: infra });
|
|
302
|
+
if (!infrastructure$.supported) {
|
|
303
|
+
return {
|
|
304
|
+
reason: `Infrastructure ${infra} not found`,
|
|
305
|
+
success: false,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const { infrastructure } = infrastructure$;
|
|
309
|
+
const unsetEnvVarOutput = await infrastructure.unstoreEnv({
|
|
310
|
+
value: value.split(':').slice(1).join(':'),
|
|
311
|
+
});
|
|
312
|
+
if (!unsetEnvVarOutput.success) {
|
|
313
|
+
return {
|
|
314
|
+
reason: unsetEnvVarOutput.reason,
|
|
315
|
+
success: false,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
workspace.env = Object.fromEntries(Object.entries(workspace.env ?? {}).filter(([key]) => key !== input.name));
|
|
319
|
+
await this.saveWorkspace(workspace, input.workspace);
|
|
320
|
+
return {
|
|
321
|
+
success: true,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
230
324
|
async getProjectStatePath(project) {
|
|
231
325
|
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yml`));
|
|
232
326
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class WorkspaceEnvSet extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
infra: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
sensitive: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
+
value: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
+
workspace: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { getBackend } from '../../../../backend/index.js';
|
|
3
|
+
export default class WorkspaceEnvSet extends Command {
|
|
4
|
+
static description = 'set an env var for a workspace';
|
|
5
|
+
static examples = ['<%= config.bin %> <%= command.id %> -w my-workspace -n myVar -v my-value -i aws -s'];
|
|
6
|
+
static flags = {
|
|
7
|
+
infra: Flags.string({ char: 'i', description: 'the infrastructure to store the env var in', required: true }),
|
|
8
|
+
name: Flags.string({ char: 'n', description: 'name of the env var to set', required: true }),
|
|
9
|
+
sensitive: Flags.boolean({ char: 's', description: 'whether the env var is sensitive' }),
|
|
10
|
+
value: Flags.string({ char: 'v', description: 'value of the env var to set', required: true }),
|
|
11
|
+
workspace: Flags.string({
|
|
12
|
+
char: 'w',
|
|
13
|
+
description: 'name of the workspace to set an env var for',
|
|
14
|
+
required: true,
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const { flags } = await this.parse(WorkspaceEnvSet);
|
|
19
|
+
const backend = await getBackend();
|
|
20
|
+
const getWorkspaceOutput = await backend.getWorkspace(flags.workspace);
|
|
21
|
+
if (!getWorkspaceOutput.found) {
|
|
22
|
+
this.error(`Workspace ${flags.workspace} not found`);
|
|
23
|
+
}
|
|
24
|
+
if (getWorkspaceOutput.hasError) {
|
|
25
|
+
this.error(getWorkspaceOutput.error);
|
|
26
|
+
}
|
|
27
|
+
const setEnvVarOutput = await backend.setEnvVar({
|
|
28
|
+
infra: flags.infra,
|
|
29
|
+
name: flags.name,
|
|
30
|
+
sensitive: flags.sensitive,
|
|
31
|
+
value: flags.value,
|
|
32
|
+
workspace: flags.workspace,
|
|
33
|
+
});
|
|
34
|
+
if (!setEnvVarOutput.success) {
|
|
35
|
+
this.error(setEnvVarOutput.reason);
|
|
36
|
+
}
|
|
37
|
+
this.log(`Env var ${flags.name} set for workspace ${flags.workspace}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class WorkspaceEnvUnset extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
name: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
7
|
+
workspace: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command, Flags } from '@oclif/core';
|
|
2
|
+
import { getBackend } from '../../../../backend/index.js';
|
|
3
|
+
export default class WorkspaceEnvUnset extends Command {
|
|
4
|
+
static description = 'unset an env var for a workspace';
|
|
5
|
+
static examples = ['<%= config.bin %> <%= command.id %> -w my-workspace -n myVar'];
|
|
6
|
+
static flags = {
|
|
7
|
+
name: Flags.string({ char: 'n', description: 'name of the env var to unset', required: true }),
|
|
8
|
+
workspace: Flags.string({
|
|
9
|
+
char: 'w',
|
|
10
|
+
description: 'name of the workspace to unset an env var for',
|
|
11
|
+
required: true,
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { flags } = await this.parse(WorkspaceEnvUnset);
|
|
16
|
+
const backend = await getBackend();
|
|
17
|
+
const getWorkspaceOutput = await backend.getWorkspace(flags.workspace);
|
|
18
|
+
if (!getWorkspaceOutput.found) {
|
|
19
|
+
this.error(`Workspace ${flags.workspace} not found`);
|
|
20
|
+
}
|
|
21
|
+
if (getWorkspaceOutput.hasError) {
|
|
22
|
+
this.error(getWorkspaceOutput.error);
|
|
23
|
+
}
|
|
24
|
+
const unsetEnvVarOutput = await backend.unsetEnvVar({
|
|
25
|
+
name: flags.name,
|
|
26
|
+
workspace: flags.workspace,
|
|
27
|
+
});
|
|
28
|
+
if (!unsetEnvVarOutput.success) {
|
|
29
|
+
this.error(unsetEnvVarOutput.reason);
|
|
30
|
+
}
|
|
31
|
+
this.log(`Unset env var ${flags.name} for workspace ${flags.workspace}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/iac/common.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export type ApplyInput = {
|
|
|
11
11
|
[key: string]: string;
|
|
12
12
|
};
|
|
13
13
|
id: string;
|
|
14
|
+
infraConfig?: {
|
|
15
|
+
terraformStateBucketName: string;
|
|
16
|
+
terraformStateBucketRegion?: string;
|
|
17
|
+
terraformStateLockTableName: string;
|
|
18
|
+
};
|
|
14
19
|
parameters?: {
|
|
15
20
|
[key: string]: string;
|
|
16
21
|
};
|