Skip to content

Commit df4ea5b

Browse files
committed
Initial commit
0 parents  commit df4ea5b

16 files changed

+3174
-0
lines changed

.circleci/config.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
version: 2
3+
jobs:
4+
node-latest: &test
5+
docker:
6+
- image: node:latest
7+
working_directory: ~/cli
8+
steps:
9+
- checkout
10+
- restore_cache: &restore_cache
11+
keys:
12+
- v1-npm-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
13+
- v1-npm-{{checksum ".circleci/config.yml"}}
14+
- run:
15+
name: Install dependencies
16+
command: yarn
17+
- run: ./bin/run --version
18+
- run: ./bin/run --help
19+
- run:
20+
name: Testing
21+
command: yarn test
22+
node-12:
23+
<<: *test
24+
docker:
25+
- image: node:12
26+
node-10:
27+
<<: *test
28+
docker:
29+
- image: node:10
30+
cache:
31+
<<: *test
32+
steps:
33+
- checkout
34+
- run:
35+
name: Install dependencies
36+
command: yarn
37+
- save_cache:
38+
key: v1-npm-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
39+
paths:
40+
- ~/cli/node_modules
41+
- /usr/local/share/.cache/yarn
42+
- /usr/local/share/.config/yarn
43+
44+
workflows:
45+
version: 2
46+
"ppp":
47+
jobs:
48+
- node-latest
49+
- node-12
50+
- node-10
51+
- cache:
52+
filters:
53+
tags:
54+
only: /^v.*/
55+
branches:
56+
ignore: /.*/

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/lib

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": [
3+
"oclif",
4+
"oclif-typescript"
5+
]
6+
}

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*-debug.log
2+
*-error.log
3+
/.nyc_output
4+
/dist
5+
/lib
6+
/package-lock.json
7+
/tmp
8+
node_modules

