Skip to content

Commit

Permalink
feat: Add create-tsbb pkg.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 19, 2021
1 parent 6b5bf31 commit a855783
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"build:hapi": "lerna exec \"npm run build\" --scope @template/hapi --stream",
"build:react-component": "lerna exec \"npm run build && npm run doc\" --scope @template/react-component --stream",
"build:react-component-tsx": "lerna exec \"npm run build\" --scope @template/react-component --stream",
"watch": "lerna exec \"tsc -p ./ --types --outDir lib --watch\" --scope tsbb --stream",
"build": "lerna exec \"tsc -p ./ --types --outDir lib\" --scope tsbb --stream",
"type-check": "lerna exec \"tsc --noEmit\" --scope tsbb --stream",
"watch": "lerna exec \"tsc -p ./ --types --outDir lib --watch\" --scope create-tsbb --scope tsbb --stream",
"build": "lerna exec \"tsc -p ./ --types --outDir lib\" --scope create-tsbb --scope tsbb --stream",
"type-check": "lerna exec \"tsc --noEmit\" --scope create-tsbb --scope tsbb --stream",
"hoist": "lerna bootstrap --hoist",
"clean": "lerna clean --yes",
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
Expand Down
64 changes: 64 additions & 0 deletions packages/create-tsbb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## create-tsbb

