@atlaskit/codemod-cli 0.11.4 → 0.12.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 (60) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/cli.js +72 -75
  3. package/dist/cjs/filepath.js +29 -83
  4. package/dist/cjs/index.js +3 -6
  5. package/dist/cjs/main.js +165 -441
  6. package/dist/cjs/presets/css-to-design-tokens/css-to-design-tokens.js +44 -135
  7. package/dist/cjs/presets/css-to-design-tokens/utils/legacy-colors.js +3 -4
  8. package/dist/cjs/presets/css-to-design-tokens/utils/meta.js +6 -29
  9. package/dist/cjs/presets/index.js +2 -9
  10. package/dist/cjs/presets/styled-to-emotion/styled-to-emotion.js +13 -25
  11. package/dist/cjs/presets/theme-to-design-tokens/theme-to-design-tokens.js +34 -82
  12. package/dist/cjs/presets/theme-to-design-tokens/utils/ast-meta.js +14 -41
  13. package/dist/cjs/presets/theme-to-design-tokens/utils/ast.js +0 -2
  14. package/dist/cjs/presets/theme-to-design-tokens/utils/color.js +9 -28
  15. package/dist/cjs/presets/theme-to-design-tokens/utils/fuzzy-search.js +44 -106
  16. package/dist/cjs/presets/theme-to-design-tokens/utils/legacy-colors.js +3 -3
  17. package/dist/cjs/presets/theme-to-design-tokens/utils/named-colors.js +1 -1
  18. package/dist/cjs/presets/theme-to-design-tokens/utils/tokens.js +2 -22
  19. package/dist/cjs/sinceRef.js +36 -92
  20. package/dist/cjs/transforms.js +27 -72
  21. package/dist/cjs/types.js +2 -45
  22. package/dist/cjs/utils.js +7 -20
  23. package/dist/cjs/version.json +1 -1
  24. package/dist/es2019/filepath.js +7 -5
  25. package/dist/es2019/main.js +17 -51
  26. package/dist/es2019/presets/css-to-design-tokens/css-to-design-tokens.js +19 -51
  27. package/dist/es2019/presets/css-to-design-tokens/utils/legacy-colors.js +0 -1
  28. package/dist/es2019/presets/css-to-design-tokens/utils/meta.js +0 -6
  29. package/dist/es2019/presets/index.js +1 -1
  30. package/dist/es2019/presets/styled-to-emotion/styled-to-emotion.js +1 -4
  31. package/dist/es2019/presets/theme-to-design-tokens/theme-to-design-tokens.js +4 -14
  32. package/dist/es2019/presets/theme-to-design-tokens/utils/ast-meta.js +2 -11
  33. package/dist/es2019/presets/theme-to-design-tokens/utils/color.js +2 -7
  34. package/dist/es2019/presets/theme-to-design-tokens/utils/fuzzy-search.js +38 -95
  35. package/dist/es2019/presets/theme-to-design-tokens/utils/tokens.js +0 -1
  36. package/dist/es2019/sinceRef.js +2 -11
  37. package/dist/es2019/transforms.js +3 -13
  38. package/dist/es2019/types.js +1 -0
  39. package/dist/es2019/utils.js +1 -12
  40. package/dist/es2019/version.json +1 -1
  41. package/dist/esm/cli.js +53 -57
  42. package/dist/esm/filepath.js +51 -63
  43. package/dist/esm/main.js +221 -322
  44. package/dist/esm/presets/css-to-design-tokens/css-to-design-tokens.js +33 -71
  45. package/dist/esm/presets/css-to-design-tokens/utils/legacy-colors.js +0 -1
  46. package/dist/esm/presets/css-to-design-tokens/utils/meta.js +0 -6
  47. package/dist/esm/presets/index.js +1 -1
  48. package/dist/esm/presets/styled-to-emotion/styled-to-emotion.js +1 -4
  49. package/dist/esm/presets/theme-to-design-tokens/theme-to-design-tokens.js +4 -15
  50. package/dist/esm/presets/theme-to-design-tokens/utils/ast-meta.js +2 -11
  51. package/dist/esm/presets/theme-to-design-tokens/utils/color.js +2 -7
  52. package/dist/esm/presets/theme-to-design-tokens/utils/fuzzy-search.js +38 -95
  53. package/dist/esm/presets/theme-to-design-tokens/utils/tokens.js +0 -1
  54. package/dist/esm/sinceRef.js +49 -65
  55. package/dist/esm/transforms.js +4 -14
  56. package/dist/esm/types.js +1 -11
  57. package/dist/esm/utils.js +1 -12
  58. package/dist/esm/version.json +1 -1
  59. package/package.json +2 -2
  60. package/tmp/api-report-tmp.d.ts +0 -66
