@codedrifters/configulator 0.0.125 → 0.0.127

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/lib/index.mjs CHANGED
@@ -751,7 +751,12 @@ var VERSION_NPM_PACKAGES = [
751
751
  { key: "TURBO_VERSION", npmPackage: "turbo" },
752
752
  { key: "VITEST_VERSION", npmPackage: "vitest" }
753
753
  ];
754
- var VERSION_KEYS_SKIP = ["NODE_WORKFLOWS"];
754
+ var VERSION_KEYS_SKIP = [
755
+ "NODE_WORKFLOWS",
756
+ "VITE_VERSION",
757
+ "VITEST_VERSION"
758
+ // Pinned to 3.x for Vite 5 compatibility; skip until ESM-only (issue #142)
759
+ ];
755
760
 
756
761
  // src/versions.ts
757
762
  var VERSION = {
@@ -787,10 +792,17 @@ var VERSION = {
787
792
  * What version of the turborepo library should we use?
788
793
  */
789
794
  TURBO_VERSION: "2.8.14",
795
+ /**
796
+ * What version of Vite to use (pnpm override). Pinned to 5.x so Vitest 4.x
797
+ * can load config (Vite 6+/7+ are ESM-only; see issue #142). Remove override
798
+ * when moving to ESM-only test setup.
799
+ */
800
+ VITE_VERSION: "5.4.11",
790
801
  /**
791
802
  * What version of Vitest to use when testRunner is 'vitest'.
803
+ * Pinned to 3.x so it works with Vite 5 (Vitest 4 requires Vite 6). See issue #142.
792
804
  */
793
- VITEST_VERSION: "4.0.18"
805
+ VITEST_VERSION: "3.2.4"
794
806
  };
795
807
 
796
808
  // src/jsii/jsii-faker.ts
@@ -1295,6 +1307,133 @@ var VSCodeConfig = class extends Component9 {
1295
1307
  }
1296
1308
  };
1297
1309
 
