hereya-cli 0.6.4 → 0.8.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 +44 -18
- package/dist/backend/common.d.ts +13 -0
- package/dist/backend/local.d.ts +2 -1
- package/dist/backend/local.js +9 -0
- package/dist/commands/bootstrap/index.js +1 -1
- package/dist/commands/unbootstrap/index.d.ts +12 -0
- package/dist/commands/unbootstrap/index.js +28 -0
- package/dist/iac/terraform.js +8 -5
- package/dist/infrastructure/aws.d.ts +1 -0
- package/dist/infrastructure/aws.js +18 -1
- package/dist/infrastructure/common.d.ts +1 -0
- package/dist/infrastructure/index.js +57 -13
- package/dist/infrastructure/local.d.ts +1 -0
- package/dist/infrastructure/local.js +3 -0
- package/dist/lib/package/index.d.ts +3 -0
- package/dist/lib/package/index.js +4 -0
- package/oclif.manifest.json +79 -40
- package/package.json +1 -1
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.8.0 linux-x64 node-v20.14.0
|
|
24
24
|
$ hereya --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ hereya COMMAND
|
|
@@ -39,6 +39,7 @@ USAGE
|
|
|
39
39
|
* [`hereya remote exec [PKGPATH]`](#hereya-remote-exec-pkgpath)
|
|
40
40
|
* [`hereya remove PACKAGE`](#hereya-remove-package)
|
|
41
41
|
* [`hereya run CMD`](#hereya-run-cmd)
|
|
42
|
+
* [`hereya unbootstrap INFRASTRUCTURETYPE`](#hereya-unbootstrap-infrastructuretype)
|
|
42
43
|
* [`hereya undeploy`](#hereya-undeploy)
|
|
43
44
|
* [`hereya up`](#hereya-up)
|
|
44
45
|
* [`hereya workspace create NAME`](#hereya-workspace-create-name)
|
|
@@ -70,7 +71,7 @@ EXAMPLES
|
|
|
70
71
|
$ hereya add cloudy/docker_postgres
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
74
|
+
_See code: [src/commands/add/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/add/index.ts)_
|
|
74
75
|
|
|
75
76
|
## `hereya bootstrap INFRASTRUCTURETYPE`
|
|
76
77
|
|
|
@@ -81,7 +82,7 @@ USAGE
|
|
|
81
82
|
$ hereya bootstrap INFRASTRUCTURETYPE [-f]
|
|
82
83
|
|
|
83
84
|
ARGUMENTS
|
|
84
|
-
INFRASTRUCTURETYPE infrastructure to bootstrap. Options are local, aws
|
|
85
|
+
INFRASTRUCTURETYPE infrastructure to bootstrap. Options are local, aws
|
|
85
86
|
|
|
86
87
|
FLAGS
|
|
87
88
|
-f, --force redeploy hereya resources if already deployed
|
|
@@ -95,7 +96,7 @@ EXAMPLES
|
|
|
95
96
|
$ hereya bootstrap local
|
|
96
97
|
```
|
|
97
98
|
|
|
98
|
-
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
99
|
+
_See code: [src/commands/bootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/bootstrap/index.ts)_
|
|
99
100
|
|
|
100
101
|
## `hereya deploy`
|
|
101
102
|
|
|
@@ -116,7 +117,7 @@ EXAMPLES
|
|
|
116
117
|
$ hereya deploy
|
|
117
118
|
```
|
|
118
119
|
|
|
119
|
-
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
120
|
+
_See code: [src/commands/deploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/deploy/index.ts)_
|
|
120
121
|
|
|
121
122
|
## `hereya down`
|
|
122
123
|
|
|
@@ -138,7 +139,7 @@ EXAMPLES
|
|
|
138
139
|
$ hereya down
|
|
139
140
|
```
|
|
140
141
|
|
|
141
|
-
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
142
|
+
_See code: [src/commands/down/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/down/index.ts)_
|
|
142
143
|
|
|
143
144
|
## `hereya env [NAME]`
|
|
144
145
|
|
|
@@ -169,7 +170,7 @@ EXAMPLES
|
|
|
169
170
|
$ hereya env -w dev -l
|
|
170
171
|
```
|
|
171
172
|
|
|
172
|
-
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
173
|
+
_See code: [src/commands/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/env/index.ts)_
|
|
173
174
|
|
|
174
175
|
## `hereya help [COMMAND]`
|
|
175
176
|
|
|
@@ -215,7 +216,7 @@ EXAMPLES
|
|
|
215
216
|
$ hereya init myProject -w=defaultWorkspace --chdir=./myProject
|
|
216
217
|
```
|
|
217
218
|
|
|
218
|
-
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
219
|
+
_See code: [src/commands/init/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/init/index.ts)_
|
|
219
220
|
|
|
220
221
|
## `hereya remote exec [PKGPATH]`
|
|
221
222
|
|
|
@@ -239,7 +240,7 @@ EXAMPLES
|
|
|
239
240
|
$ hereya remote exec
|
|
240
241
|
```
|
|
241
242
|
|
|
242
|
-
_See code: [src/commands/remote/exec/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
243
|
+
_See code: [src/commands/remote/exec/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/remote/exec/index.ts)_
|
|
243
244
|
|
|
244
245
|
## `hereya remove PACKAGE`
|
|
245
246
|
|
|
@@ -262,7 +263,7 @@ EXAMPLES
|
|
|
262
263
|
$ hereya remove cloudy/docker_postgres
|
|
263
264
|
```
|
|
264
265
|
|
|
265
|
-
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
266
|
+
_See code: [src/commands/remove/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/remove/index.ts)_
|
|
266
267
|
|
|
267
268
|
## `hereya run CMD`
|
|
268
269
|
|
|
@@ -288,7 +289,32 @@ EXAMPLES
|
|
|
288
289
|
$ hereya run -w uat -- node index.js
|
|
289
290
|
```
|
|
290
291
|
|
|
291
|
-
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
292
|
+
_See code: [src/commands/run/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/run/index.ts)_
|
|
293
|
+
|
|
294
|
+
## `hereya unbootstrap INFRASTRUCTURETYPE`
|
|
295
|
+
|
|
296
|
+
Uninstall hereya resources deployed with bootstrap command.
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
USAGE
|
|
300
|
+
$ hereya unbootstrap INFRASTRUCTURETYPE [-f]
|
|
301
|
+
|
|
302
|
+
ARGUMENTS
|
|
303
|
+
INFRASTRUCTURETYPE infrastructure to unbootstrap. Options are local, aws
|
|
304
|
+
|
|
305
|
+
FLAGS
|
|
306
|
+
-f, --force try to delete hereya resources even if not deployed
|
|
307
|
+
|
|
308
|
+
DESCRIPTION
|
|
309
|
+
Uninstall hereya resources deployed with bootstrap command.
|
|
310
|
+
|
|
311
|
+
EXAMPLES
|
|
312
|
+
$ hereya unbootstrap aws
|
|
313
|
+
|
|
314
|
+
$ hereya unbootstrap local
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
_See code: [src/commands/unbootstrap/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/unbootstrap/index.ts)_
|
|
292
318
|
|
|
293
319
|
## `hereya undeploy`
|
|
294
320
|
|
|
@@ -309,7 +335,7 @@ EXAMPLES
|
|
|
309
335
|
$ hereya undeploy
|
|
310
336
|
```
|
|
311
337
|
|
|
312
|
-
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
338
|
+
_See code: [src/commands/undeploy/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/undeploy/index.ts)_
|
|
313
339
|
|
|
314
340
|
## `hereya up`
|
|
315
341
|
|
|
@@ -331,7 +357,7 @@ EXAMPLES
|
|
|
331
357
|
$ hereya up
|
|
332
358
|
```
|
|
333
359
|
|
|
334
|
-
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
360
|
+
_See code: [src/commands/up/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/up/index.ts)_
|
|
335
361
|
|
|
336
362
|
## `hereya workspace create NAME`
|
|
337
363
|
|
|
@@ -351,7 +377,7 @@ EXAMPLES
|
|
|
351
377
|
$ hereya workspace create dev
|
|
352
378
|
```
|
|
353
379
|
|
|
354
|
-
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
380
|
+
_See code: [src/commands/workspace/create/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/workspace/create/index.ts)_
|
|
355
381
|
|
|
356
382
|
## `hereya workspace delete NAME`
|
|
357
383
|
|
|
@@ -371,7 +397,7 @@ EXAMPLES
|
|
|
371
397
|
$ hereya workspace delete dev
|
|
372
398
|
```
|
|
373
399
|
|
|
374
|
-
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
400
|
+
_See code: [src/commands/workspace/delete/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/workspace/delete/index.ts)_
|
|
375
401
|
|
|
376
402
|
## `hereya workspace env [NAME]`
|
|
377
403
|
|
|
@@ -397,7 +423,7 @@ EXAMPLES
|
|
|
397
423
|
$ hereya workspace env myEnv -w dev
|
|
398
424
|
```
|
|
399
425
|
|
|
400
|
-
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
426
|
+
_See code: [src/commands/workspace/env/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/workspace/env/index.ts)_
|
|
401
427
|
|
|
402
428
|
## `hereya workspace install PACKAGE`
|
|
403
429
|
|
|
@@ -423,7 +449,7 @@ EXAMPLES
|
|
|
423
449
|
$ hereya workspace install hereya/aws-cognito
|
|
424
450
|
```
|
|
425
451
|
|
|
426
|
-
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
452
|
+
_See code: [src/commands/workspace/install/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/workspace/install/index.ts)_
|
|
427
453
|
|
|
428
454
|
## `hereya workspace uninstall PACKAGE`
|
|
429
455
|
|
|
@@ -449,5 +475,5 @@ EXAMPLES
|
|
|
449
475
|
$ hereya workspace uninstall hereya/aws-cognito
|
|
450
476
|
```
|
|
451
477
|
|
|
452
|
-
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.
|
|
478
|
+
_See code: [src/commands/workspace/uninstall/index.ts](https://github.com/hereya/hereya-cli/blob/v0.8.0/src/commands/workspace/uninstall/index.ts)_
|
|
453
479
|
<!-- commandsstop -->
|
package/dist/backend/common.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface Backend {
|
|
|
4
4
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
5
5
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
6
6
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
7
|
+
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
|
7
8
|
getState(input: GetStateInput): Promise<GetStateOutput>;
|
|
8
9
|
getWorkspace(workspace: string): Promise<GetWorkspaceOutput>;
|
|
9
10
|
getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
|
|
@@ -124,3 +125,15 @@ export type DeleteWorkspaceOutput = {
|
|
|
124
125
|
reason: string;
|
|
125
126
|
success: false;
|
|
126
127
|
};
|
|
128
|
+
export type GetProvisioningIdInput = {
|
|
129
|
+
packageCanonicalName: string;
|
|
130
|
+
project?: string;
|
|
131
|
+
workspace?: string;
|
|
132
|
+
};
|
|
133
|
+
export type GetProvisioningIdOutput = {
|
|
134
|
+
id: string;
|
|
135
|
+
success: true;
|
|
136
|
+
} | {
|
|
137
|
+
reason: string;
|
|
138
|
+
success: false;
|
|
139
|
+
};
|
package/dist/backend/local.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Config } from '../lib/config/common.js';
|
|
2
|
-
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput } from './common.js';
|
|
2
|
+
import { AddPackageToWorkspaceInput, AddPackageToWorkspaceOutput, Backend, CreateWorkspaceInput, CreateWorkspaceOutput, DeleteWorkspaceInput, DeleteWorkspaceOutput, GetProvisioningIdInput, GetProvisioningIdOutput, GetStateInput, GetStateOutput, GetWorkspaceEnvInput, GetWorkspaceEnvOutput, GetWorkspaceOutput, InitProjectInput, InitProjectOutput, RemovePackageFromWorkspaceInput, RemovePackageFromWorkspaceOutput } from './common.js';
|
|
3
3
|
export declare class LocalBackend implements Backend {
|
|
4
4
|
addPackageToWorkspace(input: AddPackageToWorkspaceInput): Promise<AddPackageToWorkspaceOutput>;
|
|
5
5
|
createWorkspace(input: CreateWorkspaceInput): Promise<CreateWorkspaceOutput>;
|
|
6
6
|
deleteWorkspace(input: DeleteWorkspaceInput): Promise<DeleteWorkspaceOutput>;
|
|
7
|
+
getProvisioningId(input: GetProvisioningIdInput): Promise<GetProvisioningIdOutput>;
|
|
7
8
|
getState(input: GetStateInput): Promise<GetStateOutput>;
|
|
8
9
|
getWorkspace(workspace: string): Promise<GetWorkspaceOutput>;
|
|
9
10
|
getWorkspaceEnv(input: GetWorkspaceEnvInput): Promise<GetWorkspaceEnvOutput>;
|
package/dist/backend/local.js
CHANGED
|
@@ -115,6 +115,15 @@ export class LocalBackend {
|
|
|
115
115
|
success: true,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
+
async getProvisioningId(input) {
|
|
119
|
+
const id = ((input.project || input.workspace) ? [input.project, input.workspace, input.packageCanonicalName] : [input.packageCanonicalName])
|
|
120
|
+
.filter(Boolean).join('')
|
|
121
|
+
.replaceAll(/[^\dA-Za-z]/g, '');
|
|
122
|
+
return {
|
|
123
|
+
id,
|
|
124
|
+
success: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
118
127
|
async getState(input) {
|
|
119
128
|
const projectStatePath = await this.getProjectStatePath(input.project);
|
|
120
129
|
const { data, found } = await load(projectStatePath);
|
|
@@ -3,7 +3,7 @@ import { getInfrastructure } from '../../infrastructure/index.js';
|
|
|
3
3
|
export default class Bootstrap extends Command {
|
|
4
4
|
static args = {
|
|
5
5
|
infrastructureType: Args.string({
|
|
6
|
-
description: 'infrastructure to bootstrap. Options are local, aws
|
|
6
|
+
description: 'infrastructure to bootstrap. Options are local, aws',
|
|
7
7
|
required: true
|
|
8
8
|
})
|
|
9
9
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class Unbootstrap extends Command {
|
|
3
|
+
static args: {
|
|
4
|
+
infrastructureType: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
|
|
5
|
+
};
|
|
6
|
+
static description: string;
|
|
7
|
+
static examples: string[];
|
|
8
|
+
static flags: {
|
|
9
|
+
force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
+
import { getInfrastructure } from '../../infrastructure/index.js';
|
|
3
|
+
export default class Unbootstrap extends Command {
|
|
4
|
+
static args = {
|
|
5
|
+
infrastructureType: Args.string({
|
|
6
|
+
description: 'infrastructure to unbootstrap. Options are local, aws',
|
|
7
|
+
required: true
|
|
8
|
+
})
|
|
9
|
+
};
|
|
10
|
+
static description = 'Uninstall hereya resources deployed with bootstrap command.';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> <%= command.id %> aws',
|
|
13
|
+
'<%= config.bin %> <%= command.id %> local',
|
|
14
|
+
];
|
|
15
|
+
static flags = {
|
|
16
|
+
force: Flags.boolean({ char: 'f', description: 'try to delete hereya resources even if not deployed' }),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { args, flags } = await this.parse(Unbootstrap);
|
|
20
|
+
const infrastructure$ = getInfrastructure({ type: args.infrastructureType });
|
|
21
|
+
if (!infrastructure$.supported) {
|
|
22
|
+
this.warn(infrastructure$.reason);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const { infrastructure } = infrastructure$;
|
|
26
|
+
await infrastructure.unbootstrap({ force: flags.force });
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/iac/terraform.js
CHANGED
|
@@ -31,12 +31,15 @@ export class Terraform {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
async destroy(input) {
|
|
34
|
-
const applyOutput = await this.apply(input);
|
|
35
|
-
if (!applyOutput.success) {
|
|
36
|
-
return applyOutput;
|
|
37
|
-
}
|
|
38
|
-
const { env } = applyOutput;
|
|
39
34
|
try {
|
|
35
|
+
runShell('terraform', ['init'], {
|
|
36
|
+
directory: input.pkgPath,
|
|
37
|
+
env: {
|
|
38
|
+
...input.env,
|
|
39
|
+
...mapObject(input.parameters ?? {}, (key, value) => [`TF_VAR_${key}`, value])
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const env = await this.getEnv(input.pkgPath);
|
|
40
43
|
runShell('terraform', ['destroy', '-auto-approve'], {
|
|
41
44
|
directory: input.pkgPath,
|
|
42
45
|
env: {
|
|
@@ -6,6 +6,7 @@ export declare class AwsInfrastructure implements Infrastructure {
|
|
|
6
6
|
provision(input: ProvisionInput): Promise<ProvisionOutput>;
|
|
7
7
|
resolveEnv(input: ResolveEnvInput): Promise<ResolveEnvOutput>;
|
|
8
8
|
saveEnv(input: SaveEnvInput): Promise<SaveEnvOutput>;
|
|
9
|
+
unbootstrap(_: BootstrapInput): Promise<void>;
|
|
9
10
|
undeploy(input: UndeployInput): Promise<UndeployOutput>;
|
|
10
11
|
private getEnv;
|
|
11
12
|
private getFilesToUpload;
|
|
@@ -13,7 +13,7 @@ import { fileExists, getAnyPath } from '../lib/filesystem.js';
|
|
|
13
13
|
import { objectToBase64 } from '../lib/object-utils.js';
|
|
14
14
|
import { runShell } from '../lib/shell.js';
|
|
15
15
|
import { InfrastructureType } from './common.js';
|
|
16
|
-
import { provisionPackage } from './index.js';
|
|
16
|
+
import { destroyPackage, provisionPackage } from './index.js';
|
|
17
17
|
export class AwsInfrastructure {
|
|
18
18
|
async bootstrap(_) {
|
|
19
19
|
const stsClient = new STSClient({});
|
|
@@ -129,6 +129,23 @@ export class AwsInfrastructure {
|
|
|
129
129
|
return { reason: error.message, success: false };
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
async unbootstrap(_) {
|
|
133
|
+
const ssmClient = new SSMClient({});
|
|
134
|
+
const key = '/hereya-bootstrap/config';
|
|
135
|
+
try {
|
|
136
|
+
await ssmClient.send(new DeleteParameterCommand({
|
|
137
|
+
Name: key,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
console.log(`Could not delete parameter "${key}": ${error.message}. Continuing with unbootstrap...`);
|
|
142
|
+
}
|
|
143
|
+
const bootstrapPackage = 'hereya/bootstrap-aws-stack';
|
|
144
|
+
const output = await destroyPackage({ package: bootstrapPackage });
|
|
145
|
+
if (!output.success) {
|
|
146
|
+
throw new Error(output.reason);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
132
149
|
async undeploy(input) {
|
|
133
150
|
let files = [];
|
|
134
151
|
let s3Bucket = '';
|
|
@@ -12,6 +12,7 @@ export interface Infrastructure {
|
|
|
12
12
|
provision(input: ProvisionInput): Promise<ProvisionOutput>;
|
|
13
13
|
resolveEnv(input: ResolveEnvInput): Promise<ResolveEnvOutput>;
|
|
14
14
|
saveEnv(input: SaveEnvInput): Promise<SaveEnvOutput>;
|
|
15
|
+
unbootstrap(input: BootstrapInput): Promise<void>;
|
|
15
16
|
undeploy(input: UndeployInput): Promise<UndeployOutput>;
|
|
16
17
|
}
|
|
17
18
|
export type BootstrapInput = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getBackend } from '../backend/index.js';
|
|
1
2
|
import { resolvePackage } from '../lib/package/index.js';
|
|
2
3
|
import { AwsInfrastructure } from './aws.js';
|
|
3
4
|
import { InfrastructureType } from './common.js';
|
|
@@ -41,13 +42,21 @@ export async function destroyPackage(input) {
|
|
|
41
42
|
return { env: {}, metadata, success: true };
|
|
42
43
|
}
|
|
43
44
|
const { infrastructure } = infrastructure$;
|
|
45
|
+
const backend = await getBackend();
|
|
46
|
+
const id$ = await backend.getProvisioningId({
|
|
47
|
+
packageCanonicalName: canonicalName,
|
|
48
|
+
project: input.project,
|
|
49
|
+
workspace: input.workspace
|
|
50
|
+
});
|
|
51
|
+
if (!id$.success) {
|
|
52
|
+
return { reason: id$.reason, success: false };
|
|
53
|
+
}
|
|
54
|
+
const { id } = id$;
|
|
44
55
|
const destroyOutput = metadata.deploy ? await infrastructure.undeploy({
|
|
45
56
|
canonicalName,
|
|
46
57
|
env: input.env,
|
|
47
58
|
iacType: metadata.iac,
|
|
48
|
-
id
|
|
49
|
-
.filter(Boolean).join('')
|
|
50
|
-
.replaceAll(/[^\dA-Za-z]/g, ''),
|
|
59
|
+
id,
|
|
51
60
|
parameters: input.parameters,
|
|
52
61
|
pkgName,
|
|
53
62
|
pkgUrl: packageUri,
|
|
@@ -57,9 +66,7 @@ export async function destroyPackage(input) {
|
|
|
57
66
|
canonicalName,
|
|
58
67
|
env: input.env,
|
|
59
68
|
iacType: metadata.iac,
|
|
60
|
-
id
|
|
61
|
-
.filter(Boolean).join('')
|
|
62
|
-
.replaceAll(/[^\dA-Za-z]/g, ''),
|
|
69
|
+
id,
|
|
63
70
|
parameters: input.parameters,
|
|
64
71
|
pkgName,
|
|
65
72
|
pkgUrl: packageUri,
|
|
@@ -67,6 +74,17 @@ export async function destroyPackage(input) {
|
|
|
67
74
|
if (!destroyOutput.success) {
|
|
68
75
|
return { reason: destroyOutput.reason, success: false };
|
|
69
76
|
}
|
|
77
|
+
const dependencies = metadata.dependencies ?? {};
|
|
78
|
+
const depsOutput = await Promise.all(Object.entries(dependencies).map(async ([depName]) => destroyPackage({
|
|
79
|
+
...input,
|
|
80
|
+
package: depName,
|
|
81
|
+
})));
|
|
82
|
+
if (!depsOutput.every(output => output.success)) {
|
|
83
|
+
return {
|
|
84
|
+
reason: `Failed to destroy all dependencies: ${depsOutput.filter(o => !o.success).map(o => !o.success && o.reason)}`,
|
|
85
|
+
success: false
|
|
86
|
+
};
|
|
87
|
+
}
|
|
70
88
|
return { env: destroyOutput.env, metadata, success: true };
|
|
71
89
|
}
|
|
72
90
|
export async function provisionPackage(input) {
|
|
@@ -83,14 +101,42 @@ export async function provisionPackage(input) {
|
|
|
83
101
|
console.log(`Skipping deployment of ${input.package}...`);
|
|
84
102
|
return { env: {}, metadata, success: true };
|
|
85
103
|
}
|
|
104
|
+
const dependencies = metadata.dependencies ?? {};
|
|
105
|
+
const depsOutput = await Promise.all(Object.entries(dependencies).map(async ([depName]) => provisionPackage({
|
|
106
|
+
...input,
|
|
107
|
+
package: depName,
|
|
108
|
+
})));
|
|
109
|
+
if (!depsOutput.every(output => output.success)) {
|
|
110
|
+
return {
|
|
111
|
+
reason: `Failed to provision all dependencies: ${depsOutput.filter(o => !o.success).map(o => !o.success && o.reason)}`,
|
|
112
|
+
success: false
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
let depsEnv = {};
|
|
116
|
+
for (const output of depsOutput) {
|
|
117
|
+
if (output.success) {
|
|
118
|
+
depsEnv = { ...depsEnv, ...output.env };
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return { reason: output.reason, success: false };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
86
124
|
const { infrastructure } = infrastructure$;
|
|
125
|
+
const backend = await getBackend();
|
|
126
|
+
const id$ = await backend.getProvisioningId({
|
|
127
|
+
packageCanonicalName: canonicalName,
|
|
128
|
+
project: input.project,
|
|
129
|
+
workspace: input.workspace
|
|
130
|
+
});
|
|
131
|
+
if (!id$.success) {
|
|
132
|
+
return { reason: id$.reason, success: false };
|
|
133
|
+
}
|
|
134
|
+
const { id } = id$;
|
|
87
135
|
const provisionOutput = metadata.deploy ? await infrastructure.deploy({
|
|
88
136
|
canonicalName,
|
|
89
|
-
env: input.env,
|
|
137
|
+
env: { ...input.env, ...depsEnv },
|
|
90
138
|
iacType: metadata.iac,
|
|
91
|
-
id
|
|
92
|
-
.filter(Boolean).join('')
|
|
93
|
-
.replaceAll(/[^\dA-Za-z]/g, ''),
|
|
139
|
+
id,
|
|
94
140
|
parameters: input.parameters,
|
|
95
141
|
pkgName,
|
|
96
142
|
pkgUrl: packageUri,
|
|
@@ -100,9 +146,7 @@ export async function provisionPackage(input) {
|
|
|
100
146
|
canonicalName,
|
|
101
147
|
env: input.env,
|
|
102
148
|
iacType: metadata.iac,
|
|
103
|
-
id
|
|
104
|
-
.filter(Boolean).join('')
|
|
105
|
-
.replaceAll(/[^\dA-Za-z]/g, ''),
|
|
149
|
+
id,
|
|
106
150
|
parameters: input.parameters,
|
|
107
151
|
pkgName,
|
|
108
152
|
pkgUrl: packageUri,
|
|
@@ -10,6 +10,7 @@ export declare class LocalInfrastructure implements Infrastructure {
|
|
|
10
10
|
value: string;
|
|
11
11
|
}>;
|
|
12
12
|
saveEnv(input: SaveEnvInput): Promise<SaveEnvOutput>;
|
|
13
|
+
unbootstrap(): Promise<void>;
|
|
13
14
|
undeploy(input: UndeployInput): Promise<UndeployOutput>;
|
|
14
15
|
private download;
|
|
15
16
|
private isNotEmpty;
|
|
@@ -64,6 +64,9 @@ export class LocalInfrastructure {
|
|
|
64
64
|
console.log(`Saving env to ${input.id}`);
|
|
65
65
|
return { success: true };
|
|
66
66
|
}
|
|
67
|
+
async unbootstrap() {
|
|
68
|
+
console.log('Unbootstrapping local infrastructure');
|
|
69
|
+
}
|
|
67
70
|
async undeploy(input) {
|
|
68
71
|
input.parameters = {
|
|
69
72
|
...input.parameters,
|
|
@@ -21,6 +21,7 @@ export type ResolvePackageOutput = {
|
|
|
21
21
|
reason: string;
|
|
22
22
|
};
|
|
23
23
|
export declare const PackageMetadata: z.ZodObject<{
|
|
24
|
+
dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
24
25
|
deploy: z.ZodOptional<z.ZodBoolean>;
|
|
25
26
|
iac: z.ZodNativeEnum<typeof IacType>;
|
|
26
27
|
infra: z.ZodNativeEnum<typeof InfrastructureType>;
|
|
@@ -38,6 +39,7 @@ export declare const PackageMetadata: z.ZodObject<{
|
|
|
38
39
|
}, "strip", z.ZodTypeAny, {
|
|
39
40
|
iac: IacType;
|
|
40
41
|
infra: InfrastructureType;
|
|
42
|
+
dependencies?: Record<string, string> | undefined;
|
|
41
43
|
deploy?: boolean | undefined;
|
|
42
44
|
onDeploy?: {
|
|
43
45
|
version: string;
|
|
@@ -47,6 +49,7 @@ export declare const PackageMetadata: z.ZodObject<{
|
|
|
47
49
|
}, {
|
|
48
50
|
iac: IacType;
|
|
49
51
|
infra: InfrastructureType;
|
|
52
|
+
dependencies?: Record<string, string> | undefined;
|
|
50
53
|
deploy?: boolean | undefined;
|
|
51
54
|
onDeploy?: {
|
|
52
55
|
version: string;
|
|
@@ -25,6 +25,9 @@ export async function resolvePackage(input) {
|
|
|
25
25
|
const metadataContent$ = metadataContentCandidates[0];
|
|
26
26
|
try {
|
|
27
27
|
const metadata = PackageMetadata.parse(yaml.parse(metadataContent$.content));
|
|
28
|
+
if (!metadata.deploy && metadata.dependencies) {
|
|
29
|
+
return { found: false, reason: 'Package has dependencies but is not a deploy package' };
|
|
30
|
+
}
|
|
28
31
|
if (input.isDeploying && metadata.onDeploy) {
|
|
29
32
|
return resolvePackage({ package: metadata.onDeploy.pkg });
|
|
30
33
|
}
|
|
@@ -48,6 +51,7 @@ export function getPackageCanonicalName(packageName) {
|
|
|
48
51
|
return packageName.replace('/', '-');
|
|
49
52
|
}
|
|
50
53
|
export const PackageMetadata = z.object({
|
|
54
|
+
dependencies: z.record(z.string()).optional(),
|
|
51
55
|
deploy: z.boolean().optional(),
|
|
52
56
|
iac: z.nativeEnum(IacType),
|
|
53
57
|
infra: z.nativeEnum(InfrastructureType),
|
package/oclif.manifest.json
CHANGED
|
@@ -48,45 +48,6 @@
|
|
|
48
48
|
"index.js"
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
|
-
"bootstrap": {
|
|
52
|
-
"aliases": [],
|
|
53
|
-
"args": {
|
|
54
|
-
"infrastructureType": {
|
|
55
|
-
"description": "infrastructure to bootstrap. Options are local, aws, azure, gcp",
|
|
56
|
-
"name": "infrastructureType",
|
|
57
|
-
"required": true
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"description": "Install necessary resources for hereya operations in an infrastructure.",
|
|
61
|
-
"examples": [
|
|
62
|
-
"<%= config.bin %> <%= command.id %> aws",
|
|
63
|
-
"<%= config.bin %> <%= command.id %> local"
|
|
64
|
-
],
|
|
65
|
-
"flags": {
|
|
66
|
-
"force": {
|
|
67
|
-
"char": "f",
|
|
68
|
-
"description": "redeploy hereya resources if already deployed",
|
|
69
|
-
"name": "force",
|
|
70
|
-
"allowNo": false,
|
|
71
|
-
"type": "boolean"
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
"hasDynamicHelp": false,
|
|
75
|
-
"hiddenAliases": [],
|
|
76
|
-
"id": "bootstrap",
|
|
77
|
-
"pluginAlias": "hereya-cli",
|
|
78
|
-
"pluginName": "hereya-cli",
|
|
79
|
-
"pluginType": "core",
|
|
80
|
-
"strict": true,
|
|
81
|
-
"enableJsonFlag": false,
|
|
82
|
-
"isESM": true,
|
|
83
|
-
"relativePath": [
|
|
84
|
-
"dist",
|
|
85
|
-
"commands",
|
|
86
|
-
"bootstrap",
|
|
87
|
-
"index.js"
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
51
|
"deploy": {
|
|
91
52
|
"aliases": [],
|
|
92
53
|
"args": {},
|
|
@@ -129,6 +90,45 @@
|
|
|
129
90
|
"index.js"
|
|
130
91
|
]
|
|
131
92
|
},
|
|
93
|
+
"bootstrap": {
|
|
94
|
+
"aliases": [],
|
|
95
|
+
"args": {
|
|
96
|
+
"infrastructureType": {
|
|
97
|
+
"description": "infrastructure to bootstrap. Options are local, aws",
|
|
98
|
+
"name": "infrastructureType",
|
|
99
|
+
"required": true
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"description": "Install necessary resources for hereya operations in an infrastructure.",
|
|
103
|
+
"examples": [
|
|
104
|
+
"<%= config.bin %> <%= command.id %> aws",
|
|
105
|
+
"<%= config.bin %> <%= command.id %> local"
|
|
106
|
+
],
|
|
107
|
+
"flags": {
|
|
108
|
+
"force": {
|
|
109
|
+
"char": "f",
|
|
110
|
+
"description": "redeploy hereya resources if already deployed",
|
|
111
|
+
"name": "force",
|
|
112
|
+
"allowNo": false,
|
|
113
|
+
"type": "boolean"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"hasDynamicHelp": false,
|
|
117
|
+
"hiddenAliases": [],
|
|
118
|
+
"id": "bootstrap",
|
|
119
|
+
"pluginAlias": "hereya-cli",
|
|
120
|
+
"pluginName": "hereya-cli",
|
|
121
|
+
"pluginType": "core",
|
|
122
|
+
"strict": true,
|
|
123
|
+
"enableJsonFlag": false,
|
|
124
|
+
"isESM": true,
|
|
125
|
+
"relativePath": [
|
|
126
|
+
"dist",
|
|
127
|
+
"commands",
|
|
128
|
+
"bootstrap",
|
|
129
|
+
"index.js"
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
132
|
"down": {
|
|
133
133
|
"aliases": [],
|
|
134
134
|
"args": {},
|
|
@@ -374,6 +374,45 @@
|
|
|
374
374
|
"index.js"
|
|
375
375
|
]
|
|
376
376
|
},
|
|
377
|
+
"unbootstrap": {
|
|
378
|
+
"aliases": [],
|
|
379
|
+
"args": {
|
|
380
|
+
"infrastructureType": {
|
|
381
|
+
"description": "infrastructure to unbootstrap. Options are local, aws",
|
|
382
|
+
"name": "infrastructureType",
|
|
383
|
+
"required": true
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
"description": "Uninstall hereya resources deployed with bootstrap command.",
|
|
387
|
+
"examples": [
|
|
388
|
+
"<%= config.bin %> <%= command.id %> aws",
|
|
389
|
+
"<%= config.bin %> <%= command.id %> local"
|
|
390
|
+
],
|
|
391
|
+
"flags": {
|
|
392
|
+
"force": {
|
|
393
|
+
"char": "f",
|
|
394
|
+
"description": "try to delete hereya resources even if not deployed",
|
|
395
|
+
"name": "force",
|
|
396
|
+
"allowNo": false,
|
|
397
|
+
"type": "boolean"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"hasDynamicHelp": false,
|
|
401
|
+
"hiddenAliases": [],
|
|
402
|
+
"id": "unbootstrap",
|
|
403
|
+
"pluginAlias": "hereya-cli",
|
|
404
|
+
"pluginName": "hereya-cli",
|
|
405
|
+
"pluginType": "core",
|
|
406
|
+
"strict": true,
|
|
407
|
+
"enableJsonFlag": false,
|
|
408
|
+
"isESM": true,
|
|
409
|
+
"relativePath": [
|
|
410
|
+
"dist",
|
|
411
|
+
"commands",
|
|
412
|
+
"unbootstrap",
|
|
413
|
+
"index.js"
|
|
414
|
+
]
|
|
415
|
+
},
|
|
377
416
|
"undeploy": {
|
|
378
417
|
"aliases": [],
|
|
379
418
|
"args": {},
|
|
@@ -744,5 +783,5 @@
|
|
|
744
783
|
]
|
|
745
784
|
}
|
|
746
785
|
},
|
|
747
|
-
"version": "0.
|
|
786
|
+
"version": "0.8.0"
|
|
748
787
|
}
|