@atlaskit/codemod-cli 0.18.0 → 0.20.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/dist/cjs/filepath.js +1 -1
- package/dist/cjs/main.js +1 -1
- package/dist/cjs/presets/index.js +2 -1
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js +79 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/element-adapter-types.js +27 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.js +51 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/move-to-react-drop-indicator.js +37 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/pointer-outside-of-preview.js +40 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.js +40 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +48 -0
- package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable.js +40 -0
- package/dist/cjs/transforms.js +3 -3
- package/dist/es2019/filepath.js +2 -2
- package/dist/es2019/presets/index.js +2 -1
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js +52 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/element-adapter-types.js +17 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.js +63 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/move-to-react-drop-indicator.js +31 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/pointer-outside-of-preview.js +28 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.js +28 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +42 -0
- package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable.js +19 -0
- package/dist/es2019/transforms.js +3 -3
- package/dist/esm/filepath.js +2 -2
- package/dist/esm/main.js +1 -1
- package/dist/esm/presets/index.js +2 -1
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js +73 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/element-adapter-types.js +21 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.js +44 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/move-to-react-drop-indicator.js +31 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/pointer-outside-of-preview.js +34 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.js +34 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.js +42 -0
- package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable.js +33 -0
- package/dist/esm/transforms.js +3 -3
- package/dist/types/presets/index.d.ts +1 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/element-adapter-types.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.d.ts +3 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/move-to-react-drop-indicator.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/pointer-outside-of-preview.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.d.ts +2 -0
- package/dist/types/presets/upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable.d.ts +2 -0
- package/dist/types-ts4.5/presets/index.d.ts +1 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/element-adapter-types.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.d.ts +3 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/move-to-react-drop-indicator.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/pointer-outside-of-preview.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/update-safe-imports.d.ts +2 -0
- package/dist/types-ts4.5/presets/upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable.d.ts +2 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/codemod-cli
|
|
2
2
|
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#70616](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70616) [`533c86673290`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/533c86673290) - Adding a new pattern for upgrading Pragmatic drag and drop consumers to `1.0`
|
|
8
|
+
|
|
9
|
+
Pattern name: `"upgrade-pragmatic-drag-and-drop-to-stable"`
|
|
10
|
+
|
|
11
|
+
## 0.19.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#60956](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60956) [`3c438c899565`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3c438c899565) - Updated glob dependency to 9.0.0 to fix VULN-1129796
|
|
16
|
+
|
|
3
17
|
## 0.18.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/cjs/filepath.js
CHANGED
|
@@ -27,7 +27,7 @@ function _findDependentPackagePaths() {
|
|
|
27
27
|
return "".concat(crawlPath.replace(/^\.\//, ''), "/**/package.json");
|
|
28
28
|
}); // Convert array into glob string
|
|
29
29
|
globString = searchStrings.length > 1 ? "{".concat(searchStrings.join(','), "}") : searchStrings[0];
|
|
30
|
-
packageJsonPaths = _glob.
|
|
30
|
+
packageJsonPaths = (0, _glob.globSync)(globString, {
|
|
31
31
|
ignore: '**/node_modules/**',
|
|
32
32
|
nodir: true
|
|
33
33
|
});
|
package/dist/cjs/main.js
CHANGED
|
@@ -305,7 +305,7 @@ function _main() {
|
|
|
305
305
|
case 4:
|
|
306
306
|
_yield$parseArgs = _context5.sent;
|
|
307
307
|
packages = _yield$parseArgs.packages;
|
|
308
|
-
_process$env$_PACKAGE = "0.
|
|
308
|
+
_process$env$_PACKAGE = "0.20.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
|
|
309
309
|
logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
|
|
310
310
|
if (packages && packages.length > 0) {
|
|
311
311
|
logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
|
|
@@ -9,12 +9,13 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
require("./styled-to-emotion/styled-to-emotion");
|
|
10
10
|
require("./theme-remove-deprecated-mixins/theme-remove-deprecated-mixins");
|
|
11
11
|
require("./migrate-to-new-buttons/migrate-to-new-buttons");
|
|
12
|
+
require("./upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable");
|
|
12
13
|
/**
|
|
13
14
|
* Manually import presets to make sure typescript includes them
|
|
14
15
|
* in the final bundle.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-to-new-buttons'].map(function (preset) {
|
|
18
|
+
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-to-new-buttons', 'upgrade-pragmatic-drag-and-drop-to-stable'].map(function (preset) {
|
|
18
19
|
return _path.default.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
19
20
|
});
|
|
20
21
|
var _default = exports.default = presets;
|
package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateAutoScroll = updateAutoScroll;
|
|
7
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
var scenarios = [{
|
|
11
|
+
existing: {
|
|
12
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/file',
|
|
13
|
+
namedImport: 'autoScrollForFiles'
|
|
14
|
+
},
|
|
15
|
+
updated: {
|
|
16
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/external',
|
|
17
|
+
namedImport: 'autoScrollForExternal'
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
existing: {
|
|
21
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/file',
|
|
22
|
+
namedImport: 'unsafeOverflowAutoScrollForFiles'
|
|
23
|
+
},
|
|
24
|
+
updated: {
|
|
25
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/external',
|
|
26
|
+
namedImport: 'unsafeOverflowAutoScrollForExternal'
|
|
27
|
+
}
|
|
28
|
+
}];
|
|
29
|
+
function updateAutoScroll(file, api) {
|
|
30
|
+
var j = api.jscodeshift;
|
|
31
|
+
var root = j(file.source);
|
|
32
|
+
var changed = false;
|
|
33
|
+
var _iterator = _createForOfIteratorHelper(scenarios),
|
|
34
|
+
_step;
|
|
35
|
+
try {
|
|
36
|
+
var _loop = function _loop() {
|
|
37
|
+
var scenario = _step.value;
|
|
38
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
39
|
+
return path.node.source.value === scenario.existing.importPath;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// move on to the next scenario
|
|
43
|
+
if (!isUsingImport) {
|
|
44
|
+
return 1; // continue
|
|
45
|
+
}
|
|
46
|
+
changed = true;
|
|
47
|
+
|
|
48
|
+
// replace old import path with new import path
|
|
49
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
50
|
+
return path.node.source.value === scenario.existing.importPath;
|
|
51
|
+
})
|
|
52
|
+
// replace import
|
|
53
|
+
.map(function (path) {
|
|
54
|
+
path.node.source.value = scenario.updated.importPath;
|
|
55
|
+
return path;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// replace old named import and usages with new one
|
|
59
|
+
root.find(j.Identifier).filter(function (path) {
|
|
60
|
+
return path.value.name === scenario.existing.namedImport;
|
|
61
|
+
}).replaceWith(j.identifier(scenario.updated.namedImport));
|
|
62
|
+
};
|
|
63
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
64
|
+
if (_loop()) continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Don't format the file if we are not changing anything
|
|
68
|
+
} catch (err) {
|
|
69
|
+
_iterator.e(err);
|
|
70
|
+
} finally {
|
|
71
|
+
_iterator.f();
|
|
72
|
+
}
|
|
73
|
+
if (!changed) {
|
|
74
|
+
return file.source;
|
|
75
|
+
}
|
|
76
|
+
return root.toSource({
|
|
77
|
+
quote: 'single'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shiftCanMonitorArgType = shiftCanMonitorArgType;
|
|
7
|
+
var newImport = '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
|
+
function shiftCanMonitorArgType(file, api) {
|
|
9
|
+
var j = api.jscodeshift;
|
|
10
|
+
var root = j(file.source);
|
|
11
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
12
|
+
return path.node.source.value === newImport;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// don't change the file if we don't need to
|
|
16
|
+
if (!isUsingImport) {
|
|
17
|
+
return file.source;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// replace old named import and usages with new one
|
|
21
|
+
root.find(j.Identifier).filter(function (path) {
|
|
22
|
+
return path.value.name === 'ElementMonitorCanMonitorArgs';
|
|
23
|
+
}).replaceWith(j.identifier('ElementMonitorGetFeedbackArgs'));
|
|
24
|
+
return root.toSource({
|
|
25
|
+
quote: 'single'
|
|
26
|
+
});
|
|
27
|
+
}
|
package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveFromFileAdapterToExternalAdapter = moveFromFileAdapterToExternalAdapter;
|
|
7
|
+
exports.pleaseMigrateMessage = void 0;
|
|
8
|
+
var _codemodUtils = require("@atlaskit/codemod-utils");
|
|
9
|
+
var pleaseMigrateMessage = exports.pleaseMigrateMessage = "\n The file adapter has been replaced by a new (more powerful) external adapter.\n Please see our external adapter documentation on how to migrate your file adapter usage.\n\n We have also included \"containsFiles()\" as an import in this file as it is helpful to\n restrict your monitors and drop targets to only be for files.\n\n We have also included \"getFiles()\" as an import as it is a helpful way to extract the files\n from a drag operation\n\n dropTargetForExternal({\n canDrop: containsFiles,\n onDrop({source}) {\n const files = getFiles({source});\n }\n });\n\n monitorForExternal({\n canMonitor: containsFiles,\n onDrop({source}) {\n const files = getFiles({source});\n }\n });\n\n - [1.0 upgrade documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/changelog)\n - [external adapter documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/external)\n - [file usage documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/external/files)\n";
|
|
10
|
+
var oldImportPath = '@atlaskit/pragmatic-drag-and-drop/adapter/file';
|
|
11
|
+
var newImportPath = '@atlaskit/pragmatic-drag-and-drop/external/adapter';
|
|
12
|
+
function moveFromFileAdapterToExternalAdapter(file, api) {
|
|
13
|
+
var j = api.jscodeshift;
|
|
14
|
+
var root = j(file.source);
|
|
15
|
+
var isUsingFileAdapter = root.find(j.ImportDeclaration).some(function (path) {
|
|
16
|
+
return path.node.source.value === oldImportPath;
|
|
17
|
+
});
|
|
18
|
+
if (!isUsingFileAdapter) {
|
|
19
|
+
return file.source;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// replace old import path with new import path
|
|
23
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
24
|
+
return path.node.source.value === oldImportPath;
|
|
25
|
+
})
|
|
26
|
+
// replace import
|
|
27
|
+
.map(function (path) {
|
|
28
|
+
path.node.source.value = newImportPath;
|
|
29
|
+
return path;
|
|
30
|
+
})
|
|
31
|
+
// Add an import for 'containsFiles()' and `getFiles()` as likely this file will need it
|
|
32
|
+
.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('containsFiles')), j.importSpecifier(j.identifier('getFiles'))], j.literal('@atlaskit/pragmatic-drag-and-drop/external/file')));
|
|
33
|
+
|
|
34
|
+
// update usages of `monitorForFiles` and `dropTargetForFiles`
|
|
35
|
+
root.find(j.Identifier).filter(function (path) {
|
|
36
|
+
return path.value.name === 'monitorForFiles';
|
|
37
|
+
}).replaceWith(j.identifier('monitorForExternal'));
|
|
38
|
+
root.find(j.Identifier).filter(function (path) {
|
|
39
|
+
return path.value.name === 'dropTargetForFiles';
|
|
40
|
+
}).replaceWith(j.identifier('dropTargetForExternal'));
|
|
41
|
+
|
|
42
|
+
// add comment to the start of the file
|
|
43
|
+
(0, _codemodUtils.addCommentToStartOfFile)({
|
|
44
|
+
j: j,
|
|
45
|
+
base: root,
|
|
46
|
+
message: pleaseMigrateMessage
|
|
47
|
+
});
|
|
48
|
+
return root.toSource({
|
|
49
|
+
quote: 'single'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveToReactDropIndicator = moveToReactDropIndicator;
|
|
7
|
+
var oldPackagePath = '@atlaskit/pragmatic-drag-and-drop-react-indicator';
|
|
8
|
+
var newPackagePath = '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator';
|
|
9
|
+
function isString(value) {
|
|
10
|
+
return typeof value === 'string';
|
|
11
|
+
}
|
|
12
|
+
function isOldPackagePath(value) {
|
|
13
|
+
return isString(value) && value.startsWith(oldPackagePath);
|
|
14
|
+
}
|
|
15
|
+
function moveToReactDropIndicator(file, api) {
|
|
16
|
+
var j = api.jscodeshift;
|
|
17
|
+
var root = j(file.source);
|
|
18
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
19
|
+
return isOldPackagePath(path.node.source.value);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Don't format the file if we are not changing anything
|
|
23
|
+
if (!isUsingImport) {
|
|
24
|
+
return file.source;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// replace imports
|
|
28
|
+
root.find(j.ImportDeclaration).forEach(function (path) {
|
|
29
|
+
var value = path.node.source.value;
|
|
30
|
+
if (isString(value) && isOldPackagePath(path.node.source.value)) {
|
|
31
|
+
path.node.source.value = value.replace(oldPackagePath, newPackagePath);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return root.toSource({
|
|
35
|
+
quote: 'single'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shiftToPointerOutsideOfPreview = shiftToPointerOutsideOfPreview;
|
|
7
|
+
var paths = {
|
|
8
|
+
current: '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer',
|
|
9
|
+
next: '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview'
|
|
10
|
+
};
|
|
11
|
+
function shiftToPointerOutsideOfPreview(file, api) {
|
|
12
|
+
var j = api.jscodeshift;
|
|
13
|
+
var root = j(file.source);
|
|
14
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
15
|
+
return path.node.source.value === paths.current;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// don't change the file if we don't need to
|
|
19
|
+
if (!isUsingImport) {
|
|
20
|
+
return file.source;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// replace old import path with new import path
|
|
24
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
25
|
+
return path.node.source.value === paths.current;
|
|
26
|
+
})
|
|
27
|
+
// replace import
|
|
28
|
+
.map(function (path) {
|
|
29
|
+
path.node.source.value = paths.next;
|
|
30
|
+
return path;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// replace old named import and usages with new one
|
|
34
|
+
root.find(j.Identifier).filter(function (path) {
|
|
35
|
+
return path.value.name === 'offsetFromPointer';
|
|
36
|
+
}).replaceWith(j.identifier('pointerOutsideOfPreview'));
|
|
37
|
+
return root.toSource({
|
|
38
|
+
quote: 'single'
|
|
39
|
+
});
|
|
40
|
+
}
|
package/dist/cjs/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shiftToPreventUnhandled = shiftToPreventUnhandled;
|
|
7
|
+
var paths = {
|
|
8
|
+
current: '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled',
|
|
9
|
+
next: '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled'
|
|
10
|
+
};
|
|
11
|
+
function shiftToPreventUnhandled(file, api) {
|
|
12
|
+
var j = api.jscodeshift;
|
|
13
|
+
var root = j(file.source);
|
|
14
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
15
|
+
return path.node.source.value === paths.current;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// don't change the file if we don't need to
|
|
19
|
+
if (!isUsingImport) {
|
|
20
|
+
return file.source;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// replace old import path with new import path
|
|
24
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
25
|
+
return path.node.source.value === paths.current;
|
|
26
|
+
})
|
|
27
|
+
// replace import
|
|
28
|
+
.map(function (path) {
|
|
29
|
+
path.node.source.value = paths.next;
|
|
30
|
+
return path;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// replace old named import and usages with new one
|
|
34
|
+
root.find(j.Identifier).filter(function (path) {
|
|
35
|
+
return path.value.name === 'cancelUnhandled';
|
|
36
|
+
}).replaceWith(j.identifier('preventUnhandled'));
|
|
37
|
+
return root.toSource({
|
|
38
|
+
quote: 'single'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.updateSafeImports = updateSafeImports;
|
|
7
|
+
var importMap = {
|
|
8
|
+
// core package
|
|
9
|
+
'@atlaskit/pragmatic-drag-and-drop/adapter/element': '@atlaskit/pragmatic-drag-and-drop/element/adapter',
|
|
10
|
+
'@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview',
|
|
11
|
+
'@atlaskit/pragmatic-drag-and-drop/util/center-under-pointer': '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer',
|
|
12
|
+
'@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-on-source': '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source',
|
|
13
|
+
'@atlaskit/pragmatic-drag-and-drop/util/disable-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview',
|
|
14
|
+
'@atlaskit/pragmatic-drag-and-drop/util/scroll-just-enough-into-view': '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view',
|
|
15
|
+
'@atlaskit/pragmatic-drag-and-drop/util/combine': '@atlaskit/pragmatic-drag-and-drop/combine',
|
|
16
|
+
'@atlaskit/pragmatic-drag-and-drop/util/once': '@atlaskit/pragmatic-drag-and-drop/once',
|
|
17
|
+
'@atlaskit/pragmatic-drag-and-drop/util/reorder': '@atlaskit/pragmatic-drag-and-drop/reorder',
|
|
18
|
+
// hitbox package
|
|
19
|
+
'@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge': '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'
|
|
20
|
+
|
|
21
|
+
// Doing cancel-unhandled in it's own transformer as the name is changing too
|
|
22
|
+
// '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled':
|
|
23
|
+
// '@atlaskit/pragmatic-drag-and-drop/cancel-unhandled',
|
|
24
|
+
// We are doing the name update in another transform
|
|
25
|
+
// '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
|
|
26
|
+
// '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function updateSafeImports(file, api) {
|
|
30
|
+
var j = api.jscodeshift;
|
|
31
|
+
var root = j(file.source);
|
|
32
|
+
|
|
33
|
+
// avoiding reformatting the file if we are not changing anything
|
|
34
|
+
var changed = false;
|
|
35
|
+
root.find(j.ImportDeclaration).forEach(function (path) {
|
|
36
|
+
var importPath = path.node.source.value;
|
|
37
|
+
if (typeof importPath === 'string' && importMap[importPath]) {
|
|
38
|
+
changed = true;
|
|
39
|
+
path.node.source.value = importMap[importPath];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (!changed) {
|
|
43
|
+
return file.source;
|
|
44
|
+
}
|
|
45
|
+
return root.toSource({
|
|
46
|
+
quote: 'single'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = transformer;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _updateSafeImports = require("./transformers/update-safe-imports");
|
|
10
|
+
var _externalAdapter = require("./transformers/external-adapter");
|
|
11
|
+
var _moveToReactDropIndicator = require("./transformers/move-to-react-drop-indicator");
|
|
12
|
+
var _autoScroll = require("./transformers/auto-scroll");
|
|
13
|
+
var _pointerOutsideOfPreview = require("./transformers/pointer-outside-of-preview");
|
|
14
|
+
var _preventUnhandled = require("./transformers/prevent-unhandled");
|
|
15
|
+
var _elementAdapterTypes = require("./transformers/element-adapter-types");
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
var transformers = [_updateSafeImports.updateSafeImports, _externalAdapter.moveFromFileAdapterToExternalAdapter, _moveToReactDropIndicator.moveToReactDropIndicator, _autoScroll.updateAutoScroll, _pointerOutsideOfPreview.shiftToPointerOutsideOfPreview, _preventUnhandled.shiftToPreventUnhandled, _elementAdapterTypes.shiftCanMonitorArgType];
|
|
22
|
+
function transformer(file, api) {
|
|
23
|
+
var source = file.source;
|
|
24
|
+
var _iterator = _createForOfIteratorHelper(transformers),
|
|
25
|
+
_step;
|
|
26
|
+
try {
|
|
27
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
28
|
+
var fn = _step.value;
|
|
29
|
+
var updated = _objectSpread(_objectSpread({}, file), {}, {
|
|
30
|
+
source: source
|
|
31
|
+
});
|
|
32
|
+
source = fn(updated, api);
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
return source;
|
|
40
|
+
}
|
package/dist/cjs/transforms.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.parseTransformPath = exports.hasTransform = exports.getTransforms = exports.getTransformVersion = exports.getTransformPath = exports.getTransformModule = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _glob =
|
|
10
|
+
var _glob = require("glob");
|
|
11
11
|
var _semver = _interopRequireDefault(require("semver"));
|
|
12
12
|
var _presets = _interopRequireDefault(require("./presets"));
|
|
13
13
|
var basePath = function basePath(packages) {
|
|
@@ -17,7 +17,7 @@ var basePath = function basePath(packages) {
|
|
|
17
17
|
return _path.default.join.apply(_path.default, [process.cwd(), 'node_modules'].concat(packageDirectory, ['codemods']));
|
|
18
18
|
};
|
|
19
19
|
var hasTransform = exports.hasTransform = function hasTransform(transformPath) {
|
|
20
|
-
return _glob.
|
|
20
|
+
return (0, _glob.globSync)(transformPath).length > 0;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/** Retrieves transforms for `packages` if provided, otherwise all transforms including presets */
|
|
@@ -27,7 +27,7 @@ var getTransforms = exports.getTransforms = function getTransforms(packages) {
|
|
|
27
27
|
transforms.unshift.apply(transforms, (0, _toConsumableArray2.default)(_presets.default));
|
|
28
28
|
}
|
|
29
29
|
return transforms.map(function (transform) {
|
|
30
|
-
return _glob.
|
|
30
|
+
return (0, _glob.globSync)(transform);
|
|
31
31
|
}).reduce(function (acc, val) {
|
|
32
32
|
return acc.concat(val);
|
|
33
33
|
}, []).map(function (transform) {
|
package/dist/es2019/filepath.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { globSync } from 'glob';
|
|
2
2
|
import { promises } from 'fs';
|
|
3
3
|
const {
|
|
4
4
|
readFile
|
|
@@ -14,7 +14,7 @@ export async function findDependentPackagePaths(crawlPaths, dependencyPackage) {
|
|
|
14
14
|
|
|
15
15
|
// Convert array into glob string
|
|
16
16
|
const globString = searchStrings.length > 1 ? `{${searchStrings.join(',')}}` : searchStrings[0];
|
|
17
|
-
const packageJsonPaths =
|
|
17
|
+
const packageJsonPaths = globSync(globString, {
|
|
18
18
|
ignore: '**/node_modules/**',
|
|
19
19
|
nodir: true
|
|
20
20
|
});
|
|
@@ -7,5 +7,6 @@ import path from 'path';
|
|
|
7
7
|
import './styled-to-emotion/styled-to-emotion';
|
|
8
8
|
import './theme-remove-deprecated-mixins/theme-remove-deprecated-mixins';
|
|
9
9
|
import './migrate-to-new-buttons/migrate-to-new-buttons';
|
|
10
|
-
|
|
10
|
+
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
11
|
+
const presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-to-new-buttons', 'upgrade-pragmatic-drag-and-drop-to-stable'].map(preset => path.join(__dirname, preset, `${preset}.@(ts|js|tsx)`));
|
|
11
12
|
export default presets;
|
package/dist/es2019/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const scenarios = [{
|
|
2
|
+
existing: {
|
|
3
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/file',
|
|
4
|
+
namedImport: 'autoScrollForFiles'
|
|
5
|
+
},
|
|
6
|
+
updated: {
|
|
7
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/external',
|
|
8
|
+
namedImport: 'autoScrollForExternal'
|
|
9
|
+
}
|
|
10
|
+
}, {
|
|
11
|
+
existing: {
|
|
12
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/file',
|
|
13
|
+
namedImport: 'unsafeOverflowAutoScrollForFiles'
|
|
14
|
+
},
|
|
15
|
+
updated: {
|
|
16
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/external',
|
|
17
|
+
namedImport: 'unsafeOverflowAutoScrollForExternal'
|
|
18
|
+
}
|
|
19
|
+
}];
|
|
20
|
+
export function updateAutoScroll(file, api) {
|
|
21
|
+
const j = api.jscodeshift;
|
|
22
|
+
const root = j(file.source);
|
|
23
|
+
let changed = false;
|
|
24
|
+
for (const scenario of scenarios) {
|
|
25
|
+
const isUsingImport = root.find(j.ImportDeclaration).some(path => path.node.source.value === scenario.existing.importPath);
|
|
26
|
+
|
|
27
|
+
// move on to the next scenario
|
|
28
|
+
if (!isUsingImport) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
changed = true;
|
|
32
|
+
|
|
33
|
+
// replace old import path with new import path
|
|
34
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value === scenario.existing.importPath)
|
|
35
|
+
// replace import
|
|
36
|
+
.map(path => {
|
|
37
|
+
path.node.source.value = scenario.updated.importPath;
|
|
38
|
+
return path;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// replace old named import and usages with new one
|
|
42
|
+
root.find(j.Identifier).filter(path => path.value.name === scenario.existing.namedImport).replaceWith(j.identifier(scenario.updated.namedImport));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Don't format the file if we are not changing anything
|
|
46
|
+
if (!changed) {
|
|
47
|
+
return file.source;
|
|
48
|
+
}
|
|
49
|
+
return root.toSource({
|
|
50
|
+
quote: 'single'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const newImport = '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
2
|
+
export function shiftCanMonitorArgType(file, api) {
|
|
3
|
+
const j = api.jscodeshift;
|
|
4
|
+
const root = j(file.source);
|
|
5
|
+
const isUsingImport = root.find(j.ImportDeclaration).some(path => path.node.source.value === newImport);
|
|
6
|
+
|
|
7
|
+
// don't change the file if we don't need to
|
|
8
|
+
if (!isUsingImport) {
|
|
9
|
+
return file.source;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// replace old named import and usages with new one
|
|
13
|
+
root.find(j.Identifier).filter(path => path.value.name === 'ElementMonitorCanMonitorArgs').replaceWith(j.identifier('ElementMonitorGetFeedbackArgs'));
|
|
14
|
+
return root.toSource({
|
|
15
|
+
quote: 'single'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { addCommentToStartOfFile } from '@atlaskit/codemod-utils';
|
|
2
|
+
export const pleaseMigrateMessage = `
|
|
3
|
+
The file adapter has been replaced by a new (more powerful) external adapter.
|
|
4
|
+
Please see our external adapter documentation on how to migrate your file adapter usage.
|
|
5
|
+
|
|
6
|
+
We have also included "containsFiles()" as an import in this file as it is helpful to
|
|
7
|
+
restrict your monitors and drop targets to only be for files.
|
|
8
|
+
|
|
9
|
+
We have also included "getFiles()" as an import as it is a helpful way to extract the files
|
|
10
|
+
from a drag operation
|
|
11
|
+
|
|
12
|
+
dropTargetForExternal({
|
|
13
|
+
canDrop: containsFiles,
|
|
14
|
+
onDrop({source}) {
|
|
15
|
+
const files = getFiles({source});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
monitorForExternal({
|
|
20
|
+
canMonitor: containsFiles,
|
|
21
|
+
onDrop({source}) {
|
|
22
|
+
const files = getFiles({source});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
- [1.0 upgrade documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/changelog)
|
|
27
|
+
- [external adapter documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/external)
|
|
28
|
+
- [file usage documentation](https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/external/files)
|
|
29
|
+
`;
|
|
30
|
+
const oldImportPath = '@atlaskit/pragmatic-drag-and-drop/adapter/file';
|
|
31
|
+
const newImportPath = '@atlaskit/pragmatic-drag-and-drop/external/adapter';
|
|
32
|
+
export function moveFromFileAdapterToExternalAdapter(file, api) {
|
|
33
|
+
const j = api.jscodeshift;
|
|
34
|
+
const root = j(file.source);
|
|
35
|
+
const isUsingFileAdapter = root.find(j.ImportDeclaration).some(path => path.node.source.value === oldImportPath);
|
|
36
|
+
if (!isUsingFileAdapter) {
|
|
37
|
+
return file.source;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// replace old import path with new import path
|
|
41
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value === oldImportPath)
|
|
42
|
+
// replace import
|
|
43
|
+
.map(path => {
|
|
44
|
+
path.node.source.value = newImportPath;
|
|
45
|
+
return path;
|
|
46
|
+
})
|
|
47
|
+
// Add an import for 'containsFiles()' and `getFiles()` as likely this file will need it
|
|
48
|
+
.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('containsFiles')), j.importSpecifier(j.identifier('getFiles'))], j.literal('@atlaskit/pragmatic-drag-and-drop/external/file')));
|
|
49
|
+
|
|
50
|
+
// update usages of `monitorForFiles` and `dropTargetForFiles`
|
|
51
|
+
root.find(j.Identifier).filter(path => path.value.name === 'monitorForFiles').replaceWith(j.identifier('monitorForExternal'));
|
|
52
|
+
root.find(j.Identifier).filter(path => path.value.name === 'dropTargetForFiles').replaceWith(j.identifier('dropTargetForExternal'));
|
|
53
|
+
|
|
54
|
+
// add comment to the start of the file
|
|
55
|
+
addCommentToStartOfFile({
|
|
56
|
+
j,
|
|
57
|
+
base: root,
|
|
58
|
+
message: pleaseMigrateMessage
|
|
59
|
+
});
|
|
60
|
+
return root.toSource({
|
|
61
|
+
quote: 'single'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const oldPackagePath = '@atlaskit/pragmatic-drag-and-drop-react-indicator';
|
|
2
|
+
const newPackagePath = '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator';
|
|
3
|
+
function isString(value) {
|
|
4
|
+
return typeof value === 'string';
|
|
5
|
+
}
|
|
6
|
+
function isOldPackagePath(value) {
|
|
7
|
+
return isString(value) && value.startsWith(oldPackagePath);
|
|
8
|
+
}
|
|
9
|
+
export function moveToReactDropIndicator(file, api) {
|
|
10
|
+
const j = api.jscodeshift;
|
|
11
|
+
const root = j(file.source);
|
|
12
|
+
const isUsingImport = root.find(j.ImportDeclaration).some(path => isOldPackagePath(path.node.source.value));
|
|
13
|
+
|
|
14
|
+
// Don't format the file if we are not changing anything
|
|
15
|
+
if (!isUsingImport) {
|
|
16
|
+
return file.source;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// replace imports
|
|
20
|
+
root.find(j.ImportDeclaration).forEach(path => {
|
|
21
|
+
const {
|
|
22
|
+
value
|
|
23
|
+
} = path.node.source;
|
|
24
|
+
if (isString(value) && isOldPackagePath(path.node.source.value)) {
|
|
25
|
+
path.node.source.value = value.replace(oldPackagePath, newPackagePath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return root.toSource({
|
|
29
|
+
quote: 'single'
|
|
30
|
+
});
|
|
31
|
+
}
|