@codedrifters/configulator 0.0.121 → 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 +7 -8
- package/lib/index.d.mts +119 -1
- package/lib/index.d.ts +120 -2
- package/lib/index.js +161 -41
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +147 -29
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -6
- package/vitest.config.ts +16 -0
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
|
-
- **
|
|
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
|
|
302
|
-
-
|
|
303
|
-
-
|
|
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
|
@@ -399,6 +399,10 @@ declare const VERSION: {
|
|
|
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
|
@@ -448,6 +448,10 @@ declare const VERSION: {
|
|
|
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 };
|
package/lib/index.js
CHANGED
|
@@ -186,6 +186,7 @@ __export(index_exports, {
|
|
|
186
186
|
ROOT_CI_TASK_NAME: () => ROOT_CI_TASK_NAME,
|
|
187
187
|
ROOT_TURBO_TASK_NAME: () => ROOT_TURBO_TASK_NAME,
|
|
188
188
|
ResetTask: () => ResetTask,
|
|
189
|
+
TestRunner: () => TestRunner,
|
|
189
190
|
TurboRepo: () => TurboRepo,
|
|
190
191
|
TurboRepoTask: () => TurboRepoTask,
|
|
191
192
|
TypeScriptConfig: () => TypeScriptConfig,
|
|
@@ -194,6 +195,7 @@ __export(index_exports, {
|
|
|
194
195
|
VERSION_KEYS_SKIP: () => VERSION_KEYS_SKIP,
|
|
195
196
|
VERSION_NPM_PACKAGES: () => VERSION_NPM_PACKAGES,
|
|
196
197
|
VSCodeConfig: () => VSCodeConfig,
|
|
198
|
+
Vitest: () => Vitest,
|
|
197
199
|
getLatestEligibleVersion: () => getLatestEligibleVersion
|
|
198
200
|
});
|
|
199
201
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -772,7 +774,8 @@ var VERSION_NPM_PACKAGES = [
|
|
|
772
774
|
{ key: "AWS_CONSTRUCTS_VERSION", npmPackage: "constructs" },
|
|
773
775
|
{ key: "PNPM_VERSION", npmPackage: "pnpm" },
|
|
774
776
|
{ key: "PROJEN_VERSION", npmPackage: "projen" },
|
|
775
|
-
{ key: "TURBO_VERSION", npmPackage: "turbo" }
|
|
777
|
+
{ key: "TURBO_VERSION", npmPackage: "turbo" },
|
|
778
|
+
{ key: "VITEST_VERSION", npmPackage: "vitest" }
|
|
776
779
|
];
|
|
777
780
|
var VERSION_KEYS_SKIP = ["NODE_WORKFLOWS"];
|
|
778
781
|
|
|
@@ -809,7 +812,11 @@ var VERSION = {
|
|
|
809
812
|
/**
|
|
810
813
|
* What version of the turborepo library should we use?
|
|
811
814
|
*/
|
|
812
|
-
TURBO_VERSION: "2.8.13"
|
|
815
|
+
TURBO_VERSION: "2.8.13",
|
|
816
|
+
/**
|
|
817
|
+
* What version of Vitest to use when testRunner is 'vitest'.
|
|
818
|
+
*/
|
|
819
|
+
VITEST_VERSION: "4.0.18"
|
|
813
820
|
};
|
|
814
821
|
|
|
815
822
|
// src/jsii/jsii-faker.ts
|
|
@@ -948,22 +955,116 @@ var PnpmWorkspace = class _PnpmWorkspace extends import_projen4.Component {
|
|
|
948
955
|
};
|
|
949
956
|
|
|
950
957
|
// src/projects/monorepo-project.ts
|
|
951
|
-
var
|
|
958
|
+
var import_javascript3 = require("projen/lib/javascript");
|
|
952
959
|
var import_typescript = require("projen/lib/typescript");
|
|
953
960
|
var import_ts_deepmerge2 = require("ts-deepmerge");
|
|
954
961
|
|
|
955
962
|
// src/tasks/reset-task.ts
|
|
956
|
-
var
|
|
963
|
+
var import_projen7 = require("projen");
|
|
957
964
|
|
|
958
965
|
// src/projects/typescript-project.ts
|
|
959
|
-
var
|
|
960
|
-
var
|
|
966
|
+
var import_projen6 = require("projen");
|
|
967
|
+
var import_javascript2 = require("projen/lib/javascript");
|
|
961
968
|
var import_release = require("projen/lib/release");
|
|
962
969
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
963
|
-
|
|
970
|
+
|
|
971
|
+
// src/vitest/vitest-component.ts
|
|
972
|
+
var import_projen5 = require("projen");
|
|
973
|
+
var import_javascript = require("projen/lib/javascript");
|
|
974
|
+
var import_textfile = require("projen/lib/textfile");
|
|
975
|
+
var Vitest = class _Vitest extends import_projen5.Component {
|
|
976
|
+
constructor(project, options = {}) {
|
|
977
|
+
super(project);
|
|
978
|
+
this.project = project;
|
|
979
|
+
this.configFilePath = options.configFilePath ?? "vitest.config.ts";
|
|
980
|
+
const config = options.config ?? {};
|
|
981
|
+
this.include = config.include ?? ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
982
|
+
this.exclude = config.exclude ?? [
|
|
983
|
+
"**/node_modules/**",
|
|
984
|
+
"**/dist/**",
|
|
985
|
+
"**/lib/**",
|
|
986
|
+
"**/.?*"
|
|
987
|
+
];
|
|
988
|
+
this.environment = config.environment ?? "node";
|
|
989
|
+
this.passWithNoTests = config.passWithNoTests ?? true;
|
|
990
|
+
this.coverageEnabled = config.coverageEnabled ?? true;
|
|
991
|
+
this.coverageDirectory = config.coverageDirectory ?? "coverage";
|
|
992
|
+
this.coverageReporters = config.coverageReporters ?? ["text", "lcov"];
|
|
993
|
+
this.version = options.vitestVersion ?? VERSION.VITEST_VERSION;
|
|
994
|
+
project.addDevDeps(`vitest@${this.version}`);
|
|
995
|
+
if (this.coverageEnabled) {
|
|
996
|
+
project.addDevDeps(`@vitest/coverage-v8@${this.version}`);
|
|
997
|
+
}
|
|
998
|
+
const coveragePath = `/${this.coverageDirectory}/`;
|
|
999
|
+
project.gitignore.addPatterns(coveragePath);
|
|
1000
|
+
project.npmignore?.exclude(coveragePath);
|
|
1001
|
+
this.addTestTasks();
|
|
1002
|
+
this.synthesizeConfig();
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Find the Vitest component on a project.
|
|
1006
|
+
*/
|
|
1007
|
+
static of(project) {
|
|
1008
|
+
const isVitest = (c) => c instanceof _Vitest;
|
|
1009
|
+
return project.components.find(isVitest);
|
|
1010
|
+
}
|
|
1011
|
+
preSynthesize() {
|
|
1012
|
+
super.preSynthesize();
|
|
1013
|
+
for (const component of this.project.components) {
|
|
1014
|
+
if (component instanceof import_javascript.Jest) {
|
|
1015
|
+
throw new Error("Vitest cannot be used together with Jest");
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
addTestTasks() {
|
|
1020
|
+
this.project.testTask.exec("vitest run --update");
|
|
1021
|
+
if (!this.project.tasks.tryFind("test:watch")) {
|
|
1022
|
+
this.project.addTask("test:watch", {
|
|
1023
|
+
description: "Run tests in watch mode",
|
|
1024
|
+
exec: "vitest watch",
|
|
1025
|
+
receiveArgs: true
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
synthesizeConfig() {
|
|
1030
|
+
this.project.tryRemoveFile(this.configFilePath);
|
|
1031
|
+
new import_textfile.TextFile(this, this.configFilePath, {
|
|
1032
|
+
lines: this.renderConfig()
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
renderConfig() {
|
|
1036
|
+
return [
|
|
1037
|
+
'import { defineConfig } from "vitest/config";',
|
|
1038
|
+
"",
|
|
1039
|
+
"export default defineConfig({",
|
|
1040
|
+
" test: {",
|
|
1041
|
+
` include: ${JSON.stringify(this.include)},`,
|
|
1042
|
+
` exclude: ${JSON.stringify(this.exclude)},`,
|
|
1043
|
+
` environment: "${this.environment}",`,
|
|
1044
|
+
` passWithNoTests: ${this.passWithNoTests},`,
|
|
1045
|
+
" coverage: {",
|
|
1046
|
+
` enabled: ${this.coverageEnabled},`,
|
|
1047
|
+
` provider: "v8",`,
|
|
1048
|
+
` reportsDirectory: "${this.coverageDirectory}",`,
|
|
1049
|
+
` reporter: ${JSON.stringify(this.coverageReporters)},`,
|
|
1050
|
+
" },",
|
|
1051
|
+
" },",
|
|
1052
|
+
"});"
|
|
1053
|
+
];
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
// src/projects/typescript-project.ts
|
|
1058
|
+
var TestRunner = {
|
|
1059
|
+
JEST: "jest",
|
|
1060
|
+
VITEST: "vitest"
|
|
1061
|
+
};
|
|
1062
|
+
var TypeScriptProject = class extends import_projen6.typescript.TypeScriptProject {
|
|
964
1063
|
constructor(userOptions) {
|
|
965
1064
|
const pnpmVersion = userOptions.parent && userOptions.parent instanceof MonorepoProject ? userOptions.parent.pnpmVersion : VERSION.PNPM_VERSION;
|
|
966
1065
|
const pnpmWorkspace = userOptions.parent && userOptions.parent instanceof MonorepoProject ? PnpmWorkspace.of(userOptions.parent) : void 0;
|
|
1066
|
+
const testRunner = userOptions.testRunner ?? TestRunner.JEST;
|
|
1067
|
+
const useJest = testRunner === TestRunner.JEST;
|
|
967
1068
|
const defaultOptions = {
|
|
968
1069
|
/**
|
|
969
1070
|
* This is a standard, so don't require it to passed in everywhere.
|
|
@@ -976,7 +1077,7 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
976
1077
|
/**
|
|
977
1078
|
* Packaging options
|
|
978
1079
|
*/
|
|
979
|
-
packageManager:
|
|
1080
|
+
packageManager: import_javascript2.NodePackageManager.PNPM,
|
|
980
1081
|
pnpmVersion,
|
|
981
1082
|
licensed: userOptions.license !== void 0 || false,
|
|
982
1083
|
copyrightOwner: "CodeDrifters",
|
|
@@ -985,27 +1086,32 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
985
1086
|
* Don't add sample code.
|
|
986
1087
|
*/
|
|
987
1088
|
sampleCode: false,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1089
|
+
...useJest ? {
|
|
1090
|
+
/**
|
|
1091
|
+
* Make sure jest config is stored outside of package.json
|
|
1092
|
+
*/
|
|
1093
|
+
jestOptions: {
|
|
1094
|
+
configFilePath: "jest.config.json",
|
|
1095
|
+
jestConfig: {
|
|
1096
|
+
roots: [`<rootDir>/src`],
|
|
1097
|
+
transform: {
|
|
1098
|
+
["^.+\\.[t]sx?$"]: new import_javascript2.Transform("@swc/jest")
|
|
1099
|
+
},
|
|
1100
|
+
moduleFileExtensions: ["js", "ts"]
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
/**
|
|
1104
|
+
* SWC for faster testing
|
|
1105
|
+
*/
|
|
1106
|
+
devDeps: ["@swc/jest", "@swc/core"]
|
|
1107
|
+
} : {
|
|
1108
|
+
jest: false,
|
|
1109
|
+
devDeps: []
|
|
1000
1110
|
},
|
|
1001
1111
|
/**
|
|
1002
1112
|
* Turn on prettier formatting
|
|
1003
1113
|
*/
|
|
1004
1114
|
prettier: true,
|
|
1005
|
-
/**
|
|
1006
|
-
* SWC for faster testing
|
|
1007
|
-
*/
|
|
1008
|
-
devDeps: ["@swc/jest", "@swc/core"],
|
|
1009
1115
|
/**
|
|
1010
1116
|
* Don't package test files.
|
|
1011
1117
|
*/
|
|
@@ -1024,7 +1130,7 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
1024
1130
|
exclude: Object.keys(pnpmWorkspace?.defaultCatalog || {}),
|
|
1025
1131
|
...userOptions.parent && userOptions.parent instanceof MonorepoProject ? {
|
|
1026
1132
|
workflowOptions: {
|
|
1027
|
-
schedule:
|
|
1133
|
+
schedule: import_javascript2.UpgradeDependenciesSchedule.WEEKLY
|
|
1028
1134
|
},
|
|
1029
1135
|
cooldown: 1
|
|
1030
1136
|
} : {}
|
|
@@ -1042,7 +1148,19 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
1042
1148
|
};
|
|
1043
1149
|
const options = (0, import_ts_deepmerge.merge)(defaultOptions, userOptions);
|
|
1044
1150
|
super(options);
|
|
1045
|
-
this.
|
|
1151
|
+
this.tsconfig?.addExclude("**/*.test.*");
|
|
1152
|
+
this.tsconfig?.addExclude("**/*.spec.*");
|
|
1153
|
+
if (options.testRunner === TestRunner.VITEST) {
|
|
1154
|
+
new Vitest(this, {
|
|
1155
|
+
config: {
|
|
1156
|
+
include: ["src/**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
|
1157
|
+
...options.vitestOptions?.config
|
|
1158
|
+
},
|
|
1159
|
+
...options.vitestOptions
|
|
1160
|
+
});
|
|
1161
|
+
} else {
|
|
1162
|
+
this.deps.removeDependency("ts-jest");
|
|
1163
|
+
}
|
|
1046
1164
|
this.package.file.addOverride(
|
|
1047
1165
|
"packageManager",
|
|
1048
1166
|
`pnpm@${options.pnpmVersion}`
|
|
@@ -1053,7 +1171,7 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
1053
1171
|
"import/no-extraneous-dependencies": "off"
|
|
1054
1172
|
}
|
|
1055
1173
|
});
|
|
1056
|
-
this.gitignore?.addPatterns(".DS_Store");
|
|
1174
|
+
this.gitignore?.addPatterns(".DS_Store", "test-reports");
|
|
1057
1175
|
this.npmignore?.addPatterns("*.spec.*", "*.test.*", "__fixtures__");
|
|
1058
1176
|
const turboActive = userOptions.parent && TurboRepo.of(userOptions.parent) !== void 0;
|
|
1059
1177
|
if (turboActive) {
|
|
@@ -1101,7 +1219,7 @@ var TypeScriptProject = class extends import_projen5.typescript.TypeScriptProjec
|
|
|
1101
1219
|
};
|
|
1102
1220
|
|
|
1103
1221
|
// src/tasks/reset-task.ts
|
|
1104
|
-
var ResetTask = class _ResetTask extends
|
|
1222
|
+
var ResetTask = class _ResetTask extends import_projen7.Component {
|
|
1105
1223
|
constructor(project, options = {}) {
|
|
1106
1224
|
super(project);
|
|
1107
1225
|
this.project = project;
|
|
@@ -1174,12 +1292,12 @@ var ResetTask = class _ResetTask extends import_projen6.Component {
|
|
|
1174
1292
|
};
|
|
1175
1293
|
|
|
1176
1294
|
// src/vscode/vscode.ts
|
|
1177
|
-
var
|
|
1178
|
-
var VSCodeConfig = class extends
|
|
1295
|
+
var import_projen8 = require("projen");
|
|
1296
|
+
var VSCodeConfig = class extends import_projen8.Component {
|
|
1179
1297
|
constructor(project) {
|
|
1180
1298
|
super(project);
|
|
1181
|
-
const vsConfig = new
|
|
1182
|
-
const vsSettings = new
|
|
1299
|
+
const vsConfig = new import_projen8.vscode.VsCode(project);
|
|
1300
|
+
const vsSettings = new import_projen8.vscode.VsCodeSettings(vsConfig);
|
|
1183
1301
|
vsSettings.addSetting("editor.tabSize", 2);
|
|
1184
1302
|
vsSettings.addSetting("editor.detectIndentation", false);
|
|
1185
1303
|
vsSettings.addSetting("editor.bracketPairColorization.enabled", true);
|
|
@@ -1283,7 +1401,7 @@ var MonorepoProject = class extends import_typescript.TypeScriptAppProject {
|
|
|
1283
1401
|
depsUpgrade: true,
|
|
1284
1402
|
depsUpgradeOptions: {
|
|
1285
1403
|
workflowOptions: {
|
|
1286
|
-
schedule:
|
|
1404
|
+
schedule: import_javascript3.UpgradeDependenciesSchedule.DAILY
|
|
1287
1405
|
},
|
|
1288
1406
|
cooldown: 1
|
|
1289
1407
|
},
|
|
@@ -1339,7 +1457,7 @@ var MonorepoProject = class extends import_typescript.TypeScriptAppProject {
|
|
|
1339
1457
|
* Use PNPM instead of the default (Yarn). Much of the ecosystem depends
|
|
1340
1458
|
* on PNPM and making monorepos PNPM only simplifies many configurations.
|
|
1341
1459
|
*/
|
|
1342
|
-
packageManager:
|
|
1460
|
+
packageManager: import_javascript3.NodePackageManager.PNPM,
|
|
1343
1461
|
/**
|
|
1344
1462
|
* Some additional pre-build steps if we're using turbo's remote cache.
|
|
1345
1463
|
* Set GIT_BRANCH_NAME so Turborepo remote cache hashes match between local and CI.
|
|
@@ -1398,17 +1516,17 @@ var MonorepoProject = class extends import_typescript.TypeScriptAppProject {
|
|
|
1398
1516
|
"packageManager",
|
|
1399
1517
|
`pnpm@${options.pnpmVersion}`
|
|
1400
1518
|
);
|
|
1401
|
-
this.gitignore?.addPatterns(".DS_Store");
|
|
1519
|
+
this.gitignore?.addPatterns(".DS_Store", "test-reports");
|
|
1402
1520
|
this.addDevDeps("constructs@catalog:");
|
|
1403
1521
|
if (options.upgradeConfigulatorTask === true) {
|
|
1404
|
-
this.upgradeConfigulatorTask = new
|
|
1522
|
+
this.upgradeConfigulatorTask = new import_javascript3.UpgradeDependencies(
|
|
1405
1523
|
this,
|
|
1406
1524
|
(0, import_ts_deepmerge2.merge)(
|
|
1407
1525
|
{
|
|
1408
1526
|
include: ["@codedrifters/configulator"],
|
|
1409
1527
|
taskName: `upgrade-codedrifters-configulator`,
|
|
1410
1528
|
workflowOptions: {
|
|
1411
|
-
schedule:
|
|
1529
|
+
schedule: import_javascript3.UpgradeDependenciesSchedule.DAILY
|
|
1412
1530
|
}
|
|
1413
1531
|
},
|
|
1414
1532
|
options.upgradeConfigulatorTaskOptions ?? {}
|
|
@@ -1448,9 +1566,9 @@ var MonorepoProject = class extends import_typescript.TypeScriptAppProject {
|
|
|
1448
1566
|
|
|
1449
1567
|
// src/typescript/typescript-config.ts
|
|
1450
1568
|
var import_node_path2 = require("path");
|
|
1451
|
-
var
|
|
1569
|
+
var import_projen9 = require("projen");
|
|
1452
1570
|
var import_path2 = require("projen/lib/util/path");
|
|
1453
|
-
var TypeScriptConfig = class extends
|
|
1571
|
+
var TypeScriptConfig = class extends import_projen9.Component {
|
|
1454
1572
|
constructor(project) {
|
|
1455
1573
|
super(project);
|
|
1456
1574
|
let tsPaths = {};
|
|
@@ -1478,12 +1596,12 @@ var TypeScriptConfig = class extends import_projen8.Component {
|
|
|
1478
1596
|
|
|
1479
1597
|
// src/workflows/aws-deploy-workflow.ts
|
|
1480
1598
|
var import_utils3 = __toESM(require_lib());
|
|
1481
|
-
var
|
|
1599
|
+
var import_projen10 = require("projen");
|
|
1482
1600
|
var import_build = require("projen/lib/build");
|
|
1483
1601
|
var import_github = require("projen/lib/github");
|
|
1484
1602
|
var import_workflows_model2 = require("projen/lib/github/workflows-model");
|
|
1485
1603
|
var PROD_DEPLOY_NAME = "prod-deploy";
|
|
1486
|
-
var AwsDeployWorkflow = class _AwsDeployWorkflow extends
|
|
1604
|
+
var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen10.Component {
|
|
1487
1605
|
constructor(project, options = {}) {
|
|
1488
1606
|
super(project);
|
|
1489
1607
|
this.project = project;
|
|
@@ -1746,6 +1864,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen9.Componen
|
|
|
1746
1864
|
ROOT_CI_TASK_NAME,
|
|
1747
1865
|
ROOT_TURBO_TASK_NAME,
|
|
1748
1866
|
ResetTask,
|
|
1867
|
+
TestRunner,
|
|
1749
1868
|
TurboRepo,
|
|
1750
1869
|
TurboRepoTask,
|
|
1751
1870
|
TypeScriptConfig,
|
|
@@ -1754,6 +1873,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends import_projen9.Componen
|
|
|
1754
1873
|
VERSION_KEYS_SKIP,
|
|
1755
1874
|
VERSION_NPM_PACKAGES,
|
|
1756
1875
|
VSCodeConfig,
|
|
1876
|
+
Vitest,
|
|
1757
1877
|
getLatestEligibleVersion
|
|
1758
1878
|
});
|
|
1759
1879
|
//# sourceMappingURL=index.js.map
|