hereya-cli 0.15.0 → 0.16.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 +23 -21
- package/dist/commands/add/index.js +11 -5
- package/dist/commands/deploy/index.js +13 -5
- package/dist/commands/remove/index.js +10 -5
- package/dist/commands/workspace/install/index.d.ts +1 -0
- package/dist/commands/workspace/install/index.js +86 -40
- package/dist/commands/workspace/uninstall/index.d.ts +1 -0
- package/dist/commands/workspace/uninstall/index.js +92 -51
- package/oclif.manifest.json +44 -32
- 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.16.0 linux-x64 node-v22.13.1
|
|
24
24
|
$ hereya --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ hereya COMMAND
|
|
@@ -73,7 +73,7 @@ EXAMPLES
|
|
|
73
73
|
$ hereya add cloudy/docker_postgres
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
76
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/add/index.ts)_
|
|
77
77
|
|
|
78
78
|
## `hereya bootstrap INFRASTRUCTURETYPE`
|
|
79
79
|
|
|
@@ -98,7 +98,7 @@ EXAMPLES
|
|
|
98
98
|
$ hereya bootstrap local
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
101
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/bootstrap/index.ts)_
|
|
102
102
|
|
|
103
103
|
## `hereya deploy`
|
|
104
104
|
|
|
@@ -120,7 +120,7 @@ EXAMPLES
|
|
|
120
120
|
$ hereya deploy
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
123
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/deploy/index.ts)_
|
|
124
124
|
|
|
125
125
|
## `hereya down`
|
|
126
126
|
|
|
@@ -143,7 +143,7 @@ EXAMPLES
|
|
|
143
143
|
$ hereya down
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
146
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/down/index.ts)_
|
|
147
147
|
|
|
148
148
|
## `hereya env [NAME]`
|
|
149
149
|
|
|
@@ -174,7 +174,7 @@ EXAMPLES
|
|
|
174
174
|
$ hereya env -w dev -l
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
177
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/env/index.ts)_
|
|
178
178
|
|
|
179
179
|
## `hereya help [COMMAND]`
|
|
180
180
|
|
|
@@ -220,7 +220,7 @@ EXAMPLES
|
|
|
220
220
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
223
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/init/index.ts)_
|
|
224
224
|
|
|
225
225
|
## `hereya remove PACKAGE`
|
|
226
226
|
|
|
@@ -244,7 +244,7 @@ EXAMPLES
|
|
|
244
244
|
$ hereya remove cloudy/docker_postgres
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
247
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/remove/index.ts)_
|
|
248
248
|
|
|
249
249
|
## `hereya run CMD`
|
|
250
250
|
|
|
@@ -270,7 +270,7 @@ EXAMPLES
|
|
|
270
270
|
$ hereya run -w uat -- node index.js
|
|
271
271
|
```
|
|
272
272
|
|
|
273
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
273
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/run/index.ts)_
|
|
274
274
|
|
|
275
275
|
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
276
276
|
|
|
@@ -295,7 +295,7 @@ EXAMPLES
|
|
|
295
295
|
$ hereya unbootstrap local
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
298
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/unbootstrap/index.ts)_
|
|
299
299
|
|
|
300
300
|
## `hereya undeploy`
|
|
301
301
|
|
|
@@ -317,7 +317,7 @@ EXAMPLES
|
|
|
317
317
|
$ hereya undeploy
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
320
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/undeploy/index.ts)_
|
|
321
321
|
|
|
322
322
|
## `hereya up`
|
|
323
323
|
|
|
@@ -340,7 +340,7 @@ EXAMPLES
|
|
|
340
340
|
$ hereya up
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
343
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/up/index.ts)_
|
|
344
344
|
|
|
345
345
|
## `hereya workspace create NAME`
|
|
346
346
|
|
|
@@ -360,7 +360,7 @@ EXAMPLES
|
|
|
360
360
|
$ hereya workspace create dev
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
363
|
+
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/create/index.ts)_
|
|
364
364
|
|
|
365
365
|
## `hereya workspace delete NAME`
|
|
366
366
|
|
|
@@ -380,7 +380,7 @@ EXAMPLES
|
|
|
380
380
|
$ hereya workspace delete dev
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
383
|
+
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/delete/index.ts)_
|
|
384
384
|
|
|
385
385
|
## `hereya workspace env [NAME]`
|
|
386
386
|
|
|
@@ -406,7 +406,7 @@ EXAMPLES
|
|
|
406
406
|
$ hereya workspace env myEnv -w dev
|
|
407
407
|
```
|
|
408
408
|
|
|
409
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
409
|
+
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/index.ts)_
|
|
410
410
|
|
|
411
411
|
## `hereya workspace env set`
|
|
412
412
|
|
|
@@ -430,7 +430,7 @@ EXAMPLES
|
|
|
430
430
|
$ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
433
|
+
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/set/index.ts)_
|
|
434
434
|
|
|
435
435
|
## `hereya workspace env unset`
|
|
436
436
|
|
|
@@ -451,7 +451,7 @@ EXAMPLES
|
|
|
451
451
|
$ hereya workspace env unset -w my-workspace -n myVar
|
|
452
452
|
```
|
|
453
453
|
|
|
454
|
-
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
454
|
+
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/env/unset/index.ts)_
|
|
455
455
|
|
|
456
456
|
## `hereya workspace install PACKAGE`
|
|
457
457
|
|
|
@@ -459,7 +459,7 @@ Add a package to the workspace.
|
|
|
459
459
|
|
|
460
460
|
```
|
|
461
461
|
USAGE
|
|
462
|
-
$ hereya workspace install PACKAGE -w <value> [-p <value>] [-f <value>]
|
|
462
|
+
$ hereya workspace install PACKAGE -w <value> [--debug] [-p <value>] [-f <value>]
|
|
463
463
|
|
|
464
464
|
ARGUMENTS
|
|
465
465
|
PACKAGE The package to add. Packages are gitHub repositories. Use the format owner/repository
|
|
@@ -469,6 +469,7 @@ FLAGS
|
|
|
469
469
|
-p, --parameter=<value>... [default: ] parameter for the package, in the form of 'key=value'. Can be specified
|
|
470
470
|
multiple times.
|
|
471
471
|
-w, --workspace=<value> (required) name of the workspace to add the package to
|
|
472
|
+
--debug enable debug mode
|
|
472
473
|
|
|
473
474
|
DESCRIPTION
|
|
474
475
|
Add a package to the workspace.
|
|
@@ -477,7 +478,7 @@ EXAMPLES
|
|
|
477
478
|
$ hereya workspace install hereya/aws-cognito
|
|
478
479
|
```
|
|
479
480
|
|
|
480
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
481
|
+
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/install/index.ts)_
|
|
481
482
|
|
|
482
483
|
## `hereya workspace uninstall PACKAGE`
|
|
483
484
|
|
|
@@ -485,7 +486,7 @@ Remove a package from a workspace.
|
|
|
485
486
|
|
|
486
487
|
```
|
|
487
488
|
USAGE
|
|
488
|
-
$ hereya workspace uninstall PACKAGE -w <value> [-p <value>] [-f <value>]
|
|
489
|
+
$ hereya workspace uninstall PACKAGE -w <value> [--debug] [-p <value>] [-f <value>]
|
|
489
490
|
|
|
490
491
|
ARGUMENTS
|
|
491
492
|
PACKAGE The package to remove. Packages are gitHub repositories. Use the format owner/repository
|
|
@@ -495,6 +496,7 @@ FLAGS
|
|
|
495
496
|
-p, --parameter=<value>... [default: ] parameter for the package, in the form of 'key=value'. Can be specified
|
|
496
497
|
multiple times.
|
|
497
498
|
-w, --workspace=<value> (required) name of the workspace to remove the package from
|
|
499
|
+
--debug enable debug mode
|
|
498
500
|
|
|
499
501
|
DESCRIPTION
|
|
500
502
|
Remove a package from a workspace.
|
|
@@ -503,5 +505,5 @@ EXAMPLES
|
|
|
503
505
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
504
506
|
```
|
|
505
507
|
|
|
506
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
508
|
+
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.16.0/src/commands/workspace/uninstall/index.ts)_
|
|
507
509
|
<!-- commandsstop -->
|
|
@@ -42,6 +42,12 @@ export default class Add extends Command {
|
|
|
42
42
|
{
|
|
43
43
|
async task(ctx, task) {
|
|
44
44
|
return task.newListr([
|
|
45
|
+
{
|
|
46
|
+
async task(ctx) {
|
|
47
|
+
ctx.package = args.package;
|
|
48
|
+
ctx.userSpecifiedParameters = flags.parameter;
|
|
49
|
+
},
|
|
50
|
+
},
|
|
45
51
|
{
|
|
46
52
|
async task(ctx) {
|
|
47
53
|
const configManager = getConfigManager();
|
|
@@ -71,10 +77,10 @@ export default class Add extends Command {
|
|
|
71
77
|
},
|
|
72
78
|
{
|
|
73
79
|
async task(ctx) {
|
|
74
|
-
const userSpecifiedParameters = arrayOfStringToObject(
|
|
80
|
+
const userSpecifiedParameters = arrayOfStringToObject(ctx.userSpecifiedParameters);
|
|
75
81
|
const parameterManager = getParameterManager();
|
|
76
82
|
const parametersOutput = await parameterManager.getPackageParameters({
|
|
77
|
-
package:
|
|
83
|
+
package: ctx.package,
|
|
78
84
|
projectRootDir,
|
|
79
85
|
userSpecifiedParameters,
|
|
80
86
|
workspace: ctx.configOutput.config.workspace,
|
|
@@ -88,7 +94,7 @@ export default class Add extends Command {
|
|
|
88
94
|
async task(ctx) {
|
|
89
95
|
const provisionOutput = await provisionPackage({
|
|
90
96
|
env: ctx.workspaceEnvOutput.env,
|
|
91
|
-
package:
|
|
97
|
+
package: ctx.package,
|
|
92
98
|
parameters: ctx.parametersOutput.parameters,
|
|
93
99
|
project: ctx.configOutput.config.project,
|
|
94
100
|
skipDeploy: true,
|
|
@@ -120,7 +126,7 @@ export default class Add extends Command {
|
|
|
120
126
|
const configManager = getConfigManager();
|
|
121
127
|
await configManager.addPackage({
|
|
122
128
|
metadata: ctx.provisionOutput.metadata,
|
|
123
|
-
package:
|
|
129
|
+
package: ctx.package,
|
|
124
130
|
projectRootDir,
|
|
125
131
|
});
|
|
126
132
|
await delay(500);
|
|
@@ -135,7 +141,7 @@ export default class Add extends Command {
|
|
|
135
141
|
await backend.saveState(newConfig);
|
|
136
142
|
const parameterManager = getParameterManager();
|
|
137
143
|
const { filePath, saved } = await parameterManager.savePackageParameters({
|
|
138
|
-
package:
|
|
144
|
+
package: ctx.package,
|
|
139
145
|
parameters: ctx.parametersOutput.parameters,
|
|
140
146
|
projectRootDir,
|
|
141
147
|
workspace: ctx.configOutput.config.workspace,
|
|
@@ -48,16 +48,15 @@ export default class Deploy extends Command {
|
|
|
48
48
|
{
|
|
49
49
|
async task(ctx) {
|
|
50
50
|
const backend = await getBackend();
|
|
51
|
-
const { workspace } = flags;
|
|
52
51
|
const getWorkspaceEnvOutput = await backend.getWorkspaceEnv({
|
|
53
52
|
project: ctx.configOutput.config.project,
|
|
54
|
-
workspace,
|
|
53
|
+
workspace: flags.workspace,
|
|
55
54
|
});
|
|
56
55
|
if (!getWorkspaceEnvOutput.success) {
|
|
57
56
|
throw new Error(getWorkspaceEnvOutput.reason);
|
|
58
57
|
}
|
|
59
58
|
ctx.workspaceEnv = getWorkspaceEnvOutput.env;
|
|
60
|
-
ctx.workspace = workspace;
|
|
59
|
+
ctx.workspace = flags.workspace;
|
|
61
60
|
await delay(500);
|
|
62
61
|
},
|
|
63
62
|
title: 'Loading workspace environment variables',
|
|
@@ -250,7 +249,13 @@ export default class Deploy extends Command {
|
|
|
250
249
|
},
|
|
251
250
|
{
|
|
252
251
|
skip: (ctx) => ctx.deployPackages.length === 0,
|
|
253
|
-
task(ctx, task) {
|
|
252
|
+
async task(ctx, task) {
|
|
253
|
+
const envManager = getEnvManager();
|
|
254
|
+
const { env: projectEnv } = await envManager.getProjectEnv({
|
|
255
|
+
markSecret: true,
|
|
256
|
+
projectRootDir,
|
|
257
|
+
workspace: ctx.workspace,
|
|
258
|
+
});
|
|
254
259
|
return task.newListr(ctx.deployPackages.map((packageName) => ({
|
|
255
260
|
async task() {
|
|
256
261
|
const parameterManager = getParameterManager();
|
|
@@ -265,13 +270,16 @@ export default class Deploy extends Command {
|
|
|
265
270
|
package: packageName,
|
|
266
271
|
parameters,
|
|
267
272
|
project: ctx.configOutput.config.project,
|
|
268
|
-
projectEnv
|
|
273
|
+
projectEnv,
|
|
269
274
|
projectRootDir,
|
|
270
275
|
workspace: ctx.workspace,
|
|
271
276
|
});
|
|
272
277
|
if (!provisionOutput.success) {
|
|
273
278
|
throw new Error(provisionOutput.reason);
|
|
274
279
|
}
|
|
280
|
+
console.log(Object.entries(provisionOutput.env)
|
|
281
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
282
|
+
.join('\n'));
|
|
275
283
|
},
|
|
276
284
|
title: `Provisioning package ${packageName}`,
|
|
277
285
|
})), { concurrent: true });
|
|
@@ -34,6 +34,11 @@ export default class Remove extends Command {
|
|
|
34
34
|
{
|
|
35
35
|
async task(ctx, task) {
|
|
36
36
|
return task.newListr([
|
|
37
|
+
{
|
|
38
|
+
async task(ctx) {
|
|
39
|
+
ctx.package = args.package;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
37
42
|
{
|
|
38
43
|
async task(ctx) {
|
|
39
44
|
const configManager = getConfigManager();
|
|
@@ -43,8 +48,8 @@ export default class Remove extends Command {
|
|
|
43
48
|
}
|
|
44
49
|
ctx.configOutput = loadConfigOutput;
|
|
45
50
|
const { config } = loadConfigOutput;
|
|
46
|
-
if (!(
|
|
47
|
-
throw new Error(`Package ${
|
|
51
|
+
if (!(ctx.package in (config.packages ?? {})) && !(ctx.package in (config.deploy ?? {}))) {
|
|
52
|
+
throw new Error(`Package ${ctx.package} not found in the project.`);
|
|
48
53
|
}
|
|
49
54
|
await delay(500);
|
|
50
55
|
},
|
|
@@ -69,7 +74,7 @@ export default class Remove extends Command {
|
|
|
69
74
|
async task(ctx) {
|
|
70
75
|
const parameterManager = getParameterManager();
|
|
71
76
|
const parametersOutput = await parameterManager.getPackageParameters({
|
|
72
|
-
package:
|
|
77
|
+
package: ctx.package,
|
|
73
78
|
projectRootDir,
|
|
74
79
|
workspace: ctx.configOutput.config.workspace,
|
|
75
80
|
});
|
|
@@ -82,7 +87,7 @@ export default class Remove extends Command {
|
|
|
82
87
|
async task(ctx) {
|
|
83
88
|
const destroyOutput = await destroyPackage({
|
|
84
89
|
env: ctx.workspaceEnvOutput.env,
|
|
85
|
-
package:
|
|
90
|
+
package: ctx.package,
|
|
86
91
|
parameters: ctx.parametersOutput.parameters,
|
|
87
92
|
project: ctx.configOutput.config.project,
|
|
88
93
|
skipDeploy: true,
|
|
@@ -113,7 +118,7 @@ export default class Remove extends Command {
|
|
|
113
118
|
const configManager = getConfigManager();
|
|
114
119
|
await configManager.removePackage({
|
|
115
120
|
metadata: ctx.destroyOutput.metadata,
|
|
116
|
-
package:
|
|
121
|
+
package: ctx.package,
|
|
117
122
|
projectRootDir,
|
|
118
123
|
});
|
|
119
124
|
await delay(500);
|
|
@@ -6,6 +6,7 @@ export default class WorkspaceInstall extends Command {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
+
debug: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
10
|
parameter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[], import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
11
|
'parameter-file': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
12
|
workspace: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Listr, ListrLogLevels, ListrLogger } from 'listr2';
|
|
2
3
|
import { getBackend } from '../../../backend/index.js';
|
|
3
4
|
import { provisionPackage } from '../../../infrastructure/index.js';
|
|
4
5
|
import { arrayOfStringToObject } from '../../../lib/object-utils.js';
|
|
6
|
+
import { delay, setDebug } from '../../../lib/shell.js';
|
|
5
7
|
import { load } from '../../../lib/yaml-utils.js';
|
|
6
8
|
export default class WorkspaceInstall extends Command {
|
|
7
9
|
static args = {
|
|
8
10
|
package: Args.string({
|
|
9
11
|
description: 'The package to add. Packages are gitHub repositories. Use the format owner/repository',
|
|
10
|
-
required: true
|
|
12
|
+
required: true,
|
|
11
13
|
}),
|
|
12
14
|
};
|
|
13
15
|
static description = 'Add a package to the workspace.';
|
|
14
|
-
static examples = [
|
|
15
|
-
'<%= config.bin %> <%= command.id %> hereya/aws-cognito',
|
|
16
|
-
];
|
|
16
|
+
static examples = ['<%= config.bin %> <%= command.id %> hereya/aws-cognito'];
|
|
17
17
|
static flags = {
|
|
18
|
+
debug: Flags.boolean({
|
|
19
|
+
default: false,
|
|
20
|
+
description: 'enable debug mode',
|
|
21
|
+
}),
|
|
18
22
|
parameter: Flags.string({
|
|
19
23
|
char: 'p',
|
|
20
24
|
default: [],
|
|
21
|
-
description:
|
|
25
|
+
description: "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
|
|
22
26
|
multiple: true,
|
|
23
27
|
}),
|
|
24
28
|
'parameter-file': Flags.string({
|
|
@@ -33,42 +37,84 @@ export default class WorkspaceInstall extends Command {
|
|
|
33
37
|
};
|
|
34
38
|
async run() {
|
|
35
39
|
const { args, flags } = await this.parse(WorkspaceInstall);
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
setDebug(flags.debug);
|
|
41
|
+
const myLogger = new ListrLogger({ useIcons: false });
|
|
42
|
+
const task = new Listr([
|
|
43
|
+
{
|
|
44
|
+
async task(ctx, task) {
|
|
45
|
+
return task.newListr([
|
|
46
|
+
{
|
|
47
|
+
async task(ctx) {
|
|
48
|
+
const backend = await getBackend();
|
|
49
|
+
const loadWorkspaceOutput = await backend.getWorkspace(flags.workspace);
|
|
50
|
+
if (!loadWorkspaceOutput.found || loadWorkspaceOutput.hasError) {
|
|
51
|
+
throw new Error(`Workspace ${flags.workspace} not found`);
|
|
52
|
+
}
|
|
53
|
+
ctx.workspace = loadWorkspaceOutput;
|
|
54
|
+
await delay(500);
|
|
55
|
+
},
|
|
56
|
+
title: `Loading workspace ${flags.workspace}`,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
async task(ctx) {
|
|
60
|
+
const parametersInCmdline = arrayOfStringToObject(flags.parameter);
|
|
61
|
+
let parametersFromFile = {};
|
|
62
|
+
if (flags['parameter-file']) {
|
|
63
|
+
const { data, found } = await load(flags['parameter-file']);
|
|
64
|
+
if (!found) {
|
|
65
|
+
throw new Error(`Parameter file ${flags['parameter-file']} not found`);
|
|
66
|
+
}
|
|
67
|
+
parametersFromFile = data;
|
|
68
|
+
}
|
|
69
|
+
const parameters = { ...parametersFromFile, ...parametersInCmdline };
|
|
70
|
+
ctx.parameters = parameters;
|
|
71
|
+
await delay(500);
|
|
72
|
+
},
|
|
73
|
+
title: 'Resolving parameters',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
async task(ctx) {
|
|
77
|
+
const provisionOutput = await provisionPackage({
|
|
78
|
+
package: args.package,
|
|
79
|
+
parameters: ctx.parameters,
|
|
80
|
+
workspace: flags.workspace,
|
|
81
|
+
});
|
|
82
|
+
if (!provisionOutput.success) {
|
|
83
|
+
throw new Error(provisionOutput.reason);
|
|
84
|
+
}
|
|
85
|
+
ctx.provisionOutput = provisionOutput;
|
|
86
|
+
},
|
|
87
|
+
title: 'Provisioning package',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
async task(ctx) {
|
|
91
|
+
const { env, metadata } = ctx.provisionOutput;
|
|
92
|
+
const backend = await getBackend();
|
|
93
|
+
const output = await backend.addPackageToWorkspace({
|
|
94
|
+
env,
|
|
95
|
+
infra: metadata.infra,
|
|
96
|
+
package: args.package,
|
|
97
|
+
parameters: ctx.parameters,
|
|
98
|
+
workspace: flags.workspace,
|
|
99
|
+
});
|
|
100
|
+
if (!output.success) {
|
|
101
|
+
throw new Error(output.reason);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
title: 'Saving exported environment variables to workspace',
|
|
105
|
+
},
|
|
106
|
+
]);
|
|
107
|
+
},
|
|
108
|
+
title: `Installing ${args.package} into workspace ${flags.workspace}`,
|
|
109
|
+
},
|
|
110
|
+
], { concurrent: false });
|
|
111
|
+
try {
|
|
112
|
+
await task.run();
|
|
113
|
+
myLogger.log(ListrLogLevels.COMPLETED, `Package ${args.package} installed successfully into workspace ${flags.workspace}`);
|
|
58
114
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const output = await backend.addPackageToWorkspace({
|
|
63
|
-
env,
|
|
64
|
-
infra: metadata.infra,
|
|
65
|
-
package: args.package,
|
|
66
|
-
parameters,
|
|
67
|
-
workspace: flags.workspace,
|
|
68
|
-
});
|
|
69
|
-
if (!output.success) {
|
|
70
|
-
this.error(output.reason);
|
|
115
|
+
catch (error) {
|
|
116
|
+
myLogger.log(ListrLogLevels.FAILED, error);
|
|
117
|
+
this.error(error.message);
|
|
71
118
|
}
|
|
72
|
-
this.log(`Package ${args.package} added to workspace ${flags.workspace}`);
|
|
73
119
|
}
|
|
74
120
|
}
|
|
@@ -6,6 +6,7 @@ export default class WorkspaceUninstall extends Command {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
+
debug: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
10
|
parameter: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[], import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
11
|
'parameter-file': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
12
|
workspace: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Listr, ListrLogLevels, ListrLogger } from 'listr2';
|
|
2
3
|
import { getBackend } from '../../../backend/index.js';
|
|
3
4
|
import { destroyPackage } from '../../../infrastructure/index.js';
|
|
4
5
|
import { arrayOfStringToObject } from '../../../lib/object-utils.js';
|
|
6
|
+
import { delay, setDebug } from '../../../lib/shell.js';
|
|
5
7
|
import { load } from '../../../lib/yaml-utils.js';
|
|
6
8
|
export default class WorkspaceUninstall extends Command {
|
|
7
9
|
static args = {
|
|
8
10
|
package: Args.string({
|
|
9
11
|
description: 'The package to remove. Packages are gitHub repositories. Use the format owner/repository',
|
|
10
|
-
required: true
|
|
12
|
+
required: true,
|
|
11
13
|
}),
|
|
12
14
|
};
|
|
13
15
|
static description = 'Remove a package from a workspace.';
|
|
14
|
-
static examples = [
|
|
15
|
-
'<%= config.bin %> <%= command.id %> hereya/aws-cognito',
|
|
16
|
-
];
|
|
16
|
+
static examples = ['<%= config.bin %> <%= command.id %> hereya/aws-cognito'];
|
|
17
17
|
static flags = {
|
|
18
|
+
debug: Flags.boolean({
|
|
19
|
+
default: false,
|
|
20
|
+
description: 'enable debug mode',
|
|
21
|
+
}),
|
|
18
22
|
parameter: Flags.string({
|
|
19
23
|
char: 'p',
|
|
20
24
|
default: [],
|
|
21
|
-
description:
|
|
25
|
+
description: "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
|
|
22
26
|
multiple: true,
|
|
23
27
|
}),
|
|
24
28
|
'parameter-file': Flags.string({
|
|
@@ -33,53 +37,90 @@ export default class WorkspaceUninstall extends Command {
|
|
|
33
37
|
};
|
|
34
38
|
async run() {
|
|
35
39
|
const { args, flags } = await this.parse(WorkspaceUninstall);
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
setDebug(flags.debug);
|
|
41
|
+
const myLogger = new ListrLogger({ useIcons: false });
|
|
42
|
+
const task = new Listr([
|
|
43
|
+
{
|
|
44
|
+
async task(ctx, task) {
|
|
45
|
+
return task.newListr([
|
|
46
|
+
{
|
|
47
|
+
async task(ctx) {
|
|
48
|
+
const backend = await getBackend();
|
|
49
|
+
const loadWorkspaceOutput = await backend.getWorkspace(flags.workspace);
|
|
50
|
+
if (!loadWorkspaceOutput.found || loadWorkspaceOutput.hasError) {
|
|
51
|
+
throw new Error(`Workspace ${flags.workspace} not found`);
|
|
52
|
+
}
|
|
53
|
+
if (!(args.package in (loadWorkspaceOutput.workspace.packages ?? {}))) {
|
|
54
|
+
throw new Error(`Package ${args.package} not found in workspace ${flags.workspace}`);
|
|
55
|
+
}
|
|
56
|
+
ctx.workspace = loadWorkspaceOutput;
|
|
57
|
+
await delay(500);
|
|
58
|
+
},
|
|
59
|
+
title: `Loading workspace ${flags.workspace}`,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
async task(ctx) {
|
|
63
|
+
const parametersInCmdline = arrayOfStringToObject(flags.parameter);
|
|
64
|
+
let parametersFromFile = {};
|
|
65
|
+
if (flags['parameter-file']) {
|
|
66
|
+
const { data, found } = await load(flags['parameter-file']);
|
|
67
|
+
if (!found) {
|
|
68
|
+
throw new Error(`Parameter file ${flags['parameter-file']} not found`);
|
|
69
|
+
}
|
|
70
|
+
parametersFromFile = data;
|
|
71
|
+
}
|
|
72
|
+
const parameters = {
|
|
73
|
+
...ctx.workspace.workspace.packages?.[args.package].parameters,
|
|
74
|
+
...parametersFromFile,
|
|
75
|
+
...parametersInCmdline,
|
|
76
|
+
};
|
|
77
|
+
ctx.parameters = parameters;
|
|
78
|
+
await delay(500);
|
|
79
|
+
},
|
|
80
|
+
title: 'Resolving parameters',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
async task(ctx) {
|
|
84
|
+
const destroyOutput = await destroyPackage({
|
|
85
|
+
package: args.package,
|
|
86
|
+
parameters: ctx.parameters,
|
|
87
|
+
workspace: flags.workspace,
|
|
88
|
+
});
|
|
89
|
+
if (!destroyOutput.success) {
|
|
90
|
+
throw new Error(destroyOutput.reason);
|
|
91
|
+
}
|
|
92
|
+
ctx.destroyOutput = destroyOutput;
|
|
93
|
+
},
|
|
94
|
+
title: 'Destroying package',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
async task(ctx) {
|
|
98
|
+
const { env, metadata } = ctx.destroyOutput;
|
|
99
|
+
const backend = await getBackend();
|
|
100
|
+
const output = await backend.removePackageFromWorkspace({
|
|
101
|
+
env,
|
|
102
|
+
infra: metadata.infra,
|
|
103
|
+
package: args.package,
|
|
104
|
+
workspace: flags.workspace,
|
|
105
|
+
});
|
|
106
|
+
if (!output.success) {
|
|
107
|
+
throw new Error(output.reason);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
title: 'Removing exported environment variables from workspace',
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
},
|
|
114
|
+
title: `Uninstalling package ${args.package} from workspace ${flags.workspace}`,
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
try {
|
|
118
|
+
await task.run();
|
|
119
|
+
myLogger.log(ListrLogLevels.COMPLETED, `Package ${args.package} uninstalled successfully from workspace ${flags.workspace}`);
|
|
70
120
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const output = await backend.removePackageFromWorkspace({
|
|
75
|
-
env,
|
|
76
|
-
infra: metadata.infra,
|
|
77
|
-
package: args.package,
|
|
78
|
-
workspace: flags.workspace,
|
|
79
|
-
});
|
|
80
|
-
if (!output.success) {
|
|
81
|
-
this.error(output.reason);
|
|
121
|
+
catch (error) {
|
|
122
|
+
myLogger.log(ListrLogLevels.FAILED, error);
|
|
123
|
+
this.error(error.message);
|
|
82
124
|
}
|
|
83
|
-
this.log(`Package ${args.package} removed from workspace ${flags.workspace}`);
|
|
84
125
|
}
|
|
85
126
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -571,37 +571,6 @@
|
|
|
571
571
|
"index.js"
|
|
572
572
|
]
|
|
573
573
|
},
|
|
574
|
-
"workspace:delete": {
|
|
575
|
-
"aliases": [],
|
|
576
|
-
"args": {
|
|
577
|
-
"name": {
|
|
578
|
-
"description": "name of the workspace to delete",
|
|
579
|
-
"name": "name",
|
|
580
|
-
"required": true
|
|
581
|
-
}
|
|
582
|
-
},
|
|
583
|
-
"description": "Delete a workspace if it exists.",
|
|
584
|
-
"examples": [
|
|
585
|
-
"<%= config.bin %> <%= command.id %> dev"
|
|
586
|
-
],
|
|
587
|
-
"flags": {},
|
|
588
|
-
"hasDynamicHelp": false,
|
|
589
|
-
"hiddenAliases": [],
|
|
590
|
-
"id": "workspace:delete",
|
|
591
|
-
"pluginAlias": "hereya-cli",
|
|
592
|
-
"pluginName": "hereya-cli",
|
|
593
|
-
"pluginType": "core",
|
|
594
|
-
"strict": true,
|
|
595
|
-
"enableJsonFlag": false,
|
|
596
|
-
"isESM": true,
|
|
597
|
-
"relativePath": [
|
|
598
|
-
"dist",
|
|
599
|
-
"commands",
|
|
600
|
-
"workspace",
|
|
601
|
-
"delete",
|
|
602
|
-
"index.js"
|
|
603
|
-
]
|
|
604
|
-
},
|
|
605
574
|
"workspace:env": {
|
|
606
575
|
"aliases": [],
|
|
607
576
|
"args": {
|
|
@@ -652,6 +621,37 @@
|
|
|
652
621
|
"index.js"
|
|
653
622
|
]
|
|
654
623
|
},
|
|
624
|
+
"workspace:delete": {
|
|
625
|
+
"aliases": [],
|
|
626
|
+
"args": {
|
|
627
|
+
"name": {
|
|
628
|
+
"description": "name of the workspace to delete",
|
|
629
|
+
"name": "name",
|
|
630
|
+
"required": true
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
"description": "Delete a workspace if it exists.",
|
|
634
|
+
"examples": [
|
|
635
|
+
"<%= config.bin %> <%= command.id %> dev"
|
|
636
|
+
],
|
|
637
|
+
"flags": {},
|
|
638
|
+
"hasDynamicHelp": false,
|
|
639
|
+
"hiddenAliases": [],
|
|
640
|
+
"id": "workspace:delete",
|
|
641
|
+
"pluginAlias": "hereya-cli",
|
|
642
|
+
"pluginName": "hereya-cli",
|
|
643
|
+
"pluginType": "core",
|
|
644
|
+
"strict": true,
|
|
645
|
+
"enableJsonFlag": false,
|
|
646
|
+
"isESM": true,
|
|
647
|
+
"relativePath": [
|
|
648
|
+
"dist",
|
|
649
|
+
"commands",
|
|
650
|
+
"workspace",
|
|
651
|
+
"delete",
|
|
652
|
+
"index.js"
|
|
653
|
+
]
|
|
654
|
+
},
|
|
655
655
|
"workspace:install": {
|
|
656
656
|
"aliases": [],
|
|
657
657
|
"args": {
|
|
@@ -666,6 +666,12 @@
|
|
|
666
666
|
"<%= config.bin %> <%= command.id %> hereya/aws-cognito"
|
|
667
667
|
],
|
|
668
668
|
"flags": {
|
|
669
|
+
"debug": {
|
|
670
|
+
"description": "enable debug mode",
|
|
671
|
+
"name": "debug",
|
|
672
|
+
"allowNo": false,
|
|
673
|
+
"type": "boolean"
|
|
674
|
+
},
|
|
669
675
|
"parameter": {
|
|
670
676
|
"char": "p",
|
|
671
677
|
"description": "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
|
|
@@ -724,6 +730,12 @@
|
|
|
724
730
|
"<%= config.bin %> <%= command.id %> hereya/aws-cognito"
|
|
725
731
|
],
|
|
726
732
|
"flags": {
|
|
733
|
+
"debug": {
|
|
734
|
+
"description": "enable debug mode",
|
|
735
|
+
"name": "debug",
|
|
736
|
+
"allowNo": false,
|
|
737
|
+
"type": "boolean"
|
|
738
|
+
},
|
|
727
739
|
"parameter": {
|
|
728
740
|
"char": "p",
|
|
729
741
|
"description": "parameter for the package, in the form of 'key=value'. Can be specified multiple times.",
|
|
@@ -884,5 +896,5 @@
|
|
|
884
896
|
]
|
|
885
897
|
}
|
|
886
898
|
},
|
|
887
|
-
"version": "0.
|
|
899
|
+
"version": "0.16.0"
|
|
888
900
|
}
|