flow-upgrade 2.5.0 → 2.7.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 (30) hide show
  1. package/README.md +21 -0
  2. package/dist/Styled.js +0 -2
  3. package/dist/Types.js +1 -8
  4. package/dist/bin/runSpecificCodemod.js +21 -38
  5. package/dist/bin/upgrade.js +8 -15
  6. package/dist/codemodUtils/getClassMemberName.js +1 -8
  7. package/dist/codemodUtils/replaceMethodWithArrowProp.js +6 -14
  8. package/dist/codemods/collapseObjectInitialization.js +6 -19
  9. package/dist/codemods/convertImplicitInexactObjectTypes.js +3 -13
  10. package/dist/codemods/convertLegacyUtilityTypes.js +69 -0
  11. package/dist/codemods/convertShapeToPartial.js +3 -13
  12. package/dist/codemods/eliminateAbstractComponent.js +72 -0
  13. package/dist/codemods/removeAnnotationsInDestructuring.js +3 -13
  14. package/dist/codemods/removeDuplicateClassProperties.js +12 -29
  15. package/dist/codemods/removeExplicitlyExactObjectTypeSyntax.js +3 -13
  16. package/dist/codemods/renamePartial.js +3 -13
  17. package/dist/codemods/replaceReactDollarUtilityTypes.js +8 -21
  18. package/dist/codemods/replaceTemporaryTypes.js +9 -21
  19. package/dist/codemods/typeCastToAsExpression.js +5 -15
  20. package/dist/codemods/typeParameterBoundExactEmptyObjectToInexact.js +5 -16
  21. package/dist/findFlowFiles.js +15 -32
  22. package/dist/runCodemods.js +14 -17
  23. package/dist/upgrade.js +30 -48
  24. package/dist/upgrades/0.170.0/index.js +4 -15
  25. package/dist/upgrades/0.176.0/index.js +4 -15
  26. package/dist/upgrades/0.201.0/index.js +4 -15
  27. package/dist/upgrades/0.84.0/index.js +4 -15
  28. package/dist/upgrades/index.js +5 -19
  29. package/dist/utils/redirectConsole.js +3 -16
  30. package/package.json +6 -6
@@ -1,17 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _hermesTransform = require("hermes-transform");
9
-
10
- var _Types = require("../Types");
11
-
1
+ import { t } from 'hermes-transform';
2
+ import { codemod } from '../Types';
12
3
  const UTILITY_TYPES = new Set(['React$ComponentType', 'React$AbstractComponent', 'React$Element', 'React$MixedElement', 'React$ElementType', 'React$Key', 'React$Ref', 'React$RefSetter', 'React$Node', 'React$Context', 'React$Portal', 'React$ElementProps', 'React$ElementConfig', 'React$ElementRef', 'React$Config', 'React$Config', 'React$RefObject']);
