Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[legacy-framework] Add initial CLI project #7

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
blitz-cli
=========

Blitz CLI

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/blitz-cli.svg)](https://npmjs.org/package/blitz-cli)
[![Downloads/week](https://img.shields.io/npm/dw/blitz-cli.svg)](https://npmjs.org/package/blitz-cli)
[![License](https://img.shields.io/npm/l/blitz-cli.svg)](https://github.com/mabadir/blitz-cli/blob/master/package.json)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g blitz-cli
$ blitz COMMAND
running command...
$ blitz (-v|--version|version)
blitz-cli/0.0.0 darwin-x64 node-v12.14.1
$ blitz --help [COMMAND]
USAGE
$ blitz COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`blitz console [FILE]`](#blitz-console-file)
* [`blitz db [FILE]`](#blitz-db-file)
* [`blitz generate [FILE]`](#blitz-generate-file)
* [`blitz help [COMMAND]`](#blitz-help-command)
* [`blitz new [FILE]`](#blitz-new-file)
* [`blitz run [FILE]`](#blitz-run-file)
* [`blitz start [FILE]`](#blitz-start-file)

## `blitz console [FILE]`

describe the command here

```
USAGE
$ blitz console [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/console.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/console.ts)_

## `blitz db [FILE]`

describe the command here

```
USAGE
$ blitz db [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/db.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/db.ts)_

## `blitz generate [FILE]`

describe the command here

```
USAGE
$ blitz generate [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/generate.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/generate.ts)_

## `blitz help [COMMAND]`

display help for blitz

```
USAGE
$ blitz help [COMMAND]

ARGUMENTS
COMMAND command to show help for

OPTIONS
--all see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_

## `blitz new [FILE]`

Create new Blitz project

```
USAGE
$ blitz new [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name Directory name
```

_See code: [src/commands/new.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/new.ts)_

## `blitz run [FILE]`

describe the command here

```
USAGE
$ blitz run [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/run.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/run.ts)_

## `blitz start [FILE]`

describe the command here

```
USAGE
$ blitz start [FILE]

OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
```

_See code: [src/commands/start.ts](https://github.com/mabadir/blitz-cli/blob/v0.0.0/src/commands/start.ts)_
<!-- commandsstop -->
5 changes: 5 additions & 0 deletions packages/cli/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

require('@oclif/command').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'))
3 changes: 3 additions & 0 deletions packages/cli/bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
92 changes: 57 additions & 35 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,66 @@
{
"name": "@blitzjs/cli",
"description": "Framework for building monolithic, full-stack, serverless React apps with zero data-fetching and zero client-side state management",
"version": "0.0.1",
"license": "MIT",
"engines": {
"yarn": "^1.19.1",
"node": ">=12.16.1"
"name": "@blitz/cli",
"description": "Blitz CLI",
"version": "0.0.0",
"author": "Mina Abadir @mabadir",
"bin": {
"blitz": "./bin/run"
},
"repository": {
"type": "git",
"url": "https://github.com/blitz-js/blitz"
"dependencies": {
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^2",
"@oclif/plugin-not-found": "^1.2.3",
"tslib": "^1"
},
"author": {
"name": "Brandon Bayer",
"email": "b@bayer.ws",
"url": "https://twitter.com/flybayer"
"devDependencies": {
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"@types/chai": "^4",
"@types/mocha": "^5",
"@types/node": "^10",
"chai": "^4",
"eslint": "^5.13",
"eslint-config-oclif": "^3.1",
"eslint-config-oclif-typescript": "^0.1",
"globby": "^10",
"mocha": "^5",
"nyc": "^14",
"ts-node": "^8",
"typescript": "^3.7.5"
},
"engines": {
"node": ">=8.0.0"
},
"contributors": [
{
"name": "Michael Edelman",
"email": "michael@fabulas.io",
"url": "https://twitter.com/edelman215"
}
],
"main": "dist/index.js",
"module": "dist/testtsdx.esm.js",
"typings": "dist/index.d.ts",
"files": [
"dist"
"/bin",
"/lib",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"keywords": [
"oclif"
],
"license": "MIT",
"main": "lib/index.js",
"oclif": {
"commands": "./lib/commands",
"bin": "blitz",
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-not-found"
]
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint"
"postpack": "rm -f oclif.manifest.json",
"posttest": "eslint . --ext .ts --config .eslintrc",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md"
},
"peerDependencies": {},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
}
"types": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/blitz-js/blitz"
}
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Command, flags} from '@oclif/command'

export default class Console extends Command {
static description = 'describe the command here'

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}

static args = [{name: 'file'}]

async run() {
const {args, flags} = this.parse(Console)

const name = flags.name || 'world'
this.log(`hello ${name} from /Users/mina/Code/blitz-cli/src/commands/console.ts`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Command, flags} from '@oclif/command'

export default class Db extends Command {
static description = 'describe the command here'

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}

static args = [{name: 'file'}]

async run() {
const {args, flags} = this.parse(Db)

const name = flags.name || 'world'
this.log(`hello ${name} from /Users/mina/Code/blitz-cli/src/commands/db.ts`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Command, flags} from '@oclif/command'

export default class Generate extends Command {
static description = 'describe the command here'

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}

static args = [{name: 'file'}]

async run() {
const {args, flags} = this.parse(Generate)

const name = flags.name || 'world'
this.log(`hello ${name} from /Users/mina/Code/blitz-cli/src/commands/generate.ts`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Command, flags} from '@oclif/command'

export default class New extends Command {
static description = 'Create new Blitz project'

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'Directory name'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}

static args = [{name: 'file'}]

async run() {
const {args, flags} = this.parse(New)

const name = flags.name || 'hello-world'
// TODO: Handoff to generator
if (args.file && flags.force) {
// TODO: Logic to force creation on existing directory
}
}
}
25 changes: 25 additions & 0 deletions packages/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Command, flags} from '@oclif/command'

export default class Run extends Command {
static description = 'describe the command here'

static flags = {
help: flags.help({char: 'h'}),
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
// flag with no value (-f, --force)
force: flags.boolean({char: 'f'}),
}

static args = [{name: 'file'}]

async run() {
const {args, flags} = this.parse(Run)

const name = flags.name || 'world'
this.log(`hello ${name} from /Users/mina/Code/blitz-cli/src/commands/run.ts`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}
Loading