hereya-cli 0.17.2 → 0.18.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.17.2 linux-x64 node-v22.13.1
23
+ hereya-cli/0.18.0 linux-x64 node-v22.13.1
24
24
  $ hereya --help [COMMAND]
25
25
  USAGE
26
26
  $ hereya COMMAND
@@ -74,7 +74,7 @@ EXAMPLES
74
74
  $ hereya add cloudy/docker_postgres
75
75
  ```
76
76
 
77
- _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/add/index.ts)_
77
+ _See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/add/index.ts)_
78
78
 
79
79
  ## `hereya bootstrap INFRASTRUCTURETYPE`
80
80
 
@@ -99,7 +99,7 @@ EXAMPLES
99
99
  $ hereya bootstrap local
100
100
  ```
101
101
 
102
- _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/bootstrap/index.ts)_
102
+ _See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/bootstrap/index.ts)_
103
103
 
104
104
  ## `hereya deploy`
105
105
 
@@ -121,7 +121,7 @@ EXAMPLES
121
121
  $ hereya deploy
122
122
  ```
123
123
 
124
- _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/deploy/index.ts)_
124
+ _See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/deploy/index.ts)_
125
125
 
126
126
  ## `hereya down`
127
127
 
@@ -144,7 +144,7 @@ EXAMPLES
144
144
  $ hereya down
145
145
  ```
146
146
 
147
- _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/down/index.ts)_
147
+ _See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/down/index.ts)_
148
148
 
149
149
  ## `hereya env [NAME]`
150
150
 
@@ -175,7 +175,7 @@ EXAMPLES
175
175
  $ hereya env -w dev -l
176
176
  ```
177
177
 
178
- _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/env/index.ts)_
178
+ _See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/env/index.ts)_
179
179
 
180
180
  ## `hereya env set [NAME]`
181
181
 
@@ -202,7 +202,7 @@ EXAMPLES
202
202
  $ hereya env set FOO -v bar -w dev
203
203
  ```
204
204
 
205
- _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/env/set/index.ts)_
205
+ _See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/env/set/index.ts)_
206
206
 
207
207
  ## `hereya help [COMMAND]`
208
208
 
@@ -248,7 +248,7 @@ EXAMPLES
248
248
  $ hereya init myProject -w=defaultWorkspace --chdir=./myProject
249
249
  ```
250
250
 
251
- _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/init/index.ts)_
251
+ _See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/init/index.ts)_
252
252
 
253
253
  ## `hereya remove PACKAGE`
254
254
 
@@ -272,7 +272,7 @@ EXAMPLES
272
272
  $ hereya remove cloudy/docker_postgres
273
273
  ```
274
274
 
275
- _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/remove/index.ts)_
275
+ _See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/remove/index.ts)_
276
276
 
277
277
  ## `hereya run CMD`
278
278
 
@@ -298,7 +298,7 @@ EXAMPLES
298
298
  $ hereya run -w uat -- node index.js
299
299
  ```
300
300
 
301
- _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/run/index.ts)_
301
+ _See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/run/index.ts)_
302
302
 
303
303
  ## `hereya unbootstrap INFRASTRUCTURETYPE`
304
304
 
@@ -323,7 +323,7 @@ EXAMPLES
323
323
  $ hereya unbootstrap local
324
324
  ```
325
325
 
326
- _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/unbootstrap/index.ts)_
326
+ _See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/unbootstrap/index.ts)_
327
327
 
328
328
  ## `hereya undeploy`
329
329
 
@@ -345,7 +345,7 @@ EXAMPLES
345
345
  $ hereya undeploy
346
346
  ```
347
347
 
348
- _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/undeploy/index.ts)_
348
+ _See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/undeploy/index.ts)_
349
349
 
350
350
  ## `hereya up`
351
351
 
@@ -368,7 +368,7 @@ EXAMPLES
368
368
  $ hereya up
369
369
  ```
370
370
 
371
- _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/up/index.ts)_
371
+ _See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/up/index.ts)_
372
372
 
373
373
  ## `hereya workspace create NAME`
374
374
 
@@ -388,7 +388,7 @@ EXAMPLES
388
388
  $ hereya workspace create dev
389
389
  ```
390
390
 
391
- _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/create/index.ts)_
391
+ _See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/create/index.ts)_
392
392
 
393
393
  ## `hereya workspace delete NAME`
394
394
 
@@ -408,7 +408,7 @@ EXAMPLES
408
408
  $ hereya workspace delete dev
409
409
  ```
410
410
 
411
- _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/delete/index.ts)_
411
+ _See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/delete/index.ts)_
412
412
 
413
413
  ## `hereya workspace env [NAME]`
414
414
 
@@ -434,7 +434,7 @@ EXAMPLES
434
434
  $ hereya workspace env myEnv -w dev
