@atlaskit/codemod-cli 0.19.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 +8 -0
- 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/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/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/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 +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
3
11
|
## 0.19.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const paths = {
|
|
2
|
+
current: '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer',
|
|
3
|
+
next: '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview'
|
|
4
|
+
};
|
|
5
|
+
export function shiftToPointerOutsideOfPreview(file, api) {
|
|
6
|
+
const j = api.jscodeshift;
|
|
7
|
+
const root = j(file.source);
|
|
8
|
+
const isUsingImport = root.find(j.ImportDeclaration).some(path => path.node.source.value === paths.current);
|
|
9
|
+
|
|
10
|
+
// don't change the file if we don't need to
|
|
11
|
+
if (!isUsingImport) {
|
|
12
|
+
return file.source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// replace old import path with new import path
|
|
16
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value === paths.current)
|
|
17
|
+
// replace import
|
|
18
|
+
.map(path => {
|
|
19
|
+
path.node.source.value = paths.next;
|
|
20
|
+
return path;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// replace old named import and usages with new one
|
|
24
|
+
root.find(j.Identifier).filter(path => path.value.name === 'offsetFromPointer').replaceWith(j.identifier('pointerOutsideOfPreview'));
|
|
25
|
+
return root.toSource({
|
|
26
|
+
quote: 'single'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const paths = {
|
|
2
|
+
current: '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled',
|
|
3
|
+
next: '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled'
|
|
4
|
+
};
|
|
5
|
+
export function shiftToPreventUnhandled(file, api) {
|
|
6
|
+
const j = api.jscodeshift;
|
|
7
|
+
const root = j(file.source);
|
|
8
|
+
const isUsingImport = root.find(j.ImportDeclaration).some(path => path.node.source.value === paths.current);
|
|
9
|
+
|
|
10
|
+
// don't change the file if we don't need to
|
|
11
|
+
if (!isUsingImport) {
|
|
12
|
+
return file.source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// replace old import path with new import path
|
|
16
|
+
root.find(j.ImportDeclaration).filter(path => path.node.source.value === paths.current)
|
|
17
|
+
// replace import
|
|
18
|
+
.map(path => {
|
|
19
|
+
path.node.source.value = paths.next;
|
|
20
|
+
return path;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// replace old named import and usages with new one
|
|
24
|
+
root.find(j.Identifier).filter(path => path.value.name === 'cancelUnhandled').replaceWith(j.identifier('preventUnhandled'));
|
|
25
|
+
return root.toSource({
|
|
26
|
+
quote: 'single'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const importMap = {
|
|
2
|
+
// core package
|
|
3
|
+
'@atlaskit/pragmatic-drag-and-drop/adapter/element': '@atlaskit/pragmatic-drag-and-drop/element/adapter',
|
|
4
|
+
'@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview',
|
|
5
|
+
'@atlaskit/pragmatic-drag-and-drop/util/center-under-pointer': '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer',
|
|
6
|
+
'@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-on-source': '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source',
|
|
7
|
+
'@atlaskit/pragmatic-drag-and-drop/util/disable-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview',
|
|
8
|
+
'@atlaskit/pragmatic-drag-and-drop/util/scroll-just-enough-into-view': '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view',
|
|
9
|
+
'@atlaskit/pragmatic-drag-and-drop/util/combine': '@atlaskit/pragmatic-drag-and-drop/combine',
|
|
10
|
+
'@atlaskit/pragmatic-drag-and-drop/util/once': '@atlaskit/pragmatic-drag-and-drop/once',
|
|
11
|
+
'@atlaskit/pragmatic-drag-and-drop/util/reorder': '@atlaskit/pragmatic-drag-and-drop/reorder',
|
|
12
|
+
// hitbox package
|
|
13
|
+
'@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge': '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'
|
|
14
|
+
|
|
15
|
+
// Doing cancel-unhandled in it's own transformer as the name is changing too
|
|
16
|
+
// '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled':
|
|
17
|
+
// '@atlaskit/pragmatic-drag-and-drop/cancel-unhandled',
|
|
18
|
+
// We are doing the name update in another transform
|
|
19
|
+
// '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
|
|
20
|
+
// '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function updateSafeImports(file, api) {
|
|
24
|
+
const j = api.jscodeshift;
|
|
25
|
+
const root = j(file.source);
|
|
26
|
+
|
|
27
|
+
// avoiding reformatting the file if we are not changing anything
|
|
28
|
+
let changed = false;
|
|
29
|
+
root.find(j.ImportDeclaration).forEach(path => {
|
|
30
|
+
const importPath = path.node.source.value;
|
|
31
|
+
if (typeof importPath === 'string' && importMap[importPath]) {
|
|
32
|
+
changed = true;
|
|
33
|
+
path.node.source.value = importMap[importPath];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!changed) {
|
|
37
|
+
return file.source;
|
|
38
|
+
}
|
|
39
|
+
return root.toSource({
|
|
40
|
+
quote: 'single'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { updateSafeImports } from './transformers/update-safe-imports';
|
|
2
|
+
import { moveFromFileAdapterToExternalAdapter } from './transformers/external-adapter';
|
|
3
|
+
import { moveToReactDropIndicator } from './transformers/move-to-react-drop-indicator';
|
|
4
|
+
import { updateAutoScroll } from './transformers/auto-scroll';
|
|
5
|
+
import { shiftToPointerOutsideOfPreview } from './transformers/pointer-outside-of-preview';
|
|
6
|
+
import { shiftToPreventUnhandled } from './transformers/prevent-unhandled';
|
|
7
|
+
import { shiftCanMonitorArgType } from './transformers/element-adapter-types';
|
|
8
|
+
const transformers = [updateSafeImports, moveFromFileAdapterToExternalAdapter, moveToReactDropIndicator, updateAutoScroll, shiftToPointerOutsideOfPreview, shiftToPreventUnhandled, shiftCanMonitorArgType];
|
|
9
|
+
export default function transformer(file, api) {
|
|
10
|
+
let source = file.source;
|
|
11
|
+
for (const fn of transformers) {
|
|
12
|
+
const updated = {
|
|
13
|
+
...file,
|
|
14
|
+
source
|
|
15
|
+
};
|
|
16
|
+
source = fn(updated, api);
|
|
17
|
+
}
|
|
18
|
+
return source;
|
|
19
|
+
}
|
package/dist/esm/main.js
CHANGED
|
@@ -298,7 +298,7 @@ function _main() {
|
|
|
298
298
|
case 4:
|
|
299
299
|
_yield$parseArgs = _context5.sent;
|
|
300
300
|
packages = _yield$parseArgs.packages;
|
|
301
|
-
_process$env$_PACKAGE = "0.
|
|
301
|
+
_process$env$_PACKAGE = "0.20.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
|
|
302
302
|
logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
|
|
303
303
|
if (packages && packages.length > 0) {
|
|
304
304
|
logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
|
|
@@ -7,7 +7,8 @@ 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
|
+
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-to-new-buttons', 'upgrade-pragmatic-drag-and-drop-to-stable'].map(function (preset) {
|
|
11
12
|
return path.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
12
13
|
});
|
|
13
14
|
export default presets;
|
package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/auto-scroll.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
var scenarios = [{
|
|
5
|
+
existing: {
|
|
6
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/file',
|
|
7
|
+
namedImport: 'autoScrollForFiles'
|
|
8
|
+
},
|
|
9
|
+
updated: {
|
|
10
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/external',
|
|
11
|
+
namedImport: 'autoScrollForExternal'
|
|
12
|
+
}
|
|
13
|
+
}, {
|
|
14
|
+
existing: {
|
|
15
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/file',
|
|
16
|
+
namedImport: 'unsafeOverflowAutoScrollForFiles'
|
|
17
|
+
},
|
|
18
|
+
updated: {
|
|
19
|
+
importPath: '@atlaskit/pragmatic-drag-and-drop-auto-scroll/unsafe-overflow/external',
|
|
20
|
+
namedImport: 'unsafeOverflowAutoScrollForExternal'
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
export function updateAutoScroll(file, api) {
|
|
24
|
+
var j = api.jscodeshift;
|
|
25
|
+
var root = j(file.source);
|
|
26
|
+
var changed = false;
|
|
27
|
+
var _iterator = _createForOfIteratorHelper(scenarios),
|
|
28
|
+
_step;
|
|
29
|
+
try {
|
|
30
|
+
var _loop = function _loop() {
|
|
31
|
+
var scenario = _step.value;
|
|
32
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
33
|
+
return path.node.source.value === scenario.existing.importPath;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// move on to the next scenario
|
|
37
|
+
if (!isUsingImport) {
|
|
38
|
+
return 1; // continue
|
|
39
|
+
}
|
|
40
|
+
changed = true;
|
|
41
|
+
|
|
42
|
+
// replace old import path with new import path
|
|
43
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
44
|
+
return path.node.source.value === scenario.existing.importPath;
|
|
45
|
+
})
|
|
46
|
+
// replace import
|
|
47
|
+
.map(function (path) {
|
|
48
|
+
path.node.source.value = scenario.updated.importPath;
|
|
49
|
+
return path;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// replace old named import and usages with new one
|
|
53
|
+
root.find(j.Identifier).filter(function (path) {
|
|
54
|
+
return path.value.name === scenario.existing.namedImport;
|
|
55
|
+
}).replaceWith(j.identifier(scenario.updated.namedImport));
|
|
56
|
+
};
|
|
57
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
58
|
+
if (_loop()) continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Don't format the file if we are not changing anything
|
|
62
|
+
} catch (err) {
|
|
63
|
+
_iterator.e(err);
|
|
64
|
+
} finally {
|
|
65
|
+
_iterator.f();
|
|
66
|
+
}
|
|
67
|
+
if (!changed) {
|
|
68
|
+
return file.source;
|
|
69
|
+
}
|
|
70
|
+
return root.toSource({
|
|
71
|
+
quote: 'single'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var newImport = '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
2
|
+
export function shiftCanMonitorArgType(file, api) {
|
|
3
|
+
var j = api.jscodeshift;
|
|
4
|
+
var root = j(file.source);
|
|
5
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
6
|
+
return path.node.source.value === newImport;
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// don't change the file if we don't need to
|
|
10
|
+
if (!isUsingImport) {
|
|
11
|
+
return file.source;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// replace old named import and usages with new one
|
|
15
|
+
root.find(j.Identifier).filter(function (path) {
|
|
16
|
+
return path.value.name === 'ElementMonitorCanMonitorArgs';
|
|
17
|
+
}).replaceWith(j.identifier('ElementMonitorGetFeedbackArgs'));
|
|
18
|
+
return root.toSource({
|
|
19
|
+
quote: 'single'
|
|
20
|
+
});
|
|
21
|
+
}
|
package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/external-adapter.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { addCommentToStartOfFile } from '@atlaskit/codemod-utils';
|
|
2
|
+
export var 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";
|
|
3
|
+
var oldImportPath = '@atlaskit/pragmatic-drag-and-drop/adapter/file';
|
|
4
|
+
var newImportPath = '@atlaskit/pragmatic-drag-and-drop/external/adapter';
|
|
5
|
+
export function moveFromFileAdapterToExternalAdapter(file, api) {
|
|
6
|
+
var j = api.jscodeshift;
|
|
7
|
+
var root = j(file.source);
|
|
8
|
+
var isUsingFileAdapter = root.find(j.ImportDeclaration).some(function (path) {
|
|
9
|
+
return path.node.source.value === oldImportPath;
|
|
10
|
+
});
|
|
11
|
+
if (!isUsingFileAdapter) {
|
|
12
|
+
return file.source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// replace old import path with new import path
|
|
16
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
17
|
+
return path.node.source.value === oldImportPath;
|
|
18
|
+
})
|
|
19
|
+
// replace import
|
|
20
|
+
.map(function (path) {
|
|
21
|
+
path.node.source.value = newImportPath;
|
|
22
|
+
return path;
|
|
23
|
+
})
|
|
24
|
+
// Add an import for 'containsFiles()' and `getFiles()` as likely this file will need it
|
|
25
|
+
.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('containsFiles')), j.importSpecifier(j.identifier('getFiles'))], j.literal('@atlaskit/pragmatic-drag-and-drop/external/file')));
|
|
26
|
+
|
|
27
|
+
// update usages of `monitorForFiles` and `dropTargetForFiles`
|
|
28
|
+
root.find(j.Identifier).filter(function (path) {
|
|
29
|
+
return path.value.name === 'monitorForFiles';
|
|
30
|
+
}).replaceWith(j.identifier('monitorForExternal'));
|
|
31
|
+
root.find(j.Identifier).filter(function (path) {
|
|
32
|
+
return path.value.name === 'dropTargetForFiles';
|
|
33
|
+
}).replaceWith(j.identifier('dropTargetForExternal'));
|
|
34
|
+
|
|
35
|
+
// add comment to the start of the file
|
|
36
|
+
addCommentToStartOfFile({
|
|
37
|
+
j: j,
|
|
38
|
+
base: root,
|
|
39
|
+
message: pleaseMigrateMessage
|
|
40
|
+
});
|
|
41
|
+
return root.toSource({
|
|
42
|
+
quote: 'single'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var oldPackagePath = '@atlaskit/pragmatic-drag-and-drop-react-indicator';
|
|
2
|
+
var 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
|
+
var j = api.jscodeshift;
|
|
11
|
+
var root = j(file.source);
|
|
12
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
13
|
+
return isOldPackagePath(path.node.source.value);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Don't format the file if we are not changing anything
|
|
17
|
+
if (!isUsingImport) {
|
|
18
|
+
return file.source;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// replace imports
|
|
22
|
+
root.find(j.ImportDeclaration).forEach(function (path) {
|
|
23
|
+
var value = path.node.source.value;
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var paths = {
|
|
2
|
+
current: '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer',
|
|
3
|
+
next: '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview'
|
|
4
|
+
};
|
|
5
|
+
export function shiftToPointerOutsideOfPreview(file, api) {
|
|
6
|
+
var j = api.jscodeshift;
|
|
7
|
+
var root = j(file.source);
|
|
8
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
9
|
+
return path.node.source.value === paths.current;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// don't change the file if we don't need to
|
|
13
|
+
if (!isUsingImport) {
|
|
14
|
+
return file.source;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// replace old import path with new import path
|
|
18
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
19
|
+
return path.node.source.value === paths.current;
|
|
20
|
+
})
|
|
21
|
+
// replace import
|
|
22
|
+
.map(function (path) {
|
|
23
|
+
path.node.source.value = paths.next;
|
|
24
|
+
return path;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// replace old named import and usages with new one
|
|
28
|
+
root.find(j.Identifier).filter(function (path) {
|
|
29
|
+
return path.value.name === 'offsetFromPointer';
|
|
30
|
+
}).replaceWith(j.identifier('pointerOutsideOfPreview'));
|
|
31
|
+
return root.toSource({
|
|
32
|
+
quote: 'single'
|
|
33
|
+
});
|
|
34
|
+
}
|
package/dist/esm/presets/upgrade-pragmatic-drag-and-drop-to-stable/transformers/prevent-unhandled.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var paths = {
|
|
2
|
+
current: '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled',
|
|
3
|
+
next: '@atlaskit/pragmatic-drag-and-drop/prevent-unhandled'
|
|
4
|
+
};
|
|
5
|
+
export function shiftToPreventUnhandled(file, api) {
|
|
6
|
+
var j = api.jscodeshift;
|
|
7
|
+
var root = j(file.source);
|
|
8
|
+
var isUsingImport = root.find(j.ImportDeclaration).some(function (path) {
|
|
9
|
+
return path.node.source.value === paths.current;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// don't change the file if we don't need to
|
|
13
|
+
if (!isUsingImport) {
|
|
14
|
+
return file.source;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// replace old import path with new import path
|
|
18
|
+
root.find(j.ImportDeclaration).filter(function (path) {
|
|
19
|
+
return path.node.source.value === paths.current;
|
|
20
|
+
})
|
|
21
|
+
// replace import
|
|
22
|
+
.map(function (path) {
|
|
23
|
+
path.node.source.value = paths.next;
|
|
24
|
+
return path;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// replace old named import and usages with new one
|
|
28
|
+
root.find(j.Identifier).filter(function (path) {
|
|
29
|
+
return path.value.name === 'cancelUnhandled';
|
|
30
|
+
}).replaceWith(j.identifier('preventUnhandled'));
|
|
31
|
+
return root.toSource({
|
|
32
|
+
quote: 'single'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var importMap = {
|
|
2
|
+
// core package
|
|
3
|
+
'@atlaskit/pragmatic-drag-and-drop/adapter/element': '@atlaskit/pragmatic-drag-and-drop/element/adapter',
|
|
4
|
+
'@atlaskit/pragmatic-drag-and-drop/util/set-custom-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview',
|
|
5
|
+
'@atlaskit/pragmatic-drag-and-drop/util/center-under-pointer': '@atlaskit/pragmatic-drag-and-drop/element/center-under-pointer',
|
|
6
|
+
'@atlaskit/pragmatic-drag-and-drop/util/preserve-offset-on-source': '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source',
|
|
7
|
+
'@atlaskit/pragmatic-drag-and-drop/util/disable-native-drag-preview': '@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview',
|
|
8
|
+
'@atlaskit/pragmatic-drag-and-drop/util/scroll-just-enough-into-view': '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view',
|
|
9
|
+
'@atlaskit/pragmatic-drag-and-drop/util/combine': '@atlaskit/pragmatic-drag-and-drop/combine',
|
|
10
|
+
'@atlaskit/pragmatic-drag-and-drop/util/once': '@atlaskit/pragmatic-drag-and-drop/once',
|
|
11
|
+
'@atlaskit/pragmatic-drag-and-drop/util/reorder': '@atlaskit/pragmatic-drag-and-drop/reorder',
|
|
12
|
+
// hitbox package
|
|
13
|
+
'@atlaskit/pragmatic-drag-and-drop-hitbox/addon/closest-edge': '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge'
|
|
14
|
+
|
|
15
|
+
// Doing cancel-unhandled in it's own transformer as the name is changing too
|
|
16
|
+
// '@atlaskit/pragmatic-drag-and-drop/addon/cancel-unhandled':
|
|
17
|
+
// '@atlaskit/pragmatic-drag-and-drop/cancel-unhandled',
|
|
18
|
+
// We are doing the name update in another transform
|
|
19
|
+
// '@atlaskit/pragmatic-drag-and-drop/util/offset-from-pointer':
|
|
20
|
+
// '@atlaskit/pragmatic-drag-and-drop/element/offset-from-pointer',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function updateSafeImports(file, api) {
|
|
24
|
+
var j = api.jscodeshift;
|
|
25
|
+
var root = j(file.source);
|
|
26
|
+
|
|
27
|
+
// avoiding reformatting the file if we are not changing anything
|
|
28
|
+
var changed = false;
|
|
29
|
+
root.find(j.ImportDeclaration).forEach(function (path) {
|
|
30
|
+
var importPath = path.node.source.value;
|
|
31
|
+
if (typeof importPath === 'string' && importMap[importPath]) {
|
|
32
|
+
changed = true;
|
|
33
|
+
path.node.source.value = importMap[importPath];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (!changed) {
|
|
37
|
+
return file.source;
|
|
38
|
+
}
|
|
39
|
+
return root.toSource({
|
|
40
|
+
quote: 'single'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
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; } } }; }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
import { updateSafeImports } from './transformers/update-safe-imports';
|
|
8
|
+
import { moveFromFileAdapterToExternalAdapter } from './transformers/external-adapter';
|
|
9
|
+
import { moveToReactDropIndicator } from './transformers/move-to-react-drop-indicator';
|
|
10
|
+
import { updateAutoScroll } from './transformers/auto-scroll';
|
|
11
|
+
import { shiftToPointerOutsideOfPreview } from './transformers/pointer-outside-of-preview';
|
|
12
|
+
import { shiftToPreventUnhandled } from './transformers/prevent-unhandled';
|
|
13
|
+
import { shiftCanMonitorArgType } from './transformers/element-adapter-types';
|
|
14
|
+
var transformers = [updateSafeImports, moveFromFileAdapterToExternalAdapter, moveToReactDropIndicator, updateAutoScroll, shiftToPointerOutsideOfPreview, shiftToPreventUnhandled, shiftCanMonitorArgType];
|
|
15
|
+
export default function transformer(file, api) {
|
|
16
|
+
var source = file.source;
|
|
17
|
+
var _iterator = _createForOfIteratorHelper(transformers),
|
|
18
|
+
_step;
|
|
19
|
+
try {
|
|
20
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
21
|
+
var fn = _step.value;
|
|
22
|
+
var updated = _objectSpread(_objectSpread({}, file), {}, {
|
|
23
|
+
source: source
|
|
24
|
+
});
|
|
25
|
+
source = fn(updated, api);
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
_iterator.e(err);
|
|
29
|
+
} finally {
|
|
30
|
+
_iterator.f();
|
|
31
|
+
}
|
|
32
|
+
return source;
|
|
33
|
+
}
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
import './styled-to-emotion/styled-to-emotion';
|
|
6
6
|
import './theme-remove-deprecated-mixins/theme-remove-deprecated-mixins';
|
|
7
7
|
import './migrate-to-new-buttons/migrate-to-new-buttons';
|
|
8
|
+
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
8
9
|
declare const presets: string[];
|
|
9
10
|
export default presets;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { API, FileInfo } from 'jscodeshift';
|
|
2
|
+
export declare const 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";
|
|
3
|
+
export declare function moveFromFileAdapterToExternalAdapter(file: FileInfo, api: API): string;
|
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
import './styled-to-emotion/styled-to-emotion';
|
|
6
6
|
import './theme-remove-deprecated-mixins/theme-remove-deprecated-mixins';
|
|
7
7
|
import './migrate-to-new-buttons/migrate-to-new-buttons';
|
|
8
|
+
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
8
9
|
declare const presets: string[];
|
|
9
10
|
export default presets;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { API, FileInfo } from 'jscodeshift';
|
|
2
|
+
export declare const 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";
|
|
3
|
+
export declare function moveFromFileAdapterToExternalAdapter(file: FileInfo, api: API): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "A cli for distributing codemods for atlassian-frontend components and services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"bin": "./bin/codemod-cli.js",
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
43
|
-
"@atlaskit/tokens": "^1.
|
|
43
|
+
"@atlaskit/tokens": "^1.38.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@codeshift/utils": "^0.2.4",
|
|
46
46
|
"@types/jscodeshift": "^0.11.0",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
58
|
+
"prettier": "^2.8.0",
|
|
58
59
|
"ts-node": "^10.9.1",
|
|
59
60
|
"typescript": "~4.9.5"
|
|
60
61
|
},
|