hereya-cli 0.8.5 → 0.8.7

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.8.5 linux-x64 node-v20.15.0
23
+ hereya-cli/0.8.7 linux-x64 node-v20.15.0
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -71,7 +71,7 @@ EXAMPLES
71
71
  $ hereya add cloudy/docker_postgres
72
72
  ```
73
73
 
74
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/add/index.ts)_
74
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/add/index.ts)_
75
75
 
76
76
  ## `hereya bootstrap INFRASTRUCTURETYPE`
77
77
 
@@ -96,7 +96,7 @@ EXAMPLES
96
96
  $ hereya bootstrap local
97
97
  ```
98
98
 
99
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/bootstrap/index.ts)_
99
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/bootstrap/index.ts)_
100
100
 
101
101
  ## `hereya deploy`
102
102
 
@@ -117,7 +117,7 @@ EXAMPLES
117
117
  $ hereya deploy
118
118
  ```
119
119
 
120
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/deploy/index.ts)_
120
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/deploy/index.ts)_
121
121
 
122
122
  ## `hereya down`
123
123
 
@@ -139,7 +139,7 @@ EXAMPLES
139
139
  $ hereya down
140
140
  ```
141
141
 
142
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/down/index.ts)_
142
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/down/index.ts)_
143
143
 
144
144
  ## `hereya env [NAME]`
145
145
 
@@ -170,7 +170,7 @@ EXAMPLES
170
170
  $ hereya env -w dev -l
171
171
  ```
172
172
 
173
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/env/index.ts)_
173
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/env/index.ts)_
174
174
 
175
175
  ## `hereya help [COMMAND]`
176
176
 
@@ -216,7 +216,7 @@ EXAMPLES
216
216
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
217
217
  ```
218
218
 
219
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/init/index.ts)_
219
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/init/index.ts)_
220
220
 
221
221
  ## `hereya remote exec [PKGPATH]`
222
222
 
@@ -240,7 +240,7 @@ EXAMPLES
240
240
  $ hereya remote exec
241
241
  ```
242
242
 
243
- _See code: [src/commands/remote/exec/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/remote/exec/index.ts)_
243
+ _See code: [src/commands/remote/exec/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/remote/exec/index.ts)_
244
244
 
245
245
  ## `hereya remove PACKAGE`
246
246
 
@@ -263,7 +263,7 @@ EXAMPLES
263
263
  $ hereya remove cloudy/docker_postgres
264
264
  ```
265
265
 
266
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/remove/index.ts)_
266
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/remove/index.ts)_
267
267
 
268
268
  ## `hereya run CMD`
269
269
 
@@ -289,7 +289,7 @@ EXAMPLES
289
289
  $ hereya run -w uat -- node index.js
290
290
  ```
291
291
 
292
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/run/index.ts)_
292
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/run/index.ts)_
293
293
 
294
294
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
295
295
 
@@ -314,7 +314,7 @@ EXAMPLES
314
314
  $ hereya unbootstrap local
315
315
  ```
316
316
 
317
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/unbootstrap/index.ts)_
317
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/unbootstrap/index.ts)_
318
318
 
319
319
  ## `hereya undeploy`
320
320
 
@@ -335,7 +335,7 @@ EXAMPLES
335
335
  $ hereya undeploy
336
336
  ```
337
337
 
338
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/undeploy/index.ts)_
338
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/undeploy/index.ts)_
339
339
 
340
340
  ## `hereya up`
341
341
 
@@ -357,7 +357,7 @@ EXAMPLES
357
357
  $ hereya up
358
358
  ```
359
359
 
360
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/up/index.ts)_
360
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/up/index.ts)_
361
361
 
362
362
  ## `hereya workspace create NAME`
363
363
 
@@ -377,7 +377,7 @@ EXAMPLES
377
377
  $ hereya workspace create dev
378
378
  ```
379
379
 
380
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/workspace/create/index.ts)_
380
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/workspace/create/index.ts)_
381
381
 
382
382
  ## `hereya workspace delete NAME`
383
383
 
@@ -397,7 +397,7 @@ EXAMPLES
397
397
  $ hereya workspace delete dev
398
398
  ```
399
399
 
400
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/workspace/delete/index.ts)_
400
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/workspace/delete/index.ts)_
401
401
 
402
402
  ## `hereya workspace env [NAME]`
403
403
 
@@ -423,7 +423,7 @@ EXAMPLES
423
423
  $ hereya workspace env myEnv -w dev
424
424
  ```
425
425
 
426
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/workspace/env/index.ts)_
426
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/workspace/env/index.ts)_
427
427
 
428
428
  ## `hereya workspace install PACKAGE`
429
429
 
@@ -449,7 +449,7 @@ EXAMPLES
449
449
  $ hereya workspace install hereya/aws-cognito
450
450
  ```
451
451
 
452
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/workspace/install/index.ts)_
452
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/workspace/install/index.ts)_
453
453
 
454
454
  ## `hereya workspace uninstall PACKAGE`
455
455
 
@@ -475,5 +475,5 @@ EXAMPLES
475
475
  $ hereya workspace uninstall hereya/aws-cognito