1310
+ // src/workflows/approve-merge-upgrade.ts
1311
+ import { JobPermission as JobPermission2 } from "projen/lib/github/workflows-model";
1312
+ var MERGE_METHODS = {
1313
+ SQUASH: "squash",
1314
+ MERGE: "merge",
1315
+ REBASE: "rebase"
1316
+ };
1317
+ var DEFAULT_WORKFLOW_NAME = "approve-and-merge-upgrade";
1318
+ var DEFAULT_AUTO_APPROVE_LABEL = "auto-approve";
1319
+ var DEFAULT_HEAD_BRANCH = "github-actions/upgrade";
1320
+ var DEFAULT_APPROVAL_APP_ID_SECRET = "APPROVAL_APP_ID";
1321
+ var DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET = "APPROVAL_APP_PRIVATE_KEY";
1322
+ var DEFAULT_MERGE_METHOD = MERGE_METHODS.SQUASH;
1323
+ var PULL_REQUEST_TARGET_TYPES = [
1324
+ "labeled",
1325
+ "synchronize",
1326
+ "reopened",
1327
+ "ready_for_review"
1328
+ ];
1329
+ function addApproveMergeUpgradeWorkflow(project, options) {
1330
+ const workflowName = options.workflowName ?? DEFAULT_WORKFLOW_NAME;
1331
+ const autoApproveLabel = options.autoApproveLabel ?? DEFAULT_AUTO_APPROVE_LABEL;
1332
+ const headBranch = options.headBranch ?? DEFAULT_HEAD_BRANCH;
1333
+ const allowedUsernames = options.allowedUsernames;
1334
+ const appIdSecret = options.approvalAppIdSecret ?? DEFAULT_APPROVAL_APP_ID_SECRET;
1335
+ const privateKeySecret = options.approvalAppPrivateKeySecret ?? DEFAULT_APPROVAL_APP_PRIVATE_KEY_SECRET;
1336
+ const mergeMethod = options.mergeMethod ?? DEFAULT_MERGE_METHOD;
1337
+ const workflow = project.github?.addWorkflow(workflowName);
1338
+ if (!workflow) return;
1339
+ workflow.on({
1340
+ pullRequestTarget: {
1341
+ types: [...PULL_REQUEST_TARGET_TYPES],
1342
+ ...options.branches && options.branches.length > 0 ? { branches: options.branches } : {}
1343
+ }
1344
+ });
1345
+ const jobCondition = [
1346
+ `contains(github.event.pull_request.labels.*.name, '${autoApproveLabel}')`,
1347
+ `github.event.pull_request.head.ref == '${headBranch}'`,
1348
+ `(${allowedUsernames.map((u) => `github.event.pull_request.user.login == '${u}'`).join(" || ")})`
1349
+ ].join(" && ");
1350
+ workflow.addJobs({
1351
+ "approve-and-merge": {
1352
+ name: "Approve and merge upgrade PR",
1353
+ runsOn: ["ubuntu-latest"],
1354
+ permissions: {
1355
+ pullRequests: JobPermission2.WRITE,
1356
+ contents: JobPermission2.WRITE
1357
+ },
1358
+ if: jobCondition,
1359
+ steps: [
1360
+ {
1361
+ name: "Generate token",
1362
+ id: "generate_token",
1363
+ uses: "actions/create-github-app-token@v2",
1364
+ with: {
1365
+ "app-id": `\${{ secrets.${appIdSecret} }}`,
1366
+ "private-key": `\${{ secrets.${privateKeySecret} }}`
1367
+ }
1368
+ },
1369
+ {
1370
+ name: "Auto-approve",
1371
+ uses: "hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363",
1372
+ with: {
1373
+ "github-token": "${{ steps.generate_token.outputs.token }}"
1374
+ }
1375
+ },
1376
+ {
1377
+ name: "Enable auto-merge (squash)",
1378
+ uses: "peter-evans/enable-pull-request-automerge@v3",
1379
+ with: {
1380
+ token: "${{ steps.generate_token.outputs.token }}",
1381
+ "pull-request-number": "${{ github.event.pull_request.number }}",
1382
+ "merge-method": mergeMethod
1383
+ }
1384
+ }
1385
+ ]
1386
+ }
1387
+ });
1388
+ }
1389
+
1390
+ // src/workflows/build-complete-job.ts
1391
+ import { JobPermission as JobPermission3 } from "projen/lib/github/workflows-model";
1392
+ var BUILD_JOB_ID = "build";
1393
+ var COMPLETE_JOB_ID = "complete";
1394
+ function buildCompleteJobRunScript(jobIds) {
1395
+ const lines = [];
1396
+ for (const id of jobIds) {
1397
+ const expr = "${{ needs." + id + ".result }}";
1398
+ if (id === BUILD_JOB_ID) {
1399
+ lines.push(
1400
+ `if [ "${expr}" != "success" ]; then echo "Job ${id} must succeed"; exit 1; fi`
1401
+ );
1402
+ } else {
1403
+ lines.push(
1404
+ `if [ "${expr}" != "success" ] && [ "${expr}" != "skipped" ]; then echo "Job ${id} must succeed or be skipped"; exit 1; fi`
1405
+ );
1406
+ }
1407
+ }
1408
+ return lines.join("\n");
1409
+ }
1410
+ function addBuildCompleteJob(buildWorkflow) {
1411
+ const w = buildWorkflow.workflow;
1412
+ if (!w?.jobs || typeof w.addJob !== "function") {
1413
+ return;
1414
+ }
1415
+ const jobIds = Object.keys(w.jobs).filter((id) => id !== COMPLETE_JOB_ID);
1416
+ if (jobIds.length === 0) {
1417
+ return;
1418
+ }
1419
+ const runScript = buildCompleteJobRunScript(jobIds);
1420
+ w.addJob(COMPLETE_JOB_ID, {
1421
+ name: "Complete",
1422
+ needs: jobIds,
1423
+ if: "always()",
1424
+ runsOn: ["ubuntu-latest"],
1425
+ permissions: {
1426
+ contents: JobPermission3.NONE
1427
+ },
1428
+ steps: [
1429
+ {
1430
+ name: "Verify all jobs succeeded or were skipped",
1431
+ run: runScript
1432
+ }
1433
+ ]
1434
+ });
1435
+ }
1436
+
1298
1437
  // src/projects/monorepo-project.ts