435
435
  ```
436
436
 
437
- _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/env/index.ts)_
437
+ _See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/env/index.ts)_
438
438
 
439
439
  ## `hereya workspace env set`
440
440
 
@@ -458,7 +458,7 @@ EXAMPLES
458
458
  $ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
459
459
  ```
460
460
 
461
- _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/env/set/index.ts)_
461
+ _See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/env/set/index.ts)_
462
462
 
463
463
  ## `hereya workspace env unset`
464
464
 
@@ -479,7 +479,7 @@ EXAMPLES
479
479
  $ hereya workspace env unset -w my-workspace -n myVar
480
480
  ```
481
481
 
482
- _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/env/unset/index.ts)_
482
+ _See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/env/unset/index.ts)_
483
483
 
484
484
  ## `hereya workspace install PACKAGE`
485
485
 
@@ -506,7 +506,7 @@ EXAMPLES
506
506
  $ hereya workspace install hereya/aws-cognito
507
507
  ```
508
508
 
509
- _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/install/index.ts)_
509
+ _See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/install/index.ts)_
510
510
 
511
511
  ## `hereya workspace uninstall PACKAGE`
512
512
 
@@ -533,5 +533,5 @@ EXAMPLES
533
533
  $ hereya workspace uninstall hereya/aws-cognito
534
534
  ```
535
535
 
536
- _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.17.2/src/commands/workspace/uninstall/index.ts)_
536
+ _See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.18.0/src/commands/workspace/uninstall/index.ts)_
537
537
  <!-- commandsstop -->
@@ -87,31 +87,30 @@ export default class Down extends Command {
87
87
  {
88
88
  skip: (ctx) => !ctx.packages || ctx.packages.length === 0,
89
89
  async task(ctx) {
90
- const { configOutput, destroyed, packages, workspace, workspaceEnvOutput } = ctx;
91
- if (!packages || packages.length === 0) {
90
+ if (!ctx.packages || ctx.packages.length === 0) {
92
91
  return;
93
92
  }
94
- return task.newListr(packages.map((packageName) => ({
93
+ return task.newListr(ctx.packages.map((packageName) => ({
95
94
  async task() {
96
95
  const parameterManager = getParameterManager();
97
96
  const { parameters } = await parameterManager.getPackageParameters({
98
97
  package: packageName,
99
98
  projectRootDir,
100
- workspace,
99
+ workspace: ctx.workspace,
101
100
  });
102
101
  const destroyOutput = await destroyPackage({
103
- env: workspaceEnvOutput.env,
102
+ env: ctx.workspaceEnvOutput.env,
104
103
  isDeploying: flags.deploy,
105
104
  package: packageName,
106
105
  parameters,
107
- project: configOutput.config.project,
108
- workspace,
106
+ project: ctx.configOutput.config.project,
107
+ workspace: ctx.workspace,
109
108
  });
110
109
  if (!destroyOutput.success) {
111
110
  throw new Error(destroyOutput.reason);
112
111
  }
113
112
  const { env, metadata } = destroyOutput;
114
- const output = destroyed || [];
113
+ const output = ctx.destroyed || [];
115
114
  output.push({ env, metadata, packageName });
116
115
  ctx.destroyed = output;
117
116
  },
@@ -1,5 +1,7 @@
1
1
  import type { GetRepoContentInput, GetRepoContentOutput, PackageManager } from './common.js';
2
2
  export declare class GitHubPackageManager implements PackageManager {
3
+ private readonly registryUrl;
4
+ constructor(registryUrl?: string);
3
5
  downloadPackage(pkgUrl: string, destPath: string): Promise<string>;
4
6
  getRepoContent({ owner, path: filePath, repo }: GetRepoContentInput): Promise<GetRepoContentOutput>;
5
7
  }
@@ -11,6 +11,10 @@ import { simpleGit } from 'simple-git';
11
11
  import { BackOffPolicy, Retryable } from 'typescript-retry-decorator';
12
12
  import { isNotEmpty } from '../filesystem.js';
13
13
  export class GitHubPackageManager {
14
+ registryUrl;
15
+ constructor(registryUrl = process.env.HEREYA_REGISTRY_URL || 'https://github.com') {
16
+ this.registryUrl = registryUrl;
17
+ }
14
18
  // eslint-disable-next-line new-cap
15
19
  async downloadPackage(pkgUrl, destPath) {
16
20
  if (await isNotEmpty(destPath)) {
@@ -24,7 +28,7 @@ export class GitHubPackageManager {
24
28
  return destPath;
25
29
  }
26
30
  async getRepoContent({ owner, path: filePath, repo }) {
27
- const pkgUrl = `https://github.com/${owner}/${repo}`;
31
+ const pkgUrl = `${this.registryUrl}/${owner}/${repo}`;
28
32
  const tmpFolder = path.join(os.tmpdir(), 'hereya', 'github', owner, repo);
