@atlaskit/codemod-cli 0.33.1 → 0.34.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/main.js +1 -1
  3. package/dist/cjs/presets/index.js +3 -1
  4. package/dist/cjs/presets/lozenge-discovery-to-tag-with-fg/codemods/lozenge-discovery-to-tag-with-fg.js +219 -0
  5. package/dist/cjs/presets/lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg.js +44 -0
  6. package/dist/cjs/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +142 -0
  7. package/dist/cjs/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +44 -0
  8. package/dist/cjs/presets/migrate-deprecated-icon/utils/mock.js +81 -0
  9. package/dist/es2019/presets/index.js +3 -1
  10. package/dist/es2019/presets/lozenge-discovery-to-tag-with-fg/codemods/lozenge-discovery-to-tag-with-fg.js +207 -0
  11. package/dist/es2019/presets/lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg.js +18 -0
  12. package/dist/es2019/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +130 -0
  13. package/dist/es2019/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +18 -0
  14. package/dist/es2019/presets/migrate-deprecated-icon/utils/mock.js +75 -0
  15. package/dist/esm/main.js +1 -1
  16. package/dist/esm/presets/index.js +3 -1
  17. package/dist/esm/presets/lozenge-discovery-to-tag-with-fg/codemods/lozenge-discovery-to-tag-with-fg.js +213 -0
  18. package/dist/esm/presets/lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg.js +37 -0
  19. package/dist/esm/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.js +135 -0
  20. package/dist/esm/presets/migrate-deprecated-icon/migrate-deprecated-icon.js +37 -0
  21. package/dist/esm/presets/migrate-deprecated-icon/utils/mock.js +75 -0
  22. package/dist/types/presets/index.d.ts +2 -0
  23. package/dist/types/presets/lozenge-discovery-to-tag-with-fg/codemods/lozenge-discovery-to-tag-with-fg.d.ts +12 -0
  24. package/dist/types/presets/lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg.d.ts +2 -0
  25. package/dist/types/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.d.ts +3 -0
  26. package/dist/types/presets/migrate-deprecated-icon/migrate-deprecated-icon.d.ts +2 -0
  27. package/dist/types-ts4.5/presets/index.d.ts +2 -0
  28. package/dist/types-ts4.5/presets/lozenge-discovery-to-tag-with-fg/codemods/lozenge-discovery-to-tag-with-fg.d.ts +12 -0
  29. package/dist/types-ts4.5/presets/lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg.d.ts +2 -0
  30. package/dist/types-ts4.5/presets/migrate-deprecated-icon/codemods/migrate-deprecated-icon.d.ts +3 -0
  31. package/dist/types-ts4.5/presets/migrate-deprecated-icon/migrate-deprecated-icon.d.ts +2 -0
  32. package/package.json +4 -2
