@absolutejs/changelog 0.7.0 → 0.8.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 CHANGED
@@ -6,6 +6,20 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.8.0 — 2026-11-19
10
+
11
+ ### Added
12
+
13
+ - **Migrations can rename a class's methods and move dependencies** (`Migration`, `applyMigration`, `applyDependencyMigrations`, `isDependencyMigration`)
14
+ A method renamed on a class's instances (`new Elysia().beforeHandle(...)` to `.onBeforeHandle(...)`) and a peer that has to move with a release (Elysia to 2.0.0-rc.0) are now data a project can have applied, like a renamed export. A method is renamed only where the file shows its receiver is an instance; a dependency moves only where it is a version range below the one asked for.
15
+
16
+ ## 0.7.1 — 2026-10-07
17
+
18
+ ### Fixed
19
+
20
+ - **Quote style, comments and line wrapping no longer read as API changes** (`diffSurface`)
21
+ Two builds of the same API can print a declaration differently: a formatter swaps 'single' for "double" quotes, wraps a parameter list and adds a trailing comma, or a doc comment is reworded. The release gate and the upgrade advisor reported each of those as a changed export. Declarations are now compared token by token, with string literals in one form and comments, trailing commas and spacing ignored; a different string, type or parameter is still a change. The declarations shown in a report keep their own text.
22
+
9
23
  ## 0.7.0 — 2026-09-10
10
24
 
11
25
  ### Added
