Upgrade to 1.9.1

Reviewed By: vjeux

Differential Revision: D6497877

fbshipit-source-id: 3b88b96e375ddf1fbe039a0593569bbdde40a2dc
This commit is contained in:
Adam Ernst 2017-12-06 17:25:06 -08:00 committed by Facebook Github Bot
parent 3a377ee0a7
commit 9e4cfb4c93
14 changed files with 199 additions and 203 deletions

14
flow-typed/Promise.js vendored
View File

@ -22,20 +22,20 @@ declare class Promise<+R> {
resolve: (result?: Promise<R> | R) => void,
reject: (error?: any) => void,
) => mixed,
): void,
): void;
then<U>(
onFulfill?: ?(value: R) => Promise<U> | ?U,
onReject?: ?(error: any) => Promise<U> | ?U,
): Promise<U>,
): Promise<U>;
catch<U>(onReject?: (error: any) => ?Promise<U> | U): Promise<U>,
catch<U>(onReject?: (error: any) => ?Promise<U> | U): Promise<U>;
static resolve<T>(object?: Promise<T> | T): Promise<T>,
static reject<T>(error?: mixed): Promise<T>,
static resolve<T>(object?: Promise<T> | T): Promise<T>;
static reject<T>(error?: mixed): Promise<T>;
static all<T: Iterable<mixed>>(
promises: T,
): Promise<$TupleMap<T, typeof $await>>,
static race<T>(promises: Array<Promise<T>>): Promise<T>,
): Promise<$TupleMap<T, typeof $await>>;
static race<T>(promises: Array<Promise<T>>): Promise<T>;
}

View File

@ -12,39 +12,39 @@
declare module 'graceful-fs' {
declare class Stats {
dev: number,
ino: number,
mode: number,
nlink: number,
uid: number,
gid: number,
rdev: number,
size: number,
blksize: number,
blocks: number,
atime: Date,
mtime: Date,
ctime: Date,
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atime: Date;
mtime: Date;
ctime: Date;
isFile(): boolean,
isDirectory(): boolean,
isBlockDevice(): boolean,
isCharacterDevice(): boolean,
isSymbolicLink(): boolean,
isFIFO(): boolean,
isSocket(): boolean,
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
}
declare class FSWatcher extends events$EventEmitter {
close(): void,
close(): void;
}
declare class ReadStream extends stream$Readable {
close(): void,
close(): void;
}
declare class WriteStream extends stream$Writable {
close(): void,
close(): void;
}
declare function gracefulify(fs: Object): void;

View File

@ -31,7 +31,7 @@
"lerna": "2.4.0",
"micromatch": "^2.3.11",
"mkdirp": "^0.5.1",
"prettier": "1.7.0",
"prettier": "1.9.1",
"promise": "^7.1.1",
"sinon": "^2.3.1",
"temp": "^0.8.3"

View File

@ -170,13 +170,13 @@ async function getRamBundleInfo(
type: module.type,
}));
const {
preloadedModules,
ramGroups,
} = await deltaTransformer.getRamOptions(options.entryFile, {
dev: options.dev,
platform: options.platform,
});
const {preloadedModules, ramGroups} = await deltaTransformer.getRamOptions(
options.entryFile,
{
dev: options.dev,
platform: options.platform,
},
);
const startupModules = [];
const lazyModules = [];

View File

