hereya-cli 0.32.0 → 0.34.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.32.0 linux-x64 node-v22.14.0
23
+ hereya-cli/0.34.0 linux-x64 node-v22.14.0
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -84,7 +84,7 @@ EXAMPLES
84
84
  $ hereya add cloudy/docker_postgres
85
85
  ```
86
86
 
87
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/add/index.ts)_
87
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/add/index.ts)_
88
88
 
89
89
  ## `hereya bootstrap INFRASTRUCTURETYPE`
90
90
 
@@ -109,7 +109,7 @@ EXAMPLES
109
109
  $ hereya bootstrap local
110
110
  ```
111
111
 
112
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/bootstrap/index.ts)_
112
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/bootstrap/index.ts)_
113
113
 
114
114
  ## `hereya config get-backend`
115
115
 
@@ -126,7 +126,7 @@ EXAMPLES
126
126
  $ hereya config get-backend
127
127
  ```
128
128
 
129
- _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/config/get-backend/index.ts)_
129
+ _See code: [src/commands/config/get-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/config/get-backend/index.ts)_
130
130
 
131
131
  ## `hereya config use-backend TYPE`
132
132
 
@@ -148,7 +148,7 @@ EXAMPLES
148
148
  $ hereya config use-backend local
149
149
  ```
150
150
 
151
- _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/config/use-backend/index.ts)_
151
+ _See code: [src/commands/config/use-backend/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/config/use-backend/index.ts)_
152
152
 
153
153
  ## `hereya deploy`
154
154
 
@@ -173,7 +173,7 @@ EXAMPLES
173
173
  $ hereya deploy
174
174
  ```
175
175
 
176
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/deploy/index.ts)_
176
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/deploy/index.ts)_
177
177
 
178
178
  ## `hereya down`
179
179
 
@@ -200,7 +200,7 @@ EXAMPLES
200
200
  $ hereya down
201
201
  ```
202
202
 
203
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/down/index.ts)_
203
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/down/index.ts)_
204
204
 
205
205
  ## `hereya env [NAME]`
206
206
 
@@ -231,7 +231,7 @@ EXAMPLES
231
231
  $ hereya env -w dev -l
232
232
  ```
233
233
 
234
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/env/index.ts)_
234
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/env/index.ts)_
235
235
 
236
236
  ## `hereya env set [NAME]`
237
237
 
@@ -258,7 +258,7 @@ EXAMPLES
258
258
  $ hereya env set FOO -v bar -w dev
259
259
  ```
260
260
 
261
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/env/set/index.ts)_
261
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/env/set/index.ts)_
262
262
 
263
263
  ## `hereya help [COMMAND]`
264
264
 
@@ -304,7 +304,7 @@ EXAMPLES
304
304
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
305
305
  ```
306
306
 
307
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/init/index.ts)_
307
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/init/index.ts)_
308
308
 
309
309
  ## `hereya remove PACKAGE`
310
310
 
@@ -331,7 +331,7 @@ EXAMPLES
331
331
  $ hereya remove cloudy/docker_postgres
332
332
  ```
333
333
 
334
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/remove/index.ts)_
334
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/remove/index.ts)_
335
335
 
336
336
  ## `hereya run CMD`
337
337
 
@@ -357,7 +357,7 @@ EXAMPLES
357
357
  $ hereya run -w uat -- node index.js
358
358
  ```
359
359
 
360
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/run/index.ts)_
360
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/run/index.ts)_
361
361
 
362
362
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
363
363
 
@@ -382,7 +382,7 @@ EXAMPLES
382
382
  $ hereya unbootstrap local
383
383
  ```
384
384
 
385
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/unbootstrap/index.ts)_
385
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/unbootstrap/index.ts)_
386
386
 
387
387
  ## `hereya undeploy`
388
388
 
@@ -407,7 +407,7 @@ EXAMPLES
407
407
  $ hereya undeploy
408
408
  ```
409
409
 
410
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/undeploy/index.ts)_
410
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/undeploy/index.ts)_
411
411
 
412
412
  ## `hereya up`
413
413
 
@@ -434,7 +434,7 @@ EXAMPLES
434
434
  $ hereya up
435
435
  ```
436
436
 
437
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/up/index.ts)_
437
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/up/index.ts)_
438
438
 
439
439
  ## `hereya workspace create NAME`
440
440
 
@@ -457,7 +457,7 @@ EXAMPLES
457
457
  $ hereya workspace create dev
458
458
  ```
459
459
 
460
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/create/index.ts)_
460
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/create/index.ts)_
461
461
 
462
462
  ## `hereya workspace delete NAME`
463
463
 
@@ -477,7 +477,7 @@ EXAMPLES
477
477
  $ hereya workspace delete dev
478
478
  ```
479
479
 