package/changelog.json CHANGED
@@ -2,6 +2,37 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/changelog",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "detail": "A method renamed on a class's instances (`new Elysia().beforeHandle(...)` to `.onBeforeHandle(...)`) and a peer that has to move with a release (Elysia to 2.0.0-rc.0) are now data a project can have applied, like a renamed export. A method is renamed only where the file shows its receiver is an instance; a dependency moves only where it is a version range below the one asked for.",
9
+ "kind": "added",
10
+ "summary": "Migrations can rename a class's methods and move dependencies",
11
+ "symbols": [
12
+ "Migration",
13
+ "applyMigration",
14
+ "applyDependencyMigrations",
15
+ "isDependencyMigration"
16
+ ]
17
+ }
18
+ ],
19
+ "date": "2026-11-19",
20
+ "version": "0.8.0"
21
+ },
22
+ {
23
+ "changes": [
24
+ {
25
+ "detail": "Two builds of the same API can print a declaration differently: a formatter swaps 'single' for \"double\" quotes, wraps a parameter list and adds a trailing comma, or a doc comment is reworded. The release gate and the upgrade advisor reported each of those as a changed export. Declarations are now compared token by token, with string literals in one form and comments, trailing commas and spacing ignored; a different string, type or parameter is still a change. The declarations shown in a report keep their own text.",
26
+ "kind": "fixed",
27
+ "summary": "Quote style, comments and line wrapping no longer read as API changes",
28
+ "symbols": [
29
+ "diffSurface"
30
+ ]
31
+ }
32
+ ],
33
+ "date": "2026-10-07",
34
+ "version": "0.7.1"
35
+ },
5
36
  {
6
37
  "changes": [
7
38
  {
package/dist/apply.d.ts CHANGED
@@ -17,7 +17,11 @@ export declare const applyMigration: (source: string, input: {
17
17
  migration: Migration;
18
18
  packageName: string;
19
19
  path?: string;
20
- }) => MigrationResult;
20
+ }) => {
21
+ changed: boolean;
22
+ notes: string[];
23
+ source: string;
24
+ };
21
25
  /**
22
26
  * Apply migrations in order.
23
27
  *
@@ -0,0 +1,13 @@
1
+ import { type Migration } from "./types";
2
+ export type DependencyEdit = {
3
+ from: string;
4
+ name: string;
5
+ section: string;
6
+ to: string;
7
+ };
8
+ type Outcome = {
9
+ edits: DependencyEdit[];
10
+ manifest: string;
11
+ };
12
+ export declare const applyDependencyMigrations: (manifest: string, migrations: readonly Migration[]) => Outcome;
13
+ export {};
@@ -0,0 +1,16 @@
1
+ import ts from "typescript";
2
+ import type { Migration } from "./types";
3
+ type MethodsMigration = Extract<Migration, {
4
+ methods: unknown;
5
+ }>;
6
+ type Result = {
7
+ changed: boolean;
8
+ notes: string[];
9
+ source: string;
10
+ };
11
+ export declare const applyMethods: (input: {
12
+ file: ts.SourceFile;
13
+ methods: MethodsMigration["methods"];
14
+ source: string;
15
+ }) => Result;
16
+ export {};
package/dist/cli.js CHANGED
@@ -28,6 +28,7 @@ var CHANGELOG_CONTRACT = 1;
28
28
  var CHANGELOG_FILE = "changelog.json";
29
29
  var CHANGELOG_MARKDOWN = "CHANGELOG.md";
30
30
  var UNRELEASED_DIRECTORY = "changelog/unreleased";
31
+ var isDependencyMigration = (migration) => ("dependencies" in migration);
31
32
  var isDisruptive = (change) => change.kind === "breaking" || change.kind === "removed";
32
33
  var isMechanical = (migration) => !("manual" in migration);
33
34
 
@@ -145,9 +146,27 @@ var readMigration = (value, where, problems) => {
145
146
  instruction,
146
147
  resubpath: { from: resubpath.from, to: resubpath.to }
147
148
  };
149
+ const { methods } = value;
150
+ if (isRecord(methods) && isRecord(methods.owner) && isText(methods.owner.module) && isText(methods.owner.export) && isRecord(methods.renames) && Object.keys(methods.renames).length > 0 && Object.values(methods.renames).every(isText))
151
+ return {
152
+ instruction,
153
+ methods: {
154
+ owner: { export: methods.owner.export, module: methods.owner.module },
155
+ renames: Object.fromEntries(Object.entries(methods.renames).filter((entry) => isText(entry[1])))
156
+ }
157
+ };
158
+ const { dependencies } = value;
159
+ if (isRecord(dependencies) && isText(dependencies.range) && Array.isArray(dependencies.names) && dependencies.names.length > 0 && dependencies.names.every(isText)) {
160
+ const [first, ...rest] = dependencies.names.filter((name) => isText(name));
161
+ if (first !== undefined)
162
+ return {
163
+ dependencies: { names: [first, ...rest], range: dependencies.range },
164
+ instruction
165
+ };
166
+ }
148
167
  if (value.manual === true)
149
168
  return { instruction, manual: true };
150
- problems.push(`${where}: migration says neither rename, moved, resubpath nor manual`);
169
+ problems.push(`${where}: migration says neither rename, moved, resubpath, methods, dependencies nor manual`);
151
170
  return;
152
171
  };
153
172
  var readChange = (value, where, problems) => {
@@ -337,6 +356,38 @@ var readTar = (archive, keep, limits = {}) => {
337
356
  var DECLARATION = /\.d\.[cm]?ts$/u;
338
357
  var parse = (source, name) => ts.createSourceFile(name, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
339
358
  var normalize = (text) => text.replace(/\s+/gu, " ").trim();
359
+ var CLOSERS = new Set(["}", ")", "]", ">"]);
360
+ var wordy = (token) => /^[\w$#@]/u.test(token) || /[\w$]$/u.test(token);
361
+ var LAST2 = -1;
362
+ var tokenText = (scanner, scanned, state) => {
363
+ const closesTemplate = scanned === ts.SyntaxKind.CloseBraceToken && state.templates.at(LAST2) === state.depth;
364
+ const token = closesTemplate ? scanner.reScanTemplateToken(false) : scanned;
365
+ if (closesTemplate && token === ts.SyntaxKind.TemplateTail)
366
+ state.templates.pop();
367
+ if (closesTemplate)
368
+ return scanner.getTokenText();
369
+ if (token === ts.SyntaxKind.StringLiteral)
370
+ return JSON.stringify(scanner.getTokenValue());
371
+ if (token === ts.SyntaxKind.TemplateHead)
372
+ state.templates.push(state.depth);
373
+ if (token === ts.SyntaxKind.OpenBraceToken)
374
+ state.depth += 1;
375
+ if (token === ts.SyntaxKind.CloseBraceToken)
376
+ state.depth -= 1;
377
+ return scanner.getTokenText();
378
+ };
379
+ var canonical = (text) => {
380
+ const scanner = ts.createScanner(ts.ScriptTarget.Latest, true, ts.LanguageVariant.Standard, text);
381
+ const state = { depth: 0, templates: [] };
382
+ const tokens = [];
383
+ for (let token = scanner.scan();token !== ts.SyntaxKind.EndOfFileToken; token = scanner.scan()) {
384
+ const value = tokenText(scanner, token, state);
385
+ if (CLOSERS.has(value) && tokens.at(LAST2) === ",")
386
+ tokens.pop();
387
+ tokens.push(value);
388
+ }
389
+ return tokens.reduce((joined, token, index) => index > 0 && wordy(tokens[index - 1] ?? "") && wordy(token) ? `${joined} ${token}` : `${joined}${token}`, "");
390
+ };
340
391
  var resolveFrom = (files, from, specifier) => {
341
392
  if (!specifier.startsWith("."))
342
393
  return;
@@ -502,7 +553,7 @@ var SHAPE = {
502
553
  types: "types",
503
554
  unknown: "unknown"
504
555
  };
505
- var isStub = (declaration) => declaration.startsWith("export {");
556
+ var isStub = (declaration) => /^export\s*\{/u.test(declaration);
506
557
  var signatureOf = (declaration) => {
507
558
  const file = parse(`${declaration}
508
559
  `, "declaration.d.ts");
@@ -518,7 +569,7 @@ var parametersOf = (declaration) => {
518
569
  const found = [];
519
570
  const visit = (node) => {
520
571
  if (ts.isFunctionTypeNode(node) || ts.isFunctionDeclaration(node) || ts.isMethodSignature(node) || ts.isMethodDeclaration(node) || ts.isConstructSignatureDeclaration(node) || ts.isConstructorDeclaration(node))
521
- found.push(node.parameters.map((parameter) => normalize(parameter.getText())).join(", "));
572
+ found.push(node.parameters.map((parameter) => canonical(parameter.getText())).join(", "));
522
573
  ts.forEachChild(node, visit);
523
574
  };
524
575
  visit(statement);
@@ -560,7 +611,7 @@ var diffSurface = (before, after) => {
560
611
  const lost = was.entries.filter((entry) => !now.entries.includes(entry));
561
612
  if (lost.length > 0)
562
613
  withdrawn.push({ from: lost, name });
563
- if (now.declaration !== was.declaration)
614
+ if (canonical(now.declaration) !== canonical(was.declaration))
564
615
  changed.push({
565
616
  after: now.declaration,
566
617
  before: was.declaration,
@@ -581,9 +632,9 @@ var diffSurface = (before, after) => {
581
632
  var notable = (diff) => diff.changed.filter((change) => change.shape === "parameters" || change.shape === "members");
582
633
 
583
634
  // src/entries.ts
584
- var loadEntry = async (path2) => {
635
+ var loadEntry = async (path) => {
585
636
  try {
586
- const module = await import(pathToFileURL(path2).href);
637
+ const module = await import(pathToFileURL(path).href);
587
638
  const named = typeof module === "object" && module !== null && "change" in module ? module.change : undefined;
588
639
  const exported = named ?? (typeof module === "object" && module !== null && "default" in module ? module.default : undefined);
589
640
  const read = { exported };
@@ -601,10 +652,10 @@ var OUTPUT_DIRECTORIES = ["dist", "build", "lib", "types", "out"];
601
652
  var newestUnder = async (root) => {
602
653
  const found = await readdir(root, { withFileTypes: true }).catch(() => []);
603
654
  const times = await Promise.all(found.map(async (entry) => {
604
- const path2 = join(root, entry.name);
655
+ const path = join(root, entry.name);
605
656
  if (entry.isDirectory())
606
- return newestUnder(path2);
607
- return stat(path2).then((stats) => stats.mtimeMs, () => 0);
657
+ return newestUnder(path);
658
+ return stat(path).then((stats) => stats.mtimeMs, () => 0);
608
659
  }));
609
660
  return Math.max(0, ...times);
610
661
  };
@@ -660,8 +711,8 @@ var loadUnreleased = async (packageRoot) => {
660
711
  }
661
712
  return { entries, problems };
662
713
  };
663
- var readJsonFile = async (path2) => {
664
- const source = await readFile(path2, "utf8").catch(() => {
714
+ var readJsonFile = async (path) => {
715
+ const source = await readFile(path, "utf8").catch(() => {
665
716
  return;
666
717
  });
667
718
  if (source === undefined)
@@ -684,9 +735,9 @@ var indentOf = (source) => {
684
735
  const found = /\n([\t ]+)\S/u.exec(source)?.[1];
685
736
  return found === undefined || found === "" ? "\t" : found;
686
737
  };
687
- var writeJsonLike = async (path2, document) => {
688
- const source = await readFile2(path2, "utf8").catch(() => "");
689
- await writeFile(path2, `${JSON.stringify(document, null, indentOf(source))}
738
+ var writeJsonLike = async (path, document) => {
739
+ const source = await readFile2(path, "utf8").catch(() => "");
740
+ await writeFile(path, `${JSON.stringify(document, null, indentOf(source))}
690
741
  `);
691
742
  };
692
743
 
@@ -852,7 +903,7 @@ var publishedChangelog = async (name, version, options = {}) => {
852
903
  const archive = await packageArchive(name, version, options);
853
904
  if (!archive)
854
905
  return;
855
- const file = readTar(archive, (path2) => path2 === CHANGELOG_FILE).get(CHANGELOG_FILE);
906
+ const file = readTar(archive, (path) => path === CHANGELOG_FILE).get(CHANGELOG_FILE);
856
907
  if (!file)
857
908
  return;
858
909
  try {
@@ -894,6 +945,10 @@ var migrationLine = (migration) => {
894
945
  return `Import \`${migration.moved.symbol}\` from \`${migration.moved.to}\` instead of \`${migration.moved.from}\`.`;
895
946
  if ("resubpath" in migration)
896
947
  return `Import from \`${migration.resubpath.to}\` instead of \`${migration.resubpath.from}\`.`;
948
+ if ("methods" in migration)
949
+ return `${Object.entries(migration.methods.renames).map(([before, after]) => `\`.${before}()\` is now \`.${after}()\``).join(", ")} on \`${migration.methods.owner.export}\`.`;
950
+ if ("dependencies" in migration)
951
+ return `Move ${migration.dependencies.names.map((name) => `\`${name}\``).join(", ")} to \`${migration.dependencies.range}\`.`;
897
952
  return migration.instruction;
898
953
  };
899
954
  var renderChange = (change) => {
@@ -1192,7 +1247,7 @@ var check = async (root, flags) => {
1192
1247
  failures.push(`the registry did not answer for ${manifest.name}, so nothing was compared \u2014 pass --offline to skip the comparison deliberately`);
1193
1248
  if (versions !== undefined && versions.published.length === 0)
1194
1249
  console.warn(` (${manifest.name} has never been published, so there was nothing to compare)`);
1195
- const baseline = (versions?.published ?? []).filter((version) => compareVersions(version, manifest.version) <= 0).sort(compareVersions).at(LAST2);
1250
+ const baseline = (versions?.published ?? []).filter((version) => compareVersions(version, manifest.version) <= 0).sort(compareVersions).at(LAST3);
1196
1251
  if (versions !== undefined && versions.published.length > 0 && baseline === undefined && !offline)
1197
1252
  console.warn(` (nothing published at or below ${manifest.version}, so there was nothing to compare)`);
1198
1253
  if (built !== undefined && baseline !== undefined) {
@@ -1216,7 +1271,7 @@ var check = async (root, flags) => {
1216
1271
  `));
1217
1272
  console.log(`${manifest.name}@${manifest.version}: changelog holds (${entries.length} pending, ${current.releases.length} released)`);
1218
1273
  };
1219
- var LAST2 = -1;
1274
+ var LAST3 = -1;
1220
1275
  var subpathsOf = (manifest) => {
1221
1276
  const { exports } = manifest;
1222
1277
  if (typeof exports !== "object" || exports === null)
@@ -1224,13 +1279,13 @@ var subpathsOf = (manifest) => {
1224
1279
  return new Set(Object.keys(exports).map((key) => key === "." ? manifest.name ?? "" : `${manifest.name}${key.slice(1)}`));
1225
1280
  };
1226
1281
  var CHECKING_CONFIGS = ["tsconfig.json", "tsconfig.eslint.json"];
1227
- var readTsconfig = async (path2) => {
1228
- const source = await readFile3(path2, "utf8").catch(() => {
1282
+ var readTsconfig = async (path) => {
1283
+ const source = await readFile3(path, "utf8").catch(() => {
1229
1284
  return;
1230
1285
  });
1231
1286
  if (source === undefined)
1232
1287
  return;
1233
- const read = ts2.parseConfigFileTextToJson(path2, source);
1288
+ const read = ts2.parseConfigFileTextToJson(path, source);
1234
1289
  if (read.error !== undefined)
1235
1290
  return;
1236
1291
  const { config } = read;
@@ -1240,8 +1295,8 @@ var readTsconfig = async (path2) => {
1240
1295
  var coversEntries = (include) => Array.isArray(include) && include.some((entry) => typeof entry === "string" && entry.startsWith("changelog"));
1241
1296
  var includeOf = (config) => typeof config === "object" && config !== null ? new Map(Object.entries(config)).get("include") : undefined;
1242
1297
  var includeEntriesIn = async (root, file) => {
1243
- const path2 = join2(root, file);
1244
- const read = await readTsconfig(path2);
1298
+ const path = join2(root, file);
1299
+ const read = await readTsconfig(path);
1245
1300
  if (read === undefined)
1246
1301
  return false;
1247
1302
  const include = includeOf(read.config);
@@ -1251,7 +1306,7 @@ var includeEntriesIn = async (root, file) => {
1251
1306
  if (opened === null)
1252
1307
  return false;
1253
1308
  const opens = opened.index + opened[0].length;
1254
- await writeFile2(path2, `${read.source.slice(0, opens)}
1309
+ await writeFile2(path, `${read.source.slice(0, opens)}
1255
1310
  "changelog/**/*",${read.source.slice(opens)}`);
1256
1311
  return true;
1257
1312
  };
