hereya-cli 0.13.1 → 0.15.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 +19 -19
- package/dist/backend/common.d.ts +3 -2
- package/dist/backend/local.d.ts +3 -1
- package/dist/backend/local.js +32 -6
- package/dist/commands/add/index.js +124 -67
- package/dist/commands/deploy/index.js +259 -95
- package/dist/commands/down/index.js +133 -58
- package/dist/commands/remove/index.js +114 -61
- package/dist/commands/undeploy/index.js +180 -51
- package/dist/commands/up/index.js +196 -103
- package/dist/infrastructure/index.d.ts +1 -0
- package/dist/lib/log.js +4 -20
- package/dist/lib/package/common.d.ts +2 -0
- package/dist/lib/package/github.d.ts +1 -0
- package/dist/lib/package/github.js +31 -2
- package/dist/lib/package/index.js +4 -19
- package/dist/lib/shell.d.ts +1 -0
- package/dist/lib/shell.js +8 -0
- package/oclif.manifest.json +40 -40
- package/package.json +3 -3
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.15.0 linux-x64 node-v22.13.0
|
|
24
24
|
$ hereya --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ hereya COMMAND
|
|
@@ -73,7 +73,7 @@ EXAMPLES
|
|
|
73
73
|
$ hereya add cloudy/docker_postgres
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
76
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/add/index.ts)_
|
|
77
77
|
|
|
78
78
|
## `hereya bootstrap INFRASTRUCTURETYPE`
|
|
79
79
|
|
|
@@ -98,7 +98,7 @@ EXAMPLES
|
|
|
98
98
|
$ hereya bootstrap local
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
101
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/bootstrap/index.ts)_
|
|
102
102
|
|
|
103
103
|
## `hereya deploy`
|
|
104
104
|
|
|
@@ -120,7 +120,7 @@ EXAMPLES
|
|
|
120
120
|
$ hereya deploy
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
123
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/deploy/index.ts)_
|
|
124
124
|
|
|
125
125
|
## `hereya down`
|
|
126
126
|
|
|
@@ -143,7 +143,7 @@ EXAMPLES
|
|
|
143
143
|
$ hereya down
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
146
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/down/index.ts)_
|
|
147
147
|
|
|
148
148
|
## `hereya env [NAME]`
|
|
149
149
|
|
|
@@ -174,7 +174,7 @@ EXAMPLES
|
|
|
174
174
|
$ hereya env -w dev -l
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
177
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/env/index.ts)_
|
|
178
178
|
|
|
179
179
|
## `hereya help [COMMAND]`
|
|
180
180
|
|
|
@@ -220,7 +220,7 @@ EXAMPLES
|
|
|
220
220
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
223
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/init/index.ts)_
|
|
224
224
|
|
|
225
225
|
## `hereya remove PACKAGE`
|
|
226
226
|
|
|
@@ -244,7 +244,7 @@ EXAMPLES
|
|
|
244
244
|
$ hereya remove cloudy/docker_postgres
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
247
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/remove/index.ts)_
|
|
248
248
|
|
|
249
249
|
## `hereya run CMD`
|
|
250
250
|
|
|
@@ -270,7 +270,7 @@ EXAMPLES
|
|
|
270
270
|
$ hereya run -w uat -- node index.js
|
|
271
271
|
```
|
|
272
272
|
|
|
273
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
273
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/run/index.ts)_
|
|
274
274
|
|
|
275
275
|
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
276
276
|
|
|
@@ -295,7 +295,7 @@ EXAMPLES
|
|
|
295
295
|
$ hereya unbootstrap local
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
298
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/unbootstrap/index.ts)_
|
|
299
299
|
|
|
300
300
|
## `hereya undeploy`
|
|
301
301
|
|
|
@@ -317,7 +317,7 @@ EXAMPLES
|
|
|
317
317
|
$ hereya undeploy
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
320
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/undeploy/index.ts)_
|
|
321
321
|
|
|
322
322
|
## `hereya up`
|
|
323
323
|
|
|
@@ -340,7 +340,7 @@ EXAMPLES
|
|
|
340
340
|
$ hereya up
|
|
341
341
|
```
|
|
342
342
|
|
|
343
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
343
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/up/index.ts)_
|
|
344
344
|
|
|
345
345
|
## `hereya workspace create NAME`
|
|
346
346
|
|
|
@@ -360,7 +360,7 @@ EXAMPLES
|
|
|
360
360
|
$ hereya workspace create dev
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
363
|
+
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/create/index.ts)_
|
|
364
364
|
|
|
365
365
|
## `hereya workspace delete NAME`
|
|
366
366
|
|
|
@@ -380,7 +380,7 @@ EXAMPLES
|
|
|
380
380
|
$ hereya workspace delete dev
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
383
|
+
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/delete/index.ts)_
|
|
384
384
|
|
|
385
385
|
## `hereya workspace env [NAME]`
|
|
386
386
|
|
|
@@ -406,7 +406,7 @@ EXAMPLES
|
|
|
406
406
|
$ hereya workspace env myEnv -w dev
|
|
407
407
|
```
|
|
408
408
|
|
|
409
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
409
|
+
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/index.ts)_
|
|
410
410
|
|
|
411
411
|
## `hereya workspace env set`
|
|
412
412
|
|
|
@@ -430,7 +430,7 @@ EXAMPLES
|
|
|
430
430
|
$ hereya workspace env set -w my-workspace -n myVar -v my-value -i aws -s
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
433
|
+
_See code: [src/commands/workspace/env/set/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/set/index.ts)_
|
|
434
434
|
|
|
435
435
|
## `hereya workspace env unset`
|
|
436
436
|
|
|
@@ -451,7 +451,7 @@ EXAMPLES
|
|
|
451
451
|
$ hereya workspace env unset -w my-workspace -n myVar
|
|
452
452
|
```
|
|
453
453
|
|
|
454
|
-
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
454
|
+
_See code: [src/commands/workspace/env/unset/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/env/unset/index.ts)_
|
|
455
455
|
|
|
456
456
|
## `hereya workspace install PACKAGE`
|
|
457
457
|
|
|
@@ -477,7 +477,7 @@ EXAMPLES
|
|
|
477
477
|
$ hereya workspace install hereya/aws-cognito
|
|
478
478
|
```
|
|
479
479
|
|
|
480
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
480
|
+
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/install/index.ts)_
|
|
481
481
|
|
|
482
482
|
## `hereya workspace uninstall PACKAGE`
|
|
483
483
|
|
|
@@ -503,5 +503,5 @@ EXAMPLES
|
|
|
503
503
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
504
504
|
```
|
|
505
505
|
|
|
506
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
506
|
+
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.15.0/src/commands/workspace/uninstall/index.ts)_
|
|
507
507
|
<!-- commandsstop -->
|
package/dist/backend/common.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Backend {
|
|
|
10
10
|
getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
|
|
11
11
|
init(options: InitProjectInput): Promise<InitProjectOutput>;
|
|
12
12
|
removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
|
|
13
|
-
saveState(config:
|
|
13
|
+
saveState(config: Config, workspace?: string): Promise<void>;
|
|
14
14
|
setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
|
|
15
15
|
unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
|
|
16
16
|
}
|
|
@@ -110,9 +110,10 @@ export type GetWorkspaceOutput = {
|
|
|
110
110
|
});
|
|
111
111
|
export type GetStateInput = {
|
|
112
112
|
project: string;
|
|
113
|
+
workspace: string;
|
|
113
114
|
};
|
|
114
115
|
export type GetStateOutput = {
|
|
115
|
-
config:
|
|
116
|
+
config: Config;
|
|
116
117
|
found: true;
|
|
117
118
|
} | {
|
|
118
119
|
found: false;
|
package/dist/backend/local.d.ts
CHANGED
|
@@ -10,10 +10,12 @@ export declare class LocalBackend implements Backend {
|
|
|
10
10
|
getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
|
|
11
11
|
init(options: InitProjectInput): Promise<InitProjectOutput>;
|
|
12
12
|
removePackageFromWorkspace(input: RemovePackageFromWorkspaceInput): Promise<RemovePackageFromWorkspaceOutput>;
|
|
13
|
-
saveState(config:
|
|
13
|
+
saveState(config: Config, workspace?: string): Promise<void>;
|
|
14
14
|
setEnvVar(input: SetEnvVarInput): Promise<SetEnvVarOutput>;
|
|
15
15
|
unsetEnvVar(input: UnsetEnvVarInput): Promise<UnsetEnvVarOutput>;
|
|
16
|
+
private getOldProjectStatePath;
|
|
16
17
|
private getProjectStatePath;
|
|
17
18
|
private getWorkspacePath;
|
|
19
|
+
private migrateProjectState;
|
|
18
20
|
private saveWorkspace;
|
|
19
21
|
}
|
package/dist/backend/local.js
CHANGED
|
@@ -132,7 +132,8 @@ export class LocalBackend {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
async getState(input) {
|
|
135
|
-
|
|
135
|
+
await this.migrateProjectState(input);
|
|
136
|
+
const projectStatePath = await this.getProjectStatePath(input);
|
|
136
137
|
const { data, found } = await load(projectStatePath);
|
|
137
138
|
if (found) {
|
|
138
139
|
return {
|
|
@@ -228,9 +229,16 @@ export class LocalBackend {
|
|
|
228
229
|
};
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
|
-
async saveState(config) {
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
async saveState(config, workspace) {
|
|
233
|
+
await this.migrateProjectState({
|
|
234
|
+
project: config.project,
|
|
235
|
+
workspace: workspace ?? config.workspace,
|
|
236
|
+
});
|
|
237
|
+
const projectStatePath = await this.getProjectStatePath({
|
|
238
|
+
project: config.project,
|
|
239
|
+
workspace: workspace ?? config.workspace,
|
|
240
|
+
});
|
|
241
|
+
await save({ ...config, workspace: workspace ?? config.workspace }, projectStatePath);
|
|
234
242
|
}
|
|
235
243
|
async setEnvVar(input) {
|
|
236
244
|
const workspace$ = await this.getWorkspace(input.workspace);
|
|
@@ -321,12 +329,30 @@ export class LocalBackend {
|
|
|
321
329
|
success: true,
|
|
322
330
|
};
|
|
323
331
|
}
|
|
324
|
-
async
|
|
325
|
-
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', `${project}.yml`));
|
|
332
|
+
async getOldProjectStatePath(input) {
|
|
333
|
+
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', `${input.project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', `${input.project}.yml`));
|
|
334
|
+
}
|
|
335
|
+
async getProjectStatePath(input) {
|
|
336
|
+
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'projects', input.workspace, `${input.project}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'projects', input.workspace, `${input.project}.yml`));
|
|
326
337
|
}
|
|
327
338
|
async getWorkspacePath(name) {
|
|
328
339
|
return getAnyPath(path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yaml`), path.join(os.homedir(), '.hereya', 'state', 'workspaces', `${name}.yml`));
|
|
329
340
|
}
|
|
341
|
+
async migrateProjectState(input) {
|
|
342
|
+
const oldProjectStatePath = await this.getOldProjectStatePath(input);
|
|
343
|
+
const newProjectStatePath = await this.getProjectStatePath(input);
|
|
344
|
+
const newProjectStateDir = path.dirname(newProjectStatePath);
|
|
345
|
+
await fs.mkdir(newProjectStateDir, { recursive: true });
|
|
346
|
+
try {
|
|
347
|
+
await fs.access(oldProjectStatePath);
|
|
348
|
+
await fs.rename(oldProjectStatePath, newProjectStatePath);
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
if (error.code !== 'ENOENT') {
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
330
356
|
async saveWorkspace(data, name) {
|
|
331
357
|
const workspacePath = await this.getWorkspacePath(name);
|
|
332
358
|
await save(data, workspacePath);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { Listr, ListrLogLevels, ListrLogger } from 'listr2';
|
|
2
3
|
import { getBackend } from '../../backend/index.js';
|
|
3
4
|
import { provisionPackage } from '../../infrastructure/index.js';
|
|
4
5
|
import { getConfigManager } from '../../lib/config/index.js';
|
|
5
6
|
import { getEnvManager } from '../../lib/env/index.js';
|
|
6
7
|
import { logEnv } from '../../lib/env-utils.js';
|
|
7
|
-
import { getLogger } from '../../lib/log.js';
|
|
8
8
|
import { arrayOfStringToObject } from '../../lib/object-utils.js';
|
|
9
9
|
import { getParameterManager } from '../../lib/parameter/index.js';
|
|
10
|
-
import { setDebug } from '../../lib/shell.js';
|
|
10
|
+
import { delay, setDebug } from '../../lib/shell.js';
|
|
11
11
|
export default class Add extends Command {
|
|
12
12
|
static args = {
|
|
13
13
|
package: Args.string({
|
|
@@ -36,73 +36,130 @@ export default class Add extends Command {
|
|
|
36
36
|
async run() {
|
|
37
37
|
const { args, flags } = await this.parse(Add);
|
|
38
38
|
setDebug(flags.debug);
|
|
39
|
-
const logger = getLogger();
|
|
40
39
|
const projectRootDir = flags.chdir || process.env.HEREYA_PROJECT_ROOT_DIR;
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const myLogger = new ListrLogger({ useIcons: false });
|
|
41
|
+
const task = new Listr([
|
|
42
|
+
{
|
|
43
|
+
async task(ctx, task) {
|
|
44
|
+
return task.newListr([
|
|
45
|
+
{
|
|
46
|
+
async task(ctx) {
|
|
47
|
+
const configManager = getConfigManager();
|
|
48
|
+
const loadConfigOutput = await configManager.loadConfig({ projectRootDir });
|
|
49
|
+
if (!loadConfigOutput.found) {
|
|
50
|
+
throw new Error("Project not initialized. Run 'hereya init' first.");
|
|
51
|
+
}
|
|
52
|
+
ctx.configOutput = loadConfigOutput;
|
|
53
|
+
await delay(500);
|
|
54
|
+
},
|
|
55
|
+
title: 'Loading project config',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
async task(ctx) {
|
|
59
|
+
const backend = await getBackend();
|
|
60
|
+
const getWorkspaceEnvOutput = await backend.getWorkspaceEnv({
|
|
61
|
+
project: ctx.configOutput.config.project,
|
|
62
|
+
workspace: ctx.configOutput.config.workspace,
|
|
63
|
+
});
|
|
64
|
+
if (!getWorkspaceEnvOutput.success) {
|
|
65
|
+
throw new Error(getWorkspaceEnvOutput.reason);
|
|
66
|
+
}
|
|
67
|
+
ctx.workspaceEnvOutput = getWorkspaceEnvOutput;
|
|
68
|
+
await delay(500);
|
|
69
|
+
},
|
|
70
|
+
title: 'Loading Workspace environment variables',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
async task(ctx) {
|
|
74
|
+
const userSpecifiedParameters = arrayOfStringToObject(flags.parameter);
|
|
75
|
+
const parameterManager = getParameterManager();
|
|
76
|
+
const parametersOutput = await parameterManager.getPackageParameters({
|
|
77
|
+
package: args.package,
|
|
78
|
+
projectRootDir,
|
|
79
|
+
userSpecifiedParameters,
|
|
80
|
+
workspace: ctx.configOutput.config.workspace,
|
|
81
|
+
});
|
|
82
|
+
ctx.parametersOutput = parametersOutput;
|
|
83
|
+
await delay(500);
|
|
84
|
+
},
|
|
85
|
+
title: 'Resolving package parameters',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
async task(ctx) {
|
|
89
|
+
const provisionOutput = await provisionPackage({
|
|
90
|
+
env: ctx.workspaceEnvOutput.env,
|
|
91
|
+
package: args.package,
|
|
92
|
+
parameters: ctx.parametersOutput.parameters,
|
|
93
|
+
project: ctx.configOutput.config.project,
|
|
94
|
+
skipDeploy: true,
|
|
95
|
+
workspace: ctx.configOutput.config.workspace,
|
|
96
|
+
});
|
|
97
|
+
if (!provisionOutput.success) {
|
|
98
|
+
throw new Error(provisionOutput.reason);
|
|
99
|
+
}
|
|
100
|
+
ctx.provisionOutput = provisionOutput;
|
|
101
|
+
},
|
|
102
|
+
title: 'Provisioning package',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
async task(ctx) {
|
|
106
|
+
const { env, metadata } = ctx.provisionOutput;
|
|
107
|
+
const envManager = getEnvManager();
|
|
108
|
+
await envManager.addProjectEnv({
|
|
109
|
+
env,
|
|
110
|
+
infra: metadata.originalInfra ?? metadata.infra,
|
|
111
|
+
projectRootDir,
|
|
112
|
+
workspace: ctx.configOutput.config.workspace,
|
|
113
|
+
});
|
|
114
|
+
await delay(500);
|
|
115
|
+
},
|
|
116
|
+
title: 'Saving exported environment variables',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
async task(ctx) {
|
|
120
|
+
const configManager = getConfigManager();
|
|
121
|
+
await configManager.addPackage({
|
|
122
|
+
metadata: ctx.provisionOutput.metadata,
|
|
123
|
+
package: args.package,
|
|
124
|
+
projectRootDir,
|
|
125
|
+
});
|
|
126
|
+
await delay(500);
|
|
127
|
+
},
|
|
128
|
+
title: 'Adding package to hereya manifest',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
async task(ctx) {
|
|
132
|
+
const backend = await getBackend();
|
|
133
|
+
const configManager = getConfigManager();
|
|
134
|
+
const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
|
|
135
|
+
await backend.saveState(newConfig);
|
|
136
|
+
const parameterManager = getParameterManager();
|
|
137
|
+
const { filePath, saved } = await parameterManager.savePackageParameters({
|
|
138
|
+
package: args.package,
|
|
139
|
+
parameters: ctx.parametersOutput.parameters,
|
|
140
|
+
projectRootDir,
|
|
141
|
+
workspace: ctx.configOutput.config.workspace,
|
|
142
|
+
});
|
|
143
|
+
await delay(500);
|
|
144
|
+
if (saved) {
|
|
145
|
+
myLogger.log(ListrLogLevels.COMPLETED, `Saved the following parameters for the package in ${filePath}:`);
|
|
146
|
+
logEnv(ctx.parametersOutput.parameters, (msg) => myLogger.log(ListrLogLevels.COMPLETED, msg));
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
title: 'Saving state',
|
|
150
|
+
},
|
|
151
|
+
], { concurrent: false });
|
|
152
|
+
},
|
|
153
|
+
title: `Adding ${args.package}`,
|
|
154
|
+
},
|
|
155
|
+
], { concurrent: false });
|
|
156
|
+
try {
|
|
157
|
+
await task.run();
|
|
158
|
+
myLogger.log(ListrLogLevels.COMPLETED, 'Package added successfully');
|
|
46
159
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
project: config.project,
|
|
51
|
-
workspace: config.workspace,
|
|
52
|
-
});
|
|
53
|
-
if (!getWorkspaceEnvOutput.success) {
|
|
54
|
-
this.error(getWorkspaceEnvOutput.reason);
|
|
55
|
-
}
|
|
56
|
-
const { env: workspaceEnv } = getWorkspaceEnvOutput;
|
|
57
|
-
const userSpecifiedParameters = arrayOfStringToObject(flags.parameter);
|
|
58
|
-
const parameterManager = getParameterManager();
|
|
59
|
-
const { parameters } = await parameterManager.getPackageParameters({
|
|
60
|
-
package: args.package,
|
|
61
|
-
projectRootDir,
|
|
62
|
-
userSpecifiedParameters,
|
|
63
|
-
workspace: config.workspace,
|
|
64
|
-
});
|
|
65
|
-
logger.log(`Provisioning package ${args.package}`);
|
|
66
|
-
const provisionOutput = await provisionPackage({
|
|
67
|
-
env: workspaceEnv,
|
|
68
|
-
package: args.package,
|
|
69
|
-
parameters,
|
|
70
|
-
project: config.project,
|
|
71
|
-
skipDeploy: true,
|
|
72
|
-
workspace: config.workspace,
|
|
73
|
-
});
|
|
74
|
-
if (!provisionOutput.success) {
|
|
75
|
-
this.error(provisionOutput.reason);
|
|
76
|
-
}
|
|
77
|
-
const { env, metadata } = provisionOutput;
|
|
78
|
-
logger.done(`Package ${args.package} provisioned successfully`);
|
|
79
|
-
logger.log(`Saving exported environment variables`);
|
|
80
|
-
const envManager = getEnvManager();
|
|
81
|
-
await envManager.addProjectEnv({
|
|
82
|
-
env,
|
|
83
|
-
infra: metadata.originalInfra ?? metadata.infra,
|
|
84
|
-
projectRootDir,
|
|
85
|
-
workspace: config.workspace,
|
|
86
|
-
});
|
|
87
|
-
logger.done('Saved exported environment variables');
|
|
88
|
-
logger.log('Adding package to hereya manifest');
|
|
89
|
-
await configManager.addPackage({
|
|
90
|
-
metadata,
|
|
91
|
-
package: args.package,
|
|
92
|
-
projectRootDir,
|
|
93
|
-
});
|
|
94
|
-
logger.done('Package added to hereya manifest');
|
|
95
|
-
const { config: newConfig } = await configManager.loadConfig({ projectRootDir });
|
|
96
|
-
await backend.saveState(newConfig);
|
|
97
|
-
const { filePath, saved } = await parameterManager.savePackageParameters({
|
|
98
|
-
package: args.package,
|
|
99
|
-
parameters,
|
|
100
|
-
projectRootDir,
|
|
101
|
-
workspace: config.workspace,
|
|
102
|
-
});
|
|
103
|
-
if (saved) {
|
|
104
|
-
await logger.done(`Saved the following parameters for the package in ${filePath}:`);
|
|
105
|
-
logEnv(parameters, (msg) => logger.done(msg));
|
|
160
|
+
catch (error) {
|
|
161
|
+
myLogger.log(ListrLogLevels.FAILED, error);
|
|
162
|
+
this.error(error.message);
|
|
106
163
|
}
|
|
107
164
|
}
|
|
108
165
|
}
|