Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
/ compgen Public archive

Collection of composable generators as 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.

License

Notifications You must be signed in to change notification settings

developer239/compgen

Repository files navigation

NOTE: no longer under development

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)

About

Collection of composable generators as 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.

Resources

License

Stars

Watchers

Forks

Packages