@codedrifters/configulator 0.0.52 → 0.0.54

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 (2) hide show
  1. package/README.md +342 -2
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,4 +1,344 @@
1
- # Configulator
1
+ # Project Setup Guide: Projen & Configulator
2
+
3
+ ## Overview
4
+
5
+ This guide explains the core infrastructure tools used in our projects: Projen and Configulator. These tools help us maintain consistency across multiple projects and reduce repetitive setup work.
6
+
7
+ ## What is Projen?
8
+
9
+ Projen is a project generator and configuration management tool that:
10
+
11
+ - Creates standardized project structures
12
+ - Manages configuration files programmatically
13
+ - Handles dependency updates automatically
14
+ - Provides consistent build workflows
15
+
16
+ ### Key Concepts
17
+
18
+ **Components:** Individual pieces of configuration (e.g., Jest, Prettier, TypeScript). Each component configures specific files and settings. When you add or remove a component, all its associated files and configurations are automatically managed.
19
+
20
+ **Project Types:** Base-level configurations for different kinds of projects (e.g., TypeScript app, monorepo, React project).
21
+
22
+ **Synthesis:** The process of generating actual files from your configuration. Run `npx projen` to synthesize your project.
23
+
24
+ ## What is Configulator?
25
+
26
+ configulator is Code Drifters' custom extension of Projen. It:
27
+
28
+ - Extends standard Projen configurations with our preferred defaults
29
+ - Provides company-specific components and workflows
30
+ - Currently at version 0.48 (alpha/internal use)
31
+ - Available as an npm package: `@codedrifters/configulator`
32
+
33
+ ### Why We Built It
34
+
35
+ Instead of setting up each new project from scratch (90% identical setup repeated), Configulator lets us:
36
+
37
+ - Generate consistent project structures
38
+ - Pick and choose components we need
39
+ - Maintain standardized tooling across all projects
40
+ - Receive updates to common configurations automatically
41
+
42
+ ## Creating a New Project
43
+
44
+ ### Basic Setup
45
+
46
+ ```bash
47
+ npx projen new --from @codedrifters/Configulator@0.48 monorepo
48
+ ```
49
+
50
+ This creates a project with:
51
+
52
+ - TypeScript configuration
53
+ - Prettier for code formatting
54
+ - VS Code settings
55
+ - GitHub workflows (build, PR checks)
56
+ - Weekly dependency upgrade workflow
57
+
58
+ ### Minimal Configuration Example
59
+
60
+ The simplest `.projenrc.ts` file:
61
+
62
+ ```typescript
63
+ import { MonorepoProject } from '@codedrifters/Configulator';
64
+
65
+ const project = new MonorepoProject({
66
+ name: 'my-project-name'
67
+ });
68
+
69
+ project.synth();
70
+ ```
71
+
72
+ ## Important: File Management Rules
73
+
74
+ ### DO NOT Edit These Files Directly
75
+
76
+ Projen manages many files automatically. Never edit these files by hand:
77
+
78
+ - Configuration files (`.prettierrc`, `tsconfig.json`, etc.)
79
+ - GitHub workflows (`.github/workflows/*`)
80
+ - Build scripts
81
+ - Most files listed in `.projen/files.json`
82
+
83
+ ### Exception: package.json
84
+
85
+ `package.json` is special - Projen reads, modifies, and writes it back, preserving some manual changes. However, you should still manage dependencies through Projen config, not by editing `package.json` directly.
86
+
87
+ ### Adding Dependencies
88
+
89
+ **WRONG:**
90
+ ```bash
91
+ npm install some-package
92
+ ```
93
+
94
+ **CORRECT:** Add dependencies in your `.projenrc.ts` configuration and run `npx projen`.
95
+
96
+ ## Understanding the Monorepo Configuration
97
+
98
+ Our monorepo projects are configured in `.projenrc/` folder with multiple files:
99
+
100
+ ```
101
+ .projenrc/
102
+ ├── index.ts # Main configuration
103
+ ├── root.ts # Root project config
104
+ ├── sample-app.ts # Example sub-project
105
+ └── ehr-project.ts # Actual sub-project
106
+ ```
107
+
108
+ ### Key Configuration Options
109
+
110
+ The root configuration extends Projen's TypeScript app with our defaults:
111
+
112
+ - **TypeScript:** Enabled by default
113
+ - **Prettier:** Enabled for consistent formatting
114
+ - **License:** Unlicensed (for client work)
115
+ - **Package Manager:** PNPM (mandatory)
116
+ - **Default Branch:** main
117
+ - **Sample Code:** Disabled (no hello-world examples)
118
+ - **Dependency Upgrades:** Configured but can be adjusted
119
+ - **Turbo Repo:** Enabled for monorepo builds
120
+
121
+ ## Turbo Repo
122
+
123
+ ### What It Does
124
+
125
+ Turbo Repo is a build system for monorepos that:
126
+
127
+ - Caches build outputs intelligently
128
+ - Only rebuilds what changed
129
+ - Speeds up CI/CD significantly
130
+ - Works with remote caching
131
+
132
+ ### How It Works
133
+
134
+ **Hashing:** All input files (source code, configs) are hashed
135
+
136
+ **Cache Check:** If inputs haven't changed, cached outputs are reused
137
+
138
+ **Smart Rebuilds:** Only affected packages rebuild when dependencies change
139
+
140
+ **Remote Cache:** Build outputs stored in S3 (not Vercel) for team sharing
141
+
142
+ ### Running Locally
143
+
144
+ Before using Turbo Repo locally, you need AWS credentials:
145
+
146
+ ```bash
147
+ # Run the login script (credentials last ~8 hours)
148
+ ./scripts/aws-profile-turbo-repo.sh
149
+ ```
150
+
151
+ **Common Error:** If you get a "gRPC error" when running Turbo first thing in the morning, the Lambda function is cold. Just run the command again - it will work the second time.
152
+
153
+ ### Benefits
154
+
155
+ - **Fast CI:** Builds can complete in under a minute when using cached outputs
156
+ - **Selective Rebuilds:** Only changed code rebuilds, not the entire monorepo
157
+ - **Local + CI Sharing:** Cache between your machine and GitHub Actions
158
+
159
+ ## Automatic Dependency Updates
160
+
161
+ Our projects include a GitHub Action that:
162
+
163
+ - Runs weekly (configurable)
164
+ - Checks for updated packages
165
+ - Opens a PR with updates
166
+ - Runs all tests automatically
167
+
168
+ **Review Process:** If tests pass, the updates are likely safe to merge. Good test coverage makes this workflow reliable.
169
+
170
+ ## VS Code Configuration
171
+
172
+ Projects automatically include VS Code settings:
173
+
174
+ - Tab size: 2 spaces
175
+ - Format on save with Prettier
176
+ - Recommended extensions (can be customized)
177
+
178
+ Settings are in `.vscode/settings.json` (auto-generated).
179
+
180
+ ## Custom Components
181
+
182
+ You can create custom components for repeated configurations. Examples:
183
+
184
+ ### Storybook Component
185
+
186
+ ```typescript
187
+ // Adds Storybook with all necessary config
188
+ import { StorybookComponent } from './.projenrc/storybook';
189
+
190
+ // In your project config
191
+ new StorybookComponent(project);
192
+ ```
193
+
194
+ ### Playwright Component
195
+
196
+ ```typescript
197
+ // Adds Playwright testing framework
198
+ import { PlaywrightComponent } from './.projenrc/playwright';
199
+
200
+ new PlaywrightComponent(project);
201
+ ```
202
+
203
+ Components encapsulate:
204
+
205
+ - Dependencies (dev and production)
206
+ - Configuration files
207
+ - Build scripts
208
+ - Sample files (one-time generation)
209
+
210
+ ### Sample Files vs Config Files
211
+
212
+ **Config Files:** Deleted and regenerated on every `npx projen` run
213
+
214
+ - YAML, JSON, INI files
215
+ - TypeScript configs
216
+ - Build configurations
217
+
218
+ **Sample Files:** Generated once, never overwritten
219
+
220
+ - Starter code templates
221
+ - Example tests
222
+ - Framework setup files (e.g., Storybook's `main.ts`)
223
+
224
+ Sample files give you a starting point but won't receive updates. Modify them freely for your needs.
225
+
226
+ ## Working with Monorepos
227
+
228
+ ### Workspace Structure
229
+
230
+ Our monorepos use PNPM workspaces. The workspace file (`.pnpm-workspace.yaml`) is auto-generated and lists all sub-projects:
231
+
232
+ ```yaml
233
+ packages:
234
+ - 'packages/package-a'
235
+ - 'packages/package-b'
236
+ - 'apps/frontend'
237
+ ```
238
+
239
+ ### Opening Sub-Projects in VS Code
240
+
241
+ You can:
242
+
243
+ - Open the entire monorepo (uses root `.vscode/`)
244
+ - Open individual sub-projects (can have their own `.vscode/`)
245
+
246
+ For individual projects, consider creating VS Code workspace files (advanced topic).
247
+
248
+ ## Workflow Tips
249
+
250
+ ### Before Committing
251
+
252
+ Run Turbo build locally to cache everything:
253
+
254
+ ```bash
255
+ # This caches outputs that GitHub Actions can reuse
256
+ turbo run build
257
+ ```
258
+
259
+ Then commit and push. Your GitHub build will be much faster.
260
+
261
+ ### Adding New Packages
262
+
263
+ 1. Edit your `.projenrc.ts` configuration
264
+ 2. Add dependencies using the project API
265
+ 3. Run `npx projen` to regenerate configs
266
+ 4. Commit the changes
267
+
268
+ ### Updating Configulator
269
+
270
+ To receive updates from Configulator in your project:
271
+
272
+ 1. Update the version in `versions.ts`
273
+ 2. Run `npx projen`
274
+ 3. Review and test changes
275
+ 4. Commit
276
+
277
+ ## Common Patterns
278
+
279
+ ### Version Management
280
+
281
+ Versions for specific packages can be pinned in a `versions.ts` file:
282
+
283
+ ```typescript
284
+ export const versions = {
285
+ turbo: '1.10.0',
286
+ pnpm: '8.6.0',
287
+ node: '18.x'
288
+ };
289
+ ```
290
+
291
+ This gives you explicit control over important dependencies while letting others auto-update.
292
+
293
+ ### AWS Profiles Setup
294
+
295
+ For Turbo Repo caching and CDK deployment, set up AWS profiles:
296
+
297
+ ```bash
298
+ # Run the appropriate setup script
299
+ ./scripts/aws-profile-turbo-repo.sh
300
+ ```
301
+
302
+ These create temporary credentials (~8 hours) using SSO - much safer than long-lived access keys.
303
+
304
+ ## Troubleshooting
305
+
306
+ **"Cannot find module" errors**
307
+
308
+ Run `npx projen` to regenerate configuration files.
309
+
310
+ **Turbo Repo cache errors**
311
+
312
+ - Ensure you've run the AWS login script
313
+ - If it's your first run of the day, try running the command twice
314
+
315
+ **Build workflow failures**
316
+
317
+ Check that you haven't manually edited generated files. If you have, run `npx projen` to restore them.
318
+
319
+ **Dependency conflicts**
320
+
321
+ Don't mix `npm install` with Projen. Always add dependencies through configuration.
322
+
323
+ ## Next Steps
324
+
325
+ - Learn about CDK setup for AWS deployments
326
+ - Explore creating custom components for your team's needs
327
+ - Review project-specific configurations in existing repos (on-site, openhigh)
328
+ - Set up AWS profiles for Turbo Repo remote caching
329
+
330
+ ## Additional Resources
331
+
332
+ - **Projen Documentation:** https://projen.io
333
+ - **Turbo Repo Docs:** https://turbo.build/repo/docs
334
+ - **Code Drifters Configulator:** https://www.npmjs.com/package/@codedrifters/configulator
335
+
336
+ ---
337
+
338
+ **Remember:** The goal is consistency and automation. Let the tools manage the boilerplate so you can focus on building features.
339
+
340
+ # **ARCHIVE FROM INITIAL SETUP**
341
+ ## Configulator
2
342
 
3
343
  A library of [Projen](https://projen.io/) components used by CodeDrifters to manage repository configuration across various projects.
4
344
 
@@ -12,4 +352,4 @@ For a specific version, use:
12
352
 
13
353
  `npx projen new --from @codedrifters/configulator@0.0.15 monorepo`
14
354
 
15
- These docs are a work in progress and very light currently.
355
+ These docs are a work in progress and very light currently.
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "@swc/core": "^1.13.20",
14
14
  "@swc/jest": "^0.2.39",
15
15
  "@types/jest": "^30.0.0",
16
- "@types/node": "^22.18.10",
16
+ "@types/node": "^22.18.11",
17
17
  "@typescript-eslint/eslint-plugin": "^8",
18
18
  "@typescript-eslint/parser": "^8",
19
19
  "commit-and-tag-version": "^12",
@@ -35,12 +35,12 @@
35
35
  "projen": "0.98.0"
36
36
  },
37
37
  "dependencies": {
38
- "@jsii/spec": "^1.115.0",
38
+ "@jsii/spec": "^1.116.0",
39
39
  "type-fest": "^4"
40
40
  },
41
41
  "main": "lib/index.js",
42
42
  "license": "MIT",
43
- "version": "0.0.52",
43
+ "version": "0.0.54",
44
44
  "types": "lib/index.d.ts",
45
45
  "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\".",
46
46
  "scripts": {