@@ -12,12 +12,10 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
12
12
  matchDict: {},
13
13
  items: {}
14
14
  };
15
-
16
15
  var levenshtein = function (str1, str2) {
17
16
  var current = [];
18
17
  var prev;
19
18
  var value;
20
-
21
19
  for (var i = 0; i <= str2.length; i++) {
22
20
  for (var j = 0; j <= str1.length; j++) {
23
21
  if (i && j) {
@@ -31,65 +29,52 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
31
29
  } else {
32
30
  value = i + j;
33
31
  }
34
-
35
32
  prev = current[j];
36
33
  current[j] = value;
37
34
  }
38
35
  }
39
-
40
36
  return current.pop();
41
- }; // return an edit distance from 0 to 1
42
-
37
+ };
43
38
 
39
+ // return an edit distance from 0 to 1
44
40
  var _distance = function (str1, str2) {
45
41
  if (str1 === null && str2 === null) {
46
42
  throw new Error('Trying to compare two null values');
47
43
  }
48
-
49
44
  if (str1 === null || str2 === null) {
50
45
  return 0;
51
46
  }
52
-
53
47
  str1 = String(str1);
54
48
  str2 = String(str2);
55
49
  var distance = levenshtein(str1, str2);
56
-
57
50
  if (str1.length > str2.length) {
58
51
  return 1 - distance / str1.length;
59
52
  } else {
60
53
  return 1 - distance / str2.length;
61
54
  }
62
55
  };
63
-
64
56
  var _nonWordRe = /[^a-zA-Z0-9\u00C0-\u00FF, ]+/g;
65
-
66
57
  var _iterateGrams = function (value, gramSize) {
67
58
  gramSize = gramSize || 2;
68
59
  var simplified = '-' + value.toLowerCase().replace(_nonWordRe, '') + '-',
69
- lenDiff = gramSize - simplified.length,
70
- results = [];
71
-
60
+ lenDiff = gramSize - simplified.length,
61
+ results = [];
72
62
  if (lenDiff > 0) {
73
63
  for (var i = 0; i < lenDiff; ++i) {
74
64
  simplified += '-';
75
65
  }
76
66
  }
77
-
78
67
  for (var i = 0; i < simplified.length - gramSize + 1; ++i) {
79
68
  results.push(simplified.slice(i, i + gramSize));
80
69
  }
81
-
82
70
  return results;
83
71
  };
84
-
85
72
  var _gramCounter = function (value, gramSize) {
86
73
  // return an object where key=gram, value=number of occurrences
87
74
  gramSize = gramSize || 2;
88
-
89
75
  var result = {},
90
- grams = _iterateGrams(value, gramSize),
91
- i = 0;
92
-
76
+ grams = _iterateGrams(value, gramSize),
77
+ i = 0;
93
78
  for (i; i < grams.length; ++i) {
94
79
  if (grams[i] in result) {
95
80
  // @ts-expect-error
@@ -99,62 +84,51 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
99
84
  result[grams[i]] = 1;
100
85
  }
101
86
  }
102
-
103
87
  return result;
104
- }; // the main functions
105
-
88
+ };
106
89
 
