hereya-cli 0.24.0 → 0.25.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.24.0 linux-x64 node-v22.14.0
23
+ hereya-cli/0.25.0 linux-x64 node-v22.14.0
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -82,7 +82,7 @@ EXAMPLES
82
82
  $ hereya add cloudy/docker_postgres
83
83
  ```
84
84
 
85
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/add/index.ts)_
85
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/add/index.ts)_
86
86
 
87
87
  ## `hereya bootstrap INFRASTRUCTURETYPE`
88
88
 
@@ -107,7 +107,7 @@ EXAMPLES
107
107
  $ hereya bootstrap local
108
108
  ```
109
109
 
110
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/bootstrap/index.ts)_
110
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/bootstrap/index.ts)_
111
111
 
112
112
  ## `hereya deploy`
113
113
 
@@ -132,7 +132,7 @@ EXAMPLES
132
132
  $ hereya deploy
133
133
  ```
134
134
 
135
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/deploy/index.ts)_
135
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/deploy/index.ts)_
136
136
 
137
137
  ## `hereya down`
138
138
 
@@ -158,7 +158,7 @@ EXAMPLES
158
158
  $ hereya down
159
159
  ```
160
160
 
161
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/down/index.ts)_
161
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/down/index.ts)_
162
162
 
163
163
  ## `hereya env [NAME]`
164
164
 
@@ -189,7 +189,7 @@ EXAMPLES
189
189
  $ hereya env -w dev -l
190
190
  ```
191
191
 
192
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/env/index.ts)_
192
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/env/index.ts)_
193
193
 
194
194
  ## `hereya env set [NAME]`
195
195
 
@@ -216,7 +216,7 @@ EXAMPLES
216
216
  $ hereya env set FOO -v bar -w dev
217
217
  ```
218
218
 
219
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/env/set/index.ts)_
219
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/env/set/index.ts)_
220
220
 
221
221
  ## `hereya help [COMMAND]`
222
222
 
@@ -262,7 +262,7 @@ EXAMPLES
262
262
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
263
263
  ```
264
264
 
265
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/init/index.ts)_
265
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/init/index.ts)_
266
266
 
267
267
  ## `hereya remove PACKAGE`
268
268
 
@@ -289,7 +289,7 @@ EXAMPLES
289
289
  $ hereya remove cloudy/docker_postgres
290
290
  ```
291
291
 
292
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/remove/index.ts)_
292
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/remove/index.ts)_
293
293
 
294
294
  ## `hereya run CMD`
295
295
 
@@ -315,7 +315,7 @@ EXAMPLES
315
315
  $ hereya run -w uat -- node index.js
316
316
  ```
317
317
 
318
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/run/index.ts)_
318
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/run/index.ts)_
319
319
 
320
320
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
321
321
 
@@ -340,7 +340,7 @@ EXAMPLES
340
340
  $ hereya unbootstrap local
341
341
  ```
342
342
 
343
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/unbootstrap/index.ts)_
343
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/unbootstrap/index.ts)_
344
344
 
345
345
  ## `hereya undeploy`
346
346
 
@@ -365,7 +365,7 @@ EXAMPLES
365
365
  $ hereya undeploy
366
366
  ```
367
367
 
368
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/undeploy/index.ts)_
368
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/undeploy/index.ts)_
369
369
 
370
370
  ## `hereya up`
371
371
 
@@ -391,7 +391,7 @@ EXAMPLES
391
391
  $ hereya up
392
392
  ```
393
393
 
394
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/up/index.ts)_
394
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/up/index.ts)_
395
395
 
396
396
  ## `hereya workspace create NAME`
397
397
 
@@ -414,7 +414,7 @@ EXAMPLES
414
414
  $ hereya workspace create dev
415
415
  ```
416
416
 
417
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/create/index.ts)_
417
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/create/index.ts)_
418
418
 
419
419
  ## `hereya workspace delete NAME`
420
420
 
@@ -434,7 +434,7 @@ EXAMPLES
434
434
  $ hereya workspace delete dev
435
435
  ```