[![tsbb](https://user-images.githubusercontent.com/1680273/57547188-94c60100-7390-11e9-93b2-5ebf085bb925.png)](https://github.com/jaywcjlove/tsbb)

<p align="center">
<a href="https://www.travis-ci.org/jaywcjlove/tsbb">
<img src="https://www.travis-ci.org/jaywcjlove/tsbb.svg?branch=master">
</a>
<a href="https://github.com/jaywcjlove/tsbb/issues">
<img src="https://img.shields.io/github/issues/jaywcjlove/tsbb.svg">
</a>
<a href="https://github.com/jaywcjlove/tsbb/network">
<img src="https://img.shields.io/github/forks/jaywcjlove/tsbb.svg">
</a>
<a href="https://github.com/jaywcjlove/tsbb/stargazers">
<img src="https://img.shields.io/github/stars/jaywcjlove/tsbb.svg">
</a>
<a href="https://github.com/jaywcjlove/tsbb/releases">
<img src="https://img.shields.io/github/release/jaywcjlove/tsbb.svg">
</a>
<a href="https://www.npmjs.com/package/create-tsbb">
<img src="https://img.shields.io/npm/v/create-tsbb.svg">
</a>
</p>

Creates a [`tsbb`](https://www.travis-ci.org/jaywcjlove/tsbb) application using the command line.

### Usage

```shell
$ yarn create tsbb [appName]
# or npm
$ npm create tsbb my-app
# or npx
$ npx create-tsbb my-app
```

### Command Help

Below is a help of commands you might find useful. The example download is from https://jaywcjlove.github.io/tsbb

```bash
Usage: create-tsbb <app-name> [options] [--help|h]

Options:
--version, -v Show version number
--help, -h Displays help information.
--example, -e Example from: https://jaywcjlove.github.io/tsbb , default: "basic"
--force, -f Overwrite target directory if it exists. default: false
--path, -p Specify the download target git address. default: "https://jaywcjlove.github.io/tsbb"

Example:
npx create-tsbb my-app
yarn create tsbb appName
npm create tsbb my-app
npm create tsbb my-app -f
npm create tsbb my-app -p https://jaywcjlove.github.io/tsbb

Copyright 2021
```
## License
[MIT © Kenny Wong](https://github.com/jaywcjlove/tsbb/blob/master/LICENSE)
48 changes: 48 additions & 0 deletions packages/create-tsbb/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "create-tsbb",
"version": "1.0.1",
"description": "Creates a TSBB application using the command line.",
"homepage": "https://jaywcjlove.github.io/tsbb",
"author": "Kenny Wong <wowohoo@qq.com> (https://github.com/jaywcjlove)",
"main": "lib/index.js",
"typings": "lib/create.d.ts",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jaywcjlove/tree/master/create-tsbb"
},
"bin": {
"create-tsbb": "lib/cli.js"
},
"scripts": {
"watch": "npm run watch:ts",
"watch:ts": "tsbb watch & npm run build:types -- --watch",
"build": "npm run build:ts && npm run build:types",
"build:ts": "tsbb build",
"build:types": "tsbb types"
},
"files": [
"lib",
"src"
],
"jest": {},
"keywords": [
"kkt",
"tsbb",
"create-tsbb",
"react",
"redux",
"rematch",
"uiw",
"redux-saga",
"elm",
"framework",
"frontend"
],
"devDependencies": {
"tsbb": "2.0.0"
},
"dependencies": {
"create-kkt": "2.1.3"
}
}
62 changes: 62 additions & 0 deletions packages/create-tsbb/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env node

import minimist from 'minimist';
import { create } from 'create-kkt';

async function run(): Promise<void> {
try {
const argvs = minimist(process.argv.slice(2));
if (argvs.h || argvs.help) {
console.log('\n Usage: create-tsbb <app-name> [options] [--help|h]');
console.log('\n Options:');
console.log(' --version, -v', 'Show version number');
console.log(' --help, -h', 'Displays help information.');
console.log(
' --example, -e',
'Example from: \x1b[34mhttp://jaywcjlove.github.io/tsbb/ \x1b[0m , default: "basic"',
);
console.log(' --force, -f', 'Overwrite target directory if it exists. default: false');
console.log(
' --path, -p',
'Specify the download target git address. default: "\x1b[34mhttp://jaywcjlove.github.io/tsbb/ \x1b[0m"',
);
exampleHelp();
console.log('\n Copyright 2021');
console.log('\n');
return;
}
const { version } = require('../package.json');
if (argvs.v || argvs.version) {
console.log(`\n create-tsbb v${version}\n`);
return;
}
argvs.appName = argvs._[0];
argvs.path = argvs.p = argvs.path || argvs.p || 'http://jaywcjlove.github.io/tsbb/';
argvs.force = argvs.f = argvs.force || argvs.f || false;
argvs.example = argvs.e = (argvs.example || argvs.e || 'basic').toLocaleLowerCase();
create(argvs, exampleHelp);
} catch (error) {
console.log(`\x1b[31m${error.message}\x1b[0m`);
console.log(error);
process.exit(1);
}
}

export function exampleHelp() {
console.log('\n Example:');
console.log(' \x1b[35myarn\x1b[0m create tsbb \x1b[33mappName\x1b[0m');
console.log(' \x1b[35mnpx\x1b[0m create-tsbb \x1b[33mmy-app\x1b[0m');
console.log(' \x1b[35mnpm\x1b[0m create tsbb \x1b[33mmy-app\x1b[0m');
console.log(' \x1b[35mnpm\x1b[0m create tsbb \x1b[33mmy-app\x1b[0m -f');
console.log(
' \x1b[35mnpm\x1b[0m create tsbb \x1b[33mmy-app\x1b[0m -p \x1b[34mhttp://jaywcjlove.github.io/tsbb/\x1b[0m',
);
}

try {
run();
} catch (error) {
console.log(`\x1b[31m${error.message}\x1b[0m`);
console.log(error);
process.exit(1);
}
1 change: 1 addition & 0 deletions packages/create-tsbb/src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="node" />
16 changes: 16 additions & 0 deletions packages/create-tsbb/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"declaration": true,
"target": "es2017",
"noImplicitAny": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "lib",
"baseUrl": ".",
"typeRoots": ["node_modules/@types/*", "src/type/*"]
},
"include": ["src/**/*"]
}
15 changes: 10 additions & 5 deletions packages/tsbb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ TSBB is a zero-config CLI that helps you develop, test, and publish modern TypeS

You will need `Node.js` installed on your system.

```bash
$ npx tsbb create my-project
```shell
$ yarn create tsbb [appName]
# or npm
$ npm create tsbb my-app
# or npx
$ npx create-tsbb my-app

$ cd my-project

$ npm run watch # Listen compile .ts files.
Expand All @@ -61,7 +66,7 @@ or
```bash
$ npm install tsbb -g
# Create project
$ tsbb create my-project --example=Express
$ create-tsbb my-project --example=express
# --- Example name ----------------┴ˇˇˇˇˇˇ
```

Expand All @@ -70,9 +75,9 @@ $ tsbb create my-project --example=Express
Initialize the project from one of the examples:

```shell
$ npx tsbb create my-app -e <Example Name>
$ npx create-tsbb my-app -e <Example Name>
# --- E.g: ----------------┴ˇˇˇˇˇˇˇˇˇˇˇˇˇˇ
# npx tsbb create my-app -e Basic
# npx create-tsbb my-app -e Basic
```

- [**`Basic`**](example/basic) - The [Node.js](https://nodejs.org/en/) base application example.
Expand Down

0 comments on commit a855783

Please sign in to comment.