@@ -0,0 +1,213 @@
1
+ /* eslint-disable @repo/internal/fs/filename-pattern-match */
2
+
3
+ var LOZENGE_ENTRY_POINT = '@atlaskit/lozenge';
4
+ var TAG_ENTRY_POINT = '@atlaskit/tag';
5
+ var FG_ENTRY_POINT = '@atlassian/jira-feature-gating';
6
+ var FEATURE_GATE_NAME = 'platform-dst-lozenge-tag-badge-visual-uplifts';
7
+ var PRINT_SETTINGS = {
8
+ quote: 'single'
9
+ };
10
+ /**
11
+ * Codemod to migrate Lozenge components with appearance='new' or 'discovery' to Tag behind feature gate.
12
+ *
13
+ * This codemod:
14
+ * 1. Finds Lozenges with appearance="new" or appearance="discovery"
15
+ * 2. Also includes discovery Lozenges with isBold={true} or isBold
16
+ * 3. Wraps them in a feature gate: fg('platform-dst-lozenge-tag-badge-visual-uplifts')
17
+ * 4. Converts to Tag with color="purple" when feature gate is off
18
+ * 5. Adds necessary imports (Tag, fg)
19
+ */
20
+ export default function transformer(file, api) {
21
+ var j = api.jscodeshift;
22
+ var source;
23
+
24
+ // Try to parse the file
25
+ try {
26
+ source = j(file.source);
27
+ } catch (error) {
28
+ // eslint-disable-next-line no-console
29
+ console.error(error);
30
+ return file.source;
31
+ }
32
+
33
+ // Check if Lozenge is imported from @atlaskit/lozenge
34
+ var hasLozengeImport = source.find(j.ImportDeclaration).some(function (importPath) {
35
+ return importPath.value.source.value === LOZENGE_ENTRY_POINT;
36
+ });
37
+ if (!hasLozengeImport) {
38
+ return file.source;
39
+ }
40
+
41
+ // Get all Lozenge component names (handles renamed imports)
42
+ var lozengeNames = new Set();
43
+ source.find(j.ImportDeclaration).forEach(function (importPath) {
44
+ if (importPath.value.source.value === LOZENGE_ENTRY_POINT) {
45
+ var _importPath$value$spe;
46
+ (_importPath$value$spe = importPath.value.specifiers) === null || _importPath$value$spe === void 0 || _importPath$value$spe.forEach(function (specifier) {
47
+ if (specifier.type === 'ImportDefaultSpecifier') {
48
+ lozengeNames.add(specifier.local.name);
49
+ } else if (specifier.type === 'ImportSpecifier' && specifier.imported.name === 'default') {
50
+ lozengeNames.add(specifier.local.name);
51
+ }
52
+ });
53
+ }
54
+ });
55
+
56
+ // Find all Lozenge elements that should be migrated
57
+ var lozengeElements = [];
58
+ source.find(j.JSXElement).forEach(function (path) {
59
+ var _openingElement$name;
60
+ var openingElement = path.value.openingElement;
61
+ if (((_openingElement$name = openingElement.name) === null || _openingElement$name === void 0 ? void 0 : _openingElement$name.type) === 'JSXIdentifier' && lozengeNames.has(openingElement.name.name)) {
62
+ var _openingElement$attri;
63
+ var element = {
64
+ path: path,
65
+ shouldMigrate: false
66
+ };
67
+
68
+ // Check for appearance and isBold props
69
+ (_openingElement$attri = openingElement.attributes) === null || _openingElement$attri === void 0 || _openingElement$attri.forEach(function (attr) {
70
+ var _attr$name;
71
+ if (attr.type === 'JSXAttribute' && ((_attr$name = attr.name) === null || _attr$name === void 0 ? void 0 : _attr$name.type) === 'JSXIdentifier') {
72
+ if (attr.name.name === 'appearance') {
73
+ var _attr$value, _attr$value2;
74
+ if (((_attr$value = attr.value) === null || _attr$value === void 0 ? void 0 : _attr$value.type) === 'StringLiteral') {
75
+ element.appearanceValue = attr.value.value;
76
+ } else if (((_attr$value2 = attr.value) === null || _attr$value2 === void 0 ? void 0 : _attr$value2.type) === 'JSXExpressionContainer') {
77
+ var expression = attr.value.expression;
78
+ if (expression.type === 'StringLiteral') {
79
+ element.appearanceValue = expression.value;
80
+ }
81
+ }
82
+ } else if (attr.name.name === 'isBold') {
83
+ var _attr$value3;
84
+ if (attr.value === null) {
85
+ element.isBoldValue = true;
86
+ } else if (((_attr$value3 = attr.value) === null || _attr$value3 === void 0 ? void 0 : _attr$value3.type) === 'JSXExpressionContainer') {
87
+ var _expression = attr.value.expression;
88
+ if (_expression.type === 'BooleanLiteral') {
89
+ element.isBoldValue = _expression.value;
90
+ } else if (_expression.type === 'Literal' && typeof _expression.value === 'boolean') {
91
+ element.isBoldValue = _expression.value;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ });
97
+
98
+ // Determine if this Lozenge should be migrated
99
+ // Migrate if: appearance="new" OR appearance="discovery" OR (appearance="discovery" AND isBold={true})
100
+ if (element.appearanceValue === 'new' || element.appearanceValue === 'discovery' || element.appearanceValue === 'discovery' && element.isBoldValue === true) {
101
+ element.shouldMigrate = true;
102
+ }
103
+ if (element.shouldMigrate) {
104
+ lozengeElements.push(element);
105
+ }
106
+ }
107
+ });
108
+
109
+ // If no elements to migrate, return early
110
+ if (lozengeElements.length === 0) {
111
+ return file.source;
112
+ }
113
+
114
+ // Check if Tag import exists
115
+ var hasTagImport = source.find(j.ImportDeclaration).some(function (importPath) {
116
+ return importPath.value.source.value === TAG_ENTRY_POINT;
117
+ });
118
+
119
+ // Check if fg is already imported from @atlassian/jira-feature-gating
120
+ var hasFgImport = source.find(j.ImportDeclaration).some(function (importPath) {
121
+ if (importPath.value.source.value === FG_ENTRY_POINT) {
122
+ var _importPath$value$spe2;
123
+ // Check if 'fg' is in the specifiers
124
+ return (_importPath$value$spe2 = importPath.value.specifiers) === null || _importPath$value$spe2 === void 0 ? void 0 : _importPath$value$spe2.some(function (spec) {
125
+ return spec.type === 'ImportSpecifier' && spec.imported.name === 'fg';
126
+ });
127
+ }
128
+ return false;
129
+ });
130
+
131
+ // Add imports after Lozenge import to avoid blank lines
132
+ var lozengeImport = source.find(j.ImportDeclaration).filter(function (path) {
133
+ return path.value.source.value === LOZENGE_ENTRY_POINT;
134
+ }).at(0);
135
+ if (lozengeImport.length > 0) {
136
+ // Add imports in reverse order so they appear in the right order
137
+ if (!hasFgImport) {
138
+ lozengeImport.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('fg'))], j.stringLiteral(FG_ENTRY_POINT)));
139
+ }
140
+ if (!hasTagImport) {
141
+ lozengeImport.insertAfter(j.importDeclaration([j.importDefaultSpecifier(j.identifier('Tag'))], j.stringLiteral(TAG_ENTRY_POINT)));
142
+ }
143
+ }
144
+
145
+ // Transform each element
146
+ lozengeElements.forEach(function (element) {
147
+ var _openingElement$attri2;
148
+ var path = element.path;
149
+ var openingElement = path.value.openingElement;
150
+
151
+ // Extract text content or JSX expression from children
152
+ var children = path.value.children;
153
+ var textAttribute = null;
154
+ if (children && children.length > 0) {
155
+ // Check if there's a single JSX expression child (e.g., {formatMessage(...)})
156
+ if (children.length === 1 && children[0].type === 'JSXExpressionContainer') {
157
+ var expression = children[0].expression;
158
+ // Use the expression as the text value
159
+ textAttribute = j.jsxAttribute(j.jsxIdentifier('text'), j.jsxExpressionContainer(expression));
160
+ } else {
161
+ // Extract plain text content from JSXText nodes
162
+ var textContent = children.filter(function (child) {
163
+ return child.type === 'JSXText';
164
+ }).map(function (child) {
165
+ return child.value.trim();
166
+ }).filter(function (text) {
167
+ return text.length > 0;
168
+ }).join(' ');
169
+ if (textContent) {
170
+ textAttribute = j.jsxAttribute(j.jsxIdentifier('text'), j.stringLiteral(textContent));
171
+ }
172
+ }
173
+ }
174
+
175
+ // Create the Tag element
176
+ var tagAttributes = [j.jsxAttribute(j.jsxIdentifier('color'), j.stringLiteral('purple'))];
177
+ if (textAttribute) {
178
+ tagAttributes.unshift(textAttribute);
179
+ }
180
+
181
+ // Copy other props from Lozenge to Tag (except appearance and isBold)
182
+ (_openingElement$attri2 = openingElement.attributes) === null || _openingElement$attri2 === void 0 || _openingElement$attri2.forEach(function (attr) {
183
+ var _attr$name2;
184
+ if (attr.type === 'JSXAttribute' && ((_attr$name2 = attr.name) === null || _attr$name2 === void 0 ? void 0 : _attr$name2.type) === 'JSXIdentifier') {
185
+ if (attr.name.name !== 'appearance' && attr.name.name !== 'isBold') {
186
+ tagAttributes.push(attr);
187
+ }
188
+ }
189
+ });
190
+ var tagElement = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier('Tag'), tagAttributes, true), null, []);
191
+
192
+ // Keep the original Lozenge element (just the element, without wrapping)
193
+ var lozengeElement = path.value;
194
+
195
+ // Create the conditional expression: fg(FEATURE_GATE_NAME) ? <Tag .../> : <Lozenge .../>
196
+ // When feature gate is ON, show Tag (new behavior)
197
+ // When feature gate is OFF, show Lozenge (old behavior)
198
+ var conditionalExpression = j.conditionalExpression(j.callExpression(j.identifier('fg'), [j.stringLiteral(FEATURE_GATE_NAME)]), tagElement, lozengeElement);
199
+
200
+ // Check if the parent is a JSXElement (means we're inside JSX, need curly braces)
201
+ // Otherwise, it's a regular expression (like in a return statement)
202
+ var parent = path.parent;
203
+ var needsJSXWrapper = parent && (parent.value.type === 'JSXElement' || parent.value.type === 'JSXExpressionContainer');
204
+ if (needsJSXWrapper) {
205
+ // Inside JSX, wrap in expression container
206
+ j(path).replaceWith(j.jsxExpressionContainer(conditionalExpression));
207
+ } else {
208
+ // In regular JS context (like return statement), just use the conditional
209
+ j(path).replaceWith(conditionalExpression);
210
+ }
211
+ });
212
+ return source.toSource(PRINT_SETTINGS);
213
+ }
@@ -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 lozengeDiscoveryToTagWithFgTransformer from './codemods/lozenge-discovery-to-tag-with-fg';
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 = [lozengeDiscoveryToTagWithFgTransformer];
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,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
+ };
@@ -12,7 +12,9 @@ import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
12
12
  import './remove-token-fallbacks/remove-token-fallbacks';
