@hiiretail/gcp-infra-generators 1.0.0 → 1.0.2

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.
Files changed (74) hide show
  1. package/dist/generators/clan-resources/clan-project/index.js +89 -189
  2. package/dist/generators/common-resources/bigquery/index.js +172 -267
  3. package/dist/generators/common-resources/budget/index.js +67 -153
  4. package/dist/generators/common-resources/cloud-armor/index.js +17 -167
  5. package/dist/generators/common-resources/cloud-storage/index.js +96 -205
  6. package/dist/generators/common-resources/cloudsql/index.js +71 -177
  7. package/dist/generators/common-resources/cloudsql-database/index.js +40 -287
  8. package/dist/generators/common-resources/confluent-cluster/index.js +23 -132
  9. package/dist/generators/common-resources/datastore/index.js +48 -194
  10. package/dist/generators/common-resources/elastic-cloud/index.js +22 -132
  11. package/dist/generators/common-resources/elastic-index-policy/handle-yaml.js +76 -0
  12. package/dist/generators/common-resources/elastic-index-policy/index.js +131 -286
  13. package/dist/generators/common-resources/elastic-template/index.js +52 -162
  14. package/dist/generators/common-resources/firestore/index.js +93 -233
  15. package/dist/generators/common-resources/iam/index.js +35 -157
  16. package/dist/generators/common-resources/iam/valid-prefix.js +8 -0
  17. package/dist/generators/common-resources/kafka-connect/index.js +35 -144
  18. package/dist/generators/common-resources/kafka-topics/index.js +20 -129
  19. package/dist/generators/common-resources/kms/index.js +31 -141
  20. package/dist/generators/common-resources/memorystore/index.js +42 -328
  21. package/dist/generators/common-resources/monitoring/handle-yaml.js +49 -0
  22. package/dist/generators/common-resources/monitoring/index.js +144 -322
  23. package/dist/generators/common-resources/monitoring/templates/alerts/generic-infra.yaml +37 -2
  24. package/dist/generators/common-resources/monitoring/validate.js +58 -0
  25. package/dist/generators/common-resources/pubsub/append.js +130 -0
  26. package/dist/generators/common-resources/pubsub/get-gcp-projects.js +34 -0
  27. package/dist/generators/common-resources/pubsub/handle-subscribers.js +68 -0
  28. package/dist/generators/common-resources/pubsub/index.js +194 -536
  29. package/dist/generators/common-resources/pubsub/validate.js +53 -0
  30. package/dist/generators/common-resources/scheduler/append.js +85 -0
  31. package/dist/generators/common-resources/scheduler/index.js +62 -249
  32. package/dist/generators/common-resources/spanner/append.js +31 -0
  33. package/dist/generators/common-resources/spanner/index.js +102 -269
  34. package/dist/generators/common-resources/spanner/validate.js +38 -0
  35. package/dist/generators/docs/rca/index.js +25 -135
  36. package/dist/generators/docs/runbook/index.js +16 -126
  37. package/dist/generators/docs/srb/index.js +33 -147
  38. package/dist/generators/docs/srb/run-docker.js +2 -0
  39. package/dist/generators/init/clan-infra/gcp-projects.js +47 -0
  40. package/dist/generators/init/clan-infra/index.js +95 -290
  41. package/dist/generators/init/clan-infra/tribe-clan-repo.js +38 -0
  42. package/dist/generators/init/clan-infra/validate.js +8 -0
  43. package/dist/generators/maintenance/manage-states/index.js +142 -219
  44. package/dist/generators/maintenance/update-modules/index.js +56 -155
  45. package/dist/generators/organization/clan-project/googlecloud.js +124 -0
  46. package/dist/generators/organization/clan-project/index.js +81 -303
  47. package/dist/node_modules/.package-lock.json +88 -31
  48. package/dist/node_modules/@google-cloud/storage/build/cjs/src/bucket.js +5 -5
  49. package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.d.ts +1 -0
  50. package/dist/node_modules/@google-cloud/storage/build/cjs/src/file.js +10 -1
  51. package/dist/node_modules/@google-cloud/storage/build/cjs/src/storage.js +1 -1
  52. package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.d.ts +4 -4
  53. package/dist/node_modules/@google-cloud/storage/build/cjs/src/transfer-manager.js +4 -4
  54. package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.d.ts +1 -1
  55. package/dist/node_modules/@google-cloud/storage/build/cjs/src/util.js +2 -2
  56. package/dist/node_modules/@google-cloud/storage/build/esm/src/bucket.js +5 -5
  57. package/dist/node_modules/@google-cloud/storage/build/esm/src/file.d.ts +1 -0
  58. package/dist/node_modules/@google-cloud/storage/build/esm/src/file.js +10 -1
  59. package/dist/node_modules/@google-cloud/storage/build/esm/src/storage.js +1 -1
  60. package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.d.ts +4 -4
  61. package/dist/node_modules/@google-cloud/storage/build/esm/src/transfer-manager.js +4 -4
  62. package/dist/node_modules/@google-cloud/storage/build/esm/src/util.d.ts +1 -1
  63. package/dist/node_modules/@google-cloud/storage/build/esm/src/util.js +2 -2
  64. package/dist/node_modules/@google-cloud/storage/package.json +5 -5
  65. package/dist/package.json +45 -0
  66. package/dist/src/BaseGenerator.js +84 -0
  67. package/dist/src/SecretsGenerator.js +137 -0
  68. package/dist/src/cli.js +54 -255
  69. package/dist/src/dependency-check.js +48 -0
  70. package/dist/src/update-check.js +38 -0
  71. package/dist/src/validators.js +33 -0
  72. package/dist/src/yeoman.js +80 -0
  73. package/package.json +2 -3
  74. package/dist/node_modules/@google-cloud/storage/CHANGELOG.md +0 -1769
