@absolutejs/changelog 0.8.1 → 0.9.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 +14 -0
- package/changelog.json +30 -0
- package/dist/applyMethods.d.ts +15 -0
- package/dist/cli.js +35 -1
- package/dist/cli.js.map +5 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +65 -21
- package/dist/index.js.map +7 -7
- package/dist/types.d.ts +22 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,15 +74,10 @@ var variablesOf = (file) => {
|
|
|
74
74
|
return declared;
|
|
75
75
|
};
|
|
76
76
|
var applyEdits = (source, edits) => [...edits].sort((left, right) => right.start - left.start).reduce((out, edit) => out.slice(0, edit.start) + edit.text + out.slice(edit.end), source);
|
|
77
|
-
var
|
|
78
|
-
const
|
|
79
|
-
const unchanged = { changed: false, notes: [], source };
|
|
80
|
-
const renameOf = new Map(Object.entries(methods.renames).filter(([before, after]) => IDENTIFIER.test(before) && IDENTIFIER.test(after)));
|
|
81
|
-
if (renameOf.size === 0)
|
|
82
|
-
return unchanged;
|
|
83
|
-
const binding = bindingsOf(file, methods.owner);
|
|
77
|
+
var instanceCalls = (file, owner, names) => {
|
|
78
|
+
const binding = bindingsOf(file, owner);
|
|
84
79
|
if (binding.names.size === 0 && binding.namespaces.size === 0)
|
|
85
|
-
return
|
|
80
|
+
return [];
|
|
86
81
|
const instances = new Set;
|
|
87
82
|
const step = (node) => {
|
|
88
83
|
if (ts.isNewExpression(node))
|
|
@@ -115,19 +110,26 @@ var applyMethods = (input) => {
|
|
|
115
110
|
found.forEach(({ name }) => instances.add(name));
|
|
116
111
|
found = newlyFound();
|
|
117
112
|
}
|
|
118
|
-
const
|
|
113
|
+
const calls = [];
|
|
119
114
|
const visit = (node) => {
|
|
120
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) &&
|
|
121
|
-
|
|
122
|
-
edits.push({
|
|
123
|
-
end: name.getEnd(),
|
|
124
|
-
start: name.getStart(file),
|
|
125
|
-
text: renameOf.get(name.text) ?? name.text
|
|
126
|
-
});
|
|
127
|
-
}
|
|
115
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && names.has(node.expression.name.text) && isInstance(node.expression.expression))
|
|
116
|
+
calls.push(node.expression.name);
|
|
128
117
|
ts.forEachChild(node, visit);
|
|
129
118
|
};
|
|
130
119
|
visit(file);
|
|
120
|
+
return calls;
|
|
121
|
+
};
|
|
122
|
+
var applyMethods = (input) => {
|
|
123
|
+
const { file, methods, source } = input;
|
|
124
|
+
const unchanged = { changed: false, notes: [], source };
|
|
125
|
+
const renameOf = new Map(Object.entries(methods.renames).filter(([before, after]) => IDENTIFIER.test(before) && IDENTIFIER.test(after)));
|
|
126
|
+
if (renameOf.size === 0)
|
|
127
|
+
return unchanged;
|
|
128
|
+
const edits = instanceCalls(file, methods.owner, new Set(renameOf.keys())).map((name) => ({
|
|
129
|
+
end: name.getEnd(),
|
|
130
|
+
start: name.getStart(file),
|
|
131
|
+
text: renameOf.get(name.text) ?? name.text
|
|
132
|
+
}));
|
|
131
133
|
if (edits.length === 0)
|
|
132
134
|
return unchanged;
|
|
133
135
|
const changed = {
|
|
@@ -137,6 +139,13 @@ var applyMethods = (input) => {
|
|
|
137
139
|
};
|
|
138
140
|
return changed;
|
|
139
141
|
};
|
|
142
|
+
var findCalls = (input) => {
|
|
143
|
+
const file = ts.createSourceFile(input.path, input.source, ts.ScriptTarget.Latest, true, /\.[cm]?ts$/u.test(input.path) ? ts.ScriptKind.TS : ts.ScriptKind.TSX);
|
|
144
|
+
return instanceCalls(file, input.owner, new Set(input.methods)).map((name) => ({
|
|
145
|
+
line: file.getLineAndCharacterOfPosition(name.getStart(file)).line + 1,
|
|
146
|
+
method: name.text
|
|
147
|
+
}));
|
|
148
|
+
};
|
|
140
149
|
|
|
141
150
|
// src/types.ts
|
|
142
151
|
var CHANGE_KINDS = [
|
|
@@ -449,9 +458,9 @@ var SCOPE_WILDCARD = "/*";
|
|
|
449
458
|
var isTable = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
450
459
|
var matches = (pattern, name) => pattern.endsWith(SCOPE_WILDCARD) ? name.startsWith(pattern.slice(0, pattern.length - 1)) : pattern === name;
|
|
451
460
|
var floorOf = (spec) => spec.trim().replace(/^[\^~<>=v\s]+/u, "").split(/[\s|]/u)[0] ?? "";
|
|
452
|
-
var
|
|
461
|
+
var isBelow = (version, floor) => {
|
|
453
462
|
try {
|
|
454
|
-
return Bun.semver.
|
|
463
|
+
return Bun.semver.order(version, floor) < 0;
|
|
455
464
|
} catch {
|
|
456
465
|
return false;
|
|
457
466
|
}
|
|
@@ -488,7 +497,7 @@ var editText = (text, edit) => {
|
|
|
488
497
|
};
|
|
489
498
|
var moves = (migration, name, spec) => {
|
|
490
499
|
const { names, range } = migration.dependencies;
|
|
491
|
-
return typeof spec === "string" && VERSIONED.test(spec) && names.some((pattern) => matches(pattern, name)) && spec !== range &&
|
|
500
|
+
return typeof spec === "string" && VERSIONED.test(spec) && names.some((pattern) => matches(pattern, name)) && spec !== range && isBelow(floorOf(spec), floorOf(range));
|
|
492
501
|
};
|
|
493
502
|
var moveSection = (table, section, migration) => {
|
|
494
503
|
const { range } = migration.dependencies;
|
|
@@ -691,6 +700,37 @@ var readMigration = (value, where, problems) => {
|
|
|
691
700
|
problems.push(`${where}: migration says neither rename, moved, resubpath, methods, dependencies nor manual`);
|
|
692
701
|
return;
|
|
693
702
|
};
|
|
703
|
+
var nonEmptyText = (value) => {
|
|
704
|
+
if (!Array.isArray(value))
|
|
705
|
+
return;
|
|
706
|
+
const [first, ...rest] = value.filter((entry) => isText(entry));
|
|
707
|
+
if (first === undefined || rest.length + 1 !== value.length)
|
|
708
|
+
return;
|
|
709
|
+
const list = [first, ...rest];
|
|
710
|
+
return list;
|
|
711
|
+
};
|
|
712
|
+
var readReach = (value, where, problems) => {
|
|
713
|
+
if (value === undefined)
|
|
714
|
+
return;
|
|
715
|
+
const calls = isRecord(value) && isRecord(value.calls) && isRecord(value.calls.owner) ? {
|
|
716
|
+
methods: nonEmptyText(value.calls.methods),
|
|
717
|
+
owner: value.calls.owner
|
|
718
|
+
} : undefined;
|
|
719
|
+
const files = isRecord(value) ? nonEmptyText(value.files) : undefined;
|
|
720
|
+
const callsRead = calls?.methods !== undefined && isText(calls.owner.export) && isText(calls.owner.module) ? {
|
|
721
|
+
methods: calls.methods,
|
|
722
|
+
owner: { export: calls.owner.export, module: calls.owner.module }
|
|
723
|
+
} : undefined;
|
|
724
|
+
if (!isRecord(value) || value.calls !== undefined && callsRead === undefined || value.files !== undefined && files === undefined || callsRead === undefined && files === undefined) {
|
|
725
|
+
problems.push(`${where}: reaches names neither calls nor files`);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const reach = {
|
|
729
|
+
...callsRead === undefined ? {} : { calls: callsRead },
|
|
730
|
+
...files === undefined ? {} : { files }
|
|
731
|
+
};
|
|
732
|
+
return reach;
|
|
733
|
+
};
|
|
694
734
|
var readChange = (value, where, problems) => {
|
|
695
735
|
if (!isRecord(value)) {
|
|
696
736
|
problems.push(`${where}: not an object`);
|
|
@@ -705,8 +745,10 @@ var readChange = (value, where, problems) => {
|
|
|
705
745
|
problems.push(`${where}: needs a summary`);
|
|
706
746
|
return;
|
|
707
747
|
}
|
|
748
|
+
const reaches = readReach(value.reaches, where, problems);
|
|
708
749
|
const shared = {
|
|
709
750
|
...isText(value.detail) ? { detail: value.detail } : {},
|
|
751
|
+
...reaches === undefined ? {} : { reaches },
|
|
710
752
|
...isText(value.reference) ? { reference: value.reference } : {},
|
|
711
753
|
summary: value.summary
|
|
712
754
|
};
|
|
@@ -1501,6 +1543,7 @@ var renderChangelogJson = (changelog) => `${JSON.stringify({
|
|
|
1501
1543
|
...change.detail === undefined ? {} : { detail: change.detail },
|
|
1502
1544
|
kind: change.kind,
|
|
1503
1545
|
...isDisruptive(change) ? { migration: change.migration } : {},
|
|
1546
|
+
...change.reaches === undefined ? {} : { reaches: change.reaches },
|
|
1504
1547
|
...change.reference === undefined ? {} : { reference: change.reference },
|
|
1505
1548
|
summary: change.summary,
|
|
1506
1549
|
...change.symbols && change.symbols.length > 0 ? { symbols: change.symbols } : {}
|
|
@@ -1555,6 +1598,7 @@ export {
|
|
|
1555
1598
|
describeReconciliation,
|
|
1556
1599
|
diffSurface,
|
|
1557
1600
|
disruptiveBetween,
|
|
1601
|
+
findCalls,
|
|
1558
1602
|
forgetRegistry,
|
|
1559
1603
|
isDependencyMigration,
|
|
1560
1604
|
isDisruptive,
|
|
@@ -1589,5 +1633,5 @@ export {
|
|
|
1589
1633
|
validateChange
|
|
1590
1634
|
};
|
|
1591
1635
|
|
|
1592
|
-
//# debugId=
|
|
1636
|
+
//# debugId=5DB87A31C35D88C064756E2164756E21
|
|
1593
1637
|
//# sourceMappingURL=index.js.map
|