Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lakhdar committed Jan 20, 2021
0 parents commit c2acacd
Show file tree
Hide file tree
Showing 14 changed files with 4,320 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"ignorePatterns": ["node_modules"],
"env": {
"jest": true
},
"extends": ["prettier"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["./node_modules/gts"],
"parserOptions": {
"jsxPragma": "h"
},
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{"ignoreRestSiblings": true}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-types": "off"
}
},
{
"files": ["**/*.js", "**/*.jsx"],
"extends": ["eslint:recommended"],
"rules": {
"no-unused-vars": ["error", {"argsIgnorePattern": "^_"}]
},
"env": {
"node": true
}
}
],
"root": true
}
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
*-debug.log
*-error.log
.nyc_output
dist
bin
lib
package-lock.json
tmp
node_modules

.idea
npm-debug.log
.vscode/*
.ds_store
veracode
.size-snapshot.json
reports/*.xml

!.vscode/extensions.json
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
bracketSpacing: false,
singleQuote: true,
trailingComma: 'es5',
};
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@coveo/cli
==========



[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@coveo/cli.svg)](https://npmjs.org/package/@coveo/cli)
[![Codecov](https://codecov.io/gh/coveo/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/coveo/cli)
[![Downloads/week](https://img.shields.io/npm/dw/@coveo/cli.svg)](https://npmjs.org/package/@coveo/cli)
[![License](https://img.shields.io/npm/l/@coveo/cli.svg)](https://github.com/coveo/cli/blob/master/package.json)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g @coveo/cli
$ coveo COMMAND
running command...
$ coveo (-v|--version|version)
@coveo/cli/0.0.0 darwin-x64 node-v14.15.4
$ coveo --help [COMMAND]
USAGE
$ coveo COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`coveo hello [FILE]`](#coveo-hello-file)
* [`coveo help [COMMAND]`](#coveo-help-command)

## `coveo hello [FILE]`

describe the command here

```
USAGE
$ coveo hello [FILE]
OPTIONS
-f, --force
-h, --help show CLI help
-n, --name=name name to print
EXAMPLE
$ coveo hello
hello world from ./src/hello.ts!
```

_See code: [src/commands/hello.ts](https://github.com/coveo/cli/blob/v0.0.0/src/commands/hello.ts)_

## `coveo help [COMMAND]`

display help for coveo

```
USAGE
$ coveo 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/v3.2.1/src/commands/help.ts)_
<!-- commandsstop -->
87 changes: 87 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "@coveo/cli",
"version": "0.0.0",
"author": "Coveo",
"bin": {
"coveo": "./bin/run"
},
"bugs": "https://github.com/coveo/cli/issues",
"dependencies": {
"@oclif/command": "^1",
"@oclif/config": "^1",
"@oclif/plugin-help": "^3",
"tslib": "^1"
},
"devDependencies": {
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/lint": "^11.0.0",
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"@types/chai": "^4",
"@types/mocha": "^5",
"@types/node": "^10",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"chai": "^4",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"globby": "^10",
"gts": "^3.1.0",
"husky": "^4.3.8",
"lint-staged": "^10.5.3",
"mocha": "^5",
"nyc": "^14",
"prettier": "^2.2.1",
"ts-node": "^8",
"typescript": "^3.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"lint-staged": {
"**/*.ts": [
"npm run lint:fix",
"git add"
]
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"/bin",
"/lib",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"homepage": "https://github.com/coveo/cli",
"keywords": [
"oclif"
],
"license": "Apache-2.0",
"main": "lib/index.js",
"oclif": {
"commands": "./lib/commands",
"bin": "coveo",
"plugins": [
"@oclif/plugin-help"
]
},
"repository": "coveo/cli",
"scripts": {
"lint:check": "eslint .",
"lint:fix": "eslint --fix .",
"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"
},
"types": "lib/index.d.ts"
}
31 changes: 31 additions & 0 deletions src/commands/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {Command, flags} from '@oclif/command';

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

static examples = [
`$ coveo hello
hello world from ./src/hello.ts!
`,
];

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(Hello);

const name = flags.name ?? 'world';
this.log(`hello ${name} from ./src/commands/hello.ts`);
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`);
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {run} from '@oclif/command';
17 changes: 17 additions & 0 deletions test/commands/hello.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {expect, test} from '@oclif/test';

describe('hello', () => {
test
.stdout()
.command(['hello'])
.it('runs hello', (ctx) => {
expect(ctx.stdout).to.contain('hello world');
});

test
.stdout()
.command(['hello', '--name', 'jeff'])
.it('runs hello --name jeff', (ctx) => {
expect(ctx.stdout).to.contain('hello jeff');
});
});
5 changes: 5 additions & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--require ts-node/register
--watch-extensions ts
--recursive
--reporter spec
--timeout 5000
9 changes: 9 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"noEmit": true
},
"references": [
{"path": ".."}
]
}
14 changes: 14 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"outDir": "lib",
"rootDir": "src",
"strict": true,
"target": "es2017"
},
"include": [
"src/**/*"
]
}
Loading

0 comments on commit c2acacd

Please sign in to comment.