1299
1438
  var postInstallDependenciesMap = /* @__PURE__ */ new WeakMap();
1300
1439
  var MonorepoProject = class extends TypeScriptAppProject {
@@ -1529,6 +1668,12 @@ var MonorepoProject = class extends TypeScriptAppProject {
1529
1668
  )
1530
1669
  );
1531
1670
  }
1671
+ if (options.approveMergeUpgradeOptions) {
1672
+ addApproveMergeUpgradeWorkflow(this, options.approveMergeUpgradeOptions);
1673
+ }
1674
+ if (this.buildWorkflow) {
1675
+ addBuildCompleteJob(this.buildWorkflow);
1676
+ }
1532
1677
  this.tasks.tryFind("post-upgrade")?.exec("pnpm upgrade -r");
1533
1678
  this.tasks.tryFind("post-upgrade")?.spawn(this.defaultTask);
1534
1679
  }
@@ -1595,7 +1740,7 @@ var import_utils3 = __toESM(require_lib());
1595
1740
  import { Component as Component11 } from "projen";
1596
1741
  import { BuildWorkflow } from "projen/lib/build";
1597
1742
  import { GitHub } from "projen/lib/github";
1598
- import { JobPermission as JobPermission2 } from "projen/lib/github/workflows-model";
1743
+ import { JobPermission as JobPermission4 } from "projen/lib/github/workflows-model";
1599
1744
  var PROD_DEPLOY_NAME = "prod-deploy";
1600
1745
  var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component11 {
1601
1746
  constructor(project, options = {}) {
@@ -1824,14 +1969,15 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component11 {
1824
1969
  ],
1825
1970
  runsOn: ["ubuntu-latest"],
1826
1971
  permissions: {
1827
- contents: JobPermission2.READ,
1828
- idToken: JobPermission2.WRITE
1972
+ contents: JobPermission4.READ,
1973
+ idToken: JobPermission4.WRITE
1829
1974
  },
1830
1975
  concurrency: deployJobName,
1831
1976
  if: jobCondition,
1832
1977
  steps: [...this.deploySteps(target)]
1833
1978
  });
1834
1979
  });
1980
+ addBuildCompleteJob(this.buildWorkflow);
1835
1981
  }
1836
1982
  static of(project, buildWorkflow) {
1837
1983
  const isDefined = (c) => c instanceof _AwsDeployWorkflow && c.buildWorkflow === buildWorkflow;
@@ -1863,7 +2009,9 @@ export {
1863
2009
  AwsDeployWorkflow,
1864
2010
  AwsDeploymentConfig,
1865
2011
  AwsDeploymentTarget,
2012
+ COMPLETE_JOB_ID,
1866
2013
  JsiiFaker,
2014
+ MERGE_METHODS,
1867
2015
  MIMIMUM_RELEASE_AGE,
1868
2016
  MonorepoProject,
1869
2017
  PROD_DEPLOY_NAME,
@@ -1881,6 +2029,8 @@ export {
1881
2029
  VERSION_NPM_PACKAGES,
1882
2030
  VSCodeConfig,
1883
2031
  Vitest,
2032
+ addApproveMergeUpgradeWorkflow,
2033
+ addBuildCompleteJob,
1884
2034
  getLatestEligibleVersion
1885
2035
  };
1886
2036
  //# sourceMappingURL=index.mjs.map