@codedrifters/configulator 0.0.85 → 0.0.87

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 (57) hide show
  1. package/lib/index.d.mts +1311 -0
  2. package/lib/index.d.ts +1311 -10
  3. package/lib/index.js +1508 -26
  4. package/lib/index.js.map +1 -0
  5. package/lib/index.mjs +1497 -0
  6. package/lib/index.mjs.map +1 -0
  7. package/package.json +11 -8
  8. package/lib/aws/aws-deployment-config.d.ts +0 -78
  9. package/lib/aws/aws-deployment-config.js +0 -134
  10. package/lib/aws/aws-deployment-target.d.ts +0 -183
  11. package/lib/aws/aws-deployment-target.js +0 -163
  12. package/lib/aws/aws-types.d.ts +0 -63
  13. package/lib/aws/aws-types.js +0 -9
  14. package/lib/aws/index.d.ts +0 -2
  15. package/lib/aws/index.js +0 -19
  16. package/lib/git/git-types.d.ts +0 -18
  17. package/lib/git/git-types.js +0 -9
  18. package/lib/git/index.d.ts +0 -1
  19. package/lib/git/index.js +0 -18
  20. package/lib/jsii/index.d.ts +0 -1
  21. package/lib/jsii/index.js +0 -18
  22. package/lib/jsii/jsii-faker.d.ts +0 -47
  23. package/lib/jsii/jsii-faker.js +0 -103
  24. package/lib/pnpm/index.d.ts +0 -1
  25. package/lib/pnpm/index.js +0 -18
  26. package/lib/pnpm/pnpm-workspace.d.ts +0 -244
  27. package/lib/pnpm/pnpm-workspace.js +0 -176
  28. package/lib/projects/index.d.ts +0 -2
  29. package/lib/projects/index.js +0 -19
  30. package/lib/projects/monorepo-project.d.ts +0 -82
  31. package/lib/projects/monorepo-project.js +0 -277
  32. package/lib/projects/typescript-project.d.ts +0 -20
  33. package/lib/projects/typescript-project.js +0 -181
  34. package/lib/tasks/index.d.ts +0 -1
  35. package/lib/tasks/index.js +0 -18
  36. package/lib/tasks/reset-task.d.ts +0 -51
  37. package/lib/tasks/reset-task.js +0 -149
  38. package/lib/turbo/index.d.ts +0 -2
  39. package/lib/turbo/index.js +0 -19
  40. package/lib/turbo/turbo-repo-task.d.ts +0 -36
  41. package/lib/turbo/turbo-repo-task.js +0 -43
  42. package/lib/turbo/turbo-repo.d.ts +0 -375
  43. package/lib/turbo/turbo-repo.js +0 -299
  44. package/lib/typescript/index.d.ts +0 -1
  45. package/lib/typescript/index.js +0 -18
  46. package/lib/typescript/typescript-config.d.ts +0 -13
  47. package/lib/typescript/typescript-config.js +0 -40
  48. package/lib/versions.d.ts +0 -34
  49. package/lib/versions.js +0 -38
  50. package/lib/vscode/index.d.ts +0 -1
  51. package/lib/vscode/index.js +0 -18
  52. package/lib/vscode/vscode.d.ts +0 -10
  53. package/lib/vscode/vscode.js +0 -38
  54. package/lib/workflows/aws-deploy-workflow.d.ts +0 -86
  55. package/lib/workflows/aws-deploy-workflow.js +0 -313
  56. package/lib/workflows/index.d.ts +0 -1
  57. package/lib/workflows/index.js +0 -18
