Skip to content

Commit

Permalink
chore: bump flow to 0.57.2 (#252)
Browse files Browse the repository at this point in the history
* chore: bump flow to 0.56.0

* Update snapshots

* simplify Promise<any> type

* Extract CollectOptions and CollectOutput

* Bump flow to 0.57.2
  • Loading branch information
thymikee authored and satya164 committed Oct 16, 2017
1 parent 9fd9b9b commit 09f767a
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 132 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[version]
0.42.0
0.57.2

[ignore]
.*/example
Expand Down
3 changes: 2 additions & 1 deletion jest/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

const traverse = require('traverse'); // eslint-disable-line import/no-extraneous-dependencies

const flushPromises = () => new Promise(resolve => setTimeout(resolve));
const flushPromises = (): Promise<any> =>
new Promise(resolve => setTimeout(resolve));

const replacePathsInObject = (object: mixed) => {
return traverse(object).map(
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"scripts": {
"precommit": "lint-staged",
"flow": "flow",
"flow": "flow --include-warnings",
"lint": "eslint .",
"jest": "jest",
"test": "npm run flow && npm run lint && npm run jest",
Expand Down Expand Up @@ -76,7 +76,7 @@
"babel-preset-react-native": "^2.0.0",
"eslint": "^4.3.0",
"eslint-config-callstack-io": "^0.3.1",
"flow-bin": "^0.42.0",
"flow-bin": "^0.57.2",
"husky": "^0.13.3",
"jest": "test",
"lint-staged": "^3.4.0",
Expand Down
6 changes: 4 additions & 2 deletions src/commands/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* @flow
*/
import type { Command } from '../types';

const path = require('path');
const webpack = require('webpack');
const clear = require('clear');
Expand Down Expand Up @@ -83,7 +85,7 @@ async function bundle(opts: *) {
);
}

module.exports = {
module.exports = ({
name: 'bundle',
description: 'Builds the app bundle for packaging',
action: bundle,
Expand Down Expand Up @@ -150,4 +152,4 @@ module.exports = {
default: 'webpack.haul.js',
},
],
};
}: Command);
5 changes: 3 additions & 2 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* @flow
*/
import type { Command } from '../types';

const path = require('path');
const fs = require('fs');
Expand Down Expand Up @@ -318,8 +319,8 @@ const addToXcodeBuild = async (cwd: string) => {
}
};

module.exports = {
module.exports = ({
name: 'init',
description: 'Generates necessary configuration files',
action: init,
};
}: Command);
5 changes: 3 additions & 2 deletions src/commands/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*
* @flow
*/
import type { Command } from '../types';

const clear = require('clear');
const logger = require('../logger');
Expand Down Expand Up @@ -40,9 +41,9 @@ async function reload() {
req.end();
}

module.exports = {
module.exports = ({
name: 'reload',
description: 'Sends reload request to all devices that enabled live reload',
action: reload,
options: [],
};
}: Command);
6 changes: 4 additions & 2 deletions src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* @flow
*/
import type { Command } from '../types';

const webpack = require('webpack');
const path = require('path');
const clear = require('clear');
Expand Down Expand Up @@ -122,7 +124,7 @@ async function start(opts: *) {
).listen(opts.port);
}

module.exports = {
module.exports = ({
name: 'start',
description: 'Starts a new webpack server',
action: start,
Expand Down Expand Up @@ -191,4 +193,4 @@ module.exports = {
default: 'webpack.haul.js',
},
],
};
}: Command);
17 changes: 9 additions & 8 deletions src/hot/client/hotApi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright 2017-present, Callstack.
* All rights reserved.
*
*
* @flow
*/

Expand All @@ -17,24 +17,25 @@ import resetRedBox from './utils';

const instances = {};

type State = {
error: ?Object,
};

