@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 +7 -8
- package/lib/index.d.mts +120 -2
- package/lib/index.d.ts +121 -3
- package/lib/index.js +162 -42
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +148 -30
- package/lib/index.mjs.map +1 -1
- package/package.json +6 -9
- package/vitest.config.ts +16 -0
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
|
|
|
@@ -805,11 +808,15 @@ var VERSION = {
|
|
|
805
808
|
/**
|
|
806
809
|
* Version of Projen to use.
|
|
807
810
|
*/
|
|
808
|
-
PROJEN_VERSION: "0.99.
|
|
811
|
+
PROJEN_VERSION: "0.99.18",
|
|
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
|