hereya-cli 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g hereya-cli
20
20
  $ hereya COMMAND
21
21
  running command...
22
22
  $ hereya (--version)
23
- hereya-cli/0.13.1 linux-x64 node-v22.12.0
23
+ hereya-cli/0.14.0 linux-x64 node-v22.13.0
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.13.1/src/commands/add/index.ts)_
76
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/bootstrap/index.ts)_
101
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/deploy/index.ts)_
123
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/down/index.ts)_
146
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/env/index.ts)_
177
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/init/index.ts)_
223
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/remove/index.ts)_
247
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/run/index.ts)_
273
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/unbootstrap/index.ts)_
298
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/undeploy/index.ts)_
320
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/up/index.ts)_
343
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/workspace/create/index.ts)_
363
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/workspace/delete/index.ts)_
383
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/workspace/env/index.ts)_
409
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/workspace/env/set/index.ts)_
433
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.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.13.1/src/commands/workspace/env/unset/index.ts)_
454
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/env/unset/index.ts)_
455
455
 
456
456
  ## `hereya workspace install PACKAGE`
457
457
 
@@ -477,7 +477,7 @@ EXAMPLES
477
477
  $ hereya workspace install hereya/aws-cognito
478
478
  ```
479
479
 
480
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.13.1/src/commands/workspace/install/index.ts)_
480
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/install/index.ts)_
481
481
 
482
482
  ## `hereya workspace uninstall PACKAGE`
483
483
 
@@ -503,5 +503,5 @@ EXAMPLES
503
503
  $ hereya workspace uninstall hereya/aws-cognito
504
504
  ```
505
505
 
506
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.13.1/src/commands/workspace/uninstall/index.ts)_
506
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.14.0/src/commands/workspace/uninstall/index.ts)_
507
507
  <!-- commandsstop -->
@@ -1,13 +1,13 @@
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 { getConfigManager } from '../../lib/config/index.js';
5
6
  import { getEnvManager } from '../../lib/env/index.js';
6
7
  import { logEnv } from '../../lib/env-utils.js';
7
- import { getLogger } from '../../lib/log.js';
8
8
  import { arrayOfStringToObject } from '../../lib/object-utils.js';
9
9
  import { getParameterManager } from '../../lib/parameter/index.js';
