terrafaker 0.0.6 → 0.0.8
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 +52 -213
- package/dist/commands/generate/file.js +4 -4
- package/dist/commands/generate/repo.js +22 -15
- package/dist/commands/gh/repo/clone.js +22 -0
- package/dist/commands/gh/repo/delete.js +22 -0
- package/dist/commands/glab/repo/clone.js +22 -0
- package/dist/commands/glab/repo/delete.js +20 -0
- package/dist/commands/util/format-psv.js +3 -3
- package/dist/commands/util/format-tsv.js +10 -10
- package/dist/commands/util/index.js +1 -1
- package/dist/constants/aws.js +82 -82
- package/dist/constants/azure.js +95 -95
- package/dist/constants/gcp.js +66 -66
- package/dist/enums/help-messages.js +2 -0
- package/dist/enums/providers.js +1 -1
- package/dist/enums/vcs-providers.js +5 -0
- package/dist/topics/generate.js +5 -0
- package/dist/topics/gh.js +6 -0
- package/dist/topics/glab.js +6 -0
- package/dist/types/repo.js +1 -0
- package/dist/utilities/base-command.js +45 -0
- package/dist/utilities/flags.js +22 -8
- package/dist/utilities/generators/aws-generator.js +11 -11
- package/dist/utilities/generators/azure-generator.js +7 -7
- package/dist/utilities/generators/file-generator.js +2 -2
- package/dist/utilities/generators/gcp-generator.js +13 -9
- package/dist/utilities/generators/generator-utils.js +5 -5
- package/dist/utilities/generators/provider-generator.js +26 -8
- package/dist/utilities/generators/repo-generator.js +5 -5
- package/dist/utilities/github.js +27 -4
- package/dist/utilities/gitlab.js +29 -0
- package/dist/utilities/repo-utils.js +6 -0
- package/dist/utilities/tag-utils.js +2 -2
- package/oclif.manifest.json +139 -100
- package/package.json +11 -5
- package/dist/commands/generate/index.js +0 -9
- package/dist/commands/gh/clone-repos.js +0 -46
- package/dist/commands/gh/delete-repos.js +0 -41
- package/dist/commands/gh/index.js +0 -10
package/README.md
CHANGED
|
@@ -18,17 +18,53 @@ Obviously, you shouldn't use this tool to try to generate real production infras
|
|
|
18
18
|
- Generate git repos with multiple files (and optionally push them to GitHub)
|
|
19
19
|
- Bulk clone and delete generated repos by prefix
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
`terrafaker` can be used to randomly generate a file or repo of files like this:
|
|
22
|
+
|
|
23
|
+
```tf
|
|
24
|
+
provider "aws" {
|
|
25
|
+
region = "ap-northeast-1"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
resource "aws_instance" "awful_tan_squirrel" {
|
|
29
|
+
ami = "ami-11060228d352"
|
|
30
|
+
instance_type = "m8a.metal-48xl"
|
|
31
|
+
tags = {
|
|
32
|
+
Environment = "Dev"
|
|
33
|
+
Service = "service"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
resource "aws_lambda_function" "irresponsible_lavender_elephant" {
|
|
38
|
+
ami = "ami-3934ae468a90"
|
|
39
|
+
runtime = "python3.13"
|
|
40
|
+
handler = "exports.run"
|
|
41
|
+
function_name = "run"
|
|
42
|
+
memory_size = 8960
|
|
43
|
+
role = "arn:aws:iam::0c23f323cc2f:mfa/gummy_lavender_fox"
|
|
44
|
+
tags = {
|
|
45
|
+
Environment = "Dev"
|
|
46
|
+
Service = "service"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Supported IAC providers and resources
|
|
52
|
+
|
|
53
|
+
- Terraform
|
|
54
|
+
- AWS
|
|
55
|
+
- Compute instances
|
|
56
|
+
- Functions
|
|
57
|
+
- GCP
|
|
58
|
+
- Compute instances
|
|
59
|
+
- Functions
|
|
60
|
+
- Azure
|
|
61
|
+
- Compute instances
|
|
62
|
+
- Functions
|
|
22
63
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
- Compute instances
|
|
28
|
-
- Functions
|
|
29
|
-
- Azure
|
|
30
|
-
- Compute instances
|
|
31
|
-
- Functions
|
|
64
|
+
### Supported VCS providers
|
|
65
|
+
|
|
66
|
+
- GitHub ([`brew install gh`](https://cli.github.com/))
|
|
67
|
+
- GitLab ([`brew install glab`](https://docs.gitlab.com/cli/))
|
|
32
68
|
|
|
33
69
|
## Issues
|
|
34
70
|
|
|
@@ -36,221 +72,24 @@ If you find a bug, feel free to [open up an issue](https://github.com/brandongre
|
|
|
36
72
|
|
|
37
73
|
If you would like to see a feature, and it isn't [already documented](https://github.com/brandongregoryscott/terrafaker/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement), feel free to open up a new issue and describe the desired behavior.
|
|
38
74
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* [Usage](#usage)
|
|
43
|
-
* [Commands](#commands)
|
|
44
|
-
<!-- tocstop -->
|
|
75
|
+
- [terrafaker](#terrafaker)
|
|
76
|
+
- [Usage](#usage)
|
|
77
|
+
- [Commands](./COMMANDS.md)
|
|
45
78
|
|
|
46
79
|
# Usage
|
|
47
80
|
|
|
48
81
|
<!-- usage -->
|
|
82
|
+
|
|
49
83
|
```sh-session
|
|
50
84
|
$ npm install -g terrafaker
|
|
51
85
|
$ terrafaker COMMAND
|
|
52
86
|
running command...
|
|
53
87
|
$ terrafaker (--version)
|
|
54
|
-
terrafaker/0.0.
|
|
88
|
+
terrafaker/0.0.8 darwin-arm64 node-v24.8.0
|
|
55
89
|
$ terrafaker --help [COMMAND]
|
|
56
90
|
USAGE
|
|
57
91
|
$ terrafaker COMMAND
|
|
58
92
|
...
|
|
59
93
|
```
|
|
60
|
-
<!-- usagestop -->
|
|
61
|
-
|
|
62
|
-
# Commands
|
|
63
|
-
|
|
64
|
-
<!-- commands -->
|
|
65
|
-
* [`terrafaker generate file`](#terrafaker-generate-file)
|
|
66
|
-
* [`terrafaker generate repo`](#terrafaker-generate-repo)
|
|
67
|
-
* [`terrafaker gh clone-repos`](#terrafaker-gh-clone-repos)
|
|
68
|
-
* [`terrafaker gh delete-repos`](#terrafaker-gh-delete-repos)
|
|
69
|
-
* [`terrafaker help [COMMAND]`](#terrafaker-help-command)
|
|
70
|
-
|
|
71
|
-
## `terrafaker generate file`
|
|
72
|
-
|
|
73
|
-
Generates a terraform file.
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
USAGE
|
|
77
|
-
$ terrafaker generate file [--chaos-tags | --tags <value> | --no-tags] [-f] [--name <value>] [--provider
|
|
78
|
-
aws|gcp|azure] [-q] [--resource-count <value>]
|
|
79
|
-
|
|
80
|
-
FLAGS
|
|
81
|
-
-f, --[no-]format
|
|
82
|
-
Format the output terraform files. Requires `terraform` to be in your $PATH.
|
|
83
|
-
|
|
84
|
-
-q, --quiet
|
|
85
|
-
Suppress the logging output.
|
|
86
|
-
|
|
87
|
-
--chaos-tags
|
|
88
|
-
Generate random tag keys & values
|
|
89
|
-
|
|
90
|
-
--name=<value>
|
|
91
|
-
Name for the generated file, which must end in .tf
|
|
92
|
-
|
|
93
|
-
--no-tags
|
|
94
|
-
Disable any tag generation
|
|
95
|
-
|
|
96
|
-
--provider=<option>
|
|
97
|
-
Cloud provider to generate resources for
|
|
98
|
-
<options: aws|gcp|azure>
|
|
99
|
-
|
|
100
|
-
--resource-count=<value>
|
|
101
|
-
[default: 3] Number of resources per file to generate
|
|
102
|
-
|
|
103
|
-
--tags=<value>
|
|
104
|
-
[default: Environment:Dev,Service:service] Custom tags to use for generated resources. Should be a comma-separated
|
|
105
|
-
list of tag names to generate random values for, or tag names with values delimited by a colon.
|
|
106
|
-
|
|
107
|
-
Examples:
|
|
108
|
-
|
|
109
|
-
Specify just tag keys to have a random value generated.
|
|
110
|
-
--tags Service,Team → {"Service":"(random value)","Team":"(random value)"}
|
|
111
|
-
|
|
112
|
-
Specify value for a key with the : delimiter. This can be mixed with just keys that are randomly generated.
|
|
113
|
-
--tags Service:web-app,Team → {"Service":"web-app","Team":"(random value)"}
|
|
114
|
-
--tags Service:web-app,Team:core → {"Service":"web-app","Team":"core"}
|
|
115
|
-
|
|
116
|
-
When specifying a key or value that has a space in it, the entire tag string needs to be quoted.
|
|
117
|
-
--tags "Service:my awesome web app,Team Name:The Core Team" → {"Service":"my awesome web app","Team Name":"The Core
|
|
118
|
-
Team"}
|
|
119
|
-
|
|
120
|
-
DESCRIPTION
|
|
121
|
-
Generates a terraform file.
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
_See code: [src/commands/generate/file.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.6/src/commands/generate/file.ts)_
|
|
125
|
-
|
|
126
|
-
## `terrafaker generate repo`
|
|
127
|
-
|
|
128
|
-
Generates repo(s) with multiple terraform files.
|
|
129
|
-
|
|
130
|
-
```
|
|
131
|
-
USAGE
|
|
132
|
-
$ terrafaker generate repo [--chaos-tags | --tags <value> | --no-tags] [--count <value>] [--create-remote]
|
|
133
|
-
[--directory <value>] [--file-count <value>] [-f] [--prefix <value>] [--provider aws|gcp|azure] [--public] [-q]
|
|
134
|
-
[--resource-count <value>]
|
|
135
|
-
|
|
136
|
-
FLAGS
|
|
137
|
-
-f, --[no-]format
|
|
138
|
-
Format the output terraform files. Requires `terraform` to be in your $PATH.
|
|
139
|
-
|
|
140
|
-
-q, --quiet
|
|
141
|
-
Suppress the logging output.
|
|
142
|
-
|
|
143
|
-
--chaos-tags
|
|
144
|
-
Generate random tag keys & values
|
|
145
|
-
|
|
146
|
-
--count=<value>
|
|
147
|
-
[default: 1] Number of repos to generate
|
|
148
|
-
|
|
149
|
-
--create-remote
|
|
150
|
-
Create and push a remote GitHub repo. Requires the `gh` CLI to be installed. To install, run `brew install gh`.
|
|
151
|
-
|
|
152
|
-
--directory=<value>
|
|
153
|
-
[default: .] Directory to generate the repo(s) in
|
|
154
|
-
|
|
155
|
-
--file-count=<value>
|
|
156
|
-
[default: 3] Number of files per repo to generate
|
|
157
|
-
|
|
158
|
-
--no-tags
|
|
159
|
-
Disable any tag generation
|
|
160
|
-
|
|
161
|
-
--prefix=<value>
|
|
162
|
-
[default: tf_] Prefix for repo names, useful for quickly identifying generated content
|
|
163
|
-
|
|
164
|
-
--provider=<option>
|
|
165
|
-
Cloud provider to generate resources for
|
|
166
|
-
<options: aws|gcp|azure>
|
|
167
|
-
|
|
168
|
-
--public
|
|
169
|
-
Whether the remote repo(s) created are public.
|
|
170
|
-
|
|
171
|
-
--resource-count=<value>
|
|
172
|
-
[default: 3] Number of resources per file to generate
|
|
173
|
-
|
|
174
|
-
--tags=<value>
|
|
175
|
-
[default: Environment:Dev,Service:service] Custom tags to use for generated resources. Should be a comma-separated
|
|
176
|
-
list of tag names to generate random values for, or tag names with values delimited by a colon.
|
|
177
|
-
|
|
178
|
-
Examples:
|
|
179
|
-
|
|
180
|
-
Specify just tag keys to have a random value generated.
|
|
181
|
-
--tags Service,Team → {"Service":"(random value)","Team":"(random value)"}
|
|
182
|
-
|
|
183
|
-
Specify value for a key with the : delimiter. This can be mixed with just keys that are randomly generated.
|
|
184
|
-
--tags Service:web-app,Team → {"Service":"web-app","Team":"(random value)"}
|
|
185
|
-
--tags Service:web-app,Team:core → {"Service":"web-app","Team":"core"}
|
|
186
|
-
|
|
187
|
-
When specifying a key or value that has a space in it, the entire tag string needs to be quoted.
|
|
188
|
-
--tags "Service:my awesome web app,Team Name:The Core Team" → {"Service":"my awesome web app","Team Name":"The Core
|
|
189
|
-
Team"}
|
|
190
|
-
|
|
191
|
-
DESCRIPTION
|
|
192
|
-
Generates repo(s) with multiple terraform files.
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
_See code: [src/commands/generate/repo.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.6/src/commands/generate/repo.ts)_
|
|
196
|
-
|
|
197
|
-
## `terrafaker gh clone-repos`
|
|
198
|
-
|
|
199
|
-
Clones repos from your Github account, useful for pulling down generated repos for manual modifications. Requires the `gh` CLI to be installed. To install, run `brew install gh`.
|
|
200
|
-
|
|
201
|
-
```
|
|
202
|
-
USAGE
|
|
203
|
-
$ terrafaker gh clone-repos --prefix <value> [--directory <value>]
|
|
204
|
-
|
|
205
|
-
FLAGS
|
|
206
|
-
--directory=<value> [default: .] Directory to clone the repo(s) in
|
|
207
|
-
--prefix=<value> (required) Prefix for the repos to clone, such as 'tf_'
|
|
208
|
-
|
|
209
|
-
DESCRIPTION
|
|
210
|
-
Clones repos from your Github account, useful for pulling down generated repos for manual modifications. Requires the
|
|
211
|
-
`gh` CLI to be installed. To install, run `brew install gh`.
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
_See code: [src/commands/gh/clone-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.6/src/commands/gh/clone-repos.ts)_
|
|
215
94
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
Deletes repos from your Github account, useful for cleaning up generated test data. Requires the `gh` CLI to be installed. To install, run `brew install gh`.
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
USAGE
|
|
222
|
-
$ terrafaker gh delete-repos --prefix <value>
|
|
223
|
-
|
|
224
|
-
FLAGS
|
|
225
|
-
--prefix=<value> (required) Prefix for the repos to delete, such as 'tf_'
|
|
226
|
-
|
|
227
|
-
DESCRIPTION
|
|
228
|
-
Deletes repos from your Github account, useful for cleaning up generated test data. Requires the `gh` CLI to be
|
|
229
|
-
installed. To install, run `brew install gh`.
|
|
230
|
-
|
|
231
|
-
If the deletion fails, you may need to refresh your CLI permissions with `gh auth refresh -s delete_repo`
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
_See code: [src/commands/gh/delete-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.6/src/commands/gh/delete-repos.ts)_
|
|
235
|
-
|
|
236
|
-
## `terrafaker help [COMMAND]`
|
|
237
|
-
|
|
238
|
-
Display help for terrafaker.
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
USAGE
|
|
242
|
-
$ terrafaker help [COMMAND...] [-n]
|
|
243
|
-
|
|
244
|
-
ARGUMENTS
|
|
245
|
-
[COMMAND...] Command to show help for.
|
|
246
|
-
|
|
247
|
-
FLAGS
|
|
248
|
-
-n, --nested-commands Include all nested commands in the output.
|
|
249
|
-
|
|
250
|
-
DESCRIPTION
|
|
251
|
-
Display help for terrafaker.
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
|
|
255
|
-
<!-- commandsstop -->
|
|
256
|
-
<!-- prettier-ignore-end -->
|
|
95
|
+
<!-- usagestop -->
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../utilities/base-command.js";
|
|
3
3
|
import { chaosTagsFlag, formatFlag, getTagsOption, noTagsFlag, providerFlag, quietFlag, resourceCountFlag, tagsFlag, } from "../../utilities/flags.js";
|
|
4
|
-
import { formatTfFileName, success } from "../../utilities/string-utils.js";
|
|
5
|
-
import { randomProvider } from "../../utilities/generators/generator-utils.js";
|
|
6
4
|
import { FileGenerator } from "../../utilities/generators/file-generator.js";
|
|
5
|
+
import { randomProvider } from "../../utilities/generators/generator-utils.js";
|
|
6
|
+
import { formatTfFileName, success } from "../../utilities/string-utils.js";
|
|
7
7
|
class File extends BaseCommand {
|
|
8
8
|
static description = "Generates a terraform file.";
|
|
9
9
|
static flags = {
|
|
@@ -20,15 +20,15 @@ class File extends BaseCommand {
|
|
|
20
20
|
};
|
|
21
21
|
async run() {
|
|
22
22
|
const { flags } = await this.parse(File);
|
|
23
|
-
const { name, quiet,
|
|
23
|
+
const { format, name, quiet, "resource-count": resourceCount } = flags;
|
|
24
24
|
const tags = getTagsOption(flags);
|
|
25
25
|
const provider = flags.provider ?? randomProvider();
|
|
26
26
|
const fileName = formatTfFileName(name ?? "main.tf");
|
|
27
27
|
FileGenerator.generate({
|
|
28
28
|
fileName,
|
|
29
|
+
format,
|
|
29
30
|
provider,
|
|
30
31
|
resourceCount,
|
|
31
|
-
format,
|
|
32
32
|
tags,
|
|
33
33
|
});
|
|
34
34
|
if (!quiet) {
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { BaseCommand } from "../../utilities/base-command.js";
|
|
4
|
-
import { chaosTagsFlag, formatFlag, getTagsOption, noTagsFlag, providerFlag, quietFlag, resourceCountFlag, tagsFlag, } from "../../utilities/flags.js";
|
|
5
|
-
import { $ } from "zx";
|
|
6
3
|
import { HelpMessages } from "../../enums/help-messages.js";
|
|
4
|
+
import { VcsProviders } from "../../enums/vcs-providers.js";
|
|
5
|
+
import { BaseCommand } from "../../utilities/base-command.js";
|
|
6
|
+
import { chaosTagsFlag, directoryFlag, formatFlag, getTagsOption, noTagsFlag, providerFlag, quietFlag, resourceCountFlag, tagsFlag, vcsProviderFlag, } from "../../utilities/flags.js";
|
|
7
7
|
import { RepoGenerator } from "../../utilities/generators/repo-generator.js";
|
|
8
|
+
import { GitHub } from "../../utilities/github.js";
|
|
9
|
+
import { GitLab } from "../../utilities/gitlab.js";
|
|
8
10
|
import { success } from "../../utilities/string-utils.js";
|
|
9
11
|
class Repo extends BaseCommand {
|
|
10
12
|
static description = "Generates repo(s) with multiple terraform files.";
|
|
11
13
|
static flags = {
|
|
12
14
|
"chaos-tags": chaosTagsFlag,
|
|
13
15
|
count: Flags.integer({
|
|
14
|
-
description: "Number of repos to generate",
|
|
15
16
|
default: 1,
|
|
17
|
+
description: "Number of repos to generate",
|
|
16
18
|
}),
|
|
17
19
|
"create-remote": Flags.boolean({
|
|
18
|
-
description: `Create and push a remote
|
|
19
|
-
}),
|
|
20
|
-
directory: Flags.string({
|
|
21
|
-
description: "Directory to generate the repo(s) in",
|
|
22
|
-
default: ".",
|
|
20
|
+
description: `Create and push a remote repo. ${HelpMessages.RequiresVcsCLI}`,
|
|
23
21
|
}),
|
|
22
|
+
directory: directoryFlag,
|
|
24
23
|
"file-count": Flags.integer({
|
|
25
|
-
description: "Number of files per repo to generate",
|
|
26
24
|
default: 3,
|
|
25
|
+
description: "Number of files per repo to generate",
|
|
27
26
|
}),
|
|
28
27
|
format: formatFlag,
|
|
29
28
|
"no-tags": noTagsFlag,
|
|
30
29
|
prefix: Flags.string({
|
|
31
|
-
description: "Prefix for repo names, useful for quickly identifying generated content",
|
|
32
30
|
default: "tf_",
|
|
31
|
+
description: "Prefix for repo names, useful for quickly identifying generated content",
|
|
33
32
|
}),
|
|
34
33
|
provider: providerFlag,
|
|
35
34
|
public: Flags.boolean({
|
|
36
|
-
description: "Whether the remote repo(s) created are public.",
|
|
37
35
|
default: false,
|
|
36
|
+
description: "Whether the remote repo(s) created are public.",
|
|
38
37
|
}),
|
|
39
38
|
quiet: quietFlag,
|
|
40
39
|
"resource-count": resourceCountFlag,
|
|
41
40
|
tags: tagsFlag(),
|
|
41
|
+
"vcs-provider": vcsProviderFlag,
|
|
42
42
|
};
|
|
43
43
|
async run() {
|
|
44
44
|
const { flags } = await this.parse(Repo);
|
|
45
|
-
const {
|
|
45
|
+
const { count, "create-remote": createRemote, "file-count": fileCount, format, prefix, public: isPublic, quiet, "resource-count": resourceCount, "vcs-provider": vcsProvider, } = flags;
|
|
46
46
|
const tags = getTagsOption(flags);
|
|
47
47
|
const provider = flags.provider;
|
|
48
48
|
const directory = path.resolve(process.cwd(), flags.directory);
|
|
@@ -53,12 +53,19 @@ class Repo extends BaseCommand {
|
|
|
53
53
|
format,
|
|
54
54
|
prefix,
|
|
55
55
|
provider,
|
|
56
|
-
resourceCount,
|
|
57
56
|
quiet,
|
|
57
|
+
resourceCount,
|
|
58
58
|
tags,
|
|
59
59
|
});
|
|
60
60
|
if (createRemote) {
|
|
61
|
-
|
|
61
|
+
switch (vcsProvider) {
|
|
62
|
+
case VcsProviders.GitHub:
|
|
63
|
+
await GitHub.pushRepo({ isPublic, path });
|
|
64
|
+
break;
|
|
65
|
+
case VcsProviders.GitLab:
|
|
66
|
+
await GitLab.pushRepo({ isPublic, path });
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
62
69
|
if (!quiet) {
|
|
63
70
|
this.log(success(`Successfully pushed '${name}'`));
|
|
64
71
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HelpMessages } from "../../../enums/help-messages.js";
|
|
2
|
+
import { BaseCommand } from "../../../utilities/base-command.js";
|
|
3
|
+
import { directoryFlag, requiredPrefixFlag } from "../../../utilities/flags.js";
|
|
4
|
+
import { GitHub } from "../../../utilities/github.js";
|
|
5
|
+
class Clone extends BaseCommand {
|
|
6
|
+
static description = `Clones repos from your GitHub account, useful for pulling down generated repos for manual modifications. ${HelpMessages.RequiresGhCli}`;
|
|
7
|
+
static flags = {
|
|
8
|
+
directory: directoryFlag,
|
|
9
|
+
prefix: requiredPrefixFlag,
|
|
10
|
+
};
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(Clone);
|
|
13
|
+
const { directory, prefix } = flags;
|
|
14
|
+
await this.cloneRepos({
|
|
15
|
+
cloneRepo: GitHub.cloneRepo,
|
|
16
|
+
directory,
|
|
17
|
+
listRepos: GitHub.listRepos,
|
|
18
|
+
prefix,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { Clone };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HelpMessages } from "../../../enums/help-messages.js";
|
|
2
|
+
import { BaseCommand } from "../../../utilities/base-command.js";
|
|
3
|
+
import { requiredPrefixFlag } from "../../../utilities/flags.js";
|
|
4
|
+
import { GitHub } from "../../../utilities/github.js";
|
|
5
|
+
class Delete extends BaseCommand {
|
|
6
|
+
static description = `Deletes repos from your GitHub account, useful for cleaning up generated test data. ${HelpMessages.RequiresGhCli}
|
|
7
|
+
|
|
8
|
+
If the deletion fails, you may need to refresh your CLI permissions with \`gh auth refresh -s delete_repo\``;
|
|
9
|
+
static flags = {
|
|
10
|
+
prefix: requiredPrefixFlag,
|
|
11
|
+
};
|
|
12
|
+
async run() {
|
|
13
|
+
const { flags } = await this.parse(Delete);
|
|
14
|
+
const { prefix } = flags;
|
|
15
|
+
await this.deleteRepos({
|
|
16
|
+
deleteRepo: GitHub.deleteRepo,
|
|
17
|
+
listRepos: GitHub.listRepos,
|
|
18
|
+
prefix,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { Delete };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HelpMessages } from "../../../enums/help-messages.js";
|
|
2
|
+
import { BaseCommand } from "../../../utilities/base-command.js";
|
|
3
|
+
import { directoryFlag, requiredPrefixFlag } from "../../../utilities/flags.js";
|
|
4
|
+
import { GitLab } from "../../../utilities/gitlab.js";
|
|
5
|
+
class Clone extends BaseCommand {
|
|
6
|
+
static description = `Clones repos from your GitLab account, useful for pulling down generated repos for manual modifications. ${HelpMessages.RequiresGlabCli}`;
|
|
7
|
+
static flags = {
|
|
8
|
+
directory: directoryFlag,
|
|
9
|
+
prefix: requiredPrefixFlag,
|
|
10
|
+
};
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(Clone);
|
|
13
|
+
const { directory, prefix } = flags;
|
|
14
|
+
await this.cloneRepos({
|
|
15
|
+
cloneRepo: GitLab.cloneRepo,
|
|
16
|
+
directory,
|
|
17
|
+
listRepos: GitLab.listRepos,
|
|
18
|
+
prefix,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { Clone };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HelpMessages } from "../../../enums/help-messages.js";
|
|
2
|
+
import { BaseCommand } from "../../../utilities/base-command.js";
|
|
3
|
+
import { requiredPrefixFlag } from "../../../utilities/flags.js";
|
|
4
|
+
import { GitLab } from "../../../utilities/gitlab.js";
|
|
5
|
+
class Delete extends BaseCommand {
|
|
6
|
+
static description = `Deletes repos from your GitLab account, useful for cleaning up generated test data. ${HelpMessages.RequiresGlabCli}`;
|
|
7
|
+
static flags = {
|
|
8
|
+
prefix: requiredPrefixFlag,
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(Delete);
|
|
12
|
+
const { prefix } = flags;
|
|
13
|
+
await this.deleteRepos({
|
|
14
|
+
deleteRepo: GitLab.deleteRepo,
|
|
15
|
+
listRepos: GitLab.listRepos,
|
|
16
|
+
prefix,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export { Delete };
|
|
@@ -4,15 +4,15 @@ import { BaseCommand } from "../../utilities/base-command.js";
|
|
|
4
4
|
import { stringifySingleLineArray } from "../../utilities/collection-utils.js";
|
|
5
5
|
const EXAMPLE_INSTANCE_TYPES = ["m5.large", "m5.xlarge", "m5.2xlarge"];
|
|
6
6
|
class FormatPsv extends BaseCommand {
|
|
7
|
-
static hidden = true;
|
|
8
|
-
static description = "Utility command for formatting a PSV (pipe-separated value) into an array or object with array values. Primarily used for parsing data from the AWS docs.";
|
|
9
7
|
static args = {
|
|
10
8
|
psv: Args.string({
|
|
11
|
-
required: true,
|
|
12
9
|
description: `Pipe-separated value to format into a string array, i.e. '${EXAMPLE_INSTANCE_TYPES.join(" | ")}'.
|
|
13
10
|
If the string is multiple lines, it will be formatted into an object where the key is the first column before a tab, i.e. 'M5\t${EXAMPLE_INSTANCE_TYPES.join(" | ")}'`,
|
|
11
|
+
required: true,
|
|
14
12
|
}),
|
|
15
13
|
};
|
|
14
|
+
static description = "Utility command for formatting a PSV (pipe-separated value) into an array or object with array values. Primarily used for parsing data from the AWS docs.";
|
|
15
|
+
static hidden = true;
|
|
16
16
|
async run() {
|
|
17
17
|
const { args } = await this.parse(FormatPsv);
|
|
18
18
|
const { psv } = args;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { compact } from "lodash-es";
|
|
2
3
|
import { BaseCommand } from "../../utilities/base-command.js";
|
|
3
4
|
import { stringifySingleLineArray } from "../../utilities/collection-utils.js";
|
|
4
|
-
import { compact } from "lodash-es";
|
|
5
5
|
const EXAMPLE = `c4d-standard-2 2 7 No Up to 10 N/A`;
|
|
6
6
|
class FormatTsv extends BaseCommand {
|
|
7
|
-
static
|
|
7
|
+
static args = {
|
|
8
|
+
tsv: Args.string({
|
|
9
|
+
description: `Tab-separated value to format into a string array, i.e. '${EXAMPLE}'.
|
|
10
|
+
If the string is multiple lines (which it generally is), the specified column index from each line will be placed in the array.`,
|
|
11
|
+
required: true,
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
8
14
|
static description = "Utility command for formatting a TSV (tab-separated value) into an array. Primarily used for parsing data from the GCP docs.";
|
|
9
15
|
static flags = {
|
|
10
16
|
index: Flags.integer({
|
|
11
17
|
char: "i",
|
|
12
|
-
description: "Column index to pull from each line.",
|
|
13
18
|
default: 0,
|
|
19
|
+
description: "Column index to pull from each line.",
|
|
14
20
|
}),
|
|
15
21
|
};
|
|
16
|
-
static
|
|
17
|
-
tsv: Args.string({
|
|
18
|
-
required: true,
|
|
19
|
-
description: `Tab-separated value to format into a string array, i.e. '${EXAMPLE}'.
|
|
20
|
-
If the string is multiple lines (which it generally is), the specified column index from each line will be placed in the array.`,
|
|
21
|
-
}),
|
|
22
|
-
};
|
|
22
|
+
static hidden = true;
|
|
23
23
|
async run() {
|
|
24
24
|
const { args, flags } = await this.parse(FormatTsv);
|
|
25
25
|
const { index } = flags;
|