29
33
  try {
30
34
  const destPath = await this.downloadPackage(pkgUrl, tmpFolder);
@@ -2,8 +2,10 @@ import { z } from 'zod';
2
2
  import { IacType } from '../../iac/common.js';
3
3
  import { InfrastructureType } from '../../infrastructure/common.js';
4
4
  import { PackageManager } from './common.js';
5
+ import { LocalPackageManager } from './local.js';
5
6
  export declare const packageManager: PackageManager;
6
- export declare function getPackageManager(): PackageManager;
7
+ export declare const localPackageManager: LocalPackageManager;
8
+ export declare function getPackageManager(protocol: string): PackageManager;
7
9
  export declare function resolvePackage(input: ResolvePackageInput): Promise<ResolvePackageOutput>;
8
10
  export declare function getPackageCanonicalName(packageName: string): string;
9
11
  export declare function downloadPackage(pkgUrl: string, destPath: string): Promise<string>;
@@ -3,17 +3,31 @@ import { z } from 'zod';
3
3
  import { IacType } from '../../iac/common.js';
4
4
  import { InfrastructureType } from '../../infrastructure/common.js';
5
5
  import { GitHubPackageManager } from './github.js';
6
+ import { LocalPackageManager } from './local.js';
6
7
  export const packageManager = new GitHubPackageManager();
7
- export function getPackageManager() {
8
+ export const localPackageManager = new LocalPackageManager();
9
+ export function getPackageManager(protocol) {
10
+ if (protocol === 'local') {
11
+ return localPackageManager;
12
+ }
8
13
  return packageManager;
9
14
  }
10
15
  export async function resolvePackage(input) {
11
- const pkgParts = input.package.split('/');
12
- if (pkgParts.length !== 2) {
13
- return { found: false, reason: 'Invalid package format. Use owner/repository' };
16
+ const isLocal = input.package.startsWith('local://');
17
+ let [owner, repo] = ['', ''];
18
+ if (isLocal) {
19
+ ;
20
+ [owner, repo] = input.package.split('://');
21
+ }
22
+ else {
23
+ const pkgParts = input.package.split('/');
24
+ if (pkgParts.length !== 2) {
25
+ return { found: false, reason: 'Invalid package format. Use owner/repository' };
26
+ }
27
+ ;
28
+ [owner, repo] = pkgParts;
14
29
  }
15
- const [owner, repo] = pkgParts;
16
- const packageManager = getPackageManager();
30
+ const packageManager = getPackageManager(isLocal ? 'local' : '');
17
31
  const metadataContentCandidates = (await Promise.all([
18
32
  packageManager.getRepoContent({ owner, path: 'hereyarc.yaml', repo }),
19
33
  packageManager.getRepoContent({ owner, path: 'hereyarc.yml', repo }),
@@ -43,10 +57,14 @@ export async function resolvePackage(input) {
43
57
  }
44
58
  }
45
59
  export function getPackageCanonicalName(packageName) {
60
+ const isLocal = packageName.startsWith('local://');
61
+ if (isLocal) {
62
+ return packageName.replace('local://', 'local--').replace('/', '-');
63
+ }
46
64
  return packageName.replace('/', '-');
47
65
  }
48
66
  export async function downloadPackage(pkgUrl, destPath) {
49
- const packageManager = getPackageManager();
67
+ const packageManager = getPackageManager(pkgUrl.startsWith('local://') ? 'local' : '');
50
68
  return packageManager.downloadPackage(pkgUrl, destPath);
51
69
  }
52
70
  export const PackageMetadata = z.object({
@@ -0,0 +1,5 @@
1
+ import { GetRepoContentInput, GetRepoContentOutput, PackageManager } from './common.js';
2
+ export declare class LocalPackageManager implements PackageManager {
3
+ downloadPackage(pkgUrl: string, destPath: string): Promise<string>;
4
+ getRepoContent({ path: filePath, repo }: GetRepoContentInput): Promise<GetRepoContentOutput>;
5
+ }
@@ -0,0 +1,32 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ export class LocalPackageManager {
4
+ async downloadPackage(pkgUrl, destPath) {
5
+ const [, source] = pkgUrl.split('://');
6
+ await fs.cp(source, destPath, { recursive: true });
7
+ return destPath;
8
+ }
9
+ async getRepoContent({ path: filePath, repo }) {
10
+ try {
11
+ const resolvedPath = path.join(repo, filePath);
12
+ if (await fs.stat(resolvedPath)) {
13
+ const content = await fs.readFile(resolvedPath, 'utf8');
14
+ return {
15
+ content,
16
+ found: true,
17
+ pkgUrl: `local://${repo}`,
18
+ };
19
+ }
20
+ return {
21
+ found: false,
22
+ reason: `File ${filePath} not found in ${repo}`,
23
+ };
24
+ }
25
+ catch (error) {
26
+ return {
27
+ found: false,
28
+ reason: error.message,
29
+ };
30
+ }
31
+ }
32
+ }
@@ -304,18 +304,19 @@
304
304
  "index.js"
305
305
  ]
306
306
  },
307
- "remove": {
307
+ "run": {
308
308
  "aliases": [],
309
309
  "args": {
310
- "package": {
311
- "description": "The package to remove. Packages are gitHub repositories. Use the format owner/repository",
312
- "name": "package",
310
+ "cmd": {
311
+ "description": "command to run",
312
+ "name": "cmd",
313
313
  "required": true
314
314
  }
315
315
  },
316
- "description": "Remove a package from the project.",
316
+ "description": "Run a command with hereya env vars.",
317
317
  "examples": [
318
- "<%= config.bin %> <%= command.id %> cloudy/docker_postgres"
318
+ "<%= config.bin %> <%= command.id %> -- npm run dev",
319
+ "<%= config.bin %> <%= command.id %> -w uat -- node index.js"
319
320
  ],
320
321
  "flags": {
321
322
  "chdir": {
@@ -326,42 +327,44 @@
326
327
  "multiple": false,
327
328
  "type": "option"
328
329
  },
329
- "debug": {
330
- "description": "enable debug mode",
331
- "name": "debug",
332
- "allowNo": false,
333
- "type": "boolean"
330
+ "workspace": {
331
+ "char": "w",
332
+ "description": "name of the workspace to run the command in",
333
+ "name": "workspace",
334
+ "required": false,
335
+ "hasDynamicHelp": false,
336
+ "multiple": false,
337
+ "type": "option"
334
338
  }
335
339
  },
336
340
  "hasDynamicHelp": false,
337
341
  "hiddenAliases": [],
338
- "id": "remove",
342
+ "id": "run",
339
343
  "pluginAlias": "hereya-cli",
340
344
  "pluginName": "hereya-cli",
341
345
  "pluginType": "core",
342
- "strict": true,
346
+ "strict": false,
343
347
  "enableJsonFlag": false,
344
348
  "isESM": true,
345
349
  "relativePath": [
346
350
  "dist",
347
351
  "commands",
348
- "remove",
352
+ "run",
349
353
  "index.js"
350
354
  ]
351
355
  },
352
- "run": {
356
+ "remove": {
353
357
  "aliases": [],
354
358
  "args": {
355
- "cmd": {
356
- "description": "command to run",
357
- "name": "cmd",
359
+ "package": {
360
+ "description": "The package to remove. Packages are gitHub repositories. Use the format owner/repository",
361
+ "name": "package",
358
362
  "required": true
359
363
  }
360
364
  },
361
- "description": "Run a command with hereya env vars.",
365
+ "description": "Remove a package from the project.",
362
366
  "examples": [
363
- "<%= config.bin %> <%= command.id %> -- npm run dev",
364
- "<%= config.bin %> <%= command.id %> -w uat -- node index.js"
367
+ "<%= config.bin %> <%= command.id %> cloudy/docker_postgres"
365
368
  ],
366
369
  "flags": {
367
370
  "chdir": {
@@ -372,29 +375,26 @@
372
375
  "multiple": false,
373
376
  "type": "option"
374
377
  },
375
- "workspace": {
376
- "char": "w",
377
- "description": "name of the workspace to run the command in",
378
- "name": "workspace",
379
- "required": false,
380
- "hasDynamicHelp": false,
381
- "multiple": false,
382
- "type": "option"
378
+ "debug": {
379
+ "description": "enable debug mode",
380
+ "name": "debug",
381
+ "allowNo": false,
382
+ "type": "boolean"
383
383
  }
384
384
  },
385
385
  "hasDynamicHelp": false,
386
386
  "hiddenAliases": [],
387
- "id": "run",
387
+ "id": "remove",
388
388
  "pluginAlias": "hereya-cli",
389
389
  "pluginName": "hereya-cli",
390
390
  "pluginType": "core",
391
- "strict": false,
391
+ "strict": true,
392
392
  "enableJsonFlag": false,
393
393
  "isESM": true,
394
394
  "relativePath": [
395
395
  "dist",
396
396
  "commands",
397
- "run",
397
+ "remove",
398
398
  "index.js"
399
399
  ]
400
400
  },
@@ -954,5 +954,5 @@
954
954
  ]
955
955
  }
956
956
  },
957
- "version": "0.17.2"
957
+ "version": "0.18.0"
958
958
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hereya-cli",
3
3
  "description": "Infrastructure as Package",
4
- "version": "0.17.2",
4
+ "version": "0.18.0",
5
5
  "author": "Hereya Developers",
6
6
  "bin": {
7
7
  "hereya": "./bin/run.js"