hereya-cli 0.26.0 → 0.28.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 +21 -21
- package/dist/backend/common.d.ts +1 -0
- package/dist/backend/local.d.ts +0 -1
- package/dist/backend/local.js +16 -27
- package/dist/infrastructure/index.js +5 -0
- package/dist/infrastructure/local.js +2 -2
- package/dist/lib/config/simple.js +23 -19
- package/dist/lib/env/index.js +2 -5
- package/dist/lib/filesystem.d.ts +0 -1
- package/dist/lib/filesystem.js +1 -26
- package/dist/lib/package/github.js +6 -19
- package/dist/lib/package/index.js +11 -9
- package/dist/lib/package/local.js +2 -2
- package/dist/lib/parameter/index.js +2 -5
- package/oclif.manifest.json +1 -1
- package/package.json +1 -2
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.
|
|
23
|
+
hereya-cli/0.28.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.
|
|
85
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.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.
|
|
110
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.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.
|
|
135
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/deploy/index.ts)_
|
|
136
136
|
|
|
137
137
|
## `hereya down`
|
|
138
138
|
|
|
@@ -159,7 +159,7 @@ EXAMPLES
|
|
|
159
159
|
$ hereya down
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
162
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/down/index.ts)_
|
|
163
163
|
|
|
164
164
|
## `hereya env [NAME]`
|
|
165
165
|
|
|
@@ -190,7 +190,7 @@ EXAMPLES
|
|
|
190
190
|
$ hereya env -w dev -l
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
193
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/env/index.ts)_
|
|
194
194
|
|
|
195
195
|
## `hereya env set [NAME]`
|
|
196
196
|
|
|
@@ -217,7 +217,7 @@ EXAMPLES
|
|
|
217
217
|
$ hereya env set FOO -v bar -w dev
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
_See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
220
|
+
_See code: [src/commands/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/env/set/index.ts)_
|
|
221
221
|
|
|
222
222
|
## `hereya help [COMMAND]`
|
|
223
223
|
|
|
@@ -263,7 +263,7 @@ EXAMPLES
|
|
|
263
263
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
266
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/init/index.ts)_
|
|
267
267
|
|
|
268
268
|
## `hereya remove PACKAGE`
|
|
269
269
|
|
|
@@ -290,7 +290,7 @@ EXAMPLES
|
|
|
290
290
|
$ hereya remove cloudy/docker_postgres
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
293
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/remove/index.ts)_
|
|
294
294
|
|
|
295
295
|
## `hereya run CMD`
|
|
296
296
|
|
|
@@ -316,7 +316,7 @@ EXAMPLES
|
|
|
316
316
|
$ hereya run -w uat -- node index.js
|
|
317
317
|
```
|
|
318
318
|
|
|
319
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
319
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/run/index.ts)_
|
|
320
320
|
|
|
321
321
|
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
322
322
|
|
|
@@ -341,7 +341,7 @@ EXAMPLES
|
|
|
341
341
|
$ hereya unbootstrap local
|
|
342
342
|
```
|
|
343
343
|
|
|
344
|
-
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
344
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/unbootstrap/index.ts)_
|
|
345
345
|
|
|
346
346
|
## `hereya undeploy`
|
|
347
347
|
|
|
@@ -366,7 +366,7 @@ EXAMPLES
|
|
|
366
366
|
$ hereya undeploy
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
369
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/undeploy/index.ts)_
|
|
370
370
|
|
|
371
371
|
## `hereya up`
|
|
372
372
|
|
|
@@ -393,7 +393,7 @@ EXAMPLES
|
|
|
393
393
|
$ hereya up
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
396
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/up/index.ts)_
|
|
397
397
|
|
|
398
398
|
## `hereya workspace create NAME`
|
|
399
399
|
|
|
@@ -416,7 +416,7 @@ EXAMPLES
|
|
|
416
416
|
$ hereya workspace create dev
|
|
417
417
|
```
|
|
418
418
|
|
|
419
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
419
|
+
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/create/index.ts)_
|
|
420
420
|
|
|
421
421
|
## `hereya workspace delete NAME`
|
|
422
422
|
|
|
@@ -436,7 +436,7 @@ EXAMPLES
|
|
|
436
436
|
$ hereya workspace delete dev
|
|
437
437
|
```
|
|
438
438
|
|
|
439
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
439
|
+
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/delete/index.ts)_
|
|
440
440
|
|
|
441
441
|
## `hereya workspace env [NAME]`
|
|
442
442
|
|
|
@@ -462,7 +462,7 @@ EXAMPLES
|
|
|
462
462
|
$ hereya workspace env myEnv -w dev
|
|
463
463
|
```
|
|
464
464
|
|
|
465
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
465
|
+
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/env/index.ts)_
|
|
466
466
|
|
|
467
467
|
## `hereya workspace env set`
|
|
468
468
|
|
|
@@ -486,7 +486,7 @@ EXAMPLES
|
|
|
486
486
|
$ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
|
|
487
487
|
```
|
|
488
488
|
|
|
489
|
-
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
489
|
+
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/env/set/index.ts)_
|
|
490
490
|
|
|
491
491
|
## `hereya workspace env unset`
|
|
492
492
|
|
|
@@ -507,7 +507,7 @@ EXAMPLES
|
|
|
507
507
|
$ hereya workspace env unset -w my-workspace -n myVar
|
|
508
508
|
```
|
|
509
509
|
|
|
510
|
-
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
510
|
+
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/env/unset/index.ts)_
|
|
511
511
|
|
|
512
512
|
## `hereya workspace install PACKAGE`
|
|
513
513
|
|
|
@@ -534,7 +534,7 @@ EXAMPLES
|
|
|
534
534
|
$ hereya workspace install hereya/aws-cognito
|
|
535
535
|
```
|
|
536
536
|
|
|
537
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
537
|
+
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/install/index.ts)_
|
|
538
538
|
|
|
539
539
|
## `hereya workspace list`
|
|
540
540
|
|
|
@@ -551,7 +551,7 @@ EXAMPLES
|
|
|
551
551
|
$ hereya workspace list
|
|
552
552
|
```
|
|
553
553
|
|
|
554
|
-
_See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
554
|
+
_See code: [src/commands/workspace/list/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/list/index.ts)_
|
|
555
555
|
|
|
556
556
|
## `hereya workspace uninstall PACKAGE`
|
|
557
557
|
|
|
@@ -578,5 +578,5 @@ EXAMPLES
|
|
|
578
578
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
579
579
|
```
|
|
580
580
|
|
|
581
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
581
|
+
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.28.0/src/commands/workspace/uninstall/index.ts)_
|
|
582
582
|
<!-- commandsstop -->
|
package/dist/backend/common.d.ts
CHANGED
package/dist/backend/local.d.ts
CHANGED
package/dist/backend/local.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
1
2
|
import fs from 'node:fs/promises';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -146,19 +147,26 @@ export class LocalBackend {
|
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
149
|
async getProvisioningId(input) {
|
|
149
|
-
const id = (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
// const id = (
|
|
151
|
+
// input.project || input.workspace
|
|
152
|
+
// ? [input.project, input.workspace, input.packageCanonicalName]
|
|
153
|
+
// : [input.packageCanonicalName]
|
|
154
|
+
// )
|
|
155
|
+
// .filter(Boolean)
|
|
156
|
+
// .join('')
|
|
157
|
+
// .replaceAll(/[^\dA-Za-z]/g, '')
|
|
158
|
+
const lookupStorepath = await getAnyPath(path.join(os.homedir(), '.hereya', `provisioning.yaml`), path.join(os.homedir(), '.hereya', `provisioning.yml`));
|
|
159
|
+
const { data, found } = await load(lookupStorepath);
|
|
160
|
+
if (!found || !data[input.logicalId]) {
|
|
161
|
+
data[input.logicalId] = `p-${randomUUID()}`;
|
|
162
|
+
await save(data, lookupStorepath);
|
|
163
|
+
}
|
|
155
164
|
return {
|
|
156
|
-
id,
|
|
165
|
+
id: data[input.logicalId],
|
|
157
166
|
success: true,
|
|
158
167
|
};
|
|
159
168
|
}
|
|
160
169
|
async getState(input) {
|
|
161
|
-
await this.migrateProjectState(input);
|
|
162
170
|
const projectStatePath = await this.getProjectStatePath(input);
|
|
163
171
|
const { data, found } = await load(projectStatePath);
|
|
164
172
|
if (found) {
|
|
@@ -309,10 +317,6 @@ export class LocalBackend {
|
|
|
309
317
|
}
|
|
310
318
|
}
|
|
311
319
|
async saveState(config, workspace) {
|
|
312
|
-
await this.migrateProjectState({
|
|
313
|
-
project: config.project,
|
|
314
|
-
workspace: workspace ?? config.workspace,
|
|
315
|
-
});
|
|
316
320
|
const projectStatePath = await this.getProjectStatePath({
|
|
317
321
|
project: config.project,
|
|
318
322
|
workspace: workspace ?? config.workspace,
|
|
@@ -379,21 +383,6 @@ export class LocalBackend {
|
|
|
379
383
|
async getWorkspacePath(name) {
|
|
380
384
|
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yml`));
|
|
381
385
|
}
|
|
382
|
-
async migrateProjectState(input) {
|
|
383
|
-
const oldProjectStatePath = await this.getOldProjectStatePath(input);
|
|
384
|
-
const newProjectStatePath = await this.getProjectStatePath(input);
|
|
385
|
-
const newProjectStateDir = path.dirname(newProjectStatePath);
|
|
386
|
-
await fs.mkdir(newProjectStateDir, { recursive: true });
|
|
387
|
-
try {
|
|
388
|
-
await fs.access(oldProjectStatePath);
|
|
389
|
-
await fs.rename(oldProjectStatePath, newProjectStatePath);
|
|
390
|
-
}
|
|
391
|
-
catch (error) {
|
|
392
|
-
if (error.code !== 'ENOENT') {
|
|
393
|
-
throw error;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
386
|
async saveWorkspace(data, name) {
|
|
398
387
|
const workspacePath = await this.getWorkspacePath(name);
|
|
399
388
|
await save(data, workspacePath);
|
|
@@ -43,6 +43,7 @@ export async function destroyPackage(input) {
|
|
|
43
43
|
const { infrastructure } = infrastructure$;
|
|
44
44
|
const backend = await getBackend();
|
|
45
45
|
const id$ = await backend.getProvisioningId({
|
|
46
|
+
logicalId: getProvisioningLogicalId({ pkg: pkgName, project: input.project, workspace: input.workspace }),
|
|
46
47
|
packageCanonicalName: canonicalName,
|
|
47
48
|
project: input.project,
|
|
48
49
|
workspace: input.workspace,
|
|
@@ -130,6 +131,7 @@ export async function provisionPackage(input) {
|
|
|
130
131
|
const { infrastructure } = infrastructure$;
|
|
131
132
|
const backend = await getBackend();
|
|
132
133
|
const id$ = await backend.getProvisioningId({
|
|
134
|
+
logicalId: getProvisioningLogicalId({ pkg: pkgName, project: input.project, workspace: input.workspace }),
|
|
133
135
|
packageCanonicalName: canonicalName,
|
|
134
136
|
project: input.project,
|
|
135
137
|
workspace: input.workspace,
|
|
@@ -166,3 +168,6 @@ export async function provisionPackage(input) {
|
|
|
166
168
|
}
|
|
167
169
|
return { env: provisionOutput.env, metadata, success: true };
|
|
168
170
|
}
|
|
171
|
+
function getProvisioningLogicalId({ pkg, project, workspace }) {
|
|
172
|
+
return [pkg.replace('/', '.'), workspace, project].filter(Boolean).join('.');
|
|
173
|
+
}
|
|
@@ -17,7 +17,7 @@ export class LocalInfrastructure {
|
|
|
17
17
|
}
|
|
18
18
|
async destroy(input) {
|
|
19
19
|
// noinspection DuplicatedCode
|
|
20
|
-
const destPath = path.join(os.homedir(), '.hereya', input.id, input.canonicalName);
|
|
20
|
+
const destPath = path.join(os.homedir(), '.hereya', 'provisioning', input.id, input.canonicalName);
|
|
21
21
|
const downloadPath = await downloadPackage(input.pkgUrl, destPath);
|
|
22
22
|
const iac$ = getIac({ type: input.iacType });
|
|
23
23
|
if (!iac$.supported) {
|
|
@@ -40,7 +40,7 @@ export class LocalInfrastructure {
|
|
|
40
40
|
}
|
|
41
41
|
async provision(input) {
|
|
42
42
|
// noinspection DuplicatedCode
|
|
43
|
-
const destPath = path.join(os.homedir(), '.hereya', input.id, input.canonicalName);
|
|
43
|
+
const destPath = path.join(os.homedir(), '.hereya', 'provisioning', input.id, input.canonicalName);
|
|
44
44
|
const downloadPath = await downloadPackage(input.pkgUrl, destPath);
|
|
45
45
|
const iac$ = getIac({ type: input.iacType });
|
|
46
46
|
if (!iac$.supported) {
|
|
@@ -6,26 +6,30 @@ export class SimpleConfigManager {
|
|
|
6
6
|
const { config } = await this.loadConfig({ projectRootDir: input.projectRootDir });
|
|
7
7
|
await yaml.save({
|
|
8
8
|
...config,
|
|
9
|
-
...(input.metadata.deploy
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
...(input.metadata.deploy
|
|
10
|
+
? {
|
|
11
|
+
deploy: {
|
|
12
|
+
...config.deploy,
|
|
13
|
+
[input.package]: {
|
|
14
|
+
version: '',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
: {
|
|
19
|
+
packages: {
|
|
20
|
+
...config.packages,
|
|
21
|
+
[input.package]: {
|
|
22
|
+
version: '',
|
|
23
|
+
...(input.metadata.onDeploy
|
|
24
|
+
? {
|
|
25
|
+
onDeploy: {
|
|
26
|
+
...input.metadata.onDeploy,
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
: {}),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
29
33
|
}, await this.getConfigPath(input.projectRootDir));
|
|
30
34
|
}
|
|
31
35
|
async loadConfig(input) {
|
package/dist/lib/env/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { getExecutor } from '../../executor/index.js';
|
|
3
|
-
import { getAnyPath
|
|
3
|
+
import { getAnyPath } from '../filesystem.js';
|
|
4
4
|
import { load, save } from '../yaml-utils.js';
|
|
5
5
|
export class EnvManager {
|
|
6
6
|
async addProjectEnv(input) {
|
|
@@ -34,10 +34,7 @@ export class EnvManager {
|
|
|
34
34
|
return { env: finalEnv, success: true };
|
|
35
35
|
}
|
|
36
36
|
async getStaticEnvDir(projectRootDir) {
|
|
37
|
-
|
|
38
|
-
const targetDir = path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyastaticenv');
|
|
39
|
-
await migrateFiles(sourceDir, targetDir);
|
|
40
|
-
return targetDir;
|
|
37
|
+
return path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyastaticenv');
|
|
41
38
|
}
|
|
42
39
|
async removeProjectEnv(input) {
|
|
43
40
|
const envPath = await this.getEnvPath(input);
|
package/dist/lib/filesystem.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
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>;
|
package/dist/lib/filesystem.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from 'node:path';
|
|
1
|
+
import { access, constants, readdir } from 'node:fs/promises';
|
|
3
2
|
export async function getAnyPath(...candidates) {
|
|
4
3
|
const checkAccess = async (index) => {
|
|
5
4
|
if (index >= candidates.length)
|
|
@@ -32,27 +31,3 @@ export async function isNotEmpty(directoryPath) {
|
|
|
32
31
|
return false;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
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,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
7
2
|
import fs from 'node:fs/promises';
|
|
8
3
|
import os from 'node:os';
|
|
9
4
|
import path from 'node:path';
|
|
10
5
|
import { simpleGit } from 'simple-git';
|
|
11
|
-
import {
|
|
12
|
-
import { isNotEmpty } from '../filesystem.js';
|
|
6
|
+
import { fileExists, isNotEmpty } from '../filesystem.js';
|
|
13
7
|
export class GitHubPackageManager {
|
|
14
8
|
registryUrl;
|
|
15
9
|
constructor(registryUrl = process.env.HEREYA_REGISTRY_URL || 'https://github.com') {
|
|
16
10
|
this.registryUrl = registryUrl;
|
|
17
11
|
}
|
|
18
|
-
// eslint-disable-next-line new-cap
|
|
19
12
|
async downloadPackage(pkgUrl, destPath) {
|
|
20
13
|
if (await isNotEmpty(destPath)) {
|
|
21
14
|
return destPath;
|
|
@@ -29,10 +22,10 @@ export class GitHubPackageManager {
|
|
|
29
22
|
}
|
|
30
23
|
async getRepoContent({ owner, path: filePath, repo }) {
|
|
31
24
|
const pkgUrl = `${this.registryUrl}/${owner}/${repo}`;
|
|
32
|
-
const tmpFolder = path.join(os.
|
|
25
|
+
const tmpFolder = path.join(os.homedir(), '.hereya', 'downloads', randomUUID());
|
|
33
26
|
try {
|
|
34
27
|
const destPath = await this.downloadPackage(pkgUrl, tmpFolder);
|
|
35
|
-
if (await
|
|
28
|
+
if (await fileExists(path.join(destPath, filePath))) {
|
|
36
29
|
const content = await fs.readFile(path.join(destPath, filePath), 'utf8');
|
|
37
30
|
// remove the tmp folder
|
|
38
31
|
await fs.rm(destPath, { recursive: true });
|
|
@@ -42,6 +35,8 @@ export class GitHubPackageManager {
|
|
|
42
35
|
pkgUrl,
|
|
43
36
|
};
|
|
44
37
|
}
|
|
38
|
+
// remove the tmp folder
|
|
39
|
+
await fs.rm(destPath, { recursive: true });
|
|
45
40
|
return {
|
|
46
41
|
found: false,
|
|
47
42
|
reason: `File ${filePath} not found in ${pkgUrl}`,
|
|
@@ -55,11 +50,3 @@ export class GitHubPackageManager {
|
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
|
-
__decorate([
|
|
59
|
-
Retryable({
|
|
60
|
-
backOff: 1000,
|
|
61
|
-
backOffPolicy: BackOffPolicy.ExponentialBackOffPolicy,
|
|
62
|
-
exponentialOption: { maxInterval: 4000, multiplier: 3 },
|
|
63
|
-
maxAttempts: 3,
|
|
64
|
-
})
|
|
65
|
-
], GitHubPackageManager.prototype, "downloadPackage", null);
|
|
@@ -13,11 +13,17 @@ export function getPackageManager(protocol) {
|
|
|
13
13
|
return packageManager;
|
|
14
14
|
}
|
|
15
15
|
export async function resolvePackage(input) {
|
|
16
|
-
|
|
16
|
+
if (input.package.includes('.')) {
|
|
17
|
+
return { found: false, reason: 'Invalid package format. Package name cannot contain dots (.) nor double dashes (--)' };
|
|
18
|
+
}
|
|
19
|
+
if (input.package.includes('--')) {
|
|
20
|
+
return { found: false, reason: 'Invalid package format. Package name cannot contain dots (.) nor double dashes (--)' };
|
|
21
|
+
}
|
|
22
|
+
const isLocal = input.package.startsWith('local/');
|
|
17
23
|
let [owner, repo] = ['', ''];
|
|
18
24
|
if (isLocal) {
|
|
19
|
-
;
|
|
20
|
-
|
|
25
|
+
owner = 'local';
|
|
26
|
+
repo = input.package.replace('local/', '');
|
|
21
27
|
}
|
|
22
28
|
else {
|
|
23
29
|
const pkgParts = input.package.split('/');
|
|
@@ -57,14 +63,10 @@ export async function resolvePackage(input) {
|
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
export function getPackageCanonicalName(packageName) {
|
|
60
|
-
|
|
61
|
-
if (isLocal) {
|
|
62
|
-
return packageName.replace('local://', 'local--').replace('/', '-');
|
|
63
|
-
}
|
|
64
|
-
return packageName.replace('/', '-');
|
|
66
|
+
return packageName.replace('/', '--');
|
|
65
67
|
}
|
|
66
68
|
export async function downloadPackage(pkgUrl, destPath) {
|
|
67
|
-
const packageManager = getPackageManager(pkgUrl.startsWith('local
|
|
69
|
+
const packageManager = getPackageManager(pkgUrl.startsWith('local/') ? 'local' : '');
|
|
68
70
|
return packageManager.downloadPackage(pkgUrl, destPath);
|
|
69
71
|
}
|
|
70
72
|
export const PackageMetadata = z.object({
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
export class LocalPackageManager {
|
|
4
4
|
async downloadPackage(pkgUrl, destPath) {
|
|
5
|
-
const
|
|
5
|
+
const source = pkgUrl.replace('local/', '');
|
|
6
6
|
await copyRecursive(source, destPath);
|
|
7
7
|
return destPath;
|
|
8
8
|
}
|
|
@@ -15,7 +15,7 @@ export class LocalPackageManager {
|
|
|
15
15
|
return {
|
|
16
16
|
content,
|
|
17
17
|
found: true,
|
|
18
|
-
pkgUrl: `local
|
|
18
|
+
pkgUrl: `local/${pkgRootDir}`,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { getAnyPath
|
|
2
|
+
import { getAnyPath } 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 {
|
|
@@ -47,10 +47,7 @@ export class ParameterManager {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
async getParametersFolder(projectRootDir) {
|
|
50
|
-
|
|
51
|
-
const targetDir = path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyavars');
|
|
52
|
-
await migrateFiles(sourceDir, targetDir);
|
|
53
|
-
return targetDir;
|
|
50
|
+
return path.join(projectRootDir ?? process.cwd(), 'hereyaconfig', 'hereyavars');
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
export const parameterManager = new ParameterManager();
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hereya-cli",
|
|
3
3
|
"description": "Infrastructure as Package",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"author": "Hereya Developers",
|
|
6
6
|
"bin": {
|
|
7
7
|
"hereya": "./bin/run.js"
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"ignore": "^7.0.3",
|
|
24
24
|
"listr2": "^8.2.5",
|
|
25
25
|
"simple-git": "^3.27.0",
|
|
26
|
-
"typescript-retry-decorator": "^2.4.2",
|
|
27
26
|
"unzip-stream": "^0.3.4",
|
|
28
27
|
"yaml": "^2.7.0",
|
|
29
28
|
"zod": "^3.24.2"
|