@@ -1260,8 +1315,8 @@ var includeEntries = async (root) => {
1260
1315
  return wired.some(Boolean) ? undefined : "no tsconfig include list to wire \u2014 make sure changelog/ is compiled by something";
1261
1316
  };
1262
1317
  var ignoreGenerated = async (root) => {
1263
- const path2 = join2(root, ".prettierignore");
1264
- const existing = await readFile3(path2, "utf8").catch(() => "");
1318
+ const path = join2(root, ".prettierignore");
1319
+ const existing = await readFile3(path, "utf8").catch(() => "");
1265
1320
  const wanted = [CHANGELOG_FILE, CHANGELOG_MARKDOWN].filter((name) => !existing.split(`
1266
1321
  `).includes(name));
1267
1322
  if (wanted.length === 0)
@@ -1269,7 +1324,7 @@ var ignoreGenerated = async (root) => {
1269
1324
  const head = existing.trim() === "" ? `# Generated by absolute-changelog. Edit the entries, not these.
1270
1325
  ` : `${existing.trimEnd()}
1271
1326
  `;
1272
- await writeFile2(path2, `${head}${wanted.join(`
1327
+ await writeFile2(path, `${head}${wanted.join(`
1273
1328
  `)}
1274
1329
  `);
1275
1330
  };
@@ -1333,5 +1388,5 @@ await main().catch((error) => {
1333
1388
  process.exit(1);
1334
1389
  });
1335
1390
 
1336
- //# debugId=D18444F7EA93A50564756E2164756E21
1391
+ //# debugId=F85103537D4064B364756E2164756E21
1337
1392
  //# sourceMappingURL=cli.js.map