480
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/delete/index.ts)_
480
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/delete/index.ts)_
481
481
 
482
482
  ## `hereya workspace env [NAME]`
483
483
 
@@ -503,7 +503,7 @@ EXAMPLES
503
503
  $ hereya workspace env myEnv -w dev
504
504
  ```
505
505
 
506
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/env/index.ts)_
506
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/env/index.ts)_
507
507
 
508
508
  ## `hereya workspace env set`
509
509
 
@@ -527,7 +527,7 @@ EXAMPLES
527
527
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
528
528
  ```
529
529
 
530
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/env/set/index.ts)_
530
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/env/set/index.ts)_
531
531
 
532
532
  ## `hereya workspace env unset`
533
533
 
@@ -548,7 +548,7 @@ EXAMPLES
548
548
  $ hereya workspace env unset -w my-workspace -n myVar
549
549
  ```
550
550
 
551
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/env/unset/index.ts)_
551
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/env/unset/index.ts)_
552
552
 
553
553
  ## `hereya workspace install PACKAGE`
554
554
 
@@ -575,7 +575,7 @@ EXAMPLES
575
575
  $ hereya workspace install hereya/aws-cognito
576
576
  ```
577
577
 
578
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/install/index.ts)_
578
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/install/index.ts)_
579
579
 
580
580
  ## `hereya workspace list`
581
581
 
@@ -592,7 +592,7 @@ EXAMPLES
592
592
  $ hereya workspace list
593
593
  ```
594
594
 
595
- _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/list/index.ts)_
595
+ _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/list/index.ts)_
596
596
 
597
597
  ## `hereya workspace uninstall PACKAGE`
598
598
 
@@ -619,5 +619,5 @@ EXAMPLES
619
619
  $ hereya workspace uninstall hereya/aws-cognito
620
620
  ```
621
621
 
622
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.32.0/src/commands/workspace/uninstall/index.ts)_
622
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.34.0/src/commands/workspace/uninstall/index.ts)_
623
623
  <!-- commandsstop -->
