npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

full-node-cli

v1.0.2

Published

全栈一体化工程脚手架

Downloads

8

Readme

full-node-cli

功能介绍

full-node-cli 是前端多框架全栈一体化脚手架,前端支持vue,react 与后端nodejs EggJs/MidwayJs 框架很好的结合,内置常规的前后端插件,方便快速开发。

内置功能点

  • 前端多语言框架支持,vue, react,umi
  • node后端使用的是MidwayJs框架,内置 Mysql,Sequelize模型orm框架 ,umzug数据迁移工具,Typescript ,等工具。

​ MidwayJs 文档: https://www.yuque.com/midwayjs/midway_v2

​ Sequelize 文档:https://www.sequelize.com.cn/

安装教程

# 安装脚手架
npm install full-node-cli -g

创建项目

# 初始化脚手架文件
full create hello-world(项目名称)

选择前端vue 或 react 全栈一体框架

🍡 react,umi,egg/midway

🍭 vue,egg/midway

选择继续按提示完成操作

安装依赖

# 安装前后端依赖
npm run i

启动开发环境

# 启动前端开发环境
npm run c

# 启动后台开发环境
npm run s

开启后端数据库模型

修改配置文件 server/src/config/config.default.ts

注:根据项目需求确定是否用到数据库,不需要设置为 config.useSql = false

  // 开启使用数据库模型 
  config.useSql = true

	// 配置sequelize 的 数据库信息
  config.sequelize = {
    dialect: 'mysql', // 数据库类型
    host: '127.0.0.1', // 数据库服务ip地址
    port: '3306', // 端口
    database: 'database', // 数据库名称
    username: 'root', // 用户名称
    password: '123456', // 密码
    timezone: '+08:00',
    modelFile: isProd ? 'js' : 'ts', // 模型文件后缀名 (建议保持原样)
    logging: false, // 是否开启 log打印
    dialectOptions: {
      dateStrings: true,
      typeCast: (field: any, next: () => void) => {
        if (field.type === 'DATETIME') {
          return field.string()
        }
        return next()
      }
    }
  }

开启数据迁移功能

修改配置文件 server/src/config/config.default.ts

注:根据项目需求确定是否用到数据库迁移,不需要设置为 config.useUmzug = false

 // 启用更新数据库脚本
  config.useUmzug = true

新建更新数据库脚本,存放在 server/src/models/migrations目录

例如:添加update-1.0.1.ts文件 (更新数据库脚本文件,把 text_user 表添加一个 tel_number 字段)

import { QueryInterface, Sequelize } from 'sequelize'
import { DataType } from 'sequelize-typescript'

type Migration = {
  name: string
  path?: string
  context: {
    queryInterface: QueryInterface
    sequelize: Sequelize
  }
}

export const up = async ({ name, path, context: { queryInterface } }: Migration) => {
  try {
    console.log('upgrade db => ', name, path)
    // 更新表脚本
    await queryInterface.addColumn('text_user', 'tel_number', DataType.STRING())

  } catch (error) {
    console.log(error, 'error===')
  }
}

编译打包

# 整站编译打包
npm run build

打完包之后,本地启动后端开发环境

npm run s

直接访问 http://127.0.0.1:7001 就可以访问前端编译后的页面了。(注:在没有执行打包命令,后端开发环境访问页面都是上一次打包的版本)

部署

使用纯 Node.js 或者 pm2 等工具部署,可以参考官方文档:https://www.yuque.com/midwayjs/midway_v2/deployment

ps:开发遇到问题的可以留言 [email protected]