@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/lib/index.mjs
CHANGED
|
@@ -746,7 +746,8 @@ var VERSION_NPM_PACKAGES = [
|
|
|
746
746
|
{ key: "AWS_CONSTRUCTS_VERSION", npmPackage: "constructs" },
|
|
747
747
|
{ key: "PNPM_VERSION", npmPackage: "pnpm" },
|
|
748
748
|
{ key: "PROJEN_VERSION", npmPackage: "projen" },
|
|
749
|
-
{ key: "TURBO_VERSION", npmPackage: "turbo" }
|
|
749
|
+
{ key: "TURBO_VERSION", npmPackage: "turbo" },
|
|
750
|
+
{ key: "VITEST_VERSION", npmPackage: "vitest" }
|
|
750
751
|
];
|
|
751
752
|
var VERSION_KEYS_SKIP = ["NODE_WORKFLOWS"];
|
|
752
753
|
|
|
@@ -783,7 +784,11 @@ var VERSION = {
|
|
|
783
784
|
/**
|
|
784
785
|
* What version of the turborepo library should we use?
|
|
785
786
|
*/
|
|
786
|
-
TURBO_VERSION: "2.8.13"
|
|
787
|
+
TURBO_VERSION: "2.8.13",
|
|
788
|
+
/**
|
|
789
|
+
* What version of Vitest to use when testRunner is 'vitest'.
|
|
790
|
+
*/
|
|
791
|
+
VITEST_VERSION: "4.0.18"
|
|
787
792
|
};
|
|
788
793
|
|
|
789
794
|
// src/jsii/jsii-faker.ts
|
|
@@ -933,7 +938,7 @@ import {
|
|
|
933
938
|
import { merge as merge2 } from "ts-deepmerge";
|
|
934
939
|
|
|
935
940
|
// src/tasks/reset-task.ts
|
|
936
|
-
import { Component as
|
|
941
|
+
import { Component as Component8 } from "projen";
|
|
937
942
|
|
|
938
943
|
// src/projects/typescript-project.ts
|
|
939
944
|
import { typescript } from "projen";
|
|
@@ -944,10 +949,104 @@ import {
|
|
|
944
949
|
} from "projen/lib/javascript";
|
|
945
950
|
import { ReleaseTrigger } from "projen/lib/release";
|
|
946
951
|
import { merge } from "ts-deepmerge";
|
|
952
|
+
|
|
953
|
+
// src/vitest/vitest-component.ts
|
|
954
|
+
import { Component as Component7 } from "projen";
|
|
955
|
+
import { Jest } from "projen/lib/javascript";
|
|
956
|
+
import { TextFile } from "projen/lib/textfile";
|
|
957
|
+
var Vitest = class _Vitest extends Component7 {
|
|
958
|
+
constructor(project, options = {}) {
|
|
959
|
+
super(project);
|
|
960
|
+
this.project = project;
|
|
961
|
+
this.configFilePath = options.configFilePath ?? "vitest.config.ts";
|
|
962
|
+
const config = options.config ?? {};
|
|
963
|
+
this.include = config.include ?? ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
964
|
+
this.exclude = config.exclude ?? [
|
|
965
|
+
"**/node_modules/**",
|
|
966
|
+
"**/dist/**",
|
|
967
|
+
"**/lib/**",
|
|
968
|
+
"**/.?*"
|
|
969
|
+
];
|
|
970
|
+
this.environment = config.environment ?? "node";
|
|
971
|
+
this.passWithNoTests = config.passWithNoTests ?? true;
|
|
972
|
+
this.coverageEnabled = config.coverageEnabled ?? true;
|
|
973
|
+
this.coverageDirectory = config.coverageDirectory ?? "coverage";
|
|
974
|
+
this.coverageReporters = config.coverageReporters ?? ["text", "lcov"];
|
|
975
|
+
this.version = options.vitestVersion ?? VERSION.VITEST_VERSION;
|
|
976
|
+
project.addDevDeps(`vitest@${this.version}`);
|
|
977
|
+
if (this.coverageEnabled) {
|
|
978
|
+
project.addDevDeps(`@vitest/coverage-v8@${this.version}`);
|
|
979
|
+
}
|
|
980
|
+
const coveragePath = `/${this.coverageDirectory}/`;
|
|
981
|
+
project.gitignore.addPatterns(coveragePath);
|
|
982
|
+
project.npmignore?.exclude(coveragePath);
|
|
983
|
+
this.addTestTasks();
|
|
984
|
+
this.synthesizeConfig();
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Find the Vitest component on a project.
|
|
988
|
+
*/
|
|
989
|
+
static of(project) {
|
|
990
|
+
const isVitest = (c) => c instanceof _Vitest;
|
|
991
|
+
return project.components.find(isVitest);
|
|
992
|
+
}
|
|
993
|
+
preSynthesize() {
|
|
994
|
+
super.preSynthesize();
|
|
995
|
+
for (const component of this.project.components) {
|
|
996
|
+
if (component instanceof Jest) {
|
|
997
|
+
throw new Error("Vitest cannot be used together with Jest");
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
addTestTasks() {
|
|
1002
|
+
this.project.testTask.exec("vitest run --update");
|
|
1003
|
+
if (!this.project.tasks.tryFind("test:watch")) {
|
|
1004
|
+
this.project.addTask("test:watch", {
|
|
1005
|
+
description: "Run tests in watch mode",
|
|
1006
|
+
exec: "vitest watch",
|
|
1007
|
+
receiveArgs: true
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
synthesizeConfig() {
|
|
1012
|
+
this.project.tryRemoveFile(this.configFilePath);
|
|
1013
|
+
new TextFile(this, this.configFilePath, {
|
|
1014
|
+
lines: this.renderConfig()
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
renderConfig() {
|
|
1018
|
+
return [
|
|
1019
|
+
'import { defineConfig } from "vitest/config";',
|
|
1020
|
+
"",
|
|
1021
|
+
"export default defineConfig({",
|
|
1022
|
+
" test: {",
|
|
1023
|
+
` include: ${JSON.stringify(this.include)},`,
|
|
1024
|
+
` exclude: ${JSON.stringify(this.exclude)},`,
|
|
1025
|
+
` environment: "${this.environment}",`,
|
|
1026
|
+
` passWithNoTests: ${this.passWithNoTests},`,
|
|
1027
|
+
" coverage: {",
|
|
1028
|
+
` enabled: ${this.coverageEnabled},`,
|
|
1029
|
+
` provider: "v8",`,
|
|
1030
|
+
` reportsDirectory: "${this.coverageDirectory}",`,
|
|
1031
|
+
` reporter: ${JSON.stringify(this.coverageReporters)},`,
|
|
1032
|
+
" },",
|
|
1033
|
+
" },",
|
|
1034
|
+
"});"
|
|
1035
|
+
];
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
// src/projects/typescript-project.ts
|
|
1040
|
+
var TestRunner = {
|
|
1041
|
+
JEST: "jest",
|
|
1042
|
+
VITEST: "vitest"
|
|
1043
|
+
};
|
|
947
1044
|
var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
948
1045
|
constructor(userOptions) {
|
|
949
1046
|
const pnpmVersion = userOptions.parent && userOptions.parent instanceof MonorepoProject ? userOptions.parent.pnpmVersion : VERSION.PNPM_VERSION;
|
|
950
1047
|
const pnpmWorkspace = userOptions.parent && userOptions.parent instanceof MonorepoProject ? PnpmWorkspace.of(userOptions.parent) : void 0;
|
|
1048
|
+
const testRunner = userOptions.testRunner ?? TestRunner.JEST;
|
|
1049
|
+
const useJest = testRunner === TestRunner.JEST;
|
|
951
1050
|
const defaultOptions = {
|
|
952
1051
|
/**
|
|
953
1052
|
* This is a standard, so don't require it to passed in everywhere.
|
|
@@ -969,27 +1068,32 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
|
969
1068
|
* Don't add sample code.
|
|
970
1069
|
*/
|
|
971
1070
|
sampleCode: false,
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1071
|
+
...useJest ? {
|
|
1072
|
+
/**
|
|
1073
|
+
* Make sure jest config is stored outside of package.json
|
|
1074
|
+
*/
|
|
1075
|
+
jestOptions: {
|
|
1076
|
+
configFilePath: "jest.config.json",
|
|
1077
|
+
jestConfig: {
|
|
1078
|
+
roots: [`<rootDir>/src`],
|
|
1079
|
+
transform: {
|
|
1080
|
+
["^.+\\.[t]sx?$"]: new Transform("@swc/jest")
|
|
1081
|
+
},
|
|
1082
|
+
moduleFileExtensions: ["js", "ts"]
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
/**
|
|
1086
|
+
* SWC for faster testing
|
|
1087
|
+
*/
|
|
1088
|
+
devDeps: ["@swc/jest", "@swc/core"]
|
|
1089
|
+
} : {
|
|
1090
|
+
jest: false,
|
|
1091
|
+
devDeps: []
|
|
984
1092
|
},
|
|
985
1093
|
/**
|
|
986
1094
|
* Turn on prettier formatting
|
|
987
1095
|
*/
|
|
988
1096
|
prettier: true,
|
|
989
|
-
/**
|
|
990
|
-
* SWC for faster testing
|
|
991
|
-
*/
|
|
992
|
-
devDeps: ["@swc/jest", "@swc/core"],
|
|
993
1097
|
/**
|
|
994
1098
|
* Don't package test files.
|
|
995
1099
|
*/
|
|
@@ -1026,7 +1130,19 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
|
1026
1130
|
};
|
|
1027
1131
|
const options = merge(defaultOptions, userOptions);
|
|
1028
1132
|
super(options);
|
|
1029
|
-
this.
|
|
1133
|
+
this.tsconfig?.addExclude("**/*.test.*");
|
|
1134
|
+
this.tsconfig?.addExclude("**/*.spec.*");
|
|
1135
|
+
if (options.testRunner === TestRunner.VITEST) {
|
|
1136
|
+
new Vitest(this, {
|
|
1137
|
+
config: {
|
|
1138
|
+
include: ["src/**/*.{test,spec}.?(c|m)[jt]s?(x)"],
|
|
1139
|
+
...options.vitestOptions?.config
|
|
1140
|
+
},
|
|
1141
|
+
...options.vitestOptions
|
|
1142
|
+
});
|
|
1143
|
+
} else {
|
|
1144
|
+
this.deps.removeDependency("ts-jest");
|
|
1145
|
+
}
|
|
1030
1146
|
this.package.file.addOverride(
|
|
1031
1147
|
"packageManager",
|
|
1032
1148
|
`pnpm@${options.pnpmVersion}`
|
|
@@ -1037,7 +1153,7 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
|
1037
1153
|
"import/no-extraneous-dependencies": "off"
|
|
1038
1154
|
}
|
|
1039
1155
|
});
|
|
1040
|
-
this.gitignore?.addPatterns(".DS_Store");
|
|
1156
|
+
this.gitignore?.addPatterns(".DS_Store", "test-reports");
|
|
1041
1157
|
this.npmignore?.addPatterns("*.spec.*", "*.test.*", "__fixtures__");
|
|
1042
1158
|
const turboActive = userOptions.parent && TurboRepo.of(userOptions.parent) !== void 0;
|
|
1043
1159
|
if (turboActive) {
|
|
@@ -1085,7 +1201,7 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
|
1085
1201
|
};
|
|
1086
1202
|
|
|
1087
1203
|
// src/tasks/reset-task.ts
|
|
1088
|
-
var ResetTask = class _ResetTask extends
|
|
1204
|
+
var ResetTask = class _ResetTask extends Component8 {
|
|
1089
1205
|
constructor(project, options = {}) {
|
|
1090
1206
|
super(project);
|
|
1091
1207
|
this.project = project;
|
|
@@ -1158,8 +1274,8 @@ var ResetTask = class _ResetTask extends Component7 {
|
|
|
1158
1274
|
};
|
|
1159
1275
|
|
|
1160
1276
|
// src/vscode/vscode.ts
|
|
1161
|
-
import { Component as
|
|
1162
|
-
var VSCodeConfig = class extends
|
|
1277
|
+
import { Component as Component9, vscode } from "projen";
|
|
1278
|
+
var VSCodeConfig = class extends Component9 {
|
|
1163
1279
|
constructor(project) {
|
|
1164
1280
|
super(project);
|
|
1165
1281
|
const vsConfig = new vscode.VsCode(project);
|
|
@@ -1382,7 +1498,7 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
1382
1498
|
"packageManager",
|
|
1383
1499
|
`pnpm@${options.pnpmVersion}`
|
|
1384
1500
|
);
|
|
1385
|
-
this.gitignore?.addPatterns(".DS_Store");
|
|
1501
|
+
this.gitignore?.addPatterns(".DS_Store", "test-reports");
|
|
1386
1502
|
this.addDevDeps("constructs@catalog:");
|
|
1387
1503
|
if (options.upgradeConfigulatorTask === true) {
|
|
1388
1504
|
this.upgradeConfigulatorTask = new UpgradeDependencies(
|
|
@@ -1432,9 +1548,9 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
1432
1548
|
|
|
1433
1549
|
// src/typescript/typescript-config.ts
|
|
1434
1550
|
import { relative as relative3 } from "path";
|
|
1435
|
-
import { Component as
|
|
1551
|
+
import { Component as Component10 } from "projen";
|
|
1436
1552
|
import { ensureRelativePathStartsWithDot } from "projen/lib/util/path";
|
|
1437
|
-
var TypeScriptConfig = class extends
|
|
1553
|
+
var TypeScriptConfig = class extends Component10 {
|
|
1438
1554
|
constructor(project) {
|
|
1439
1555
|
super(project);
|
|
1440
1556
|
let tsPaths = {};
|
|
@@ -1462,12 +1578,12 @@ var TypeScriptConfig = class extends Component9 {
|
|
|
1462
1578
|
|
|
1463
1579
|
// src/workflows/aws-deploy-workflow.ts
|
|
1464
1580
|
var import_utils3 = __toESM(require_lib());
|
|
1465
|
-
import { Component as
|
|
1581
|
+
import { Component as Component11 } from "projen";
|
|
1466
1582
|
import { BuildWorkflow } from "projen/lib/build";
|
|
1467
1583
|
import { GitHub } from "projen/lib/github";
|
|
1468
1584
|
import { JobPermission as JobPermission2 } from "projen/lib/github/workflows-model";
|
|
1469
1585
|
var PROD_DEPLOY_NAME = "prod-deploy";
|
|
1470
|
-
var AwsDeployWorkflow = class _AwsDeployWorkflow extends
|
|
1586
|
+
var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component11 {
|
|
1471
1587
|
constructor(project, options = {}) {
|
|
1472
1588
|
super(project);
|
|
1473
1589
|
this.project = project;
|
|
@@ -1729,6 +1845,7 @@ export {
|
|
|
1729
1845
|
ROOT_CI_TASK_NAME,
|
|
1730
1846
|
ROOT_TURBO_TASK_NAME,
|
|
1731
1847
|
ResetTask,
|
|
1848
|
+
TestRunner,
|
|
1732
1849
|
TurboRepo,
|
|
1733
1850
|
TurboRepoTask,
|
|
1734
1851
|
TypeScriptConfig,
|
|
@@ -1737,6 +1854,7 @@ export {
|
|
|
1737
1854
|
VERSION_KEYS_SKIP,
|
|
1738
1855
|
VERSION_NPM_PACKAGES,
|
|
1739
1856
|
VSCodeConfig,
|
|
1857
|
+
Vitest,
|
|
1740
1858
|
getLatestEligibleVersion
|
|
1741
1859
|
};
|
|
1742
1860
|
//# sourceMappingURL=index.mjs.map
|