Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Commit

Permalink
Started progress on CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
Luciano Nooijen committed Dec 6, 2018
1 parent dce7612 commit 57b8dcd
Show file tree
Hide file tree
Showing 5 changed files with 377 additions and 13 deletions.
5 changes: 5 additions & 0 deletions cli/add-post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function addPost() {
console.log('AddPost Working!');
}

export default addPost;
37 changes: 37 additions & 0 deletions cli/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* tslint:disable: no-console */

import chalk from 'chalk';
import figlet from 'figlet';
import inquirer from 'inquirer';

import addPost from './add-post';

const prompt = inquirer.createPromptModule();
const choices = ['Add post'];
const question = {
choices,
name: 'action',
type: 'list',
message: 'Please select the action you wish to perform',
};

const intro = () => {
console.clear();
console.log(
chalk.yellow(
figlet.textSync('NodeJS Blog', { horizontalLayout: 'full' })));
};

const promptHandler = async () => {
const answer = await prompt([question]) as any; // Hack to avoid error...
if (answer.action === 'Add post') {
addPost();
}
};

const cli = async () => {
intro();
await promptHandler();
};

cli();
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"scripts": {
"dev": "nodemon",
"cli": "ts-node cli/index.ts",
"start": "ts-node server/server.ts",
"build": "tsc",
"lint": "yarn run lint:js && yarn run lint:ts",
Expand Down Expand Up @@ -65,10 +66,13 @@
"devDependencies": {
"@types/eslint": "^4.16.4",
"@types/express": "^4.16.0",
"@types/figlet": "^1.2.0",
"@types/inquirer": "^0.0.43",
"@types/jest": "^23.3.9",
"@types/knex": "^0.15.1",
"@types/node": "^10.12.9",
"babel-eslint": "^10.0.1",
"clui": "^0.3.6",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.12.0",
Expand All @@ -78,7 +82,10 @@
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-security": "^1.4.0",
"figlet": "^1.2.1",
"inquirer": "^6.2.1",
"jest": "^23.6.0",
"minimist": "^1.2.0",
"nodemon": "^1.18.6",
"prettier": "^1.15.2",
"prettier-eslint": "^8.8.2",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"lib": ["es2015"],
"module": "amd", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
Expand Down
Loading

0 comments on commit 57b8dcd

Please sign in to comment.