feat(scripts): add android support, remove Firefox Hello (#67)

This commit is contained in:
Vlad Filippov 2016-09-27 18:52:39 -04:00 коммит произвёл GitHub
Родитель 46923a1735
Коммит 44e015f103
6 изменённых файлов: 86 добавлений и 49 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -5,6 +5,8 @@ loop-server
syncserver
selenium-*
servers_android.json
node_modules
pm2
dump.rdb

Просмотреть файл

@ -163,6 +163,22 @@ Available options:
**Use `npm run test-oauth` - only OAuth functional tests**
*******
### Firefox for Android
> Skip this if you are not working on Firefox for Android and FxA.
You can test sync locally in Firefox for Android using an emulator or a device on the same network. These docs were tested with the [Genymotion](https://www.genymotion.com/download) simulator.
* Install Firefox on the device or emulator.
* Run `npm run start-android` this will: stop all local FxA servers, create a local PM2 configuration and rerun the servers.
The script will tell you which IP to use to work with FxA.
Follow the instructions of the script to update values in `about:config`.
*******
### Firefox for iOS
@ -198,31 +214,6 @@ NODE_ENV=dev DB=mysql node bin/internal.js
*******
### Hello/Loop Setup
> Skip this if you are not working on testing Firefox Hello.
To get the Hello service setup and configured to run with a local version of Firefox Accounts, you need to run a couple commands after running `npm run postinstall` and `./pm2 start servers.json`.
#### Install Hello Service
```bash
npm run install-extras
```
#### Start Hello service
Note: The Hello Service currently only supports node version 0.10.
```bash
nvm install 0.10
nvm exec 0.10 ./pm2 start servers_extra.json
```
#### Run
Once services have started, run `npm start` to open Firefox with a local profile. Access the Hello service as you normally would.
*******
### Running with MailDev
If you want to inspect emails, you can run fxa-local-dev with [MailDev](https://www.npmjs.com/package/maildev).

64
_scripts/start-android.js Normal file
Просмотреть файл

@ -0,0 +1,64 @@
var fs = require('fs');
var path = require('path');
var execSync = require('child_process').execSync;
var _ = require('lodash');
var chalk = require('chalk');
var internalIp = require('internal-ip');
var ip = internalIp.v4();
function createConfig () {
var servers = require('../servers.json');
function findConfig(name) {
return _.findIndex(servers.apps, function(obj) {
return obj.name === name;
});
}
function setConf(idx, name, value) {
servers.apps[idx].env[name] = value;
}
var auth = findConfig('auth-server key server PORT 9000');
var content = findConfig('content-server PORT 3030');
var oauth = findConfig('oauth-server PORT 9010');
setConf(auth, 'CONTENT_SERVER_URL', 'http://' + ip + ':3030');
setConf(auth, 'PUBLIC_URL', 'http://' + ip + ':9000');
setConf(auth, 'MAILER_HOST', ip);
setConf(auth, 'SMTP_PORT', '9999');
setConf(auth, 'OAUTH_URL', 'http://' + ip + ':9010');
setConf(content, 'PUBLIC_URL', 'http://' + ip + ':3030');
setConf(content, 'FXA_URL', 'http://' + ip + ':9000');
setConf(content, 'FXA_OAUTH_URL', 'http://' + ip + ':9010');
setConf(content, 'FXA_PROFILE_URL', 'http://' + ip + ':1111');
setConf(content, 'FXA_PROFILE_IMAGES_URL', 'http://' + ip + ':1112');
setConf(oauth, 'PUBLIC_URL', 'http://' + ip + ':9010');
setConf(oauth, 'CONTENT_URL', 'http://' + ip + ':3030');
setConf(oauth, 'ISSUER', ip + ':9000');
setConf(oauth, 'VERIFICATION_URL', 'http://' + ip + ':5050/v2');
fs.writeFileSync(path.join(__dirname, '..', 'servers_android.json'), JSON.stringify(servers, null, 2));
}
function run(cmd) {
var result = execSync(cmd);
console.log(result.toString());
}
run(__dirname + '/../pm2 kill');
createConfig(ip);
run(__dirname + '/../pm2 start servers_android.json');
console.log(chalk.green('***********'));
console.log(chalk.green('Access the fxa-content-server via:', 'http://' + ip + ':3030'));
console.log(chalk.green('***********'));
console.log(chalk.green('Make sure your Firefox for Android configuration is the following:'));
console.log(chalk.green('identity.fxaccounts.auth.uri', ' http://' + ip + ':9000/v1'));
console.log(chalk.green('identity.fxaccounts.remote.oauth.uri', ' http://' + ip + ':9010/v1'));
console.log(chalk.green('identity.fxaccounts.remote.profile.uri', ' http://' + ip + ':1111/v1'));
console.log(chalk.green('identity.fxaccounts.remote.webchannel.uri', 'http://' + ip + ':3030'));
console.log(chalk.green('***********'));
console.log(chalk.green('Add http://' + ip + ':3030 to "webchannel.allowObject.urlWhitelist"'));

Просмотреть файл

@ -7,6 +7,7 @@
"install-extras": "_scripts/install_extras.sh",
"update": "./pm2 kill && _scripts/update_all.sh",
"start": "fxa-dev-launcher",
"start-android": "node _scripts/start-android.js",
"test": "node test/functional.js --suite=full",
"test-core": "node test/functional.js --suite=core",
"test-oauth": "node test/functional.js --suite=oauth",
@ -27,6 +28,8 @@
"chalk": "1.1.1",
"foxfire": "1.0.1",
"fxa-dev-launcher": "vladikoff/fxa-dev-launcher",
"internal-ip": "1.2.0",
"lodash": "4.16.2",
"minimist": "1.1.1",
"pm2": "1.1.3",
"replace-in-file": "0.2.1",

Просмотреть файл

@ -21,7 +21,7 @@
"min_uptime": "2m"
},
{
"name": "auth-server key server",
"name": "auth-server key server PORT 9000",
"script": "bin/key_server.js",
"cwd": "fxa-auth-server",
"env": {

Просмотреть файл

@ -1,23 +0,0 @@
{
"apps": [
{
"name": "loop-server PORT 10222",
"script": "loop/index.js",
"cwd": "loop-server",
"env": {
"NODE_ENV": "test",
"PORT": "10222",
"CONFIG_FILES": "../_scripts/configs/loop.json"
},
"max_restarts": "1",
"min_uptime": "2m"
},
{
"name": "redis-server PORT 6379",
"script": "redis.sh",
"cwd": "_scripts",
"max_restarts": "1",
"min_uptime": "2m"
}
]
}