@codedrifters/configulator 0.0.94 → 0.0.96
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 +34 -0
- package/lib/index.d.mts +41 -1
- package/lib/index.d.ts +42 -2
- package/lib/index.js +103 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +99 -3
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -644,6 +644,99 @@ var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component4 {
|
|
|
644
644
|
}
|
|
645
645
|
};
|
|
646
646
|
|
|
647
|
+
// src/latest-eligible-version.ts
|
|
648
|
+
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
649
|
+
function isPrerelease(version) {
|
|
650
|
+
const v = version.replace(/^v/, "");
|
|
651
|
+
return /^\d+\.\d+\.\d+-/.test(v);
|
|
652
|
+
}
|
|
653
|
+
function compareVersions(a, b) {
|
|
654
|
+
const parse = (v) => {
|
|
655
|
+
const parts = v.replace(/^v/, "").split(/[-+]/)[0].split(".");
|
|
656
|
+
return parts.map((p) => {
|
|
657
|
+
const n = parseInt(p, 10);
|
|
658
|
+
return Number.isNaN(n) ? 0 : n;
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
const pa = parse(a);
|
|
662
|
+
const pb = parse(b);
|
|
663
|
+
const len = Math.max(pa.length, pb.length);
|
|
664
|
+
for (let i = 0; i < len; i++) {
|
|
665
|
+
const na = pa[i] ?? 0;
|
|
666
|
+
const nb = pb[i] ?? 0;
|
|
667
|
+
if (na !== nb) return na - nb;
|
|
668
|
+
}
|
|
669
|
+
return 0;
|
|
670
|
+
}
|
|
671
|
+
async function getLatestEligibleVersion(packageName, minimumReleaseAgeMinutes) {
|
|
672
|
+
const url = `${NPM_REGISTRY}/${encodeURIComponent(packageName)}`;
|
|
673
|
+
let res;
|
|
674
|
+
try {
|
|
675
|
+
res = await fetch(url, {
|
|
676
|
+
headers: { Accept: "application/json" }
|
|
677
|
+
});
|
|
678
|
+
} catch {
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
if (!res.ok) return null;
|
|
682
|
+
let data;
|
|
683
|
+
try {
|
|
684
|
+
data = await res.json();
|
|
685
|
+
} catch {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
688
|
+
const time = data.time;
|
|
689
|
+
if (!time || typeof time !== "object") return null;
|
|
690
|
+
const nowMs = Date.now();
|
|
691
|
+
const minAgeMs = minimumReleaseAgeMinutes * 60 * 1e3;
|
|
692
|
+
const distTagLatest = data["dist-tags"]?.latest;
|
|
693
|
+
if (distTagLatest && !isPrerelease(distTagLatest)) {
|
|
694
|
+
const publishedAtStr = time[distTagLatest];
|
|
695
|
+
if (typeof publishedAtStr === "string") {
|
|
696
|
+
const publishedAt = Date.parse(publishedAtStr);
|
|
697
|
+
if (!Number.isNaN(publishedAt) && nowMs - publishedAt >= minAgeMs) {
|
|
698
|
+
return distTagLatest;
|
|
699
|
+
}
|
|
700
|
+
} else {
|
|
701
|
+
return distTagLatest;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
const versionTimestamps = [];
|
|
705
|
+
for (const [key, value] of Object.entries(time)) {
|
|
706
|
+
if (key === "created" || key === "modified" || typeof value !== "string") {
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (isPrerelease(key)) continue;
|
|
710
|
+
const publishedAt = Date.parse(value);
|
|
711
|
+
if (Number.isNaN(publishedAt)) continue;
|
|
712
|
+
const ageMs = nowMs - publishedAt;
|
|
713
|
+
if (ageMs >= minAgeMs) {
|
|
714
|
+
versionTimestamps.push({ version: key, publishedAt });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (versionTimestamps.length === 0) return null;
|
|
718
|
+
let candidates = versionTimestamps;
|
|
719
|
+
if (distTagLatest && !isPrerelease(distTagLatest)) {
|
|
720
|
+
candidates = versionTimestamps.filter(
|
|
721
|
+
(e) => compareVersions(e.version, distTagLatest) <= 0
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
if (candidates.length === 0) return null;
|
|
725
|
+
candidates.sort((a, b) => compareVersions(b.version, a.version));
|
|
726
|
+
return candidates[0].version;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// src/version-package-map.ts
|
|
730
|
+
var VERSION_NPM_PACKAGES = [
|
|
731
|
+
{ key: "AWS_CDK_CLI_VERSION", npmPackage: "aws-cdk" },
|
|
732
|
+
{ key: "AWS_CDK_LIB_VERSION", npmPackage: "aws-cdk-lib" },
|
|
733
|
+
{ key: "AWS_CONSTRUCTS_VERSION", npmPackage: "constructs" },
|
|
734
|
+
{ key: "PNPM_VERSION", npmPackage: "pnpm" },
|
|
735
|
+
{ key: "PROJEN_VERSION", npmPackage: "projen" },
|
|
736
|
+
{ key: "TURBO_VERSION", npmPackage: "turbo" }
|
|
737
|
+
];
|
|
738
|
+
var VERSION_KEYS_SKIP = ["NODE_WORKFLOWS"];
|
|
739
|
+
|
|
647
740
|
// src/versions.ts
|
|
648
741
|
var VERSION = {
|
|
649
742
|
/**
|
|
@@ -767,7 +860,7 @@ var PnpmWorkspace = class _PnpmWorkspace extends Component6 {
|
|
|
767
860
|
super(project);
|
|
768
861
|
project.tryFindObjectFile("package.json")?.addDeletionOverride("pnpm");
|
|
769
862
|
this.fileName = options.fileName ?? "pnpm-workspace.yaml";
|
|
770
|
-
this.minimumReleaseAge = options.minimumReleaseAge
|
|
863
|
+
this.minimumReleaseAge = options.minimumReleaseAge ?? MIMIMUM_RELEASE_AGE.ONE_DAY;
|
|
771
864
|
this.minimumReleaseAgeExclude = options.minimumReleaseAgeExclude ? ["@codedrifters/*", ...options.minimumReleaseAgeExclude] : ["@codedrifters/*"];
|
|
772
865
|
this.onlyBuiltDependencies = options.onlyBuiltDependencies ? options.onlyBuiltDependencies : [];
|
|
773
866
|
this.ignoredBuiltDependencies = options.ignoredBuiltDependencies ? options.ignoredBuiltDependencies : [];
|
|
@@ -1156,7 +1249,7 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
1156
1249
|
depsUpgrade: true,
|
|
1157
1250
|
depsUpgradeOptions: {
|
|
1158
1251
|
workflowOptions: {
|
|
1159
|
-
schedule: UpgradeDependenciesSchedule2.
|
|
1252
|
+
schedule: UpgradeDependenciesSchedule2.expressions(["0 23 * * *"])
|
|
1160
1253
|
},
|
|
1161
1254
|
cooldown: 1
|
|
1162
1255
|
},
|
|
@@ -1611,6 +1704,9 @@ export {
|
|
|
1611
1704
|
TypeScriptConfig,
|
|
1612
1705
|
TypeScriptProject,
|
|
1613
1706
|
VERSION,
|
|
1614
|
-
|
|
1707
|
+
VERSION_KEYS_SKIP,
|
|
1708
|
+
VERSION_NPM_PACKAGES,
|
|
1709
|
+
VSCodeConfig,
|
|
1710
|
+
getLatestEligibleVersion
|
|
1615
1711
|
};
|
|
1616
1712
|
//# sourceMappingURL=index.mjs.map
|