Skip to content

Commit

Permalink
Bump to v1.1.0
Browse files Browse the repository at this point in the history
- Fixed #2
- Fixed #3
  • Loading branch information
jonatansalas committed Jul 15, 2017
1 parent 0c80766 commit b0a6d1f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 35 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-typescript-api",
"version": "1.0.4",
"version": "1.1.0",
"description": "A simple CLI to create a Typescript basic project to develop APIs",
"main": "bin/index.js",
"bin": {
Expand Down Expand Up @@ -33,8 +33,9 @@
},
"homepage": "https://github.com/BlackBoxVision/create-typescript-api#readme",
"dependencies": {
"commander": "^2.11.0",
"ink": "^0.1.2",
"ink-text-input": "^1.0.1",
"ink-spinner": "^1.0.0",
"isomorphic-fetch": "^2.2.1",
"prop-types": "^15.5.10",
"react": "^15.6.1",
Expand Down
32 changes: 17 additions & 15 deletions src/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { h, Component, Text } from 'ink';
import TextInput from 'ink-text-input';
import PropTypes from 'prop-types';
import Spinner from 'ink-spinner';
import readLine from 'readline';

import Conditional from './components/Conditional';
Expand All @@ -8,47 +9,48 @@ import FileUtils from './util/File';
import ZipUtils from './util/Zip';

export default class Cli extends Component {
static propTypes = {
projectName: PropTypes.string.isRequired
};

static defaultProps = {
projectName: 'test'
};

state = {
query: '',
progress: 0,
error: null,
result: null,
projectName: null
};

componentDidMount() {
async componentDidMount() {
readLine.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);

await this.createScaffold(this.props.projectName);
}

render(props, state) {
return (
<Container>
<Conditional expression={state.query.length >= 0 && !state.result}>
<Text blue>Insert your project name:</Text>
<br />
<TextInput value={state.query} onChange={this.handleChange} onSubmit={this.handleSubmit} />
<Conditional expression={!state.error && !state.result}>
<Spinner green /> Fetching base project from GitHub.
</Conditional>
<Conditional expression={state.error}>
<Text red>
{state.error}
</Text>
</Conditional>
<Conditional expression={state.result === 'ok'}>
<Text blue>
<Text green>
Project {state.projectName} has been created successfully.
</Text>
</Conditional>
</Container>
);
}

handleChange = value =>
this.setState(state => ({
query: value
}));

handleSubmit = async path => {
createScaffold = async path => {
try {
const gitHubUrl = 'https://github.com/BlackBoxVision/typescript-hapi-starter/archive/master.zip';
const gitHubFolderName = 'typescript-hapi-starter-master';
Expand Down
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env node

import {h, mount} from 'ink';
import { h, mount } from 'ink';
import { Command } from 'commander';

import Cli from './cli';

mount(<Cli/>, process.stdout);
import packageJson from '../package.json';

new Command(packageJson.name)
.version(packageJson.version)
.arguments('<project-name>', 'The name of the Project')
.action(projectName => mount(<Cli projectName={projectName} />, process.stdout))
.parse(process.argv);
28 changes: 12 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"

ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"

ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
Expand Down Expand Up @@ -411,6 +407,10 @@ cli-cursor@^1.0.2:
dependencies:
restore-cursor "^1.0.1"

cli-spinners@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.0.0.tgz#ef987ed3d48391ac3dab9180b406a742180d6e6a"

co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
Expand All @@ -435,7 +435,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

commander@^2.8.1:
commander, commander@^2.8.1:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"

Expand Down Expand Up @@ -720,12 +720,6 @@ has-ansi@^2.0.0:
dependencies:
ansi-regex "^2.0.0"

has-ansi@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-3.0.0.tgz#36077ef1d15f333484aa7fa77a28606f1c655b37"
dependencies:
ansi-regex "^3.0.0"

has-flag@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"
Expand Down Expand Up @@ -785,11 +779,13 @@ ini@~1.3.0:
version "1.3.4"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e"

ink-text-input:
version "1.0.1"
resolved "https://registry.yarnpkg.com/ink-text-input/-/ink-text-input-1.0.1.tgz#e3a94bec0b34290a6933e83ed548c8bb4f04d099"
ink-spinner:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ink-spinner/-/ink-spinner-1.0.0.tgz#fb0897279f06a8f1414467006edba7a5cf1c176c"
dependencies:
has-ansi "^3.0.0"
cli-spinners "^1.0.0"
object.omit "^2.0.1"
prop-types "^15.5.10"

ink@^0.1.2:
version "0.1.2"
Expand Down Expand Up @@ -1109,7 +1105,7 @@ object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"

object.omit@^2.0.0:
object.omit@^2.0.0, object.omit@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
dependencies:
Expand Down

0 comments on commit b0a6d1f

Please sign in to comment.