README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
ppp
2+
===
3+
4+
Pontomais CLI
5+
6+
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7+
[![Version](https://img.shields.io/npm/v/ppp.svg)](https://npmjs.org/package/ppp)
8+
[![CircleCI](https://circleci.com/gh/fmilani/ppp/tree/master.svg?style=shield)](https://circleci.com/gh/fmilani/ppp/tree/master)
9+
[![Downloads/week](https://img.shields.io/npm/dw/ppp.svg)](https://npmjs.org/package/ppp)
10+
[![License](https://img.shields.io/npm/l/ppp.svg)](https://github.com/fmilani/ppp/blob/master/package.json)
11+
12+
<!-- toc -->
13+
* [Usage](#usage)
14+
* [Commands](#commands)
15+
<!-- tocstop -->
16+
# Usage
17+
<!-- usage -->
18+
```sh-session
19+
$ npm install -g ppp
20+
$ ppp COMMAND
21+
running command...
22+
$ ppp (-v|--version|version)
23+
ppp/0.0.0 linux-x64 node-v14.7.0
24+
$ ppp --help [COMMAND]
25+
USAGE
26+
$ ppp COMMAND
27+
...
28+
```
29+
<!-- usagestop -->
30+
# Commands
31+
<!-- commands -->
32+
* [`ppp hello [FILE]`](#ppp-hello-file)
33+
* [`ppp help [COMMAND]`](#ppp-help-command)
34+
35+
## `ppp hello [FILE]`
36+
37+
describe the command here
38+
39+
```
40+
USAGE
41+
$ ppp hello [FILE]
42+
43+
OPTIONS
44+
-f, --force
45+
-h, --help show CLI help
46+
-n, --name=name name to print
47+
48+
EXAMPLE
49+
$ ppp hello
50+
hello world from ./src/hello.ts!
51+
```
52+
53+
_See code: [src/commands/hello.ts](https://github.com/fmilani/ppp/blob/v0.0.0/src/commands/hello.ts)_
54+
55+
## `ppp help [COMMAND]`
56+
57+
display help for ppp
58+
59+
```
60+
USAGE
61+
$ ppp help [COMMAND]
62+
63+
ARGUMENTS
64+
COMMAND command to show help for
65+
66+
OPTIONS
67+
--all see all commands in CLI
68+
```
69+
70+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.1.0/src/commands/help.ts)_
71+
<!-- commandsstop -->

bin/run

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
require('@oclif/command').run()
4+
.then(require('@oclif/command/flush'))
5+
.catch(require('@oclif/errors/handle'))

bin/run.cmd

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\run" %*

package.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "ppp",
3+
"description": "Pontomais CLI",
4+
"version": "0.0.0",
5+
"author": "Felipe Milani @fmilani",
6+
"bin": {
7+
"ppp": "./bin/run"
8+
},
9+
"bugs": "https://github.com/fmilani/ppp/issues",
10+
"dependencies": {
11+
"@oclif/command": "^1",
12+
"@oclif/config": "^1",
13+
"@oclif/plugin-help": "^3",
14+
"tslib": "^1"
15+
},
16+
"devDependencies": {
17+
"@oclif/dev-cli": "^1",
18+
"@oclif/test": "^1",
19+
"@types/chai": "^4",
20+
"@types/mocha": "^5",
21+
"@types/node": "^10",
22+
"chai": "^4",
23+
"eslint": "^5.13",
24+
"eslint-config-oclif": "^3.1",
25+
"eslint-config-oclif-typescript": "^0.1",
26+
"globby": "^10",
27+
"mocha": "^5",
28+
"nyc": "^14",
29+
"ts-node": "^8",
30+
"typescript": "^3.3"
31+
},
32+
"engines": {
33+
"node": ">=8.0.0"
34+
},
35+
"files": [
36+
"/bin",
37+
"/lib",
38+
"/npm-shrinkwrap.json",
39+
"/oclif.manifest.json"
40+
],
41+
"homepage": "https://github.com/fmilani/ppp",
42+
"keywords": [
43+
"oclif"
44+
],
45+
"license": "MIT",
46+
"main": "lib/index.js",
47+
"oclif": {
48+
"commands": "./lib/commands",
49+
"bin": "ppp",
50+
"plugins": [
51+
"@oclif/plugin-help"
52+
]
53+
},
54+
"repository": "fmilani/ppp",
55+
"scripts": {
56+
"postpack": "rm -f oclif.manifest.json",
57+
"posttest": "eslint . --ext .ts --config .eslintrc",
58+
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
59+
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
60+
"version": "oclif-dev readme && git add README.md"
61+
},
62+
"types": "lib/index.d.ts"
63+
}

src/commands/hello.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {Command, flags} from '@oclif/command'
2+
3+
export default class Hello extends Command {
4+
static description = 'describe the command here'
5+
6+
static examples = [
7+
`$ ppp hello
8+
hello world from ./src/hello.ts!
9+
`,
10+
]
11+
12+
static flags = {
13+
help: flags.help({char: 'h'}),
14+
// flag with a value (-n, --name=VALUE)
15+
name: flags.string({char: 'n', description: 'name to print'}),
16+
// flag with no value (-f, --force)
17+
force: flags.boolean({char: 'f'}),
18+
}
19+
20+
static args = [{name: 'file'}]
21+
22+
async run() {
23+
const {args, flags} = this.parse(Hello)
24+
25+
const name = flags.name ?? 'world'
26+
this.log(`hello ${name} from ./src/commands/hello.ts`)
27+
if (args.file && flags.force) {
28+
this.log(`you input --force and --file: ${args.file}`)
29+
}
30+
}
31+
}

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {run} from '@oclif/command'

test/commands/hello.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {expect, test} from '@oclif/test'
2+
3+
describe('hello', () => {
4+
test
5+
.stdout()
6+
.command(['hello'])
7+
.it('runs hello', ctx => {
8+
expect(ctx.stdout).to.contain('hello world')
9+
})
10+
11+
test
12+
.stdout()
13+
.command(['hello', '--name', 'jeff'])
14+
.it('runs hello --name jeff', ctx => {
15+
expect(ctx.stdout).to.contain('hello jeff')
16+
})
17+
})

test/mocha.opts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--require ts-node/register
2+
--watch-extensions ts
3+
--recursive
4+
--reporter spec
5+
--timeout 5000

test/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../tsconfig",
3+
"compilerOptions": {
4+
"noEmit": true
5+
},
6+
"references": [
7+
{"path": ".."}
8+
]
9+
}

tsconfig.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"importHelpers": true,
5+
"module": "commonjs",
6+
"outDir": "lib",
7+
"rootDir": "src",
8+
"strict": true,
9+
"target": "es2017"
10+
},
11+
"include": [
12+
"src/**/*"
13+
]
14+
}

0 commit comments

Comments
 (0)