@@ -1,236 +1,125 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __commonJS = (cb, mod) => function __require() {
5
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
- };
7
-
8
- // src/validators.js
9
- var require_validators = __commonJS({
10
- "src/validators.js"(exports2, module2) {
11
- var path2 = require("path");
12
- module2.exports = {
13
- chain: /* @__PURE__ */ __name((input, ...validators) => {
14
- let msg = "";
15
- validators.every((validator) => {
16
- msg = validator(input);
17
- return msg === true;
18
- });
19
- return msg === true ? true : msg;
20
- }, "chain"),
21
- filename: /* @__PURE__ */ __name((input) => {
22
- if (!input) {
23
- return true;
24
- }
25
- return path2.basename(input) === input ? true : "Invalid filename";
26
- }, "filename"),
27
- maxLength: /* @__PURE__ */ __name((input, maxLength) => !input || input.length <= maxLength ? true : `Exceeds max \
28
- length: ${maxLength}`, "maxLength"),
29
- required: /* @__PURE__ */ __name((input) => {
30
- const msg = "Required";
31
- if (Array.isArray(input)) {
32
- return input.length > 0 ? true : msg;
33
- }
34
- if (input) {
35
- return input.trim().length > 0 ? true : msg;
36
- }
37
- return msg;
38
- }, "required")
39
- };
40
- }
41
- });
42
-
43
- // src/BaseGenerator.js
44
- var require_BaseGenerator = __commonJS({
45
- "src/BaseGenerator.js"(exports2, module2) {
46
- var Generator = require("yeoman-generator");
47
- var path2 = require("path");
48
- var fs = require("fs");
49
- var inquirer = require("inquirer");
50
- var { chain, required: required2, filename } = require_validators();
51
- module2.exports = class extends Generator {
52
- constructor(args, opts) {
53
- super(args, opts);
54
- this.baseDir = path2.resolve(path2.join(__dirname, ".."));
55
- this.destinationRoot(process.cwd());
56
- const [command, generator] = opts.namespace.split(":").slice(-2);
57
- this.generatorId = path2.join(command, generator);
58
- this.sourceRoot(
59
- path2.join(this.baseDir, "generators", this.generatorId, "templates")
60
- );
61
- this.copyDir = (templateDir, targetDir, answers = this.answers, skipIfExists = false) => {
62
- if (skipIfExists && fs.existsSync(targetDir)) {
63
- return;
64
- }
65
- this.fs.copyTpl(
66
- this.templatePath(`${templateDir}/**/*`),
67
- this.destinationPath(targetDir),
68
- answers
69
- );
70
- };
71
- this.listSubDirectories = (parent) => fs.readdirSync(parent).filter((f) => !f.startsWith(".")).filter((f) => fs.
72
- lstatSync(path2.join(parent, f)).isDirectory()).sort((a, b) => a.localeCompare(b));
73
- this.kebabCase = (input) => input.replace(/\s|_/g, "-");
74
- this.chooseOrCreatePrompts = (name, getChoicesDirectory) => [
75
- {
76
- when: /* @__PURE__ */ __name((answers) => fs.existsSync(getChoicesDirectory(answers)), "when"),
77
- type: "list",
78
- name,
79
- message: `Choose ${name}`,
80
- store: true,
81
- choices: /* @__PURE__ */ __name((answers) => [
82
- ...this.listSubDirectories(getChoicesDirectory(answers)),
83
- new inquirer.Separator(),
84
- `Create new ${name}`
85
- ], "choices"),
86
- validate: required2,
87
- filter: this.kebabCase
88
- },
89
- {
90
- when: /* @__PURE__ */ __name((answers) => !fs.existsSync(getChoicesDirectory(answers)) || answers[name] === `\
91
- Create-new-${name}`, "when"),
92
- type: "input",
93
- name: `new-${name}`,
94
- message: `New ${name} name`,
95
- store: false,
96
- validate: /* @__PURE__ */ __name((input) => chain(input, required2, filename), "validate"),
97
- filter: this.kebabCase
98
- },
99
- {
100
- when: /* @__PURE__ */ __name((answers) => !fs.existsSync(getChoicesDirectory(answers)) || answers[name] === "\
101
- Create-new-tribe", "when"),
102
- type: "input",
103
- name: "costCenter",
104
- message: "Please provide the Cost Center of the Tribe",
105
- store: false,
106
- validate: /* @__PURE__ */ __name((input) => chain(input, required2, filename), "validate"),
107
- filter: this.kebabCase
108
- }
109
- ];
110
- }
111
- };
112
- }
113
- });
1
+ const path = require('path');
2
+ const chalk = require('chalk');
3
+ const BaseGenerator = require('../../../src/BaseGenerator');
4
+ const { required } = require('../../../src/validators');
114
5
 
115
- // generators/common-resources/cloud-storage/index.js
116
- var path = require("path");
117
- var chalk = require("chalk");
118
- var BaseGenerator = require_BaseGenerator();
119
- var { required } = require_validators();
120
6
  module.exports = class extends BaseGenerator {
121
7
  prompting() {
122
8
  const prompts = [
123
9
  {
124
- type: "input",
125
- name: "bucketName",
126
- message: "Please provide the Cloud Storage bucket name",
127
- validate: required
10
+ type: 'input',
11
+ name: 'bucketName',
12
+ message: 'Please provide the Cloud Storage bucket name',
13
+ validate: required,
128
14
  },
129
15
  {
130
- type: "list",
131
- name: "versioning",
132
- message: "Do you want to enable versioning for the bucket?",
133
- default: "true",
134
- choices: ["true", "false"]
16
+ type: 'list',
17
+ name: 'versioning',
18
+ message: 'Do you want to enable versioning for the bucket?',
19
+ default: 'true',
20
+ choices: ['true', 'false'],
135
21
  },
136
22
  {
137
- type: "input",
138
- name: "prefix",
139
- message: "Please provide the prefix for the bucket name",
140
- validate: required
23
+ type: 'input',
24
+ name: 'prefix',
25
+ message: 'Please provide the prefix for the bucket name',
26
+ validate: required,
141
27
  },
142
28
  {
143
- type: "list",
144
- name: "lifecycleRules",
145
- message: "Do you want to set up lifecycle rules for the bucket?",
146
- default: "false",
147
- choices: ["true", "false"]
29
+ type: 'list',
30
+ name: 'lifecycleRules',
31
+ message: 'Do you want to set up lifecycle rules for the bucket?',
32
+ default: 'false',
33
+ choices: ['true', 'false'],
148
34
  },
149
35
  {
150
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
151
- type: "list",
152
- name: "action",
153
- message: "Select the action of this Lifecycle Rule",
154
- default: "Delete",
155
- choices: ["Delete", "SetStorageClass"]
36
+ when: (response) => response.lifecycleRules === 'true',
37
+ type: 'list',
38
+ name: 'action',
39
+ message: 'Select the action of this Lifecycle Rule',
40
+ default: 'Delete',
41
+ choices: ['Delete', 'SetStorageClass'],
156
42
  },
157
43
  {
158
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true" && response.action === "SetStorage\
159
- Class", "when"),
160
- type: "list",
161
- name: "storageClass",
162
- message: "Select the Storage Class for objects in the bucket",
163
- default: "STANDARD",
44
+ when: (response) =>
45
+ response.lifecycleRules === 'true' &&
46
+ response.action === 'SetStorageClass',
47
+ type: 'list',
48
+ name: 'storageClass',
49
+ message: 'Select the Storage Class for objects in the bucket',
50
+ default: 'STANDARD',
164
51
  choices: [
165
- "STANDARD",
166
- "MULTI_REGIONAL",
167
- "REGIONAL",
168
- "NEARLINE",
169
- "COLDLINE",
170
- "ARCHIVE"
171
- ]
52
+ 'STANDARD',
53
+ 'MULTI_REGIONAL',
54
+ 'REGIONAL',
55
+ 'NEARLINE',
56
+ 'COLDLINE',
57
+ 'ARCHIVE',
58
+ ],
172
59
  },
173
60
  {
174
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
175
- type: "input",
176
- name: "age",
177
- message: "Minimum age of an object in days to satisfy the condition. Use null to not set the value",
178
- validate: required
61
+ when: (response) => response.lifecycleRules === 'true',
62
+ type: 'input',
63
+ name: 'age',
64
+ message:
65
+ 'Minimum age of an object in days to satisfy the condition. Use null to not set the value',
66
+ validate: required,
179
67
  },
180
68
  {
181
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
182
- type: "input",
183
- name: "createdBefore",
184
- message: "A date in format YYYY-MM-DD. This condition is satisfied when an object is created before midnight of \
185
- the specified date in UTC. Use null to not set the value",
186
- validate: required
69
+ when: (response) => response.lifecycleRules === 'true',
70
+ type: 'input',
71
+ name: 'createdBefore',
72
+ message:
73
+ 'A date in format YYYY-MM-DD. This condition is satisfied when an object is created before midnight of the specified date in UTC. Use null to not set the value',
74
+ validate: required,
187
75
  },
188
76
  {
189
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
190
- type: "list",
191
- name: "withState",
192
- message: "Match to live and/or archived objects. Unversioned buckets have only live objects. Use null to not set\
193
- the value",
194
- default: "LIVE",
195
- choices: ["LIVE", "ARCHIVED", "ANY", "null"]
77
+ when: (response) => response.lifecycleRules === 'true',
78
+ type: 'list',
79
+ name: 'withState',
80
+ message:
81
+ 'Match to live and/or archived objects. Unversioned buckets have only live objects. Use null to not set the value',
82
+ default: 'LIVE',
83
+ choices: ['LIVE', 'ARCHIVED', 'ANY', 'null'],
196
84
  },
197
85
  {
198
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
199
- type: "input",
200
- name: "matchesStorageClass",
201
- message: "Specify comma delimited string of Storage Class of objects to satisfy the condition. Supported values:\
202
- STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY. Use null to not set the \
203
- value",
204
- validate: required
86
+ when: (response) => response.lifecycleRules === 'true',
87
+ type: 'input',
88
+ name: 'matchesStorageClass',
89
+ message:
90
+ 'Specify comma delimited string of Storage Class of objects to satisfy the condition. Supported values: STANDARD, MULTI_REGIONAL, REGIONAL, NEARLINE, COLDLINE, ARCHIVE, DURABLE_REDUCED_AVAILABILITY. Use null to not set the value',
91
+ validate: required,
205
92
  },
206
93
  {
207
- when: /* @__PURE__ */ __name((response) => response.lifecycleRules === "true", "when"),
208
- type: "input",
209
- name: "numNewerVersions",
210
- message: "Relevant only for versioned objects. The number of newer versions of an object to satisfy the conditio\
211
- n. Use null to not set the value",
212
- validate: required
94
+ when: (response) => response.lifecycleRules === 'true',
95
+ type: 'input',
96
+ name: 'numNewerVersions',
97
+ message:
98
+ 'Relevant only for versioned objects. The number of newer versions of an object to satisfy the condition. Use null to not set the value',
99
+ validate: required,
213
100
  },
214
101
  {
215
- type: "list",
216
- name: "retentionPolicy",
217
- message: "Do you want to set up a retention period for the bucket?",
218
- default: "false",
219
- choices: ["true", "false"]
102
+ type: 'list',
103
+ name: 'retentionPolicy',
104
+ message: 'Do you want to set up a retention period for the bucket?',
105
+ default: 'false',
106
+ choices: ['true', 'false'],
220
107
  },
221
108
  {
222
- when: /* @__PURE__ */ __name((response) => response.retentionPolicy === "true", "when"),
223
- type: "input",
224
- name: "retentionPeriod",
225
- message: "The period of time, in seconds, that objects in the bucket must be retained and cannot be deleted, ove\
226
- rwritten, or archived. The value must be less than 2147483647 seconds",
227
- validate: required
228
- }
109
+ when: (response) => response.retentionPolicy === 'true',
110
+ type: 'input',
111
+ name: 'retentionPeriod',
112
+ message:
113
+ 'The period of time, in seconds, that objects in the bucket must be retained and cannot be deleted, overwritten, or archived. The value must be less than 2147483647 seconds',
114
+ validate: required,
115
+ },
229
116
  ];
117
+
230
118
  return this.prompt(prompts).then((props) => {
231
119
  this.answers = props;
232
120
  });
233
121
  }
