Skip to content

Commit 882277e

Browse files
danieldelcoreDaniel Del Core
andauthored
bumps ansi-regex (#238)
* bumps ansi-regex * docs(changeset): Bumps dev deps to resolve vulnerability with ansi-regex Co-authored-by: Daniel Del Core <[email protected]>
1 parent 0672c15 commit 882277e

File tree

7 files changed

+1261
-746
lines changed

7 files changed

+1261
-746
lines changed

.changeset/hungry-years-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'extract-react-types': patch
3+
---
4+
5+
Bumps dev deps to resolve vulnerability with ansi-regex

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,27 @@
5151
"babel-errors": "^1.1.1",
5252
"babel-eslint": "^10.0.1",
5353
"babel-file": "^3.0.0",
54-
"babel-file-loader": "^2.0.0",
5554
"babel-flow-identifiers": "^1.1.3",
5655
"babel-helper-simplify-module": "^2.2.1",
5756
"babel-identifiers": "^1.1.2",
5857
"babel-normalize-comments": "^1.0.1",
5958
"babel-react-components": "^1.1.0",
6059
"babel-type-scopes": "^1.1.0",
61-
"babylon": "^7.0.0-beta.22",
6260
"babylon-options": "^2.0.1",
63-
"eslint": "^5.13.0",
61+
"babylon": "^7.0.0-beta.22",
6462
"eslint-config-airbnb": "^17.1.0",
6563
"eslint-config-prettier": "^4.0.0",
6664
"eslint-plugin-import": "^2.16.0",
6765
"eslint-plugin-jest": "^22.2.2",
6866
"eslint-plugin-jsx-a11y": "^6.2.1",
6967
"eslint-plugin-prettier": "^3.0.1",
7068
"eslint-plugin-react": "^7.12.4",
69+
"eslint": "^5.13.0",
7170
"jest-in-case": "^1.0.2",
7271
"jest-watch-typeahead": "^0.4.2",
7372
"react-markings": "^1.2.0",
73+
"read-file-async": "^1.0.0",
74+
"resolve-async": "^1.0.1",
7475
"resolve": "^1.10.1",
7576
"strip-indent": "^2.0.0"
7677
},
@@ -86,13 +87,13 @@
8687
"@storybook/addon-links": "^6.1.14",
8788
"@storybook/react": "^6.1.14",
8889
"@storybook/storybook-deployer": "^2.8.7",
89-
"babel-jest": "^24.7.1",
90+
"babel-jest": "^26.0.0",
9091
"babel-loader": "^8.2.2",
9192
"babel-plugin-emotion": "^10.0.14",
9293
"enzyme": "^3.3.0",
9394
"enzyme-adapter-react-16": "^1.1.1",
9495
"flow-bin": "^0.98.0",
95-
"jest": "^24.7.1",
96+
"jest": "^26.0.0",
9697
"jest-in-case": "^1.0.2",
9798
"jsdom": "^11.7.0",
9899
"npm-run-all": "^4.1.5",

packages/extract-react-types/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,23 @@
2525
"ast-pretty-print": "^2.0.1",
2626
"babel-errors": "^1.1.1",
2727
"babel-file": "^3.0.0",
28-
"babel-file-loader": "^2.0.0",
2928
"babel-flow-identifiers": "^1.1.3",
3029
"babel-helper-simplify-module": "^2.2.1",
3130
"babel-identifiers": "^1.1.2",
3231
"babel-normalize-comments": "^1.0.1",
3332
"babel-react-components": "^1.1.0",
3433
"babel-type-scopes": "^1.1.0",
35-
"babylon": "^7.0.0-beta.22",
3634
"babylon-options": "^2.0.1",
35+
"babylon": "^7.0.0-beta.22",
36+
"read-file-async": "^1.0.0",
37+
"resolve-async": "^1.0.1",
3738
"resolve": "^1.10.1",
3839
"strip-indent": "^2.0.0"
3940
},
4041
"devDependencies": {
41-
"babel-jest": "^24.7.1",
42+
"babel-jest": "^26.0.0",
4243
"flow-bin": "^0.98.0",
43-
"jest": "^24.7.1",
44+
"jest": "^26.0.0",
4445
"prettier": "^1.13.7"
4546
}
4647
}