13
13
  import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
14
14
  import './lozenge-to-tag-migration/lozenge-to-tag-migration';
15
+ import './lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg';
15
16
  import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
16
17
  import './tag-to-newTag-migration/tag-to-newTag-migration';
18
+ import './migrate-deprecated-icon/migrate-deprecated-icon';
17
19
  declare const presets: string[];
18
20
  export default presets;
@@ -0,0 +1,12 @@
1
+ import { type API, type FileInfo } from 'jscodeshift';
2
+ /**
3
+ * Codemod to migrate Lozenge components with appearance='new' or 'discovery' to Tag behind feature gate.
4
+ *
5
+ * This codemod:
6
+ * 1. Finds Lozenges with appearance="new" or appearance="discovery"
7
+ * 2. Also includes discovery Lozenges with isBold={true} or isBold
8
+ * 3. Wraps them in a feature gate: fg('platform-dst-lozenge-tag-badge-visual-uplifts')
9
+ * 4. Converts to Tag with color="purple" when feature gate is off
10
+ * 5. Adds necessary imports (Tag, fg)
11
+ */
12
+ export default function transformer(file: FileInfo, api: API): any;
@@ -0,0 +1,2 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ declare const transformer: (file: FileInfo, api: API) => string;
3
+ export default transformer;
@@ -0,0 +1,2 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API): Promise<string>;
@@ -12,7 +12,9 @@ import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
12
12
  import './remove-token-fallbacks/remove-token-fallbacks';
