ueno-cli
Version:
Ueno Command-Line Utility
100 lines • 4.06 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = require("path");
const async_exec_1 = require("async-exec");
const ink_1 = require("ink");
const lodash_1 = require("lodash");
const Spinner = require("ink-spinner");
const PROCESSING = 0;
const DONE = 1;
class ReactNativeInit extends ink_1.Component {
constructor() {
super(...arguments);
this.state = {
mode: PROCESSING,
text: 'Loading...',
};
}
componentDidMount() {
this.start();
}
get folderName() {
return lodash_1.kebabCase(this.props.appName);
}
get dirName() {
return path.join(process.cwd(), this.folderName);
}
start() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { appName, bundleId, next } = this.props;
const branch = !next ? '-b master' : '';
this.setState({ text: 'Cloning ueno-llc/react-native-starter' });
yield async_exec_1.default(`git clone ${branch} git@github.com:ueno-llc/react-native-starter.git ${this.dirName}`);
this.setState({ text: 'Installing dependencies' });
yield async_exec_1.default(`cd ${this.dirName} && yarn`);
this.setState({ text: 'Renaming application' });
yield async_exec_1.default(`cd ${this.dirName} && yarn rename "${appName}" "${bundleId}"`);
this.setState({ mode: DONE });
setTimeout(this.props.onComplete, 10);
});
}
render() {
const { appName } = this.props;
if (this.state.mode === PROCESSING) {
return (ink_1.h("div", null,
ink_1.h("div", null,
"Creating a new React Native app in ",
ink_1.h(ink_1.Color, { green: true }, this.dirName),
"."),
ink_1.h("div", null),
ink_1.h("div", null,
ink_1.h(Spinner, null),
" ",
this.state.text)));
}
if (this.state.mode === DONE) {
return (ink_1.h("div", null,
ink_1.h("div", null),
ink_1.h("div", null,
"Success! Created app ",
ink_1.h(ink_1.Color, { yellow: true }, appName),
" at ",
this.dirName),
ink_1.h("div", null, "Inside that directory, you can run several commands:"),
ink_1.h("div", null),
ink_1.h("div", null,
" ",
ink_1.h(ink_1.Color, { cyan: true }, "yarn start")),
ink_1.h("div", null, " Starts the metro packager"),
ink_1.h("div", null),
ink_1.h("div", null,
" ",
ink_1.h(ink_1.Color, { cyan: true }, "react-native run-ios")),
ink_1.h("div", null, " Builds the iOS app and starts Simulator"),
ink_1.h("div", null),
ink_1.h("div", null,
" ",
ink_1.h(ink_1.Color, { cyan: true }, "react-native run-android")),
ink_1.h("div", null, " Builds the Android app"),
ink_1.h("div", null),
ink_1.h("div", null, "We suggest that you begin by typing:"),
ink_1.h("div", null,
" ",
ink_1.h(ink_1.Color, { cyan: true }, "cd"),
" ",
this.folderName),
ink_1.h("div", null,
" ",
ink_1.h(ink_1.Color, { cyan: true },
"yarn start ",
'&&',
" react-native run-ios")),
ink_1.h("div", null),
ink_1.h("div", null, "Happy hacking!")));
}
return null;
}
}
exports.ReactNativeInit = ReactNativeInit;
//# sourceMappingURL=ReactNativeInit.js.map