@atlaskit/codemod-cli 0.31.0 → 0.31.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 -2
- package/dist/cjs/presets/{lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/codemods/lozenge-appearance-semantic-migration.js} +12 -15
- package/dist/cjs/presets/{lozenge-appearance-to-color/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration.js} +2 -2
- package/dist/cjs/presets/remove-token-fallbacks/utils/reporter.js +3 -2
- package/dist/es2019/presets/index.js +2 -2
- package/dist/es2019/presets/{lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/codemods/lozenge-appearance-semantic-migration.js} +16 -18
- package/dist/es2019/presets/{lozenge-appearance-to-color/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration.js} +2 -2
- package/dist/es2019/presets/remove-token-fallbacks/utils/reporter.js +4 -0
- package/dist/esm/main.js +1 -1
- package/dist/esm/presets/index.js +2 -2
- package/dist/esm/presets/{lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/codemods/lozenge-appearance-semantic-migration.js} +12 -15
- package/dist/esm/presets/{lozenge-appearance-to-color/lozenge-appearance-to-color.js → lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration.js} +2 -2
- package/dist/esm/presets/remove-token-fallbacks/utils/reporter.js +4 -1
- package/dist/types/presets/index.d.ts +1 -1
- package/dist/types/presets/lozenge-appearance-semantic-migration/codemods/lozenge-appearance-semantic-migration.d.ts +10 -0
- package/dist/types-ts4.5/presets/index.d.ts +1 -1
- package/dist/types-ts4.5/presets/lozenge-appearance-semantic-migration/codemods/lozenge-appearance-semantic-migration.d.ts +10 -0
- package/package.json +2 -2
- package/dist/types/presets/lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.d.ts +0 -10
- package/dist/types-ts4.5/presets/lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.d.ts +0 -10
- /package/dist/types/presets/{lozenge-appearance-to-color/lozenge-appearance-to-color.d.ts → lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration.d.ts} +0 -0
- /package/dist/types-ts4.5/presets/{lozenge-appearance-to-color/lozenge-appearance-to-color.d.ts → lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/codemod-cli
|
|
2
2
|
|
|
3
|
+
## 0.31.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`100f9ea636d3a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/100f9ea636d3a) -
|
|
8
|
+
Updated lozenge codemod to preserve appearance prop (no color prop change), also renamed to
|
|
9
|
+
lozenge-appearance-semantic-migration
|
|
10
|
+
|
|
11
|
+
## 0.31.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 0.31.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.
|
|
365
|
+
_process$env$_PACKAGE = "0.0.0-development", _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) {
|
|
@@ -14,14 +14,14 @@ require("./migrate-icon-object-to-object/migrate-icon-object-to-object");
|
|
|
14
14
|
require("./upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable");
|
|
15
15
|
require("./remove-dark-theme-vr-options/remove-dark-theme-vr-options");
|
|
16
16
|
require("./remove-token-fallbacks/remove-token-fallbacks");
|
|
17
|
-
require("./lozenge-appearance-
|
|
17
|
+
require("./lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration");
|
|
18
18
|
require("./lozenge-to-tag-migration/lozenge-to-tag-migration");
|
|
19
19
|
/**
|
|
20
20
|
* Manually import presets to make sure typescript includes them
|
|
21
21
|
* in the final bundle.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
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-
|
|
24
|
+
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'].map(function (preset) {
|
|
25
25
|
return _path.default.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
26
26
|
});
|
|
27
27
|
var _default = exports.default = presets;
|
|
@@ -11,8 +11,8 @@ var PRINT_SETTINGS = {
|
|
|
11
11
|
quote: 'single'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
var
|
|
14
|
+
// Old appearance values that map to new semantic appearance values
|
|
15
|
+
var OLD_TO_NEW_APPEARANCE_MAP = {
|
|
16
16
|
default: 'neutral',
|
|
17
17
|
inprogress: 'information',
|
|
18
18
|
moved: 'warning',
|
|
@@ -21,11 +21,11 @@ var APPEARANCE_TO_COLOR_MAP = {
|
|
|
21
21
|
success: 'success'
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
|
-
* Codemod to migrate Lozenge component
|
|
24
|
+
* Codemod to migrate Lozenge component appearance semantic values.
|
|
25
25
|
*
|
|
26
26
|
* This codemod:
|
|
27
|
-
* 1.
|
|
28
|
-
* 2. Maps
|
|
27
|
+
* 1. Updates `appearance` prop values to new semantic values
|
|
28
|
+
* 2. Maps old semantic values to new semantic values (e.g. default → neutral, inprogress → information)
|
|
29
29
|
* 3. Adds comments for dynamic values that need manual verification
|
|
30
30
|
*/
|
|
31
31
|
function transformer(file, api) {
|
|
@@ -107,27 +107,24 @@ function transformer(file, api) {
|
|
|
107
107
|
appearanceValue = element.appearanceValue;
|
|
108
108
|
var openingElement = path.value.openingElement;
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// Update appearance prop values to new semantic values
|
|
111
111
|
if (hasAppearanceProp) {
|
|
112
112
|
var _openingElement$attri2;
|
|
113
113
|
(_openingElement$attri2 = openingElement.attributes) === null || _openingElement$attri2 === void 0 || _openingElement$attri2.forEach(function (attr) {
|
|
114
114
|
var _attr$name2;
|
|
115
115
|
if (attr.type === 'JSXAttribute' && ((_attr$name2 = attr.name) === null || _attr$name2 === void 0 ? void 0 : _attr$name2.type) === 'JSXIdentifier' && attr.name.name === 'appearance') {
|
|
116
|
-
// Rename appearance to color
|
|
117
|
-
attr.name.name = 'color';
|
|
118
|
-
|
|
119
116
|
// Handle different types of appearance values
|
|
120
117
|
if (appearanceValue === 'dynamic') {
|
|
121
118
|
// For dynamic values, add a comment
|
|
122
|
-
(0, _codemodUtils.addCommentBefore)(j, j(path), "FIXME: This Lozenge component uses a dynamic `appearance` prop
|
|
123
|
-
} else if (appearanceValue && !
|
|
119
|
+
(0, _codemodUtils.addCommentBefore)(j, j(path), "FIXME: This Lozenge component uses a dynamic `appearance` prop with updated semantic values.\nPlease verify that the values being passed use the new semantic values: neutral, information, warning, discovery, danger, success.\nOld values mapping: default\u2192neutral, inprogress\u2192information, moved\u2192warning, new\u2192discovery, removed\u2192danger, success\u2192success.");
|
|
120
|
+
} else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
124
121
|
// For invalid string values, add a warning comment
|
|
125
|
-
(0, _codemodUtils.addCommentBefore)(j, j(path), "FIXME: This Lozenge component uses an
|
|
126
|
-
} else if (appearanceValue &&
|
|
122
|
+
(0, _codemodUtils.addCommentBefore)(j, j(path), "FIXME: This Lozenge component uses an unknown `appearance` value \"".concat(appearanceValue, "\".\nValid new semantic appearance values are: ").concat(Object.values(OLD_TO_NEW_APPEARANCE_MAP).join(', '), ".\nPlease update this value to a valid semantic appearance value."));
|
|
123
|
+
} else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
127
124
|
var _attr$value3;
|
|
128
|
-
// For valid string values, update the value to the
|
|
125
|
+
// For valid string values, update the value to the new semantic value
|
|
129
126
|
if (((_attr$value3 = attr.value) === null || _attr$value3 === void 0 ? void 0 : _attr$value3.type) === 'StringLiteral') {
|
|
130
|
-
attr.value.value =
|
|
127
|
+
attr.value.value = OLD_TO_NEW_APPEARANCE_MAP[appearanceValue];
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
130
|
}
|
|
@@ -8,7 +8,7 @@ exports.default = transformer;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var
|
|
11
|
+
var _lozengeAppearanceSemanticMigration = _interopRequireDefault(require("./codemods/lozenge-appearance-semantic-migration"));
|
|
12
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
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
14
|
function transformer(_x, _x2) {
|
|
@@ -20,7 +20,7 @@ function _transformer() {
|
|
|
20
20
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
23
|
-
transformers = [
|
|
23
|
+
transformers = [_lozengeAppearanceSemanticMigration.default];
|
|
24
24
|
src = file.source;
|
|
25
25
|
transformers.forEach(function (transformer) {
|
|
26
26
|
if (typeof src === 'undefined') {
|
|
@@ -15,7 +15,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
15
15
|
var _uuid = require("uuid");
|
|
16
16
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
17
17
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* eslint-disable no-console */
|
|
18
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } /* eslint-disable no-console */ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
19
19
|
function writeToCsv(_x, _x2) {
|
|
20
20
|
return _writeToCsv.apply(this, arguments);
|
|
21
21
|
}
|
|
@@ -296,7 +296,8 @@ function _writeReports() {
|
|
|
296
296
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
297
297
|
while (1) switch (_context6.prev = _context6.next) {
|
|
298
298
|
case 0:
|
|
299
|
-
|
|
299
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
300
|
+
replacementsFilePath = _path.default.join(reportFolder, "".concat((0, _uuid.v4)(), "_success.csv")); // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
300
301
|
nonReplacementsFilePath = _path.default.join(reportFolder, "".concat((0, _uuid.v4)(), "_failed.csv"));
|
|
301
302
|
_context6.next = 4;
|
|
302
303
|
return _promises.default.mkdir(reportFolder, {
|
|
@@ -12,7 +12,7 @@ import './migrate-icon-object-to-object/migrate-icon-object-to-object';
|
|
|
12
12
|
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
13
13
|
import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
|
|
14
14
|
import './remove-token-fallbacks/remove-token-fallbacks';
|
|
15
|
-
import './lozenge-appearance-
|
|
15
|
+
import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
|
|
16
16
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
17
|
-
const 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-
|
|
17
|
+
const 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'].map(preset => path.join(__dirname, preset, `${preset}.@(ts|js|tsx)`));
|
|
18
18
|
export default presets;
|
|
@@ -5,8 +5,8 @@ const PRINT_SETTINGS = {
|
|
|
5
5
|
quote: 'single'
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
const
|
|
8
|
+
// Old appearance values that map to new semantic appearance values
|
|
9
|
+
const OLD_TO_NEW_APPEARANCE_MAP = {
|
|
10
10
|
default: 'neutral',
|
|
11
11
|
inprogress: 'information',
|
|
12
12
|
moved: 'warning',
|
|
@@ -15,11 +15,11 @@ const APPEARANCE_TO_COLOR_MAP = {
|
|
|
15
15
|
success: 'success'
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Codemod to migrate Lozenge component
|
|
18
|
+
* Codemod to migrate Lozenge component appearance semantic values.
|
|
19
19
|
*
|
|
20
20
|
* This codemod:
|
|
21
|
-
* 1.
|
|
22
|
-
* 2. Maps
|
|
21
|
+
* 1. Updates `appearance` prop values to new semantic values
|
|
22
|
+
* 2. Maps old semantic values to new semantic values (e.g. default → neutral, inprogress → information)
|
|
23
23
|
* 3. Adds comments for dynamic values that need manual verification
|
|
24
24
|
*/
|
|
25
25
|
export default function transformer(file, api) {
|
|
@@ -103,30 +103,28 @@ export default function transformer(file, api) {
|
|
|
103
103
|
} = element;
|
|
104
104
|
const openingElement = path.value.openingElement;
|
|
105
105
|
|
|
106
|
-
//
|
|
106
|
+
// Update appearance prop values to new semantic values
|
|
107
107
|
if (hasAppearanceProp) {
|
|
108
108
|
var _openingElement$attri2;
|
|
109
109
|
(_openingElement$attri2 = openingElement.attributes) === null || _openingElement$attri2 === void 0 ? void 0 : _openingElement$attri2.forEach(attr => {
|
|
110
110
|
var _attr$name2;
|
|
111
111
|
if (attr.type === 'JSXAttribute' && ((_attr$name2 = attr.name) === null || _attr$name2 === void 0 ? void 0 : _attr$name2.type) === 'JSXIdentifier' && attr.name.name === 'appearance') {
|
|
112
|
-
// Rename appearance to color
|
|
113
|
-
attr.name.name = 'color';
|
|
114
|
-
|
|
115
112
|
// Handle different types of appearance values
|
|
116
113
|
if (appearanceValue === 'dynamic') {
|
|
117
114
|
// For dynamic values, add a comment
|
|
118
|
-
addCommentBefore(j, j(path), `FIXME: This Lozenge component uses a dynamic \`appearance\` prop
|
|
119
|
-
Please verify that the values being passed
|
|
120
|
-
|
|
115
|
+
addCommentBefore(j, j(path), `FIXME: This Lozenge component uses a dynamic \`appearance\` prop with updated semantic values.
|
|
116
|
+
Please verify that the values being passed use the new semantic values: neutral, information, warning, discovery, danger, success.
|
|
117
|
+
Old values mapping: default→neutral, inprogress→information, moved→warning, new→discovery, removed→danger, success→success.`);
|
|
118
|
+
} else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
121
119
|
// For invalid string values, add a warning comment
|
|
122
|
-
addCommentBefore(j, j(path), `FIXME: This Lozenge component uses an
|
|
123
|
-
Valid semantic
|
|
124
|
-
Please update this value to a valid semantic
|
|
125
|
-
} else if (appearanceValue &&
|
|
120
|
+
addCommentBefore(j, j(path), `FIXME: This Lozenge component uses an unknown \`appearance\` value "${appearanceValue}".
|
|
121
|
+
Valid new semantic appearance values are: ${Object.values(OLD_TO_NEW_APPEARANCE_MAP).join(', ')}.
|
|
122
|
+
Please update this value to a valid semantic appearance value.`);
|
|
123
|
+
} else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
126
124
|
var _attr$value3;
|
|
127
|
-
// For valid string values, update the value to the
|
|
125
|
+
// For valid string values, update the value to the new semantic value
|
|
128
126
|
if (((_attr$value3 = attr.value) === null || _attr$value3 === void 0 ? void 0 : _attr$value3.type) === 'StringLiteral') {
|
|
129
|
-
attr.value.value =
|
|
127
|
+
attr.value.value = OLD_TO_NEW_APPEARANCE_MAP[appearanceValue];
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import lozengeAppearanceSemanticMigrationTransformer from './codemods/lozenge-appearance-semantic-migration';
|
|
2
2
|
export default async function transformer(file, api) {
|
|
3
|
-
const transformers = [
|
|
3
|
+
const transformers = [lozengeAppearanceSemanticMigrationTransformer];
|
|
4
4
|
let src = file.source;
|
|
5
5
|
transformers.forEach(transformer => {
|
|
6
6
|
if (typeof src === 'undefined') {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
7
|
async function writeToCsv(filePath, data) {
|
|
6
8
|
await fs.writeFile(filePath, data.join('\n'), 'utf-8');
|
|
@@ -112,7 +114,9 @@ function prepareCsvData(items) {
|
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
116
|
export async function writeReports(details, reportFolder) {
|
|
117
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
115
118
|
const replacementsFilePath = path.join(reportFolder, `${uuidv4()}_success.csv`);
|
|
119
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
116
120
|
const nonReplacementsFilePath = path.join(reportFolder, `${uuidv4()}_failed.csv`);
|
|
117
121
|
await fs.mkdir(reportFolder, {
|
|
118
122
|
recursive: true
|
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.
|
|
358
|
+
_process$env$_PACKAGE = "0.0.0-development", _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) {
|
|
@@ -12,9 +12,9 @@ import './migrate-icon-object-to-object/migrate-icon-object-to-object';
|
|
|
12
12
|
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
13
13
|
import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
|
|
14
14
|
import './remove-token-fallbacks/remove-token-fallbacks';
|
|
15
|
-
import './lozenge-appearance-
|
|
15
|
+
import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
|
|
16
16
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
17
|
-
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-
|
|
17
|
+
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'].map(function (preset) {
|
|
18
18
|
return path.join(__dirname, preset, "".concat(preset, ".@(ts|js|tsx)"));
|
|
19
19
|
});
|
|
20
20
|
export default presets;
|
|
@@ -5,8 +5,8 @@ var PRINT_SETTINGS = {
|
|
|
5
5
|
quote: 'single'
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
var
|
|
8
|
+
// Old appearance values that map to new semantic appearance values
|
|
9
|
+
var OLD_TO_NEW_APPEARANCE_MAP = {
|
|
10
10
|
default: 'neutral',
|
|
11
11
|
inprogress: 'information',
|
|
12
12
|
moved: 'warning',
|
|
@@ -15,11 +15,11 @@ var APPEARANCE_TO_COLOR_MAP = {
|
|
|
15
15
|
success: 'success'
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Codemod to migrate Lozenge component
|
|
18
|
+
* Codemod to migrate Lozenge component appearance semantic values.
|
|
19
19
|
*
|
|
20
20
|
* This codemod:
|
|
21
|
-
* 1.
|
|
22
|
-
* 2. Maps
|
|
21
|
+
* 1. Updates `appearance` prop values to new semantic values
|
|
22
|
+
* 2. Maps old semantic values to new semantic values (e.g. default → neutral, inprogress → information)
|
|
23
23
|
* 3. Adds comments for dynamic values that need manual verification
|
|
24
24
|
*/
|
|
25
25
|
export default function transformer(file, api) {
|
|
@@ -101,27 +101,24 @@ export default function transformer(file, api) {
|
|
|
101
101
|
appearanceValue = element.appearanceValue;
|
|
102
102
|
var openingElement = path.value.openingElement;
|
|
103
103
|
|
|
104
|
-
//
|
|
104
|
+
// Update appearance prop values to new semantic values
|
|
105
105
|
if (hasAppearanceProp) {
|
|
106
106
|
var _openingElement$attri2;
|
|
107
107
|
(_openingElement$attri2 = openingElement.attributes) === null || _openingElement$attri2 === void 0 || _openingElement$attri2.forEach(function (attr) {
|
|
108
108
|
var _attr$name2;
|
|
109
109
|
if (attr.type === 'JSXAttribute' && ((_attr$name2 = attr.name) === null || _attr$name2 === void 0 ? void 0 : _attr$name2.type) === 'JSXIdentifier' && attr.name.name === 'appearance') {
|
|
110
|
-
// Rename appearance to color
|
|
111
|
-
attr.name.name = 'color';
|
|
112
|
-
|
|
113
110
|
// Handle different types of appearance values
|
|
114
111
|
if (appearanceValue === 'dynamic') {
|
|
115
112
|
// For dynamic values, add a comment
|
|
116
|
-
addCommentBefore(j, j(path), "FIXME: This Lozenge component uses a dynamic `appearance` prop
|
|
117
|
-
} else if (appearanceValue && !
|
|
113
|
+
addCommentBefore(j, j(path), "FIXME: This Lozenge component uses a dynamic `appearance` prop with updated semantic values.\nPlease verify that the values being passed use the new semantic values: neutral, information, warning, discovery, danger, success.\nOld values mapping: default\u2192neutral, inprogress\u2192information, moved\u2192warning, new\u2192discovery, removed\u2192danger, success\u2192success.");
|
|
114
|
+
} else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
118
115
|
// For invalid string values, add a warning comment
|
|
119
|
-
addCommentBefore(j, j(path), "FIXME: This Lozenge component uses an
|
|
120
|
-
} else if (appearanceValue &&
|
|
116
|
+
addCommentBefore(j, j(path), "FIXME: This Lozenge component uses an unknown `appearance` value \"".concat(appearanceValue, "\".\nValid new semantic appearance values are: ").concat(Object.values(OLD_TO_NEW_APPEARANCE_MAP).join(', '), ".\nPlease update this value to a valid semantic appearance value."));
|
|
117
|
+
} else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
|
|
121
118
|
var _attr$value3;
|
|
122
|
-
// For valid string values, update the value to the
|
|
119
|
+
// For valid string values, update the value to the new semantic value
|
|
123
120
|
if (((_attr$value3 = attr.value) === null || _attr$value3 === void 0 ? void 0 : _attr$value3.type) === 'StringLiteral') {
|
|
124
|
-
attr.value.value =
|
|
121
|
+
attr.value.value = OLD_TO_NEW_APPEARANCE_MAP[appearanceValue];
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
124
|
}
|
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
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
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
|
|
6
|
+
import lozengeAppearanceSemanticMigrationTransformer from './codemods/lozenge-appearance-semantic-migration';
|
|
7
7
|
export default function transformer(_x, _x2) {
|
|
8
8
|
return _transformer.apply(this, arguments);
|
|
9
9
|
}
|
|
@@ -13,7 +13,7 @@ function _transformer() {
|
|
|
13
13
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
14
|
while (1) switch (_context.prev = _context.next) {
|
|
15
15
|
case 0:
|
|
16
|
-
transformers = [
|
|
16
|
+
transformers = [lozengeAppearanceSemanticMigrationTransformer];
|
|
17
17
|
src = file.source;
|
|
18
18
|
transformers.forEach(function (transformer) {
|
|
19
19
|
if (typeof src === 'undefined') {
|
|
@@ -7,6 +7,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
7
7
|
/* eslint-disable no-console */
|
|
8
8
|
import fs from 'fs/promises';
|
|
9
9
|
import path from 'path';
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
10
12
|
import { v4 as uuidv4 } from 'uuid';
|
|
11
13
|
function writeToCsv(_x, _x2) {
|
|
12
14
|
return _writeToCsv.apply(this, arguments);
|
|
@@ -288,7 +290,8 @@ function _writeReports() {
|
|
|
288
290
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
289
291
|
while (1) switch (_context6.prev = _context6.next) {
|
|
290
292
|
case 0:
|
|
291
|
-
|
|
293
|
+
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
294
|
+
replacementsFilePath = path.join(reportFolder, "".concat(uuidv4(), "_success.csv")); // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
292
295
|
nonReplacementsFilePath = path.join(reportFolder, "".concat(uuidv4(), "_failed.csv"));
|
|
293
296
|
_context6.next = 4;
|
|
294
297
|
return fs.mkdir(reportFolder, {
|
|
@@ -10,7 +10,7 @@ import './migrate-icon-object-to-object/migrate-icon-object-to-object';
|
|
|
10
10
|
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
11
11
|
import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
|
|
12
12
|
import './remove-token-fallbacks/remove-token-fallbacks';
|
|
13
|
-
import './lozenge-appearance-
|
|
13
|
+
import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
|
|
14
14
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
15
15
|
declare const presets: string[];
|
|
16
16
|
export default presets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type API, type FileInfo } from 'jscodeshift';
|
|
2
|
+
/**
|
|
3
|
+
* Codemod to migrate Lozenge component appearance semantic values.
|
|
4
|
+
*
|
|
5
|
+
* This codemod:
|
|
6
|
+
* 1. Updates `appearance` prop values to new semantic values
|
|
7
|
+
* 2. Maps old semantic values to new semantic values (e.g. default → neutral, inprogress → information)
|
|
8
|
+
* 3. Adds comments for dynamic values that need manual verification
|
|
9
|
+
*/
|
|
10
|
+
export default function transformer(file: FileInfo, api: API): string;
|
|
@@ -10,7 +10,7 @@ import './migrate-icon-object-to-object/migrate-icon-object-to-object';
|
|
|
10
10
|
import './upgrade-pragmatic-drag-and-drop-to-stable/upgrade-pragmatic-drag-and-drop-to-stable';
|
|
11
11
|
import './remove-dark-theme-vr-options/remove-dark-theme-vr-options';
|
|
12
12
|
import './remove-token-fallbacks/remove-token-fallbacks';
|
|
13
|
-
import './lozenge-appearance-
|
|
13
|
+
import './lozenge-appearance-semantic-migration/lozenge-appearance-semantic-migration';
|
|
14
14
|
import './lozenge-to-tag-migration/lozenge-to-tag-migration';
|
|
15
15
|
declare const presets: string[];
|
|
16
16
|
export default presets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type API, type FileInfo } from 'jscodeshift';
|
|
2
|
+
/**
|
|
3
|
+
* Codemod to migrate Lozenge component appearance semantic values.
|
|
4
|
+
*
|
|
5
|
+
* This codemod:
|
|
6
|
+
* 1. Updates `appearance` prop values to new semantic values
|
|
7
|
+
* 2. Maps old semantic values to new semantic values (e.g. default → neutral, inprogress → information)
|
|
8
|
+
* 3. Adds comments for dynamic values that need manual verification
|
|
9
|
+
*/
|
|
10
|
+
export default function transformer(file: FileInfo, api: API): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.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,7 @@
|
|
|
29
29
|
"bin": "./bin/codemod-cli.js",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
32
|
-
"@atlaskit/tokens": "^
|
|
32
|
+
"@atlaskit/tokens": "^8.0.0",
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
34
|
"@codeshift/utils": "^0.2.4",
|
|
35
35
|
"@hypermod/utils": "^0.4.2",
|
package/dist/types/presets/lozenge-appearance-to-color/codemods/lozenge-appearance-to-color.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type API, type FileInfo } from 'jscodeshift';
|
|
2
|
-
/**
|
|
3
|
-
* Codemod to migrate Lozenge component from `appearance` prop to `color` prop.
|
|
4
|
-
*
|
|
5
|
-
* This codemod:
|
|
6
|
-
* 1. Renames `appearance` prop to `color` for semantic values
|
|
7
|
-
* 2. Maps existing semantic values directly (e.g. success → success)
|
|
8
|
-
* 3. Adds comments for dynamic values that need manual verification
|
|
9
|
-
*/
|
|
10
|
-
export default function transformer(file: FileInfo, api: API): string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type API, type FileInfo } from 'jscodeshift';
|
|
2
|
-
/**
|
|
3
|
-
* Codemod to migrate Lozenge component from `appearance` prop to `color` prop.
|
|
4
|
-
*
|
|
5
|
-
* This codemod:
|
|
6
|
-
* 1. Renames `appearance` prop to `color` for semantic values
|
|
7
|
-
* 2. Maps existing semantic values directly (e.g. success → success)
|
|
8
|
-
* 3. Adds comments for dynamic values that need manual verification
|
|
9
|
-
*/
|
|
10
|
-
export default function transformer(file: FileInfo, api: API): string;
|
|
File without changes
|