@atlaskit/codemod-cli 0.27.3 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/main.js +18 -13
- package/dist/cjs/presets/remove-token-fallbacks/remove-token-fallbacks.js +294 -43
- package/dist/cjs/presets/remove-token-fallbacks/utils/chunk.js +14 -0
- package/dist/cjs/presets/remove-token-fallbacks/utils/normalize-values.js +4 -3
- package/dist/cjs/presets/remove-token-fallbacks/utils/remove-unused-imports.js +2 -2
- package/dist/cjs/presets/remove-token-fallbacks/utils/reporter.js +28 -21
- package/dist/cjs/presets/remove-token-fallbacks/utils/token-processor.js +154 -46
- package/dist/es2019/main.js +7 -1
- package/dist/es2019/presets/remove-token-fallbacks/remove-token-fallbacks.js +122 -17
- package/dist/es2019/presets/remove-token-fallbacks/utils/chunk.js +8 -0
- package/dist/es2019/presets/remove-token-fallbacks/utils/normalize-values.js +4 -3
- package/dist/es2019/presets/remove-token-fallbacks/utils/remove-unused-imports.js +3 -3
- package/dist/es2019/presets/remove-token-fallbacks/utils/reporter.js +6 -1
- package/dist/es2019/presets/remove-token-fallbacks/utils/token-processor.js +85 -9
- package/dist/esm/main.js +18 -13
- package/dist/esm/presets/remove-token-fallbacks/remove-token-fallbacks.js +294 -41
- package/dist/esm/presets/remove-token-fallbacks/utils/chunk.js +8 -0
- package/dist/esm/presets/remove-token-fallbacks/utils/normalize-values.js +4 -3
- package/dist/esm/presets/remove-token-fallbacks/utils/remove-unused-imports.js +2 -2
- package/dist/esm/presets/remove-token-fallbacks/utils/reporter.js +28 -21
- package/dist/esm/presets/remove-token-fallbacks/utils/token-processor.js +154 -46
- package/dist/types/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +1 -1
- package/dist/types/presets/remove-token-fallbacks/utils/chunk.d.ts +1 -0
- package/dist/types-ts4.5/presets/remove-token-fallbacks/remove-token-fallbacks.d.ts +1 -1
- package/dist/types-ts4.5/presets/remove-token-fallbacks/utils/chunk.d.ts +1 -0
- package/package.json +4 -4
|
@@ -40,12 +40,12 @@ export function removeUnusedImports(importDeclarations, j) {
|
|
|
40
40
|
};
|
|
41
41
|
var processImportDeclaration = function processImportDeclaration(importDeclaration) {
|
|
42
42
|
var _importDeclaration$va, _importDeclaration$va2;
|
|
43
|
-
if (((_importDeclaration$va = importDeclaration.value.specifiers) === null || _importDeclaration$va === void 0 ? void 0 : _importDeclaration$va.length) === 0) {
|
|
43
|
+
if (((_importDeclaration$va = importDeclaration.value) === null || _importDeclaration$va === void 0 || (_importDeclaration$va = _importDeclaration$va.specifiers) === null || _importDeclaration$va === void 0 ? void 0 : _importDeclaration$va.length) === 0) {
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
var hadUnusedDefaultImport = removeUnusedDefaultImport(importDeclaration);
|
|
47
47
|
var hadUnusedNonDefaultImports = removeUnusedNonDefaultImports(importDeclaration);
|
|
48
|
-
if (((_importDeclaration$va2 = importDeclaration.value.specifiers) === null || _importDeclaration$va2 === void 0 ? void 0 : _importDeclaration$va2.length) === 0) {
|
|
48
|
+
if (((_importDeclaration$va2 = importDeclaration.value) === null || _importDeclaration$va2 === void 0 || (_importDeclaration$va2 = _importDeclaration$va2.specifiers) === null || _importDeclaration$va2 === void 0 ? void 0 : _importDeclaration$va2.length) === 0) {
|
|
49
49
|
j(importDeclaration).remove();
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
@@ -74,41 +74,47 @@ function _clearFolder() {
|
|
|
74
74
|
while (1) switch (_context3.prev = _context3.next) {
|
|
75
75
|
case 0:
|
|
76
76
|
console.log('Clearing report folder:', reportFolder);
|
|
77
|
+
// Create the folder if it doesn't exist
|
|
77
78
|
_context3.next = 3;
|
|
78
|
-
return fs.
|
|
79
|
+
return fs.mkdir(reportFolder, {
|
|
80
|
+
recursive: true
|
|
81
|
+
});
|
|
79
82
|
case 3:
|
|
83
|
+
_context3.next = 5;
|
|
84
|
+
return fs.readdir(reportFolder);
|
|
85
|
+
case 5:
|
|
80
86
|
filesToDelete = _context3.sent;
|
|
81
87
|
_iterator = _createForOfIteratorHelper(filesToDelete);
|
|
82
|
-
_context3.prev =
|
|
88
|
+
_context3.prev = 7;
|
|
83
89
|
_iterator.s();
|
|
84
|
-
case
|
|
90
|
+
case 9:
|
|
85
91
|
if ((_step = _iterator.n()).done) {
|
|
86
|
-
_context3.next =
|
|
92
|
+
_context3.next = 16;
|
|
87
93
|
break;
|
|
88
94
|
}
|
|
89
95
|
file = _step.value;
|
|
90
96
|
filePath = path.join(reportFolder, file);
|
|
91
|
-
_context3.next =
|
|
97
|
+
_context3.next = 14;
|
|
92
98
|
return fs.unlink(filePath);
|
|
93
|
-
case 12:
|
|
94
|
-
_context3.next = 7;
|
|
95
|
-
break;
|
|
96
99
|
case 14:
|
|
97
|
-
_context3.next =
|
|
100
|
+
_context3.next = 9;
|
|
98
101
|
break;
|
|
99
102
|
case 16:
|
|
100
|
-
_context3.
|
|
101
|
-
|
|
103
|
+
_context3.next = 21;
|
|
104
|
+
break;
|
|
105
|
+
case 18:
|
|
106
|
+
_context3.prev = 18;
|
|
107
|
+
_context3.t0 = _context3["catch"](7);
|
|
102
108
|
_iterator.e(_context3.t0);
|
|
103
|
-
case
|
|
104
|
-
_context3.prev =
|
|
109
|
+
case 21:
|
|
110
|
+
_context3.prev = 21;
|
|
105
111
|
_iterator.f();
|
|
106
|
-
return _context3.finish(
|
|
107
|
-
case
|
|
112
|
+
return _context3.finish(21);
|
|
113
|
+
case 24:
|
|
108
114
|
case "end":
|
|
109
115
|
return _context3.stop();
|
|
110
116
|
}
|
|
111
|
-
}, _callee3, null, [[
|
|
117
|
+
}, _callee3, null, [[7, 18, 21, 24]]);
|
|
112
118
|
}));
|
|
113
119
|
return _clearFolder.apply(this, arguments);
|
|
114
120
|
}
|
|
@@ -117,16 +123,17 @@ function saveFilePaths(_x5, _x6) {
|
|
|
117
123
|
}
|
|
118
124
|
function _saveFilePaths() {
|
|
119
125
|
_saveFilePaths = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(reportFolder, files) {
|
|
120
|
-
var filesTxtPath;
|
|
126
|
+
var filesTxtPath, sortedFiles;
|
|
121
127
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
122
128
|
while (1) switch (_context4.prev = _context4.next) {
|
|
123
129
|
case 0:
|
|
124
130
|
filesTxtPath = path.join(reportFolder, 'files.txt');
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
sortedFiles = Array.from(files).sort(); // Sort the file paths alphabetically
|
|
132
|
+
_context4.next = 4;
|
|
133
|
+
return fs.writeFile(filesTxtPath, sortedFiles.map(function (filePath) {
|
|
127
134
|
return "\"".concat(filePath, "\"");
|
|
128
|
-
}).join('
|
|
129
|
-
case
|
|
135
|
+
}).join('\n'), 'utf-8');
|
|
136
|
+
case 4:
|
|
130
137
|
case "end":
|
|
131
138
|
return _context4.stop();
|
|
132
139
|
}
|
|
@@ -87,7 +87,7 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
87
87
|
value: function () {
|
|
88
88
|
var _processSingleToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(callPath) {
|
|
89
89
|
var _callPath$node$loc2;
|
|
90
|
-
var args, line, tokenKey, isSkipped, tokenValue, _ref, rawFallbackValue, fallbackValue, resolvedImportDeclaration, resolvedLocalVarDeclaration, _normalizeValues, difference, isAcceptableDifference, tokenLogValue, fallbackLogValue, normalizedTokenValue, normalizedFallbackValue, areEqual, logData, fallbackRemoved, importDeclaration, localVarDeclaration, message;
|
|
90
|
+
var args, line, tokenKey, isSkipped, tokenValue, _ref, rawFallbackValue, fallbackValue, resolvedImportDeclaration, resolvedLocalVarDeclaration, _normalizeValues, difference, isAcceptableDifference, tokenLogValue, fallbackLogValue, normalizedTokenValue, normalizedFallbackValue, areEqual, logData, fallbackRemoved, importDeclaration, localVarDeclaration, isBorderToken, message;
|
|
91
91
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
92
92
|
while (1) switch (_context2.prev = _context2.next) {
|
|
93
93
|
case 0:
|
|
@@ -117,7 +117,9 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
117
117
|
resolvedLocalVarDeclaration: undefined
|
|
118
118
|
});
|
|
119
119
|
case 8:
|
|
120
|
-
isSkipped = tokenKey.startsWith('elevation.shadow') ||
|
|
120
|
+
isSkipped = false; // tokenKey.startsWith('elevation.shadow') ||
|
|
121
|
+
// tokenKey.startsWith('font.body') ||
|
|
122
|
+
// tokenKey.startsWith('font.heading');
|
|
121
123
|
tokenValue = isSkipped ? '' : this.tokenMap[tokenKey];
|
|
122
124
|
this.logVerbose("Token value from tokenMap: ".concat(chalk.magenta(tokenValue), " for key: ").concat(chalk.yellow(tokenKey)));
|
|
123
125
|
if (!isSkipped) {
|
|
@@ -156,7 +158,8 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
156
158
|
difference: difference
|
|
157
159
|
};
|
|
158
160
|
fallbackRemoved = false;
|
|
159
|
-
|
|
161
|
+
isBorderToken = tokenKey.startsWith('border');
|
|
162
|
+
if (areEqual || (isAcceptableDifference || this.options.forceUpdate) && !isBorderToken) {
|
|
160
163
|
this.log(chalk.green(areEqual ? 'Token value and fallback value are equal, removing fallback' : 'Token value and fallback value are within acceptable difference threshold, removing fallback'));
|
|
161
164
|
args.pop();
|
|
162
165
|
this.details.replaced.push(logData);
|
|
@@ -164,7 +167,7 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
164
167
|
importDeclaration = resolvedImportDeclaration;
|
|
165
168
|
localVarDeclaration = resolvedLocalVarDeclaration;
|
|
166
169
|
} else {
|
|
167
|
-
message = normalizedFallbackValue === undefined ? "Fallback value could not be resolved" : "Values mismatched significantly";
|
|
170
|
+
message = isBorderToken ? 'Skip modifying border token' : normalizedFallbackValue === undefined ? "Fallback value could not be resolved" : "Values mismatched significantly";
|
|
168
171
|
this.logError(message);
|
|
169
172
|
if (this.options.addEslintComments) {
|
|
170
173
|
addOrUpdateEslintIgnoreComment(this.j, tokenValue, fallbackValue, callPath);
|
|
@@ -178,7 +181,7 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
178
181
|
resolvedImportDeclaration: importDeclaration,
|
|
179
182
|
resolvedLocalVarDeclaration: localVarDeclaration
|
|
180
183
|
});
|
|
181
|
-
case
|
|
184
|
+
case 31:
|
|
182
185
|
case "end":
|
|
183
186
|
return _context2.stop();
|
|
184
187
|
}
|
|
@@ -321,10 +324,57 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
321
324
|
key: "processFallbackAsMemberExpression",
|
|
322
325
|
value: function () {
|
|
323
326
|
var _processFallbackAsMemberExpression = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(fallbackValueNode) {
|
|
324
|
-
var objectName, propertyName, fallbackValue,
|
|
327
|
+
var objectName, propertyName, fallbackValue, resolvedImportDeclaration, resolvedLocalVarDeclaration, _getFullMemberPath, fullMemberPath, pathSegments, localVarDeclaration, _importDeclaration, rawFallbackValue, importDeclaration, importSource;
|
|
325
328
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
326
329
|
while (1) switch (_context5.prev = _context5.next) {
|
|
327
330
|
case 0:
|
|
331
|
+
// Function to get full member expression path as string
|
|
332
|
+
_getFullMemberPath = function getFullMemberPath(node) {
|
|
333
|
+
if (node.type === 'Identifier') {
|
|
334
|
+
return node.name;
|
|
335
|
+
} else if (node.type === 'MemberExpression') {
|
|
336
|
+
return "".concat(_getFullMemberPath(node.object), ".").concat(node.property.type === 'Identifier' ? node.property.name : '');
|
|
337
|
+
}
|
|
338
|
+
return '';
|
|
339
|
+
};
|
|
340
|
+
fullMemberPath = _getFullMemberPath(fallbackValueNode); // Detect long member expression paths
|
|
341
|
+
pathSegments = fullMemberPath.split('.');
|
|
342
|
+
if (!(pathSegments.length > 2)) {
|
|
343
|
+
_context5.next = 9;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
this.logVerbose("Detected long member expression: ".concat(chalk.yellow(fullMemberPath), ". Just resolving import or local variable declaration."));
|
|
347
|
+
|
|
348
|
+
// Find the import statement or local variable for the top-level object
|
|
349
|
+
objectName = pathSegments[0];
|
|
350
|
+
|
|
351
|
+
// Check if it's a local variable
|
|
352
|
+
localVarDeclaration = this.source.find(this.j.VariableDeclarator, {
|
|
353
|
+
id: {
|
|
354
|
+
name: objectName
|
|
355
|
+
}
|
|
356
|
+
}).at(0);
|
|
357
|
+
if (localVarDeclaration.size()) {
|
|
358
|
+
resolvedLocalVarDeclaration = localVarDeclaration.paths()[0];
|
|
359
|
+
this.logVerbose("Resolved local variable declaration for: ".concat(chalk.yellow(objectName)));
|
|
360
|
+
} else {
|
|
361
|
+
// Search for import declaration
|
|
362
|
+
_importDeclaration = this.source.find(this.j.ImportDeclaration).filter(this.createImportFilter(objectName)).at(0);
|
|
363
|
+
if (_importDeclaration.size()) {
|
|
364
|
+
resolvedImportDeclaration = _importDeclaration.paths()[0];
|
|
365
|
+
this.logVerbose("Resolved import declaration for: ".concat(chalk.yellow(objectName)));
|
|
366
|
+
} else {
|
|
367
|
+
this.logError("Could not resolve import or local variable for: ".concat(chalk.yellow(objectName)));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return _context5.abrupt("return", {
|
|
371
|
+
rawFallbackValue: fullMemberPath,
|
|
372
|
+
fallbackValue: undefined,
|
|
373
|
+
resolvedImportDeclaration: resolvedImportDeclaration,
|
|
374
|
+
resolvedLocalVarDeclaration: resolvedLocalVarDeclaration
|
|
375
|
+
});
|
|
376
|
+
case 9:
|
|
377
|
+
// Existing logic for member expressions with shorter paths
|
|
328
378
|
if (fallbackValueNode.object.type === 'Identifier') {
|
|
329
379
|
objectName = fallbackValueNode.object.name;
|
|
330
380
|
}
|
|
@@ -334,7 +384,7 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
334
384
|
propertyName = fallbackValueNode.property.value;
|
|
335
385
|
}
|
|
336
386
|
if (!(!objectName || !propertyName)) {
|
|
337
|
-
_context5.next =
|
|
387
|
+
_context5.next = 14;
|
|
338
388
|
break;
|
|
339
389
|
}
|
|
340
390
|
this.logError("Could not determine object and property names from member expression: ".concat(chalk.yellow(fallbackValueNode)));
|
|
@@ -344,36 +394,37 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
344
394
|
resolvedImportDeclaration: undefined,
|
|
345
395
|
resolvedLocalVarDeclaration: undefined
|
|
346
396
|
});
|
|
347
|
-
case
|
|
397
|
+
case 14:
|
|
348
398
|
rawFallbackValue = "".concat(objectName, ".").concat(propertyName);
|
|
349
399
|
this.logVerbose("Fallback is a member expression: ".concat(chalk.yellow(rawFallbackValue), ", attempting to resolve..."));
|
|
400
|
+
|
|
350
401
|
// Find the import statement for the object
|
|
351
402
|
importDeclaration = this.source.find(this.j.ImportDeclaration).filter(this.createImportFilter(objectName)).at(0);
|
|
352
403
|
if (!importDeclaration.size()) {
|
|
353
|
-
_context5.next =
|
|
404
|
+
_context5.next = 25;
|
|
354
405
|
break;
|
|
355
406
|
}
|
|
356
407
|
importSource = importDeclaration.get().value.source.value;
|
|
357
|
-
_context5.next =
|
|
408
|
+
_context5.next = 21;
|
|
358
409
|
return this.resolveValueFromImport(this.rootDir, importSource, objectName, propertyName);
|
|
359
|
-
case
|
|
410
|
+
case 21:
|
|
360
411
|
fallbackValue = _context5.sent;
|
|
361
412
|
if (fallbackValue !== undefined) {
|
|
362
413
|
resolvedImportDeclaration = importDeclaration.paths()[0];
|
|
363
414
|
this.logVerbose("Resolved fallback value from member expression: ".concat(chalk.yellow(fallbackValue)));
|
|
364
415
|
}
|
|
365
|
-
_context5.next =
|
|
416
|
+
_context5.next = 26;
|
|
366
417
|
break;
|
|
367
|
-
case
|
|
418
|
+
case 25:
|
|
368
419
|
this.logError("Could not find import for member expression: ".concat(chalk.yellow(rawFallbackValue)));
|
|
369
|
-
case
|
|
420
|
+
case 26:
|
|
370
421
|
return _context5.abrupt("return", {
|
|
371
422
|
rawFallbackValue: rawFallbackValue,
|
|
372
423
|
fallbackValue: fallbackValue,
|
|
373
424
|
resolvedImportDeclaration: resolvedImportDeclaration,
|
|
374
425
|
resolvedLocalVarDeclaration: undefined
|
|
375
426
|
});
|
|
376
|
-
case
|
|
427
|
+
case 27:
|
|
377
428
|
case "end":
|
|
378
429
|
return _context5.stop();
|
|
379
430
|
}
|
|
@@ -388,51 +439,108 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
388
439
|
key: "processFallbackAsTemplateLiteral",
|
|
389
440
|
value: function () {
|
|
390
441
|
var _processFallbackAsTemplateLiteral = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(fallbackValueNode) {
|
|
391
|
-
var expressions, rawFallbackValue, fallbackValue,
|
|
442
|
+
var expressions, quasis, resolvedImportDeclaration, resolvedLocalVarDeclaration, rawFallbackValue, fallbackValue, _iterator, _step, _expression, result, _result, exprValue, expression, _result2, _result3;
|
|
392
443
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
393
444
|
while (1) switch (_context6.prev = _context6.next) {
|
|
394
445
|
case 0:
|
|
395
446
|
expressions = fallbackValueNode.expressions;
|
|
396
|
-
rawFallbackValue = '';
|
|
397
447
|
quasis = fallbackValueNode.quasis;
|
|
448
|
+
rawFallbackValue = '';
|
|
398
449
|
if (!(expressions.length !== 1 || quasis.length !== 2)) {
|
|
399
|
-
_context6.next =
|
|
450
|
+
_context6.next = 35;
|
|
400
451
|
break;
|
|
401
452
|
}
|
|
402
453
|
this.logError("Unsupported template literal structure");
|
|
454
|
+
|
|
455
|
+
// Attempt to resolve any imports or local variables used in expressions
|
|
456
|
+
_iterator = _createForOfIteratorHelper(expressions);
|
|
457
|
+
_context6.prev = 6;
|
|
458
|
+
_iterator.s();
|
|
459
|
+
case 8:
|
|
460
|
+
if ((_step = _iterator.n()).done) {
|
|
461
|
+
_context6.next = 26;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
_expression = _step.value;
|
|
465
|
+
if (!(_expression.type === 'Identifier')) {
|
|
466
|
+
_context6.next = 18;
|
|
467
|
+
break;
|
|
468
|
+
}
|
|
469
|
+
_context6.next = 13;
|
|
470
|
+
return this.processFallbackAsIdentifier(_expression);
|
|
471
|
+
case 13:
|
|
472
|
+
result = _context6.sent;
|
|
473
|
+
if (result.resolvedImportDeclaration) {
|
|
474
|
+
resolvedImportDeclaration = result.resolvedImportDeclaration;
|
|
475
|
+
}
|
|
476
|
+
if (result.resolvedLocalVarDeclaration) {
|
|
477
|
+
resolvedLocalVarDeclaration = result.resolvedLocalVarDeclaration;
|
|
478
|
+
}
|
|
479
|
+
_context6.next = 24;
|
|
480
|
+
break;
|
|
481
|
+
case 18:
|
|
482
|
+
if (!(_expression.type === 'MemberExpression')) {
|
|
483
|
+
_context6.next = 24;
|
|
484
|
+
break;
|
|
485
|
+
}
|
|
486
|
+
_context6.next = 21;
|
|
487
|
+
return this.processFallbackAsMemberExpression(_expression);
|
|
488
|
+
case 21:
|
|
489
|
+
_result = _context6.sent;
|
|
490
|
+
if (_result.resolvedImportDeclaration) {
|
|
491
|
+
resolvedImportDeclaration = _result.resolvedImportDeclaration;
|
|
492
|
+
}
|
|
493
|
+
if (_result.resolvedLocalVarDeclaration) {
|
|
494
|
+
resolvedLocalVarDeclaration = _result.resolvedLocalVarDeclaration;
|
|
495
|
+
}
|
|
496
|
+
case 24:
|
|
497
|
+
_context6.next = 8;
|
|
498
|
+
break;
|
|
499
|
+
case 26:
|
|
500
|
+
_context6.next = 31;
|
|
501
|
+
break;
|
|
502
|
+
case 28:
|
|
503
|
+
_context6.prev = 28;
|
|
504
|
+
_context6.t0 = _context6["catch"](6);
|
|
505
|
+
_iterator.e(_context6.t0);
|
|
506
|
+
case 31:
|
|
507
|
+
_context6.prev = 31;
|
|
508
|
+
_iterator.f();
|
|
509
|
+
return _context6.finish(31);
|
|
510
|
+
case 34:
|
|
403
511
|
return _context6.abrupt("return", {
|
|
404
512
|
rawFallbackValue: rawFallbackValue,
|
|
405
513
|
fallbackValue: fallbackValue,
|
|
406
|
-
resolvedImportDeclaration:
|
|
407
|
-
resolvedLocalVarDeclaration:
|
|
514
|
+
resolvedImportDeclaration: resolvedImportDeclaration,
|
|
515
|
+
resolvedLocalVarDeclaration: resolvedLocalVarDeclaration
|
|
408
516
|
});
|
|
409
|
-
case
|
|
517
|
+
case 35:
|
|
410
518
|
expression = expressions[0];
|
|
411
519
|
if (!(expression.type === 'Identifier')) {
|
|
412
|
-
_context6.next =
|
|
520
|
+
_context6.next = 45;
|
|
413
521
|
break;
|
|
414
522
|
}
|
|
415
|
-
_context6.next =
|
|
523
|
+
_context6.next = 39;
|
|
416
524
|
return this.processFallbackAsIdentifier(expression);
|
|
417
|
-
case
|
|
418
|
-
|
|
419
|
-
exprValue =
|
|
420
|
-
resolvedImportDeclaration =
|
|
421
|
-
resolvedLocalVarDeclaration =
|
|
422
|
-
_context6.next =
|
|
525
|
+
case 39:
|
|
526
|
+
_result2 = _context6.sent;
|
|
527
|
+
exprValue = _result2.fallbackValue;
|
|
528
|
+
resolvedImportDeclaration = _result2.resolvedImportDeclaration;
|
|
529
|
+
resolvedLocalVarDeclaration = _result2.resolvedLocalVarDeclaration;
|
|
530
|
+
_context6.next = 51;
|
|
423
531
|
break;
|
|
424
|
-
case
|
|
532
|
+
case 45:
|
|
425
533
|
if (!(expression.type === 'MemberExpression')) {
|
|
426
|
-
_context6.next =
|
|
534
|
+
_context6.next = 51;
|
|
427
535
|
break;
|
|
428
536
|
}
|
|
429
|
-
_context6.next =
|
|
537
|
+
_context6.next = 48;
|
|
430
538
|
return this.processFallbackAsMemberExpression(expression);
|
|
431
|
-
case
|
|
432
|
-
|
|
433
|
-
exprValue =
|
|
434
|
-
resolvedImportDeclaration =
|
|
435
|
-
case
|
|
539
|
+
case 48:
|
|
540
|
+
_result3 = _context6.sent;
|
|
541
|
+
exprValue = _result3.fallbackValue;
|
|
542
|
+
resolvedImportDeclaration = _result3.resolvedImportDeclaration;
|
|
543
|
+
case 51:
|
|
436
544
|
if (exprValue !== undefined) {
|
|
437
545
|
rawFallbackValue = "".concat(quasis[0].value.raw, "${").concat(exprValue, "}").concat(quasis[1].value.raw);
|
|
438
546
|
fallbackValue = "".concat(quasis[0].value.cooked).concat(exprValue).concat(quasis[1].value.cooked);
|
|
@@ -444,11 +552,11 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
444
552
|
resolvedImportDeclaration: resolvedImportDeclaration,
|
|
445
553
|
resolvedLocalVarDeclaration: resolvedLocalVarDeclaration
|
|
446
554
|
});
|
|
447
|
-
case
|
|
555
|
+
case 53:
|
|
448
556
|
case "end":
|
|
449
557
|
return _context6.stop();
|
|
450
558
|
}
|
|
451
|
-
}, _callee6, this);
|
|
559
|
+
}, _callee6, this, [[6, 28, 31, 34]]);
|
|
452
560
|
}));
|
|
453
561
|
function processFallbackAsTemplateLiteral(_x6) {
|
|
454
562
|
return _processFallbackAsTemplateLiteral.apply(this, arguments);
|
|
@@ -472,19 +580,19 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
472
580
|
key: "tryResolveLocalPath",
|
|
473
581
|
value: function () {
|
|
474
582
|
var _tryResolveLocalPath = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(currentDir, importPath) {
|
|
475
|
-
var
|
|
583
|
+
var _iterator2, _step2, ext, potentialPath;
|
|
476
584
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
477
585
|
while (1) switch (_context7.prev = _context7.next) {
|
|
478
586
|
case 0:
|
|
479
|
-
|
|
587
|
+
_iterator2 = _createForOfIteratorHelper(this.possibleExtensions);
|
|
480
588
|
_context7.prev = 1;
|
|
481
|
-
|
|
589
|
+
_iterator2.s();
|
|
482
590
|
case 3:
|
|
483
|
-
if ((
|
|
591
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
484
592
|
_context7.next = 17;
|
|
485
593
|
break;
|
|
486
594
|
}
|
|
487
|
-
ext =
|
|
595
|
+
ext = _step2.value;
|
|
488
596
|
potentialPath = path.resolve(currentDir, "".concat(importPath).concat(ext));
|
|
489
597
|
_context7.prev = 6;
|
|
490
598
|
_context7.next = 9;
|
|
@@ -504,10 +612,10 @@ export var TokenProcessor = /*#__PURE__*/function () {
|
|
|
504
612
|
case 19:
|
|
505
613
|
_context7.prev = 19;
|
|
506
614
|
_context7.t1 = _context7["catch"](1);
|
|
507
|
-
|
|
615
|
+
_iterator2.e(_context7.t1);
|
|
508
616
|
case 22:
|
|
509
617
|
_context7.prev = 22;
|
|
510
|
-
|
|
618
|
+
_iterator2.f();
|
|
511
619
|
return _context7.finish(22);
|
|
512
620
|
case 25:
|
|
513
621
|
return _context7.abrupt("return", null);
|
|
@@ -24,6 +24,6 @@ export declare const parser = "tsx";
|
|
|
24
24
|
export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
|
|
25
25
|
/**
|
|
26
26
|
* Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
|
|
27
|
-
* It also applies prettier to the affected files.
|
|
27
|
+
* It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
|
|
28
28
|
*/
|
|
29
29
|
export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chunkArray: <T>(array: T[], chunkSize: number) => T[][];
|
|
@@ -24,6 +24,6 @@ export declare const parser = "tsx";
|
|
|
24
24
|
export declare function beforeAll(options: RemoveTokenFallbackOptions): Promise<void>;
|
|
25
25
|
/**
|
|
26
26
|
* Function executed after all transformations to combine individual file reports into a comprehensive transformation report.
|
|
27
|
-
* It also applies prettier to the affected files.
|
|
27
|
+
* It also applies prettier and eslint (to remove dangling suppressions) to the affected files.
|
|
28
28
|
*/
|
|
29
29
|
export declare function afterAll(options: RemoveTokenFallbackOptions): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chunkArray: <T>(array: T[], chunkSize: number) => T[][];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/codemod-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"bin": "./bin/codemod-cli.js",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
42
|
-
"@atlaskit/tokens": "^4.
|
|
42
|
+
"@atlaskit/tokens": "^4.6.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@codeshift/utils": "^0.2.4",
|
|
45
45
|
"@hypermod/utils": "^0.4.2",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"color-diff": "^1.2.0",
|
|
50
50
|
"enquirer": "^2.3.4",
|
|
51
51
|
"glob": "9.0.0",
|
|
52
|
-
"jscodeshift": "^0.
|
|
52
|
+
"jscodeshift": "^17.0.0",
|
|
53
53
|
"meow": "^8.1.1",
|
|
54
54
|
"projector-spawn": "^1.0.1",
|
|
55
55
|
"read-pkg-up": "^7.0.1",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"uuid": "^3.1.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@af/formatting": "
|
|
61
|
+
"@af/formatting": "^0.0.4",
|
|
62
62
|
"@types/color-diff": "^1.2.1",
|
|
63
63
|
"prettier": "^3.2.5",
|
|
64
64
|
"ts-node": "^10.9.1",
|