@atlaskit/codemod-cli 1.0.0 → 1.0.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`dc456d412b841`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dc456d412b841) -
8
+ Fixed lozenge-appearance-semantic-migration codemod incorrectly flagging already-migrated semantic
9
+ values as unknown.
10
+
11
+ ## 1.0.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 1.0.0
4
18
 
5
19
  ### Major Changes
package/dist/cjs/main.js CHANGED
@@ -367,7 +367,7 @@ function _main() {
367
367
  case 4:
368
368
  _yield$parseArgs = _context6.sent;
369
369
  packages = _yield$parseArgs.packages;
370
- _process$env$_PACKAGE = "0.0.0-development", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
370
+ _process$env$_PACKAGE = "1.0.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
371
371
  logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
372
372
  if (packages && packages.length > 0) {
373
373
  logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = transformer;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
9
  var _utils = require("@hypermod/utils");
8
10
  var _codemodUtils = require("@atlaskit/codemod-utils");
9
11
  var LOZENGE_ENTRY_POINT = '@atlaskit/lozenge';
@@ -20,6 +22,9 @@ var OLD_TO_NEW_APPEARANCE_MAP = {
20
22
  removed: 'danger',
21
23
  success: 'success'
22
24
  };
25
+
26
+ // New semantic values that are already valid and should be left unchanged
27
+ var NEW_SEMANTIC_VALUES = new Set(Object.values(OLD_TO_NEW_APPEARANCE_MAP));
23
28
  /**
24
29
  * Codemod to migrate Lozenge component appearance semantic values.
25
30
  *
@@ -117,9 +122,11 @@ function transformer(file, api) {
117
122
  if (appearanceValue === 'dynamic') {
118
123
  // For dynamic values, add a comment
119
124
  (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.");
125
+ } else if (appearanceValue && NEW_SEMANTIC_VALUES.has(appearanceValue)) {
126
+ // Already using new semantic values, skip
120
127
  } else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
121
128
  // For invalid string values, add a warning comment
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."));
129
+ (0, _codemodUtils.addCommentBefore)(j, j(path), "FIXME: This Lozenge component uses an unknown `appearance` value \"".concat(appearanceValue, "\".\nValid new semantic appearance values are: ").concat((0, _toConsumableArray2.default)(NEW_SEMANTIC_VALUES).join(', '), ".\nPlease update this value to a valid semantic appearance value."));
123
130
  } else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
124
131
  var _attr$value3;
125
132
  // For valid string values, update the value to the new semantic value
@@ -14,6 +14,9 @@ const OLD_TO_NEW_APPEARANCE_MAP = {
14
14
  removed: 'danger',
15
15
  success: 'success'
16
16
  };
17
+
18
+ // New semantic values that are already valid and should be left unchanged
19
+ const NEW_SEMANTIC_VALUES = new Set(Object.values(OLD_TO_NEW_APPEARANCE_MAP));
17
20
  /**
18
21
  * Codemod to migrate Lozenge component appearance semantic values.
19
22
  *
@@ -115,10 +118,12 @@ export default function transformer(file, api) {
115
118
  addCommentBefore(j, j(path), `FIXME: This Lozenge component uses a dynamic \`appearance\` prop with updated semantic values.
116
119
  Please verify that the values being passed use the new semantic values: neutral, information, warning, discovery, danger, success.
117
120
  Old values mapping: default→neutral, inprogress→information, moved→warning, new→discovery, removed→danger, success→success.`);
121
+ } else if (appearanceValue && NEW_SEMANTIC_VALUES.has(appearanceValue)) {
122
+ // Already using new semantic values, skip
118
123
  } else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
119
124
  // For invalid string values, add a warning comment
120
125
  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(', ')}.
126
+ Valid new semantic appearance values are: ${[...NEW_SEMANTIC_VALUES].join(', ')}.
122
127
  Please update this value to a valid semantic appearance value.`);
123
128
  } else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
124
129
  var _attr$value3;
package/dist/esm/main.js CHANGED
@@ -360,7 +360,7 @@ function _main() {
360
360
  case 4:
361
361
  _yield$parseArgs = _context6.sent;
362
362
  packages = _yield$parseArgs.packages;
363
- _process$env$_PACKAGE = "0.0.0-development", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
363
+ _process$env$_PACKAGE = "1.0.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
364
364
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
365
365
  if (packages && packages.length > 0) {
366
366
  logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import { getImportDeclaration } from '@hypermod/utils';
2
3
  import { addCommentBefore } from '@atlaskit/codemod-utils';
3
4
  var LOZENGE_ENTRY_POINT = '@atlaskit/lozenge';
@@ -14,6 +15,9 @@ var OLD_TO_NEW_APPEARANCE_MAP = {
14
15
  removed: 'danger',
15
16
  success: 'success'
16
17
  };
18
+
19
+ // New semantic values that are already valid and should be left unchanged
20
+ var NEW_SEMANTIC_VALUES = new Set(Object.values(OLD_TO_NEW_APPEARANCE_MAP));
17
21
  /**
18
22
  * Codemod to migrate Lozenge component appearance semantic values.
19
23
  *
@@ -111,9 +115,11 @@ export default function transformer(file, api) {
111
115
  if (appearanceValue === 'dynamic') {
112
116
  // For dynamic values, add a comment
113
117
  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.");
118
+ } else if (appearanceValue && NEW_SEMANTIC_VALUES.has(appearanceValue)) {
119
+ // Already using new semantic values, skip
114
120
  } else if (appearanceValue && !OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
115
121
  // For invalid string values, add a warning comment
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."));
122
+ addCommentBefore(j, j(path), "FIXME: This Lozenge component uses an unknown `appearance` value \"".concat(appearanceValue, "\".\nValid new semantic appearance values are: ").concat(_toConsumableArray(NEW_SEMANTIC_VALUES).join(', '), ".\nPlease update this value to a valid semantic appearance value."));
117
123
  } else if (appearanceValue && OLD_TO_NEW_APPEARANCE_MAP[appearanceValue]) {
118
124
  var _attr$value3;
119
125
  // For valid string values, update the value to the new semantic value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.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/"
@@ -31,7 +31,7 @@
31
31
  "@atlaskit/codemod-utils": "^4.2.0",
32
32
  "@atlaskit/icon": "^34.0.0",
33
33
  "@atlaskit/icon-lab": "^6.4.0",
34
- "@atlaskit/tokens": "^11.4.0",
34
+ "@atlaskit/tokens": "^12.0.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "@codeshift/utils": "^0.2.4",
37
37
  "@hypermod/utils": "^0.4.2",