GithubHelp home page GithubHelp logo

lumis's Introduction

<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

lumis's People

Contributors

nicholasmordecai avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

Jakub Semik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.