90
+ // the main functions
107
91
  fuzzyset.get = function (value, defaultValue, minMatchScore) {
108
92
  // check for value in set, returning defaultValue or null if none found
109
93
  if (minMatchScore === undefined) {
110
94
  minMatchScore = 0.33;
111
95
  }
112
-
113
96
  var result = this._get(value, minMatchScore);
114
-
115
97
  if (!result && typeof defaultValue !== 'undefined') {
116
98
  return defaultValue;
117
99
  }
118
-
119
100
  return result;
120
101
  };
121
-
122
102
  fuzzyset._get = function (value, minMatchScore) {
123
- var results = []; // start with high gram size and if there are no results, go to lower gram sizes
124
-
103
+ var results = [];
104
+ // start with high gram size and if there are no results, go to lower gram sizes
125
105
  for (var gramSize = this.gramSizeUpper; gramSize >= this.gramSizeLower; --gramSize) {
126
106
  results = this.__get(value, gramSize, minMatchScore);
127
-
128
107
  if (results && results.length > 0) {
129
108
  return results;
130
109
  }
131
110
  }
132
-
133
111
  return null;
134
112
  };
135
-
136
113
  fuzzyset.__get = function (value, gramSize, minMatchScore) {
137
114
  var normalizedValue = this._normalizeStr(value),
138
- matches = {},
139
- gramCounts = _gramCounter(normalizedValue, gramSize),
140
- items = this.items[gramSize],
141
- sumOfSquareGramCounts = 0,
142
- gram,
143
- gramCount,
144
- i,
145
- index,
146
- otherGramCount;
147
-
115
+ matches = {},
116
+ gramCounts = _gramCounter(normalizedValue, gramSize),
117
+ items = this.items[gramSize],
118
+ sumOfSquareGramCounts = 0,
119
+ gram,
120
+ gramCount,
121
+ i,
122
+ index,
123
+ otherGramCount;
148
124
  for (gram in gramCounts) {
149
125
  // @ts-expect-error
150
126
  gramCount = gramCounts[gram];
151
127
  sumOfSquareGramCounts += Math.pow(gramCount, 2);
152
-
153
128
  if (gram in this.matchDict) {
154
129
  for (i = 0; i < this.matchDict[gram].length; ++i) {
155
130
  index = this.matchDict[gram][i][0];
156
131
  otherGramCount = this.matchDict[gram][i][1];
157
-
158
132
  if (index in matches) {
159
133
  // @ts-expect-error
160
134
  matches[index] += gramCount * otherGramCount;
@@ -165,31 +139,26 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
165
139
  }
166
140
  }
167
141
  }
168
-
169
142
  function isEmptyObject(obj) {
170
143
  for (var prop in obj) {
171
144
  if (obj.hasOwnProperty(prop)) {
172
145
  return false;
173
146
  }
174
147
  }
175
-
176
148
  return true;
177
149
  }
178
-
179
150
  if (isEmptyObject(matches)) {
180
151
  return null;
181
152
  }
182
-
183
153
  var vectorNormal = Math.sqrt(sumOfSquareGramCounts),
184
- results = [],
185
- matchScore; // build a results list of [score, str]
186
-
154
+ results = [],
155
+ matchScore;
156
+ // build a results list of [score, str]
187
157
  for (var matchIndex in matches) {
188
158
  // @ts-expect-error
189
159
  matchScore = matches[matchIndex];
190
160
  results.push([matchScore / (vectorNormal * items[matchIndex][0]), items[matchIndex][1]]);
191
161
  }
192
-
193
162
  var sortDescending = function (a, b) {
194
163
  if (a[0] < b[0]) {
195
164
  return 1;
@@ -199,23 +168,19 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
199
168
  return 0;
200
169
  }
201
170
  };
202
-
203
171
  results.sort(sortDescending);
204
-
205
172
  if (this.useLevenshtein) {
206
173
  var newResults = [],
207
- endIndex = Math.min(50, results.length); // truncate somewhat arbitrarily to 50
174
+ endIndex = Math.min(50, results.length);
175
+ // truncate somewhat arbitrarily to 50
208
176
  // @ts-expect-error
209
-
210
177
  for (var i = 0; i < endIndex; ++i) {
211
178
  // @ts-expect-error
212
179
  newResults.push([_distance(results[i][1], normalizedValue), results[i][1]]);
213
180
  }
214
-
215
181
  results = newResults;
216
182
  results.sort(sortDescending);
217
183
  }
218
-
219
184
  newResults = [];
220
185
  results.forEach(function (scoreWordPair) {
221
186
  if (scoreWordPair[0] >= minMatchScore) {
@@ -225,112 +190,90 @@ const FuzzySet = function (arr = [], useLevenshtein, gramSizeLower = 2, gramSize
225
190
  }.bind(this));
226
191
  return newResults;
227
192
  };
228
-
229
193
  fuzzyset.add = function (value) {
230
194
  var normalizedValue = this._normalizeStr(value);
231
-
232
195
  if (normalizedValue in this.exactSet) {
233
196
  return false;
234
197
  }
235
-
236
198
  var i = this.gramSizeLower;
237
-
238
199
  for (i; i < this.gramSizeUpper + 1; ++i) {
239
200
  this._add(value, i);
240
201
  }
241
202
  };
242
-
243
203
  fuzzyset._add = function (value, gramSize) {
244
204
  var normalizedValue = this._normalizeStr(value),
245
- items = this.items[gramSize] || [],
246
- index = items.length;
247
-
205
+ items = this.items[gramSize] || [],
206
+ index = items.length;
248
207
  items.push(0);
249
-
250
208
  var gramCounts = _gramCounter(normalizedValue, gramSize);
251
-
252
209
  var sumOfSquareGramCounts = 0;
253
210
  var gram;
254
211
  var gramCount;
255
-
256
212
  for (gram in gramCounts) {
257
213
  // @ts-expect-error
258
214
  gramCount = gramCounts[gram];
259
215
  sumOfSquareGramCounts += Math.pow(gramCount, 2);
260
-
261
216
  if (gram in this.matchDict) {
262
217
  this.matchDict[gram].push([index, gramCount]);
263
218
  } else {
264
219
  this.matchDict[gram] = [[index, gramCount]];
265
220
  }
266
221
  }
267
-
268
222
  var vectorNormal = Math.sqrt(sumOfSquareGramCounts);
269
223
  items[index] = [vectorNormal, normalizedValue];
270
224
  this.items[gramSize] = items;
271
225
  this.exactSet[normalizedValue] = value;
272
226
  };
273
-
274
227
  fuzzyset._normalizeStr = function (str) {
275
228
  if (Object.prototype.toString.call(str) !== '[object String]') {
276
229
  throw new Error('Must use a string as argument to FuzzySet functions');
277
230
  }
278
-
279
231
  return str.toLowerCase();
280
- }; // return length of items in set
281
-
232
+ };
282
233
 
234
+ // return length of items in set
283
235
  fuzzyset.length = function () {
284
236
  var count = 0,
285
- prop;
286
-
237
+ prop;
287
238
  for (prop in this.exactSet) {
288
239
  if (this.exactSet.hasOwnProperty(prop)) {
289
240
  count += 1;
290
241
  }
291
242
  }
292
-
293
243
  return count;
294
- }; // return is set is empty
295
-
244
+ };
296
245
 
246
+ // return is set is empty
297
247
  fuzzyset.isEmpty = function () {
298
248
  for (var prop in this.exactSet) {
299
249
  if (this.exactSet.hasOwnProperty(prop)) {
300
250
  return false;
301
251
  }
302
252
  }
303
-
304
253
  return true;
305
- }; // return list of values loaded into set
306
-
254
+ };
307
255
 
