terrafaker 0.0.7 → 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 +9 -9
- package/dist/utilities/generators/azure-generator.js +5 -5
- package/dist/utilities/generators/file-generator.js +2 -2
- package/dist/utilities/generators/gcp-generator.js +8 -8
- package/dist/utilities/generators/generator-utils.js +5 -5
- package/dist/utilities/generators/provider-generator.js +7 -7
- 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
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import { FileGenerator } from "./file-generator.js";
|
|
3
|
-
import { randomMemorableSlug } from "./generator-utils.js";
|
|
4
3
|
import { $ } from "zx";
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
6
4
|
import { success } from "../string-utils.js";
|
|
5
|
+
import { FileGenerator } from "./file-generator.js";
|
|
6
|
+
import { randomMemorableSlug } from "./generator-utils.js";
|
|
7
7
|
class RepoGenerator {
|
|
8
8
|
static async generate(options) {
|
|
9
|
-
const {
|
|
9
|
+
const { fileCount = 3, format, prefix = "tf_", provider, quiet, resourceCount, tags, } = options;
|
|
10
10
|
const directory = path.resolve(process.cwd(), options.directory ?? ".");
|
|
11
11
|
const repoName = `${prefix}${randomMemorableSlug()}`;
|
|
12
12
|
const repoPath = path.join(directory, repoName);
|
|
@@ -16,9 +16,9 @@ class RepoGenerator {
|
|
|
16
16
|
for (let i = 0; i < fileCount; i++) {
|
|
17
17
|
FileGenerator.generate({
|
|
18
18
|
directory: repoPath,
|
|
19
|
+
format,
|
|
19
20
|
provider,
|
|
20
21
|
resourceCount,
|
|
21
|
-
format,
|
|
22
22
|
tags,
|
|
23
23
|
});
|
|
24
24
|
}
|
package/dist/utilities/github.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { $ } from "zx";
|
|
2
|
+
class GitHub {
|
|
3
|
+
static async cloneRepo(options) {
|
|
4
|
+
const { directory, repo } = options;
|
|
5
|
+
await $ `gh repo clone ${repo.fullName} ${directory}`;
|
|
6
|
+
}
|
|
7
|
+
static async deleteRepo(options) {
|
|
8
|
+
const { repo } = options;
|
|
9
|
+
await $ `gh repo delete ${repo.fullName} --yes`;
|
|
10
|
+
}
|
|
11
|
+
static async listRepos() {
|
|
12
|
+
const response = await $ `gh repo list --json name,nameWithOwner`;
|
|
13
|
+
const repos = JSON.parse(response.toString());
|
|
14
|
+
return normalizeRepos(repos);
|
|
15
|
+
}
|
|
16
|
+
static async pushRepo(options) {
|
|
17
|
+
const { isPublic, path } = options;
|
|
18
|
+
await $ `cd ${path} && gh repo create --source . ${isPublic ? "--public" : "--private"} --push`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function normalizeRepos(repos) {
|
|
22
|
+
return repos.map((repo) => ({
|
|
23
|
+
fullName: repo.nameWithOwner,
|
|
24
|
+
name: repo.name,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export { GitHub };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { $ } from "zx";
|
|
2
|
+
class GitLab {
|
|
3
|
+
static async cloneRepo(options) {
|
|
4
|
+
const { directory, repo } = options;
|
|
5
|
+
await $ `glab repo clone ${repo.fullName} ${directory}`;
|
|
6
|
+
}
|
|
7
|
+
static async deleteRepo(options) {
|
|
8
|
+
const { repo } = options;
|
|
9
|
+
await $ `glab repo delete ${repo.fullName} --yes`;
|
|
10
|
+
}
|
|
11
|
+
static async listRepos() {
|
|
12
|
+
const response = await $ `glab repo list --output json`;
|
|
13
|
+
const repos = JSON.parse(response.toString());
|
|
14
|
+
return normalizeRepos(repos);
|
|
15
|
+
}
|
|
16
|
+
static async pushRepo(options) {
|
|
17
|
+
const { isPublic, path } = options;
|
|
18
|
+
await $ `cd ${path} && glab repo create ${isPublic ? "--public" : "--private"} && git push --set-upstream origin main`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function normalizeRepos(repos) {
|
|
22
|
+
return repos
|
|
23
|
+
.filter((repo) => repo.marked_for_deletion_on == null)
|
|
24
|
+
.map((repo) => ({
|
|
25
|
+
fullName: repo.path_with_namespace,
|
|
26
|
+
name: repo.name,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
export { GitLab };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomMemorableSlug } from "./generators/generator-utils.js";
|
|
2
2
|
import { warn } from "./string-utils.js";
|
|
3
|
-
const
|
|
3
|
+
const parseTags = (tagString) => {
|
|
4
4
|
const csvTags = tagString.split(",").map((value) => value.trim());
|
|
5
5
|
const tags = csvTags.reduce((accumulated, csvTag) => {
|
|
6
6
|
const [tag, value] = csvTag.split(":");
|
|
@@ -15,4 +15,4 @@ const parseTagString = (tagString) => {
|
|
|
15
15
|
const stringifyTags = (tags) => Object.entries(tags)
|
|
16
16
|
.map(([key, value]) => `${key}:${value}`)
|
|
17
17
|
.join(",");
|
|
18
|
-
export {
|
|
18
|
+
export { parseTags, stringifyTags };
|
package/oclif.manifest.json
CHANGED
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"multiple": false,
|
|
47
47
|
"options": [
|
|
48
48
|
"aws",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"azure",
|
|
50
|
+
"gcp"
|
|
51
51
|
],
|
|
52
52
|
"type": "option"
|
|
53
53
|
},
|
|
@@ -93,27 +93,6 @@
|
|
|
93
93
|
"file.js"
|
|
94
94
|
]
|
|
95
95
|
},
|
|
96
|
-
"generate": {
|
|
97
|
-
"aliases": [],
|
|
98
|
-
"args": {},
|
|
99
|
-
"description": "Commands for generating terraform files.",
|
|
100
|
-
"flags": {},
|
|
101
|
-
"hasDynamicHelp": false,
|
|
102
|
-
"hidden": true,
|
|
103
|
-
"hiddenAliases": [],
|
|
104
|
-
"id": "generate",
|
|
105
|
-
"pluginAlias": "terrafaker",
|
|
106
|
-
"pluginName": "terrafaker",
|
|
107
|
-
"pluginType": "core",
|
|
108
|
-
"strict": true,
|
|
109
|
-
"isESM": true,
|
|
110
|
-
"relativePath": [
|
|
111
|
-
"dist",
|
|
112
|
-
"commands",
|
|
113
|
-
"generate",
|
|
114
|
-
"index.js"
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
96
|
"generate:repo": {
|
|
118
97
|
"aliases": [],
|
|
119
98
|
"args": {},
|
|
@@ -138,13 +117,13 @@
|
|
|
138
117
|
"type": "option"
|
|
139
118
|
},
|
|
140
119
|
"create-remote": {
|
|
141
|
-
"description": "Create and push a remote
|
|
120
|
+
"description": "Create and push a remote repo. Requires the `gh` or `glab` CLI to be installed. To install, run `brew install gh|glab`.",
|
|
142
121
|
"name": "create-remote",
|
|
143
122
|
"allowNo": false,
|
|
144
123
|
"type": "boolean"
|
|
145
124
|
},
|
|
146
125
|
"directory": {
|
|
147
|
-
"description": "Directory to
|
|
126
|
+
"description": "Directory to create the repo(s) in",
|
|
148
127
|
"name": "directory",
|
|
149
128
|
"default": ".",
|
|
150
129
|
"hasDynamicHelp": false,
|
|
@@ -191,8 +170,8 @@
|
|
|
191
170
|
"multiple": false,
|
|
192
171
|
"options": [
|
|
193
172
|
"aws",
|
|
194
|
-
"
|
|
195
|
-
"
|
|
173
|
+
"azure",
|
|
174
|
+
"gcp"
|
|
196
175
|
],
|
|
197
176
|
"type": "option"
|
|
198
177
|
},
|
|
@@ -227,6 +206,18 @@
|
|
|
227
206
|
"hasDynamicHelp": false,
|
|
228
207
|
"multiple": false,
|
|
229
208
|
"type": "option"
|
|
209
|
+
},
|
|
210
|
+
"vcs-provider": {
|
|
211
|
+
"description": "Remote version control system to interact with",
|
|
212
|
+
"name": "vcs-provider",
|
|
213
|
+
"default": "github",
|
|
214
|
+
"hasDynamicHelp": false,
|
|
215
|
+
"multiple": false,
|
|
216
|
+
"options": [
|
|
217
|
+
"github",
|
|
218
|
+
"gitlab"
|
|
219
|
+
],
|
|
220
|
+
"type": "option"
|
|
230
221
|
}
|
|
231
222
|
},
|
|
232
223
|
"hasDynamicHelp": false,
|
|
@@ -244,31 +235,21 @@
|
|
|
244
235
|
"repo.js"
|
|
245
236
|
]
|
|
246
237
|
},
|
|
247
|
-
"
|
|
238
|
+
"util:format-psv": {
|
|
248
239
|
"aliases": [],
|
|
249
|
-
"args": {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
"
|
|
254
|
-
"name": "directory",
|
|
255
|
-
"default": ".",
|
|
256
|
-
"hasDynamicHelp": false,
|
|
257
|
-
"multiple": false,
|
|
258
|
-
"type": "option"
|
|
259
|
-
},
|
|
260
|
-
"prefix": {
|
|
261
|
-
"description": "Prefix for the repos to clone, such as 'tf_'",
|
|
262
|
-
"name": "prefix",
|
|
263
|
-
"required": true,
|
|
264
|
-
"hasDynamicHelp": false,
|
|
265
|
-
"multiple": false,
|
|
266
|
-
"type": "option"
|
|
240
|
+
"args": {
|
|
241
|
+
"psv": {
|
|
242
|
+
"description": "Pipe-separated value to format into a string array, i.e. 'm5.large | m5.xlarge | m5.2xlarge'.\nIf 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\tm5.large | m5.xlarge | m5.2xlarge'",
|
|
243
|
+
"name": "psv",
|
|
244
|
+
"required": true
|
|
267
245
|
}
|
|
268
246
|
},
|
|
247
|
+
"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.",
|
|
248
|
+
"flags": {},
|
|
269
249
|
"hasDynamicHelp": false,
|
|
250
|
+
"hidden": true,
|
|
270
251
|
"hiddenAliases": [],
|
|
271
|
-
"id": "
|
|
252
|
+
"id": "util:format-psv",
|
|
272
253
|
"pluginAlias": "terrafaker",
|
|
273
254
|
"pluginName": "terrafaker",
|
|
274
255
|
"pluginType": "core",
|
|
@@ -277,49 +258,56 @@
|
|
|
277
258
|
"relativePath": [
|
|
278
259
|
"dist",
|
|
279
260
|
"commands",
|
|
280
|
-
"
|
|
281
|
-
"
|
|
261
|
+
"util",
|
|
262
|
+
"format-psv.js"
|
|
282
263
|
]
|
|
283
264
|
},
|
|
284
|
-
"
|
|
265
|
+
"util:format-tsv": {
|
|
285
266
|
"aliases": [],
|
|
286
|
-
"args": {
|
|
287
|
-
|
|
267
|
+
"args": {
|
|
268
|
+
"tsv": {
|
|
269
|
+
"description": "Tab-separated value to format into a string array, i.e. 'c4d-standard-2\t2\t7\tNo\tUp to 10\tN/A'.\nIf the string is multiple lines (which it generally is), the specified column index from each line will be placed in the array.",
|
|
270
|
+
"name": "tsv",
|
|
271
|
+
"required": true
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
"description": "Utility command for formatting a TSV (tab-separated value) into an array. Primarily used for parsing data from the GCP docs.",
|
|
288
275
|
"flags": {
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
276
|
+
"index": {
|
|
277
|
+
"char": "i",
|
|
278
|
+
"description": "Column index to pull from each line.",
|
|
279
|
+
"name": "index",
|
|
280
|
+
"default": 0,
|
|
293
281
|
"hasDynamicHelp": false,
|
|
294
282
|
"multiple": false,
|
|
295
283
|
"type": "option"
|
|
296
284
|
}
|
|
297
285
|
},
|
|
298
286
|
"hasDynamicHelp": false,
|
|
287
|
+
"hidden": true,
|
|
299
288
|
"hiddenAliases": [],
|
|
300
|
-
"id": "
|
|
289
|
+
"id": "util:format-tsv",
|
|
301
290
|
"pluginAlias": "terrafaker",
|
|
302
291
|
"pluginName": "terrafaker",
|
|
303
292
|
"pluginType": "core",
|
|
304
293
|
"strict": true,
|
|
305
|
-
"enableJsonFlag": false,
|
|
306
294
|
"isESM": true,
|
|
307
295
|
"relativePath": [
|
|
308
296
|
"dist",
|
|
309
297
|
"commands",
|
|
310
|
-
"
|
|
311
|
-
"
|
|
298
|
+
"util",
|
|
299
|
+
"format-tsv.js"
|
|
312
300
|
]
|
|
313
301
|
},
|
|
314
|
-
"
|
|
302
|
+
"util": {
|
|
315
303
|
"aliases": [],
|
|
316
304
|
"args": {},
|
|
317
|
-
"description": "
|
|
305
|
+
"description": "Miscellaneous utility commands.",
|
|
318
306
|
"flags": {},
|
|
319
307
|
"hasDynamicHelp": false,
|
|
320
308
|
"hidden": true,
|
|
321
309
|
"hiddenAliases": [],
|
|
322
|
-
"id": "
|
|
310
|
+
"id": "util",
|
|
323
311
|
"pluginAlias": "terrafaker",
|
|
324
312
|
"pluginName": "terrafaker",
|
|
325
313
|
"pluginType": "core",
|
|
@@ -328,25 +316,35 @@
|
|
|
328
316
|
"relativePath": [
|
|
329
317
|
"dist",
|
|
330
318
|
"commands",
|
|
331
|
-
"
|
|
319
|
+
"util",
|
|
332
320
|
"index.js"
|
|
333
321
|
]
|
|
334
322
|
},
|
|
335
|
-
"
|
|
323
|
+
"gh:repo:clone": {
|
|
336
324
|
"aliases": [],
|
|
337
|
-
"args": {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
"
|
|
325
|
+
"args": {},
|
|
326
|
+
"description": "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`.",
|
|
327
|
+
"flags": {
|
|
328
|
+
"directory": {
|
|
329
|
+
"description": "Directory to create the repo(s) in",
|
|
330
|
+
"name": "directory",
|
|
331
|
+
"default": ".",
|
|
332
|
+
"hasDynamicHelp": false,
|
|
333
|
+
"multiple": false,
|
|
334
|
+
"type": "option"
|
|
335
|
+
},
|
|
336
|
+
"prefix": {
|
|
337
|
+
"description": "Prefix for the repos, such as 'tf_'",
|
|
338
|
+
"name": "prefix",
|
|
339
|
+
"required": true,
|
|
340
|
+
"hasDynamicHelp": false,
|
|
341
|
+
"multiple": false,
|
|
342
|
+
"type": "option"
|
|
342
343
|
}
|
|
343
344
|
},
|
|
344
|
-
"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.",
|
|
345
|
-
"flags": {},
|
|
346
345
|
"hasDynamicHelp": false,
|
|
347
|
-
"hidden": true,
|
|
348
346
|
"hiddenAliases": [],
|
|
349
|
-
"id": "
|
|
347
|
+
"id": "gh:repo:clone",
|
|
350
348
|
"pluginAlias": "terrafaker",
|
|
351
349
|
"pluginName": "terrafaker",
|
|
352
350
|
"pluginType": "core",
|
|
@@ -355,35 +353,66 @@
|
|
|
355
353
|
"relativePath": [
|
|
356
354
|
"dist",
|
|
357
355
|
"commands",
|
|
358
|
-
"
|
|
359
|
-
"
|
|
356
|
+
"gh",
|
|
357
|
+
"repo",
|
|
358
|
+
"clone.js"
|
|
360
359
|
]
|
|
361
360
|
},
|
|
362
|
-
"
|
|
361
|
+
"gh:repo:delete": {
|
|
363
362
|
"aliases": [],
|
|
364
|
-
"args": {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"
|
|
363
|
+
"args": {},
|
|
364
|
+
"description": "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`.\n\nIf the deletion fails, you may need to refresh your CLI permissions with `gh auth refresh -s delete_repo`",
|
|
365
|
+
"flags": {
|
|
366
|
+
"prefix": {
|
|
367
|
+
"description": "Prefix for the repos, such as 'tf_'",
|
|
368
|
+
"name": "prefix",
|
|
369
|
+
"required": true,
|
|
370
|
+
"hasDynamicHelp": false,
|
|
371
|
+
"multiple": false,
|
|
372
|
+
"type": "option"
|
|
369
373
|
}
|
|
370
374
|
},
|
|
371
|
-
"
|
|
375
|
+
"hasDynamicHelp": false,
|
|
376
|
+
"hiddenAliases": [],
|
|
377
|
+
"id": "gh:repo:delete",
|
|
378
|
+
"pluginAlias": "terrafaker",
|
|
379
|
+
"pluginName": "terrafaker",
|
|
380
|
+
"pluginType": "core",
|
|
381
|
+
"strict": true,
|
|
382
|
+
"isESM": true,
|
|
383
|
+
"relativePath": [
|
|
384
|
+
"dist",
|
|
385
|
+
"commands",
|
|
386
|
+
"gh",
|
|
387
|
+
"repo",
|
|
388
|
+
"delete.js"
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
"glab:repo:clone": {
|
|
392
|
+
"aliases": [],
|
|
393
|
+
"args": {},
|
|
394
|
+
"description": "Clones repos from your GitLab account, useful for pulling down generated repos for manual modifications. Requires the `glab` CLI to be installed. To install, run `brew install glab`.",
|
|
372
395
|
"flags": {
|
|
373
|
-
"
|
|
374
|
-
"
|
|
375
|
-
"
|
|
376
|
-
"
|
|
377
|
-
"
|
|
396
|
+
"directory": {
|
|
397
|
+
"description": "Directory to create the repo(s) in",
|
|
398
|
+
"name": "directory",
|
|
399
|
+
"default": ".",
|
|
400
|
+
"hasDynamicHelp": false,
|
|
401
|
+
"multiple": false,
|
|
402
|
+
"type": "option"
|
|
403
|
+
},
|
|
404
|
+
"prefix": {
|
|
405
|
+
"description": "Prefix for the repos, such as 'tf_'",
|
|
406
|
+
"name": "prefix",
|
|
407
|
+
"required": true,
|
|
378
408
|
"hasDynamicHelp": false,
|
|
379
409
|
"multiple": false,
|
|
380
410
|
"type": "option"
|
|
381
411
|
}
|
|
382
412
|
},
|
|
383
413
|
"hasDynamicHelp": false,
|
|
384
|
-
"hidden": true,
|
|
385
414
|
"hiddenAliases": [],
|
|
386
|
-
"id": "
|
|
415
|
+
"id": "glab:repo:clone",
|
|
387
416
|
"pluginAlias": "terrafaker",
|
|
388
417
|
"pluginName": "terrafaker",
|
|
389
418
|
"pluginType": "core",
|
|
@@ -392,19 +421,28 @@
|
|
|
392
421
|
"relativePath": [
|
|
393
422
|
"dist",
|
|
394
423
|
"commands",
|
|
395
|
-
"
|
|
396
|
-
"
|
|
424
|
+
"glab",
|
|
425
|
+
"repo",
|
|
426
|
+
"clone.js"
|
|
397
427
|
]
|
|
398
428
|
},
|
|
399
|
-
"
|
|
429
|
+
"glab:repo:delete": {
|
|
400
430
|
"aliases": [],
|
|
401
431
|
"args": {},
|
|
402
|
-
"description": "
|
|
403
|
-
"flags": {
|
|
432
|
+
"description": "Deletes repos from your GitLab account, useful for cleaning up generated test data. Requires the `glab` CLI to be installed. To install, run `brew install glab`.",
|
|
433
|
+
"flags": {
|
|
434
|
+
"prefix": {
|
|
435
|
+
"description": "Prefix for the repos, such as 'tf_'",
|
|
436
|
+
"name": "prefix",
|
|
437
|
+
"required": true,
|
|
438
|
+
"hasDynamicHelp": false,
|
|
439
|
+
"multiple": false,
|
|
440
|
+
"type": "option"
|
|
441
|
+
}
|
|
442
|
+
},
|
|
404
443
|
"hasDynamicHelp": false,
|
|
405
|
-
"hidden": true,
|
|
406
444
|
"hiddenAliases": [],
|
|
407
|
-
"id": "
|
|
445
|
+
"id": "glab:repo:delete",
|
|
408
446
|
"pluginAlias": "terrafaker",
|
|
409
447
|
"pluginName": "terrafaker",
|
|
410
448
|
"pluginType": "core",
|
|
@@ -413,10 +451,11 @@
|
|
|
413
451
|
"relativePath": [
|
|
414
452
|
"dist",
|
|
415
453
|
"commands",
|
|
416
|
-
"
|
|
417
|
-
"
|
|
454
|
+
"glab",
|
|
455
|
+
"repo",
|
|
456
|
+
"delete.js"
|
|
418
457
|
]
|
|
419
458
|
}
|
|
420
459
|
},
|
|
421
|
-
"version": "0.0.
|
|
460
|
+
"version": "0.0.8"
|
|
422
461
|
}
|
package/package.json
CHANGED
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"@types/node": "24.10.3",
|
|
24
24
|
"eslint": "9.39.1",
|
|
25
25
|
"eslint-plugin-collation": "1.5.0",
|
|
26
|
+
"eslint-plugin-perfectionist": "5.3.1",
|
|
26
27
|
"eslint-plugin-vitest": "0.5.4",
|
|
28
|
+
"hcl2-parser": "1.0.3",
|
|
27
29
|
"oclif": "4.22.54",
|
|
28
30
|
"prettier": "3.6.1",
|
|
29
31
|
"shx": "0.3.4",
|
|
@@ -42,7 +44,11 @@
|
|
|
42
44
|
],
|
|
43
45
|
"homepage": "https://github.com/brandongregoryscott/terrafaker",
|
|
44
46
|
"keywords": [
|
|
45
|
-
"
|
|
47
|
+
"terraform",
|
|
48
|
+
"infrastructure",
|
|
49
|
+
"infra",
|
|
50
|
+
"infrastructure-as-code",
|
|
51
|
+
"faker"
|
|
46
52
|
],
|
|
47
53
|
"license": "Apache-2.0",
|
|
48
54
|
"main": "dist/index.js",
|
|
@@ -63,19 +69,19 @@
|
|
|
63
69
|
"scripts": {
|
|
64
70
|
"build": "npm run clean && tsc --project tsconfig.build.json",
|
|
65
71
|
"build:watch": "npm run clean && tsc --watch",
|
|
66
|
-
"clean": "shx rm -rf dist tsconfig.tsbuildinfo",
|
|
72
|
+
"clean": "shx rm -rf dist tsconfig.tsbuildinfo oclif.manifest.json",
|
|
67
73
|
"format": "prettier . --check",
|
|
68
74
|
"format:fix": "prettier . --write",
|
|
69
75
|
"generate:manifest": "oclif manifest",
|
|
70
|
-
"generate:readme": "oclif readme && prettier README.md --write",
|
|
76
|
+
"generate:readme": "oclif readme && oclif readme --readme-path COMMANDS.md && prettier {README,COMMANDS}.md --write",
|
|
71
77
|
"lint": "eslint",
|
|
72
78
|
"lint:fix": "eslint --fix",
|
|
73
79
|
"postbuild": "npm run generate:manifest && npm run generate:readme",
|
|
74
80
|
"prepack": "npm run build",
|
|
75
81
|
"test": "vitest",
|
|
76
|
-
"version": "npm run generate:readme && git add README.md"
|
|
82
|
+
"version": "npm run generate:readme && git add {README,COMMANDS}.md"
|
|
77
83
|
},
|
|
78
84
|
"type": "module",
|
|
79
85
|
"types": "dist/index.d.ts",
|
|
80
|
-
"version": "0.0.
|
|
86
|
+
"version": "0.0.8"
|
|
81
87
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../utilities/base-command.js";
|
|
2
|
-
class Generate extends BaseCommand {
|
|
3
|
-
static hidden = true;
|
|
4
|
-
static description = "Commands for generating terraform files.";
|
|
5
|
-
async run() {
|
|
6
|
-
await this.showHelp();
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export { Generate };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { confirm } from "@inquirer/prompts";
|
|
4
|
-
import { isEmpty } from "lodash-es";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { listRepos, stringifyRepos } from "../../utilities/github.js";
|
|
7
|
-
import { BaseCommand } from "../../utilities/base-command.js";
|
|
8
|
-
import { HelpMessages } from "../../enums/help-messages.js";
|
|
9
|
-
class CloneRepos extends BaseCommand {
|
|
10
|
-
static description = `Clones repos from your Github account, useful for pulling down generated repos for manual modifications. ${HelpMessages.RequiresGhCli}`;
|
|
11
|
-
static flags = {
|
|
12
|
-
directory: Flags.string({
|
|
13
|
-
description: "Directory to clone the repo(s) in",
|
|
14
|
-
default: ".",
|
|
15
|
-
}),
|
|
16
|
-
prefix: Flags.string({
|
|
17
|
-
description: "Prefix for the repos to clone, such as 'tf_'",
|
|
18
|
-
required: true,
|
|
19
|
-
}),
|
|
20
|
-
};
|
|
21
|
-
async run() {
|
|
22
|
-
const { flags } = await this.parse(CloneRepos);
|
|
23
|
-
const { prefix } = flags;
|
|
24
|
-
const allRepos = listRepos();
|
|
25
|
-
const repos = allRepos.filter((repo) => repo.name.startsWith(prefix));
|
|
26
|
-
if (isEmpty(repos)) {
|
|
27
|
-
this.log(`Repos found:\n${stringifyRepos(allRepos)}`);
|
|
28
|
-
this.log(`No repos found with prefix '${prefix}'`);
|
|
29
|
-
this.exit();
|
|
30
|
-
}
|
|
31
|
-
this.log(`Repos to clone:\n${stringifyRepos(repos)}`);
|
|
32
|
-
const confirmation = await confirm({
|
|
33
|
-
message: "Continue with cloning these repos?",
|
|
34
|
-
});
|
|
35
|
-
if (!confirmation) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
repos.forEach((repo) => {
|
|
39
|
-
const directory = path.resolve(process.cwd(), flags.directory, repo.name);
|
|
40
|
-
execSync(`gh repo clone ${repo.nameWithOwner} ${directory}`, {
|
|
41
|
-
stdio: "inherit",
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export { CloneRepos };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from "@oclif/core";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { confirm } from "@inquirer/prompts";
|
|
4
|
-
import { isEmpty } from "lodash-es";
|
|
5
|
-
import { listRepos, stringifyRepos } from "../../utilities/github.js";
|
|
6
|
-
import { HelpMessages } from "../../enums/help-messages.js";
|
|
7
|
-
class DeleteRepos extends Command {
|
|
8
|
-
static description = `Deletes repos from your Github account, useful for cleaning up generated test data. ${HelpMessages.RequiresGhCli}
|
|
9
|
-
|
|
10
|
-
If the deletion fails, you may need to refresh your CLI permissions with \`gh auth refresh -s delete_repo\``;
|
|
11
|
-
static flags = {
|
|
12
|
-
prefix: Flags.string({
|
|
13
|
-
description: "Prefix for the repos to delete, such as 'tf_'",
|
|
14
|
-
required: true,
|
|
15
|
-
}),
|
|
16
|
-
};
|
|
17
|
-
async run() {
|
|
18
|
-
const { flags } = await this.parse(DeleteRepos);
|
|
19
|
-
const { prefix } = flags;
|
|
20
|
-
const allRepos = listRepos();
|
|
21
|
-
const repos = allRepos.filter((repo) => repo.name.startsWith(prefix));
|
|
22
|
-
if (isEmpty(repos)) {
|
|
23
|
-
this.log(`Repos found:\n${stringifyRepos(allRepos)}`);
|
|
24
|
-
this.log(`No repos found with prefix '${prefix}'`);
|
|
25
|
-
this.exit();
|
|
26
|
-
}
|
|
27
|
-
this.log(`Repos to delete:\n${stringifyRepos(repos)}`);
|
|
28
|
-
const confirmation = await confirm({
|
|
29
|
-
message: "Continue with deletion of these repos?",
|
|
30
|
-
});
|
|
31
|
-
if (!confirmation) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
repos.forEach((repo) => {
|
|
35
|
-
execSync(`gh repo delete ${repo.nameWithOwner} --yes`, {
|
|
36
|
-
stdio: "inherit",
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export { DeleteRepos };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../../utilities/base-command.js";
|
|
2
|
-
import { HelpMessages } from "../../enums/help-messages.js";
|
|
3
|
-
class Gh extends BaseCommand {
|
|
4
|
-
static hidden = true;
|
|
5
|
-
static description = `Utility commands that wrap the \`gh\` CLI. ${HelpMessages.RequiresGhCli}`;
|
|
6
|
-
async run() {
|
|
7
|
-
await this.showHelp();
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export { Gh };
|