@@ -111,7 +111,7 @@ export class S3FileStorage {
111
111
  * Build an S3 key by joining the basePath with a relative path.
112
112
  */
113
113
  getKey(relativePath) {
114
- return [this.basePath, relativePath].join('/');
114
+ return [this.basePath, relativePath].filter(Boolean).join('/');
115
115
  }
116
116
  /**
117
117
  * Helper to convert a Readable stream into a string.
@@ -1,5 +1,6 @@
1
1
  import { Backend } from './common.js';
2
2
  export declare function getBackend(): Promise<Backend>;
3
+ export declare function setBackendType(type: BackendType): void;
3
4
  export declare enum BackendType {
4
5
  Local = "local",
5
6
  S3 = "s3"
@@ -3,11 +3,12 @@ import { getCurrentBackendType } from './config.js';
3
3
  import { LocalFileBackend } from './local.js';
4
4
  import { S3FileBackend } from './s3.js';
5
5
  let backend;
6
+ let currentBackendType;
6
7
  export async function getBackend() {
7
8
  if (backend) {
8
9
  return backend;
9
10
  }
10
- const backendType = await getCurrentBackendType();
11
+ const backendType = currentBackendType ?? await getCurrentBackendType();
11
12
  switch (backendType) {
12
13
  case BackendType.Local: {
13
14
  backend = new LocalFileBackend();
@@ -27,6 +28,9 @@ export async function getBackend() {
27
28
  }
28
29
  return backend;
29
30
  }
31
+ export function setBackendType(type) {
32
+ currentBackendType = type;
33
+ }
30
34
  export var BackendType;
31
35
  (function (BackendType) {
32
36
  BackendType["Local"] = "local";
@@ -1,28 +1,36 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
+ import { BackendType, setBackendType } from '../../backend/index.js';
2
3
  import { getInfrastructure } from '../../infrastructure/index.js';
4
+ import { getLogPath, setDebug } from '../../lib/log.js';
3
5
  export default class Bootstrap extends Command {
4
6
  static args = {
5
7
  infrastructureType: Args.string({
6
8
  description: 'infrastructure to bootstrap. Options are local, aws',
7
- required: true
8
- })
9
+ required: true,
10
+ }),
9
11
  };
10
12
  static description = 'Install necessary resources for hereya operations in an infrastructure.';
11
- static examples = [
12
- '<%= config.bin %> <%= command.id %> aws',
13
- '<%= config.bin %> <%= command.id %> local'
14
- ];
13
+ static examples = ['<%= config.bin %> <%= command.id %> aws', '<%= config.bin %> <%= command.id %> local'];
15
14
  static flags = {
16
15
  force: Flags.boolean({ char: 'f', description: 'redeploy hereya resources if already deployed' }),
17
16
  };
18
17
  async run() {
19
18
  const { args, flags } = await this.parse(Bootstrap);
19
+ setBackendType(BackendType.Local);
20
20
  const infrastructure$ = getInfrastructure({ type: args.infrastructureType });
21
21
  if (!infrastructure$.supported) {
22
22
  this.warn(infrastructure$.reason);
23
23
  return;
24
24
  }
25
25
  const { infrastructure } = infrastructure$;
26
- await infrastructure.bootstrap({ force: flags.force });
26
+ setDebug(true);
27
+ try {
28
+ await infrastructure.bootstrap({ force: flags.force });
29
+ }
30
+ catch (error) {
31
+ this.error(`${error.message}
32
+
33
+ See ${getLogPath()} for more details`);
34
+ }
27
35
  }
28
36
  }
@@ -1,5 +1,7 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
+ import { BackendType, setBackendType } from '../../backend/index.js';
2
3
  import { getInfrastructure } from '../../infrastructure/index.js';
4
+ import { getLogPath, setDebug } from '../../lib/log.js';
3
5
  export default class Unbootstrap extends Command {
4
6
  static args = {
5
7
  infrastructureType: Args.string({
@@ -17,12 +19,21 @@ export default class Unbootstrap extends Command {
17
19
  };
18
20
  async run() {
19
21
  const { args, flags } = await this.parse(Unbootstrap);
22
+ setBackendType(BackendType.Local);
20
23
  const infrastructure$ = getInfrastructure({ type: args.infrastructureType });
21
24
  if (!infrastructure$.supported) {
22
25
  this.warn(infrastructure$.reason);
23
26
  return;
24
27
  }
25
28
  const { infrastructure } = infrastructure$;
26
- await infrastructure.unbootstrap({ force: flags.force });
29
+ setDebug(true);
30
+ try {
31
+ await infrastructure.unbootstrap({ force: flags.force });
32
+ }
33
+ catch (error) {
34
+ this.error(`${error.message}
35
+
36
+ See ${getLogPath()} for more details`);
37
+ }
27
38
  }
28
39
  }
@@ -1,12 +1,23 @@
1
1
  import { GetParameterCommand, SSMClient } from '@aws-sdk/client-ssm';
2
+ import { getDefaultLogger } from '../lib/log.js';
2
3
  const configKey = '/hereya-bootstrap/config';
3
4
  export function getAwsConfigKey() {
4
5
  return configKey;
5
6
  }
6
7
  export async function getAwsConfig() {
7
- const ssmClient = new SSMClient({});
8
- const ssmParameter = await ssmClient.send(new GetParameterCommand({
9
- Name: configKey,
10
- }));
11
- return JSON.parse(ssmParameter.Parameter?.Value ?? '{}');
8
+ try {
9
+ const ssmClient = new SSMClient({});
10
+ const ssmParameter = await ssmClient.send(new GetParameterCommand({
11
+ Name: configKey,
12
+ }));
13
+ return JSON.parse(ssmParameter.Parameter?.Value ?? '{}');
14
+ }
15
+ catch (error) {
16
+ getDefaultLogger().error(`Could not get AWS config: ${error.message}`);
17
+ return {
18
+ backendBucket: '',
19
+ terraformStateBucketName: '',
20
+ terraformStateLockTableName: '',
21
+ };
22
+ }
12
23
  }
@@ -192,8 +192,13 @@ export class AwsInfrastructure {
192
192
  return { success: true, value: parameter.Parameter.ARN };
193
193
  }
194
194
  async unbootstrap(_) {
195
+ const bootstrapPackage = 'hereya/bootstrap-aws-stack';
196
+ const output = await destroyPackage({ package: bootstrapPackage });
197
+ if (!output.success) {
198
+ throw new Error(output.reason);
199
+ }
195
200
  const ssmClient = new SSMClient({});
196
- const key = '/hereya-bootstrap/config';
201
+ const key = getAwsConfigKey();
197
202
  try {
198
203
  await ssmClient.send(new DeleteParameterCommand({
199
204
  Name: key,
@@ -202,11 +207,6 @@ export class AwsInfrastructure {
202
207
  catch (error) {
203
208
  console.log(`Could not delete parameter "${key}": ${error.message}. Continuing with unbootstrap...`);
204
209
  }
205
- const bootstrapPackage = 'hereya/bootstrap-aws-stack';
206
- const output = await destroyPackage({ package: bootstrapPackage });
207
- if (!output.success) {
208
- throw new Error(output.reason);
209
- }
210
210
  }
211
211
  async undeploy(input) {
212
212
  input.parameters = {
@@ -1063,5 +1063,5 @@
1063
1063
  ]
1064
1064
  }
1065
1065
  },
1066
- "version": "0.32.0"
1066
+ "version": "0.34.0"
1067
1067
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.32.0",
4
+ "version": "0.34.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"