@atlaskit/codemod-cli 0.33.0 → 0.33.2
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/main.js +1 -1
- package/dist/cjs/presets/index.js +2 -1
- package/dist/cjs/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +142 -0
- package/dist/cjs/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +44 -0
- package/dist/cjs/presets/migrate-deprecated-icon/utils/mock.js +81 -0
- package/dist/es2019/presets/index.js +2 -1
- package/dist/es2019/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +130 -0
- package/dist/es2019/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +18 -0
- package/dist/es2019/presets/migrate-deprecated-icon/utils/mock.js +75 -0
- package/dist/esm/main.js +1 -1
- package/dist/esm/presets/index.js +2 -1
- package/dist/esm/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +135 -0
- package/dist/esm/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +37 -0
- package/dist/esm/presets/migrate-deprecated-icon/utils/mock.js +75 -0
- package/dist/types/presets/index.d.ts +1 -0
- package/dist/types/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.d.ts +3 -0
- package/dist/types/presets/migrate-deprecated-icon/migrate-deprecated-icon.d.ts +2 -0
- package/dist/types-ts4.5/presets/index.d.ts +1 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.d.ts +3 -0
- package/dist/types-ts4.5/presets/migrate-deprecated-icon/migrate-deprecated-icon.d.ts +2 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/codemod-cli
|
|
2
2
|
|
|
3
|
+
## 0.33.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`036c3ee917e3c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/036c3ee917e3c) -
|
|
8
|
+
Icon migration entry point update
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 0.33.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 0.33.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/cjs/main.js
CHANGED
|
@@ -362,7 +362,7 @@ function _main() {
|
|
|
362
362
|
case 4:
|
|
363
363
|
_yield$parseArgs = _context6.sent;
|
|
364
364
|
packages = _yield$parseArgs.packages;
|
|
365
|
-
_process$env$_PACKAGE = "0.33.
|
|
365
|
+
_process$env$_PACKAGE = "0.33.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
|
|
366
366
|
logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
|
|
367
367
|
if (packages && packages.length > 0) {
|
|
368
368
|
logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
|
|
@@ -18,12 +18,13 @@ require("./lozenge-appearance-semantic-migration/lozenge-appearance-semantic-mig
|
|
|
18
18
|
require("./lozenge-to-tag-migration/lozenge-to-tag-migration");
|
|
19
19
|
require("./badge-appearance-semantic-migration/badge-appearance-semantic-migration");
|
|
20
20
|
require("./tag-to-newTag-migration/tag-to-newTag-migration");
|
|
21
|
+
require("./migrate-deprecated-icon/migrate-deprecated-icon");
|
|
21
22
|
/**
|
|
22
23
|
* Manually import presets to make sure typescript includes them
|
|
23
24
|
* in the final bundle.
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
|
-
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-to-link', 'migrate-to-new-buttons', 'migrate-icon-object-to-object', 'upgrade-pragmatic-drag-and-drop-to-stable', 'remove-dark-theme-vr-options', 'remove-token-fallbacks', 'lozenge-appearance-semantic-migration', 'lozenge-to-tag-migration', 'badge-appearance-semantic-migration', 'tag-to-newTag-migration'].map(function (preset) {
|
|
27
|
+
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-deprecated-icon', 'migrate-to-link', 'migrate-to-new-buttons', 'migrate-icon-object-to-object', 'upgrade-pragmatic-drag-and-drop-to-stable', 'remove-dark-theme-vr-options', 'remove-token-fallbacks', 'lozenge-appearance-semantic-migration', 'lozenge-to-tag-migration', 'badge-appearance-semantic-migration', 'tag-to-newTag-migration'].map(function (preset) {
|
|
27
28
|
return _path.default.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
28
29
|
});
|
|
29
30
|
var _default = exports.default = presets;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _deprecatedMap = require("@atlaskit/icon-lab/deprecated-map");
|
|
9
|
+
var _metadata = _interopRequireDefault(require("@atlaskit/icon-lab/metadata"));
|
|
10
|
+
var _deprecatedMap2 = require("@atlaskit/icon/deprecated-map");
|
|
11
|
+
var _metadata2 = require("@atlaskit/icon/metadata");
|
|
12
|
+
/* eslint-disable @repo/internal/fs/filename-pattern-match */
|
|
13
|
+
|
|
14
|
+
var extractIconName = function extractIconName(importPath) {
|
|
15
|
+
var match = importPath.match(/\/([^\/]+)$/);
|
|
16
|
+
return match ? match[1] : '';
|
|
17
|
+
};
|
|
18
|
+
var getIconComponentName = function getIconComponentName(name) {
|
|
19
|
+
return name.split(/\W/).map(function (part) {
|
|
20
|
+
return "".concat(part[0].toUpperCase()).concat(part.slice(1));
|
|
21
|
+
}).join('').concat('Icon');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new default import declaration for the transformed component
|
|
26
|
+
*/
|
|
27
|
+
var createDefaultImportDeclaration = function createDefaultImportDeclaration(j, componentName, importPath) {
|
|
28
|
+
var defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
|
|
29
|
+
return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
|
|
30
|
+
};
|
|
31
|
+
var PRINT_SETTINGS = {
|
|
32
|
+
quote: 'single',
|
|
33
|
+
trailingComma: true
|
|
34
|
+
};
|
|
35
|
+
var transformer = function transformer(file, api) {
|
|
36
|
+
var j = api.jscodeshift;
|
|
37
|
+
var fileSource = j(file.source);
|
|
38
|
+
var deprecatedIcons = Object.keys(_deprecatedMap2.deprecatedCore);
|
|
39
|
+
var deprecatedIconLabIcons = Object.keys(_deprecatedMap.deprecatedCore);
|
|
40
|
+
|
|
41
|
+
// Find all deprecated icon imports
|
|
42
|
+
var deprecatedIconImports = fileSource.find(j.ImportDeclaration).filter(function (path) {
|
|
43
|
+
var _coreIconMetadata$ico, _coreIconLabMetadata$;
|
|
44
|
+
var source = path.node.source.value;
|
|
45
|
+
|
|
46
|
+
//Extract icon name from import path
|
|
47
|
+
var iconName = extractIconName(source);
|
|
48
|
+
var isDeprecated = deprecatedIcons.includes(source) || deprecatedIconLabIcons.includes(source);
|
|
49
|
+
var hasReplacement = !!((_coreIconMetadata$ico = _metadata2.coreIconMetadata[iconName]) !== null && _coreIconMetadata$ico !== void 0 && _coreIconMetadata$ico.replacement) || !!((_coreIconLabMetadata$ = _metadata.default[iconName]) !== null && _coreIconLabMetadata$ !== void 0 && _coreIconLabMetadata$.replacement);
|
|
50
|
+
return typeof source === 'string' && isDeprecated && hasReplacement;
|
|
51
|
+
});
|
|
52
|
+
if (!deprecatedIconImports.length) {
|
|
53
|
+
return fileSource.toSource();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Track import name mappings (old name -> new name) and new imports to create
|
|
57
|
+
var importNameMappings = new Map();
|
|
58
|
+
var newImportsToCreate = [];
|
|
59
|
+
|
|
60
|
+
// Process each icon-object import
|
|
61
|
+
deprecatedIconImports.forEach(function (importPath) {
|
|
62
|
+
var _coreIconMetadata$ico2, _coreIconMetadata$ico3, _coreIconLabMetadata$2, _importDeclaration$sp;
|
|
63
|
+
var importDeclaration = importPath.node;
|
|
64
|
+
var source = importDeclaration.source.value;
|
|
65
|
+
|
|
66
|
+
//Extract icon name from import path
|
|
67
|
+
var iconName = extractIconName(source);
|
|
68
|
+
var replacementIconInfo = (_coreIconMetadata$ico2 = (_coreIconMetadata$ico3 = _metadata2.coreIconMetadata[iconName]) === null || _coreIconMetadata$ico3 === void 0 ? void 0 : _coreIconMetadata$ico3.replacement) !== null && _coreIconMetadata$ico2 !== void 0 ? _coreIconMetadata$ico2 : (_coreIconLabMetadata$2 = _metadata.default[iconName]) === null || _coreIconLabMetadata$2 === void 0 ? void 0 : _coreIconLabMetadata$2.replacement;
|
|
69
|
+
if (!replacementIconInfo) {
|
|
70
|
+
return; // No replacement found, skip
|
|
71
|
+
}
|
|
72
|
+
var replacementIconName = getIconComponentName(replacementIconInfo.name);
|
|
73
|
+
var replacementIconImport = "".concat(replacementIconInfo.location, "/core/").concat(replacementIconInfo.name);
|
|
74
|
+
|
|
75
|
+
// Get the current import name (could be default import or renamed)
|
|
76
|
+
var defaultSpecifier = (_importDeclaration$sp = importDeclaration.specifiers) === null || _importDeclaration$sp === void 0 ? void 0 : _importDeclaration$sp.find(function (spec) {
|
|
77
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
78
|
+
});
|
|
79
|
+
if (defaultSpecifier) {
|
|
80
|
+
var _defaultSpecifier$loc;
|
|
81
|
+
var currentImportName = (_defaultSpecifier$loc = defaultSpecifier.local) === null || _defaultSpecifier$loc === void 0 ? void 0 : _defaultSpecifier$loc.name;
|
|
82
|
+
if (currentImportName) {
|
|
83
|
+
// Map the old import name to the new component name
|
|
84
|
+
importNameMappings.set(currentImportName, replacementIconName);
|
|
85
|
+
|
|
86
|
+
// Track the new import to create
|
|
87
|
+
newImportsToCreate.push({
|
|
88
|
+
componentName: replacementIconName,
|
|
89
|
+
importPath: replacementIconImport,
|
|
90
|
+
oldImportPath: importPath
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Update JSX elements to use new component names
|
|
97
|
+
importNameMappings.forEach(function (newName, oldName) {
|
|
98
|
+
fileSource.find(j.JSXElement).filter(function (path) {
|
|
99
|
+
var openingElement = path.value.openingElement;
|
|
100
|
+
return openingElement.name.type === 'JSXIdentifier' && openingElement.name.name === oldName;
|
|
101
|
+
}).forEach(function (elementPath) {
|
|
102
|
+
var _element$closingEleme;
|
|
103
|
+
var element = elementPath.value;
|
|
104
|
+
|
|
105
|
+
// Update opening tag
|
|
106
|
+
if (element.openingElement.name.type === 'JSXIdentifier') {
|
|
107
|
+
element.openingElement.name.name = newName;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Update closing tag if it exists
|
|
111
|
+
if (((_element$closingEleme = element.closingElement) === null || _element$closingEleme === void 0 ? void 0 : _element$closingEleme.name.type) === 'JSXIdentifier') {
|
|
112
|
+
element.closingElement.name.name = newName;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Update other references (like in render calls, etc.)
|
|
118
|
+
importNameMappings.forEach(function (newName, oldName) {
|
|
119
|
+
fileSource.find(j.Identifier).filter(function (path) {
|
|
120
|
+
return path.node.name === oldName;
|
|
121
|
+
}).forEach(function (path) {
|
|
122
|
+
var _parent$value, _parent$value2;
|
|
123
|
+
// Only update if it's not part of an import declaration or JSX element
|
|
124
|
+
// (those are handled separately)
|
|
125
|
+
var parent = path.parent;
|
|
126
|
+
if ((parent === null || parent === void 0 || (_parent$value = parent.value) === null || _parent$value === void 0 ? void 0 : _parent$value.type) !== 'ImportDefaultSpecifier' && (parent === null || parent === void 0 || (_parent$value2 = parent.value) === null || _parent$value2 === void 0 ? void 0 : _parent$value2.type) !== 'JSXIdentifier') {
|
|
127
|
+
path.node.name = newName;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Create new individual default imports
|
|
133
|
+
newImportsToCreate.forEach(function (_ref) {
|
|
134
|
+
var componentName = _ref.componentName,
|
|
135
|
+
importPath = _ref.importPath,
|
|
136
|
+
oldImportPath = _ref.oldImportPath;
|
|
137
|
+
var newImport = createDefaultImportDeclaration(j, componentName, importPath);
|
|
138
|
+
oldImportPath.replace(newImport);
|
|
139
|
+
});
|
|
140
|
+
return fileSource.toSource(PRINT_SETTINGS);
|
|
141
|
+
};
|
|
142
|
+
var _default = exports.default = transformer;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _migrateDeprecatedIcon = _interopRequireDefault(require("./codemods/migrate-deprecated-icon"));
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function transformer(_x, _x2) {
|
|
15
|
+
return _transformer.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _transformer() {
|
|
18
|
+
_transformer = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(file, api) {
|
|
19
|
+
var transformers, src;
|
|
20
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
transformers = [_migrateDeprecatedIcon.default];
|
|
24
|
+
src = file.source;
|
|
25
|
+
transformers.forEach(function (transformer) {
|
|
26
|
+
if (typeof src === 'undefined') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var nextSrc = transformer(_objectSpread(_objectSpread({}, file), {}, {
|
|
30
|
+
source: src
|
|
31
|
+
}), api);
|
|
32
|
+
if (nextSrc) {
|
|
33
|
+
src = nextSrc;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return _context.abrupt("return", src);
|
|
37
|
+
case 4:
|
|
38
|
+
case "end":
|
|
39
|
+
return _context.stop();
|
|
40
|
+
}
|
|
41
|
+
}, _callee);
|
|
42
|
+
}));
|
|
43
|
+
return _transformer.apply(this, arguments);
|
|
44
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mockMetadata = exports.mockDeprecatedIcons = void 0;
|
|
7
|
+
var mockMetadata = exports.mockMetadata = {
|
|
8
|
+
coreIconMetadata: {
|
|
9
|
+
capture: {
|
|
10
|
+
keywords: ['capture', 'icon', 'focus', 'focus area', 'capture'],
|
|
11
|
+
componentName: 'CaptureIcon',
|
|
12
|
+
package: '@atlaskit/icon/core/capture',
|
|
13
|
+
oldName: ['jira/capture'],
|
|
14
|
+
replacement: {
|
|
15
|
+
name: 'focus-area',
|
|
16
|
+
location: '@atlaskit/icon'
|
|
17
|
+
},
|
|
18
|
+
categorization: 'single-purpose',
|
|
19
|
+
usage: 'Reserved for representing Focus Areas.',
|
|
20
|
+
team: 'Design System Team',
|
|
21
|
+
status: 'deprecated'
|
|
22
|
+
},
|
|
23
|
+
'chart-matrix': {
|
|
24
|
+
keywords: ['chart-matrix', 'chartmatrix', 'icon', 'dot chart', 'graph', 'matrix', ''],
|
|
25
|
+
componentName: 'ChartMatrixIcon',
|
|
26
|
+
package: '@atlaskit/icon/core/chart-matrix',
|
|
27
|
+
replacement: {
|
|
28
|
+
name: 'chart-bubble',
|
|
29
|
+
location: '@atlaskit/icon'
|
|
30
|
+
},
|
|
31
|
+
categorization: 'multi-purpose',
|
|
32
|
+
usage: 'Multi purpose - Known uses: Matrix view in in JPD, and other matrix charts.',
|
|
33
|
+
team: 'Design System Team',
|
|
34
|
+
status: 'deprecated'
|
|
35
|
+
},
|
|
36
|
+
close: {
|
|
37
|
+
keywords: ['close', 'icon', 'cross', 'x', 'close', 'remove'],
|
|
38
|
+
componentName: 'CloseIcon',
|
|
39
|
+
package: '@atlaskit/icon/core/close',
|
|
40
|
+
oldName: ['cross', 'editor/close'],
|
|
41
|
+
replacement: {
|
|
42
|
+
name: 'cross',
|
|
43
|
+
location: '@atlaskit/icon'
|
|
44
|
+
},
|
|
45
|
+
categorization: 'multi-purpose',
|
|
46
|
+
usage: 'Known uses: closing modals, panels, and transient views; removing tags',
|
|
47
|
+
team: 'Design System Team',
|
|
48
|
+
status: 'deprecated'
|
|
49
|
+
},
|
|
50
|
+
error: {
|
|
51
|
+
keywords: ['error', 'warning', 'alert', 'icon', 'filled', 'status', 'danger', 'exclamation', '!', 'error'],
|
|
52
|
+
componentName: 'ErrorIcon',
|
|
53
|
+
package: '@atlaskit/icon/core/error',
|
|
54
|
+
oldName: ['error'],
|
|
55
|
+
replacement: {
|
|
56
|
+
name: 'status-error',
|
|
57
|
+
location: '@atlaskit/icon'
|
|
58
|
+
},
|
|
59
|
+
categorization: 'single-purpose',
|
|
60
|
+
usage: 'Reserved for error statuses and messaging. Filled status icons provide higher visual contrast to draw attention to important information.',
|
|
61
|
+
team: 'Design System Team',
|
|
62
|
+
status: 'deprecated'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var mockDeprecatedIcons = exports.mockDeprecatedIcons = {
|
|
67
|
+
deprecatedCore: {
|
|
68
|
+
'@atlaskit/icon/core/capture': {
|
|
69
|
+
message: 'The icon "capture" is deprecated in favour of "focus-area" from "@atlaskit/icon/core"'
|
|
70
|
+
},
|
|
71
|
+
'@atlaskit/icon/core/chart-matrix': {
|
|
72
|
+
message: 'The icon "chart-matrix" is deprecated in favour of "chart-bubble" from "@atlaskit/icon/core"'
|
|
73
|
+
},
|
|
74
|
+
'@atlaskit/icon/core/close': {
|
|
75
|
+
message: 'The icon "close" is deprecated in favour of "cross" from "@atlaskit/icon/core"'
|
|
76
|
+
},
|
|
77
|
+
'@atlaskit/icon/core/error': {
|
|
78
|
+
message: 'The icon "error" is deprecated in favour of "status-error" from "@atlaskit/icon/core"'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
@@ -16,5 +16,6 @@ import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migr
|
|
|
16
16
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
17
17
|
import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
|
|
18
18
|
import './tag-to-newTag-migration/tag-to-newTag-migration';
|
|
19
|
-
|
|
19
|
+
import './migrate-deprecated-icon/migrate-deprecated-icon';
|
|
20
|
+
const presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-deprecated-icon', 'migrate-to-link', 'migrate-to-new-buttons', 'migrate-icon-object-to-object', 'upgrade-pragmatic-drag-and-drop-to-stable', 'remove-dark-theme-vr-options', 'remove-token-fallbacks', 'lozenge-appearance-semantic-migration', 'lozenge-to-tag-migration', 'badge-appearance-semantic-migration', 'tag-to-newTag-migration'].map(preset => path.join(__dirname, preset, `${preset}.@(ts|js|tsx)`));
|
|
20
21
|
export default presets;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/fs/filename-pattern-match */
|
|
2
|
+
|
|
3
|
+
import { deprecatedCore as deprecatedIconLabCore } from '@atlaskit/icon-lab/deprecated-map';
|
|
4
|
+
import coreIconLabMetadata from '@atlaskit/icon-lab/metadata';
|
|
5
|
+
import { deprecatedCore as deprecatedIconCore } from '@atlaskit/icon/deprecated-map';
|
|
6
|
+
import { coreIconMetadata } from '@atlaskit/icon/metadata';
|
|
7
|
+
const extractIconName = importPath => {
|
|
8
|
+
const match = importPath.match(/\/([^\/]+)$/);
|
|
9
|
+
return match ? match[1] : '';
|
|
10
|
+
};
|
|
11
|
+
const getIconComponentName = name => {
|
|
12
|
+
return name.split(/\W/).map(part => `${part[0].toUpperCase()}${part.slice(1)}`).join('').concat('Icon');
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new default import declaration for the transformed component
|
|
17
|
+
*/
|
|
18
|
+
const createDefaultImportDeclaration = (j, componentName, importPath) => {
|
|
19
|
+
const defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
|
|
20
|
+
return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
|
|
21
|
+
};
|
|
22
|
+
const PRINT_SETTINGS = {
|
|
23
|
+
quote: 'single',
|
|
24
|
+
trailingComma: true
|
|
25
|
+
};
|
|
26
|
+
const transformer = (file, api) => {
|
|
27
|
+
const j = api.jscodeshift;
|
|
28
|
+
const fileSource = j(file.source);
|
|
29
|
+
const deprecatedIcons = Object.keys(deprecatedIconCore);
|
|
30
|
+
const deprecatedIconLabIcons = Object.keys(deprecatedIconLabCore);
|
|
31
|
+
|
|
32
|
+
// Find all deprecated icon imports
|
|
33
|
+
const deprecatedIconImports = fileSource.find(j.ImportDeclaration).filter(path => {
|
|
34
|
+
var _coreIconMetadata$ico, _coreIconLabMetadata$;
|
|
35
|
+
const source = path.node.source.value;
|
|
36
|
+
|
|
37
|
+
//Extract icon name from import path
|
|
38
|
+
const iconName = extractIconName(source);
|
|
39
|
+
const isDeprecated = deprecatedIcons.includes(source) || deprecatedIconLabIcons.includes(source);
|
|
40
|
+
const hasReplacement = !!((_coreIconMetadata$ico = coreIconMetadata[iconName]) !== null && _coreIconMetadata$ico !== void 0 && _coreIconMetadata$ico.replacement) || !!((_coreIconLabMetadata$ = coreIconLabMetadata[iconName]) !== null && _coreIconLabMetadata$ !== void 0 && _coreIconLabMetadata$.replacement);
|
|
41
|
+
return typeof source === 'string' && isDeprecated && hasReplacement;
|
|
42
|
+
});
|
|
43
|
+
if (!deprecatedIconImports.length) {
|
|
44
|
+
return fileSource.toSource();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Track import name mappings (old name -> new name) and new imports to create
|
|
48
|
+
const importNameMappings = new Map();
|
|
49
|
+
const newImportsToCreate = [];
|
|
50
|
+
|
|
51
|
+
// Process each icon-object import
|
|
52
|
+
deprecatedIconImports.forEach(importPath => {
|
|
53
|
+
var _coreIconMetadata$ico2, _coreIconMetadata$ico3, _coreIconLabMetadata$2, _importDeclaration$sp;
|
|
54
|
+
const importDeclaration = importPath.node;
|
|
55
|
+
const source = importDeclaration.source.value;
|
|
56
|
+
|
|
57
|
+
//Extract icon name from import path
|
|
58
|
+
const iconName = extractIconName(source);
|
|
59
|
+
const replacementIconInfo = (_coreIconMetadata$ico2 = (_coreIconMetadata$ico3 = coreIconMetadata[iconName]) === null || _coreIconMetadata$ico3 === void 0 ? void 0 : _coreIconMetadata$ico3.replacement) !== null && _coreIconMetadata$ico2 !== void 0 ? _coreIconMetadata$ico2 : (_coreIconLabMetadata$2 = coreIconLabMetadata[iconName]) === null || _coreIconLabMetadata$2 === void 0 ? void 0 : _coreIconLabMetadata$2.replacement;
|
|
60
|
+
if (!replacementIconInfo) {
|
|
61
|
+
return; // No replacement found, skip
|
|
62
|
+
}
|
|
63
|
+
const replacementIconName = getIconComponentName(replacementIconInfo.name);
|
|
64
|
+
const replacementIconImport = `${replacementIconInfo.location}/core/${replacementIconInfo.name}`;
|
|
65
|
+
|
|
66
|
+
// Get the current import name (could be default import or renamed)
|
|
67
|
+
const defaultSpecifier = (_importDeclaration$sp = importDeclaration.specifiers) === null || _importDeclaration$sp === void 0 ? void 0 : _importDeclaration$sp.find(spec => spec.type === 'ImportDefaultSpecifier');
|
|
68
|
+
if (defaultSpecifier) {
|
|
69
|
+
var _defaultSpecifier$loc;
|
|
70
|
+
const currentImportName = (_defaultSpecifier$loc = defaultSpecifier.local) === null || _defaultSpecifier$loc === void 0 ? void 0 : _defaultSpecifier$loc.name;
|
|
71
|
+
if (currentImportName) {
|
|
72
|
+
// Map the old import name to the new component name
|
|
73
|
+
importNameMappings.set(currentImportName, replacementIconName);
|
|
74
|
+
|
|
75
|
+
// Track the new import to create
|
|
76
|
+
newImportsToCreate.push({
|
|
77
|
+
componentName: replacementIconName,
|
|
78
|
+
importPath: replacementIconImport,
|
|
79
|
+
oldImportPath: importPath
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Update JSX elements to use new component names
|
|
86
|
+
importNameMappings.forEach((newName, oldName) => {
|
|
87
|
+
fileSource.find(j.JSXElement).filter(path => {
|
|
88
|
+
const openingElement = path.value.openingElement;
|
|
89
|
+
return openingElement.name.type === 'JSXIdentifier' && openingElement.name.name === oldName;
|
|
90
|
+
}).forEach(elementPath => {
|
|
91
|
+
var _element$closingEleme;
|
|
92
|
+
const element = elementPath.value;
|
|
93
|
+
|
|
94
|
+
// Update opening tag
|
|
95
|
+
if (element.openingElement.name.type === 'JSXIdentifier') {
|
|
96
|
+
element.openingElement.name.name = newName;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Update closing tag if it exists
|
|
100
|
+
if (((_element$closingEleme = element.closingElement) === null || _element$closingEleme === void 0 ? void 0 : _element$closingEleme.name.type) === 'JSXIdentifier') {
|
|
101
|
+
element.closingElement.name.name = newName;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Update other references (like in render calls, etc.)
|
|
107
|
+
importNameMappings.forEach((newName, oldName) => {
|
|
108
|
+
fileSource.find(j.Identifier).filter(path => path.node.name === oldName).forEach(path => {
|
|
109
|
+
var _parent$value, _parent$value2;
|
|
110
|
+
// Only update if it's not part of an import declaration or JSX element
|
|
111
|
+
// (those are handled separately)
|
|
112
|
+
const parent = path.parent;
|
|
113
|
+
if ((parent === null || parent === void 0 ? void 0 : (_parent$value = parent.value) === null || _parent$value === void 0 ? void 0 : _parent$value.type) !== 'ImportDefaultSpecifier' && (parent === null || parent === void 0 ? void 0 : (_parent$value2 = parent.value) === null || _parent$value2 === void 0 ? void 0 : _parent$value2.type) !== 'JSXIdentifier') {
|
|
114
|
+
path.node.name = newName;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Create new individual default imports
|
|
120
|
+
newImportsToCreate.forEach(({
|
|
121
|
+
componentName,
|
|
122
|
+
importPath,
|
|
123
|
+
oldImportPath
|
|
124
|
+
}) => {
|
|
125
|
+
const newImport = createDefaultImportDeclaration(j, componentName, importPath);
|
|
126
|
+
oldImportPath.replace(newImport);
|
|
127
|
+
});
|
|
128
|
+
return fileSource.toSource(PRINT_SETTINGS);
|
|
129
|
+
};
|
|
130
|
+
export default transformer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import migrateDeprecatedIconTransformer from './codemods/migrate-deprecated-icon';
|
|
2
|
+
export default async function transformer(file, api) {
|
|
3
|
+
const transformers = [migrateDeprecatedIconTransformer];
|
|
4
|
+
let src = file.source;
|
|
5
|
+
transformers.forEach(transformer => {
|
|
6
|
+
if (typeof src === 'undefined') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const nextSrc = transformer({
|
|
10
|
+
...file,
|
|
11
|
+
source: src
|
|
12
|
+
}, api);
|
|
13
|
+
if (nextSrc) {
|
|
14
|
+
src = nextSrc;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return src;
|
|
18
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const mockMetadata = {
|
|
2
|
+
coreIconMetadata: {
|
|
3
|
+
capture: {
|
|
4
|
+
keywords: ['capture', 'icon', 'focus', 'focus area', 'capture'],
|
|
5
|
+
componentName: 'CaptureIcon',
|
|
6
|
+
package: '@atlaskit/icon/core/capture',
|
|
7
|
+
oldName: ['jira/capture'],
|
|
8
|
+
replacement: {
|
|
9
|
+
name: 'focus-area',
|
|
10
|
+
location: '@atlaskit/icon'
|
|
11
|
+
},
|
|
12
|
+
categorization: 'single-purpose',
|
|
13
|
+
usage: 'Reserved for representing Focus Areas.',
|
|
14
|
+
team: 'Design System Team',
|
|
15
|
+
status: 'deprecated'
|
|
16
|
+
},
|
|
17
|
+
'chart-matrix': {
|
|
18
|
+
keywords: ['chart-matrix', 'chartmatrix', 'icon', 'dot chart', 'graph', 'matrix', ''],
|
|
19
|
+
componentName: 'ChartMatrixIcon',
|
|
20
|
+
package: '@atlaskit/icon/core/chart-matrix',
|
|
21
|
+
replacement: {
|
|
22
|
+
name: 'chart-bubble',
|
|
23
|
+
location: '@atlaskit/icon'
|
|
24
|
+
},
|
|
25
|
+
categorization: 'multi-purpose',
|
|
26
|
+
usage: 'Multi purpose - Known uses: Matrix view in in JPD, and other matrix charts.',
|
|
27
|
+
team: 'Design System Team',
|
|
28
|
+
status: 'deprecated'
|
|
29
|
+
},
|
|
30
|
+
close: {
|
|
31
|
+
keywords: ['close', 'icon', 'cross', 'x', 'close', 'remove'],
|
|
32
|
+
componentName: 'CloseIcon',
|
|
33
|
+
package: '@atlaskit/icon/core/close',
|
|
34
|
+
oldName: ['cross', 'editor/close'],
|
|
35
|
+
replacement: {
|
|
36
|
+
name: 'cross',
|
|
37
|
+
location: '@atlaskit/icon'
|
|
38
|
+
},
|
|
39
|
+
categorization: 'multi-purpose',
|
|
40
|
+
usage: 'Known uses: closing modals, panels, and transient views; removing tags',
|
|
41
|
+
team: 'Design System Team',
|
|
42
|
+
status: 'deprecated'
|
|
43
|
+
},
|
|
44
|
+
error: {
|
|
45
|
+
keywords: ['error', 'warning', 'alert', 'icon', 'filled', 'status', 'danger', 'exclamation', '!', 'error'],
|
|
46
|
+
componentName: 'ErrorIcon',
|
|
47
|
+
package: '@atlaskit/icon/core/error',
|
|
48
|
+
oldName: ['error'],
|
|
49
|
+
replacement: {
|
|
50
|
+
name: 'status-error',
|
|
51
|
+
location: '@atlaskit/icon'
|
|
52
|
+
},
|
|
53
|
+
categorization: 'single-purpose',
|
|
54
|
+
usage: 'Reserved for error statuses and messaging. Filled status icons provide higher visual contrast to draw attention to important information.',
|
|
55
|
+
team: 'Design System Team',
|
|
56
|
+
status: 'deprecated'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export const mockDeprecatedIcons = {
|
|
61
|
+
deprecatedCore: {
|
|
62
|
+
'@atlaskit/icon/core/capture': {
|
|
63
|
+
message: 'The icon "capture" is deprecated in favour of "focus-area" from "@atlaskit/icon/core"'
|
|
64
|
+
},
|
|
65
|
+
'@atlaskit/icon/core/chart-matrix': {
|
|
66
|
+
message: 'The icon "chart-matrix" is deprecated in favour of "chart-bubble" from "@atlaskit/icon/core"'
|
|
67
|
+
},
|
|
68
|
+
'@atlaskit/icon/core/close': {
|
|
69
|
+
message: 'The icon "close" is deprecated in favour of "cross" from "@atlaskit/icon/core"'
|
|
70
|
+
},
|
|
71
|
+
'@atlaskit/icon/core/error': {
|
|
72
|
+
message: 'The icon "error" is deprecated in favour of "status-error" from "@atlaskit/icon/core"'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
package/dist/esm/main.js
CHANGED
|
@@ -355,7 +355,7 @@ function _main() {
|
|
|
355
355
|
case 4:
|
|
356
356
|
_yield$parseArgs = _context6.sent;
|
|
357
357
|
packages = _yield$parseArgs.packages;
|
|
358
|
-
_process$env$_PACKAGE = "0.33.
|
|
358
|
+
_process$env$_PACKAGE = "0.33.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
|
|
359
359
|
logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
|
|
360
360
|
if (packages && packages.length > 0) {
|
|
361
361
|
logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
|
|
@@ -16,7 +16,8 @@ import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migr
|
|
|
16
16
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
17
17
|
import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
|
|
18
18
|
import './tag-to-newTag-migration/tag-to-newTag-migration';
|
|
19
|
-
|
|
19
|
+
import './migrate-deprecated-icon/migrate-deprecated-icon';
|
|
20
|
+
var presets = ['styled-to-emotion', 'theme-remove-deprecated-mixins', 'migrate-deprecated-icon', 'migrate-to-link', 'migrate-to-new-buttons', 'migrate-icon-object-to-object', 'upgrade-pragmatic-drag-and-drop-to-stable', 'remove-dark-theme-vr-options', 'remove-token-fallbacks', 'lozenge-appearance-semantic-migration', 'lozenge-to-tag-migration', 'badge-appearance-semantic-migration', 'tag-to-newTag-migration'].map(function (preset) {
|
|
20
21
|
return path.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
21
22
|
});
|
|
22
23
|
export default presets;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/fs/filename-pattern-match */
|
|
2
|
+
|
|
3
|
+
import { deprecatedCore as deprecatedIconLabCore } from '@atlaskit/icon-lab/deprecated-map';
|
|
4
|
+
import coreIconLabMetadata from '@atlaskit/icon-lab/metadata';
|
|
5
|
+
import { deprecatedCore as deprecatedIconCore } from '@atlaskit/icon/deprecated-map';
|
|
6
|
+
import { coreIconMetadata } from '@atlaskit/icon/metadata';
|
|
7
|
+
var extractIconName = function extractIconName(importPath) {
|
|
8
|
+
var match = importPath.match(/\/([^\/]+)$/);
|
|
9
|
+
return match ? match[1] : '';
|
|
10
|
+
};
|
|
11
|
+
var getIconComponentName = function getIconComponentName(name) {
|
|
12
|
+
return name.split(/\W/).map(function (part) {
|
|
13
|
+
return "".concat(part[0].toUpperCase()).concat(part.slice(1));
|
|
14
|
+
}).join('').concat('Icon');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new default import declaration for the transformed component
|
|
19
|
+
*/
|
|
20
|
+
var createDefaultImportDeclaration = function createDefaultImportDeclaration(j, componentName, importPath) {
|
|
21
|
+
var defaultSpecifier = j.importDefaultSpecifier(j.identifier(componentName));
|
|
22
|
+
return j.importDeclaration([defaultSpecifier], j.stringLiteral(importPath));
|
|
23
|
+
};
|
|
24
|
+
var PRINT_SETTINGS = {
|
|
25
|
+
quote: 'single',
|
|
26
|
+
trailingComma: true
|
|
27
|
+
};
|
|
28
|
+
var transformer = function transformer(file, api) {
|
|
29
|
+
var j = api.jscodeshift;
|
|
30
|
+
var fileSource = j(file.source);
|
|
31
|
+
var deprecatedIcons = Object.keys(deprecatedIconCore);
|
|
32
|
+
var deprecatedIconLabIcons = Object.keys(deprecatedIconLabCore);
|
|
33
|
+
|
|
34
|
+
// Find all deprecated icon imports
|
|
35
|
+
var deprecatedIconImports = fileSource.find(j.ImportDeclaration).filter(function (path) {
|
|
36
|
+
var _coreIconMetadata$ico, _coreIconLabMetadata$;
|
|
37
|
+
var source = path.node.source.value;
|
|
38
|
+
|
|
39
|
+
//Extract icon name from import path
|
|
40
|
+
var iconName = extractIconName(source);
|
|
41
|
+
var isDeprecated = deprecatedIcons.includes(source) || deprecatedIconLabIcons.includes(source);
|
|
42
|
+
var hasReplacement = !!((_coreIconMetadata$ico = coreIconMetadata[iconName]) !== null && _coreIconMetadata$ico !== void 0 && _coreIconMetadata$ico.replacement) || !!((_coreIconLabMetadata$ = coreIconLabMetadata[iconName]) !== null && _coreIconLabMetadata$ !== void 0 && _coreIconLabMetadata$.replacement);
|
|
43
|
+
return typeof source === 'string' && isDeprecated && hasReplacement;
|
|
44
|
+
});
|
|
45
|
+
if (!deprecatedIconImports.length) {
|
|
46
|
+
return fileSource.toSource();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Track import name mappings (old name -> new name) and new imports to create
|
|
50
|
+
var importNameMappings = new Map();
|
|
51
|
+
var newImportsToCreate = [];
|
|
52
|
+
|
|
53
|
+
// Process each icon-object import
|
|
54
|
+
deprecatedIconImports.forEach(function (importPath) {
|
|
55
|
+
var _coreIconMetadata$ico2, _coreIconMetadata$ico3, _coreIconLabMetadata$2, _importDeclaration$sp;
|
|
56
|
+
var importDeclaration = importPath.node;
|
|
57
|
+
var source = importDeclaration.source.value;
|
|
58
|
+
|
|
59
|
+
//Extract icon name from import path
|
|
60
|
+
var iconName = extractIconName(source);
|
|
61
|
+
var replacementIconInfo = (_coreIconMetadata$ico2 = (_coreIconMetadata$ico3 = coreIconMetadata[iconName]) === null || _coreIconMetadata$ico3 === void 0 ? void 0 : _coreIconMetadata$ico3.replacement) !== null && _coreIconMetadata$ico2 !== void 0 ? _coreIconMetadata$ico2 : (_coreIconLabMetadata$2 = coreIconLabMetadata[iconName]) === null || _coreIconLabMetadata$2 === void 0 ? void 0 : _coreIconLabMetadata$2.replacement;
|
|
62
|
+
if (!replacementIconInfo) {
|
|
63
|
+
return; // No replacement found, skip
|
|
64
|
+
}
|
|
65
|
+
var replacementIconName = getIconComponentName(replacementIconInfo.name);
|
|
66
|
+
var replacementIconImport = "".concat(replacementIconInfo.location, "/core/").concat(replacementIconInfo.name);
|
|
67
|
+
|
|
68
|
+
// Get the current import name (could be default import or renamed)
|
|
69
|
+
var defaultSpecifier = (_importDeclaration$sp = importDeclaration.specifiers) === null || _importDeclaration$sp === void 0 ? void 0 : _importDeclaration$sp.find(function (spec) {
|
|
70
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
71
|
+
});
|
|
72
|
+
if (defaultSpecifier) {
|
|
73
|
+
var _defaultSpecifier$loc;
|
|
74
|
+
var currentImportName = (_defaultSpecifier$loc = defaultSpecifier.local) === null || _defaultSpecifier$loc === void 0 ? void 0 : _defaultSpecifier$loc.name;
|
|
75
|
+
if (currentImportName) {
|
|
76
|
+
// Map the old import name to the new component name
|
|
77
|
+
importNameMappings.set(currentImportName, replacementIconName);
|
|
78
|
+
|
|
79
|
+
// Track the new import to create
|
|
80
|
+
newImportsToCreate.push({
|
|
81
|
+
componentName: replacementIconName,
|
|
82
|
+
importPath: replacementIconImport,
|
|
83
|
+
oldImportPath: importPath
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Update JSX elements to use new component names
|
|
90
|
+
importNameMappings.forEach(function (newName, oldName) {
|
|
91
|
+
fileSource.find(j.JSXElement).filter(function (path) {
|
|
92
|
+
var openingElement = path.value.openingElement;
|
|
93
|
+
return openingElement.name.type === 'JSXIdentifier' && openingElement.name.name === oldName;
|
|
94
|
+
}).forEach(function (elementPath) {
|
|
95
|
+
var _element$closingEleme;
|
|
96
|
+
var element = elementPath.value;
|
|
97
|
+
|
|
98
|
+
// Update opening tag
|
|
99
|
+
if (element.openingElement.name.type === 'JSXIdentifier') {
|
|
100
|
+
element.openingElement.name.name = newName;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Update closing tag if it exists
|
|
104
|
+
if (((_element$closingEleme = element.closingElement) === null || _element$closingEleme === void 0 ? void 0 : _element$closingEleme.name.type) === 'JSXIdentifier') {
|
|
105
|
+
element.closingElement.name.name = newName;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Update other references (like in render calls, etc.)
|
|
111
|
+
importNameMappings.forEach(function (newName, oldName) {
|
|
112
|
+
fileSource.find(j.Identifier).filter(function (path) {
|
|
113
|
+
return path.node.name === oldName;
|
|
114
|
+
}).forEach(function (path) {
|
|
115
|
+
var _parent$value, _parent$value2;
|
|
116
|
+
// Only update if it's not part of an import declaration or JSX element
|
|
117
|
+
// (those are handled separately)
|
|
118
|
+
var parent = path.parent;
|
|
119
|
+
if ((parent === null || parent === void 0 || (_parent$value = parent.value) === null || _parent$value === void 0 ? void 0 : _parent$value.type) !== 'ImportDefaultSpecifier' && (parent === null || parent === void 0 || (_parent$value2 = parent.value) === null || _parent$value2 === void 0 ? void 0 : _parent$value2.type) !== 'JSXIdentifier') {
|
|
120
|
+
path.node.name = newName;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Create new individual default imports
|
|
126
|
+
newImportsToCreate.forEach(function (_ref) {
|
|
127
|
+
var componentName = _ref.componentName,
|
|
128
|
+
importPath = _ref.importPath,
|
|
129
|
+
oldImportPath = _ref.oldImportPath;
|
|
130
|
+
var newImport = createDefaultImportDeclaration(j, componentName, importPath);
|
|
131
|
+
oldImportPath.replace(newImport);
|
|
132
|
+
});
|
|
133
|
+
return fileSource.toSource(PRINT_SETTINGS);
|
|
134
|
+
};
|
|
135
|
+
export default transformer;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
import migrateDeprecatedIconTransformer from './codemods/migrate-deprecated-icon';
|
|
7
|
+
export default function transformer(_x, _x2) {
|
|
8
|
+
return _transformer.apply(this, arguments);
|
|
9
|
+
}
|
|
10
|
+
function _transformer() {
|
|
11
|
+
_transformer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, api) {
|
|
12
|
+
var transformers, src;
|
|
13
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
transformers = [migrateDeprecatedIconTransformer];
|
|
17
|
+
src = file.source;
|
|
18
|
+
transformers.forEach(function (transformer) {
|
|
19
|
+
if (typeof src === 'undefined') {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var nextSrc = transformer(_objectSpread(_objectSpread({}, file), {}, {
|
|
23
|
+
source: src
|
|
24
|
+
}), api);
|
|
25
|
+
if (nextSrc) {
|
|
26
|
+
src = nextSrc;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return _context.abrupt("return", src);
|
|
30
|
+
case 4:
|
|
31
|
+
case "end":
|
|
32
|
+
return _context.stop();
|
|
33
|
+
}
|
|
34
|
+
}, _callee);
|
|
35
|
+
}));
|
|
36
|
+
return _transformer.apply(this, arguments);
|
|
37
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export var mockMetadata = {
|
|
2
|
+
coreIconMetadata: {
|
|
3
|
+
capture: {
|
|
4
|
+
keywords: ['capture', 'icon', 'focus', 'focus area', 'capture'],
|
|
5
|
+
componentName: 'CaptureIcon',
|
|
6
|
+
package: '@atlaskit/icon/core/capture',
|
|
7
|
+
oldName: ['jira/capture'],
|
|
8
|
+
replacement: {
|
|
9
|
+
name: 'focus-area',
|
|
10
|
+
location: '@atlaskit/icon'
|
|
11
|
+
},
|
|
12
|
+
categorization: 'single-purpose',
|
|
13
|
+
usage: 'Reserved for representing Focus Areas.',
|
|
14
|
+
team: 'Design System Team',
|
|
15
|
+
status: 'deprecated'
|
|
16
|
+
},
|
|
17
|
+
'chart-matrix': {
|
|
18
|
+
keywords: ['chart-matrix', 'chartmatrix', 'icon', 'dot chart', 'graph', 'matrix', ''],
|
|
19
|
+
componentName: 'ChartMatrixIcon',
|
|
20
|
+
package: '@atlaskit/icon/core/chart-matrix',
|
|
21
|
+
replacement: {
|
|
22
|
+
name: 'chart-bubble',
|
|
23
|
+
location: '@atlaskit/icon'
|
|
24
|
+
},
|
|
25
|
+
categorization: 'multi-purpose',
|
|
26
|
+
usage: 'Multi purpose - Known uses: Matrix view in in JPD, and other matrix charts.',
|
|
27
|
+
team: 'Design System Team',
|
|
28
|
+
status: 'deprecated'
|
|
29
|
+
},
|
|
30
|
+
close: {
|
|
31
|
+
keywords: ['close', 'icon', 'cross', 'x', 'close', 'remove'],
|
|
32
|
+
componentName: 'CloseIcon',
|
|
33
|
+
package: '@atlaskit/icon/core/close',
|
|
34
|
+
oldName: ['cross', 'editor/close'],
|
|
35
|
+
replacement: {
|
|
36
|
+
name: 'cross',
|
|
37
|
+
location: '@atlaskit/icon'
|
|
38
|
+
},
|
|
39
|
+
categorization: 'multi-purpose',
|
|
40
|
+
usage: 'Known uses: closing modals, panels, and transient views; removing tags',
|
|
41
|
+
team: 'Design System Team',
|
|
42
|
+
status: 'deprecated'
|
|
43
|
+
},
|
|
44
|
+
error: {
|
|
45
|
+
keywords: ['error', 'warning', 'alert', 'icon', 'filled', 'status', 'danger', 'exclamation', '!', 'error'],
|
|
46
|
+
componentName: 'ErrorIcon',
|
|
47
|
+
package: '@atlaskit/icon/core/error',
|
|
48
|
+
oldName: ['error'],
|
|
49
|
+
replacement: {
|
|
50
|
+
name: 'status-error',
|
|
51
|
+
location: '@atlaskit/icon'
|
|
52
|
+
},
|
|
53
|
+
categorization: 'single-purpose',
|
|
54
|
+
usage: 'Reserved for error statuses and messaging. Filled status icons provide higher visual contrast to draw attention to important information.',
|
|
55
|
+
team: 'Design System Team',
|
|
56
|
+
status: 'deprecated'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
export var mockDeprecatedIcons = {
|
|
61
|
+
deprecatedCore: {
|
|
62
|
+
'@atlaskit/icon/core/capture': {
|
|
63
|
+
message: 'The icon "capture" is deprecated in favour of "focus-area" from "@atlaskit/icon/core"'
|
|
64
|
+
},
|
|
65
|
+
'@atlaskit/icon/core/chart-matrix': {
|
|
66
|
+
message: 'The icon "chart-matrix" is deprecated in favour of "chart-bubble" from "@atlaskit/icon/core"'
|
|
67
|
+
},
|
|
68
|
+
'@atlaskit/icon/core/close': {
|
|
69
|
+
message: 'The icon "close" is deprecated in favour of "cross" from "@atlaskit/icon/core"'
|
|
70
|
+
},
|
|
71
|
+
'@atlaskit/icon/core/error': {
|
|
72
|
+
message: 'The icon "error" is deprecated in favour of "status-error" from "@atlaskit/icon/core"'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -14,5 +14,6 @@ import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migr
|
|
|
14
14
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
15
15
|
import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
|
|
16
16
|
import './tag-to-newTag-migration/tag-to-newTag-migration';
|
|
17
|
+
import './migrate-deprecated-icon/migrate-deprecated-icon';
|
|
17
18
|
declare const presets: string[];
|
|
18
19
|
export default presets;
|
|
@@ -14,5 +14,6 @@ import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migr
|
|
|
14
14
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
15
15
|
import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
|
|
16
16
|
import './tag-to-newTag-migration/tag-to-newTag-migration';
|
|
17
|
+
import './migrate-deprecated-icon/migrate-deprecated-icon';
|
|
17
18
|
declare const presets: string[];
|
|
18
19
|
export default presets;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "A cli for distributing codemods for atlassian-frontend components and services",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
"bin": "./bin/codemod-cli.js",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
32
|
-
"@atlaskit/
|
|
32
|
+
"@atlaskit/icon": "^29.3.0",
|
|
33
|
+
"@atlaskit/icon-lab": "^5.13.0",
|
|
34
|
+
"@atlaskit/tokens": "^9.1.0",
|
|
33
35
|
"@babel/runtime": "^7.0.0",
|
|
34
36
|
"@codeshift/utils": "^0.2.4",
|
|
35
37
|
"@hypermod/utils": "^0.4.2",
|