13
-
14
- var _default = (0, _Types.codemod)({
4
+ export default codemod({
15
5
  title: 'Replace React$SomeUtilityType with React.SomeUtilityType.',
16
6
  transform: context => {
17
7
  return {
@@ -26,23 +16,20 @@ var _default = (0, _Types.codemod)({
26
16
  return;
27
17
  }
28
18
 
29
- const newNode = _hermesTransform.t.GenericTypeAnnotation({
30
- id: _hermesTransform.t.QualifiedTypeIdentifier({
31
- id: _hermesTransform.t.Identifier({
19
+ const newNode = t.GenericTypeAnnotation({
20
+ id: t.QualifiedTypeIdentifier({
21
+ id: t.Identifier({
32
22
  name: utilTypeName.substring('React$'.length)
33
23
  }),
34
- qualification: _hermesTransform.t.Identifier({
24
+ qualification: t.Identifier({
35
25
  name: 'React'
36
26
  })
37
27
  }),
38
28
  typeParameters: node.typeParameters
39
29
  });
40
-
41
30
  context.replaceNode(node, newNode);
42
31
  }
43
32
 
44
33
  };
45
34
  }
46
- });
47
-
48
- exports.default = _default;
35
+ });
@@ -1,15 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _hermesTransform = require("hermes-transform");
9
-
10
- var _Types = require("../Types");
11
-
12
- var _default = (0, _Types.codemod)({
1
+ import { t } from 'hermes-transform';
2
+ import { codemod } from '../Types';
3
+ export default codemod({
4
+ title: 'Replace $TEMPORARY$ types',
13
5
  describe: ['Converts:', ' - `$TEMPORARY$object<{props}>` to `$ReadOnly<{props}>`', ' - `$TEMPORARY$array<T>` to `$ReadOnlyArray<T>`', ' - `$TEMPORARY$number<42>` annotations to `number`', ' - `$TEMPORARY$string<"foo">` annotations to `string`'].join('\n'),
14
6
  transform: context => {
15
7
  return {
@@ -18,7 +10,7 @@ var _default = (0, _Types.codemod)({
18
10
 
19
11
  if (id.type === 'Identifier' && id.name === '$TEMPORARY$object' && node.typeParameters != null) {
20
12
  context.modifyNodeInPlace(node, {
21
- id: _hermesTransform.t.Identifier({
13
+ id: t.Identifier({
22
14
  name: '$ReadOnly'
23
15
  })
24
16
  });
@@ -26,23 +18,21 @@ var _default = (0, _Types.codemod)({
26
18
 
27
19
  if (id.type === 'Identifier' && id.name === '$TEMPORARY$array' && node.typeParameters != null) {
28
20
  context.modifyNodeInPlace(node, {
29
- id: _hermesTransform.t.Identifier({
21
+ id: t.Identifier({
30
22
  name: '$ReadOnlyArray'
31
23
  })
32
24
  });
33
25
  }
34
26
 
35
27
  if (id.type === 'Identifier' && id.name === '$TEMPORARY$number') {
36
- const new_node = _hermesTransform.t.NumberTypeAnnotation();
37
-
28
+ const new_node = t.NumberTypeAnnotation();
38
29
  context.replaceNode(node, new_node, {
39
30
  keepComments: true
40
31
  });
41
32
  }
42
33
 
43
34
  if (id.type === 'Identifier' && id.name === '$TEMPORARY$string') {
44
- const new_node = _hermesTransform.t.StringTypeAnnotation();
45
-
35
+ const new_node = t.StringTypeAnnotation();
46
36
  context.replaceNode(node, new_node, {
47
37
  keepComments: true
48
38
  });
@@ -51,6 +41,4 @@ var _default = (0, _Types.codemod)({
51
41
 
52
42
  };
53
43
  }
54
- });
55
-
56
- exports.default = _default;
44
+ });
@@ -1,13 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _Types = require("../Types");
9
-
10
- var _hermesTransform = require("hermes-transform");
1
+ import { codemod } from '../Types';
2
+ import { t } from 'hermes-transform';
11
3
 
12
4
  function convertTypeCast(node) {
13
5
  const {
@@ -16,13 +8,13 @@ function convertTypeCast(node) {
16
8
  typeAnnotation
17
9
  }
18
10
  } = node;
19
- return _hermesTransform.t.AsExpression({
11
+ return t.AsExpression({
20
12
  expression: expression.type === 'TypeCastExpression' ? convertTypeCast(expression) : expression,
21
13
  typeAnnotation
22
14
  });
23
15
  }
24
16
 
25
- var _default = (0, _Types.codemod)({
17
+ export default codemod({
26
18
  title: 'Update type casting syntax',
27
19
  describe: 'Convert type cast expressions `(<expr>: <type>)` to as expressions `<expr> as <type>`',
28
20
  transform: context => {
@@ -36,6 +28,4 @@ var _default = (0, _Types.codemod)({
36
28
 
37
29
  };
38
30
  }
39
- });
40
-
41
- exports.default = _default;
31
+ });
@@ -1,15 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _Types = require("../Types");
9
-
10
- var _hermesTransform = require("hermes-transform");
11
-
12
- var _default = (0, _Types.codemod)({
1
+ import { codemod } from '../Types';
2
+ import { t } from 'hermes-transform';
3
+ export default codemod({
13
4
  title: 'Replace `T: {}` with `T: {...}` in type parameter bounds',
14
5
  describe: 'Replace `T: {}` with `T: {...}` in type parameter bounds',
15
6
  transform: context => {
@@ -19,7 +10,7 @@ var _default = (0, _Types.codemod)({
19
10
  const annotation = node.bound.typeAnnotation;
20
11
 
21
12
  if (annotation.type === 'ObjectTypeAnnotation' && !annotation.inexact && annotation.properties.length === 0 && annotation.callProperties.length === 0 && annotation.indexers.length === 0 && annotation.internalSlots.length === 0) {
22
- context.replaceNode(annotation, _hermesTransform.t.ObjectTypeAnnotation({
13
+ context.replaceNode(annotation, t.ObjectTypeAnnotation({
23
14
  properties: [],
24
15
  callProperties: [],
25
16
  exact: false,
@@ -33,6 +24,4 @@ var _default = (0, _Types.codemod)({
33
24
 
34
25
  };
35
26
  }
36
- });
37
-
38
- exports.default = _default;
27
+ });
@@ -1,24 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.findFlowFiles = findFlowFiles;
7
- exports.findFlowFilesWithSpinner = findFlowFilesWithSpinner;
8
-
9
- var _path = _interopRequireDefault(require("path"));
10
-
11
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
12
-
13
- var _ora = _interopRequireDefault(require("ora"));
14
-
15
- var _chalk = _interopRequireDefault(require("chalk"));
16
-
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import ora from 'ora';
4
+ import chalk from 'chalk';
19
5
  const PRAGMA_BYTES = 5000;
20
-
21
- async function findFlowFiles({
6
+ export async function findFlowFiles({
22
7
  includeNonAtFlow,
23
8
  rootDirectory
24
9
  }) {
@@ -27,14 +12,13 @@ async function findFlowFiles({
27
12
  return filePaths;
28
13
 
29
14
  async function processDirectory(directory) {
30
- const fileNames = await _fsExtra.default.readdir(directory);
15
+ const fileNames = await fs.readdir(directory);
31
16
  await Promise.all(fileNames.map(fileName => processFilePath(directory, fileName)));
32
17
  }
33
18
 
34
19
  async function processFilePath(directory, fileName) {
35
- const filePath = _path.default.join(directory, fileName);
36
-
37
- const stats = await _fsExtra.default.lstat(filePath);
20
+ const filePath = path.join(directory, fileName);
21
+ const stats = await fs.lstat(filePath);
38
22
 
39
23
  if (stats.isDirectory()) {
40
24
  if (fileName !== 'node_modules' && fileName !== 'flow-typed' && fileName !== '__flowtests__') {
@@ -60,22 +44,21 @@ async function findFlowFiles({
60
44
  return;
61
45
  }
62
46
 
63
- const file = await _fsExtra.default.open(filePath, 'r');
47
+ const file = await fs.open(filePath, 'r');
64
48
  const bytes = Math.min(PRAGMA_BYTES, fileByteSize);
65
49
  const buffer = Buffer.alloc(bytes);
66
- await _fsExtra.default.read(file, buffer, 0, bytes, 0);
50
+ await fs.read(file, buffer, 0, bytes, 0);
67
51
 
68
52
  if (buffer.includes('@flow')) {
69
53
  filePaths.push(filePath);
70
54
  }
71
55
 
72
- await _fsExtra.default.close(file);
56
+ await fs.close(file);
73
57
  }
74
58
  }
75
-
76
- async function findFlowFilesWithSpinner(rootDirectory, options) {
77
- const spinner = (0, _ora.default)({
78
- text: _chalk.default.italic.cyan('Finding all the Flow files to be upgraded...'),
59
+ export async function findFlowFilesWithSpinner(rootDirectory, options) {
60
+ const spinner = ora({
61
+ text: chalk.italic.cyan('Finding all the Flow files to be upgraded...'),
79
62
  color: 'cyan',
80
63
  isSilent: options.silent
81
64
  });
@@ -94,7 +77,7 @@ async function findFlowFilesWithSpinner(rootDirectory, options) {
94
77
  spinner.stop();
95
78
 
96
79
  if (!options.silent) {
97
- console.log(`Found ${_chalk.default.bold.cyan(filePaths.length)} Flow files.`);
80
+ console.log(`Found ${chalk.bold.cyan(filePaths.length)} Flow files.`);
98
81
  console.log();
99
82
  }
100
83
 
@@ -1,27 +1,24 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = runCodemods;
7
-
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
-
10
- var _hermesTransform = require("hermes-transform");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- async function runCodemods(codemods, filePaths, options) {
1
+ import fs from 'fs-extra';
2
+ import { transform } from 'hermes-transform';
3
+ export default async function runCodemods(codemods, filePaths, options) {
15
4
  const results = await Promise.allSettled(filePaths.map(async filePath => {
16
- const originalContents = await _fsExtra.default.readFile(filePath, 'utf8');
5
+ if (typeof require !== 'undefined' && require.cache) {
6
+ Object.keys(require.cache).forEach(key => {
7
+ if (key.includes('hermes-transform') || key.includes('prettier')) {
8
+ delete require.cache[key];
9
+ }
10
+ });
11
+ }
12
+
13
+ const originalContents = await fs.readFile(filePath, 'utf8');
17
14
  let contents = originalContents;
18
15
 
19
16
  for (const codemod of codemods) {
20
- contents = await (0, _hermesTransform.transform)(contents, codemod.transform, options.prettierOptions);
17
+ contents = await transform(contents, codemod.transform, options.prettierOptions);
21
18
  }
22
19
 
23
20
  if (originalContents !== contents) {
24
- await _fsExtra.default.writeFile(filePath, contents, 'utf8');
21
+ await fs.writeFile(filePath, contents, 'utf8');
25
22
  }
26
23
  }));
27
24
  }
package/dist/upgrade.js CHANGED
@@ -1,53 +1,35 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = upgrade;
7
-
8
- var _semver = _interopRequireDefault(require("semver"));
9
-
10
- var _chalk = _interopRequireDefault(require("chalk"));
11
-
12
- var _ora = _interopRequireDefault(require("ora"));
13
-
14
- var _promptConfirm = _interopRequireDefault(require("prompt-confirm"));
15
-
16
- var _Styled = _interopRequireDefault(require("./Styled"));
17
-
18
- var _findFlowFiles = require("./findFlowFiles");
19
-
20
- var _runCodemods = _interopRequireDefault(require("./runCodemods"));
21
-
22
- var _upgrades = require("./upgrades");
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- async function upgrade(directory, currentVersion, nextVersion, options) {
1
+ import semver from 'semver';
2
+ import chalk from 'chalk';
3
+ import ora from 'ora';
4
+ import Confirm from 'prompt-confirm';
5
+ import Styled from './Styled';
6
+ import { findFlowFilesWithSpinner } from './findFlowFiles';
7
+ import runCodemods from './runCodemods';
8
+ import { VERSION_UPGRADES } from './upgrades';
9
+ export default async function upgrade(directory, currentVersion, nextVersion, options) {
27
10
  const log = options.silent ? () => {} : (...messages) => console.log(...messages);
28
11
  const allUpgrades = [];
29
12
 
30
- for (let i = 0; i < _upgrades.VERSION_UPGRADES.length; i++) {
13
+ for (let i = 0; i < VERSION_UPGRADES.length; i++) {
31
14
  const {
32
15
  version,
33
16
  upgrades
34
- } = _upgrades.VERSION_UPGRADES[i];
17
+ } = VERSION_UPGRADES[i];
35
18
 
36
- if (_semver.default.cmp(version, '>', nextVersion)) {
19
+ if (semver.cmp(version, '>', nextVersion)) {
37
20
  break;
38
21
  }
39
22
 
40
- if (_semver.default.cmp(version, '>', currentVersion)) {
23
+ if (semver.cmp(version, '>', currentVersion)) {
41
24
  upgrades.forEach(upgrade => allUpgrades.push(upgrade));
42
25
  }
43
26
  }
44
27
 
45
28
  log();
46
- log(_Styled.default.sectionHeader('flow-upgrade'));
29
+ log(Styled.sectionHeader('flow-upgrade'));
47
30
  log();
48
31
  {
49
- const titleStyled = _chalk.default.bold('flow-upgrade');
50
-
32
+ const titleStyled = chalk.bold('flow-upgrade');
51
33
  const message = `
52
34
  Thank you for choosing to upgrade Flow. In every release the Flow community adds
53
35
  new features and improves the performance of Flow to better serve you and your
@@ -65,28 +47,28 @@ using git make sure you've commit the changes in your working directory.) After
65
47
  running ${titleStyled} review the changes that were made and manually tweak
66
48
  your code until you are happy with the upgrade.
67
49
 
68
- The Flow version you're upgrading from: ${_chalk.default.bold.magenta(currentVersion)}
69
- The Flow version you're upgrading to: ${_chalk.default.bold.green(nextVersion)}
50
+ The Flow version you're upgrading from: ${chalk.bold.magenta(currentVersion)}
51
+ The Flow version you're upgrading to: ${chalk.bold.green(nextVersion)}
70
52
 
71
- We will assume that your code is valid Flow ${_chalk.default.bold.magenta(currentVersion)} code.
53
+ We will assume that your code is valid Flow ${chalk.bold.magenta(currentVersion)} code.
72
54
 
73
55
  We will be running the following steps to upgrade your codebase. Each step will
74
56
  print a short message explaining what it does before it runs, but we won't stop
75
57
  to ask you for reconfirmation once we begin upgrading.
76
58
 
77
- ${allUpgrades.map((u, i) => _Styled.default.upgradeTitle(u.title, i + 1)).join('\n')}
59
+ ${allUpgrades.map((u, i) => Styled.upgradeTitle(u.title, i + 1)).join('\n')}
78
60
 
79
- Today we will be upgrading all JavaScript files using Flow in: ${_chalk.default.bold.magenta(directory)}
61
+ Today we will be upgrading all JavaScript files using Flow in: ${chalk.bold.magenta(directory)}
80
62
 
81
63
  Excluding any JavaScript files in node_modules directories, in flow-typed
82
64
  directories, in __flowtests__ directories, or files ending in -flowtest.js.
83
65
  `.slice(1);
84
66
  log(message);
85
67
  }
86
- const filePaths = await (0, _findFlowFiles.findFlowFilesWithSpinner)(directory, options);
87
- log(_chalk.default.bold.red('Please review this information to make sure that it is correct before proceeding.'));
68
+ const filePaths = await findFlowFilesWithSpinner(directory, options);
69
+ log(chalk.bold.red('Please review this information to make sure that it is correct before proceeding.'));
88
70
  log();
89
- const answer = options.yes || (await new _promptConfirm.default('Are you ready to begin the upgrade?').run());
71
+ const answer = options.yes || (await new Confirm('Are you ready to begin the upgrade?').run());
90
72
 
91
73
  if (!answer) {
92
74
  log();
@@ -106,27 +88,27 @@ directories, in __flowtests__ directories, or files ending in -flowtest.js.
106
88
  codemods.push(allUpgrades.shift());
107
89
  }
108
90
 
109
- log(_Styled.default.sectionHeader('Codemods'));
91
+ log(Styled.sectionHeader('Codemods'));
110
92
  log();
111
93
  log('We are now going to run the following codemods:');
112
94
  log();
113
- log(codemods.map((u, i) => _Styled.default.upgradeTitle(u.title, i + 1)).join('\n'));
95
+ log(codemods.map((u, i) => Styled.upgradeTitle(u.title, i + 1)).join('\n'));
114
96
  log();
115
97
  log('Following is a short description of each codemod listed above so ' + 'that you know\nhow your code is being upgraded.');
116
98
  log();
117
- log(_Styled.default.divider());
99
+ log(Styled.divider());
118
100
  log();
119
101
  codemods.forEach((u, i) => {
120
- log(_Styled.default.upgradeTitle(u.title, i + 1));
102
+ log(Styled.upgradeTitle(u.title, i + 1));
121
103
  log();
122
104
  log(u.describe);
123
105
  log();
124
- log(_Styled.default.divider());
106
+ log(Styled.divider());
125
107
  log();
126
108
  });
127
- log(`Running ${_chalk.default.bold.cyan(codemods.length)} codemods...`);
109
+ log(`Running ${chalk.bold.cyan(codemods.length)} codemods...`);
128
110
  log();
129
- await (0, _runCodemods.default)(codemods, filePaths, options);
111
+ await runCodemods(codemods, filePaths, options);
130
112
  break;
131
113
  }
132
114
 
@@ -1,16 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _removeDuplicateClassProperties = _interopRequireDefault(require("../../codemods/removeDuplicateClassProperties"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = {
1
+ import removeDuplicateClassProperties from '../../codemods/removeDuplicateClassProperties';
2
+ export default {
13
3
  version: '0.170.0',
14
- upgrades: [_removeDuplicateClassProperties.default]
15
- };
16
- exports.default = _default;
4
+ upgrades: [removeDuplicateClassProperties]
5
+ };
@@ -1,16 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _removeAnnotationsInDestructuring = _interopRequireDefault(require("../../codemods/removeAnnotationsInDestructuring"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = {
1
+ import removeAnnotationsInDestructuring from '../../codemods/removeAnnotationsInDestructuring';
2
+ export default {
13
3
  version: '0.176.0',
14
- upgrades: [_removeAnnotationsInDestructuring.default]
15
- };
16
- exports.default = _default;
4
+ upgrades: [removeAnnotationsInDestructuring]
5
+ };
@@ -1,16 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _renamePartial = _interopRequireDefault(require("../../codemods/renamePartial"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = {
1
+ import renamePartial from '../../codemods/renamePartial';
2
+ export default {
13
3
  version: '0.201.0',
14
- upgrades: [_renamePartial.default]
15
- };
16
- exports.default = _default;
4
+ upgrades: [renamePartial]
5
+ };
@@ -1,16 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _convertImplicitInexactObjectTypes = _interopRequireDefault(require("../../codemods/convertImplicitInexactObjectTypes"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = {
1
+ import convertImplicitInexactObjectTypes from '../../codemods/convertImplicitInexactObjectTypes';
2
+ export default {
13
3
  version: '0.84.0',
14
- upgrades: [_convertImplicitInexactObjectTypes.default]
15
- };
16
- exports.default = _default;
4
+ upgrades: [convertImplicitInexactObjectTypes]
5
+ };
@@ -1,19 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VERSION_UPGRADES = void 0;
7
-
8
- var _ = _interopRequireDefault(require("./0.84.0"));
9
-
10
- var _2 = _interopRequireDefault(require("./0.170.0"));
11
-
12
- var _3 = _interopRequireDefault(require("./0.176.0"));
13
-
14
- var _4 = _interopRequireDefault(require("./0.201.0"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const VERSION_UPGRADES = [_.default, _2.default, _3.default, _4.default];
19
- exports.VERSION_UPGRADES = VERSION_UPGRADES;
1
+ import v0_84_0 from './0.84.0';
2
+ import v0_170_0 from './0.170.0';
3
+ import v0_176_0 from './0.176.0';
4
+ import v0_201_0 from './0.201.0';
5
+ export const VERSION_UPGRADES = [v0_84_0, v0_170_0, v0_176_0, v0_201_0];
@@ -1,25 +1,13 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.redirectConsole = redirectConsole;
7
- exports.restoreConsole = restoreConsole;
8
-
9
- var util = _interopRequireWildcard(require("util"));
10
-
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
-
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
-
3
+ import * as util from 'util';
15
4
  const oldConsole = {
16
5
  error: console.error,
17
6
  info: console.info,
18
7
  log: console.log,
19
8
  warn: console.warn
20
9
  };
21
-
22
- function redirectConsole(reporter_) {
10
+ export function redirectConsole(reporter_) {
23
11
  const reporter = typeof reporter_ === 'function' ? reporter_(oldConsole) : reporter_;
24
12
 
25
13
  console.log = (...args) => {
@@ -38,8 +26,7 @@ function redirectConsole(reporter_) {
38
26
  reporter.onStderr(util.format(...args));
39
27
  };
40
28
  }
41
-
42
- function restoreConsole() {
29
+ export function restoreConsole() {
43
30
  for (const [name, fn] of Object.entries(oldConsole)) {
44
31
  console[name] = fn;
45
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-upgrade",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "A utility for upgrading your codebase to the latest version of Flow.",
5
5
  "engines": {
6
6
  "node": ">=14"
@@ -30,15 +30,15 @@
30
30
  "homepage": "https://github.com/facebook/flow/tree/master/packages/flow-upgrade#readme",
31
31
  "dependencies": {
32
32
  "@babel/highlight": "^7.18.6",
33
- "babel-plugin-syntax-hermes-parser": "0.24.0",
33
+ "babel-plugin-syntax-hermes-parser": "0.33.3",
34
34
  "chalk": "^2.0.1",
35
35
  "fs-extra": "10.1.0",
36
- "hermes-estree": "0.24.0",
37
- "hermes-parser": "0.24.0",
38
- "hermes-transform": "0.24.0",
36
+ "hermes-estree": "0.33.3",
37
+ "hermes-parser": "0.33.3",
38
+ "hermes-transform": "0.33.3",
39
39
  "klaw-sync": "^6.0.0",
40
40
  "ora": "^5.4.1",
41
- "prettier-plugin-hermes-parser": "0.24.0",
41
+ "prettier-plugin-hermes-parser": "0.29.1",
42
42
  "prompt-confirm": "^1.2.0",
43
43
  "semver": "^7.3.7",
44
44
  "yargs": "^17.0.1"