436
436
 
437
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/delete/index.ts)_
437
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/delete/index.ts)_
438
438
 
439
439
  ## `hereya workspace env [NAME]`
440
440
 
@@ -460,7 +460,7 @@ EXAMPLES
460
460
  $ hereya workspace env myEnv -w dev
461
461
  ```
462
462
 
463
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/env/index.ts)_
463
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/env/index.ts)_
464
464
 
465
465
  ## `hereya workspace env set`
466
466
 
@@ -484,7 +484,7 @@ EXAMPLES
484
484
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
485
485
  ```
486
486
 
487
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/env/set/index.ts)_
487
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/env/set/index.ts)_
488
488
 
489
489
  ## `hereya workspace env unset`
490
490
 
@@ -505,7 +505,7 @@ EXAMPLES
505
505
  $ hereya workspace env unset -w my-workspace -n myVar
506
506
  ```
507
507
 
508
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/env/unset/index.ts)_
508
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/env/unset/index.ts)_
509
509
 
510
510
  ## `hereya workspace install PACKAGE`
511
511
 
@@ -532,7 +532,7 @@ EXAMPLES
532
532
  $ hereya workspace install hereya/aws-cognito
533
533
  ```
534
534
 
535
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/install/index.ts)_
535
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/install/index.ts)_
536
536
 
537
537
  ## `hereya workspace list`
538
538
 
@@ -549,7 +549,7 @@ EXAMPLES
549
549
  $ hereya workspace list
550
550
  ```
551
551
 
552
- _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/list/index.ts)_
552
+ _See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/list/index.ts)_
553
553
 
554
554
  ## `hereya workspace uninstall PACKAGE`
555
555
 
@@ -576,5 +576,5 @@ EXAMPLES
576
576
  $ hereya workspace uninstall hereya/aws-cognito
577
577
  ```
578
578
 
579
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.24.0/src/commands/workspace/uninstall/index.ts)_
579
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.25.0/src/commands/workspace/uninstall/index.ts)_
580
580
  <!-- commandsstop -->
@@ -1,6 +1,7 @@
1
1
  import { Args, Command, Flags } from '@oclif/core';
2
2
  import path from 'node:path';
3
3
  import { getConfigManager } from '../../../lib/config/index.js';
4
+ import { getEnvManager } from '../../../lib/env/index.js';
4
5
  import { getAnyPath } from '../../../lib/filesystem.js';
5
6
  import { load, save } from '../../../lib/yaml-utils.js';
