@codedrifters/configulator 0.0.120 → 0.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,7 +36,7 @@ Projen is a project generator and configuration management tool that:
36
36
 
37
37
  ### Key Concepts
38
38
 
39
- **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.
39
+ **Components:** Individual pieces of configuration (e.g., Jest, Vitest, 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.
40
40
 
41
41
  **Project Types:** Base-level configurations for different kinds of projects (e.g., TypeScript app, monorepo, React project).
42
42
 
@@ -204,9 +204,8 @@ Use `TypeScriptProject` for:
204
204
  #### Key Features
205
205
 
206
206
  - **Automatic PNPM Version Inheritance**: Inherits PNPM version from parent `MonorepoProject` when used as a sub-project
207
- - **SWC for Testing**: Uses `@swc/jest` instead of `ts-jest` for faster test execution
207
+ - **Configurable Test Runner**: Choose Jest (default) or Vitest via the `testRunner` option. Jest uses `@swc/jest` for fast execution; Vitest uses a generated `vitest.config.ts` with coverage and watch tasks.
208
208
  - **Prettier Integration**: Automatic Prettier configuration
209
- - **Jest Configuration**: External Jest config file (not in package.json) with sensible defaults
210
209
  - **Automatic Turborepo Integration**: Automatically configures Turborepo tasks when parent has TurboRepo enabled
211
210
  - **Catalog Dependency Support**: Can use catalog dependencies defined in parent workspace
212
211
  - **Release Support**: Built-in support for NPM releases with continuous deployment triggers
@@ -297,12 +296,12 @@ The `TypeScriptProject` accepts all options from Projen's `TypeScriptProjectOpti
297
296
  | `sampleCode` | `boolean` | `false` | Generate sample code |
298
297
  | `release` | `boolean` | `false` | Enable NPM releases |
299
298
  | `licensed` | `boolean` | `false` | Include license (unless `license` option provided) |
299
+ | `testRunner` | `TestRunner` | `TestRunner.JEST` | Test runner: `TestRunner.JEST` or `TestRunner.VITEST` |
300
+ | `vitestOptions` | `VitestOptions` | `undefined` | Options for Vitest (only used when `testRunner` is `TestRunner.VITEST`) |
300
301
 
301
- **Jest Configuration:**
302
- - Uses external `jest.config.json` file
303
- - Configured to use `@swc/jest` for faster compilation
304
- - Test files in `src/` directory
305
- - ESLint rule `import/no-extraneous-dependencies` disabled for test files
302
+ **Test runner (Jest or Vitest):**
303
+ - **Jest (default):** External `jest.config.json`, `@swc/jest` for fast compilation, test files in `src/`. Use when you want to keep existing Jest-based workflows.
304
+ - **Vitest:** Set `testRunner: TestRunner.VITEST` to use Vitest. The project gets a generated `vitest.config.ts`, `vitest` (and optionally `@vitest/coverage-v8`) as devDeps, and tasks: `test` (runs `vitest run`), `test:watch`. Snapshots are updated automatically on each test run to match the project's previous Jest behavior (no separate snapshot-update step). Coverage directory is added to `.gitignore` and `.npmignore`. Jest is disabled (`jest: false`) when Vitest is selected; the two cannot be used together.
306
305
 
307
306
  **NPM Ignore:**
308
307
  - Automatically ignores `*.spec.*`, `*.test.*`, and `__fixtures__` patterns
package/lib/index.d.mts CHANGED
@@ -394,11 +394,15 @@ declare const VERSION: {
394
394
  /**
395
395
  * Version of Projen to use.
396
396
  */
397
- readonly PROJEN_VERSION: "0.99.17";
397
+ readonly PROJEN_VERSION: "0.99.18";
398
398
  /**
399
399
  * What version of the turborepo library should we use?
400
400
  */
401
401
  readonly TURBO_VERSION: "2.8.13";
402
+ /**
403
+ * What version of Vitest to use when testRunner is 'vitest'.
404
+ */
405
+ readonly VITEST_VERSION: "4.0.18";
402
406
  };
403
407
 
404
408
  /**
@@ -1265,10 +1269,124 @@ declare class MonorepoProject extends TypeScriptAppProject {
1265
1269
  postSynthesize(): void;
1266
1270
  }
1267
1271
 
1272
+ /**
1273
+ * Options for the Vitest config (test block in vitest.config).
1274
+ *
1275
+ * @see https://vitest.dev/config/
1276
+ */
1277
+ interface VitestConfigOptions {
1278
+ /**
1279
+ * Glob patterns for test files.
1280
+ *
1281
+ * @default ["**\/*.{test,spec}.?(c|m)[jt]s?(x)"]
1282
+ */
1283
+ readonly include?: string[];
1284
+ /**
1285
+ * Glob patterns to exclude from test files.
1286
+ *
1287
+ * @default ["**\/node_modules\/**", "**\/dist\/**", "**\/lib\/**", "**\/.?\*"]
1288
+ */
1289
+ readonly exclude?: string[];
1290
+ /**
1291
+ * Test environment.
1292
+ *
1293
+ * @default "node"
1294
+ */
1295
+ readonly environment?: "node" | "jsdom" | "happy-dom" | "edge-runtime";
1296
+ /**
1297
+ * Do not fail when no tests are found.
1298
+ *
1299
+ * @default true
1300
+ */
1301
+ readonly passWithNoTests?: boolean;
1302
+ /**
1303
+ * Enable coverage collection.
1304
+ *
1305
+ * @default true
1306
+ */
1307
+ readonly coverageEnabled?: boolean;
1308
+ /**
1309
+ * Coverage reports directory.
1310
+ *
1311
+ * @default "coverage"
1312
+ */
1313
+ readonly coverageDirectory?: string;
1314
+ /**
1315
+ * Coverage reporters.
1316
+ *
1317
+ * @default ["text", "lcov"]
1318
+ */
1319
+ readonly coverageReporters?: string[];
1320
+ }
1321
+ /**
1322
+ * Options for the Vitest component.
1323
+ */
1324
+ interface VitestOptions {
1325
+ /**
1326
+ * Config file path.
1327
+ *
1328
+ * @default "vitest.config.ts"
1329
+ */
1330
+ readonly configFilePath?: string;
1331
+ /**
1332
+ * Vitest config (test block).
1333
+ */
1334
+ readonly config?: VitestConfigOptions;
1335
+ /**
1336
+ * Vitest version (overrides VERSION.VITEST_VERSION).
1337
+ */
1338
+ readonly vitestVersion?: string;
1339
+ }
1340
+ /**
1341
+ * Vitest component for Node/TypeScript projects.
1342
+ *
1343
+ * Adds Vitest as the test runner: devDeps, vitest.config.ts, and test/watch tasks.
1344
+ * Incompatible with Jest; use jest: false when constructing the project.
1345
+ */
1346
+ declare class Vitest extends Component {
1347
+ readonly project: NodeProject;
1348
+ /**
1349
+ * Find the Vitest component on a project.
1350
+ */
1351
+ static of(project: NodeProject): Vitest | undefined;
1352
+ private readonly configFilePath;
1353
+ private readonly include;
1354
+ private readonly exclude;
1355
+ private readonly environment;
1356
+ private readonly passWithNoTests;
1357
+ private readonly coverageEnabled;
1358
+ private readonly coverageDirectory;
1359
+ private readonly coverageReporters;
1360
+ private readonly version;
1361
+ constructor(project: NodeProject, options?: VitestOptions);
1362
+ preSynthesize(): void;
1363
+ private addTestTasks;
1364
+ private synthesizeConfig;
1365
+ private renderConfig;
1366
+ }
1367
+
1368
+ /**
1369
+ * Test runner for TypeScript projects.
1370
+ */
1371
+ declare const TestRunner: {
1372
+ readonly JEST: "jest";
1373
+ readonly VITEST: "vitest";
1374
+ };
1375
+ type TestRunner = (typeof TestRunner)[keyof typeof TestRunner];
1268
1376
  /**
1269
1377
  * Configuration options for TypeScriptProject.
1270
1378
  */
1271
1379
  interface TypeScriptProjectOptions extends Omit<typescript.TypeScriptProjectOptions, "defaultReleaseBranch"> {
1380
+ /**
1381
+ * Test runner to use.
1382
+ *
1383
+ * @default TestRunner.JEST
1384
+ */
1385
+ readonly testRunner?: TestRunner;
1386
+ /**
1387
+ * Options for Vitest (only used when testRunner is 'vitest').
1388
+ */
1389
+ readonly vitestOptions?: VitestOptions;
1272
1390
  /**
1273
1391
  * Enable the reset task that deletes all build artifacts.
1274
1392
  *
@@ -1386,4 +1504,4 @@ declare class AwsDeployWorkflow extends Component {
1386
1504
  preSynthesize(): void;
1387
1505
  }
1388
1506
 
1389
- export { type AwsAccount, AwsDeployWorkflow, AwsDeploymentConfig, AwsDeploymentTarget, type AwsDeploymentTargetOptions, type AwsLocalDeploymentConfig, type AwsOrganization, type AwsRegion, type CiDeploymentConfig, type ClassTypeOptions, type DeployWorkflowOptions, type GitBranch, type IDependencyResolver, JsiiFaker, MIMIMUM_RELEASE_AGE, MonorepoProject, type MonorepoProjectOptions, PROD_DEPLOY_NAME, PnpmWorkspace, type PnpmWorkspaceOptions, ROOT_CI_TASK_NAME, ROOT_TURBO_TASK_NAME, type RemoteCacheOptions, ResetTask, type ResetTaskOptions, TurboRepo, type TurboRepoOptions, TurboRepoTask, type TurboRepoTaskOptions, TypeScriptConfig, TypeScriptProject, type TypeScriptProjectOptions, VERSION, VERSION_KEYS_SKIP, VERSION_NPM_PACKAGES, VSCodeConfig, type VersionKey, getLatestEligibleVersion };
1507
+ export { type AwsAccount, AwsDeployWorkflow, AwsDeploymentConfig, AwsDeploymentTarget, type AwsDeploymentTargetOptions, type AwsLocalDeploymentConfig, type AwsOrganization, type AwsRegion, type CiDeploymentConfig, type ClassTypeOptions, type DeployWorkflowOptions, type GitBranch, type IDependencyResolver, JsiiFaker, MIMIMUM_RELEASE_AGE, MonorepoProject, type MonorepoProjectOptions, PROD_DEPLOY_NAME, PnpmWorkspace, type PnpmWorkspaceOptions, ROOT_CI_TASK_NAME, ROOT_TURBO_TASK_NAME, type RemoteCacheOptions, ResetTask, type ResetTaskOptions, TestRunner, TurboRepo, type TurboRepoOptions, TurboRepoTask, type TurboRepoTaskOptions, TypeScriptConfig, TypeScriptProject, type TypeScriptProjectOptions, VERSION, VERSION_KEYS_SKIP, VERSION_NPM_PACKAGES, VSCodeConfig, type VersionKey, Vitest, type VitestConfigOptions, type VitestOptions, getLatestEligibleVersion };
package/lib/index.d.ts CHANGED
@@ -443,11 +443,15 @@ declare const VERSION: {
443
443
  /**
444
444
  * Version of Projen to use.
445
445
  */
446
- readonly PROJEN_VERSION: "0.99.17";
446
+ readonly PROJEN_VERSION: "0.99.18";
447
447
  /**
448
448
  * What version of the turborepo library should we use?
449
449
  */
450
450
  readonly TURBO_VERSION: "2.8.13";
451
+ /**
452
+ * What version of Vitest to use when testRunner is 'vitest'.
453
+ */
454
+ readonly VITEST_VERSION: "4.0.18";
451
455
  };
452
456
 
453
457
  /**
@@ -1314,10 +1318,124 @@ declare class MonorepoProject extends TypeScriptAppProject {
1314
1318
  postSynthesize(): void;
1315
1319
  }
1316
1320
 
1321
+ /**
1322
+ * Options for the Vitest config (test block in vitest.config).
1323
+ *
1324
+ * @see https://vitest.dev/config/
1325
+ */
1326
+ interface VitestConfigOptions {
1327
+ /**
1328
+ * Glob patterns for test files.
1329
+ *
1330
+ * @default ["**\/*.{test,spec}.?(c|m)[jt]s?(x)"]
1331
+ */
1332
+ readonly include?: string[];
1333
+ /**
1334
+ * Glob patterns to exclude from test files.
1335
+ *
1336
+ * @default ["**\/node_modules\/**", "**\/dist\/**", "**\/lib\/**", "**\/.?\*"]
1337
+ */
1338
+ readonly exclude?: string[];
1339
+ /**
1340
+ * Test environment.
1341
+ *
1342
+ * @default "node"
1343
+ */
1344
+ readonly environment?: "node" | "jsdom" | "happy-dom" | "edge-runtime";
1345
+ /**
1346
+ * Do not fail when no tests are found.
1347
+ *
1348
+ * @default true
1349
+ */
1350
+ readonly passWithNoTests?: boolean;
1351
+ /**
1352
+ * Enable coverage collection.
1353
+ *
1354
+ * @default true
1355
+ */
1356
+ readonly coverageEnabled?: boolean;
1357
+ /**
1358
+ * Coverage reports directory.
1359
+ *
1360
+ * @default "coverage"
1361
+ */
1362
+ readonly coverageDirectory?: string;
1363
+ /**
1364
+ * Coverage reporters.
1365
+ *
1366
+ * @default ["text", "lcov"]
1367
+ */
1368
+ readonly coverageReporters?: string[];
1369
+ }
1370
+ /**
1371
+ * Options for the Vitest component.
1372
+ */
1373
+ interface VitestOptions {
1374
+ /**
1375
+ * Config file path.
1376
+ *
1377
+ * @default "vitest.config.ts"
1378
+ */
1379
+ readonly configFilePath?: string;
1380
+ /**
1381
+ * Vitest config (test block).
1382
+ */
1383
+ readonly config?: VitestConfigOptions;
1384
+ /**
1385
+ * Vitest version (overrides VERSION.VITEST_VERSION).
1386
+ */
1387
+ readonly vitestVersion?: string;
1388
+ }
1389
+ /**
1390
+ * Vitest component for Node/TypeScript projects.
1391
+ *
1392
+ * Adds Vitest as the test runner: devDeps, vitest.config.ts, and test/watch tasks.
1393
+ * Incompatible with Jest; use jest: false when constructing the project.
1394
+ */
1395
+ declare class Vitest extends Component {
1396
+ readonly project: NodeProject;
1397
+ /**
1398
+ * Find the Vitest component on a project.
1399
+ */
1400
+ static of(project: NodeProject): Vitest | undefined;
1401
+ private readonly configFilePath;
1402
+ private readonly include;
1403
+ private readonly exclude;
1404
+ private readonly environment;
1405
+ private readonly passWithNoTests;
1406
+ private readonly coverageEnabled;
1407
+ private readonly coverageDirectory;
1408
+ private readonly coverageReporters;
1409
+ private readonly version;
1410
+ constructor(project: NodeProject, options?: VitestOptions);
1411
+ preSynthesize(): void;
1412
+ private addTestTasks;
1413
+ private synthesizeConfig;
1414
+ private renderConfig;
1415
+ }
1416
+
1417
+ /**
1418
+ * Test runner for TypeScript projects.
1419
+ */
1420
+ declare const TestRunner: {
1421
+ readonly JEST: "jest";
1422
+ readonly VITEST: "vitest";
1423
+ };
1424
+ type TestRunner = (typeof TestRunner)[keyof typeof TestRunner];
1317
1425
  /**
1318
1426
  * Configuration options for TypeScriptProject.
1319
1427
  */
1320
1428
  interface TypeScriptProjectOptions extends Omit<typescript.TypeScriptProjectOptions, "defaultReleaseBranch"> {
1429
+ /**
1430
+ * Test runner to use.
1431
+ *
1432
+ * @default TestRunner.JEST
1433
+ */
1434
+ readonly testRunner?: TestRunner;
1435
+ /**
1436
+ * Options for Vitest (only used when testRunner is 'vitest').
1437
+ */
1438
+ readonly vitestOptions?: VitestOptions;
1321
1439
  /**
1322
1440
  * Enable the reset task that deletes all build artifacts.
1323
1441
  *
@@ -1435,5 +1553,5 @@ declare class AwsDeployWorkflow extends Component {
1435
1553
  preSynthesize(): void;
1436
1554
  }
1437
1555
 
1438
- export { AwsDeployWorkflow, AwsDeploymentConfig, AwsDeploymentTarget, JsiiFaker, MIMIMUM_RELEASE_AGE, MonorepoProject, PROD_DEPLOY_NAME, PnpmWorkspace, ROOT_CI_TASK_NAME, ROOT_TURBO_TASK_NAME, ResetTask, TurboRepo, TurboRepoTask, TypeScriptConfig, TypeScriptProject, VERSION, VERSION_KEYS_SKIP, VERSION_NPM_PACKAGES, VSCodeConfig, getLatestEligibleVersion };
1439
- export type { AwsAccount, AwsDeploymentTargetOptions, AwsLocalDeploymentConfig, AwsOrganization, AwsRegion, CiDeploymentConfig, ClassTypeOptions, DeployWorkflowOptions, GitBranch, IDependencyResolver, MonorepoProjectOptions, PnpmWorkspaceOptions, RemoteCacheOptions, ResetTaskOptions, TurboRepoOptions, TurboRepoTaskOptions, TypeScriptProjectOptions, VersionKey };
1556
+ export { AwsDeployWorkflow, AwsDeploymentConfig, AwsDeploymentTarget, JsiiFaker, MIMIMUM_RELEASE_AGE, MonorepoProject, PROD_DEPLOY_NAME, PnpmWorkspace, ROOT_CI_TASK_NAME, ROOT_TURBO_TASK_NAME, ResetTask, TestRunner, TurboRepo, TurboRepoTask, TypeScriptConfig, TypeScriptProject, VERSION, VERSION_KEYS_SKIP, VERSION_NPM_PACKAGES, VSCodeConfig, Vitest, getLatestEligibleVersion };
1557
+ export type { AwsAccount, AwsDeploymentTargetOptions, AwsLocalDeploymentConfig, AwsOrganization, AwsRegion, CiDeploymentConfig, ClassTypeOptions, DeployWorkflowOptions, GitBranch, IDependencyResolver, MonorepoProjectOptions, PnpmWorkspaceOptions, RemoteCacheOptions, ResetTaskOptions, TurboRepoOptions, TurboRepoTaskOptions, TypeScriptProjectOptions, VersionKey, VitestConfigOptions, VitestOptions };