256
+ // return list of values loaded into set
308
257
  fuzzyset.values = function () {
309
258
  var values = [],
310
- prop;
311
-
259
+ prop;
312
260
  for (prop in this.exactSet) {
313
261
  if (this.exactSet.hasOwnProperty(prop)) {
314
262
  values.push(this.exactSet[prop]);
315
263
  }
316
264
  }
317
-
318
265
  return values;
319
- }; // initialization
320
-
266
+ };
321
267
 
268
+ // initialization
322
269
  var i = fuzzyset.gramSizeLower;
323
-
324
270
  for (i; i < fuzzyset.gramSizeUpper + 1; ++i) {
325
271
  fuzzyset.items[i] = [];
326
- } // add all the items to the set
327
-
328
-
272
+ }
273
+ // add all the items to the set
329
274
  for (i = 0; i < arr.length; ++i) {
330
275
  fuzzyset.add(arr[i]);
331
276
  }
332
-
333
277
  return fuzzyset;
334
278
  };
335
-
336
279
  export default FuzzySet;
@@ -4,6 +4,5 @@ export const getUniqueWordsFromTokens = tokens.reduce((accum, val) => [...accum,
4
4
  if (!accum.includes(val)) {
5
5
  accum.push(val);
6
6
  }
7
-
8
7
  return accum;
9
8
  }, []);
