0.1.2 • Published 3 years ago

cockpit-type v0.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago

cockpit-type

GitHub release Publish

Typings generator for your Cockpit CMS content model.

Usage

cockpit-type uses plopjs therefore all prompts and CLI usage are extended from it.

Add it to your project

yarn add -D cockpit-type or npm install --save-dev cockpit-type

Use it as script (see CLI Options)

cockpit-type <options> or cockpit-type without options, and the interactive CLI will prompt the options.

CLI options

OptionTypeDescription
languagestringProgramming language
pathstringDestination file
prefixstringPrefix for the types
filterstringFilter option ex: 'group=My Groups' allowed filters: 'collection', 'singleton' or 'group'

example: cockpit-type typescript path/to/file.ts MyPrefix 'group=My Group'

TypeScript

Types are generated using type keyword:

export type CPImageBaseType = {
    path: string
}

export type CPGalleryBaseType = CPImageBaseType & {
    meta: {
        title: string
        asset: string
    }
}

Scala

  • Types are generated using case class.
  • Requires JSON library circe as a dependency.
import io.circe.Json
import io.circe.generic.JsonCodec

@JsonCodec
case class CPImageBaseType(path: String)

@JsonCodec
case class CPMetaBaseType(title: String, asset: String)

@JsonCodec
case class CPGalleryBaseType(meta: CPMetaBaseType, path: String)
0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago