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