10
- import { setDebug } from '../../lib/shell.js';
10
+ import { delay, setDebug } from '../../lib/shell.js';
11
11
  export default class Add extends Command {
12
12
  static args = {
13
13
  package: Args.string({
@@ -36,73 +36,130 @@ export default class Add extends Command {
36
36
  async run() {
37
37
  const { args, flags } = await this.parse(Add);
38
38
  setDebug(flags.debug);
39
- const logger = getLogger();
40
39
  const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
41
- const configManager = getConfigManager();
42
- const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
43
- if (!loadConfigOutput.found) {
44
- this.warn(`Project not initialized. Run 'hereya init' first.`);
45
- return;
40
+ const myLogger = new ListrLogger({ useIcons: false });
41
+ const task = new Listr([
42
+ {
43
+ async task(ctx, task) {
44
+ return task.newListr([
45
+ {
46
+ async task(ctx) {
47
+ const configManager = getConfigManager();
48
+ const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
49
+ if (!loadConfigOutput.found) {
50
+ throw new Error("Project not initialized. Run 'hereya init' first.");
51
+ }
52
+ ctx.configOutput = loadConfigOutput;
53
+ await delay(500);
54
+ },
55
+ title: 'Loading project config',
56
+ },
57
+ {
58
+ async task(ctx) {
59
+ const backend = await getBackend();
60
+ const getWorkspaceEnvOutput = await backend.getWorkspaceEnv({
61
+ project: ctx.configOutput.config.project,
62
+ workspace: ctx.configOutput.config.workspace,
63
+ });
64
+ if (!getWorkspaceEnvOutput.success) {
65
+ throw new Error(getWorkspaceEnvOutput.reason);
66
+ }
67
+ ctx.workspaceEnvOutput = getWorkspaceEnvOutput;
68
+ await delay(500);
69
+ },
70
+ title: 'Loading Workspace environment variables',
71
+ },
72
+ {
73
+ async task(ctx) {
74
+ const userSpecifiedParameters = arrayOfStringToObject(flags.parameter);
75
+ const parameterManager = getParameterManager();
76
+ const parametersOutput = await parameterManager.getPackageParameters({
77
+ package: args.package,
78
+ projectRootDir,
79
+ userSpecifiedParameters,
80
+ workspace: ctx.configOutput.config.workspace,
81
+ });
82
+ ctx.parametersOutput = parametersOutput;
83
+ await delay(500);
84
+ },
85
+ title: 'Resolving package parameters',
86
+ },
87
+ {
88
+ async task(ctx) {
89
+ const provisionOutput = await provisionPackage({
90
+ env: ctx.workspaceEnvOutput.env,
91
+ package: args.package,
92
+ parameters: ctx.parametersOutput.parameters,
93
+ project: ctx.configOutput.config.project,
94
+ skipDeploy: true,
95
+ workspace: ctx.configOutput.config.workspace,
96
+ });
97
+ if (!provisionOutput.success) {
98
+ throw new Error(provisionOutput.reason);
99
+ }
100
+ ctx.provisionOutput = provisionOutput;
101
+ },
102
+ title: 'Provisioning package',
103
+ },
104
+ {
105
+ async task(ctx) {
106
+ const { env, metadata } = ctx.provisionOutput;
107
+ const envManager = getEnvManager();
108
+ await envManager.addProjectEnv({
109
+ env,
110
+ infra: metadata.originalInfra ?? metadata.infra,
111
+ projectRootDir,
112
+ workspace: ctx.configOutput.config.workspace,
113
+ });
114
+ await delay(500);
115
+ },
116
+ title: 'Saving exported environment variables',
117
+ },
118
+ {
119
+ async task(ctx) {
120
+ const configManager = getConfigManager();
121
+ await configManager.addPackage({
122
+ metadata: ctx.provisionOutput.metadata,
123
+ package: args.package,
124
+ projectRootDir,
125
+ });
126
+ await delay(500);
127
+ },
128
+ title: 'Adding package to hereya manifest',
129
+ },
130
+ {
131
+ async task(ctx) {
132
+ const backend = await getBackend();
133
+ const configManager = getConfigManager();
134
+ const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
135
+ await backend.saveState(newConfig);
136
+ const parameterManager = getParameterManager();
137
+ const { filePath, saved } = await parameterManager.savePackageParameters({
138
+ package: args.package,
139
+ parameters: ctx.parametersOutput.parameters,
140
+ projectRootDir,
141
+ workspace: ctx.configOutput.config.workspace,
142
+ });
143
+ await delay(500);
144
+ if (saved) {
145
+ myLogger.log(ListrLogLevels.COMPLETED, `Saved the following parameters for the package in ${filePath}:`);
146
+ logEnv(ctx.parametersOutput.parameters, (msg) => myLogger.log(ListrLogLevels.COMPLETED, msg));
147
+ }
148
+ },
149
+ title: 'Saving state',
150
+ },
151
+ ], { concurrent: false });
152
+ },
153
+ title: `Adding ${args.package}`,
154
+ },
155
+ ], { concurrent: false });
156
+ try {
157
+ await task.run();
158
+ myLogger.log(ListrLogLevels.COMPLETED, 'Package added successfully');
46
159
  }
47
- const { config } = loadConfigOutput;
48
- const backend = await getBackend();
49
- const getWorkspaceEnvOutput = await backend.getWorkspaceEnv({
50
- project: config.project,
51
- workspace: config.workspace,
52
- });
53
- if (!getWorkspaceEnvOutput.success) {
54
- this.error(getWorkspaceEnvOutput.reason);
55
- }
56
- const { env: workspaceEnv } = getWorkspaceEnvOutput;
57
- const userSpecifiedParameters = arrayOfStringToObject(flags.parameter);
58
- const parameterManager = getParameterManager();
59
- const { parameters } = await parameterManager.getPackageParameters({
60
- package: args.package,
61
- projectRootDir,
62
- userSpecifiedParameters,
63
- workspace: config.workspace,
64
- });
65
- logger.log(`Provisioning package ${args.package}`);
66
- const provisionOutput = await provisionPackage({
67
- env: workspaceEnv,
68
- package: args.package,
69
- parameters,
70
- project: config.project,
71
- skipDeploy: true,
72
- workspace: config.workspace,
73
- });
74
- if (!provisionOutput.success) {
75
- this.error(provisionOutput.reason);
76
- }
77
- const { env, metadata } = provisionOutput;
78
- logger.done(`Package ${args.package} provisioned successfully`);
79
- logger.log(`Saving exported environment variables`);
80
- const envManager = getEnvManager();
81
- await envManager.addProjectEnv({
82
- env,
83
- infra: metadata.originalInfra ?? metadata.infra,
84
- projectRootDir,
85
- workspace: config.workspace,
86
- });
87
- logger.done('Saved exported environment variables');
88
- logger.log('Adding package to hereya manifest');
89
- await configManager.addPackage({
90
- metadata,
91
- package: args.package,
92
- projectRootDir,
93
- });
94
- logger.done('Package added to hereya manifest');
95
- const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
96
- await backend.saveState(newConfig);
97
- const { filePath, saved } = await parameterManager.savePackageParameters({
98
- package: args.package,
99
- parameters,
100
- projectRootDir,
101
- workspace: config.workspace,
102
- });
103
- if (saved) {
104
- await logger.done(`Saved the following parameters for the package in ${filePath}:`);
105
- logEnv(parameters, (msg) => logger.done(msg));
160
+ catch (error) {
161
+ myLogger.log(ListrLogLevels.FAILED, error);
162
+ this.error(error.message);
106
163
  }
107
164
  }
108
165
  }