@vkontakte/vkui-codemods 0.0.4 → 0.0.6
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 +6 -7
- package/dist/getAvailableCodemods.js +14 -3
- package/dist/index.js +0 -0
- package/dist/report.js +1 -1
- package/dist/testHelpers/testHelper.js +9 -4
- package/dist/transforms/accordion.js +3 -0
- package/dist/transforms/action-sheet-item.js +3 -1
- package/dist/transforms/action-sheet.js +3 -0
- package/dist/transforms/alert.js +3 -0
- package/dist/transforms/appearance-provider.js +3 -0
- package/dist/transforms/banner.js +3 -0
- package/dist/transforms/calendar-range.js +3 -1
- package/dist/transforms/calendar.js +3 -1
- package/dist/transforms/card-scroll.js +3 -1
- package/dist/transforms/chip.js +3 -1
- package/dist/transforms/chips-input.js +3 -1
- package/dist/transforms/config-provider.js +3 -0
- package/dist/transforms/content-card.js +3 -0
- package/dist/transforms/custom-scroll-view.js +3 -0
- package/dist/transforms/date-input.js +3 -1
- package/dist/transforms/date-range-input.js +3 -1
- package/dist/transforms/fixed-layout.js +3 -0
- package/dist/transforms/form-item.js +3 -0
- package/dist/transforms/form-layout.js +3 -0
- package/dist/transforms/gallery.js +3 -1
- package/dist/transforms/gradient-prop-change.js +3 -0
- package/dist/transforms/image-base.js +9 -3
- package/dist/transforms/modal-card.js +8 -1
- package/dist/transforms/modal-page-header.js +3 -0
- package/dist/transforms/pagination.js +3 -0
- package/dist/transforms/panel-header-content.js +3 -0
- package/dist/transforms/panel-header.js +3 -0
- package/dist/transforms/placeholder.js +3 -1
- package/dist/transforms/popout-wrapper.js +3 -0
- package/dist/transforms/popover.js +3 -0
- package/dist/transforms/popper.js +3 -0
- package/dist/transforms/range-slider.js +3 -0
- package/dist/transforms/rich-tooltip.js +3 -0
- package/dist/transforms/search.js +3 -1
- package/dist/transforms/select.js +9 -3
- package/dist/transforms/simple-cell.js +3 -0
- package/dist/transforms/split-col.js +3 -0
- package/dist/transforms/tabbar.js +3 -1
- package/dist/transforms/tappable.js +3 -0
- package/dist/transforms/text-tooltip.js +3 -0
- package/dist/transforms/tooltip-container.js +39 -0
- package/dist/transforms/tooltip.js +4 -0
- package/dist/transforms/users-stack.js +3 -0
- package/dist/transforms/visually-hidden-input.js +3 -0
- package/package.json +10 -9
package/dist/codemod-helpers.js
CHANGED
|
@@ -4,13 +4,12 @@ exports.createAttributeManipulator = exports.swapBooleanValue = exports.renamePr
|
|
|
4
4
|
var report_1 = require("./report");
|
|
5
5
|
function getImportInfo(j, file, componentName, alias) {
|
|
6
6
|
var source = j(file.source);
|
|
7
|
-
var localImportName =
|
|
8
|
-
|
|
9
|
-
.find(j.ImportDeclaration)
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
if (path.node.local && path.node.local.name !== path.node.imported.name) {
|
|
7
|
+
var localImportName = null;
|
|
8
|
+
source
|
|
9
|
+
.find(j.ImportDeclaration, { source: { value: alias } })
|
|
10
|
+
.find(j.ImportSpecifier, { imported: { name: componentName } })
|
|
11
|
+
.forEach(function (path) {
|
|
12
|
+
if (path.node.local) {
|
|
14
13
|
localImportName = path.node.local.name;
|
|
15
14
|
}
|
|
16
15
|
});
|
|
@@ -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/index.js
CHANGED
|
File without changes
|
package/dist/report.js
CHANGED
|
@@ -8,7 +8,7 @@ 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
|
-
var finalMessage = "".concat(message, " Advise ").concat(chalk_1.default.white.bgBlue.bold('migration guide'), " - ").concat(package_json_1.default.homepage, "#/
|
|
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
12
|
try {
|
|
13
13
|
report(finalMessage);
|
|
14
14
|
}
|
|
@@ -3,7 +3,7 @@ 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.defineSnapshotTestFromFixture = void 0;
|
|
6
|
+
exports.defineSnapshotTestFromFixture = exports.getTestFixturesInputPath = exports.applyTransform = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Adopted version of https://github.com/facebook/jscodeshift/blob/v0.15.0/src/testUtils.js
|
|
9
9
|
* TODO [jscodeshift@>0.13.0]: Remove it
|
|
@@ -11,8 +11,14 @@ exports.defineSnapshotTestFromFixture = void 0;
|
|
|
11
11
|
*/
|
|
12
12
|
var fs_1 = __importDefault(require("fs"));
|
|
13
13
|
var path_1 = __importDefault(require("path"));
|
|
14
|
-
// @ts-expect-error: TS7016 no types for package
|
|
15
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;
|
|
16
22
|
/**
|
|
17
23
|
* Handles file-loading boilerplates, using same defaults as defineTest
|
|
18
24
|
*/
|
|
@@ -20,8 +26,7 @@ function defineSnapshotTestFromFixture(dirName, transformName, options, testFile
|
|
|
20
26
|
if (extension === void 0) { extension = 'tsx'; }
|
|
21
27
|
// Assumes transform is one level up from __tests__ directory
|
|
22
28
|
var module = require(path_1.default.join(dirName, '..', transformName));
|
|
23
|
-
var
|
|
24
|
-
var inputPath = path_1.default.join(fixtureDir, testFilePrefix + ".input.".concat(extension));
|
|
29
|
+
var inputPath = getTestFixturesInputPath(dirName, testFilePrefix, extension);
|
|
25
30
|
var source = fs_1.default.readFileSync(inputPath, 'utf8');
|
|
26
31
|
(0, testUtils_1.defineSnapshotTest)(module, options, source, 'transforms correctly');
|
|
27
32
|
}
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Accordion', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
(0, codemod_helpers_1.renameProp)(j, source, localName, { open: 'expanded' });
|
|
17
20
|
var accordionComponents = source
|
|
18
21
|
.find(j.JSXOpeningElement)
|
|
@@ -8,7 +8,9 @@ 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
|
-
|
|
11
|
+
if (localName) {
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'autoClose', 'autoCloseDisabled');
|
|
13
|
+
}
|
|
12
14
|
return source.toSource();
|
|
13
15
|
}
|
|
14
16
|
exports.default = transformer;
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ActionSheet', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
var openingTargetElements = source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; });
|
package/dist/transforms/alert.js
CHANGED
|
@@ -26,6 +26,9 @@ function transformer(file, api, options) {
|
|
|
26
26
|
var j = api.jscodeshift;
|
|
27
27
|
var source = j(file.source);
|
|
28
28
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Alert', alias).localName;
|
|
29
|
+
if (!localName) {
|
|
30
|
+
return source.toSource();
|
|
31
|
+
}
|
|
29
32
|
source
|
|
30
33
|
.find(j.JSXOpeningElement)
|
|
31
34
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -8,6 +8,9 @@ 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, 'AppearanceProvider', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement)
|
|
13
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -11,6 +11,9 @@ function transformer(file, api, options) {
|
|
|
11
11
|
var j = api.jscodeshift;
|
|
12
12
|
var source = j(file.source);
|
|
13
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Banner', alias).localName;
|
|
14
|
+
if (!localName) {
|
|
15
|
+
return source.toSource();
|
|
16
|
+
}
|
|
14
17
|
var bannerComponent = source
|
|
15
18
|
.find(j.JSXOpeningElement)
|
|
16
19
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; });
|
|
@@ -15,7 +15,9 @@ function transformer(file, api, options) {
|
|
|
15
15
|
var j = api.jscodeshift;
|
|
16
16
|
var source = j(file.source);
|
|
17
17
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CalendarRange', alias).localName;
|
|
18
|
-
|
|
18
|
+
if (localName) {
|
|
19
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
20
|
+
}
|
|
19
21
|
return source.toSource();
|
|
20
22
|
}
|
|
21
23
|
exports.default = transformer;
|
|
@@ -17,7 +17,9 @@ function transformer(file, api, options) {
|
|
|
17
17
|
var j = api.jscodeshift;
|
|
18
18
|
var source = j(file.source);
|
|
19
19
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Calendar', alias).localName;
|
|
20
|
-
|
|
20
|
+
if (localName) {
|
|
21
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
22
|
+
}
|
|
21
23
|
return source.toSource();
|
|
22
24
|
}
|
|
23
25
|
exports.default = transformer;
|
|
@@ -8,7 +8,9 @@ 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, 'CardScroll', alias).localName;
|
|
11
|
-
|
|
11
|
+
if (localName) {
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'withSpaces', 'noSpaces');
|
|
13
|
+
}
|
|
12
14
|
return source.toSource();
|
|
13
15
|
}
|
|
14
16
|
exports.default = transformer;
|
package/dist/transforms/chip.js
CHANGED
|
@@ -11,7 +11,9 @@ function transformer(file, api, options) {
|
|
|
11
11
|
var j = api.jscodeshift;
|
|
12
12
|
var source = j(file.source);
|
|
13
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Chip', alias).localName;
|
|
14
|
-
|
|
14
|
+
if (localName) {
|
|
15
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
16
|
+
}
|
|
15
17
|
return source.toSource();
|
|
16
18
|
}
|
|
17
19
|
exports.default = transformer;
|
|
@@ -11,7 +11,9 @@ function transformer(file, api, options) {
|
|
|
11
11
|
var j = api.jscodeshift;
|
|
12
12
|
var source = j(file.source);
|
|
13
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsInput', alias).localName;
|
|
14
|
-
|
|
14
|
+
if (localName) {
|
|
15
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
16
|
+
}
|
|
15
17
|
return source.toSource();
|
|
16
18
|
}
|
|
17
19
|
exports.default = transformer;
|
|
@@ -11,6 +11,9 @@ function transformer(file, api, options) {
|
|
|
11
11
|
var source = j(file.source);
|
|
12
12
|
var changed = false;
|
|
13
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ConfigProvider', alias).localName;
|
|
14
|
+
if (!localName) {
|
|
15
|
+
return source.toSource();
|
|
16
|
+
}
|
|
14
17
|
var attributes = source
|
|
15
18
|
.find(j.JSXOpeningElement)
|
|
16
19
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -8,6 +8,9 @@ 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, 'ContentCard', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement)
|
|
13
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -11,6 +11,9 @@ function transformer(file, api, options) {
|
|
|
11
11
|
var j = api.jscodeshift;
|
|
12
12
|
var source = j(file.source);
|
|
13
13
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomScrollView', alias).localName;
|
|
14
|
+
if (!localName) {
|
|
15
|
+
return source.toSource();
|
|
16
|
+
}
|
|
14
17
|
var unusedProps = source
|
|
15
18
|
.find(j.JSXOpeningElement)
|
|
16
19
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -19,7 +19,9 @@ function transformer(file, api, options) {
|
|
|
19
19
|
var j = api.jscodeshift;
|
|
20
20
|
var source = j(file.source);
|
|
21
21
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'DateInput', alias).localName;
|
|
22
|
-
|
|
22
|
+
if (localName) {
|
|
23
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
24
|
+
}
|
|
23
25
|
return source.toSource();
|
|
24
26
|
}
|
|
25
27
|
exports.default = transformer;
|
|
@@ -23,7 +23,9 @@ function transformer(file, api, options) {
|
|
|
23
23
|
var j = api.jscodeshift;
|
|
24
24
|
var source = j(file.source);
|
|
25
25
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'DateRangeInput', alias).localName;
|
|
26
|
-
|
|
26
|
+
if (localName) {
|
|
27
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
28
|
+
}
|
|
27
29
|
return source.toSource();
|
|
28
30
|
}
|
|
29
31
|
exports.default = transformer;
|
|
@@ -8,6 +8,9 @@ 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, 'FixedLayout', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement)
|
|
13
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -8,6 +8,9 @@ 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, 'FormItem', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement)
|
|
13
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'FormLayout', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
var components = source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; });
|
|
@@ -8,7 +8,9 @@ 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, 'Gallery', alias).localName;
|
|
11
|
-
|
|
11
|
+
if (localName) {
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'isDraggable', 'dragDisabled');
|
|
13
|
+
}
|
|
12
14
|
return source.toSource();
|
|
13
15
|
}
|
|
14
16
|
exports.default = transformer;
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Gradient', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -10,9 +10,15 @@ function transformer(file, api, options) {
|
|
|
10
10
|
var imageBaseLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ImageBase', alias).localName;
|
|
11
11
|
var imageLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Image', alias).localName;
|
|
12
12
|
var avatarLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Avatar', alias).localName;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (imageBaseLocalName) {
|
|
14
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, imageBaseLocalName, 'withBorder', 'noBorder');
|
|
15
|
+
}
|
|
16
|
+
if (imageLocalName) {
|
|
17
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, imageLocalName, 'withBorder', 'noBorder');
|
|
18
|
+
}
|
|
19
|
+
if (avatarLocalName) {
|
|
20
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, avatarLocalName, 'withBorder', 'noBorder');
|
|
21
|
+
}
|
|
16
22
|
return source.toSource();
|
|
17
23
|
}
|
|
18
24
|
exports.default = transformer;
|
|
@@ -14,11 +14,18 @@ function transformer(file, api, options) {
|
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localNameModalCard = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCard', alias).localName;
|
|
16
16
|
var localNameModalCardBase = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCardBase', alias).localName;
|
|
17
|
+
var localNamesForChange = [];
|
|
18
|
+
if (localNameModalCard) {
|
|
19
|
+
localNamesForChange.push(localNameModalCard);
|
|
20
|
+
}
|
|
21
|
+
if (localNameModalCardBase) {
|
|
22
|
+
localNamesForChange.push(localNameModalCardBase);
|
|
23
|
+
}
|
|
17
24
|
var modalCards = source
|
|
18
25
|
.find(j.JSXOpeningElement)
|
|
19
26
|
.filter(function (path) {
|
|
20
27
|
return path.value.name.type === 'JSXIdentifier' &&
|
|
21
|
-
|
|
28
|
+
localNamesForChange.includes(path.value.name.name);
|
|
22
29
|
});
|
|
23
30
|
modalCards.forEach(function (path) {
|
|
24
31
|
var headerAttribute = j(path).find(j.JSXAttribute, { name: { name: 'header' } });
|
|
@@ -8,6 +8,9 @@ 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, 'ModalPageHeader', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; })
|
|
13
16
|
.forEach(function (element) {
|
|
@@ -17,6 +17,9 @@ function transformer(file, api, options) {
|
|
|
17
17
|
var j = api.jscodeshift;
|
|
18
18
|
var source = j(file.source);
|
|
19
19
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Pagination', alias).localName;
|
|
20
|
+
if (!localName) {
|
|
21
|
+
return source.toSource();
|
|
22
|
+
}
|
|
20
23
|
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
21
24
|
source
|
|
22
25
|
.find(j.JSXOpeningElement)
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PanelHeader', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
var elements = source.find(j.JSXOpeningElement).filter(function (path) {
|
|
17
20
|
if (path.value.name.type === 'JSXMemberExpression') {
|
|
18
21
|
var property = path.value.name;
|
|
@@ -9,6 +9,9 @@ function transformer(file, api, options) {
|
|
|
9
9
|
var j = api.jscodeshift;
|
|
10
10
|
var source = j(file.source);
|
|
11
11
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PanelHeader', alias).localName;
|
|
12
|
+
if (!localName) {
|
|
13
|
+
return source.toSource();
|
|
14
|
+
}
|
|
12
15
|
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'visor', 'float');
|
|
13
16
|
source
|
|
14
17
|
.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; })
|
|
@@ -8,7 +8,9 @@ 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, 'Placeholder', alias).localName;
|
|
11
|
-
|
|
11
|
+
if (localName) {
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'withPadding', 'noPadding');
|
|
13
|
+
}
|
|
12
14
|
return source.toSource();
|
|
13
15
|
}
|
|
14
16
|
exports.default = transformer;
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'PopoutWrapper', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
var components = source.find(j.JSXOpeningElement, function (element) { return element.name.type === 'JSXIdentifier' && element.name.name === localName; });
|
|
17
20
|
if (components.size() > 0) {
|
|
18
21
|
(0, report_1.report)(api, ": When using ".concat(chalk_1.default.white.bgBlue('PopoutWrapper'), " you might need to apply useScrollLock() hook manually."));
|
|
@@ -35,6 +35,9 @@ function transformer(file, api, options) {
|
|
|
35
35
|
var source = j(file.source);
|
|
36
36
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
|
|
37
37
|
var attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_MANIPULATOR, api);
|
|
38
|
+
if (!localName) {
|
|
39
|
+
return source.toSource();
|
|
40
|
+
}
|
|
38
41
|
source
|
|
39
42
|
.find(j.ImportDeclaration)
|
|
40
43
|
.filter(function (path) { return path.node.source.value === alias; })
|
|
@@ -54,6 +54,9 @@ function transformer(file, api, options) {
|
|
|
54
54
|
var source = j(file.source);
|
|
55
55
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
|
|
56
56
|
var attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_MANIPULATOR, api);
|
|
57
|
+
if (!localName) {
|
|
58
|
+
return source.toSource();
|
|
59
|
+
}
|
|
57
60
|
source
|
|
58
61
|
.find(j.ImportDeclaration)
|
|
59
62
|
.filter(function (path) { return path.node.source.value === alias; })
|
|
@@ -21,6 +21,9 @@ function transformer(file, api, options) {
|
|
|
21
21
|
.find(j.ImportDeclaration)
|
|
22
22
|
.filter(function (path) { return path.node.source.value === alias; })
|
|
23
23
|
.find(j.ImportSpecifier, { imported: { name: 'RangeSlider' } });
|
|
24
|
+
if (componentImport.length === 0) {
|
|
25
|
+
return source.toSource();
|
|
26
|
+
}
|
|
24
27
|
var sliderImport = source
|
|
25
28
|
.find(j.ImportDeclaration)
|
|
26
29
|
.filter(function (path) { return path.node.source.value === alias; })
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'RichTooltip', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
var richTooltipComponents = source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; });
|
|
@@ -12,7 +12,9 @@ function transformer(file, api, options) {
|
|
|
12
12
|
var j = api.jscodeshift;
|
|
13
13
|
var source = j(file.source);
|
|
14
14
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Search', alias).localName;
|
|
15
|
-
|
|
15
|
+
if (localName) {
|
|
16
|
+
(0, codemod_helpers_1.renameProp)(j, source, localName, RENAME_MAP);
|
|
17
|
+
}
|
|
16
18
|
return source.toSource();
|
|
17
19
|
}
|
|
18
20
|
exports.default = transformer;
|
|
@@ -10,9 +10,15 @@ function transformer(file, api, options) {
|
|
|
10
10
|
var selectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Select', alias).localName;
|
|
11
11
|
var customSelectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomSelect', alias).localName;
|
|
12
12
|
var chipsSelectLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias).localName;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (selectLocalName) {
|
|
14
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, selectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
15
|
+
}
|
|
16
|
+
if (customSelectLocalName) {
|
|
17
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, customSelectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
18
|
+
}
|
|
19
|
+
if (chipsSelectLocalName) {
|
|
20
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, chipsSelectLocalName, 'fixDropdownWidth', 'dropdownAutoWidth');
|
|
21
|
+
}
|
|
16
22
|
return source.toSource();
|
|
17
23
|
}
|
|
18
24
|
exports.default = transformer;
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'SimpleCell', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -8,6 +8,9 @@ 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, 'SplitCol', alias).localName;
|
|
11
|
+
if (!localName) {
|
|
12
|
+
return source.toSource();
|
|
13
|
+
}
|
|
11
14
|
source
|
|
12
15
|
.find(j.JSXOpeningElement)
|
|
13
16
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -8,7 +8,9 @@ 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, 'Tabbar', alias).localName;
|
|
11
|
-
|
|
11
|
+
if (localName) {
|
|
12
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'shadow', 'plain');
|
|
13
|
+
}
|
|
12
14
|
return source.toSource();
|
|
13
15
|
}
|
|
14
16
|
exports.default = transformer;
|
|
@@ -14,6 +14,9 @@ function transformer(file, api, options) {
|
|
|
14
14
|
var j = api.jscodeshift;
|
|
15
15
|
var source = j(file.source);
|
|
16
16
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Tappable', alias).localName;
|
|
17
|
+
if (!localName) {
|
|
18
|
+
return source.toSource();
|
|
19
|
+
}
|
|
17
20
|
source
|
|
18
21
|
.find(j.JSXOpeningElement)
|
|
19
22
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -53,6 +53,9 @@ function transformer(file, api, options) {
|
|
|
53
53
|
var source = j(file.source);
|
|
54
54
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
|
|
55
55
|
var attributeReplacer = (0, codemod_helpers_1.createAttributeManipulator)(ATTRIBUTE_MANIPULATOR, api);
|
|
56
|
+
if (!localName) {
|
|
57
|
+
return source.toSource();
|
|
58
|
+
}
|
|
56
59
|
source
|
|
57
60
|
.find(j.ImportDeclaration)
|
|
58
61
|
.filter(function (path) { return path.node.source.value === alias; })
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
if (!localName) {
|
|
15
|
+
return source.toSource();
|
|
16
|
+
}
|
|
17
|
+
// подменяем импорт
|
|
18
|
+
source
|
|
19
|
+
.find(j.ImportDeclaration)
|
|
20
|
+
.filter(function (path) { return path.node.source.value === alias; })
|
|
21
|
+
.find(j.ImportSpecifier, { imported: { name: componentName } })
|
|
22
|
+
.forEach(function (path) {
|
|
23
|
+
j(path).replaceWith(function (path) {
|
|
24
|
+
if (path.node.local && path.node.local.name !== path.node.imported.name) {
|
|
25
|
+
needRename = false;
|
|
26
|
+
}
|
|
27
|
+
return j.importSpecifier(j.jsxIdentifier(componentNameTo), needRename ? null : path.node.local);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
source.findJSXElements(localName).forEach(function (element) {
|
|
31
|
+
// меняем название компонента в JSX на переименованный в импорте (если нужно)
|
|
32
|
+
j(element).replaceWith(function (path) {
|
|
33
|
+
var renamedLocalName = needRename ? componentNameTo : localName;
|
|
34
|
+
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);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return source.toSource();
|
|
38
|
+
}
|
|
39
|
+
exports.default = transformer;
|
|
@@ -57,6 +57,10 @@ 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
|
+
if (!localName) {
|
|
61
|
+
return source.toSource();
|
|
62
|
+
}
|
|
63
|
+
(0, codemod_helpers_1.swapBooleanValue)(api, source, localName, 'arrow', 'disableArrow');
|
|
60
64
|
// подменяем импорт
|
|
61
65
|
source
|
|
62
66
|
.find(j.ImportDeclaration)
|
|
@@ -13,6 +13,9 @@ function transformer(file, api, options) {
|
|
|
13
13
|
var j = api.jscodeshift;
|
|
14
14
|
var source = j(file.source);
|
|
15
15
|
var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'UsersStack', alias).localName;
|
|
16
|
+
if (!localName) {
|
|
17
|
+
return source.toSource();
|
|
18
|
+
}
|
|
16
19
|
source
|
|
17
20
|
.find(j.JSXOpeningElement)
|
|
18
21
|
.filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
|
|
@@ -23,6 +23,9 @@ function transformer(file, api, options) {
|
|
|
23
23
|
.find(j.ImportSpecifier)
|
|
24
24
|
.filter(function (path) { return path.node.imported.name === 'VisuallyHiddenInput'; })
|
|
25
25
|
.at(0);
|
|
26
|
+
if (componentImport.length === 0) {
|
|
27
|
+
return source.toSource();
|
|
28
|
+
}
|
|
26
29
|
componentImport.forEach(function (path) {
|
|
27
30
|
if (path.node.local && path.node.local.name !== path.node.imported.name) {
|
|
28
31
|
localImportName = path.node.local.name;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vkontakte/vkui-codemods",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
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/",
|
|
@@ -15,24 +15,25 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"chalk": "^4.1.2",
|
|
18
|
-
"commander": "^
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
19
|
"cross-spawn": "^7.0.3",
|
|
20
20
|
"jscodeshift": "^0.13.1",
|
|
21
21
|
"prompts": "^2.4.2",
|
|
22
|
-
"typescript": "^5.
|
|
22
|
+
"typescript": "^5.4.5"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@swc/core": "^1.
|
|
26
|
-
"@swc/jest": "^0.2.
|
|
25
|
+
"@swc/core": "^1.4.17",
|
|
26
|
+
"@swc/jest": "^0.2.36",
|
|
27
27
|
"@types/cross-spawn": "^6.0.6",
|
|
28
|
-
"@types/jest": "^29.5.
|
|
28
|
+
"@types/jest": "^29.5.12",
|
|
29
29
|
"@types/jscodeshift": "^0.11.11",
|
|
30
|
-
"@types/node": "^20.
|
|
31
|
-
"@types/prompts": "^2.4.
|
|
30
|
+
"@types/node": "^20.12.7",
|
|
31
|
+
"@types/prompts": "^2.4.9",
|
|
32
32
|
"jest": "^29.7.0",
|
|
33
33
|
"ts-node": "^10.9.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
+
"prepack": "yarn run build",
|
|
36
37
|
"build": "tsc",
|
|
37
38
|
"test": "jest",
|
|
38
39
|
"test:ci": "yarn test",
|
|
@@ -42,4 +43,4 @@
|
|
|
42
43
|
"provenance": true,
|
|
43
44
|
"access": "public"
|
|
44
45
|
}
|
|
45
|
-
}
|
|
46
|
+
}
|