122
+
234
123
  writing() {
235
124
  const {
236
125
  bucketName,
@@ -245,10 +134,11 @@ rwritten, or archived. The value must be less than 2147483647 seconds",
245
134
  withState,
246
135
  matchesStorageClass,
247
136
  numNewerVersions,
248
- retentionPeriod
137
+ retentionPeriod,
249
138
  } = this.answers;
250
- ["prod", "staging"].forEach((env) => {
251
- this.copyDir("cloud-storage", path.join("infra", env, "cloud-storage"), {
139
+
140
+ ['prod', 'staging'].forEach((env) => {
141
+ this.copyDir('cloud-storage', path.join('infra', env, 'cloud-storage'), {
252
142
  ...this.answers,
253
143
  env,
254
144
  bucketName,
@@ -263,14 +153,15 @@ rwritten, or archived. The value must be less than 2147483647 seconds",
263
153
  withState,
264
154
  matchesStorageClass,
265
155
  numNewerVersions,
266
- retentionPeriod
156
+ retentionPeriod,
267
157
  });
268
158
  });
269
159
  }
160
+
270
161
  end() {
271
162
  this.log(`
272
- ${chalk.green("Your Cloud Storage resources have now been created.")}
273
- ${chalk.yellow("Note: Bucket names are globally unique, the staging bucket has the suffix -staging")}
274
- ${chalk.green("1.")} Push this change in a feature branch and open a pull request.`);
163
+ ${chalk.green('Your Cloud Storage resources have now been created.')}
164
+ ${chalk.yellow('Note: Bucket names are globally unique, the staging bucket has the suffix -staging')}
165
+ ${chalk.green('1.')} Push this change in a feature branch and open a pull request.`);
275
166
  }
276
167
  };
@@ -1,232 +1,126 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __commonJS = (cb, mod) => function __require() {
5
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
- };
7
-
8
- // src/validators.js
9
- var require_validators = __commonJS({
10
- "src/validators.js"(exports2, module2) {
11
- var path2 = require("path");
12
- module2.exports = {
13
- chain: /* @__PURE__ */ __name((input, ...validators) => {
14
- let msg = "";
15
- validators.every((validator) => {
16
- msg = validator(input);
17
- return msg === true;
18
- });
19
- return msg === true ? true : msg;
20
- }, "chain"),
21
- filename: /* @__PURE__ */ __name((input) => {
22
- if (!input) {
23
- return true;
24
- }
25
- return path2.basename(input) === input ? true : "Invalid filename";
26
- }, "filename"),
27
- maxLength: /* @__PURE__ */ __name((input, maxLength) => !input || input.length <= maxLength ? true : `Exceeds max \
28
- length: ${maxLength}`, "maxLength"),
29
- required: /* @__PURE__ */ __name((input) => {
30
- const msg = "Required";
31
- if (Array.isArray(input)) {
32
- return input.length > 0 ? true : msg;
33
- }
34
- if (input) {
35
- return input.trim().length > 0 ? true : msg;
36
- }
37
- return msg;
38
- }, "required")
39
- };
40
- }
41
- });
1
+ const path = require('path');
2
+ const chalk = require('chalk');
3
+ const BaseGenerator = require('../../../src/BaseGenerator');
42
4
 
43
- // src/BaseGenerator.js
44
- var require_BaseGenerator = __commonJS({
45
- "src/BaseGenerator.js"(exports2, module2) {
46
- var Generator = require("yeoman-generator");
47
- var path2 = require("path");
48
- var fs = require("fs");
49
- var inquirer = require("inquirer");
50
- var { chain, required, filename } = require_validators();
51
- module2.exports = class extends Generator {
52
- constructor(args, opts) {
53
- super(args, opts);
54
- this.baseDir = path2.resolve(path2.join(__dirname, ".."));
55
- this.destinationRoot(process.cwd());
56
- const [command, generator] = opts.namespace.split(":").slice(-2);
57
- this.generatorId = path2.join(command, generator);
58
- this.sourceRoot(
59
- path2.join(this.baseDir, "generators", this.generatorId, "templates")
60
- );
61
- this.copyDir = (templateDir, targetDir, answers = this.answers, skipIfExists = false) => {
62
- if (skipIfExists && fs.existsSync(targetDir)) {
63
- return;
64
- }
65
- this.fs.copyTpl(
66
- this.templatePath(`${templateDir}/**/*`),
67
- this.destinationPath(targetDir),
68
- answers
69
- );
70
- };
71
- this.listSubDirectories = (parent) => fs.readdirSync(parent).filter((f) => !f.startsWith(".")).filter((f) => fs.
72
- lstatSync(path2.join(parent, f)).isDirectory()).sort((a, b) => a.localeCompare(b));
73
- this.kebabCase = (input) => input.replace(/\s|_/g, "-");
74
- this.chooseOrCreatePrompts = (name, getChoicesDirectory) => [
75
- {
76
- when: /* @__PURE__ */ __name((answers) => fs.existsSync(getChoicesDirectory(answers)), "when"),
77
- type: "list",
78
- name,
79
- message: `Choose ${name}`,
80
- store: true,
81
- choices: /* @__PURE__ */ __name((answers) => [
82
- ...this.listSubDirectories(getChoicesDirectory(answers)),
83
- new inquirer.Separator(),
84
- `Create new ${name}`
85
- ], "choices"),
86
- validate: required,
87
- filter: this.kebabCase
88
- },
89
- {
90
- when: /* @__PURE__ */ __name((answers) => !fs.existsSync(getChoicesDirectory(answers)) || answers[name] === `\
91
- Create-new-${name}`, "when"),
92
- type: "input",
93
- name: `new-${name}`,
94
- message: `New ${name} name`,
95
- store: false,
96
- validate: /* @__PURE__ */ __name((input) => chain(input, required, filename), "validate"),
97
- filter: this.kebabCase
98
- },
99
- {
100
- when: /* @__PURE__ */ __name((answers) => !fs.existsSync(getChoicesDirectory(answers)) || answers[name] === "\
101
- Create-new-tribe", "when"),
102
- type: "input",
103
- name: "costCenter",
104
- message: "Please provide the Cost Center of the Tribe",
105
- store: false,
106
- validate: /* @__PURE__ */ __name((input) => chain(input, required, filename), "validate"),
107
- filter: this.kebabCase
108
- }
109
- ];
110
- }
111
- };
112
- }
113
- });
114
-
115
- // generators/common-resources/cloudsql/index.js
116
- var path = require("path");
117
- var chalk = require("chalk");
118
- var BaseGenerator = require_BaseGenerator();
119
5
  module.exports = class extends BaseGenerator {
120
6
  prompting() {
121
7
  const prompts = [
122
8
  {
123
- type: "list",
124
- name: "instanceType",
125
- message: "Select Cloud SQL database instance type",
9
+ type: 'list',
10
+ name: 'instanceType',
11
+ message: 'Select Cloud SQL database instance type',
126
12
  store: true,
127
- default: "postgres-clan",
128
- choices: ["postgres-clan", "mysql", "mssql"]
13
+ default: 'postgres-clan',
14
+ choices: ['postgres-clan', 'mysql', 'mssql'],
129
15
  },
130
16
  {
131
- type: "list",
132
- name: "instanceDatabaseVersion",
133
- message: "Select Database Version",
17
+ type: 'list',
18
+ name: 'instanceDatabaseVersion',
19
+ message: 'Select Database Version',
134
20
  store: true,
135
- default: /* @__PURE__ */ __name((response) => {
21
+ default: (response) => {
136
22
  const defaultTypes = {
137
- "postgres-clan": "POSTGRES_16",
138
- mysql: "MYSQL_5_7",
139
- mssql: "SQLSERVER_2017_STANDARD"
23
+ 'postgres-clan': 'POSTGRES_16',
24
+ mysql: 'MYSQL_5_7',
25
+ mssql: 'SQLSERVER_2017_STANDARD',
140
26
  };
141
27
  return defaultTypes[response.instanceType];
142
- }, "default"),
143
- choices: /* @__PURE__ */ __name((response) => {
28
+ },
29
+ choices: (response) => {
144
30
  const tierTypes = {
145
- "postgres-clan": [
146
- "POSTGRES_13",
147
- "POSTGRES_14",
148
- "POSTGRES_15",
149
- "POSTGRES_16"
31
+ 'postgres-clan': [
32
+ 'POSTGRES_13',
33
+ 'POSTGRES_14',
34
+ 'POSTGRES_15',
35
+ 'POSTGRES_16',
150
36
  ],
151
- mysql: ["MYSQL_5_6", "MYSQL_5_7"],
37
+ mysql: ['MYSQL_5_6', 'MYSQL_5_7'],
152
38
  mssql: [
153
- "SQLSERVER_2017_STANDARD",
154
- "SQLSERVER_2017_ENTERPRISE",
155
- "SQLSERVER_2017_EXPRESS",
156
- "SQLSERVER_2017_WEB"
157
- ]
39
+ 'SQLSERVER_2017_STANDARD',
40
+ 'SQLSERVER_2017_ENTERPRISE',
41
+ 'SQLSERVER_2017_EXPRESS',
42
+ 'SQLSERVER_2017_WEB',
43
+ ],
158
44
  };
159
45
  return tierTypes[response.instanceType];
160
- }, "choices")
46
+ },
161
47
  },
162
48
  {
163
- type: "number",
164
- name: "diskSize",
165
- message: "Enter the disk size for the instance, in GB",
49
+ type: 'number',
50
+ name: 'diskSize',
51
+ message: 'Enter the disk size for the instance, in GB',
166
52
  store: true,
167
- default: 10
53
+ default: 10,
168
54
  },
169
55
  {
170
- type: "list",
171
- name: "enableBackups",
172
- message: "Enable Databases backup?",
173
- default: "true",
174
- choices: ["true", "false"]
175
- }
56
+ type: 'list',
57
+ name: 'enableBackups',
58
+ message: 'Enable Databases backup?',
59
+ default: 'true',
60
+ choices: ['true', 'false'],
61
+ },
176
62
  ];
63
+
177
64
  return this.prompt(prompts).then((props) => {
178
65
  this.answers = props;
179
66
  });
180
67
  }
68
+
181
69
  writing() {
182
70
  const { instanceType } = this.answers;
183
- ["prod", "staging"].forEach((env) => {
71
+
72
+ // CloudSQL Instance
73
+ ['prod', 'staging'].forEach((env) => {
184
74
  this.copyDir(
185
- path.join(instanceType, "instance"),
186
- path.join("infra", env, "cloud-sql", instanceType, "instance"),
75
+ path.join(instanceType, 'instance'),
76
+ path.join('infra', env, 'cloud-sql', instanceType, 'instance'),
187
77
  {
188
78
  ...this.answers,
189
- env
190
- }
79
+ env,
80
+ },
191
81
  );
192
82
  });
193
- ["prod", "staging"].forEach((env) => {
83
+
84
+ // CloudSQL Instance secrets
85
+ ['prod', 'staging'].forEach((env) => {
194
86
  this.copyDir(
195
- path.join(instanceType, "instance-secrets"),
196
- path.join("infra", env, "cloud-sql", instanceType, "secrets"),
87
+ path.join(instanceType, 'instance-secrets'),
88
+ path.join('infra', env, 'cloud-sql', instanceType, 'secrets'),
197
89
  {
198
90
  ...this.answers,
199
- env
200
- }
91
+ env,
92
+ },
201
93
  );
202
94
  });
203
95
  }
96
+
204
97
  end() {
205
98
  const { instanceType } = this.answers;
99
+
206
100
  const specStageFile = path.join(
207
- "infra",
208
- "staging",
209
- "cloud-sql",
101
+ 'infra',
102
+ 'staging',
103
+ 'cloud-sql',
210
104
  instanceType,
211
- "instance",
212
- "spec.hcl"
105
+ 'instance',
106
+ 'spec.hcl',
213
107
  );
214
108
  const specProdFile = path.join(
215
- "infra",
216
- "prod",
217
- "cloud-sql",
109
+ 'infra',
110
+ 'prod',
111
+ 'cloud-sql',
218
112
  instanceType,
219
- "instance",
220
- "spec.hcl"
113
+ 'instance',
114
+ 'spec.hcl',
221
115
  );
116
+
222
117
  this.log(`
223
- ${chalk.green(`Your CloudSQL ${chalk.cyan(instanceType)} instance have now been created. To finalize your configuration,\
224
- please continue
118
+ ${chalk.green(`Your CloudSQL ${chalk.cyan(instanceType)} instance have now been created. To finalize your configuration, please continue
225
119
  with manual editing of the generated files.`)}
226
- ${chalk.green("1.")} Review and change specs if needed.
120
+ ${chalk.green('1.')} Review and change specs if needed.
227
121
  \u2192 ${chalk.cyan(specStageFile)}
228
122
  \u2192 ${chalk.cyan(specProdFile)}
229
- ${chalk.green("2.")} Push this change in a feature branch and open a pull request.
123
+ ${chalk.green('2.')} Push this change in a feature branch and open a pull request.
230
124
  `);
231
125
  }
232
126
  };