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

feat: add base program #12

Merged
merged 14 commits into from
Sep 4, 2023
37 changes: 22 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
"env": {
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"root": true
}
"root": true,
"overrides": [
{
"files": [
"src/**/*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
]
}
]
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: npm install

- name: Lint
run: npx eslint .
run: npm run lint

format:
runs-on: ubuntu-latest
Expand Down
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# Faker-CLI

A CLI of [@faker-js/faker](https://github.com/faker-js/faker).
A CLI of [@faker-js/faker](https://github.com/faker-js/faker).

> **Note**: This is currently a [MVP](https://en.wikipedia.org/wiki/Minimum_viable_product).

## Install

```bash
npm install --save-dev @faker-js/cli
```

## Usage

```
faker module_name method_name
```

Faker-CLI expects a `module_name` as well as a `method_name` depending on the module chosen.

To list all possible modules run:

```bash
faker --help
```

To list all possible methods of a module run:

```bash
faker module_name --help
```

## Whats next

Upcoming features might include:

- localization
- support for all parameters `@faker-js/faker` natively
- make the CLI consumable for your own modules
3 changes: 3 additions & 0 deletions bin/faker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/src/index.js').cli(process.argv);
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 26 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@
"name": "@faker-js/cli",
"version": "0.0.0",
"description": "A CLI of @faker-js/faker.",
"main": "dist/index.js",
"bin": {
"@faker-js/cli": "bin/faker.js",
"faker": "bin/faker.js"
},
"scripts": {
"build": "tsc",
"format": "prettier src --write",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
"files": [
"dist"
],
"keywords": [
"faker",
"faker.js",
"fakerjs",
"faker-js",
"cli",
"faker-cli",
"faker.js-cli",
"fakerjs-cli",
"faker-js-cli",
"fake data generator",
"fake data",
"fake-data",
Expand All @@ -25,14 +36,25 @@
],
"repository": {
"type": "git",
"url": "https://github.com/faker-js/faker.git"
"url": "https://github.com/faker-js/cli.git"
},
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/fakerjs"
}
],
"bugs": "https://github.com/faker-js/cli/issues",
"license": "MIT",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.6.0",
"@typescript-eslint/parser": "^6.6.0",
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"typescript": "~5.2.2"
},
"dependencies": {
"@faker-js/faker": "^8.0.2",
"commander": "^11.0.0"
}
}
10 changes: 10 additions & 0 deletions src/commands/airline/aircraftType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('aircraftType')
.description(`Generates a random aircraft type.`)
.action(() => {
console.log(faker.airline.aircraftType());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/airline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('airline')
.description(`Generates a random airline.`)
.action(() => {
console.log(faker.airline.airline());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/airplane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('airplane')
.description(`Generates a random airplane.`)
.action(() => {
console.log(faker.airline.airplane());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/airport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('airport')
.description(`Generates a random airport.`)
.action(() => {
console.log(faker.airline.airport());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/flightNumber.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('flightNumber')
.description(`Generates a random flight number.`)
.action(() => {
console.log(faker.airline.flightNumber());
});

export default command;
20 changes: 20 additions & 0 deletions src/commands/airline/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Command } from 'commander';
import airportCommand from './airport';
import airlineCommand from './airline';
import airplaneCommand from './airplane';
import recordLocatorCommand from './recordLocator';
import seatCommand from './seat';
import aircraftTypeCommand from './aircraftType';
import flightNumberCommand from './flightNumber';

const command = new Command('airline')
.description(`Module to generate airline and airport related data.`)
.addCommand(airportCommand)
.addCommand(airlineCommand)
.addCommand(airplaneCommand)
.addCommand(recordLocatorCommand)
.addCommand(seatCommand)
.addCommand(aircraftTypeCommand)
.addCommand(flightNumberCommand);

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/recordLocator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('recordLocator')
.description(`Generates a random record locator.`)
.action(() => {
console.log(faker.airline.recordLocator());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/airline/seat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('seat')
.description(`Generates a random seat.`)
.action(() => {
console.log(faker.airline.seat());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/bear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('bear')
.description(`Generates a random bear species.`)
.action(() => {
console.log(faker.animal.bear());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/bird.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('bird')
.description(`Generates a random bird species.`)
.action(() => {
console.log(faker.animal.bird());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/cat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('cat')
.description(`Generates a random cat breed.`)
.action(() => {
console.log(faker.animal.cat());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/cetacean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('cetacean')
.description(`Generates a random cetacean species.`)
.action(() => {
console.log(faker.animal.cetacean());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/cow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('cow')
.description(`Generates a random cow species.`)
.action(() => {
console.log(faker.animal.cow());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/crocodilia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('crocodilia')
.description(`Generates a random crocodilian species.`)
.action(() => {
console.log(faker.animal.crocodilia());
});

export default command;
10 changes: 10 additions & 0 deletions src/commands/animal/dog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Command } from 'commander';
import { faker } from '@faker-js/faker';

const command = new Command('dog')
.description(`Generates a random dog breed.`)
.action(() => {
console.log(faker.animal.dog());
});

export default command;
Loading