@@ -1,50 +1,42 @@
1
1
  import simpleGit from 'simple-git';
2
2
  import { ValidationError } from './types';
3
3
  const packageRegex = /"(@(?:atlaskit|atlassian|atlassiansox)\/.*)": "(.*)"/;
4
-
5
4
  const parseDiffLine = line => {
6
5
  const type = line.startsWith('-') ? 'deleted' : line.startsWith('+') ? 'added' : null;
7
6
  const match = line.match(packageRegex);
8
-
9
7
  if (!type || !match) {
10
8
  return null;
11
9
  }
12
-
13
10
  return {
14
11
  type,
15
12
  name: match[1],
16
13
  version: match[2]
17
14
  };
18
15
  };
16
+
19
17
  /** Returns packages that have been upgraded in package.json since ref. The version refers to their previous
20
18
  * version
21
19
  */
22
-
23
-
24
20
  export const getPackagesSinceRef = async ref => {
25
21
  const git = simpleGit();
26
22
  let commit;
27
-
28
23
  try {
29
24
  commit = await git.revparse(['--verify', ref]);
30
25
  } catch (e) {
31
26
  throw new ValidationError(`Invalid git ref "${ref}"`);
32
27
  }
33
-
34
28
  const diff = await git.diff([commit, '--', 'package.json']);
35
29
  const modifiedPackages = diff.split('\n').map(parseDiffLine).filter(pkg => Boolean(pkg));
36
30
  const addedPackages = new Map(modifiedPackages.filter(pkg => pkg.type === 'added').map(pkg => [pkg.name, pkg]));
31
+
37
32
  /* This is holds the previous version of packages that have been upgraded. Packages are treated as
38
33
  * upgraded if they have both an addition/deletion entry in the diff and their versions differ
39
34
  */
40
-
41
35
  const upgradedPackages = modifiedPackages.filter(pkg => {
42
36
  const addedEntry = addedPackages.get(pkg.name);
43
-
44
37
  if (pkg.type !== 'deleted' || !addedEntry) {
45
38
  return false;
46
39
  }
47
-
48
40
  return pkg.version !== addedEntry.version;
49
41
  }).map(({
50
42
  name,
@@ -55,7 +47,6 @@ export const getPackagesSinceRef = async ref => {
55
47
  }));
56
48
  return upgradedPackages;
57
49
  };
58
-
59
50
  if (require.main === module) {
60
51
  getPackagesSinceRef(process.argv[2]).then(res => console.log(res));
61
52
  }
@@ -2,22 +2,18 @@ import path from 'path';
2
2
  import glob from 'glob';
3
3
  import semver from 'semver';
4
4
  import presets from './presets';
5
-
6
5
  const basePath = packages => {
7
6
  const packageDirectory = packages && packages.length > 0 ? [`{${packages.map(pkg => pkg.name).join(',')},}`] : ['@{atlaskit,atlassian,atlassiansox}', '*'];
8
7
  return path.join(process.cwd(), 'node_modules', ...packageDirectory, 'codemods');
9
8
  };
10
-
11
9
  export const hasTransform = transformPath => glob.sync(transformPath).length > 0;
12
- /** Retrieves transforms for `packages` if provided, otherwise all transforms including presets */
13
10
 
11
+ /** Retrieves transforms for `packages` if provided, otherwise all transforms including presets */
14
12
  export const getTransforms = packages => {
15
13
  const transforms = [path.join(basePath(packages), '*.@(ts|tsx|js)'), path.join(basePath(packages), '*', 'index.@(ts|tsx|js)')];
16
-
17
14
  if (!packages) {
18
15
  transforms.unshift(...presets);
19
16
  }
20
-
21
17
  return transforms.map(transform => glob.sync(transform)).reduce((acc, val) => acc.concat(val), []).map(transform => parseTransformPath(transform)).filter(filterTransforms(packages)).sort();
22
18
  };
23
19
  export const parseTransformPath = transformPath => path.parse(transformPath);
@@ -27,35 +23,29 @@ export const getTransformPath = ({
27
23
  }) => `${dir}/${base}`;
28
24
  export const getTransformModule = transform => {
29
25
  const pathSegments = transform.dir.split(path.sep);
30
- const nodeModulesIdx = pathSegments.indexOf('node_modules'); // pathSegments will be of the form [node_modules, '@atlaskit', 'avatar', 'codemods']
31
-
26
+ const nodeModulesIdx = pathSegments.indexOf('node_modules');
27
+ // pathSegments will be of the form [node_modules, '@atlaskit', 'avatar', 'codemods']
32
28
  return pathSegments.slice(nodeModulesIdx + 1, nodeModulesIdx + 3).join('/');
33
29
  };
34
30
  export const getTransformVersion = transform => {
35
31
  let transformName = transform.base;
36
-
37
32
  if (transformName.startsWith('index.')) {
38
33
  const pathSegments = transform.dir.split(path.sep);
39
34
  transformName = pathSegments[pathSegments.length - 1];
40
35
  }
41
-
42
36
  return transformName.split('-')[0];
43
37
  };
44
-
45
38
  const filterTransforms = packages => {
46
39
  if (!packages || packages.length === 0) {
47
40
  return () => true;
48
41
  }
49
-
50
42
  const packageMap = new Map(packages.map(pkg => [pkg.name, pkg.version]));
51
43
  return transform => {
52
44
  const transformVersion = getTransformVersion(transform);
53
45
  const pkgVersion = packageMap.get(getTransformModule(transform));
54
-
55
46
  if (pkgVersion === undefined) {
56
47
  throw Error(`No corresponding package found for transform "${transform.dir}/${transform.base}`);
57
48
  }
58
-
59
49
  if (transformVersion === 'next' || pkgVersion === null) {
60
50
  return true;
61
51
  } else if (semver.valid(transformVersion)) {
@@ -1,5 +1,6 @@
1
1
  /** Converts required args to optional if they have a default
2
2
  * Example: export type UserFlags = Default<Flags, keyof typeof defaultFlags>;
3
3
  */
4
+
4
5
  export class ValidationError extends Error {}
5
6
  export class NoTransformsExistError extends Error {}
@@ -1,55 +1,44 @@
1
1
  /* Utility functions to be used in codemod-cli. */
2
+
2
3
  const returnLineEnding = source => {
3
4
  var cr = source.split('\r').length;
4
5
  var lf = source.split('\n').length;
5
6
  var crlf = source.split('\r\n').length;
6
-
7
7
  if (cr + lf === 0) {
8
8
  return 'NONE';
9
9
  }
10
-
11
10
  if (crlf === cr && crlf === lf) {
12
11
  return 'CRLF';
13
12
  }
14
-
15
13
  if (cr > lf) {
16
14
  return 'CR';
17
15
  } else {
18
16
  return 'LF';
19
17
  }
20
18
  };
21
-
22
19
  const getLineEndingRegex = type => {
23
20
  if (['CR', 'LF', 'CRLF'].indexOf(type) === -1) {
24
21
  throw new Error("Line ending '" + type + "' is not supported, use CR, LF or CRLF");
25
22
  }
26
-
27
23
  if (type === 'LF') {
28
24
  return '\n';
29
25
  }
30
-
31
26
  if (type === 'CR') {
32
27
  return '\r';
33
28
  }
34
-
35
29
  if (type === 'CRLF') {
36
30
  return '\r\n';
37
31
  }
38
32
  };
39
-
40
33
  export const fixLineEnding = (source, lineEnding) => {
41
34
  const current = returnLineEnding(source);
42
-
43
35
  if (current === lineEnding) {
44
36
  return source;
45
37
  }
46
-
47
38
  const regexCurrentLineEnding = getLineEndingRegex(current);
48
39
  const regexLineEnding = getLineEndingRegex(lineEnding);
49
-
50
40
  if (current && regexLineEnding && regexCurrentLineEnding) {
51
41
  return source.replace(new RegExp(regexCurrentLineEnding, 'g'), regexLineEnding);
52
42
  }
53
-
54
43
  return source;
55
44
  };
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.11.4"
3
+ "version": "0.12.0"
4
4
  }
package/dist/esm/cli.js CHANGED
@@ -7,68 +7,64 @@ import chalk from 'chalk';
7
7
  export function run() {
8
8
  return _run.apply(this, arguments);
9
9
  }
10
-
11
10
  function _run() {
12
11
  _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
13
12
  var cli;
14
13
  return _regeneratorRuntime.wrap(function _callee$(_context) {
15
- while (1) {
16
- switch (_context.prev = _context.next) {
17
- case 0:
18
- cli = meow("\nUsage\n $ npx @atlaskit/codemod-cli [options] <file-paths>...\n\nOptions\n --preset, -n select transform by preset name, avoid user interaction\n --transform, -t the transform to run, will prompt for a transform if not provided and no module is passed\n --since-ref, runs transforms for all packages that have been upgraded since the specified git ref\n --packages, runs transforms for the specified comma separated list of packages, optionally include a version for each package to run all transforms since that version\n --parser, -p babel|babylon|flow|ts|tsx parser to use for parsing the source files (default: babel)\n --extensions, -e transform files with these file extensions (comma separated list) (default: js)\n --ignore-pattern, ignore files that match a provided glob expression\n --fail-on-error, return a 1 exit code when errors were found during execution of codemods\n --version, -v version number\n --no-filter-paths disables dependant package file path filtering logic \n --help Help me \uD83D\uDE31\n\nExamples\n # Run a codemod over the /project/src directory, will be prompted for which codemod to run\n $ npx @atlaskit/codemod-cli /project/src\n\n # Run the \"4.0.0-remove-appearance-prop\" transform of the \"button\" package\n $ npx @atlaskit/codemod-cli -t button@4.0.0-remove-appearance-prop /project/src\n\n # Run all transforms for \"@atlaskit/button\" greater than version 3.0.0 and @atlaskit/range greater than 4.0.0\n $ npx @atlaskit/codemod-cli --packages @atlaskit/button@3.0.0,@atlaskit/range@4.0.0 /project/src\n", {
19
- flags: {
20
- transform: {
21
- type: 'string',
22
- alias: 't'
23
- },
24
- preset: {
25
- type: 'string',
26
- alias: 'n'
27
- },
28
- packages: {
29
- type: 'string'
30
- },
31
- parser: {
32
- type: 'string',
33
- alias: 'p'
34
- },
35
- extensions: {
36
- type: 'string',
37
- alias: 'e'
38
- },
39
- ignorePattern: {
40
- type: 'string'
41
- },
42
- sinceRef: {
43
- type: 'string'
44
- },
45
- failOnError: {
46
- type: 'boolean'
47
- },
48
- filterPaths: {
49
- type: 'boolean',
50
- default: true
51
- }
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ cli = meow("\nUsage\n $ npx @atlaskit/codemod-cli [options] <file-paths>...\n\nOptions\n --preset, -n select transform by preset name, avoid user interaction\n --transform, -t the transform to run, will prompt for a transform if not provided and no module is passed\n --since-ref, runs transforms for all packages that have been upgraded since the specified git ref\n --packages, runs transforms for the specified comma separated list of packages, optionally include a version for each package to run all transforms since that version\n --parser, -p babel|babylon|flow|ts|tsx parser to use for parsing the source files (default: babel)\n --extensions, -e transform files with these file extensions (comma separated list) (default: js)\n --ignore-pattern, ignore files that match a provided glob expression\n --fail-on-error, return a 1 exit code when errors were found during execution of codemods\n --version, -v version number\n --no-filter-paths disables dependant package file path filtering logic \n --help Help me \uD83D\uDE31\n\nExamples\n # Run a codemod over the /project/src directory, will be prompted for which codemod to run\n $ npx @atlaskit/codemod-cli /project/src\n\n # Run the \"4.0.0-remove-appearance-prop\" transform of the \"button\" package\n $ npx @atlaskit/codemod-cli -t button@4.0.0-remove-appearance-prop /project/src\n\n # Run all transforms for \"@atlaskit/button\" greater than version 3.0.0 and @atlaskit/range greater than 4.0.0\n $ npx @atlaskit/codemod-cli --packages @atlaskit/button@3.0.0,@atlaskit/range@4.0.0 /project/src\n", {
17
+ flags: {
18
+ transform: {
19
+ type: 'string',
20
+ alias: 't'
21
+ },
22
+ preset: {
23
+ type: 'string',
24
+ alias: 'n'
25
+ },
26
+ packages: {
27
+ type: 'string'
28
+ },
29
+ parser: {
30
+ type: 'string',
31
+ alias: 'p'
32
+ },
33
+ extensions: {
34
+ type: 'string',
35
+ alias: 'e'
36
+ },
37
+ ignorePattern: {
38
+ type: 'string'
39
+ },
40
+ sinceRef: {
41
+ type: 'string'
42
+ },
43
+ failOnError: {
44
+ type: 'boolean'
45
+ },
46
+ filterPaths: {
47
+ type: 'boolean',
48
+ default: true
52
49
  }
53
- });
54
- main(cli.input, cli.flags).catch(function (e) {
55
- if (e instanceof ValidationError) {
56
- console.error(cli.help);
57
- console.error(chalk.red(e.message));
58
- process.exit(1);
59
- } else if (e instanceof NoTransformsExistError) {
60
- console.warn(chalk.yellow(e.message));
61
- process.exit(0);
62
- } else {
63
- console.error(chalk.red(e));
64
- process.exit(3);
65
- }
66
- });
67
-
68
- case 2:
69
- case "end":
70
- return _context.stop();
71
- }
50
+ }
51
+ });
52
+ main(cli.input, cli.flags).catch(function (e) {
53
+ if (e instanceof ValidationError) {
54
+ console.error(cli.help);
55
+ console.error(chalk.red(e.message));
56
+ process.exit(1);
57
+ } else if (e instanceof NoTransformsExistError) {
58
+ console.warn(chalk.yellow(e.message));
59
+ process.exit(0);
60
+ } else {
61
+ console.error(chalk.red(e));
62
+ process.exit(3);
63
+ }
64
+ });
65
+ case 2:
66
+ case "end":
67
+ return _context.stop();
72
68
  }
73
69
  }, _callee);
74
70
  }));