Skip to content

Commit 7cb8610

Browse files
committed
Add npm run android, remove unused deps.
Closes expo#40.
1 parent 648edea commit 7cb8610

File tree

5 files changed

+72
-341
lines changed

5 files changed

+72
-341
lines changed

react-native-scripts/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
"fs-promise": "^1.0.0",
3131
"indent-string": "^3.0.0",
3232
"inquirer": "^3.0.1",
33-
"jscodeshift": "^0.3.30",
3433
"match-require": "^2.0.0",
3534
"path-exists": "^3.0.0",
3635
"qrcode-terminal": "^0.11.0",
37-
"xdl": "^31.1.0"
36+
"xdl": "^32.0.0"
3837
},
3938
"devDependencies": {
4039
"babel-plugin-add-module-exports": "^0.2.1",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const args = process.argv.slice(3);
88
const validCommands = [
99
'build',
1010
'eject',
11+
'android',
1112
'ios',
1213
'start',
1314
'test',
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Android, Config, ProjectSettings, UrlUtils } from "xdl";
2+
3+
import chalk from "chalk";
4+
import indent from "indent-string";
5+
import path from "path";
6+
import pathExists from "path-exists";
7+
import qr from "qrcode-terminal";
8+
9+
import packager from "../util/packager";
10+
11+
Config.validation.reactNativeVersionWarnings = false;
12+
Config.developerTool = "crna";
13+
Config.offline = true;
14+
15+
const command: string = pathExists.sync(path.join(process.cwd(), "yarn.lock"))
16+
? "yarnpkg"
17+
: "npm";
18+
19+
packager.run(startAndroidAndPrintInfo);
20+
21+
// print a nicely formatted message with setup information
22+
async function startAndroidAndPrintInfo() {
23+
const address = await UrlUtils.constructManifestUrlAsync(process.cwd());
24+
console.log(chalk.blue("Starting Android..."));
25+
26+
const { success, error } = await Android.openProjectAsync(process.cwd());
27+
28+
qr.generate(address, qrCode => {
29+
console.log(
30+
`To view your app with live reloading, point the Exponent app to this QR code:
31+
32+
${indent(qrCode, 2)}
33+
34+
You'll find the QR scanner on the Projects tab of the app, under the '+' menu.
35+
36+
Or enter this address in the Exponent app's search bar:
37+
38+
${chalk.underline(chalk.cyan(address))}
39+
40+
Your phone will need to be on the same local network as this computer.
41+
42+
For links to install the Exponent app, please visit ${chalk.underline(chalk.cyan("https://getexponent.com"))}.
43+
44+
Logs from serving your app will appear here. Press Ctrl+C at any time to stop.
45+
`
46+
);
47+
});
48+
49+
if (!success) {
50+
console.log(chalk.red(error.message));
51+
}
52+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = async (appPath: string, appName: string, verbose: boolean) => {
3737
start: "react-native-scripts start",
3838
build: "react-native-scripts build",
3939
eject: "react-native-scripts eject",
40+
android: "react-native-scripts android",
4041
ios: "react-native-scripts ios",
4142
test: "node node_modules/jest/bin/jest.js",
4243
};

0 commit comments

Comments
 (0)