npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

data-mocker-cli

v1.1.0

Published

Cli to generate a test data set, with it you can generate any flat data structure, being able to specify the type of each field or attribute.

Downloads

2

Readme

data-mocker-cli

CI Version Downloads/week License codecov

Summary

Cli to generate a test data set, with it you can generate any flat data structure, being able to specify the type of each field or attribute.

With it you can generate thousands of test data

Usage

$ npm install -g data-mocker-cli
$ dmcli COMMAND
running command...
$ dmcli (-v|--version|version)
data-mocker-cli/1.1.0 linux-x64 node-v12.18.1
$ dmcli --help [COMMAND]
USAGE
  $ dmcli COMMAND
...

Commands

dmcli generate NUMBER

Generate a file with mock data in json, csv or sql insert format

USAGE
  $ dmcli generate NUMBER

ARGUMENTS
  NUMBER  Number of mock data

OPTIONS
  -h, --help                 show CLI help
  -o, --output=sql|json|csv  [default: json] Output file format
  -s, --schema=schema        (required) Schema of the data to be generated

See code: src/commands/generate.ts

dmcli help [COMMAND]

display help for dmcli

USAGE
  $ dmcli help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

Schema file

The schema file is a json that contains a list of the fields that each data must have.

If you want to export in sql format, you can report the name of the table within the schema.json

{
  "tableName": "people",
  "nameFormatter": "LowerSnakeCase",
  "fields": [
    {
      "type": "Number",
      "name": "Id",
      "isNullable": false,
      "min": 1
    },
    {
      "type": "Name",
      "name": "First Name"
    },
    {
      "type": "Surname",
      "name": "last name 2",
      "isNullable": true
    },
    {
      "type": "Enum",
      "name": "Gender",
      "isNullable": true,
      "source": ["Female", "Male", "Non-binary"]
    },
    {
      "type": "Phone",
      "name": "Mobile",
      "prefix": "+34",
      "pattern": "6dd dd dd dd"
    },
    {
      "type": "Email",
      "name": "Email",
      "userNames": ["gunmer", "ironMan", "spiderman"],
      "domains": ["private.es"]
    },
    {
      "type": "String",
      "name": "Description",
      "min": 25,
      "max": 100
    }
  ]
}

NameFormatters

With this property you set the style of the name of the columns or attributes. If not reported by default it is LowerCamelCase

| NameFormatters | Formats | |----------------|----------------------------------------| | UpperCamelCase | 'lorem ipsum' formats as 'LoremIpsum' | | LowerCamelCase | 'lorem ipsum' formats as 'loremIpsum' | | UpperSnakeCase | 'lorem ipsum' formats as 'Lorem_Ipsum' | | LowerSnakeCase | 'lorem ipsum' formats as 'lorem_ipsum' | | UpperKebabCase | 'lorem ipsum' formats as 'Lorem-Ipsum' | | LowerKebabCase | 'lorem ipsum' formats as 'lorem-ipsum' | | WithoutFormat | 'lorem ipsum' formats as 'lorem ipsum' |

Common attributes

All fields contain the following attributes:

| Attribute | Description | Required | Default | |------------|----------------------------------------------------------------------------|----------|---------| | type | Indicates the type of the field, if it is a name, surname, number, etc... | Yes | | | name | Name of the field with which the data will be created | Yes | | | isNullable | If true 25% of data contains an undefined value in the field | No | false |

Field types

String

Generates a text string (lorem ipsum) up to the maximum number of characters indicated

| Attribute | Description | Required | |-----------|-------------------------------------------|----------| | max | Indicates the maximum value of the string | Yes | | min | Indicates the minimum length range value | No |

Number

Generate integers

| Attribute | Description | Required | Default | |-----------|---------------|----------|-------------------| | min | Minimum value | False | −9007199254740991 | | max | Maximum value | False | 9007199254740991 |

Enum

Randomly choose a value from the reported source

| Attribute | Description | Required | |-----------|----------------------------|----------| | source | Array of options to choose | Yes |

Name

Generate a random name

| Attribute | Description | Required | |-----------|-------------------------------|----------| | source | Array of names to choose from | False |

Surname

Generate a random surname

| Attribute | Description | Required | |-----------|----------------------------------|----------| | source | Array of surnames to choose from | False |

Email

Generate a random email with default or specific username and domain

| Attribute | Description | Required | |-----------|-----------------------------------|----------| | userNames | Array of usernames to choose from | False | | domains | Array of domains to choose from | False |

Phone

Generate a random phone number with a pattern and prefix if needed

| Attribute | Description | Required | Default | |-----------|-----------------------------------------|----------|-----------| | prefix | Set the prefix number | False | Empty | | pattern | Set the patter with 'd' of phone number | False | ddddddddd |