Compgen
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.
Install / Use
/learn @developer239/CompgenREADME
NOTE: no longer under development
Composable Generators
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 | |
Full App Generators
These will create whole application setup.
| Type | Package | Version |
| ---------------- | ----------------------------------------------------- | ----------------------------------------------------------- |
| Angular | @compgen/angular | [![@compgen/angular][angular-badge]][angular-npm] |
| Nest.js | @compgen/nest | |
| Create React App | @compgen/cra |
|
| Next.js | @compgen/next |
|
| React Native | @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 | |
| Macro | @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 | |
| Application | @compgen/cra-min |
|
| Application | @compgen/nest-min |
|
| Application | @compgen/next-min |
|
| Application | @compgen/rna-min |
|
| Application | @compgen/ts-node |
|
| Deployment | @compgen/heroku |
|
| Code Quality | @compgen/editor-config |
|
| Code Quality | @compgen/browserlist |
|
| Code Quality | @compgen/eslint |
|
| Code Quality | @compgen/stylelint |
|
| Code Quality | @compgen/prettier |
|
| Code Quality | @compgen/git-hooks |
|
| Component | @compgen/react-component | [![@compgen/react-component][react-component-badge]][react-component-npm] |
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)
