Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
Merge exp.js and expo.js back together
Browse files Browse the repository at this point in the history
fbshipit-source-id: 7e97a6c
  • Loading branch information
fson authored and expbot committed Mar 3, 2018
1 parent b416805 commit 82d4205
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 479 deletions.
2 changes: 1 addition & 1 deletion bin/exp.js
Expand Up @@ -7,7 +7,7 @@ var ver = process.versions.node;
ver = ver.split('-')[0]; // explode and truncate tag from version

if (semver.satisfies(ver, '>=6.0.0')) {
require('../build/exp.js').run();
require('../build/exp.js').run('exp');
} else {
console.log(
require('chalk').red(
Expand Down
2 changes: 1 addition & 1 deletion expo-cli/bin/expo.js
Expand Up @@ -7,7 +7,7 @@ var ver = process.versions.node;
ver = ver.split('-')[0]; // explode and truncate tag from version

if (semver.satisfies(ver, '>=6.0.0')) {
require('../build/expo.js').run();
require('../build/exp.js').run('expo');
} else {
console.log(
require('chalk').red(
Expand Down
34 changes: 17 additions & 17 deletions src/exp.js
Expand Up @@ -31,6 +31,7 @@ import log from './log';
import update from './update';
import urlOpts from './urlOpts';
import addCommonOptions from './commonOptions';
import packageJSON from '../package.json';

if (process.env.NODE_ENV === 'development') {
require('source-map-support').install();
Expand Down Expand Up @@ -101,7 +102,7 @@ Command.prototype.asyncAction = function(asyncFn, skipUpdateCheck) {

// asyncActionProjectDir captures the projectDirectory from the command line,
// setting it to cwd if it is not provided.
// Commands such as `exp start` and `exp publish` use this.
// Commands such as `start` and `publish` use this.
// It does several things:
// - Everything in asyncAction
// - Checks if the user is logged in or out
Expand Down Expand Up @@ -283,7 +284,7 @@ Command.prototype.asyncActionProjectDir = function(asyncFn, skipProjectValidatio
//
// If the packager/manifest server is running and healthy, there is no need
// to rerun Doctor because the directory was already checked previously
// This is relevant for command such as `exp send`
// This is relevant for command such as `send`
if (!skipProjectValidation && (await Project.currentStatus(projectDir)) !== 'running') {
log('Making sure project is set up correctly...');
simpleSpinner.start();
Expand All @@ -304,11 +305,11 @@ Command.prototype.asyncActionProjectDir = function(asyncFn, skipProjectValidatio
}, true);
};

function runAsync() {
function runAsync(programName) {
try {
// Setup analytics
Analytics.setSegmentNodeKey('vGu92cdmVaggGA26s3lBX6Y5fILm8SQ7');
Analytics.setVersionName(require('../package.json').version);
Analytics.setVersionName(packageJSON.version);
_registerLogs();

if (process.env.SERVER_URL) {
Expand All @@ -321,18 +322,20 @@ function runAsync() {
Config.api.port = parsedUrl.port;
}

Config.developerTool = 'exp';
Config.developerTool = packageJSON.name;

// Setup our commander instance
program.name = 'exp';
program.name = programName;
program
.version(require('../package.json').version)
.version(packageJSON.version)
.option('-o, --output [format]', 'Output format. pretty (default), raw');

// Load each module found in ./commands by 'registering' it with our commander instance
const files = _.uniqBy(
[
...glob.sync('exp_commands/*.js', { cwd: __dirname }),
...(programName === 'exp'
? glob.sync('exp_commands/*.js', { cwd: __dirname })
: glob.sync('expo_commands/*.js', { cwd: __dirname })),
...glob.sync('commands/*.js', { cwd: __dirname }),
],
path.basename
Expand Down Expand Up @@ -374,7 +377,7 @@ function runAsync() {
});
if (!_.includes(commands, subCommand)) {
console.log(
`"${subCommand}" is not an exp command. See "exp --help" for the full list of commands.`
`"${subCommand}" is not an ${programName} command. See "${programName} --help" for the full list of commands.`
);
}
} else {
Expand All @@ -394,18 +397,15 @@ async function checkForUpdateAsync() {
break;

case 'out-of-date':
message = `There is a new version of exp available (${latest}).
You are currently using exp ${current}
Run \`npm install -g exp\` to get the latest version`;
message = `There is a new version of ${packageJSON.name} available (${latest}).
You are currently using ${packageJSON.name} ${current}
Run \`npm install -g ${packageJSON.name}\` to get the latest version`;
log.error(chalk.green(message));
break;

case 'ahead-of-published':
// if the user is ahead of npm, we're going to assume they know what they're doing
break;

default:
log.error('Confused about what version of exp you have?');
}
}

Expand Down Expand Up @@ -453,9 +453,9 @@ async function writePathAsync() {
}

// This is the entry point of the CLI
export function run() {
export function run(programName) {
(async function() {
await Promise.all([writePathAsync(), runAsync()]);
await Promise.all([writePathAsync(), runAsync(programName)]);
})().catch(e => {
console.error('Uncaught Error', e);
process.exit(1);
Expand Down

0 comments on commit 82d4205

Please sign in to comment.