Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions packages/expo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $ npm install -g @bluebase/cli-expo
$ bluebase COMMAND
running command...
$ bluebase (-v|--version|version)
@bluebase/cli-expo/0.0.29 darwin-x64 node-v12.10.0
@bluebase/cli-expo/0.0.30 darwin-x64 node-v12.10.0
$ bluebase --help [COMMAND]
USAGE
$ bluebase COMMAND
Expand Down Expand Up @@ -62,7 +62,7 @@ EXAMPLE
$ bluebase expo:build
```

_See code: [src/commands/expo/build.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.29/src/commands/expo/build.ts)_
_See code: [src/commands/expo/build.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.30/src/commands/expo/build.ts)_

## `bluebase expo:build:android`

Expand All @@ -82,7 +82,7 @@ EXAMPLE
$ bluebase expo:build:android
```

_See code: [src/commands/expo/build/android.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.29/src/commands/expo/build/android.ts)_
_See code: [src/commands/expo/build/android.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.30/src/commands/expo/build/android.ts)_

## `bluebase expo:build:ios`

Expand All @@ -102,7 +102,7 @@ EXAMPLE
$ bluebase expo:build:ios
```

_See code: [src/commands/expo/build/ios.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.29/src/commands/expo/build/ios.ts)_
_See code: [src/commands/expo/build/ios.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.30/src/commands/expo/build/ios.ts)_

## `bluebase expo:init`

Expand All @@ -122,7 +122,7 @@ EXAMPLE
$ bluebase expo:init
```

_See code: [src/commands/expo/init.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.29/src/commands/expo/init.ts)_
_See code: [src/commands/expo/init.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.30/src/commands/expo/init.ts)_

## `bluebase expo:start`

Expand All @@ -133,14 +133,31 @@ USAGE
$ bluebase expo:start

OPTIONS
--appJsPath=appJsPath [default: ./bluebase/expo/App] Path to App.js file relative to the root directory
--assetsDir=assetsDir [default: ./assets/expo] Path to assets directory relative to the root directory
--buildDir=buildDir [default: ./build/expo] Path to build directory relative to the root directory
--configDir=configDir [default: ./bluebase/expo] Path to config directory relative to the root directory
-a, --android Opens your app in Expo on a connected Android device
-c, --clear Clear the React Native packager cache
-i, --ios Opens your app in Expo in a currently running iOS simulator on your computer
-s, --send-to=send-to An email address to send a link to
-w, --web Opens your app in a web browser
--appJsPath=appJsPath [default: ./bluebase/expo/App] Path to App.js file relative to the root directory
--assetsDir=assetsDir [default: ./assets/expo] Path to assets directory relative to the root directory
--buildDir=buildDir [default: ./build/expo] Path to build directory relative to the root directory
--configDir=configDir [default: ./bluebase/expo] Path to config directory relative to the root directory
--dev Turns dev flag on
--host=(lan|tunnel|localhost) [default: lan] Maximum number of tasks to allow Metro to spawn.
--https To start webpack with https protocol
--lan Same as --host lan
--localhost Same as --host localhost
--max-workers=max-workers Maximum number of tasks to allow Metro to spawn.
--minify Turns minify flag on
--no-dev Turns dev flag off
--no-https To start webpack with http protocol
--no-minify Turns minify flag off
--offline Allows this command to run while offline
--tunnel Same as --host tunnel

EXAMPLE
$ bluebase expo:start
```

_See code: [src/commands/expo/start.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.29/src/commands/expo/start.ts)_
_See code: [src/commands/expo/start.ts](https://github.com/BlueBaseJS/cli/blob/v0.0.30/src/commands/expo/start.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion packages/expo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@bluebase/cli-expo",
"description": "An Expo plugin for BlueBaseJS CLI",
"version": "0.0.29",
"version": "0.0.30",
"author": "BlueEast Team <code@blueeast.com>",
"bugs": "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/BlueBaseJS/cli/issues",
"main": "./lib",
Expand Down
101 changes: 89 additions & 12 deletions packages/expo/src/commands/expo/start.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,101 @@
import { Command, flags } from '@oclif/command';
import { ExpoFlagDefs, ExpoFlags } from '../../flags';

import { Command } from '@oclif/command';
import { Utils } from '@bluebase/cli-core';
import { createBundle } from '../../scripts';
import fromRoot from '../../scripts/fromRoot';
import path from 'path';
import { spawn } from 'child_process';

export default class ExpoStart extends Command {
static description = 'Starts or restarts a local server for your app and gives you a URL to it.';
static description =
'Starts or restarts a local server for your app and gives you a URL to it.';

static examples = [
`$ bluebase expo:start`,
];
static examples = [`$ bluebase expo:start`];

static flags = ExpoFlagDefs;
static flags = {
...ExpoFlagDefs,

'send-to': flags.string({
char: 's',
description: 'An email address to send a link to',
}),

clear: flags.boolean({
char: 'c',
description: 'Clear the React Native packager cache',
}),

'max-workers': flags.integer({
description: 'Maximum number of tasks to allow Metro to spawn.',
}),

android: flags.boolean({
char: 'a',
description: 'Opens your app in Expo on a connected Android device',
}),

ios: flags.boolean({
char: 'i',
description:
'Opens your app in Expo in a currently running iOS simulator on your computer',
}),

web: flags.boolean({
char: 'w',
description: 'Opens your app in a web browser',
}),

host: flags.enum({
default: 'lan',
description: 'Maximum number of tasks to allow Metro to spawn.',
options: ['lan', 'tunnel', 'localhost'],
}),

tunnel: flags.boolean({
description: 'Same as --host tunnel',
}),

lan: flags.boolean({
description: 'Same as --host lan',
}),

localhost: flags.boolean({
description: 'Same as --host localhost',
}),

dev: flags.boolean({
description: 'Turns dev flag on',
}),

'no-dev': flags.boolean({
description: 'Turns dev flag off',
}),

minify: flags.boolean({
description: 'Turns minify flag on',
}),

'no-minify': flags.boolean({
description: 'Turns minify flag off',
}),

https: flags.boolean({
description: 'To start webpack with https protocol',
}),

'no-https': flags.boolean({
description: 'To start webpack with http protocol',
}),

offline: flags.boolean({
description: 'Allows this command to run while offline',
}),
};

async run() {
const parsed = this.parse(ExpoStart);
const flags = parsed.flags as ExpoFlags;
const inputFlags = parsed.flags as ExpoFlags;

Utils.logger.log({
label: '@bluebase/cli/expo',
Expand All @@ -27,10 +104,10 @@ export default class ExpoStart extends Command {
});

// Absolute path of build dir
const buildDir = Utils.fromProjectRoot(flags.buildDir);
const configDir = Utils.fromProjectRoot(flags.configDir);
const assetsDir = Utils.fromProjectRoot(flags.assetsDir);
const appJsPath = Utils.fromProjectRoot(flags.appJsPath);
const buildDir = Utils.fromProjectRoot(inputFlags.buildDir);
const configDir = Utils.fromProjectRoot(inputFlags.configDir);
const assetsDir = Utils.fromProjectRoot(inputFlags.assetsDir);
const appJsPath = Utils.fromProjectRoot(inputFlags.appJsPath);

/////////////////////////////
///// Transpile & Build /////
Expand Down Expand Up @@ -58,7 +135,7 @@ export default class ExpoStart extends Command {
const appJsonPath = path.join(buildDir, 'app.json');
const child = spawn(
fromRoot('./node_modules/.bin/expo'),
['start', '--config', Utils.fromProjectRoot(appJsonPath)],
['start', '--config', Utils.fromProjectRoot(appJsonPath), ...this.argv],
{ shell: true, env: process.env, stdio: 'inherit' }
)
.on('close', (_code: number) => process.exit(0))
Expand Down