package/lib/index.js CHANGED
@@ -1,27 +1,1509 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./aws/"), exports);
18
- __exportStar(require("./git/"), exports);
19
- __exportStar(require("./jsii/"), exports);
20
- __exportStar(require("./pnpm/"), exports);
21
- __exportStar(require("./projects/"), exports);
22
- __exportStar(require("./tasks/"), exports);
23
- __exportStar(require("./turbo/"), exports);
24
- __exportStar(require("./typescript/"), exports);
25
- __exportStar(require("./vscode/"), exports);
26
- __exportStar(require("./workflows/"), exports);
27
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLHlDQUF1QjtBQUN2Qix5Q0FBdUI7QUFDdkIsMENBQXdCO0FBQ3hCLDBDQUF3QjtBQUN4Qiw4Q0FBNEI7QUFDNUIsMkNBQXlCO0FBQ3pCLDJDQUF5QjtBQUN6QixnREFBOEI7QUFDOUIsNENBQTBCO0FBQzFCLCtDQUE2QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gXCIuL2F3cy9cIjtcbmV4cG9ydCAqIGZyb20gXCIuL2dpdC9cIjtcbmV4cG9ydCAqIGZyb20gXCIuL2pzaWkvXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9wbnBtL1wiO1xuZXhwb3J0ICogZnJvbSBcIi4vcHJvamVjdHMvXCI7XG5leHBvcnQgKiBmcm9tIFwiLi90YXNrcy9cIjtcbmV4cG9ydCAqIGZyb20gXCIuL3R1cmJvL1wiO1xuZXhwb3J0ICogZnJvbSBcIi4vdHlwZXNjcmlwdC9cIjtcbmV4cG9ydCAqIGZyb20gXCIuL3ZzY29kZS9cIjtcbmV4cG9ydCAqIGZyb20gXCIuL3dvcmtmbG93cy9cIjtcbiJdfQ==
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // ../utils/lib/aws/aws-types.js
34
+ var require_aws_types = __commonJS({
35
+ "../utils/lib/aws/aws-types.js"(exports2) {
36
+ "use strict";
37
+ Object.defineProperty(exports2, "__esModule", { value: true });
38
+ exports2.AWS_ENVIRONMENT_TYPE = exports2.DEPLOYMENT_TARGET_ROLE = exports2.AWS_STAGE_TYPE = void 0;
39
+ exports2.AWS_STAGE_TYPE = {
40
+ /**
41
+ * Development environment, typically used for testing and development.
42
+ */
43
+ DEV: "dev",
44
+ /**
45
+ * Staging environment, used for pre-production testing.
46
+ */
47
+ STAGE: "stage",
48
+ /**
49
+ * Production environment, used for live deployments.
50
+ */
51
+ PROD: "prod"
52
+ };
53
+ exports2.DEPLOYMENT_TARGET_ROLE = {
54
+ /**
55
+ * Account and region that represents the primary region for this service.
56
+ * For example, the base DynamoDB Region for global tables.
57
+ */
58
+ PRIMARY: "primary",
59
+ /**
60
+ * Account and region that represents a secondary region for this service.
61
+ * For example, a replica region for a global DynamoDB table.
62
+ */
63
+ SECONDARY: "secondary"
64
+ };
65
+ exports2.AWS_ENVIRONMENT_TYPE = exports2.DEPLOYMENT_TARGET_ROLE;
66
+ }
67
+ });
68
+
69
+ // ../utils/lib/git/git-utils.js
70
+ var require_git_utils = __commonJS({
71
+ "../utils/lib/git/git-utils.js"(exports2) {
72
+ "use strict";
73
+ Object.defineProperty(exports2, "__esModule", { value: true });
74
+ exports2.findGitRepoName = exports2.findGitBranch = void 0;
75
+ var node_child_process_1 = require("child_process");
76
+ var findGitBranch = () => {
77
+ return (0, node_child_process_1.execSync)("git rev-parse --abbrev-ref HEAD").toString("utf8").replace(/[\n\r\s]+$/, "");
78
+ };
79
+ exports2.findGitBranch = findGitBranch;
80
+ var findGitRepoName = () => {
81
+ if (process.env.GITHUB_REPOSITORY) {
82
+ return process.env.GITHUB_REPOSITORY;
83
+ }
84
+ const remote = (0, node_child_process_1.execSync)("git config --get remote.origin.url").toString("utf8").replace(/[\n\r\s]+$/, "").trim();
85
+ const match = remote.match(/[:\/]([^/]+\/[^/]+?)(?:\.git)?$/);
86
+ const repoName = match ? match[1] : "error-repo-name";
87
+ return repoName;
88
+ };
89
+ exports2.findGitRepoName = findGitRepoName;
90
+ }
91
+ });
92
+
93
+ // ../utils/lib/string/string-utils.js
94
+ var require_string_utils = __commonJS({
95
+ "../utils/lib/string/string-utils.js"(exports2) {
96
+ "use strict";
97
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
98
+ if (k2 === void 0) k2 = k;
99
+ var desc = Object.getOwnPropertyDescriptor(m, k);
100
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
101
+ desc = { enumerable: true, get: function() {
102
+ return m[k];
103
+ } };
104
+ }
105
+ Object.defineProperty(o, k2, desc);
106
+ }) : (function(o, m, k, k2) {
107
+ if (k2 === void 0) k2 = k;
108
+ o[k2] = m[k];
109
+ }));
110
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
111
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
112
+ }) : function(o, v) {
113
+ o["default"] = v;
114
+ });
115
+ var __importStar = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
116
+ var ownKeys = function(o) {
117
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
118
+ var ar = [];
119
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
120
+ return ar;
121
+ };
122
+ return ownKeys(o);
123
+ };
124
+ return function(mod) {
125
+ if (mod && mod.__esModule) return mod;
126
+ var result = {};
127
+ if (mod != null) {
128
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
129
+ }
130
+ __setModuleDefault(result, mod);
131
+ return result;
132
+ };
133
+ })();
134
+ Object.defineProperty(exports2, "__esModule", { value: true });
135
+ exports2.trimStringLength = exports2.hashString = void 0;
136
+ var crypto = __importStar(require("crypto"));
137
+ var hashString = (inString, trimLength = 999) => {
138
+ return crypto.createHash("sha256").update(inString).digest("hex").substring(0, trimLength);
139
+ };
140
+ exports2.hashString = hashString;
141
+ var trimStringLength = (inputString, maxLength) => {
142
+ return inputString.length < maxLength ? inputString : inputString.substring(0, maxLength);
143
+ };
144
+ exports2.trimStringLength = trimStringLength;
145
+ }
146
+ });
147
+
148
+ // ../utils/lib/index.js
149
+ var require_lib = __commonJS({
150
+ "../utils/lib/index.js"(exports2) {
151
+ "use strict";
152
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
153
+ if (k2 === void 0) k2 = k;
154
+ var desc = Object.getOwnPropertyDescriptor(m, k);
155
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
156
+ desc = { enumerable: true, get: function() {
157
+ return m[k];
158
+ } };
159
+ }
160
+ Object.defineProperty(o, k2, desc);
161
+ }) : (function(o, m, k, k2) {
162
+ if (k2 === void 0) k2 = k;
163
+ o[k2] = m[k];
164
+ }));
165
+ var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
166
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
167
+ };
168
+ Object.defineProperty(exports2, "__esModule", { value: true });
169
+ __exportStar(require_aws_types(), exports2);
170
+ __exportStar(require_git_utils(), exports2);
171
+ __exportStar(require_string_utils(), exports2);
172
+ }
173
+ });
174
+
175
+ // src/index.ts
176
+ var index_exports = {};
177
+ __export(index_exports, {
178
+ AwsDeployWorkflow: () => AwsDeployWorkflow,
179
+ AwsDeploymentConfig: () => AwsDeploymentConfig,
180
+ JsiiFaker: () => JsiiFaker,
181
+ MIMIMUM_RELEASE_AGE: () => MIMIMUM_RELEASE_AGE,
182
+ MonorepoProject: () => MonorepoProject,
183
+ PROD_DEPLOY_NAME: () => PROD_DEPLOY_NAME,
184
+ PnpmWorkspace: () => PnpmWorkspace,
185
+ ROOT_CI_TASK_NAME: () => ROOT_CI_TASK_NAME,
186
+ ROOT_TURBO_TASK_NAME: () => ROOT_TURBO_TASK_NAME,
187
+ ResetTask: () => ResetTask,
188
+ TurboRepo: () => TurboRepo,
189
+ TurboRepoTask: () => TurboRepoTask,
190
+ TypeScriptConfig: () => TypeScriptConfig,
191
+ TypeScriptProject: () => TypeScriptProject,
192
+ VSCodeConfig: () => VSCodeConfig
193
+ });
194
+ module.exports = __toCommonJS(index_exports);
195
+
196
+ // src/aws/aws-deployment-config.ts
197
+ var import_node_path = require("path");
198
+ var import_utils = __toESM(require_lib());
199
+ var import_projen = require("projen");
200
+
201
+ // src/turbo/turbo-repo-task.ts
202
+ var import_lib = require("projen/lib");
203
+ var TurboRepoTask = class extends import_lib.Component {
204
+ constructor(project, options) {
205
+ super(project);
206
+ this.project = project;
207
+ this.name = options.name;
208
+ this.dependsOn = options.dependsOn ?? [];
209
+ this.env = options.env ?? [];
210
+ this.passThroughEnv = options.passThroughEnv ?? [];
211
+ this.outputs = options.outputs ?? [];
212
+ this.cache = options.cache ?? true;
213
+ this.inputs = [
214
+ ...options.inputs ?? [],
215
+ // rerun if projen config changes
216
+ ".projen/**",
217
+ // ignore mac files
218
+ "!.DS_Store",
219
+ "!**/.DS_Store"
220
+ ];
221
+ this.outputLogs = options.outputLogs ?? "new-only";
222
+ this.persistent = options.persistent ?? false;
223
+ this.interactive = options.interactive ?? false;
224
+ this.isActive = true;
225
+ }
226
+ taskConfig() {
227
+ return {
228
+ dependsOn: this.dependsOn,
229
+ env: this.env,
230
+ passThroughEnv: this.passThroughEnv,
231
+ outputs: this.outputs,
232
+ cache: this.cache,
233
+ inputs: this.inputs,
234
+ outputLogs: this.outputLogs,
235
+ persistent: this.persistent,
236
+ interactive: this.interactive
237
+ };
238
+ }
239
+ };
240
+
241
+ // src/turbo/turbo-repo.ts
242
+ var import_lib2 = require("projen/lib");
243
+ var import_workflows_model = require("projen/lib/github/workflows-model");
244
+ var ROOT_TURBO_TASK_NAME = "turbo:build";
245
+ var ROOT_CI_TASK_NAME = "build:all";
246
+ var _TurboRepo = class _TurboRepo extends import_lib2.Component {
247
+ constructor(project, options = {}) {
248
+ super(project);
249
+ this.project = project;
250
+ /**
251
+ * Sub-Tasks to run
252
+ */
253
+ this.tasks = [];
254
+ this.turboVersion = options.turboVersion ?? "catalog:";
255
+ this.isRootProject = project === project.root;
256
+ if (this.isRootProject) {
257
+ project.addDevDeps(`turbo@${this.turboVersion}`);
258
+ }
259
+ project.gitignore.addPatterns("/.turbo");
260
+ project.npmignore?.addPatterns("/.turbo/");
261
+ this.extends = options.extends ?? (this.isRootProject ? [] : ["//"]);
262
+ this.globalDependencies = options.globalDependencies ?? [];
263
+ this.globalEnv = options.globalEnv ?? [];
264
+ this.globalPassThroughEnv = options.globalPassThroughEnv ?? [];
265
+ this.ui = options.ui ?? "stream";
266
+ this.dangerouslyDisablePackageManagerCheck = options.dangerouslyDisablePackageManagerCheck ?? false;
267
+ this.cacheDir = options.cacheDir ?? ".turbo/cache";
268
+ this.daemon = options.daemon ?? true;
269
+ this.envMode = options.envMode ?? "strict";
270
+ this.remoteCacheOptions = options.remoteCacheOptions;
271
+ this.buildAllTaskEnvVars = options.buildAllTaskEnvVars ?? {};
272
+ this.buildTask = new TurboRepoTask(this.project, {
273
+ name: ROOT_TURBO_TASK_NAME,
274
+ dependsOn: this.isRootProject ? [`^${ROOT_TURBO_TASK_NAME}`] : []
275
+ });
276
+ if (this.isRootProject) {
277
+ this.buildAllTask = this.project.tasks.addTask(ROOT_CI_TASK_NAME, {
278
+ description: "Root build followed by sub-project builds. Mimics the CI build process in one step."
279
+ });
280
+ this.buildAllTask.exec("turbo telemetry disable");
281
+ if (this.buildAllTaskEnvVars) {
282
+ Object.entries(this.buildAllTaskEnvVars).forEach(([name, value]) => {
283
+ this.addGlobalEnvVar(name, value);
284
+ });
285
+ }
286
+ if (!this.remoteCacheOptions) {
287
+ this.buildAllTask.exec(
288
+ `turbo ${ROOT_TURBO_TASK_NAME} --summarize --concurrency=10`
289
+ );
290
+ } else {
291
+ this.buildAllTask.exec(
292
+ `turbo turbo:build --summarize --concurrency=10 --cache=remote:rw --api=$TURBO_ENDPOINT --token=$TURBO_TOKEN --team=${this.remoteCacheOptions.teamName}`,
293
+ {
294
+ condition: '[ ! -n "$CI" ]',
295
+ env: {
296
+ TURBO_ENDPOINT: `$(aws ssm get-parameter --name ${this.remoteCacheOptions.endpointParamName} --query Parameter.Value --output text --profile ${this.remoteCacheOptions.profileName})`,
297
+ TURBO_TOKEN: `$(aws ssm get-parameter --name ${this.remoteCacheOptions.tokenParamName} --query Parameter.Value --output text --profile ${this.remoteCacheOptions.profileName})`
298
+ }
299
+ }
300
+ );
301
+ this.buildAllTask.exec(
302
+ `turbo turbo:build --summarize --concurrency=10 --cache=remote:rw --api=$TURBO_ENDPOINT --token=$TURBO_TOKEN --team=${this.remoteCacheOptions.teamName}`,
303
+ {
304
+ condition: '[ -n "$CI" ]',
305
+ env: {
306
+ TURBO_ENDPOINT: `$(aws ssm get-parameter --name ${this.remoteCacheOptions.endpointParamName} --query Parameter.Value --output text)`,
307
+ TURBO_TOKEN: `$(aws ssm get-parameter --name ${this.remoteCacheOptions.tokenParamName} --query Parameter.Value --output text)`
308
+ }
309
+ }
310
+ );
311
+ }
312
+ }
313
+ if (!this.isRootProject) {
314
+ const generatedFiles = this.project.components.filter((c) => c instanceof import_lib2.FileBase).map((c) => c.path);
315
+ this.preCompileTask = new TurboRepoTask(project, {
316
+ name: options.preCompileTask?.name ?? "pre-compile",
317
+ inputs: ["src/**", ...generatedFiles]
318
+ });
319
+ this.compileTask = new TurboRepoTask(project, {
320
+ name: options.compileTask?.name ?? "compile",
321
+ inputs: ["src/**", ...generatedFiles]
322
+ });
323
+ this.postCompileTask = new TurboRepoTask(project, {
324
+ name: options.postCompileTask?.name ?? "post-compile",
325
+ inputs: ["src/**", ...generatedFiles]
326
+ });
327
+ this.testTask = new TurboRepoTask(project, {
328
+ name: options.testTask?.name ?? "test"
329
+ });
330
+ this.packageTask = new TurboRepoTask(project, {
331
+ name: options.packageTask?.name ?? "package",
332
+ inputs: [".npmignore"]
333
+ });
334
+ this.tasks.push(
335
+ this.preCompileTask,
336
+ this.compileTask,
337
+ this.postCompileTask,
338
+ this.testTask,
339
+ this.packageTask
340
+ );
341
+ }
342
+ }
343
+ /**
344
+ * Static method to discovert turbo in a project.
345
+ */
346
+ static of(project) {
347
+ const isDefined = (c) => c instanceof _TurboRepo;
348
+ return project.components.find(isDefined);
349
+ }
350
+ /**
351
+ * Add an env var to the global env vars for all tasks.
352
+ * This will also become an input for the build:all task cache at the root.
353
+ */
354
+ addGlobalEnvVar(name, value) {
355
+ this.buildAllTask?.env(name, value);
356
+ if (this.isRootProject) {
357
+ this.globalEnv.push(name);
358
+ }
359
+ }
360
+ activateBranchNameEnvVar() {
361
+ this.addGlobalEnvVar("BRANCH_NAME", "$(git rev-parse --abbrev-ref HEAD)");
362
+ }
363
+ preSynthesize() {
364
+ let nextDependsOn = this.project.deps.all.filter((d) => d.version === "workspace:*").map((d) => [d.name, ROOT_TURBO_TASK_NAME].join("#"));
365
+ if (!this.isRootProject) {
366
+ [
367
+ [this.project.preCompileTask, this.preCompileTask],
368
+ [this.project.compileTask, this.compileTask],
369
+ [this.project.postCompileTask, this.postCompileTask],
370
+ [this.project.testTask, this.testTask],
371
+ [this.project.packageTask, this.packageTask]
372
+ ].forEach(([pjTask, turboTask]) => {
373
+ if (pjTask && turboTask && pjTask.steps.length > 0) {
374
+ if (nextDependsOn.length > 0) {
375
+ turboTask.dependsOn.push(...nextDependsOn);
376
+ }
377
+ nextDependsOn = [turboTask.name];
378
+ } else {
379
+ turboTask.isActive = false;
380
+ }
381
+ });
382
+ this.buildTask.dependsOn.push(...nextDependsOn);
383
+ }
384
+ const fileName = "turbo.json";
385
+ this.project.addPackageIgnore(fileName);
386
+ new import_lib2.JsonFile(this.project, fileName, {
387
+ obj: {
388
+ extends: this.extends.length ? this.extends : void 0,
389
+ globalDependencies: this.isRootProject && this.globalDependencies.length ? this.globalDependencies : void 0,
390
+ globalEnv: this.isRootProject && this.globalEnv.length ? this.globalEnv : void 0,
391
+ globalPassThroughEnv: this.isRootProject && this.globalPassThroughEnv.length ? this.globalPassThroughEnv : void 0,
392
+ ui: this.isRootProject ? this.ui : void 0,
393
+ dangerouslyDisablePackageManagerCheck: this.isRootProject ? this.dangerouslyDisablePackageManagerCheck : void 0,
394
+ cacheDir: this.isRootProject ? this.cacheDir : void 0,
395
+ daemon: this.isRootProject ? this.daemon : void 0,
396
+ envMode: this.isRootProject ? this.envMode : void 0,
397
+ /**
398
+ * All tasks
399
+ */
400
+ tasks: this.tasks.filter((task) => task.isActive).reduce(
401
+ (acc, task) => {
402
+ acc[task.name] = {
403
+ ...task.taskConfig()
404
+ };
405
+ return acc;
406
+ },
407
+ {
408
+ [this.buildTask.name]: { ...this.buildTask.taskConfig() }
409
+ }
410
+ )
411
+ }
412
+ });
413
+ super.preSynthesize();
414
+ }
415
+ };
416
+ _TurboRepo.buildWorkflowOptions = (remoteCacheOptions) => {
417
+ return {
418
+ permissions: {
419
+ contents: import_workflows_model.JobPermission.WRITE,
420
+ idToken: import_workflows_model.JobPermission.WRITE
421
+ },
422
+ preBuildSteps: [
423
+ {
424
+ name: "AWS Creds for SSM",
425
+ uses: "aws-actions/configure-aws-credentials@v4",
426
+ with: {
427
+ ["role-to-assume"]: remoteCacheOptions.oidcRole,
428
+ ["aws-region"]: "us-east-1",
429
+ ["role-duration-seconds"]: "900"
430
+ }
431
+ }
432
+ ]
433
+ };
434
+ };
435
+ var TurboRepo = _TurboRepo;
436
+
437
+ // src/aws/aws-deployment-config.ts
438
+ var AwsDeploymentConfig = class _AwsDeploymentConfig extends import_projen.Component {
439
+ constructor(project) {
440
+ super(project);
441
+ /**
442
+ * Array of targets for deployment.
443
+ */
444
+ this.awsDeploymentTargets = [];
445
+ /*****************************************************************************
446
+ *
447
+ * Synth Tasks
448
+ *
449
+ * - Configure synth task to use the branch name
450
+ * - Change the output location for easier workflows.
451
+ *
452
+ ****************************************************************************/
453
+ this.configureSynthTask = () => {
454
+ this.project.tasks.tryFind("synth")?.reset(`rm -rf ${this.cdkOut}`);
455
+ this.project.tasks.tryFind("synth")?.exec(`cdk synth --output ${this.cdkOut}`, { env: this.env });
456
+ this.project.tasks.tryFind("synth:silent")?.reset(`rm -rf ${this.cdkOut}`);
457
+ this.project.tasks.tryFind("synth:silent")?.exec(`cdk synth -q --output ${this.cdkOut}`, { env: this.env });
458
+ };
459
+ this.env = { GIT_BRANCH: "$(git branch --show-current)" };
460
+ this.projectPath = (0, import_node_path.relative)(project.root.outdir, project.outdir);
461
+ this.rootPath = (0, import_node_path.relative)(project.outdir, project.root.outdir);
462
+ this.rootCdkOut = (0, import_node_path.join)("dist", this.projectPath, "cdk.out");
463
+ this.cdkOut = (0, import_node_path.join)(this.rootPath, "dist", this.projectPath, "cdk.out");
464
+ ["deploy", "watch"].forEach((taskName) => {
465
+ const task = project.tasks.tryFind(taskName);
466
+ if (task) {
467
+ task.reset();
468
+ task.say(
469
+ "Generic task is disabled. Please use the specific task for your deployment target."
470
+ );
471
+ }
472
+ });
473
+ this.configureSynthTask();
474
+ }
475
+ static of(project) {
476
+ const isDefined = (c) => c instanceof _AwsDeploymentConfig;
477
+ return project.components.find(isDefined);
478
+ }
479
+ /*****************************************************************************
480
+ *
481
+ * Target filter helpers
482
+ *
483
+ * Return various targets for deployment scripts to use.
484
+ *
485
+ ****************************************************************************/
486
+ /**
487
+ * @returns All production deployment targets.
488
+ */
489
+ get prodTargets() {
490
+ return this.awsDeploymentTargets.filter(
491
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.PROD
492
+ );
493
+ }
494
+ get prodTargetsForCI() {
495
+ return this.awsDeploymentTargets.filter(
496
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.PROD && target.ciDeployment
497
+ );
498
+ }
499
+ get prodTargetsForLocal() {
500
+ return this.awsDeploymentTargets.filter(
501
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.PROD && target.localDeployment
502
+ );
503
+ }
504
+ /**
505
+ *
506
+ * @returns All stage deployment targets.
507
+ */
508
+ get stageTargets() {
509
+ return this.awsDeploymentTargets.filter(
510
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.STAGE
511
+ );
512
+ }
513
+ get stageTargetsForCI() {
514
+ return this.awsDeploymentTargets.filter(
515
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.STAGE && target.ciDeployment
516
+ );
517
+ }
518
+ get stageTargetsForLocal() {
519
+ return this.awsDeploymentTargets.filter(
520
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.STAGE && target.localDeployment
521
+ );
522
+ }
523
+ /**
524
+ *
525
+ * @returns All dev deployment targets.
526
+ */
527
+ get devTargets() {
528
+ return this.awsDeploymentTargets.filter(
529
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.DEV
530
+ );
531
+ }
532
+ get devTargetsForCI() {
533
+ return this.awsDeploymentTargets.filter(
534
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.DEV && target.ciDeployment
535
+ );
536
+ }
537
+ get devTargetsForLocal() {
538
+ return this.awsDeploymentTargets.filter(
539
+ (target) => target.awsStageType === import_utils.AWS_STAGE_TYPE.DEV && target.localDeployment
540
+ );
541
+ }
542
+ preSynthesize() {
543
+ super.preSynthesize();
544
+ if (TurboRepo.of(this.project)) {
545
+ const turbo = TurboRepo.of(this.project);
546
+ turbo.postCompileTask?.outputs.push((0, import_node_path.join)(this.cdkOut, "**"));
547
+ }
548
+ }
549
+ };
550
+
551
+ // src/jsii/jsii-faker.ts
552
+ var spec = __toESM(require("@jsii/spec"));
553
+ var import_projen2 = require("projen");
554
+ var ProjenBaseFqn = {
555
+ TYPESCRIPT_PROJECT: "projen.typescript.TypeScriptProject",
556
+ TYPESCRIPT_PROJECT_OPTIONS: "projen.typescript.TypeScriptProjectOptions"
557
+ };
558
+ var JsiiFaker = class _JsiiFaker extends import_projen2.Component {
559
+ constructor(project) {
560
+ super(project);
561
+ this.project = project;
562
+ this._types = {};
563
+ this.toJSON = () => {
564
+ return {
565
+ types: this._types
566
+ };
567
+ };
568
+ this._assemblyName = this.project.package.packageName;
569
+ new import_projen2.JsonFile(project, ".jsii", {
570
+ obj: () => {
571
+ return {
572
+ name: this._assemblyName,
573
+ types: this._types
574
+ };
575
+ }
576
+ });
577
+ }
578
+ // find project singleton
579
+ static of(project) {
580
+ const isDefined = (c) => c instanceof _JsiiFaker;
581
+ return project.components.find(isDefined);
582
+ }
583
+ addClassType(options) {
584
+ const fqn = [this._assemblyName, options.name].join(".");
585
+ const type = {
586
+ assembly: this._assemblyName,
587
+ base: options.baseFqn ?? ProjenBaseFqn.TYPESCRIPT_PROJECT,
588
+ fqn,
589
+ kind: spec.TypeKind.Class,
590
+ name: options.name,
591
+ initializer: {
592
+ parameters: [
593
+ {
594
+ name: "options",
595
+ type: {
596
+ fqn: options.optionsFqn ?? ProjenBaseFqn.TYPESCRIPT_PROJECT_OPTIONS
597
+ }
598
+ }
599
+ ]
600
+ }
601
+ };
602
+ this._types[fqn] = type;
603
+ }
604
+ };
605
+
606
+ // src/pnpm/pnpm-workspace.ts
607
+ var import_path = require("path");
608
+ var import_projen3 = require("projen");
609
+ var MIMIMUM_RELEASE_AGE = {
610
+ ZERO_DAYS: 0,
611
+ ONE_HOUR: 60,
612
+ SIX_HOURS: 360,
613
+ TWELVE_HOURS: 720,
614
+ ONE_DAY: 1440,
615
+ TWO_DAYS: 2880,
616
+ THREE_DAYS: 4320,
617
+ FOUR_DAYS: 5760,
618
+ FIVE_DAYS: 7200,
619
+ SIX_DAYS: 8640,
620
+ ONE_WEEK: 10080
621
+ };
622
+ var PnpmWorkspace = class _PnpmWorkspace extends import_projen3.Component {
623
+ /**
624
+ * Get the pnpm workspace component of a project. If it does not exist,
625
+ * return undefined.
626
+ *
627
+ * @param project
628
+ * @returns
629
+ */
630
+ static of(project) {
631
+ const isDefined = (c) => c instanceof _PnpmWorkspace;
632
+ return project.root.components.find(isDefined);
633
+ }
634
+ constructor(project, options = {}) {
635
+ super(project);
636
+ project.tryFindObjectFile("package.json")?.addDeletionOverride("pnpm");
637
+ this.fileName = options.fileName ?? "pnpm-workspace.yaml";
638
+ this.minimumReleaseAge = options.minimumReleaseAge ? options.minimumReleaseAge : MIMIMUM_RELEASE_AGE.ONE_DAY;
639
+ this.minimumReleaseAgeExclude = options.minimumReleaseAgeExclude ? ["@codedrifters/*", ...options.minimumReleaseAgeExclude] : ["@codedrifters/*"];
640
+ this.onlyBuiltDependencies = options.onlyBuiltDependencies ? options.onlyBuiltDependencies : [];
641
+ this.ignoredBuiltDependencies = options.ignoredBuiltDependencies ? options.ignoredBuiltDependencies : [];
642
+ this.subprojects = options.subprojects ?? [];
643
+ this.defaultCatalog = options.defaultCatalog;
644
+ this.namedCatalogs = options.namedCatalogs;
645
+ project.addPackageIgnore(this.fileName);
646
+ new import_projen3.YamlFile(this.project, this.fileName, {
647
+ obj: () => {
648
+ const pnpmConfig = {};
649
+ const packages = new Array();
650
+ for (const subproject of project.subprojects) {
651
+ packages.push((0, import_path.relative)(this.project.outdir, subproject.outdir));
652
+ }
653
+ const packageSet = new Set(packages);
654
+ for (const subprojectPath of this.subprojects) {
655
+ packageSet.add(subprojectPath);
656
+ }
657
+ if (this.subprojects.length > 0) {
658
+ packages.length = 0;
659
+ packages.push(...packageSet);
660
+ }
661
+ pnpmConfig.minimumReleaseAge = this.minimumReleaseAge;
662
+ if (this.minimumReleaseAgeExclude.length > 0) {
663
+ pnpmConfig.minimumReleaseAgeExclude = this.minimumReleaseAgeExclude;
664
+ }
665
+ if (this.onlyBuiltDependencies.length > 0) {
666
+ pnpmConfig.onlyBuiltDependencies = this.onlyBuiltDependencies;
667
+ }
668
+ if (this.ignoredBuiltDependencies.length > 0) {
669
+ pnpmConfig.ignoreBuiltDependencies = this.ignoredBuiltDependencies;
670
+ }
671
+ if (this.defaultCatalog && Object.keys(this.defaultCatalog).length > 0) {
672
+ pnpmConfig.catalog = this.defaultCatalog;
673
+ }
674
+ if (this.namedCatalogs && Object.keys(this.namedCatalogs).length > 0) {
675
+ pnpmConfig.namedCatalogs = this.namedCatalogs;
676
+ }
677
+ return {
678
+ ...packages.length > 0 ? { packages } : {},
679
+ ...pnpmConfig ? { ...pnpmConfig } : {}
680
+ };
681
+ }
682
+ });
683
+ }
684
+ };
685
+
686
+ // src/projects/monorepo-project.ts
687
+ var import_javascript2 = require("projen/lib/javascript");
688
+ var import_typescript = require("projen/lib/typescript");
689
+ var import_ts_deepmerge2 = require("ts-deepmerge");
690
+
691
+ // src/tasks/reset-task.ts
692
+ var import_projen5 = require("projen");
693
+
694
+ // src/projects/typescript-project.ts
695
+ var import_projen4 = require("projen");
696
+ var import_javascript = require("projen/lib/javascript");
697
+ var import_release = require("projen/lib/release");
698
+ var import_ts_deepmerge = require("ts-deepmerge");
699
+
700
+ // src/versions.ts
701
+ var VERSION = {
702
+ /**
703
+ * CDK CLI for workflows and command line operations.
704
+ *
705
+ * CLI and lib are versioned separately, so this is the CLI version.
706
+ */
707
+ AWS_CDK_CLI_VERSION: "2.1104.0",
708
+ /**
709
+ * CDK Version to use for construct projects.
710
+ *
711
+ * CLI and lib are versioned separately, so this is the lib version.
712
+ */
713
+ AWS_CDK_LIB_VERSION: "2.237.1",
714
+ /**
715
+ * Version of the AWS Constructs library to use.
716
+ */
717
+ AWS_CONSTRUCTS_VERSION: "10.4.5",
718
+ /**
719
+ * Version of Node.js to use in CI workflows at github actions.
720
+ */
721
+ NODE_WORKFLOWS: "24",
722
+ /**
723
+ * Version of PNPM to use in workflows at github actions.
724
+ */
725
+ PNPM_VERSION: "10.28.2",
726
+ /**
727
+ * Version of Projen to use.
728
+ */
729
+ PROJEN_VERSION: "0.99.9",
730
+ /**
731
+ * What version of the turborepo library should we use?
732
+ */
733
+ TURBO_VERSION: "2.8.3"
734
+ };
735
+
736
+ // src/projects/typescript-project.ts
737
+ var TypeScriptProject = class extends import_projen4.typescript.TypeScriptProject {
738
+ constructor(userOptions) {
739
+ const pnpmVersion = userOptions.parent && userOptions.parent instanceof MonorepoProject ? userOptions.parent.pnpmVersion : VERSION.PNPM_VERSION;
740
+ const pnpmWorkspace = userOptions.parent && userOptions.parent instanceof MonorepoProject ? PnpmWorkspace.of(userOptions.parent) : void 0;
741
+ const defaultOptions = {
742
+ /**
743
+ * This is a standard, so don't require it to passed in everywhere.
744
+ */
745
+ defaultReleaseBranch: "main",
746
+ /**
747
+ * Enable reset task by default.
748
+ */
749
+ resetTask: true,
750
+ /**
751
+ * Packaging options
752
+ */
753
+ packageManager: import_javascript.NodePackageManager.PNPM,
754
+ pnpmVersion,
755
+ licensed: userOptions.license !== void 0 || false,
756
+ copyrightOwner: "CodeDrifters",
757
+ release: false,
758
+ /**
759
+ * Don't add sample code.
760
+ */
761
+ sampleCode: false,
762
+ /**
763
+ * Make sure jest config is stored outside of package.json
764
+ */
765
+ jestOptions: {
766
+ configFilePath: "jest.config.json",
767
+ jestConfig: {
768
+ roots: [`<rootDir>/src`],
769
+ transform: {
770
+ ["^.+\\.[t]sx?$"]: new import_javascript.Transform("@swc/jest")
771
+ },
772
+ moduleFileExtensions: ["js", "ts"]
773
+ }
774
+ },
775
+ /**
776
+ * Turn on prettier formatting
777
+ */
778
+ prettier: true,
779
+ /**
780
+ * SWC for faster testing
781
+ */
782
+ devDeps: ["@swc/jest", "@swc/core"],
783
+ /**
784
+ * Don't package test files.
785
+ */
786
+ npmIgnoreOptions: {
787
+ ignorePatterns: ["*.spec.*", "*.test.*"]
788
+ },
789
+ /**
790
+ * Options for the automated dependency upgrade task / workflow
791
+ * Automatically exclude any packages that are managed by the root
792
+ * project as default catalog dependencies since we want to let the
793
+ * catalog manage those dependencies.
794
+ */
795
+ depsUpgrade: true,
796
+ depsUpgradeOptions: {
797
+ workflow: false,
798
+ exclude: Object.keys(pnpmWorkspace?.defaultCatalog || {}),
799
+ ...userOptions.parent && userOptions.parent instanceof MonorepoProject ? {
800
+ workflowOptions: {
801
+ schedule: import_javascript.UpgradeDependenciesSchedule.WEEKLY
802
+ },
803
+ cooldown: 1
804
+ } : {}
805
+ },
806
+ /**
807
+ * Only release when the package folder sourcce content changes
808
+ */
809
+ releaseTrigger: import_release.ReleaseTrigger.continuous({
810
+ paths: [`${userOptions.outdir}/src/**`]
811
+ })
812
+ };
813
+ const options = (0, import_ts_deepmerge.merge)(defaultOptions, userOptions);
814
+ super(options);
815
+ this.deps.removeDependency("ts-jest");
816
+ this.package.file.addOverride(
817
+ "packageManager",
818
+ `pnpm@${options.pnpmVersion}`
819
+ );
820
+ this.eslint?.addOverride({
821
+ files: ["**/*.test.*", "**/*.spec.*"],
822
+ rules: {
823
+ "import/no-extraneous-dependencies": "off"
824
+ }
825
+ });
826
+ this.gitignore?.addPatterns(".DS_Store");
827
+ this.npmignore?.addPatterns("*.spec.*", "*.test.*", "__fixtures__");
828
+ const turboActive = userOptions.parent && TurboRepo.of(userOptions.parent) !== void 0;
829
+ if (turboActive) {
830
+ const turbo = new TurboRepo(this);
831
+ turbo.compileTask?.outputs.push("dist/**");
832
+ turbo.compileTask?.outputs.push("lib/**");
833
+ }
834
+ if (options.resetTask !== false) {
835
+ const defaultResetTaskOptions = {
836
+ pathsToRemove: [
837
+ "node_modules",
838
+ "dist",
839
+ "lib",
840
+ "coverage",
841
+ "test-reports",
842
+ ".turbo",
843
+ "tsconfig.tsbuildinfo",
844
+ this.artifactsDirectory
845
+ ]
846
+ };
847
+ const userResetTaskOptions = options.resetTaskOptions ?? {};
848
+ const resetTaskOptions = (0, import_ts_deepmerge.merge)(
849
+ defaultResetTaskOptions,
850
+ {
851
+ ...userResetTaskOptions,
852
+ pathsToRemove: [
853
+ ...defaultResetTaskOptions.pathsToRemove ?? [],
854
+ ...userResetTaskOptions.pathsToRemove ?? []
855
+ ]
856
+ }
857
+ );
858
+ new ResetTask(this, resetTaskOptions);
859
+ }
860
+ if (options.parent && options.parent instanceof MonorepoProject) {
861
+ const originalResolve = this.package.resolveDepsAndWritePackageJson;
862
+ this.package.installDependencies = () => {
863
+ options.parent.requestInstallDependencies({
864
+ resolveDepsAndWritePackageJson: () => originalResolve.apply(this.package)
865
+ });
866
+ };
867
+ this.package.resolveDepsAndWritePackageJson = () => {
868
+ };
869
+ }
870
+ }
871
+ };
872
+
873
+ // src/tasks/reset-task.ts
874
+ var ResetTask = class _ResetTask extends import_projen5.Component {
875
+ constructor(project, options = {}) {
876
+ super(project);
877
+ this.project = project;
878
+ this.artifactsDirectory = options.artifactsDirectory ? options.artifactsDirectory : project instanceof TypeScriptProject ? project.artifactsDirectory : "lib";
879
+ const pathsToRemove = options.pathsToRemove ?? [];
880
+ const finalPaths = pathsToRemove.length === 0 ? [this.artifactsDirectory] : pathsToRemove;
881
+ this.pathsToRemove = Array.from(new Set(finalPaths));
882
+ this.taskName = options.taskName ?? "reset";
883
+ const resetTask = this.project.tasks.addTask(this.taskName, {
884
+ description: "Delete build artifacts specified by pathsToRemove option, or artifactsDirectory if pathsToRemove is empty"
885
+ });
886
+ this.pathsToRemove.forEach((path) => {
887
+ resetTask.exec(`[ -e "${path}" ] && rm -rf ${path} || true`);
888
+ });
889
+ const rootHasTurbo = TurboRepo.of(this.project.root) !== void 0;
890
+ const isSubproject = this.project !== this.project.root;
891
+ const isRootProject = this.project === this.project.root;
892
+ if (isSubproject && rootHasTurbo) {
893
+ const turbo = TurboRepo.of(this.project);
894
+ if (turbo && !turbo.isRootProject) {
895
+ const turboResetTask = new TurboRepoTask(this.project, {
896
+ name: `turbo:${this.taskName}`,
897
+ cache: false
898
+ });
899
+ turbo.tasks.push(turboResetTask);
900
+ const turboTaskWithSameName = new TurboRepoTask(this.project, {
901
+ name: this.taskName,
902
+ cache: false
903
+ });
904
+ turbo.tasks.push(turboTaskWithSameName);
905
+ turboResetTask.dependsOn.push(turboTaskWithSameName.name);
906
+ }
907
+ }
908
+ if (isRootProject && rootHasTurbo) {
909
+ const turbo = TurboRepo.of(this.project);
910
+ if (turbo && turbo.isRootProject) {
911
+ const rootTurboResetTask = new TurboRepoTask(this.project, {
912
+ name: `turbo:${this.taskName}`,
913
+ dependsOn: [`^turbo:${this.taskName}`],
914
+ cache: false
915
+ });
916
+ turbo.tasks.push(rootTurboResetTask);
917
+ const turboTaskWithSameName = new TurboRepoTask(this.project, {
918
+ name: this.taskName,
919
+ cache: false
920
+ });
921
+ turbo.tasks.push(turboTaskWithSameName);
922
+ rootTurboResetTask.dependsOn.push(turboTaskWithSameName.name);
923
+ const resetAllTask = this.project.tasks.addTask(
924
+ `${this.taskName}:all`,
925
+ {
926
+ description: `Reset all build artifacts across the monorepo by running turbo:${this.taskName} in all subprojects.`
927
+ }
928
+ );
929
+ resetAllTask.exec("turbo telemetry disable");
930
+ resetAllTask.exec(
931
+ `turbo turbo:${this.taskName} --summarize --concurrency=10`
932
+ );
933
+ resetAllTask.exec(`pnpm ${this.taskName}`);
934
+ }
935
+ }
936
+ }
937
+ /**
938
+ * Static method to discover reset task in a project.
939
+ */
940
+ static of(project) {
941
+ const isDefined = (c) => c instanceof _ResetTask;
942
+ return project.components.find(isDefined);
943
+ }
944
+ };
945
+
946
+ // src/vscode/vscode.ts
947
+ var import_projen6 = require("projen");
948
+ var VSCodeConfig = class extends import_projen6.Component {
949
+ constructor(project) {
950
+ super(project);
951
+ const vsConfig = new import_projen6.vscode.VsCode(project);
952
+ const vsSettings = new import_projen6.vscode.VsCodeSettings(vsConfig);
953
+ vsSettings.addSetting("editor.tabSize", 2);
954
+ vsSettings.addSetting("editor.detectIndentation", false);
955
+ vsSettings.addSetting("editor.bracketPairColorization.enabled", true);
956
+ vsSettings.addSetting("editor.guides.bracketPairs", "active");
957
+ vsSettings.addSetting("editor.rulers", [80, 120]);
958
+ vsSettings.addSetting(
959
+ "editor.codeActionsOnSave",
960
+ { "source.fixAll.eslint": "explicit" },
961
+ "typescript"
962
+ );
963
+ }
964
+ };
965
+
966
+ // src/projects/monorepo-project.ts
967
+ var MonorepoProject = class extends import_typescript.TypeScriptAppProject {
968
+ constructor(userOptions) {
969
+ const buildWorkflowOptions = userOptions.turboOptions?.remoteCacheOptions ? TurboRepo.buildWorkflowOptions(
970
+ userOptions.turboOptions.remoteCacheOptions
971
+ ) : {};
972
+ const defaultOptions = {
973
+ /**
974
+ * Use typescript based config file.
975
+ */
976
+ projenrcTs: true,
977
+ /**
978
+ * Projen version should be pinned to the local specified version.
979
+ */
980
+ projenVersion: "catalog:",
981
+ /**
982
+ * Use Prettier for code formatting.
983
+ */
984
+ prettier: true,
985
+ /**
986
+ * Not licensed by default.
987
+ */
988
+ licensed: false,
989
+ /**
990
+ * GitHub options for the monorepo.
991
+ * Don't enable mergify by default.
992
+ */
993
+ githubOptions: {
994
+ mergify: false,
995
+ /**
996
+ * Configure pull request linting to validate PR titles follow Conventional Commits.
997
+ * By default, all conventional commit types are allowed, providing flexibility
998
+ * for different types of changes (features, fixes, documentation, refactoring, etc.).
999
+ */
1000
+ pullRequestLintOptions: {
1001
+ semanticTitleOptions: {
1002
+ /**
1003
+ * Allowed conventional commit types for PR titles.
1004
+ * This includes all standard types from the Conventional Commits specification:
1005
+ * - feat: New features
1006
+ * - fix: Bug fixes
1007
+ * - docs: Documentation changes
1008
+ * - style: Code style changes (formatting, etc.)
1009
+ * - refactor: Code refactoring
1010
+ * - perf: Performance improvements
1011
+ * - test: Test additions or changes
1012
+ * - build: Build system changes
1013
+ * - ci: CI configuration changes
1014
+ * - chore: Maintenance tasks
1015
+ * - revert: Revert commits
1016
+ */
1017
+ types: [
1018
+ "feat",
1019
+ "fix",
1020
+ "docs",
1021
+ "style",
1022
+ "refactor",
1023
+ "perf",
1024
+ "test",
1025
+ "build",
1026
+ "ci",
1027
+ "chore",
1028
+ "revert"
1029
+ ]
1030
+ }
1031
+ }
1032
+ },
1033
+ /**
1034
+ * Default PNPM version to use in the monorepo.
1035
+ */
1036
+ pnpmVersion: VERSION.PNPM_VERSION,
1037
+ /**
1038
+ * We don't want sample code generated for the root project.
1039
+ */
1040
+ sampleCode: false,
1041
+ /**
1042
+ * Jest is not required in the root project.
1043
+ */
1044
+ jest: false,
1045
+ /**
1046
+ * Don't release the root project.
1047
+ */
1048
+ release: false,
1049
+ /**
1050
+ * Uppgrade dependencies automatically unless otherwise instructed.
1051
+ */
1052
+ depsUpgrade: true,
1053
+ depsUpgradeOptions: {
1054
+ workflowOptions: {
1055
+ schedule: import_javascript2.UpgradeDependenciesSchedule.WEEKLY
1056
+ },
1057
+ cooldown: 1
1058
+ },
1059
+ /**
1060
+ * Disable tsconfig.dev.json in the root since we aren't going to be
1061
+ * developing any code here. It's just a task runner and configuration
1062
+ * tool for sub-projects.
1063
+ */
1064
+ disableTsconfigDev: true,
1065
+ /**
1066
+ * Kill the srcdir in the root since we aren't using one.
1067
+ */
1068
+ tsconfig: {
1069
+ compilerOptions: {
1070
+ rootDir: void 0
1071
+ },
1072
+ exclude: ["node_modules"]
1073
+ },
1074
+ /**
1075
+ * Enable turborepo by default.
1076
+ */
1077
+ turbo: true,
1078
+ /**
1079
+ * Enable reset task by default.
1080
+ */
1081
+ resetTask: true,
1082
+ /**
1083
+ * Include self as a devDep
1084
+ */
1085
+ devDeps: ["@codedrifters/configulator"],
1086
+ /**
1087
+ * PNPM options for the monorepo.
1088
+ */
1089
+ pnpmOptions: {
1090
+ pnpmWorkspaceOptions: {
1091
+ defaultCatalog: {
1092
+ ["aws-cdk"]: VERSION.AWS_CDK_CLI_VERSION,
1093
+ ["aws-cdk-lib"]: VERSION.AWS_CDK_LIB_VERSION,
1094
+ ["projen"]: VERSION.PROJEN_VERSION,
1095
+ ["constructs"]: VERSION.AWS_CONSTRUCTS_VERSION,
1096
+ ["turbo"]: VERSION.TURBO_VERSION
1097
+ }
1098
+ }
1099
+ }
1100
+ };
1101
+ const requiredOptions = {
1102
+ /**
1103
+ * This is required because it's standard practice and also to simplify
1104
+ * some workflow design.
1105
+ */
1106
+ defaultReleaseBranch: "main",
1107
+ /**
1108
+ * Use PNPM instead of the default (Yarn). Much of the ecosystem depends
1109
+ * on PNPM and making monorepos PNPM only simplifies many configurations.
1110
+ */
1111
+ packageManager: import_javascript2.NodePackageManager.PNPM,
1112
+ /**
1113
+ * Some additional pre-build steps if we're using turbo's remote cache.
1114
+ */
1115
+ buildWorkflowOptions: {
1116
+ permissions: {
1117
+ ...buildWorkflowOptions?.permissions,
1118
+ ...userOptions.buildWorkflowOptions?.permissions
1119
+ },
1120
+ preBuildSteps: [
1121
+ ...buildWorkflowOptions?.preBuildSteps ?? [],
1122
+ ...userOptions.buildWorkflowOptions?.preBuildSteps ?? []
1123
+ ]
1124
+ }
1125
+ };
1126
+ const options = (0, import_ts_deepmerge2.merge)(
1127
+ defaultOptions,
1128
+ userOptions,
1129
+ requiredOptions
1130
+ );
1131
+ super({ ...options });
1132
+ /**
1133
+ * List of functions to call after dependencies have been installed.
1134
+ */
1135
+ this.postInstallDependencies = new Array();
1136
+ this.pnpmVersion = options.pnpmVersion;
1137
+ new VSCodeConfig(this);
1138
+ new PnpmWorkspace(this, options.pnpmOptions?.pnpmWorkspaceOptions);
1139
+ if (options.turbo) {
1140
+ new TurboRepo(this, options.turboOptions);
1141
+ this.buildWorkflow?.addPostBuildSteps({
1142
+ name: "Build Sub Projects",
1143
+ run: `npx projen ${ROOT_CI_TASK_NAME}`
1144
+ });
1145
+ }
1146
+ if (options.resetTask !== false) {
1147
+ const defaultResetTaskOptions = {
1148
+ pathsToRemove: ["node_modules", ".turbo", "dist", "lib"]
1149
+ };
1150
+ const userResetTaskOptions = options.resetTaskOptions ?? {};
1151
+ const resetTaskOptions = (0, import_ts_deepmerge2.merge)(
1152
+ defaultResetTaskOptions,
1153
+ {
1154
+ ...userResetTaskOptions,
1155
+ pathsToRemove: [
1156
+ ...defaultResetTaskOptions.pathsToRemove ?? [],
1157
+ ...userResetTaskOptions.pathsToRemove ?? []
1158
+ ]
1159
+ }
1160
+ );
1161
+ new ResetTask(this, resetTaskOptions);
1162
+ }
1163
+ this.package.file.addOverride(
1164
+ "packageManager",
1165
+ `pnpm@${options.pnpmVersion}`
1166
+ );
1167
+ this.gitignore?.addPatterns(".DS_Store");
1168
+ this.addDevDeps("constructs@catalog:");
1169
+ if (options.upgradeConfigulatorTask !== false) {
1170
+ this.upgradeConfigulatorTask = new import_javascript2.UpgradeDependencies(
1171
+ this,
1172
+ (0, import_ts_deepmerge2.merge)(
1173
+ {
1174
+ include: ["@codedrifters/configulator"],
1175
+ taskName: `upgrade-codedrifters-configulator`,
1176
+ workflowOptions: {
1177
+ schedule: import_javascript2.UpgradeDependenciesSchedule.DAILY
1178
+ }
1179
+ },
1180
+ options.upgradeConfigulatorTaskOptions ?? {}
1181
+ )
1182
+ );
1183
+ }
1184
+ this.tasks.tryFind("post-upgrade")?.exec("pnpm upgrade -r");
1185
+ this.tasks.tryFind("post-upgrade")?.spawn(this.defaultTask);
1186
+ }
1187
+ /**
1188
+ * Allows a sub project to request installation of dependency at the Monorepo root
1189
+ * They must provide a function that is executed after dependencies have been installed
1190
+ * If this function returns true, the install command is run for a second time after all sub project requests have run.
1191
+ * This is used to resolve dependency versions from `*` to a concrete version constraint.
1192
+ */
1193
+ requestInstallDependencies(resolver) {
1194
+ this.postInstallDependencies.push(resolver.resolveDepsAndWritePackageJson);
1195
+ }
1196
+ /**
1197
+ * Hooks into the install dependencies cycle
1198
+ */
1199
+ postSynthesize() {
1200
+ if (this.postInstallDependencies.length) {
1201
+ const nodePkg = this.package;
1202
+ nodePkg.installDependencies();
1203
+ const completedRequests = this.postInstallDependencies.map(
1204
+ (request) => request()
1205
+ );
1206
+ if (completedRequests.some(Boolean)) {
1207
+ nodePkg.installDependencies();
1208
+ }
1209
+ this.postInstallDependencies = [];
1210
+ }
1211
+ }
1212
+ };
1213
+
1214
+ // src/typescript/typescript-config.ts
1215
+ var import_node_path2 = require("path");
1216
+ var import_projen7 = require("projen");
1217
+ var import_path2 = require("projen/lib/util/path");
1218
+ var TypeScriptConfig = class extends import_projen7.Component {
1219
+ constructor(project) {
1220
+ super(project);
1221
+ let tsPaths = {};
1222
+ const workspaceDeps = project.deps.all.filter(
1223
+ (d) => d.version === "workspace:*"
1224
+ );
1225
+ workspaceDeps.forEach((dep) => {
1226
+ const subproject = project.root.subprojects.find((p) => p.package.packageName === dep.name);
1227
+ if (!subproject) {
1228
+ throw new Error(`Could not find subproject ${dep.name} in monorepo.`);
1229
+ }
1230
+ tsPaths = {
1231
+ ...tsPaths,
1232
+ [dep.name]: [
1233
+ (0, import_path2.ensureRelativePathStartsWithDot)(
1234
+ (0, import_node_path2.relative)(project.outdir, subproject.outdir)
1235
+ )
1236
+ ]
1237
+ };
1238
+ });
1239
+ project.tsconfig?.file.addOverride("compilerOptions.paths", tsPaths);
1240
+ project.tsconfigDev?.file.addOverride("compilerOptions.paths", tsPaths);
1241
+ }
1242
+ };
1243
+
1244
+ // src/workflows/aws-deploy-workflow.ts
1245
+ var import_utils2 = __toESM(require_lib());
1246
+ var import_projen8 = require("projen");
1247
+ var import_build = require("projen/lib/build");
1248
+ var import_github = require("projen/lib/github");
1249
+ var import_workflows_model2 = require("projen/lib/github/workflows-model");
1250
+ var PROD_DEPLOY_NAME = "prod-deploy";
1251
+ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen8.Component {
1252
+ constructor(project, options = {}) {
1253
+ super(project);
1254
+ this.project = project;
1255
+ /**
1256
+ * AWS environment type, such as primary or secondary.
1257
+ *
1258
+ * @deprecated Use deployment target role terminology elsewhere. This property is maintained for backward compatibility.
1259
+ * @default 'primary' (this is the only type supported currently)
1260
+ */
1261
+ this.awsEnvironmentType = import_utils2.DEPLOYMENT_TARGET_ROLE.PRIMARY;
1262
+ this.setupNode = () => {
1263
+ return [
1264
+ {
1265
+ name: "Setup Node",
1266
+ uses: "actions/setup-node@v4",
1267
+ with: {
1268
+ ["node-version"]: VERSION.NODE_WORKFLOWS
1269
+ },
1270
+ // occasionally this step fails due to internal issues at github
1271
+ timeoutMinutes: 1
1272
+ }
1273
+ ];
1274
+ };
1275
+ this.setupPnpm = () => {
1276
+ return [
1277
+ {
1278
+ name: "Setup PNPM",
1279
+ uses: "pnpm/action-setup@v3",
1280
+ with: {
1281
+ version: VERSION.PNPM_VERSION
1282
+ }
1283
+ }
1284
+ ];
1285
+ };
1286
+ /**
1287
+ * Builds a GitHub Actions condition string that checks if the current branch
1288
+ * matches any of the provided branch patterns.
1289
+ *
1290
+ * Handles both exact matches (e.g., "main") and glob patterns (e.g., "feature/*").
1291
+ * Also allows workflow_dispatch (manual runs) to proceed.
1292
+ *
1293
+ * @param branches Array of GitBranch objects with branch patterns
1294
+ * @returns Condition string or empty string if no branches provided
1295
+ */
1296
+ this.buildBranchFilterCondition = (branches) => {
1297
+ if (!branches || branches.length === 0) {
1298
+ return "";
1299
+ }
1300
+ const conditions = [];
1301
+ conditions.push("github.event_name == 'workflow_dispatch'");
1302
+ for (const branch of branches) {
1303
+ const branchPattern = branch.branch;
1304
+ if (branchPattern.includes("*")) {
1305
+ const prefix = branchPattern.replace(/\*.*$/, "");
1306
+ conditions.push(`startsWith(github.ref, 'refs/heads/${prefix}')`);
1307
+ } else {
1308
+ conditions.push(`github.ref == 'refs/heads/${branchPattern}'`);
1309
+ }
1310
+ }
1311
+ return conditions.join(" || ");
1312
+ };
1313
+ this.deploySteps = (target) => {
1314
+ const {
1315
+ awsStageType,
1316
+ deploymentTargetRole,
1317
+ account,
1318
+ region,
1319
+ ciDeploymentConfig,
1320
+ awsDeploymentConfig
1321
+ } = target;
1322
+ const { roleArn, stackPattern } = ciDeploymentConfig ?? {};
1323
+ const { rootCdkOut } = awsDeploymentConfig;
1324
+ return [
1325
+ ...this.setupPnpm(),
1326
+ ...this.setupNode(),
1327
+ /**
1328
+ * Install CDK
1329
+ */
1330
+ {
1331
+ name: "Install CDK",
1332
+ run: "pnpm add aws-cdk"
1333
+ },
1334
+ /**
1335
+ * Configure AWS creds.
1336
+ */
1337
+ {
1338
+ name: `AWS Creds ${awsStageType}/${deploymentTargetRole}/${account}/${region}`,
1339
+ uses: "aws-actions/configure-aws-credentials@v4",
1340
+ with: {
1341
+ "role-to-assume": roleArn,
1342
+ "aws-region": region,
1343
+ "role-duration-seconds": 900
1344
+ // 15 minutes
1345
+ }
1346
+ },
1347
+ /**
1348
+ * Run CDK Deploy
1349
+ */
1350
+ {
1351
+ name: `Deploy ${awsStageType}/${deploymentTargetRole}/${account}/${region}`,
1352
+ run: `pnpm dlx aws-cdk deploy --no-rollback --require-approval=never --app=${rootCdkOut} "${stackPattern}"`
1353
+ }
1354
+ ];
1355
+ };
1356
+ if (!(project.root instanceof MonorepoProject)) {
1357
+ throw new Error(
1358
+ "AwsDeployWorkflow requires the root project to be a MonorepoProject"
1359
+ );
1360
+ }
1361
+ this.rootProject = project.root;
1362
+ const github = import_github.GitHub.of(this.rootProject);
1363
+ if (!github) {
1364
+ throw new Error(
1365
+ "AwsDeployWorkflow requires a GitHub component in the root project"
1366
+ );
1367
+ }
1368
+ const turbo = TurboRepo.of(this.rootProject);
1369
+ const buildWorkflowOptions = turbo?.remoteCacheOptions ? TurboRepo.buildWorkflowOptions(turbo.remoteCacheOptions) : {};
1370
+ this.awsStageType = options.awsStageType ?? import_utils2.AWS_STAGE_TYPE.DEV;
1371
+ this.awsDeploymentTargets = options.awsDeploymentTargets ?? AwsDeploymentConfig.of(project)?.awsDeploymentTargets.filter(
1372
+ (target) => target.awsStageType === this.awsStageType && target.ciDeployment
1373
+ ) ?? [];
1374
+ this.deployAfterTargets = options.deployAfterTargets ?? [];
1375
+ if (options.buildWorkflow && options.buildWorkflowOptions) {
1376
+ throw new Error(
1377
+ "Cannot provide both buildWorkflow and buildWorkflowOptions"
1378
+ );
1379
+ }
1380
+ this.externalWorkflow = !!options.buildWorkflow;
1381
+ this.buildWorkflow = options.buildWorkflow ?? new import_build.BuildWorkflow(this.rootProject, {
1382
+ /**
1383
+ * Name based on project and environment.
1384
+ */
1385
+ name: options.buildWorkflowOptions?.name ?? [
1386
+ "deploy",
1387
+ project.name,
1388
+ this.awsStageType,
1389
+ this.awsEnvironmentType
1390
+ ].join("-"),
1391
+ /**
1392
+ * Use the root projects build task.
1393
+ */
1394
+ buildTask: this.rootProject.buildTask,
1395
+ /**
1396
+ * Use push triggers based n the branch config for each environment.
1397
+ */
1398
+ workflowTriggers: {
1399
+ push: {
1400
+ branches: [
1401
+ ...this.awsDeploymentTargets.flatMap(
1402
+ (t) => t.branches.map((b) => b.branch)
1403
+ )
1404
+ ]
1405
+ },
1406
+ workflowDispatch: {},
1407
+ ...options.buildWorkflowOptions?.workflowTriggers
1408
+ },
1409
+ /**
1410
+ * Never allow mutations for deploys. This should have been handled
1411
+ * during build.
1412
+ */
1413
+ mutableBuild: false,
1414
+ /**
1415
+ * Do this pre-merge of permissions and build steps
1416
+ */
1417
+ ...options.buildWorkflowOptions,
1418
+ /**
1419
+ * Some additional permissions may be required when turbo's involved.
1420
+ */
1421
+ permissions: {
1422
+ ...options.buildWorkflowOptions?.permissions,
1423
+ ...buildWorkflowOptions?.permissions
1424
+ },
1425
+ /**
1426
+ * Assemble all pre-build steps
1427
+ */
1428
+ preBuildSteps: [
1429
+ ...this.setupPnpm(),
1430
+ ...this.setupNode(),
1431
+ {
1432
+ name: "Install dependencies",
1433
+ run: "pnpm i --no-frozen-lockfile"
1434
+ },
1435
+ ...options.buildWorkflowOptions?.preBuildSteps ?? [],
1436
+ ...buildWorkflowOptions?.preBuildSteps ?? []
1437
+ ]
1438
+ });
1439
+ const buildJobName = (target) => {
1440
+ return [
1441
+ target.awsStageType,
1442
+ target.deploymentTargetRole,
1443
+ "deploy",
1444
+ target.project.name,
1445
+ target.account,
1446
+ target.region
1447
+ ].join("-");
1448
+ };
1449
+ this.awsDeploymentTargets.forEach((target) => {
1450
+ const deployJobName = buildJobName(target);
1451
+ const branchFilterCondition = this.buildBranchFilterCondition(
1452
+ target.branches
1453
+ );
1454
+ const jobCondition = branchFilterCondition ? [
1455
+ "${{ !needs.build.outputs.self_mutation_happened }}",
1456
+ `(${branchFilterCondition})`
1457
+ ].join(" && ") : "${{ !needs.build.outputs.self_mutation_happened }}";
1458
+ this.buildWorkflow.addPostBuildJob(deployJobName, {
1459
+ name: `Deploy ${this.project.name} ${target.awsStageType}/${target.deploymentTargetRole}/${target.account}/${target.region}`,
1460
+ needs: [
1461
+ "build",
1462
+ ...this.deployAfterTargets.map((p) => {
1463
+ return buildJobName(p);
1464
+ })
1465
+ ],
1466
+ runsOn: ["ubuntu-latest"],
1467
+ permissions: {
1468
+ contents: import_workflows_model2.JobPermission.READ,
1469
+ idToken: import_workflows_model2.JobPermission.WRITE
1470
+ },
1471
+ concurrency: deployJobName,
1472
+ if: jobCondition,
1473
+ steps: [...this.deploySteps(target)]
1474
+ });
1475
+ });
1476
+ }
1477
+ static of(project, buildWorkflow) {
1478
+ const isDefined = (c) => c instanceof _AwsDeployWorkflow && c.buildWorkflow === buildWorkflow;
1479
+ return project.components.find(isDefined);
1480
+ }
1481
+ preSynthesize() {
1482
+ if (!this.externalWorkflow && TurboRepo.of(this.rootProject)) {
1483
+ this.buildWorkflow.addPostBuildSteps({
1484
+ name: "Build Sub Projects",
1485
+ run: `npx projen ${ROOT_CI_TASK_NAME}`
1486
+ });
1487
+ }
1488
+ super.preSynthesize();
1489
+ }
1490
+ };
1491
+ // Annotate the CommonJS export names for ESM import in node:
1492
+ 0 && (module.exports = {
1493
+ AwsDeployWorkflow,
1494
+ AwsDeploymentConfig,
1495
+ JsiiFaker,
1496
+ MIMIMUM_RELEASE_AGE,
1497
+ MonorepoProject,
1498
+ PROD_DEPLOY_NAME,
1499
+ PnpmWorkspace,
1500
+ ROOT_CI_TASK_NAME,
1501
+ ROOT_TURBO_TASK_NAME,
1502
+ ResetTask,
1503
+ TurboRepo,
1504
+ TurboRepoTask,
1505
+ TypeScriptConfig,
1506
+ TypeScriptProject,
1507
+ VSCodeConfig
1508
+ });
1509
+ //# sourceMappingURL=index.js.map