@absolutejs/changelog 0.7.0 → 0.7.1
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 +7 -0
- package/changelog.json +14 -0
- package/dist/cli.js +58 -26
- package/dist/cli.js.map +3 -3
- package/dist/index.js +99 -67
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -430,11 +430,11 @@ var readMigration = (value, where, problems) => {
|
|
|
430
430
|
instruction,
|
|
431
431
|
rename: { from: rename.from, to: rename.to }
|
|
432
432
|
};
|
|
433
|
-
const { moved
|
|
434
|
-
if (isRecord(
|
|
433
|
+
const { moved } = value;
|
|
434
|
+
if (isRecord(moved) && isText(moved.symbol) && isText(moved.from) && isText(moved.to))
|
|
435
435
|
return {
|
|
436
436
|
instruction,
|
|
437
|
-
moved: { from:
|
|
437
|
+
moved: { from: moved.from, symbol: moved.symbol, to: moved.to }
|
|
438
438
|
};
|
|
439
439
|
const { resubpath } = value;
|
|
440
440
|
if (isRecord(resubpath) && isText(resubpath.from) && isText(resubpath.to))
|
|
@@ -527,12 +527,12 @@ var readRelease = (value, where, problems) => {
|
|
|
527
527
|
};
|
|
528
528
|
var validateChange = (value, where = "entry") => {
|
|
529
529
|
const problems = [];
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
530
|
+
const change = readChange(value, where, problems);
|
|
531
|
+
if (change === undefined) {
|
|
532
532
|
const failed = { problems };
|
|
533
533
|
return failed;
|
|
534
534
|
}
|
|
535
|
-
const read = { change
|
|
535
|
+
const read = { change };
|
|
536
536
|
return read;
|
|
537
537
|
};
|
|
538
538
|
var parseChangelog = (value) => {
|
|
@@ -558,22 +558,22 @@ var parseChangelog = (value) => {
|
|
|
558
558
|
};
|
|
559
559
|
};
|
|
560
560
|
var releasesBetween = (changelog, from, upto) => [...changelog.releases].filter((release) => compareVersions(release.version, from) > 0 && compareVersions(release.version, upto) <= 0).sort((left, right) => compareVersions(left.version, right.version));
|
|
561
|
-
var changesBetween = (changelog, from, upto) => releasesBetween(changelog, from, upto).flatMap((release) => release.changes.map((
|
|
562
|
-
const found = { change
|
|
561
|
+
var changesBetween = (changelog, from, upto) => releasesBetween(changelog, from, upto).flatMap((release) => release.changes.map((change) => {
|
|
562
|
+
const found = { change, version: release.version };
|
|
563
563
|
return found;
|
|
564
564
|
}));
|
|
565
565
|
var isDisruptiveAt = (found) => isDisruptive(found.change);
|
|
566
566
|
var disruptiveBetween = (changelog, from, upto) => changesBetween(changelog, from, upto).filter(isDisruptiveAt);
|
|
567
567
|
var mechanicalMigrations = (migrations) => migrations.filter((found) => isMechanical(found.migration));
|
|
568
|
-
var migrationsBetween = (changelog, from, upto) => disruptiveBetween(changelog, from, upto).map(({ change
|
|
568
|
+
var migrationsBetween = (changelog, from, upto) => disruptiveBetween(changelog, from, upto).map(({ change, version }) => {
|
|
569
569
|
const found = {
|
|
570
|
-
migration:
|
|
571
|
-
symbols:
|
|
570
|
+
migration: change.migration,
|
|
571
|
+
symbols: change.symbols,
|
|
572
572
|
version
|
|
573
573
|
};
|
|
574
574
|
return found;
|
|
575
575
|
});
|
|
576
|
-
var symbolsDisturbedBetween = (changelog, from, upto) => new Set(disruptiveBetween(changelog, from, upto).flatMap(({ change
|
|
576
|
+
var symbolsDisturbedBetween = (changelog, from, upto) => new Set(disruptiveBetween(changelog, from, upto).flatMap(({ change }) => change.symbols));
|
|
577
577
|
|
|
578
578
|
// src/surface.ts
|
|
579
579
|
import path from "path";
|
|
@@ -634,6 +634,38 @@ var readTar = (archive, keep, limits = {}) => {
|
|
|
634
634
|
var DECLARATION = /\.d\.[cm]?ts$/u;
|
|
635
635
|
var parse2 = (source, name) => ts2.createSourceFile(name, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
|
|
636
636
|
var normalize = (text) => text.replace(/\s+/gu, " ").trim();
|
|
637
|
+
var CLOSERS = new Set(["}", ")", "]", ">"]);
|
|
638
|
+
var wordy = (token) => /^[\w$#@]/u.test(token) || /[\w$]$/u.test(token);
|
|
639
|
+
var LAST2 = -1;
|
|
640
|
+
var tokenText = (scanner, scanned, state) => {
|
|
641
|
+
const closesTemplate = scanned === ts2.SyntaxKind.CloseBraceToken && state.templates.at(LAST2) === state.depth;
|
|
642
|
+
const token = closesTemplate ? scanner.reScanTemplateToken(false) : scanned;
|
|
643
|
+
if (closesTemplate && token === ts2.SyntaxKind.TemplateTail)
|
|
644
|
+
state.templates.pop();
|
|
645
|
+
if (closesTemplate)
|
|
646
|
+
return scanner.getTokenText();
|
|
647
|
+
if (token === ts2.SyntaxKind.StringLiteral)
|
|
648
|
+
return JSON.stringify(scanner.getTokenValue());
|
|
649
|
+
if (token === ts2.SyntaxKind.TemplateHead)
|
|
650
|
+
state.templates.push(state.depth);
|
|
651
|
+
if (token === ts2.SyntaxKind.OpenBraceToken)
|
|
652
|
+
state.depth += 1;
|
|
653
|
+
if (token === ts2.SyntaxKind.CloseBraceToken)
|
|
654
|
+
state.depth -= 1;
|
|
655
|
+
return scanner.getTokenText();
|
|
656
|
+
};
|
|
657
|
+
var canonical = (text) => {
|
|
658
|
+
const scanner = ts2.createScanner(ts2.ScriptTarget.Latest, true, ts2.LanguageVariant.Standard, text);
|
|
659
|
+
const state = { depth: 0, templates: [] };
|
|
660
|
+
const tokens = [];
|
|
661
|
+
for (let token = scanner.scan();token !== ts2.SyntaxKind.EndOfFileToken; token = scanner.scan()) {
|
|
662
|
+
const value = tokenText(scanner, token, state);
|
|
663
|
+
if (CLOSERS.has(value) && tokens.at(LAST2) === ",")
|
|
664
|
+
tokens.pop();
|
|
665
|
+
tokens.push(value);
|
|
666
|
+
}
|
|
667
|
+
return tokens.reduce((joined, token, index) => index > 0 && wordy(tokens[index - 1] ?? "") && wordy(token) ? `${joined} ${token}` : `${joined}${token}`, "");
|
|
668
|
+
};
|
|
637
669
|
var resolveFrom = (files, from, specifier) => {
|
|
638
670
|
if (!specifier.startsWith("."))
|
|
639
671
|
return;
|
|
@@ -799,7 +831,7 @@ var SHAPE = {
|
|
|
799
831
|
types: "types",
|
|
800
832
|
unknown: "unknown"
|
|
801
833
|
};
|
|
802
|
-
var isStub = (declaration) =>
|
|
834
|
+
var isStub = (declaration) => /^export\s*\{/u.test(declaration);
|
|
803
835
|
var signatureOf = (declaration) => {
|
|
804
836
|
const file = parse2(`${declaration}
|
|
805
837
|
`, "declaration.d.ts");
|
|
@@ -815,7 +847,7 @@ var parametersOf = (declaration) => {
|
|
|
815
847
|
const found = [];
|
|
816
848
|
const visit = (node) => {
|
|
817
849
|
if (ts2.isFunctionTypeNode(node) || ts2.isFunctionDeclaration(node) || ts2.isMethodSignature(node) || ts2.isMethodDeclaration(node) || ts2.isConstructSignatureDeclaration(node) || ts2.isConstructorDeclaration(node))
|
|
818
|
-
found.push(node.parameters.map((parameter) =>
|
|
850
|
+
found.push(node.parameters.map((parameter) => canonical(parameter.getText())).join(", "));
|
|
819
851
|
ts2.forEachChild(node, visit);
|
|
820
852
|
};
|
|
821
853
|
visit(statement);
|
|
@@ -835,12 +867,12 @@ var membersOf = (declaration) => {
|
|
|
835
867
|
return members;
|
|
836
868
|
};
|
|
837
869
|
var sameNames = (left, right) => left.size === right.size && [...left].every((name) => right.has(name));
|
|
838
|
-
var changeShape = (
|
|
839
|
-
if (isStub(
|
|
870
|
+
var changeShape = (change) => {
|
|
871
|
+
if (isStub(change.before) !== isStub(change.after))
|
|
840
872
|
return SHAPE.unknown;
|
|
841
|
-
if (parametersOf(
|
|
873
|
+
if (parametersOf(change.before) !== parametersOf(change.after))
|
|
842
874
|
return SHAPE.parameters;
|
|
843
|
-
if (!sameNames(membersOf(
|
|
875
|
+
if (!sameNames(membersOf(change.before), membersOf(change.after)))
|
|
844
876
|
return SHAPE.members;
|
|
845
877
|
return SHAPE.types;
|
|
846
878
|
};
|
|
@@ -857,7 +889,7 @@ var diffSurface = (before, after) => {
|
|
|
857
889
|
const lost = was.entries.filter((entry) => !now.entries.includes(entry));
|
|
858
890
|
if (lost.length > 0)
|
|
859
891
|
withdrawn.push({ from: lost, name });
|
|
860
|
-
if (now.declaration !== was.declaration)
|
|
892
|
+
if (canonical(now.declaration) !== canonical(was.declaration))
|
|
861
893
|
changed.push({
|
|
862
894
|
after: now.declaration,
|
|
863
895
|
before: was.declaration,
|
|
@@ -875,12 +907,12 @@ var diffSurface = (before, after) => {
|
|
|
875
907
|
withdrawn
|
|
876
908
|
};
|
|
877
909
|
};
|
|
878
|
-
var notable = (diff) => diff.changed.filter((
|
|
910
|
+
var notable = (diff) => diff.changed.filter((change) => change.shape === "parameters" || change.shape === "members");
|
|
879
911
|
|
|
880
912
|
// src/entries.ts
|
|
881
|
-
var loadEntry = async (
|
|
913
|
+
var loadEntry = async (path) => {
|
|
882
914
|
try {
|
|
883
|
-
const module = await import(pathToFileURL(
|
|
915
|
+
const module = await import(pathToFileURL(path).href);
|
|
884
916
|
const named = typeof module === "object" && module !== null && "change" in module ? module.change : undefined;
|
|
885
917
|
const exported = named ?? (typeof module === "object" && module !== null && "default" in module ? module.default : undefined);
|
|
886
918
|
const read = { exported };
|
|
@@ -898,10 +930,10 @@ var OUTPUT_DIRECTORIES = ["dist", "build", "lib", "types", "out"];
|
|
|
898
930
|
var newestUnder = async (root) => {
|
|
899
931
|
const found = await readdir(root, { withFileTypes: true }).catch(() => []);
|
|
900
932
|
const times = await Promise.all(found.map(async (entry) => {
|
|
901
|
-
const
|
|
933
|
+
const path = join(root, entry.name);
|
|
902
934
|
if (entry.isDirectory())
|
|
903
|
-
return newestUnder(
|
|
904
|
-
return stat(
|
|
935
|
+
return newestUnder(path);
|
|
936
|
+
return stat(path).then((stats) => stats.mtimeMs, () => 0);
|
|
905
937
|
}));
|
|
906
938
|
return Math.max(0, ...times);
|
|
907
939
|
};
|
|
@@ -957,8 +989,8 @@ var loadUnreleased = async (packageRoot) => {
|
|
|
957
989
|
}
|
|
958
990
|
return { entries, problems };
|
|
959
991
|
};
|
|
960
|
-
var readJsonFile = async (
|
|
961
|
-
const source = await readFile(
|
|
992
|
+
var readJsonFile = async (path) => {
|
|
993
|
+
const source = await readFile(path, "utf8").catch(() => {
|
|
962
994
|
return;
|
|
963
995
|
});
|
|
964
996
|
if (source === undefined)
|
|
@@ -976,39 +1008,39 @@ var strayEntries = async (packageRoot) => {
|
|
|
976
1008
|
};
|
|
977
1009
|
// src/reconcile.ts
|
|
978
1010
|
var migrationHolds = (input) => {
|
|
979
|
-
const { after, change
|
|
1011
|
+
const { after, change, subpaths } = input;
|
|
980
1012
|
const wrong = [];
|
|
981
|
-
const { migration } =
|
|
1013
|
+
const { migration } = change;
|
|
982
1014
|
if ("rename" in migration) {
|
|
983
1015
|
const { from } = migration.rename;
|
|
984
1016
|
const into = migration.rename.to;
|
|
985
1017
|
if (!after.has(into))
|
|
986
|
-
wrong.push(`\`${
|
|
1018
|
+
wrong.push(`\`${change.summary}\` renames to \`${into}\`, which this version does not export`);
|
|
987
1019
|
if (after.has(from))
|
|
988
|
-
wrong.push(`\`${
|
|
989
|
-
if (!
|
|
990
|
-
wrong.push(`\`${
|
|
1020
|
+
wrong.push(`\`${change.summary}\` renames \`${from}\` away, but this version still exports it`);
|
|
1021
|
+
if (!change.symbols.includes(from))
|
|
1022
|
+
wrong.push(`\`${change.summary}\` renames \`${from}\`, which is not in its own symbols`);
|
|
991
1023
|
}
|
|
992
1024
|
if ("moved" in migration) {
|
|
993
1025
|
const { symbol } = migration.moved;
|
|
994
1026
|
const into = migration.moved.to;
|
|
995
1027
|
if (!after.has(symbol))
|
|
996
|
-
wrong.push(`\`${
|
|
1028
|
+
wrong.push(`\`${change.summary}\` moves \`${symbol}\`, which this version does not export`);
|
|
997
1029
|
if (subpaths.size > 0 && !subpaths.has(into))
|
|
998
|
-
wrong.push(`\`${
|
|
1030
|
+
wrong.push(`\`${change.summary}\` moves \`${symbol}\` to \`${into}\`, which is not an entry point of this package`);
|
|
999
1031
|
}
|
|
1000
1032
|
if ("resubpath" in migration && subpaths.size > 0 && !subpaths.has(migration.resubpath.to))
|
|
1001
|
-
wrong.push(`\`${
|
|
1002
|
-
if (
|
|
1003
|
-
for (const symbol of
|
|
1033
|
+
wrong.push(`\`${change.summary}\` points at \`${migration.resubpath.to}\`, which is not an entry point of this package`);
|
|
1034
|
+
if (change.kind === "removed") {
|
|
1035
|
+
for (const symbol of change.symbols)
|
|
1004
1036
|
if (after.has(symbol))
|
|
1005
|
-
wrong.push(`\`${
|
|
1037
|
+
wrong.push(`\`${change.summary}\` says \`${symbol}\` was removed, but this version still exports it`);
|
|
1006
1038
|
}
|
|
1007
1039
|
return wrong;
|
|
1008
1040
|
};
|
|
1009
1041
|
var describeReconciliation = (found) => {
|
|
1010
1042
|
const lines = [];
|
|
1011
|
-
const
|
|
1043
|
+
const moved = {
|
|
1012
1044
|
members: "changed the members of its type",
|
|
1013
1045
|
parameters: "changed what it is called with",
|
|
1014
1046
|
removed: "is no longer exported",
|
|
@@ -1016,27 +1048,27 @@ var describeReconciliation = (found) => {
|
|
|
1016
1048
|
withdrawn: "is no longer exported from"
|
|
1017
1049
|
};
|
|
1018
1050
|
for (const entry of found.unannounced)
|
|
1019
|
-
lines.push(entry.kind === "withdrawn" ? `\`${entry.name}\` ${
|
|
1051
|
+
lines.push(entry.kind === "withdrawn" ? `\`${entry.name}\` ${moved.withdrawn} ${(entry.from ?? []).join(", ")} and no entry says so` : `\`${entry.name}\` ${moved[entry.kind]} and no entry says so`);
|
|
1020
1052
|
for (const name of found.unknownSymbols)
|
|
1021
1053
|
lines.push(`an entry names \`${name}\`, which this package does not export`);
|
|
1022
1054
|
lines.push(...found.wrongMigrations);
|
|
1023
1055
|
return lines;
|
|
1024
1056
|
};
|
|
1025
1057
|
var reconcile = (input) => {
|
|
1026
|
-
const disruptive = new Set(input.changes.filter(isDisruptive).flatMap((
|
|
1027
|
-
const mentioned = new Set(input.changes.flatMap((
|
|
1058
|
+
const disruptive = new Set(input.changes.filter(isDisruptive).flatMap((change) => [...change.symbols]));
|
|
1059
|
+
const mentioned = new Set(input.changes.flatMap((change) => [...change.symbols ?? []]));
|
|
1028
1060
|
const unannounced = [
|
|
1029
1061
|
...input.diff.removed.filter((name) => !disruptive.has(name)).map((name) => ({ kind: "removed", name })),
|
|
1030
1062
|
...input.diff.withdrawn.filter((entry) => !disruptive.has(entry.name)).map((entry) => ({ from: entry.from, kind: "withdrawn", name: entry.name })),
|
|
1031
|
-
...input.diff.changed.filter((
|
|
1063
|
+
...input.diff.changed.filter((change) => !mentioned.has(change.name) && change.shape !== "unknown").map((change) => ({ kind: change.shape, name: change.name }))
|
|
1032
1064
|
];
|
|
1033
1065
|
const unknownSymbols = [
|
|
1034
|
-
...new Set(input.changes.flatMap((
|
|
1066
|
+
...new Set(input.changes.flatMap((change) => [...change.symbols ?? []]).filter((name) => !input.known.has(name)))
|
|
1035
1067
|
];
|
|
1036
1068
|
const { after } = input;
|
|
1037
|
-
const wrongMigrations = after === undefined ? [] : input.changes.filter(isDisruptive).flatMap((
|
|
1069
|
+
const wrongMigrations = after === undefined ? [] : input.changes.filter(isDisruptive).flatMap((change) => migrationHolds({
|
|
1038
1070
|
after,
|
|
1039
|
-
change
|
|
1071
|
+
change,
|
|
1040
1072
|
subpaths: input.subpaths ?? new Set
|
|
1041
1073
|
}));
|
|
1042
1074
|
return { unannounced, unknownSymbols, wrongMigrations };
|
|
@@ -1135,7 +1167,7 @@ var publishedChangelog = async (name, version, options = {}) => {
|
|
|
1135
1167
|
const archive = await packageArchive(name, version, options);
|
|
1136
1168
|
if (!archive)
|
|
1137
1169
|
return;
|
|
1138
|
-
const file = readTar(archive, (
|
|
1170
|
+
const file = readTar(archive, (path) => path === CHANGELOG_FILE).get(CHANGELOG_FILE);
|
|
1139
1171
|
if (!file)
|
|
1140
1172
|
return;
|
|
1141
1173
|
try {
|
|
@@ -1178,19 +1210,19 @@ var migrationLine = (migration) => {
|
|
|
1178
1210
|
return `Import from \`${migration.resubpath.to}\` instead of \`${migration.resubpath.from}\`.`;
|
|
1179
1211
|
return migration.instruction;
|
|
1180
1212
|
};
|
|
1181
|
-
var renderChange = (
|
|
1182
|
-
const symbols =
|
|
1183
|
-
const lines = [`- **${
|
|
1184
|
-
if (
|
|
1185
|
-
lines.push(` ${
|
|
1186
|
-
if (isDisruptive(
|
|
1187
|
-
lines.push(` _Migration:_ ${
|
|
1188
|
-
const mechanical = migrationLine(
|
|
1189
|
-
if (mechanical !==
|
|
1213
|
+
var renderChange = (change) => {
|
|
1214
|
+
const symbols = change.symbols && change.symbols.length > 0 ? ` (${change.symbols.map((name) => `\`${name}\``).join(", ")})` : "";
|
|
1215
|
+
const lines = [`- **${change.summary}**${symbols}`];
|
|
1216
|
+
if (change.detail !== undefined)
|
|
1217
|
+
lines.push(` ${change.detail}`);
|
|
1218
|
+
if (isDisruptive(change)) {
|
|
1219
|
+
lines.push(` _Migration:_ ${change.migration.instruction}`);
|
|
1220
|
+
const mechanical = migrationLine(change.migration);
|
|
1221
|
+
if (mechanical !== change.migration.instruction)
|
|
1190
1222
|
lines.push(` _Applied automatically:_ ${mechanical}`);
|
|
1191
1223
|
}
|
|
1192
|
-
if (
|
|
1193
|
-
lines.push(` See ${
|
|
1224
|
+
if (change.reference !== undefined)
|
|
1225
|
+
lines.push(` See ${change.reference}.`);
|
|
1194
1226
|
return lines.join(`
|
|
1195
1227
|
`);
|
|
1196
1228
|
};
|
|
@@ -1217,13 +1249,13 @@ var renderChangelogJson = (changelog) => `${JSON.stringify({
|
|
|
1217
1249
|
contract: CHANGELOG_CONTRACT,
|
|
1218
1250
|
name: changelog.name,
|
|
1219
1251
|
releases: [...changelog.releases].sort((left, right) => compareVersions(right.version, left.version)).map((release) => ({
|
|
1220
|
-
changes: release.changes.map((
|
|
1221
|
-
...
|
|
1222
|
-
kind:
|
|
1223
|
-
...isDisruptive(
|
|
1224
|
-
...
|
|
1225
|
-
summary:
|
|
1226
|
-
...
|
|
1252
|
+
changes: release.changes.map((change) => ({
|
|
1253
|
+
...change.detail === undefined ? {} : { detail: change.detail },
|
|
1254
|
+
kind: change.kind,
|
|
1255
|
+
...isDisruptive(change) ? { migration: change.migration } : {},
|
|
1256
|
+
...change.reference === undefined ? {} : { reference: change.reference },
|
|
1257
|
+
summary: change.summary,
|
|
1258
|
+
...change.symbols && change.symbols.length > 0 ? { symbols: change.symbols } : {}
|
|
1227
1259
|
})),
|
|
1228
1260
|
date: release.date,
|
|
1229
1261
|
...release.note === undefined ? {} : { note: release.note },
|
|
@@ -1307,5 +1339,5 @@ export {
|
|
|
1307
1339
|
validateChange
|
|
1308
1340
|
};
|
|
1309
1341
|
|
|
1310
|
-
//# debugId=
|
|
1342
|
+
//# debugId=00D829A9B9D35BB264756E2164756E21
|
|
1311
1343
|
//# sourceMappingURL=index.js.map
|