476
476
  ```
477
477
 
478
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.5/src/commands/workspace/uninstall/index.ts)_
478
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.7/src/commands/workspace/uninstall/index.ts)_
479
479
  <!-- commandsstop -->
@@ -2,7 +2,7 @@ import { Args, Command, Flags } from '@oclif/core';
2
2
  import path from 'node:path';
3
3
  import { getIac } from '../../../iac/index.js';
4
4
  import { getInfrastructure } from '../../../infrastructure/index.js';
5
- import { base64ToJSONString } from '../../../lib/object-utils.js';
5
+ import { base64ToJSONString, tryBase64ToJSONString } from '../../../lib/object-utils.js';
6
6
  import { save } from '../../../lib/yaml-utils.js';
7
7
  export default class RemoteExec extends Command {
8
8
  static args = {
@@ -31,11 +31,13 @@ export default class RemoteExec extends Command {
31
31
  const { args, flags } = await this.parse(RemoteExec);
32
32
  const workspaceEnv = Object.fromEntries((process.env.HEREYA_WORKSPACE_ENV?.split(',') ?? [])
33
33
  .filter(param => param.trim())
34
- .map(param => param.split('=')));
34
+ .map(param => param.split('='))
35
+ .map(([key, value]) => [key, tryBase64ToJSONString(value)]));
35
36
  const parameters = Object.fromEntries((process.env.HEREYA_PARAMETERS?.split(',') ?? [])
36
37
  .filter(param => param.trim())
37
- .map(param => param.split('=')));
38
- parameters.hereyaProjectEnv = parameters.hereyaProjectEnv ? base64ToJSONString(parameters.hereyaProjectEnv) : undefined;
38
+ .map(param => param.split('='))
39
+ .map(([key, value]) => [key, tryBase64ToJSONString(value)]));
40
+ parameters.hereyaProjectEnv = parameters.hereyaProjectEnv ? base64ToJSONString(parameters.hereyaProjectEnv) : '';
39
41
  const id = process.env.HEREYA_ID;
40
42
  const iacType = process.env.HEREYA_IAC_TYPE;
41
43
  const destroy = process.env.HEREYA_DESTROY === 'true';
@@ -13,17 +13,17 @@ export class Terraform {
13
13
  runShell(terraform, ['init'], {
14
14
  directory: input.pkgPath,
15
15
  env: {
16
- ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, value]),
16
+ ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value]),
17
17
  ...input.env,
18
- ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, value])
18
+ ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value])
19
19
  }
20
20
  });
21
21
  runShell(terraform, ['apply', '-auto-approve'], {
22
22
  directory: input.pkgPath,
23
23
  env: {
24
- ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, value]),
24
+ ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value]),
25
25
  ...input.env,
26
- ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, value])
26
+ ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value])
27
27
  }
28
28
  });
29
29
  const env = await this.getEnv(input.pkgPath);
@@ -45,18 +45,18 @@ export class Terraform {
45
45
  runShell(terraform, ['init'], {
46
46
  directory: input.pkgPath,
47
47
  env: {
48
- ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, value]),
48
+ ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value]),
49
49
  ...input.env,
50
- ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, value])
50
+ ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value])
51
51
  }
52
52
  });
53
53
  const env = await this.getEnv(input.pkgPath);
54
54
  runShell(terraform, ['destroy', '-auto-approve'], {
55
55
  directory: input.pkgPath,
56
56
  env: {
57
- ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, value]),
57
+ ...mapObject(input.env ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value]),
58
58
  ...input.env,
59
- ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, value])
59
+ ...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, typeof value === "object" ? JSON.stringify(value) : value])
60
60
  }
61
61
  });
62
62
  return {
@@ -244,7 +244,7 @@ export class AwsInfrastructure {
244
244
  }
245
245
  const ssmClient = new SSMClient({});
246
246
  const parameterName = `/hereya/package-parameters/${input.id}`;
247
- const parameterValue = Object.entries(input.parameters ?? {}).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join(',');
247
+ const parameterValue = Object.entries(input.parameters ?? {}).map(([key, value]) => `${key}=${typeof value === "object" ? objectToBase64(value) : value}`).join(',');
248
248
  if (parameterValue) {
249
249
  await ssmClient.send(new PutParameterCommand({
250
250
  Name: parameterName,
@@ -278,7 +278,7 @@ export class AwsInfrastructure {
278
278
  {
279
279
  name: 'HEREYA_WORKSPACE_ENV',
280
280
  type: 'PLAINTEXT',
281
- value: Object.entries(input.env ?? {}).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join(','),
281
+ value: Object.entries(input.env ?? {}).map(([key, value]) => `${key}=${typeof value === "object" ? objectToBase64(value) : value}`).join(','),
282
282
  },
283
283
  {
284
284
  name: 'PKG_REPO_URL',
@@ -4,3 +4,4 @@ export declare function arrayOfStringToObject(arr: string[], keyValueSeparator?:
4
4
  };
5
5
  export declare function objectToBase64(obj: object): string;
6
6
  export declare function base64ToJSONString(base64: string): string;
7
+ export declare function tryBase64ToJSONString(base64: string): string;
@@ -13,3 +13,15 @@ export function objectToBase64(obj) {
13
13
  export function base64ToJSONString(base64) {
14
14
  return Buffer.from(base64, 'base64').toString('utf8');
15
15
  }
16
+ export function tryBase64ToJSONString(base64) {
17
+ try {
18
+ const value = base64ToJSONString(base64);
19
+ if (typeof JSON.parse(value) === 'object') {
20
+ return value;
21
+ }
22
+ return base64;
23
+ }
24
+ catch {
25
+ return base64;
26
+ }
27
+ }
@@ -783,5 +783,5 @@
783
783
  ]
784
784
  }
785
785
  },
786
- "version": "0.8.5"
786
+ "version": "0.8.7"
787
787
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.8.5",
4
+ "version": "0.8.7",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"