vuetify-codemods 1.0.1 → 1.0.3
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/dist/main.js +97 -0
- package/package.json +3 -2
package/dist/main.js
CHANGED
|
@@ -96010,6 +96010,101 @@ const v4ElevationPlugin = {
|
|
|
96010
96010
|
return count;
|
|
96011
96011
|
}
|
|
96012
96012
|
};
|
|
96013
|
+
const v4FormSlotRefsPlugin = {
|
|
96014
|
+
type: "codemod",
|
|
96015
|
+
name: "vuetify-4-form-slot-refs",
|
|
96016
|
+
transform({ sfcAST }) {
|
|
96017
|
+
if (!sfcAST) return 0;
|
|
96018
|
+
let count = 0;
|
|
96019
|
+
const slotNodes = findSlotNodes(sfcAST, ["VForm"], ["default"]);
|
|
96020
|
+
for (const node2 of slotNodes) {
|
|
96021
|
+
const refs = findSlotPropReferences(
|
|
96022
|
+
node2,
|
|
96023
|
+
["errors", "isDisabled", "isReadonly", "isValidating", "isValid", "items"]
|
|
96024
|
+
);
|
|
96025
|
+
for (const ref of refs) {
|
|
96026
|
+
count += removeDotMember(ref.reference, "value");
|
|
96027
|
+
}
|
|
96028
|
+
}
|
|
96029
|
+
return count;
|
|
96030
|
+
}
|
|
96031
|
+
};
|
|
96032
|
+
const breakpoints = ["sm", "md", "lg", "xl", "xxl"];
|
|
96033
|
+
const v4GridPlugin = {
|
|
96034
|
+
type: "codemod",
|
|
96035
|
+
name: "vuetify-4-grid",
|
|
96036
|
+
transform({ sfcAST, utils: utils2 }) {
|
|
96037
|
+
if (!sfcAST) return 0;
|
|
96038
|
+
let count = 0;
|
|
96039
|
+
const { builders: builders2 } = utils2;
|
|
96040
|
+
const elements = ast_helpers_exports.findAll(sfcAST, { type: "VElement" });
|
|
96041
|
+
for (const el of elements) {
|
|
96042
|
+
const tag = el.rawName;
|
|
96043
|
+
if (classify(tag) === "VRow") {
|
|
96044
|
+
const denseAttr = getStaticAttr(el, "dense");
|
|
96045
|
+
if (denseAttr) {
|
|
96046
|
+
const idx = el.startTag.attributes.indexOf(denseAttr);
|
|
96047
|
+
el.startTag.attributes.splice(
|
|
96048
|
+
idx,
|
|
96049
|
+
1,
|
|
96050
|
+
builders2.vAttribute(
|
|
96051
|
+
builders2.vIdentifier("density"),
|
|
96052
|
+
builders2.vLiteral("compact")
|
|
96053
|
+
)
|
|
96054
|
+
);
|
|
96055
|
+
count++;
|
|
96056
|
+
}
|
|
96057
|
+
for (const prop of ["align", "justify", "align-content"]) {
|
|
96058
|
+
if (propToClass(el, prop, prop, builders2)) count++;
|
|
96059
|
+
for (const bp of breakpoints) {
|
|
96060
|
+
if (propToClass(el, `${prop}-${bp}`, `${prop}-${bp}`, builders2)) count++;
|
|
96061
|
+
}
|
|
96062
|
+
}
|
|
96063
|
+
}
|
|
96064
|
+
if (classify(tag) === "VCol") {
|
|
96065
|
+
if (propToClass(el, "order", "order", builders2)) count++;
|
|
96066
|
+
for (const bp of breakpoints) {
|
|
96067
|
+
if (propToClass(el, `order-${bp}`, `order-${bp}`, builders2)) count++;
|
|
96068
|
+
}
|
|
96069
|
+
if (propToClass(el, "align-self", "align-self", builders2)) count++;
|
|
96070
|
+
}
|
|
96071
|
+
}
|
|
96072
|
+
return count;
|
|
96073
|
+
}
|
|
96074
|
+
};
|
|
96075
|
+
function getStaticAttr(el, name) {
|
|
96076
|
+
return el.startTag.attributes.find(
|
|
96077
|
+
(a3) => !a3.directive && a3.key.name === name
|
|
96078
|
+
);
|
|
96079
|
+
}
|
|
96080
|
+
function removeAttr(el, name) {
|
|
96081
|
+
const idx = el.startTag.attributes.findIndex(
|
|
96082
|
+
(a3) => !a3.directive && a3.key.name === name
|
|
96083
|
+
);
|
|
96084
|
+
if (~idx) el.startTag.attributes.splice(idx, 1);
|
|
96085
|
+
}
|
|
96086
|
+
function appendStaticClass(el, cls, builders2) {
|
|
96087
|
+
const attr = getStaticAttr(el, "class");
|
|
96088
|
+
if (attr?.value) {
|
|
96089
|
+
if (attr.value.type === "VLiteral") {
|
|
96090
|
+
attr.value.value = attr.value.value ? `${attr.value.value} ${cls}` : cls;
|
|
96091
|
+
}
|
|
96092
|
+
} else {
|
|
96093
|
+
el.startTag.attributes.unshift(
|
|
96094
|
+
builders2.vAttribute(
|
|
96095
|
+
builders2.vIdentifier("class"),
|
|
96096
|
+
builders2.vLiteral(cls)
|
|
96097
|
+
)
|
|
96098
|
+
);
|
|
96099
|
+
}
|
|
96100
|
+
}
|
|
96101
|
+
function propToClass(el, propName, classPrefix, builders2) {
|
|
96102
|
+
const attr = getStaticAttr(el, propName);
|
|
96103
|
+
if (attr?.value?.type !== "VLiteral" || !attr.value.value) return false;
|
|
96104
|
+
appendStaticClass(el, `${classPrefix}-${attr.value.value}`, builders2);
|
|
96105
|
+
removeAttr(el, propName);
|
|
96106
|
+
return true;
|
|
96107
|
+
}
|
|
96013
96108
|
const v4SnackbarMultilinePlugin = {
|
|
96014
96109
|
type: "codemod",
|
|
96015
96110
|
name: "vuetify-4-snackbar-multiline",
|
|
@@ -96101,6 +96196,8 @@ function vuetify4() {
|
|
|
96101
96196
|
return [
|
|
96102
96197
|
v4ComboboxItemSlotPlugin,
|
|
96103
96198
|
v4ElevationPlugin,
|
|
96199
|
+
v4FormSlotRefsPlugin,
|
|
96200
|
+
v4GridPlugin,
|
|
96104
96201
|
v4SnackbarMultilinePlugin,
|
|
96105
96202
|
v4SnackbarQueueSlotPlugin,
|
|
96106
96203
|
v4TypographyPlugin
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuetify-codemods",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"bin": {
|
|
6
6
|
"vuetify-codemods": "dist/main.js"
|
|
7
7
|
},
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@inquirer/prompts": "^8.3.0",
|
|
24
|
+
"ast-types-x": "^1.18.0",
|
|
24
25
|
"esprima": "^4.0.1",
|
|
25
26
|
"lodash-es": "^4.17.23",
|
|
26
27
|
"vue-eslint-parser": "^10.4.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/node": "^24.10.13",
|
|
30
|
-
"
|
|
31
|
+
"@vuetify/github-releaser": "^4.0.3",
|
|
31
32
|
"conventional-changelog-cli": "^5.0.0",
|
|
32
33
|
"conventional-changelog-vuetify": "^2.0.2",
|
|
33
34
|
"eslint": "^9.39.2",
|