lumis
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

<typescript> <megmut> code style: prettier npm Coverage Status

Lumis

Automatically create factory and fake data from typescript interfaces

Please note, this is still very early development and has not been tested in a production envirnoment!

Prerequisites

This project requires NodeJS (version 8 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
6.4.1
v8.16.0

Table of contents

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installation

BEFORE YOU INSTALL: please read the prerequisites

To install the library, run:

$ npm install --save-dev lumis

Or if you prefer using Yarn:

$ yarn add --dev lumis

Usage

To run Lumis on your project, add the command to your package.json scripts:

"script": {
      "...": "...",
      "lumis": "lumis -f ./src/**/*{.d.ts,.ts}"
}

and execute the above script like so:

$ npm run lumis
# or
$ yarn lumis

or if you have it installed globally:

$ lumis --files=./**/*.ts

Examples

Create the following file, saving the example below inside.

  export interface Example {
    str: string;
    num: number;
    literal: {
        key1: string;
        key2: string;
    };
    arraySimple: string[];
    arrayComplex: Array<{key1: string, key2: number}>;

    tupSimple: [string, string, number];
    tupComplex: [number, string, {key1: string}];
    address: Address;
  }

  interface Address {
      streetName: string;
      houseNumber: number;
  }

Now run your npm command:

$ npm run lumis
# or
$ yarn lumis

Now in any other Typescript file in your project, you can get the factory.

import { Example, Address } from 'lumis';

const newExample = Example.create({...});

// note, this is currently being implemented
const fakedExample = Example.fake();

Running the tests

$ npm test

Known Bugs

  • Nullkeyword isn't being recognised in the looper

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

  1. Fork it!
  2. Create your feature branch: git checkout -b feat/my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request 😎

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Nicholas Mordecai

See also the list of contributors who participated in this project.

License

Apache 2.0 License © Nicholas Mordecai

Notes To Self
  • If a nested structure is optional, a config should be set to allow that nested property to be or not to be generated

Package Sidebar

Install

npm i lumis

Weekly Downloads

2

Version

0.1.1

License

Apache-2.0

Unpacked Size

377 kB

Total Files

57

Last publish

Collaborators

  • megmut