0.3.3 • Published 5 years ago

@pcg/pcg v0.3.3

Weekly downloads
-
License
see file LICENSE....
Repository
-
Last release
5 years ago

Project Core Generator

Install

PCG should be installed globally on your local machine.

npm install -g @pcg/pcg

Usage

Firstly you should create config file called pcg.config.js in the root directory of new project.

And simply run the generator. It will do all the work

pcg 

If you've changed schema or config you could update project with the same command

pcg

Most of existing files will not be modified. If you want PCG to overwrite the old files, run

pcg --overwrite

Project types

PCG allows to create and support any type of project. Here is list of planned and available projects to create:

  • Loopback API (ready)
  • Javascript Library (in development)
  • Vue Admin (in development)

Loopback API

Node.js API server based on Loopback v3 framework. API endpoints created from OpenAPI v2 schema. So you should create OAS2 schema before generating the code.

Example of pcg.config.js

module.exports = {
    type: 'loopback',
    name: '@dv/ping',
    shortname: 'ping',
    description: 'Ping API',
    author: {
        name: 'Main Author',
        email: 'author1@deepvision.team',
    },
    contributors: [
        {
            name: 'Other Author',
            email: 'author2@deepvision.team',
        },
    ],
    repository: {
        name: 'Ping API',
        host: 'git.deepvision.team',
        path: 'dv/ping/api',
    },
    license: 'file LICENSE.md',
    headers: [
        {
            name: 'author',
            value: '💧DeepVision <support@deepvision.team>',
        },
    ],
    js: {
        nodeVersion: 10,
        babel: {
            plugins: [
                '@babel/plugin-proposal-optional-chaining',
                '@babel/plugin-proposal-class-properties',
                '@babel/plugin-proposal-object-rest-spread',
                '@babel/plugin-proposal-export-default-from',
            ],
        },
    },
    loopback: {
        datasource: {
            type: 'mongo',
            user: 'ping',
            pass: 'ping',
            database: 'ping',
        },
        oas2: '/common/oas2.json',
        middlewares: [
            {
                stage: 'auth',
                path: './middlewares/auth',
                params: {},
            },
            {
                stage: 'parse',
                path: 'body-parser#json',
                params: {},
            },
        ],
    },
};

type – project type, should be "loopback"
name – project name, used in package.json
shortname – short project name, used in source code when needed, should be alphanumeric only
description – project description, used in package.json
author and contributors – used in package.json
repository – used for Gitlab repository synchronization