@ -5086,31 +5086,28 @@ describe('traverseDependencies', function() {
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
it.skip(
'allows setting dependencies for asset modules (broken)',
async () => {
const assetDependencies = ['/root/apple.png', '/root/banana.png'];
it.skip('allows setting dependencies for asset modules (broken)', async () => {
const assetDependencies = ['/root/apple.png', '/root/banana.png'];
setMockFileSystem({
root: {
'index.js': 'require("./a.png")',
'a.png': '',
'apple.png': '',
'banana.png': '',
},
});
setMockFileSystem({
root: {
'index.js': 'require("./a.png")',
'a.png': '',
'apple.png': '',
'banana.png': '',
},
});
const opts = {...defaults, assetDependencies, roots: ['/root']};
await processDgraph(opts, async dgraph => {
const {dependencies} = await dgraph.getDependencies({
entryPath: '/root/index.js',
});
const [, assetModule] = dependencies;
const deps = await assetModule.getDependencies();
expect(deps).toBe(assetDependencies);
const opts = {...defaults, assetDependencies, roots: ['/root']};
await processDgraph(opts, async dgraph => {
const {dependencies} = await dgraph.getDependencies({
entryPath: '/root/index.js',
});
},
);
const [, assetModule] = dependencies;
const deps = await assetModule.getDependencies();
expect(deps).toBe(assetDependencies);
});
});
});
describe('Deterministic order of dependencies', () => {

View File

@ -146,29 +146,29 @@ async function traverseDependenciesForSingleFile(
// added and removed dependency, to get all the modules that have to be added
// and removed from the dependency graph.
const added = await Promise.all(
Array.from(
currentDependencies,
).map(async ([absolutePath, relativePath]) => {
if (previousDependencies.has(absolutePath)) {
return new Set();
}
Array.from(currentDependencies).map(
async ([absolutePath, relativePath]) => {
if (previousDependencies.has(absolutePath)) {
return new Set();
}
return await addDependency(
nonNullEdge,
relativePath,
dependencyGraph,
transformOptions,
edges,
() => {
total++;
onProgress(numProcessed, total);
},
() => {
numProcessed++;
onProgress(numProcessed, total);
},
);
}),
return await addDependency(
nonNullEdge,
relativePath,
dependencyGraph,
transformOptions,
edges,
() => {
total++;
onProgress(numProcessed, total);
},
() => {
numProcessed++;
onProgress(numProcessed, total);
},
);
},
),
);
numProcessed++;

View File

@ -66,6 +66,6 @@ type HasteMapOptions = {|
declare class HasteMap {
// node-haste/DependencyGraph/HasteMap.js
build(): Promise<Object>,
constructor(options: HasteMapOptions): void,
build(): Promise<Object>;
constructor(options: HasteMapOptions): void;
}

View File

@ -131,39 +131,35 @@ describe('processRequest', () => {
});
it('returns JS bundle source on request of *.bundle (compat)', () => {
return makeRequest(
requestHandler,
'mybundle.runModule.bundle',
).then(response => expect(response.body).toEqual('this is the source'));
return makeRequest(requestHandler, 'mybundle.runModule.bundle').then(
response => expect(response.body).toEqual('this is the source'),
);
});
it('returns Last-Modified header on request of *.bundle', () => {
return makeRequest(
requestHandler,
'mybundle.bundle?runModule=true',
).then(response => {
expect(response.getHeader('Last-Modified')).toBeDefined();
});
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true').then(
response => {
expect(response.getHeader('Last-Modified')).toBeDefined();
},
);
});
it('returns build info headers on request of *.bundle', () => {
return makeRequest(
requestHandler,
'mybundle.bundle?runModule=true',
).then(response => {
expect(response.getHeader('X-Metro-Files-Changed-Count')).toEqual('38');
});
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true').then(
response => {
expect(response.getHeader('X-Metro-Files-Changed-Count')).toEqual('38');
},
);
});
it('returns Content-Length header on request of *.bundle', () => {
return makeRequest(
requestHandler,
'mybundle.bundle?runModule=true',
).then(response => {
expect(response.getHeader('Content-Length')).toEqual(
'' + Buffer.byteLength(response.body),
);
});
return makeRequest(requestHandler, 'mybundle.bundle?runModule=true').then(
response => {
expect(response.getHeader('Content-Length')).toEqual(
'' + Buffer.byteLength(response.body),
);
},
);
});
it('returns 304 on request of *.bundle when if-modified-since equals Last-Modified', () => {
@ -175,70 +171,73 @@ describe('processRequest', () => {
});
it('returns sourcemap on request of *.map', () => {
return makeRequest(
requestHandler,
'mybundle.map?runModule=true',
).then(response => expect(response.body).toEqual('this is the source map'));
return makeRequest(requestHandler, 'mybundle.map?runModule=true').then(
response => expect(response.body).toEqual('this is the source map'),
);
});
it('works with .ios.js extension', () => {
return makeRequest(
requestHandler,
'index.ios.includeRequire.bundle',
).then(response => {
expect(response.body).toEqual('this is the source');
expect(Serializers.fullBundle).toBeCalledWith(expect.any(DeltaBundler), {
assetPlugins: [],
bundleType: 'bundle',
deltaBundleId: expect.any(String),
dev: true,
entryFile: 'index.ios.js',
entryModuleOnly: false,
excludeSource: false,
generateSourceMaps: false,
hot: true,
inlineSourceMap: false,
isolateModuleIDs: false,
minify: false,
onProgress: jasmine.any(Function),
platform: null,
resolutionResponse: null,
runBeforeMainModule: ['InitializeCore'],
runModule: true,
sourceMapUrl: 'http://localhost:8081/index.ios.includeRequire.map',
unbundle: false,
});
});
return makeRequest(requestHandler, 'index.ios.includeRequire.bundle').then(
response => {
expect(response.body).toEqual('this is the source');
expect(Serializers.fullBundle).toBeCalledWith(
expect.any(DeltaBundler),
{
assetPlugins: [],
bundleType: 'bundle',
deltaBundleId: expect.any(String),
dev: true,
entryFile: 'index.ios.js',
entryModuleOnly: false,
excludeSource: false,
generateSourceMaps: false,
hot: true,
inlineSourceMap: false,
isolateModuleIDs: false,
minify: false,
onProgress: jasmine.any(Function),
platform: null,
resolutionResponse: null,
runBeforeMainModule: ['InitializeCore'],
runModule: true,
sourceMapUrl: 'http://localhost:8081/index.ios.includeRequire.map',
unbundle: false,
},
);
},
);
});
it('passes in the platform param', function() {
return makeRequest(
requestHandler,
'index.bundle?platform=ios',
).then(function(response) {
expect(response.body).toEqual('this is the source');
expect(Serializers.fullBundle).toBeCalledWith(expect.any(DeltaBundler), {
assetPlugins: [],
bundleType: 'bundle',
deltaBundleId: expect.any(String),
dev: true,
entryFile: 'index.js',
entryModuleOnly: false,
excludeSource: false,
generateSourceMaps: false,
hot: true,
inlineSourceMap: false,
isolateModuleIDs: false,
minify: false,
onProgress: jasmine.any(Function),
platform: 'ios',
resolutionResponse: null,
runBeforeMainModule: ['InitializeCore'],
runModule: true,
sourceMapUrl: 'http://localhost:8081/index.map?platform=ios',
unbundle: false,
});
});
return makeRequest(requestHandler, 'index.bundle?platform=ios').then(
function(response) {
expect(response.body).toEqual('this is the source');
expect(Serializers.fullBundle).toBeCalledWith(
expect.any(DeltaBundler),
{
assetPlugins: [],
bundleType: 'bundle',
deltaBundleId: expect.any(String),
dev: true,
entryFile: 'index.js',
entryModuleOnly: false,
excludeSource: false,
generateSourceMaps: false,
hot: true,
inlineSourceMap: false,
isolateModuleIDs: false,
minify: false,
onProgress: jasmine.any(Function),
platform: 'ios',
resolutionResponse: null,
runBeforeMainModule: ['InitializeCore'],
runModule: true,
sourceMapUrl: 'http://localhost:8081/index.map?platform=ios',
unbundle: false,
},
);
},
);
});
it('passes in the assetPlugin param', function() {
@ -283,12 +282,11 @@ describe('processRequest', () => {
};
});
return makeRequest(
requestHandler,
'index.delta?platform=ios',
).then(function(response) {
expect(response.body).toEqual('{"delta": "bundle"}');
});
return makeRequest(requestHandler, 'index.delta?platform=ios').then(
function(response) {
expect(response.body).toEqual('{"delta": "bundle"}');
},
);
});
it('should send the correct deltaBundlerId to the bundler', () => {

View File

@ -40,9 +40,9 @@ it('symbolicates stack frames', () => {
];
const stack = mappings.map(m => m.to);
const maps = Object.entries(
groupBy(mappings, m => m.from.file),
).map(([file, ms]) => [file, sourceMap(file, ms)]);
const maps = Object.entries(groupBy(mappings, m => m.from.file)).map(
([file, ms]) => [file, sourceMap(file, ms)],
);
return symbolicate(connection, makeData(stack, maps)).then(() =>
expect(connection.end).toBeCalledWith(

View File

@ -86,8 +86,9 @@ exports.handler = makeAsyncCommand(async (argv: any) => {
function onReady(server) {
console.log(
`The HTTP server is ready to accept requests on ${server.address()
.address}:${server.address().port}`,
`The HTTP server is ready to accept requests on ${
server.address().address
}:${server.address().port}`,
);
}

View File

@ -303,14 +303,14 @@ class URIBasedGlobalTransformCache {
* waiting a little time before retring if experience shows it's useful.
*/
static _fetchResultFromURIWithRetry(uri: string): Promise<CachedResult> {
return URIBasedGlobalTransformCache._fetchResultFromURI(
uri,
).catch(error => {
if (!URIBasedGlobalTransformCache.shouldRetryAfterThatError(error)) {
throw error;
}
return this._fetchResultFromURI(uri);
});
return URIBasedGlobalTransformCache._fetchResultFromURI(uri).catch(
error => {
if (!URIBasedGlobalTransformCache.shouldRetryAfterThatError(error)) {
throw error;
}
return this._fetchResultFromURI(uri);
},
);
}
/**

View File

@ -106,7 +106,9 @@ class AssetResolutionCache {
platform: assetData.platform,
});
if (assetData.platform) {
const assetNameWithPlatform = `${assetData.name}.${assetData.platform}.${assetData.type}`;
const assetNameWithPlatform = `${assetData.name}.${
assetData.platform
}.${assetData.type}`;
getWithDefaultArray(results, assetNameWithPlatform).push({
fileName,
platform: null,

View File

@ -269,13 +269,12 @@ describe('Module', () => {
it('exposes the transformed code rather than the raw file contents', () => {
transformResult = {code: exampleCode};
const module = createModule({transformCode});
return Promise.all([
module.read(),
module.getCode(),
]).then(([data, code]) => {
expect(data.code).toBe(exampleCode);
expect(code).toBe(exampleCode);
});
return Promise.all([module.read(), module.getCode()]).then(
([data, code]) => {
expect(data.code).toBe(exampleCode);
expect(code).toBe(exampleCode);
},
);
});
it('exposes the raw file contents as `source` property', () => {
@ -287,13 +286,12 @@ describe('Module', () => {
const map = {version: 3};
transformResult = {map, code: exampleCode};
const module = createModule({transformCode});
return Promise.all([
module.read(),
module.getMap(),
]).then(([data, sourceMap]) => {
expect(data.map).toBe(map);
expect(sourceMap).toBe(map);
});
return Promise.all([module.read(), module.getMap()]).then(
([data, sourceMap]) => {
expect(data.map).toBe(map);
expect(sourceMap).toBe(map);
},
);
});
it('caches the transform result for the same transform options', () => {

View File

@ -4308,9 +4308,9 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.0.tgz#47481588f41f7c90f63938feb202ac82554e7150"
prettier@1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.1.tgz#41638a0d47c1efbd1b7d5a742aaa5548eab86d70"
pretty-format@21.3.0-beta.13:
version "21.3.0-beta.13"