1.0.73 • Published 3 years ago

erisl-crm-cli v1.0.73

Weekly downloads
152
License
ISC
Repository
github
Last release
3 years ago

ERISL CRM CLI

命令

  • erisl-crm-cli init 初始化项目
  • erisl-crm-cli create 创建模板页面
  • erisl-crm-cli delete 删除模板页面
  • erisl-crm-cli dev 开发模式
  • erisl-crm-cli start 生产模式
  • erisl-crm-cli build 编译
  • erisl-crm-cli export 导出静态页面

参数

  • dictionary: 在 export/init 的时候使用, 默认 out, 譬如: erisl-crm-cli init|export dictionary=webapp 或者 erisl-crm-cli init|export webapp
  • controller: 在 create/delete 的时候使用, 必须有。譬如: erisl-crm-cli create|delete math
  • action: 在 create/delete 的时候使用, 默认 manage, 跟在 controller 后面, 譬如 erisl-crm-cli create|delete math test

根目录新增 next.config.js

const { nextConfig } = require('erisl-crm-cli')
const projectConfig = require('./project.config')

const { version, prefix, protocol, host, port } = projectConfig 

module.exports = (phase, defaultConfig) => {
    let configObj = nextConfig(phase, defaultConfig, { 
        version, prefix, protocol, host, port
    })

    return configObj
}

根目录新增 mysql.config.js

const { mysqlConfig } = require('erisl-crm-cli')
const { mysqlOptions } = mysqlConfig
const { user, password, host, port, database } = mysqlOptions

module.exports = {
    mysqlOptions: {
        user,
        password,
        host,
        port,
        database
    }
}

根目录新增 project.config.js

const { projectConfig } = require('erisl-crm-cli')

const { version, prefix, protocol, host, port } = projectConfig

module.exports = {
    version,
    prefix,
    protocol,
    host, 
    port
}

根目录新增 server

  • apis 存放 Rest Api
  • modules 存放 graphql 的 resolver 和 schema
  • plugins 存放 graphql 的 plugin
  • .js 举例: test.js => 用于响应 /test/, ${prefix}/test/* 请求
  const express = require('express')
  const moment = require('moment')

  const router = express.Router()

  router.use((req, res, next) => {
      const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
      console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
      next()
  })

  router.get('/*', (req, res) => {
      res.statusCode = 200
      res.json({ name: 'TEST' })
  })

  module.exports = router
  • apis/hello.js
const express = require('express')
const router = express.Router()

router.get('/*', (req, res) => {
    res.statusCode = 200
    res.json({ name: 'Hello' })
})

module.exports = router
  • modules/link/schema.js
module.exports = {
    query: `
        link: String
    `,
    mutation: `
        linkUpdate(link: Date): String
    `,
    subscription: ``,
    type: ``
} 
  • modules/link/resolver.js
let localLink = ''

module.exports = {
    link: () => {
        return localLink
    },
    linkUpdate: ({ link }) =>{
        console.log('link', link)
        localLink = link
        return localLink
    }
}
  • plugins/date.js
const moment = require('moment')
const { Kind } = require('graphql/language')
const { GraphQLScalarType } = require('graphql')

const customScalarDate = new GraphQLScalarType({
    name: 'Date',
    description: 'Date custom scalar type',
    parseValue: value => moment(value).valueOf(),
    serialize: value => moment(value).format('YYYY-MM-DD HH:mm:ss:SSS'),
    parseLiteral: ast => (ast.kind === Kind.INT)
        ? parseInt(ast.value, 10)
        : null
})

module.exports = { Date: customScalarDate }
1.0.73

3 years ago

1.0.72

3 years ago

1.0.71

3 years ago

1.0.70

3 years ago

1.0.69

3 years ago

1.0.68

3 years ago

1.0.67

3 years ago

1.0.66

3 years ago

1.0.65

3 years ago

1.0.64

3 years ago

1.0.62

3 years ago

1.0.61

3 years ago

1.0.60

3 years ago

1.0.63

3 years ago

1.0.59

3 years ago

1.0.58

3 years ago

1.0.57

3 years ago

1.0.56

3 years ago

1.0.55

3 years ago

1.0.54

3 years ago

1.0.53

3 years ago

1.0.52

3 years ago

1.0.51

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.49

3 years ago

1.0.50

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.40

3 years ago

1.0.41

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.22

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago