Skip to content

Commit 48d1d87

Browse files
brentvatneanp
authored andcommitted
Initial pass at support -- deps still need to be updated
1 parent ed4f5f4 commit 48d1d87

File tree

5 files changed

+102
-25
lines changed

5 files changed

+102
-25
lines changed

react-native-scripts/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-scripts",
3-
"version": "1.3.1",
3+
"version": "1.4.0",
44
"description": "Configuration and scripts for Create React Native App.",
55
"license": "BSD-3-Clause",
66
"keywords": [
@@ -24,20 +24,21 @@
2424
"build": "taskr build"
2525
},
2626
"dependencies": {
27+
"@expo/bunyan": "1.8.10",
2728
"babel-runtime": "^6.9.2",
2829
"chalk": "^2.0.1",
2930
"cross-spawn": "^5.0.1",
3031
"fs-extra": "^3.0.1",
3132
"indent-string": "^3.0.0",
3233
"inquirer": "^3.0.1",
34+
"lodash": "^4.17.4",
3335
"match-require": "^2.0.0",
3436
"minimist": "^1.2.0",
3537
"path-exists": "^3.0.0",
3638
"progress": "^2.0.0",
3739
"qrcode-terminal": "^0.11.0",
3840
"rimraf": "^2.6.1",
39-
"xdl": "44.0.0",
40-
"@expo/bunyan": "1.8.10"
41+
"xdl": "45.0.0-alpha.0"
4142
},
4243
"devDependencies": {
4344
"@taskr/babel": "^1.0.6",

react-native-scripts/src/scripts/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import install from '../util/install';
1010

1111
// UPDATE DEPENDENCY VERSIONS HERE
1212
const DEFAULT_DEPENDENCIES = {
13-
expo: '^20.0.0',
13+
expo: '^21.0.0-rc.5',
1414
react: '16.0.0-alpha.12',
15-
'react-native': '^0.47.0',
15+
'react-native': '^0.48.3',
1616
};
1717

1818
// TODO figure out how this interacts with ejection

react-native-scripts/src/util/packager.js

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ProjectUtils,
88
} from 'xdl';
99

10+
import _ from 'lodash';
1011
import spawn from 'cross-spawn';
1112
import ProgressBar from 'progress';
1213
import bunyan from '@expo/bunyan';
@@ -62,7 +63,11 @@ function shouldIgnoreMsg(msg) {
6263
msg.indexOf('Warning: PropTypes has been moved to a separate package') >= 0;
6364
}
6465

65-
function run(onReady: () => ?any, options: Object = {}, isInteractive = false) {
66+
function run(
67+
onReady: () => ?any,
68+
options: Object = {},
69+
isInteractive?: boolean = false
70+
) {
6671
let packagerReady = false;
6772
let needsClear = false;
6873
let logBuffer = '';
@@ -142,13 +147,9 @@ ${chalk.cyan(` sudo sysctl -w kern.maxfiles=5242880
142147

143148
if (packagerReady) {
144149
const message = `${chunk.msg.trim()}\n`;
145-
if (chunk.level <= bunyan.INFO) {
146-
log.withTimestamp(message);
147-
} else if (chunk.level === bunyan.WARN) {
148-
log.withTimestamp(chalk.yellow(message));
149-
} else {
150-
log.withTimestamp(chalk.red(message));
150+
logWithLevel(chunk);
151151

152+
if (chunk.level === bunyan.ERROR) {
152153
// if you run into a syntax error then we should clear log output on reload
153154
needsClear = message.indexOf('SyntaxError') >= 0;
154155
}
@@ -248,4 +249,84 @@ ${chalk.cyan(` sudo sysctl -w kern.maxfiles=5242880
248249
);
249250
}
250251

252+
const logStackTrace = (chunk, logFn, nestedLogFn, colorFn) => {
253+
let traceInfo;
254+
try {
255+
traceInfo = JSON.parse(chunk.msg);
256+
} catch (e) {
257+
return logFn(colorFn(chunk.msg));
258+
}
259+
260+
let { message, stack } = traceInfo;
261+
logFn(colorFn(chalk.bold(message)));
262+
263+
const isLibraryFrame = line => {
264+
return line.startsWith('node_modules');
265+
};
266+
267+
let stackFrames = _.compact(stack.split('\n'));
268+
let lastAppCodeFrameIndex = _.findLastIndex(stackFrames, line => {
269+
return !isLibraryFrame(line);
270+
});
271+
let lastFrameIndexToLog = Math.min(
272+
stackFrames.length - 1,
273+
lastAppCodeFrameIndex + 2 // show max two more frames after last app code frame
274+
);
275+
let unloggedFrames = stackFrames.length - lastFrameIndexToLog;
276+
277+
// If we're only going to exclude one frame, just log them all
278+
if (unloggedFrames === 1) {
279+
lastFrameIndexToLog = stackFrames.length - 1;
280+
unloggedFrames = 0;
281+
}
282+
283+
for (let i = 0; i <= lastFrameIndexToLog; i++) {
284+
let line = stackFrames[i];
285+
if (!line) {
286+
continue;
287+
} else if (line.match(/react-native\/.*YellowBox.js/)) {
288+
continue;
289+
}
290+
291+
if (line.startsWith('node_modules')) {
292+
nestedLogFn(colorFn('- ' + line));
293+
} else {
294+
nestedLogFn(colorFn('* ' + line));
295+
}
296+
}
297+
298+
if (unloggedFrames > 0) {
299+
nestedLogFn(
300+
colorFn(
301+
`- ... ${unloggedFrames} more stack frames from framework internals`
302+
)
303+
);
304+
}
305+
};
306+
307+
const logWithLevel = chunk => {
308+
if (!chunk.msg) {
309+
return;
310+
}
311+
312+
let colorFn = (str) => str;
313+
if (chunk.level === bunyan.WARN) {
314+
colorFn = chalk.yellow;
315+
} else if (chunk.level === bunyan.ERROR) {
316+
colorFn = chalk.red;
317+
}
318+
319+
if (chunk.includesStack) {
320+
logStackTrace(chunk, log.withTimestamp, log, colorFn);
321+
} else {
322+
logLines(chunk.msg, log.withTimestamp, colorFn);
323+
}
324+
};
325+
326+
const logLines = (msg, logFn, colorFn) => {
327+
for (let line of msg.split('\n')) {
328+
logFn(colorFn(line));
329+
}
330+
};
331+
251332
export default { run };
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"expo": {
3-
"sdkVersion": "20.0.0"
3+
"sdkVersion": "21.0.0"
44
}
55
}

react-native-scripts/yarn.lock

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
babel-runtime "^6.23.0"
2727
exec-async "^2.2.0"
2828

29-
"@expo/schemer@^1.0.28":
30-
version "1.0.43"
31-
resolved "https://registry.yarnpkg.com/@expo/schemer/-/schemer-1.0.43.tgz#e5129f904c192b79dc88e952d8ce5e6bfa158eb6"
29+
"@expo/[email protected].44":
30+
version "1.0.44"
31+
resolved "https://registry.yarnpkg.com/@expo/schemer/-/schemer-1.0.44.tgz#d74a94ba0217f160c1a86ce1c6a42f581485a542"
3232
dependencies:
3333
ajv "^5.2.2"
3434
babel-polyfill "^6.23.0"
@@ -1774,10 +1774,6 @@ invariant@^2.0.0, invariant@^2.2.0:
17741774
dependencies:
17751775
loose-envify "^1.0.0"
17761776

1777-
ip@^1.1.3:
1778-
version "1.1.5"
1779-
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a"
1780-
17811777
17821778
version "1.3.0"
17831779
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.3.0.tgz#1e03a52fdad83a8bbb2b25cbf4998b4cffcd3dec"
@@ -3342,14 +3338,14 @@ wrappy@1:
33423338
version "1.0.2"
33433339
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
33443340

3345-
xdl@44.0.0:
3346-
version "44.0.0"
3347-
resolved "https://registry.yarnpkg.com/xdl/-/xdl-44.0.0.tgz#72ef1231c12d88348141814076c96c54ad0903a0"
3341+
xdl@45.0.0-alpha.0:
3342+
version "45.0.0-alpha.0"
3343+
resolved "https://registry.yarnpkg.com/xdl/-/xdl-45.0.0-alpha.0.tgz#f9877e9a91b2319c054a22b763e754d3d3ee628f"
33483344
dependencies:
33493345
"@expo/bunyan" "^1.8.10"
33503346
"@expo/json-file" "^5.3.0"
33513347
"@expo/osascript" "^1.8.0"
3352-
"@expo/schemer" "^1.0.28"
3348+
"@expo/schemer" "1.0.44"
33533349
"@expo/spawn-async" "^1.2.8"
33543350
analytics-node "^2.1.0"
33553351
auth0 "^2.7.0"
@@ -3369,7 +3365,6 @@ [email protected]:
33693365
home-dir "^1.0.0"
33703366
indent-string "^3.1.0"
33713367
instapromise "2.0.7-rc.1"
3372-
ip "^1.1.3"
33733368
joi "^10.0.2"
33743369
jsonfile "^2.3.1"
33753370
jsonschema "^1.1.0"

0 commit comments

Comments
 (0)