packages/extract-react-types/src/converter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import nodePath from 'path';
33
import { sync as resolveSync } from 'resolve';
44
import * as t from '@babel/types';
5-
import { loadFileSync, resolveImportFilePathSync } from 'babel-file-loader';
65
import { isFlowIdentifier } from 'babel-flow-identifiers';
76
import { getTypeBinding } from 'babel-type-scopes';
87
import { getIdentifierKind } from 'babel-identifiers';
98
import { isReactComponentClass } from 'babel-react-components';
109
import { normalizeComment } from 'babel-normalize-comments';
10+
import { loadFileSync, resolveImportFilePathSync } from './file-loader';
1111

1212
import {
1313
findExports,

packages/extract-react-types/src/export-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { explodeModule } from '@aparna036/babel-explode-module';
22
import { explodedToStatements } from 'babel-helper-simplify-module';
33
import printAST from 'ast-pretty-print';
4-
import { loadFileSync, resolveImportFilePathSync } from 'babel-file-loader';
4+
import { loadFileSync, resolveImportFilePathSync } from './file-loader';
55

66
export function hasDestructuredDefaultExport(path) {
77
const exportPath = path
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const { readFileSync } = require('fs');
2+
const { dirname } = require('path');
3+
const { sync: resolveSync } = require('resolve');
4+
const readFileAsync = require('read-file-async');
5+
const resolveAsync = require('resolve-async');
6+
const createFile = require('babel-file');
7+
8+
function getPathFileName(path) {
9+
return path.hub.file.opts.filename;
10+
}
11+
12+
function getImportSource(path) {
13+
return path.node.source.value;
14+
}
15+
16+
function toResolveOptions(fromPath, resolveOpts) {
17+
return Object.assign({}, resolveOpts, { basedir: dirname(fromPath) });
18+
}
19+
20+
function resolveFilePathAsync(path, filePath, resolveOpts) {
21+
let fromPath = getPathFileName(path);
22+
let opts = toResolveOptions(fromPath, resolveOpts);
23+
return resolveAsync(filePath, opts);
24+
}
25+
26+
function resolveFilePathSync(path, filePath, resolveOpts) {
27+
let fromPath = getPathFileName(path);
28+
let opts = toResolveOptions(fromPath, resolveOpts);
29+
return resolveSync(filePath, opts);
30+
}
31+
32+
function resolveImportFilePathAsync(importDeclaration, resolveOpts) {
33+
let fromPath = getPathFileName(importDeclaration);
34+
let toPath = getImportSource(importDeclaration);
35+
let opts = toResolveOptions(fromPath, resolveOpts);
36+
return resolveAsync(toPath, opts);
37+
}
38+
39+
function resolveImportFilePathSync(importDeclaration, resolveOpts) {
40+
let fromPath = getPathFileName(importDeclaration);
41+
let toPath = getImportSource(importDeclaration);
42+
let opts = toResolveOptions(fromPath, resolveOpts);
43+
return resolveSync(toPath, opts);
44+
}
45+
46+
function loadFileAsync(filePath, parserOpts) {
47+
return readFileAsync(filePath).then(buffer =>
48+
createFile(buffer.toString(), { filename: filePath, parserOpts })
49+
);
50+
}
51+
52+
function loadFileSync(filePath, parserOpts) {
53+
let buffer = readFileSync(filePath);
54+
return createFile(buffer.toString(), { filename: filePath, parserOpts });
55+
}
56+
57+
function loadImportAsync(importDeclaration, resolveOpts, parserOpts) {
58+
return resolveImportFilePathAsync(importDeclaration, resolveOpts).then(resolved =>
59+
loadFileAsync(resolved, parserOpts)
60+
);
61+
}
62+
63+
function loadImportSync(importDeclaration, resolveOpts, parserOpts) {
64+
const resolved = resolveImportFilePathSync(importDeclaration, resolveOpts);
65+
return loadFileSync(resolved, parserOpts);
66+
}
67+
68+
module.exports = {
69+
resolveFilePathAsync,
70+
resolveFilePathSync,
71+
resolveImportFilePathAsync,
72+
resolveImportFilePathSync,
73+
loadFileAsync,
74+
loadFileSync,
75+
loadImportAsync,
76+
loadImportSync
77+
};

0 commit comments

Comments
 (0)