6
7
  export default class EnvSet extends Command {
@@ -40,13 +41,11 @@ export default class EnvSet extends Command {
40
41
  this.warn(`Project not initialized. Run 'hereya init' first.`);
41
42
  return;
42
43
  }
43
- const rootDir = projectRootDir ?? process.cwd();
44
+ const envManager = getEnvManager();
45
+ const envDir = await envManager.getStaticEnvDir(projectRootDir);
44
46
  const candidates = flags.workspace
45
- ? [
46
- path.join(rootDir, 'hereyastaticenv', `env.${flags.workspace}.yaml`),
47
- path.join(rootDir, 'hereyastaticenv', `env.${flags.workspace}.yml`),
48
- ]
49
- : [path.join(rootDir, 'hereyastaticenv', `env.yaml`), path.join(rootDir, 'hereyastaticenv', `env.yml`)];
47
+ ? [path.join(envDir, `env.${flags.workspace}.yaml`), path.join(envDir, `env.${flags.workspace}.yml`)]
48
+ : [path.join(envDir, `env.yaml`), path.join(envDir, `env.yml`)];
50
49
  const envFile = await getAnyPath(...candidates);
51
50
  const { data: env } = await load(envFile);
52
51
  env[args.name] = flags.value;
@@ -2,6 +2,7 @@ import { InfrastructureType } from '../../infrastructure/common.js';
2
2
  export declare class EnvManager {
3
3
  addProjectEnv(input: AddEnvInput): Promise<void>;
4
4
  getProjectEnv(input: GetProjectEnvInput): Promise<GetProjectEnvOutput>;
5
+ getStaticEnvDir(projectRootDir?: string): Promise<string>;
5
6
  removeProjectEnv(input: RemoveEnvInput): Promise<void>;
6
7
  private getEnvPath;
7
8
  private getUserEnvPaths;
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import { getExecutor } from '../../executor/index.js';
3
- import { getAnyPath } from '../filesystem.js';
3
+ import { getAnyPath, migrateFiles } from '../filesystem.js';
4
4
  import { load, save } from '../yaml-utils.js';
5
5
  export class EnvManager {
6
6
  async addProjectEnv(input) {
@@ -33,6 +33,12 @@ export class EnvManager {
33
33
  const finalEnv = { ...resolvedEnv, ...userMergedEnv };
34
34
  return { env: finalEnv, success: true };
35
35
  }
36
+ async getStaticEnvDir(projectRootDir) {
37
+ const sourceDir = path.join(projectRootDir ?? process.cwd(), 'hereyastaticenv');
38
+ const targetDir = path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyastaticenv');
39
+ await migrateFiles(sourceDir, targetDir);
40
+ return targetDir;
41
+ }
36
42
  async removeProjectEnv(input) {
37
43
  const envPath = await this.getEnvPath(input);
38
44
  const { data: existingEnv, found } = await load(envPath);
@@ -48,8 +54,8 @@ export class EnvManager {
48
54
  }
49
55
  async getUserEnvPaths(input) {
50
56
  const paths = await Promise.all([
51
- getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.yaml`), path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.yml`)),
52
- getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.${input.workspace}.yaml`), path.join(input.projectRootDir ?? process.cwd(), 'hereyastaticenv', `env.${input.workspace}.yml`)),
57
+ getAnyPath(path.join(await this.getStaticEnvDir(input.projectRootDir), `env.yaml`), path.join(await this.getStaticEnvDir(input.projectRootDir), `env.yml`)),
58
+ getAnyPath(path.join(await this.getStaticEnvDir(input.projectRootDir), `env.${input.workspace}.yaml`), path.join(await this.getStaticEnvDir(input.projectRootDir), `env.${input.workspace}.yml`)),
53
59
  ]);
54
60
  return paths;
55
61
  }
@@ -1,3 +1,4 @@
1
1
  export declare function getAnyPath(...candidates: string[]): Promise<string>;
2
2
  export declare function fileExists(filePath: string): Promise<boolean>;
3
3
  export declare function isNotEmpty(directoryPath: string): Promise<boolean>;
4
+ export declare function migrateFiles(sourceDir: string, targetDir: string): Promise<void>;
@@ -1,4 +1,5 @@
1
- import { access, constants, readdir } from 'node:fs/promises';
1
+ import fs, { access, constants, readdir } from 'node:fs/promises';
2
+ import path from 'node:path';
2
3
  export async function getAnyPath(...candidates) {
3
4
  const checkAccess = async (index) => {
4
5
  if (index >= candidates.length)
@@ -31,3 +32,27 @@ export async function isNotEmpty(directoryPath) {
31
32
  return false;
32
33
  }
33
34
  }
35
+ export async function migrateFiles(sourceDir, targetDir) {
36
+ const sourceDirExists = await fs
37
+ .access(sourceDir)
38
+ .then(() => true)
39
+ .catch(() => false);
40
+ if (!sourceDirExists) {
41
+ return;
42
+ }
43
+ const targetDirExists = await fs
44
+ .access(targetDir)
45
+ .then(() => true)
46
+ .catch(() => false);
47
+ if (targetDirExists) {
48
+ return;
49
+ }
50
+ await fs.mkdir(targetDir, { recursive: true });
51
+ const files = await fs.readdir(sourceDir);
52
+ await Promise.all(files.map(async (file) => {
53
+ const sourcePath = path.join(sourceDir, file);
54
+ const targetPath = path.join(targetDir, file);
55
+ await fs.rename(sourcePath, targetPath);
56
+ }));
57
+ await fs.rmdir(sourceDir);
58
+ }
@@ -1,6 +1,7 @@
1
1
  export declare class ParameterManager {
2
2
  getPackageParameters(input: GetPackageParametersInput): Promise<GetPackageParametersOutput>;
3
3
  savePackageParameters(input: SavePackageParametersInput): Promise<SavePackageParametersOutput>;
4
+ private getParametersFolder;
4
5
  }
5
6
  export declare const parameterManager: ParameterManager;
6
7
  export declare function getParameterManager(): ParameterManager;
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { getAnyPath } from '../filesystem.js';
2
+ import { getAnyPath, migrateFiles } from '../filesystem.js';
3
3
  import { getPackageCanonicalName } from '../package/index.js';
4
4
  import { load, save } from '../yaml-utils.js';
5
5
  export class ParameterManager {
@@ -9,7 +9,7 @@ export class ParameterManager {
9
9
  [`${pkgName}.yaml`, `${pkgName}.yml`],
10
10
  [`${pkgName}.${input.workspace}.yaml`, `${pkgName}.${input.workspace}.yml`],
11
11
  ].map(async ([filename, altFilename]) => {
12
- const filePath = await getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyavars', filename), path.join(input.projectRootDir ?? process.cwd(), 'hereyavars', altFilename));
12
+ const filePath = await getAnyPath(path.join(await this.getParametersFolder(input.projectRootDir), filename), path.join(await this.getParametersFolder(input.projectRootDir), altFilename));
13
13
  const { data: parameters } = await load(filePath);
14
14
  return parameters;
15
15
  }));
@@ -29,7 +29,7 @@ export class ParameterManager {
29
29
  [`${pkgName}.yaml`, `${pkgName}.yml`],
30
30
  [`${pkgName}.${input.workspace}.yaml`, `${pkgName}.${input.workspace}.yml`],
31
31
  ].map(async ([filename, altFilename]) => {
32
- const filePath = await getAnyPath(path.join(input.projectRootDir ?? process.cwd(), 'hereyavars', filename), path.join(input.projectRootDir ?? process.cwd(), 'hereyavars', altFilename));
32
+ const filePath = await getAnyPath(path.join(await this.getParametersFolder(input.projectRootDir), filename), path.join(await this.getParametersFolder(input.projectRootDir), altFilename));
33
33
  const { found } = await load(filePath);
34
34
  return found;
35
35
  }));
@@ -39,13 +39,19 @@ export class ParameterManager {
39
39
  saved: false,
40
40
  };
41
41
  }
42
- const filePath = path.join(input.projectRootDir ?? process.cwd(), 'hereyavars', `${pkgName}.yaml`);
42
+ const filePath = path.join(await this.getParametersFolder(input.projectRootDir), `${pkgName}.yaml`);
43
43
  await save(input.parameters, filePath);
44
44
  return {
45
45
  filePath,
46
46
  saved: true,
47
47
  };
48
48
  }
49
+ async getParametersFolder(projectRootDir) {
50
+ const sourceDir = path.join(projectRootDir ?? process.cwd(), 'hereyavars');
51
+ const targetDir = path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyavars');
52
+ await migrateFiles(sourceDir, targetDir);
53
+ return targetDir;
54
+ }
49
55
  }
50
56
  export const parameterManager = new ParameterManager();
51
57
  export function getParameterManager() {
@@ -988,5 +988,5 @@
988
988
  ]
989
989
  }
990
990
  },
991
- "version": "0.24.0"
991
+ "version": "0.25.0"
992
992
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.24.0",
4
+ "version": "0.25.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"