@absolutejs/changelog 0.3.0 → 0.5.0
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/CHANGELOG.md +25 -0
- package/changelog.json +53 -0
- package/dist/cli.js +113 -41
- package/dist/cli.js.map +6 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +83 -30
- package/dist/index.js.map +5 -5
- package/dist/reconcile.d.ts +5 -2
- package/dist/registry.d.ts +14 -11
- package/dist/surface.d.ts +28 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { change, manual, moved, renamed } from "./authoring";
|
|
|
3
3
|
export { builtSurface, changelogPaths, loadUnreleased, readJsonFile, type LoadedEntries, type LoadedEntry, } from "./entries";
|
|
4
4
|
export { changesBetween, disruptiveBetween, mechanicalMigrations, migrationsBetween, parseChangelog, releasesBetween, symbolsDisturbedBetween, validateChange, type ChangeAt, type ChangelogRead, type MigrationAt, } from "./read";
|
|
5
5
|
export { describeReconciliation, reconcile, type Reconciliation, type Unannounced, } from "./reconcile";
|
|
6
|
-
export { isPackageName, packageArchive, packageVersions, publishedChangelog, publishedSurface, type PackageVersions, type RegistryOptions, } from "./registry";
|
|
7
|
-
export { changeShape, declaresTypes, diffSurface, notable, surfaceOfArchive, surfaceOfFiles, typeEntriesOf, type ChangeShape, type PackageSurface, type SurfaceChange, type SurfaceDiff, } from "./surface";
|
|
6
|
+
export { forgetRegistry, isPackageName, packageArchive, packageVersions, publishedChangelog, publishedSurface, type PackageVersions, type RegistryOptions, } from "./registry";
|
|
7
|
+
export { changeShape, declaresTypes, diffSurface, notable, surfaceOfArchive, surfaceOfFiles, typeEntriesOf, type ChangeShape, type PackageSurface, type SurfaceChange, type SurfaceDiff, type SurfaceName, type TypeEntry, type Withdrawal, } from "./surface";
|
|
8
8
|
export { asText, readTar, type TarLimits } from "./tarball";
|
|
9
9
|
export { CHANGELOG_CONTRACT, CHANGELOG_FILE, CHANGELOG_MARKDOWN, CHANGE_KINDS, DISRUPTIVE_KINDS, isDisruptive, isMechanical, UNRELEASED_DIRECTORY, type Change, type ChangeKind, type Changelog, type DisruptiveChange, type DisruptiveKind, type Migration, type NonEmpty, type OrdinaryChange, type Release, } from "./types";
|
|
10
10
|
export { compareVersions, isPrerelease, nextVersion, parseVersion, releaseKindFor, type ReleaseKind, } from "./versioning";
|
package/dist/index.js
CHANGED
|
@@ -735,33 +735,55 @@ var surfaceOfArchive = (archive) => {
|
|
|
735
735
|
};
|
|
736
736
|
var surfaceOfFiles = (files, entries) => {
|
|
737
737
|
const surface = new Map;
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
738
|
+
const offered = entries.flatMap((entry) => [...exportsOf(files, entry.path, new Set)].map(([name, declaration]) => ({ declaration, name, specifier: entry.specifier })));
|
|
739
|
+
for (const { declaration, name, specifier } of offered) {
|
|
740
|
+
const known = surface.get(name);
|
|
741
|
+
if (known === undefined)
|
|
742
|
+
surface.set(name, { declaration, entries: [specifier] });
|
|
743
|
+
else if (!known.entries.includes(specifier))
|
|
744
|
+
known.entries.push(specifier);
|
|
745
|
+
}
|
|
746
|
+
for (const value of surface.values())
|
|
747
|
+
value.entries.sort();
|
|
742
748
|
return surface;
|
|
743
749
|
};
|
|
744
|
-
var
|
|
750
|
+
var exportEntries = (value, packageName, specifier) => {
|
|
751
|
+
const here = specifier ?? packageName;
|
|
745
752
|
if (typeof value === "string")
|
|
746
|
-
return [value];
|
|
753
|
+
return [{ specifier: here, value }];
|
|
747
754
|
if (typeof value !== "object" || value === null)
|
|
748
755
|
return [];
|
|
749
|
-
return Object.entries(value).flatMap(([key, nested]) => key
|
|
756
|
+
return Object.entries(value).flatMap(([key, nested]) => key.startsWith(".") ? exportEntries(nested, packageName, key === "." ? packageName : `${packageName}${key.slice(1)}`) : exportEntries(nested, packageName, here));
|
|
750
757
|
};
|
|
751
758
|
var typeEntriesOf = (manifest, files) => {
|
|
752
759
|
const record = typeof manifest === "object" && manifest !== null ? new Map(Object.entries(manifest)) : new Map;
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
760
|
+
const named = record.get("name");
|
|
761
|
+
const packageName = typeof named === "string" ? named : "";
|
|
762
|
+
const resolved = (value, specifier) => {
|
|
763
|
+
if (typeof value !== "string")
|
|
764
|
+
return [];
|
|
765
|
+
const cleaned = value.replace(/^\.\//u, "");
|
|
766
|
+
const candidates = DECLARATION.test(cleaned) ? [cleaned] : [
|
|
767
|
+
cleaned.replace(/\.[cm]?js$/u, ".d.ts"),
|
|
768
|
+
cleaned.replace(/\.[cm]?js$/u, ".d.mts"),
|
|
769
|
+
cleaned.replace(/\.[cm]?js$/u, ".d.cts")
|
|
770
|
+
];
|
|
771
|
+
return candidates.filter((candidate) => files.has(candidate)).map((resolvedPath) => ({ path: resolvedPath, specifier }));
|
|
772
|
+
};
|
|
773
|
+
const found = [
|
|
774
|
+
...resolved(record.get("types"), packageName),
|
|
775
|
+
...resolved(record.get("typings"), packageName),
|
|
776
|
+
...exportEntries(record.get("exports"), packageName).flatMap((entry) => resolved(entry.value, entry.specifier))
|
|
757
777
|
];
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
778
|
+
const fallback = found.length === 0 && files.has("dist/index.d.ts") ? [{ path: "dist/index.d.ts", specifier: packageName }] : [];
|
|
779
|
+
const seen = new Set;
|
|
780
|
+
return [...found, ...fallback].filter((entry) => {
|
|
781
|
+
const key = `${entry.specifier}\x00${entry.path}`;
|
|
782
|
+
if (seen.has(key))
|
|
783
|
+
return false;
|
|
784
|
+
seen.add(key);
|
|
785
|
+
return true;
|
|
786
|
+
});
|
|
765
787
|
};
|
|
766
788
|
var SHAPE = {
|
|
767
789
|
members: "members",
|
|
@@ -816,23 +838,33 @@ var changeShape = (change2) => {
|
|
|
816
838
|
};
|
|
817
839
|
var diffSurface = (before, after) => {
|
|
818
840
|
const removed = [];
|
|
841
|
+
const withdrawn = [];
|
|
819
842
|
const changed = [];
|
|
820
|
-
for (const [name,
|
|
843
|
+
for (const [name, was] of before) {
|
|
821
844
|
const now = after.get(name);
|
|
822
845
|
if (now === undefined)
|
|
823
846
|
removed.push(name);
|
|
824
|
-
|
|
847
|
+
if (now === undefined)
|
|
848
|
+
continue;
|
|
849
|
+
const lost = was.entries.filter((entry) => !now.entries.includes(entry));
|
|
850
|
+
if (lost.length > 0)
|
|
851
|
+
withdrawn.push({ from: lost, name });
|
|
852
|
+
if (now.declaration !== was.declaration)
|
|
825
853
|
changed.push({
|
|
826
|
-
after: now,
|
|
827
|
-
before: declaration,
|
|
854
|
+
after: now.declaration,
|
|
855
|
+
before: was.declaration,
|
|
828
856
|
name,
|
|
829
|
-
shape: changeShape({
|
|
857
|
+
shape: changeShape({
|
|
858
|
+
after: now.declaration,
|
|
859
|
+
before: was.declaration
|
|
860
|
+
})
|
|
830
861
|
});
|
|
831
862
|
}
|
|
832
863
|
return {
|
|
833
864
|
added: [...after.keys()].filter((name) => !before.has(name)),
|
|
834
865
|
changed,
|
|
835
|
-
removed
|
|
866
|
+
removed,
|
|
867
|
+
withdrawn
|
|
836
868
|
};
|
|
837
869
|
};
|
|
838
870
|
var notable = (diff) => diff.changed.filter((change2) => change2.shape === "parameters" || change2.shape === "members");
|
|
@@ -955,10 +987,11 @@ var describeReconciliation = (found) => {
|
|
|
955
987
|
members: "changed the members of its type",
|
|
956
988
|
parameters: "changed what it is called with",
|
|
957
989
|
removed: "is no longer exported",
|
|
958
|
-
types: "changed its declaration"
|
|
990
|
+
types: "changed its declaration",
|
|
991
|
+
withdrawn: "is no longer exported from"
|
|
959
992
|
};
|
|
960
993
|
for (const entry of found.unannounced)
|
|
961
|
-
lines.push(`\`${entry.name}\` ${moved2[entry.kind]} and no entry says so`);
|
|
994
|
+
lines.push(entry.kind === "withdrawn" ? `\`${entry.name}\` ${moved2.withdrawn} ${(entry.from ?? []).join(", ")} and no entry says so` : `\`${entry.name}\` ${moved2[entry.kind]} and no entry says so`);
|
|
962
995
|
for (const name of found.unknownSymbols)
|
|
963
996
|
lines.push(`an entry names \`${name}\`, which this package does not export`);
|
|
964
997
|
lines.push(...found.wrongMigrations);
|
|
@@ -969,6 +1002,7 @@ var reconcile = (input) => {
|
|
|
969
1002
|
const mentioned = new Set(input.changes.flatMap((change2) => [...change2.symbols ?? []]));
|
|
970
1003
|
const unannounced = [
|
|
971
1004
|
...input.diff.removed.filter((name) => !disruptive.has(name)).map((name) => ({ kind: "removed", name })),
|
|
1005
|
+
...input.diff.withdrawn.filter((entry) => !disruptive.has(entry.name)).map((entry) => ({ from: entry.from, kind: "withdrawn", name: entry.name })),
|
|
972
1006
|
...input.diff.changed.filter((change2) => !mentioned.has(change2.name) && change2.shape !== "unknown").map((change2) => ({ kind: change2.shape, name: change2.name }))
|
|
973
1007
|
];
|
|
974
1008
|
const unknownSymbols = [
|
|
@@ -993,6 +1027,8 @@ var MAX_ARCHIVE_BYTES = MAX_ARCHIVE_MEBIBYTES * MEBIBYTE2;
|
|
|
993
1027
|
var MAX_DOWNLOAD_MEBIBYTES = 32;
|
|
994
1028
|
var MAX_DOWNLOAD_BYTES = MAX_DOWNLOAD_MEBIBYTES * MEBIBYTE2;
|
|
995
1029
|
var TIMEOUT_MS = 20000;
|
|
1030
|
+
var NOT_FOUND = 404;
|
|
1031
|
+
var NOTHING_PUBLISHED = { published: [], tarballs: {} };
|
|
996
1032
|
var PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u;
|
|
997
1033
|
var MAX_NAME_LENGTH = 214;
|
|
998
1034
|
var isPackageName = (name) => name.length <= MAX_NAME_LENGTH && PACKAGE_NAME.test(name);
|
|
@@ -1036,9 +1072,25 @@ var packageArchive = async (name, version, options = {}) => {
|
|
|
1036
1072
|
return;
|
|
1037
1073
|
}
|
|
1038
1074
|
};
|
|
1075
|
+
var packuments = new Map;
|
|
1076
|
+
var SECONDS_PER_MINUTE = 60;
|
|
1077
|
+
var MILLISECONDS_PER_SECOND = 1000;
|
|
1078
|
+
var PACKUMENT_MINUTES = 5;
|
|
1079
|
+
var PACKUMENT_TTL_MS = PACKUMENT_MINUTES * SECONDS_PER_MINUTE * MILLISECONDS_PER_SECOND;
|
|
1080
|
+
var forgetRegistry = () => packuments.clear();
|
|
1039
1081
|
var packageVersions = async (name, options = {}) => {
|
|
1040
1082
|
if (!isPackageName(name))
|
|
1041
1083
|
return;
|
|
1084
|
+
const cacheable = options.fetch === undefined && options.registry === undefined;
|
|
1085
|
+
const known = cacheable ? packuments.get(name) : undefined;
|
|
1086
|
+
if (known !== undefined && Date.now() - known.asked < PACKUMENT_TTL_MS)
|
|
1087
|
+
return known.value;
|
|
1088
|
+
const value = askRegistry(name, options);
|
|
1089
|
+
if (cacheable)
|
|
1090
|
+
packuments.set(name, { asked: Date.now(), value });
|
|
1091
|
+
return value;
|
|
1092
|
+
};
|
|
1093
|
+
var askRegistry = async (name, options) => {
|
|
1042
1094
|
const call = options.fetch ?? fetch;
|
|
1043
1095
|
const url = `${options.registry ?? DEFAULT_REGISTRY}/${name.replace("/", "%2f")}`;
|
|
1044
1096
|
try {
|
|
@@ -1047,9 +1099,9 @@ var packageVersions = async (name, options = {}) => {
|
|
|
1047
1099
|
signal: AbortSignal.timeout(TIMEOUT_MS)
|
|
1048
1100
|
});
|
|
1049
1101
|
const response = abbreviated.ok ? abbreviated : await call(url, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
1050
|
-
if (
|
|
1051
|
-
return;
|
|
1052
|
-
return
|
|
1102
|
+
if (response.ok)
|
|
1103
|
+
return readPackument(await response.json());
|
|
1104
|
+
return response.status === NOT_FOUND ? NOTHING_PUBLISHED : undefined;
|
|
1053
1105
|
} catch {
|
|
1054
1106
|
return;
|
|
1055
1107
|
}
|
|
@@ -1196,6 +1248,7 @@ export {
|
|
|
1196
1248
|
describeReconciliation,
|
|
1197
1249
|
diffSurface,
|
|
1198
1250
|
disruptiveBetween,
|
|
1251
|
+
forgetRegistry,
|
|
1199
1252
|
isDisruptive,
|
|
1200
1253
|
isMechanical,
|
|
1201
1254
|
isPackageName,
|
|
@@ -1228,5 +1281,5 @@ export {
|
|
|
1228
1281
|
validateChange
|
|
1229
1282
|
};
|
|
1230
1283
|
|
|
1231
|
-
//# debugId=
|
|
1284
|
+
//# debugId=ECB826E53B18086C64756E2164756E21
|
|
1232
1285
|
//# sourceMappingURL=index.js.map
|