Code Monkey home page Code Monkey logo

compgen's Introduction

Composable Generators

release

Replace your big boilerplate repositories with small composable generators.

@compgen is an alternative to Yeoman and other libraries that help you to kickstart new projects, prescribe best practices and configure tools to help you stay productive.

This library is unique though because @compgen generators are small and composable. You can use generators separately to create small chunks of code, or you can compose them together so that you can create bigger and more opinionated codebase.

Core Packages

Use these to build your own generators.

Type Package Version
Library Core @compgen/core @compgen/core

Full App Generators

These will create whole application setup.

Type Package Version
Angular @compgen/angular @compgen/angular
Nest.js @compgen/nest @compgen/nest-min-full
Create React App @compgen/cra @compgen/cra-full
Next.js @compgen/next @compgen/next-min-full
React Native @compgen/rna @compgen/rna

Macro Generators

Multiple micro generators composed into robust generators. These generators are useful for opinionated codebase setup.

Type Package Version
Macro @compgen/code-quality @compgen/code-quality
Macro @compgen/eslint-auto @compgen/eslint-auto

Micro Generators

You can easily selectively add code quality tools and other useful libraries to your existing codebase.

Type Package Version
Application @compgen/angular-min @compgen/cra-min
Application @compgen/cra-min @compgen/cra-min
Application @compgen/nest-min @compgen/nest-min
Application @compgen/next-min @compgen/next-min
Application @compgen/rna-min @compgen/rna-min
Application @compgen/ts-node @compgen/ts-node
Deployment @compgen/heroku @compgen/heroku
Code Quality @compgen/editor-config @compgen/editor-config
Code Quality @compgen/browserlist @compgen/browserlist
Code Quality @compgen/eslint @compgen/eslint
Code Quality @compgen/stylelint @compgen/stylelint
Code Quality @compgen/prettier @compgen/prettier
Code Quality @compgen/git-hooks @compgen/git-hooks
Component @compgen/react-component @compgen/react-component

Programmable Examples

Minimal micro generator

This is how many lines of code you have to write to add prettier to all your projects in the future:

// src/templates/.prettierrc.js

module.exports = require('@linters/prettier-config')
// src/index.ts

import path from 'path'
import { builder, execute } from '@compgen/core'

export const createPrettierSchema = () => {
  const schema = builder('prettier')

  schema.addFolder({
    name: 'prettier',
    source: path.join(__dirname, 'templates'),
  })

  schema.addScript('format', "prettier --write '*/**/*.{ts,tsx,css,md,json}'")
  schema.addDevDependencies(['prettier', '@linters/prettier-config'])

  return schema.toJson()
}

const projectFolder = '.'
execute(createPrettierSchema(), projectFolder)

Composing multiple micro generators

We can easily use existing micro generators and bundle them together into bigger generator.

Micro generators

Generator implementation

import { AppType, builder } from '@compgen/core'
import { createEditorConfigSchema } from '@compgen/editor-config'
import { createEslintSchema } from '@compgen/eslint'
import { createPrettierConfig } from '@compgen/prettier'
import { createStylelintWebConfig } from '@compgen/stylelint'

export const createWebCodeQualitySchema = () => {
  const schema = builder('codequality')
  const hasPrettier = true

  schema.combineSchema(createEditorConfigSchema())
  schema.combineSchema(createEslintSchema({ appType: AppType.WEB }))
  schema.combineSchema(createPrettierConfig({ appType: AppType.WEB }))
  schema.combineSchema(createStylelintWebConfig({ hasPrettier }))

  return schema.toJson()
}

const projectFolder = '.'
execute(createWebCodeQualitySchema(), projectFolder)

compgen's People

Contributors

developer239 avatar semantic-release-bot 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.