/**
* Wrap root component factory with custom HotWrapper, which allows for deep force update
* and servers as an error boundry.
*/
export function makeHot(initialRootFactory: Function, id?: string = 'default') {
return () => {
class HotWrapper extends Component {
state: {
error: ?Object,
class HotWrapper extends Component<*, State> {
state = {
error: null,
};

rootComponentFactory: ?Function;

constructor(props: *) {
super(props);
this.state = {
error: null,
};
instances[id] = this;
this.rootComponentFactory = null;
}
Expand Down Expand Up @@ -126,7 +127,7 @@ export function callOnce(callback: Function) {

/**
* Clear specified module cache. The module must be a resolved with `require.resolve`.
*
*
*/
export function clearCacheFor(resolvedModuleName: string) {
delete require.cache[resolvedModuleName];
Expand Down
3 changes: 1 addition & 2 deletions src/hot/client/hotPatch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Copyright 2017-present, Callstack.
* All rights reserved.
*
*
* @flow
*/

Expand Down Expand Up @@ -55,7 +55,6 @@ if (typeof global.__REACT_HOT_LOADER__ !== 'undefined') {
typeof id === 'string' && /react-native/.test(id)
? _createElement
: patchedCreateElement;
// $FlowFixMe
return fn(type, ...args);
};

Expand Down
7 changes: 6 additions & 1 deletion src/loaders/assetLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ module.exports = async function assetLoader() {

const query = utils.getOptions(this) || {};
const options = this.options[query.config] || {};
const config: Config = Object.assign({}, options, query);
const config: Config = Object.assign(
{},
{ platform: 'ios', root: process.cwd() },
options,
query,
);

const pathSepPattern = new RegExp(`\\${path.sep}`, 'g');
const filepath = this.resourcePath;
Expand Down
19 changes: 16 additions & 3 deletions src/resolvers/AssetResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ type Options = {
platform: 'ios' | 'android',
};

type CollectOutput = {
[key: string]: {
platform: 'ios' | 'android',
name: string,
},
};

type CollectOptions = {
name: string,
platform: string,
type: string,
};

function AssetResolver(options: Options) {
const platform = options.platform;
const test = options.test || AssetResolver.test;
Expand Down Expand Up @@ -83,9 +96,9 @@ function AssetResolver(options: Options) {

AssetResolver.test = /\.(bmp|gif|jpg|jpeg|png|psd|svg|webp|m4v|aac|aiff|caf|m4a|mp3|wav|html|pdf)$/;
AssetResolver.collect = (
list,
{ name, type, platform }: { name: string, type: string, platform: string },
) => {
list: Array<string>,
{ name, type, platform }: CollectOptions,
): CollectOutput => {
const regex = /^(bmp|gif|jpg|jpeg|png|psd|tiff|webp|svg)$/.test(type)
? new RegExp(
`^${escapeStringRegexp(
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/rawBodyMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @flow
*/
function rawBodyMiddleware(req: *, res: *, next: *) {
function rawBodyMiddleware(req: any, res: *, next: *) {
req.rawBody = '';
req.setEncoding('utf8');

Expand Down
14 changes: 7 additions & 7 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
* @flow
*/

export type CommandArgs = Array<string>;
type Choice = {
value: string | boolean | number,
description: string,
};

export type CommandOption = {
name: string,
description: string,
parse?: (val: string) => mixed,
default?: mixed | ((opts: { [key: string]: string }) => mixed),
parse?: Function,
default?: any,
example?: string,
choices?: Array<{
value: mixed,
description: string,
}>,
choices?: Array<Choice>,
};

export type Command = {
Expand Down
2 changes: 0 additions & 2 deletions src/utils/__tests__/__snapshots__/getBabelConfig.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`creates new config when no .babelrc found 1`] = `
Object {
"babelrc": false,
"plugins": Array [
"<<REPLACED>>/utils/fixRequireIssues.js",
"<<NODE_MODULE>>/react-hot-loader/babel.js",
Expand All @@ -16,7 +15,6 @@ Object {

exports[`does not include "hot" plugins in production 1`] = `
Object {
"babelrc": false,
"plugins": Array [
"<<REPLACED>>/utils/fixRequireIssues.js",
],
Expand Down

0 comments on commit 09f767a

Please sign in to comment.