@vkontakte/vkui-codemods 0.0.3 → 0.0.5
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/codemod-helpers.js +28 -7
- package/dist/getAvailableCodemods.js +14 -3
- package/dist/report.js +7 -1
- package/dist/testHelpers/testHelper.js +33 -0
- package/dist/transforms/action-sheet-item.js +1 -20
- package/dist/transforms/appearance-provider.js +2 -0
- package/dist/transforms/card-scroll.js +14 -0
- package/dist/transforms/chips-input.js +1 -1
- package/dist/transforms/config-provider.js +22 -2
- package/dist/transforms/content-card.js +2 -0
- package/dist/transforms/form-item.js +2 -0
- package/dist/transforms/form-layout.js +24 -0
- package/dist/transforms/gallery.js +14 -0
- package/dist/transforms/gradient-prop-change.js +2 -0
- package/dist/transforms/image-base.js +18 -0
- package/dist/transforms/modal-card.js +13 -3
- package/dist/transforms/modal-page-header.js +2 -2
- package/dist/transforms/panel-header.js +36 -0
- package/dist/transforms/placeholder.js +14 -0
- package/dist/transforms/popout-wrapper.js +23 -0
- package/dist/transforms/select.js +18 -0
- package/dist/transforms/tabbar.js +14 -0
- package/dist/transforms/tooltip-container.js +36 -0
- package/dist/transforms/tooltip.js +1 -0
- package/dist/transforms/typography.js +2 -0
- package/package.json +8 -7
package/dist/codemod-helpers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAttributeManipulator = exports.renameProp = exports.getImportInfo = void 0;
|
|
3
|
+
exports.createAttributeManipulator = exports.swapBooleanValue = exports.renameProp = exports.getImportInfo = void 0;
|
|
4
|
+
var report_1 = require("./report");
|
|
4
5
|
function getImportInfo(j, file, componentName, alias) {
|
|
5
6
|
var source = j(file.source);
|
|
6
7
|
var localImportName = componentName;
|
|
@@ -31,6 +32,31 @@ function renameProp(j, source, componentName, renameMap) {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
exports.renameProp = renameProp;
|
|
35
|
+
function swapBooleanValue(api, source, componentName, previousPropName, currentPropName) {
|
|
36
|
+
var j = api.jscodeshift;
|
|
37
|
+
source
|
|
38
|
+
.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === componentName; })
|
|
39
|
+
.find(j.JSXAttribute, function (attribute) { return attribute.name.name === previousPropName; })
|
|
40
|
+
.forEach(function (attribute) {
|
|
41
|
+
var node = attribute.node;
|
|
42
|
+
if (!node.value) {
|
|
43
|
+
j(attribute).remove();
|
|
44
|
+
}
|
|
45
|
+
else if (node.value.type === 'JSXExpressionContainer' &&
|
|
46
|
+
node.value.expression.type === 'BooleanLiteral') {
|
|
47
|
+
if (node.value.expression.value) {
|
|
48
|
+
j(attribute).remove();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier(currentPropName)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
(0, report_1.report)(api, "Manual changes required for ".concat(componentName, "'s ").concat(previousPropName, " prop."));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.swapBooleanValue = swapBooleanValue;
|
|
34
60
|
var createAttributeManipulator = function (props, api) {
|
|
35
61
|
var map = new Map(Object.entries(props));
|
|
36
62
|
return {
|
|
@@ -42,12 +68,7 @@ var createAttributeManipulator = function (props, api) {
|
|
|
42
68
|
var found = map.get(attributeKey);
|
|
43
69
|
if (found && found.reportText) {
|
|
44
70
|
var text = typeof found.reportText === 'function' ? found.reportText() : found.reportText;
|
|
45
|
-
|
|
46
|
-
api.report(text);
|
|
47
|
-
}
|
|
48
|
-
catch (_a) {
|
|
49
|
-
console.warn(text);
|
|
50
|
-
}
|
|
71
|
+
(0, report_1.report)(api, text);
|
|
51
72
|
}
|
|
52
73
|
return {
|
|
53
74
|
action: found && found.action,
|
|
@@ -7,12 +7,23 @@ exports.TRANSFORM_DIR = void 0;
|
|
|
7
7
|
var fs_1 = __importDefault(require("fs"));
|
|
8
8
|
exports.TRANSFORM_DIR = "".concat(__dirname, "/transforms");
|
|
9
9
|
var CODEMODS = [];
|
|
10
|
-
function
|
|
10
|
+
var swapElementsOfArray = function (a, b, array) {
|
|
11
|
+
if (a === -1 || b === -1) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var valueA = array[a];
|
|
15
|
+
var valueB = array[b];
|
|
16
|
+
array[b] = valueA;
|
|
17
|
+
array[a] = valueB;
|
|
18
|
+
};
|
|
19
|
+
function getAvailableCodemods(dirname) {
|
|
20
|
+
if (dirname === void 0) { dirname = exports.TRANSFORM_DIR; }
|
|
11
21
|
if (CODEMODS.length === 0) {
|
|
12
22
|
CODEMODS = fs_1.default
|
|
13
|
-
.readdirSync(
|
|
14
|
-
.filter(function (fname) { return fname.endsWith('.js'); })
|
|
23
|
+
.readdirSync(dirname)
|
|
24
|
+
.filter(function (fname) { return fname.endsWith('.js') || fname.endsWith('.ts'); })
|
|
15
25
|
.map(function (fname) { return fname.slice(0, -3); });
|
|
26
|
+
swapElementsOfArray(CODEMODS.findIndex(function (fname) { return fname === 'text-tooltip'; }), CODEMODS.findIndex(function (fname) { return fname === 'tooltip'; }), CODEMODS);
|
|
16
27
|
}
|
|
17
28
|
return CODEMODS;
|
|
18
29
|
}
|
package/dist/report.js
CHANGED
|
@@ -8,6 +8,12 @@ var chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
var package_json_1 = __importDefault(require("../package.json"));
|
|
9
9
|
function report(api, message) {
|
|
10
10
|
var report = api.report;
|
|
11
|
-
|
|
11
|
+
var finalMessage = "".concat(message, " Advise ").concat(chalk_1.default.white.bgBlue.bold('migration guide'), " - ").concat(package_json_1.default.homepage, "#/Migrations \n\n");
|
|
12
|
+
try {
|
|
13
|
+
report(finalMessage);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.warn(finalMessage);
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
exports.report = report;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defineSnapshotTestFromFixture = exports.getTestFixturesInputPath = exports.applyTransform = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Adopted version of https://github.com/facebook/jscodeshift/blob/v0.15.0/src/testUtils.js
|
|
9
|
+
* TODO [jscodeshift@>0.13.0]: Remove it
|
|
10
|
+
* More info - PR #6254
|
|
11
|
+
*/
|
|
12
|
+
var fs_1 = __importDefault(require("fs"));
|
|
13
|
+
var path_1 = __importDefault(require("path"));
|
|
14
|
+
var testUtils_1 = require("jscodeshift/dist/testUtils");
|
|
15
|
+
Object.defineProperty(exports, "applyTransform", { enumerable: true, get: function () { return testUtils_1.applyTransform; } });
|
|
16
|
+
function getTestFixturesInputPath(dirName, testFilePrefix, extension) {
|
|
17
|
+
if (extension === void 0) { extension = 'tsx'; }
|
|
18
|
+
var fixtureDir = path_1.default.join(dirName, '..', '__testfixtures__');
|
|
19
|
+
return path_1.default.join(fixtureDir, testFilePrefix + ".input.".concat(extension));
|
|
20
|
+
}
|
|
21
|
+
exports.getTestFixturesInputPath = getTestFixturesInputPath;
|
|
22
|
+
/**
|
|
23
|
+
* Handles file-loading boilerplates, using same defaults as defineTest
|
|
24
|
+
*/
|
|
25
|
+
function defineSnapshotTestFromFixture(dirName, transformName, options, testFilePrefix, extension) {
|
|
26
|
+
if (extension === void 0) { extension = 'tsx'; }
|
|
27
|
+
// Assumes transform is one level up from __tests__ directory
|
|
28
|
+
var module = require(path_1.default.join(dirName, '..', transformName));
|
|
29
|
+
var inputPath = getTestFixturesInputPath(dirName, testFilePrefix, extension);
|
|
30
|
+
var source = fs_1.default.readFileSync(inputPath, 'utf8');
|
|
31
|
+
(0, testUtils_1.defineSnapshotTest)(module, options, source, 'transforms correctly');
|
|
32
|
+
}
|
|
33
|
+
exports.defineSnapshotTestFromFixture = defineSnapshotTestFromFixture;
|
|
@@ -8,26 +8,7 @@ function transformer(file, api, options) {
|
|
|
8
8
|
var j = api.jscodeshift;
|
|
9
9
|
var source = j(file.source);
|
|
10
10
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ActionSheetItem', alias).localName;
|
|
11
|
-
source
|
|
12
|
-
.find(j.JSXOpeningElement)
|
|
13
|
-
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
14
|
-
.find(j.JSXAttribute)
|
|
15
|
-
.filter(function (attribute) { return attribute.node.name.name === 'autoClose'; })
|
|
16
|
-
.forEach(function (attribute) {
|
|
17
|
-
var node = attribute.node;
|
|
18
|
-
if (!node.value) {
|
|
19
|
-
j(attribute).remove();
|
|
20
|
-
}
|
|
21
|
-
else if (node.value.type === 'JSXExpressionContainer' &&
|
|
22
|
-
node.value.expression.type === 'BooleanLiteral') {
|
|
23
|
-
if (node.value.expression.value) {
|
|
24
|
-
j(attribute).remove();
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier('autoCloseDisabled')));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
11
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'autoClose', 'autoCloseDisabled');
|
|
31
12
|
return source.toSource();
|
|
32
13
|
}
|
|
33
14
|
exports.default = transformer;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
3
4
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
4
6
|
function transformer(file, api, options) {
|
|
5
7
|
var alias = options.alias;
|
|
6
8
|
var j = api.jscodeshift;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CardScroll', alias).localName;
|
|
11
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'withSpaces', 'noSpaces');
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
14
|
+
exports.default = transformer;
|
|
@@ -4,7 +4,7 @@ exports.parser = void 0;
|
|
|
4
4
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
5
|
exports.parser = 'tsx';
|
|
6
6
|
var RENAME_MAP = {
|
|
7
|
-
inputAriaLabel: '
|
|
7
|
+
inputAriaLabel: 'placeholder',
|
|
8
8
|
};
|
|
9
9
|
function transformer(file, api, options) {
|
|
10
10
|
var alias = options.alias;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parser = void 0;
|
|
4
4
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
var ALLOWED_PLATFORM_LIST = ['android', 'ios', 'vkcom'];
|
|
6
|
+
var wrapUnknownPlatformToVKUITokensClassName = function (unknownPlatform, appearance) { return "vkui--".concat(unknownPlatform, "--").concat(appearance); };
|
|
5
7
|
exports.parser = 'tsx';
|
|
6
8
|
function transformer(file, api, options) {
|
|
7
9
|
var alias = options.alias;
|
|
@@ -9,10 +11,11 @@ function transformer(file, api, options) {
|
|
|
9
11
|
var source = j(file.source);
|
|
10
12
|
var changed = false;
|
|
11
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ConfigProvider', alias).localName;
|
|
12
|
-
source
|
|
14
|
+
var attributes = source
|
|
13
15
|
.find(j.JSXOpeningElement)
|
|
14
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
15
|
-
.find(j.JSXAttribute)
|
|
17
|
+
.find(j.JSXAttribute);
|
|
18
|
+
attributes
|
|
16
19
|
.filter(function (attribute) { return attribute.node.name.name === 'webviewType'; })
|
|
17
20
|
.forEach(function (attribute) {
|
|
18
21
|
var node = attribute.node.value;
|
|
@@ -55,6 +58,23 @@ function transformer(file, api, options) {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
});
|
|
61
|
+
attributes
|
|
62
|
+
.filter(function (attribute) { return attribute.node.name.name === 'platform'; })
|
|
63
|
+
.forEach(function (attribute) {
|
|
64
|
+
var node = attribute.node.value;
|
|
65
|
+
if (!node) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if ((node.type === 'Literal' || node.type === 'StringLiteral') &&
|
|
69
|
+
typeof node.value === 'string') {
|
|
70
|
+
if (!ALLOWED_PLATFORM_LIST.includes(node.value)) {
|
|
71
|
+
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier('tokensClassNames'), j.jsxExpressionContainer(j.objectExpression([
|
|
72
|
+
j.objectProperty(j.jsxIdentifier('light'), j.stringLiteral(wrapUnknownPlatformToVKUITokensClassName(node.value, 'light'))),
|
|
73
|
+
j.objectProperty(j.jsxIdentifier('dark'), j.stringLiteral(wrapUnknownPlatformToVKUITokensClassName(node.value, 'dark'))),
|
|
74
|
+
]))));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
58
78
|
if (changed) {
|
|
59
79
|
source
|
|
60
80
|
.find(j.ImportDeclaration)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
3
4
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
4
6
|
function transformer(file, api, options) {
|
|
5
7
|
var alias = options.alias;
|
|
6
8
|
var j = api.jscodeshift;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
3
4
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
4
6
|
function transformer(file, api, options) {
|
|
5
7
|
var alias = options.alias;
|
|
6
8
|
var j = api.jscodeshift;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parser = void 0;
|
|
7
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
9
|
+
var report_1 = require("../report");
|
|
10
|
+
exports.parser = 'tsx';
|
|
11
|
+
function transformer(file, api, options) {
|
|
12
|
+
var alias = options.alias;
|
|
13
|
+
var j = api.jscodeshift;
|
|
14
|
+
var source = j(file.source);
|
|
15
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'FormLayout', alias).localName;
|
|
16
|
+
var components = source
|
|
17
|
+
.find(j.JSXOpeningElement)
|
|
18
|
+
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; });
|
|
19
|
+
if (components.size() > 0) {
|
|
20
|
+
(0, report_1.report)(api, ": ".concat(chalk_1.default.white.bgBlue('FormLayout'), " component does not exist anymore. Use native form."));
|
|
21
|
+
}
|
|
22
|
+
return source.toSource();
|
|
23
|
+
}
|
|
24
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Gallery', alias).localName;
|
|
11
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'isDraggable', 'dragDisabled');
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
14
|
+
exports.default = transformer;
|
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parser = void 0;
|
|
6
7
|
var chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
8
9
|
var report_1 = require("../report");
|
|
10
|
+
exports.parser = 'tsx';
|
|
9
11
|
function transformer(file, api, options) {
|
|
10
12
|
var alias = options.alias;
|
|
11
13
|
var j = api.jscodeshift;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var imageBaseLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ImageBase', alias).localName;
|
|
11
|
+
var imageLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Image', alias).localName;
|
|
12
|
+
var avatarLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Avatar', alias).localName;
|
|
13
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, imageBaseLocalName, 'withBorder', 'noBorder');
|
|
14
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, imageLocalName, 'withBorder', 'noBorder');
|
|
15
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, avatarLocalName, 'withBorder', 'noBorder');
|
|
16
|
+
return source.toSource();
|
|
17
|
+
}
|
|
18
|
+
exports.default = transformer;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parser = void 0;
|
|
7
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
3
8
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
9
|
+
var report_1 = require("../report");
|
|
10
|
+
exports.parser = 'tsx';
|
|
4
11
|
function transformer(file, api, options) {
|
|
5
12
|
var alias = options.alias;
|
|
6
13
|
var j = api.jscodeshift;
|
|
7
14
|
var source = j(file.source);
|
|
8
15
|
var localNameModalCard = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCard', alias).localName;
|
|
9
16
|
var localNameModalCardBase = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCardBase', alias).localName;
|
|
10
|
-
source
|
|
17
|
+
var modalCards = source
|
|
11
18
|
.find(j.JSXOpeningElement)
|
|
12
19
|
.filter(function (path) {
|
|
13
20
|
return path.value.name.type === 'JSXIdentifier' &&
|
|
14
21
|
[localNameModalCard, localNameModalCardBase].includes(path.value.name.name);
|
|
15
|
-
})
|
|
16
|
-
|
|
22
|
+
});
|
|
23
|
+
modalCards.forEach(function (path) {
|
|
17
24
|
var headerAttribute = j(path).find(j.JSXAttribute, { name: { name: 'header' } });
|
|
18
25
|
var subheaderAttribute = j(path).find(j.JSXAttribute, { name: { name: 'subheader' } });
|
|
19
26
|
if (subheaderAttribute.length > 0) {
|
|
@@ -27,6 +34,9 @@ function transformer(file, api, options) {
|
|
|
27
34
|
}
|
|
28
35
|
}
|
|
29
36
|
});
|
|
37
|
+
if (modalCards.size() > 0) {
|
|
38
|
+
(0, report_1.report)(api, ": ".concat(chalk_1.default.white.bgBlue('ModalCard'), " and ").concat(chalk_1.default.white.bgBlue('ModalCardBase'), " might need 'Spacing' now. Manual changes required."));
|
|
39
|
+
}
|
|
30
40
|
return source.toSource();
|
|
31
41
|
}
|
|
32
42
|
exports.default = transformer;
|
|
@@ -9,8 +9,7 @@ function transformer(file, api, options) {
|
|
|
9
9
|
var source = j(file.source);
|
|
10
10
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalPageHeader', alias).localName;
|
|
11
11
|
source
|
|
12
|
-
.find(j.JSXOpeningElement)
|
|
13
|
-
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
12
|
+
.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; })
|
|
14
13
|
.forEach(function (element) {
|
|
15
14
|
var attributes = element.value.attributes;
|
|
16
15
|
if (attributes) {
|
|
@@ -27,6 +26,7 @@ function transformer(file, api, options) {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
});
|
|
29
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'separator', 'noSeparator');
|
|
30
30
|
return source.toSource();
|
|
31
31
|
}
|
|
32
32
|
exports.default = transformer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
var report_1 = require("../report");
|
|
6
|
+
exports.parser = 'tsx';
|
|
7
|
+
function transformer(file, api, options) {
|
|
8
|
+
var alias = options.alias;
|
|
9
|
+
var j = api.jscodeshift;
|
|
10
|
+
var source = j(file.source);
|
|
11
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PanelHeader', alias).localName;
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'visor', 'float');
|
|
13
|
+
source
|
|
14
|
+
.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; })
|
|
15
|
+
.find(j.JSXAttribute, function (attribute) { return attribute.name.name === 'separator'; })
|
|
16
|
+
.forEach(function (attribute) {
|
|
17
|
+
var node = attribute.node;
|
|
18
|
+
if (!node.value) {
|
|
19
|
+
j(attribute).remove();
|
|
20
|
+
}
|
|
21
|
+
else if (node.value.type === 'JSXExpressionContainer' &&
|
|
22
|
+
node.value.expression.type === 'BooleanLiteral') {
|
|
23
|
+
if (node.value.expression.value) {
|
|
24
|
+
j(attribute).remove();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
j(attribute).replaceWith(j.jsxAttribute(j.jsxIdentifier('delimiter'), j.stringLiteral('none')));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
(0, report_1.report)(api, "Manual changes required for PanelHeader's separator prop.");
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return source.toSource();
|
|
35
|
+
}
|
|
36
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Placeholder', alias).localName;
|
|
11
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'withPadding', 'noPadding');
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
14
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parser = void 0;
|
|
7
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
9
|
+
var report_1 = require("../report");
|
|
10
|
+
exports.parser = 'tsx';
|
|
11
|
+
function transformer(file, api, options) {
|
|
12
|
+
var alias = options.alias;
|
|
13
|
+
var j = api.jscodeshift;
|
|
14
|
+
var source = j(file.source);
|
|
15
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PopoutWrapper', alias).localName;
|
|
16
|
+
var components = source.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; });
|
|
17
|
+
if (components.size() > 0) {
|
|
18
|
+
(0, report_1.report)(api, ": When using ".concat(chalk_1.default.white.bgBlue('PopoutWrapper'), " you might need to apply useScrollLock() hook manually."));
|
|
19
|
+
}
|
|
20
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'hasMask', 'noBackground');
|
|
21
|
+
return source.toSource();
|
|
22
|
+
}
|
|
23
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var selectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Select', alias).localName;
|
|
11
|
+
var customSelectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomSelect', alias).localName;
|
|
12
|
+
var chipsSelectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias).localName;
|
|
13
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, selectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
14
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, customSelectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
15
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, chipsSelectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
16
|
+
return source.toSource();
|
|
17
|
+
}
|
|
18
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
function transformer(file, api, options) {
|
|
7
|
+
var alias = options.alias;
|
|
8
|
+
var j = api.jscodeshift;
|
|
9
|
+
var source = j(file.source);
|
|
10
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Tabbar', alias).localName;
|
|
11
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'shadow', 'plain');
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
14
|
+
exports.default = transformer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parser = void 0;
|
|
4
|
+
var codemod_helpers_1 = require("../codemod-helpers");
|
|
5
|
+
exports.parser = 'tsx';
|
|
6
|
+
var componentName = 'TooltipContainer';
|
|
7
|
+
var componentNameTo = 'OnboardingTooltipContainer';
|
|
8
|
+
function transformer(file, api, options) {
|
|
9
|
+
var alias = options.alias;
|
|
10
|
+
var j = api.jscodeshift;
|
|
11
|
+
var source = j(file.source);
|
|
12
|
+
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
|
|
13
|
+
var needRename = true;
|
|
14
|
+
// подменяем импорт
|
|
15
|
+
source
|
|
16
|
+
.find(j.ImportDeclaration)
|
|
17
|
+
.filter(function (path) { return path.node.source.value === alias; })
|
|
18
|
+
.find(j.ImportSpecifier, { imported: { name: componentName } })
|
|
19
|
+
.forEach(function (path) {
|
|
20
|
+
j(path).replaceWith(function (path) {
|
|
21
|
+
if (path.node.local && path.node.local.name !== path.node.imported.name) {
|
|
22
|
+
needRename = false;
|
|
23
|
+
}
|
|
24
|
+
return j.importSpecifier(j.jsxIdentifier(componentNameTo), needRename ? null : path.node.local);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
source.findJSXElements(localName).forEach(function (element) {
|
|
28
|
+
// меняем название компонента в JSX на переименованный в импорте (если нужно)
|
|
29
|
+
j(element).replaceWith(function (path) {
|
|
30
|
+
var renamedLocalName = needRename ? componentNameTo : localName;
|
|
31
|
+
return j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(renamedLocalName), path.node.openingElement.attributes, path.node.closingElement ? false : true), path.node.closingElement ? j.jsxClosingElement(j.jsxIdentifier(renamedLocalName)) : null, path.node.children);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return source.toSource();
|
|
35
|
+
}
|
|
36
|
+
exports.default = transformer;
|
|
@@ -57,6 +57,7 @@ function transformer(file, api, options) {
|
|
|
57
57
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
|
|
58
58
|
var attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_REPLACER, api);
|
|
59
59
|
var needRename = true;
|
|
60
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'arrow', 'disableArrow');
|
|
60
61
|
// подменяем импорт
|
|
61
62
|
source
|
|
62
63
|
.find(j.ImportDeclaration)
|
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parser = void 0;
|
|
6
7
|
var chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
var codemod_helpers_1 = require("../codemod-helpers");
|
|
8
9
|
var report_1 = require("../report");
|
|
10
|
+
exports.parser = 'tsx';
|
|
9
11
|
function transformer(file, api, options) {
|
|
10
12
|
var alias = options.alias;
|
|
11
13
|
var j = api.jscodeshift;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/vkui-codemods",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Codemods for automatic VKUI major version upgrade",
|
|
5
5
|
"repository": "https://github.com/VKCOM/VKUI",
|
|
6
6
|
"homepage": "https://vkcom.github.io/VKUI/",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"cross-spawn": "^7.0.3",
|
|
20
20
|
"jscodeshift": "^0.13.1",
|
|
21
21
|
"prompts": "^2.4.2",
|
|
22
|
-
"typescript": "^5.3.
|
|
22
|
+
"typescript": "^5.3.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@swc/core": "^1.3.
|
|
26
|
-
"@swc/jest": "^0.2.
|
|
25
|
+
"@swc/core": "^1.3.105",
|
|
26
|
+
"@swc/jest": "^0.2.31",
|
|
27
27
|
"@types/cross-spawn": "^6.0.6",
|
|
28
|
-
"@types/jest": "^29.5.
|
|
28
|
+
"@types/jest": "^29.5.11",
|
|
29
29
|
"@types/jscodeshift": "^0.11.11",
|
|
30
|
-
"@types/node": "^20.10
|
|
30
|
+
"@types/node": "^20.11.10",
|
|
31
31
|
"@types/prompts": "^2.4.2",
|
|
32
32
|
"jest": "^29.7.0",
|
|
33
|
-
"ts-node": "^10.9.
|
|
33
|
+
"ts-node": "^10.9.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsc",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"migrate": "jscodeshift"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
|
+
"provenance": true,
|
|
42
43
|
"access": "public"
|
|
43
44
|
}
|
|
44
45
|
}
|