13
13
  import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
14
14
  import './lozenge-to-tag-migration/lozenge-to-tag-migration';
15
+ import './lozenge-discovery-to-tag-with-fg/lozenge-discovery-to-tag-with-fg';
15
16
  import './badge-appearance-semantic-migration/badge-appearance-semantic-migration';
16
17
  import './tag-to-newTag-migration/tag-to-newTag-migration';
18
+ import './migrate-deprecated-icon/migrate-deprecated-icon';
17
19
  declare const presets: string[];
18
20
  export default presets;
@@ -0,0 +1,12 @@
1
+ import { type API, type FileInfo } from 'jscodeshift';
2
+ /**
3
+ * Codemod to migrate Lozenge components with appearance='new' or 'discovery' to Tag behind feature gate.
4
+ *
5
+ * This codemod:
6
+ * 1. Finds Lozenges with appearance="new" or appearance="discovery"
7
+ * 2. Also includes discovery Lozenges with isBold={true} or isBold
8
+ * 3. Wraps them in a feature gate: fg('platform-dst-lozenge-tag-badge-visual-uplifts')
9
+ * 4. Converts to Tag with color="purple" when feature gate is off
10
+ * 5. Adds necessary imports (Tag, fg)
11
+ */
12
+ export default function transformer(file: FileInfo, api: API): any;
@@ -0,0 +1,2 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ declare const transformer: (file: FileInfo, api: API) => string;
3
+ export default transformer;
@@ -0,0 +1,2 @@
1
+ import type { API, FileInfo } from 'jscodeshift';
2
+ export default function transformer(file: FileInfo, api: API): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.33.1",
3
+ "version": "0.34.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/"
@@ -29,7 +29,9 @@
29
29
  "bin": "./bin/codemod-cli.js",
30
30
  "dependencies": {
31
31
  "@atlaskit/codemod-utils": "^4.2.0",
32
- "@atlaskit/tokens": "^9.0.0",
32
+ "@atlaskit/icon": "^29.4.0",
33
+ "@atlaskit/icon-lab": "^5.14.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",