software-template
v1.2.8
Published
Application template for web/mobile/pc/server/plugin.Buildin tamplate such as React/Flutter/Electron/Koa/ChromeExtension and more.
Downloads
79
Readme
Software-Template
简介
是 software-cli 功能扩展包,主要负责项目文件生成,内置项目模板如下(持续更新迭代升级):
- WEB: React/Vue
- Mobile: 微信小程序/Flutter
- PC: Electron
- Server: NodeJS
- Plugins: ChromeExtension/BabelPlugin/ESLintPlugin/VSCodeExtension
单独使用
step1:安装
npm i software-template --save-dev
step2: 引用模块
const { Creator } = require('software-template');
step3: 调用API
Creator.createProject('js', path.join(process.cwd(), 'z-test', 'test-a'));//创建项目
let file = path.join(process.cwd(), "z-test", "test-b", "src", "route", "index.jsx");
Creator.addCode(file, "//@mark_route_import", `const Demo = lazy(() => import("@view/demo/demo"));`);//标记处插入代码
function test(){
console.log("run test()")
}
Creator.addCode(file, 10, test.toString());//第10行插入代码
API 说明
createProject(projStack:String, root:String,projName:String) 创建项目
projStack:项目技术栈,只能传入以下值其中之一,'js', 'ts', 'react', 'vue', 'wxext', 'electron', 'koa', 'chromeext', 'vscodeext' root:即将创建项目目录的父目录,传入绝对路径 projName:项目名称
addCode(filePath: String, mark: String|Number, text: String) 给指定路径的文件插入代码
filePath:文件路径 mark:文件中已存在的自定义标记或行号 text:代码文本
应用包
所有应用包的 UI 框架需要自行添加,不做集成。
app-js
原生 JS 应用项目模板,通常用在使用 ES 编写 JS SDK 的场景中。
app-ts(暂未发布)
TS 应用项目模板,通常用在使用 TypeScript 编写 JS SDK 的场景中。
app-react
React 应用项目基础模板,React18 + redux5。
app-Vue(暂未发布)
Vue 应用项目基础模板,react3 + vuex4。
app-electron
Electron 应用项目模板,默认集成 react 框架。
app-flutter(暂未发布)
Flutter 应用项目模板
app-wxext(暂未发布)
微信小程序应用项目模板,采用小程序容器技术实现。
版本说明
- 1.1.0 删除原有的 MPA 应用模式,推荐使用模块联邦创建子应用;新增 electron 项目支持;
- 1.2.0 修改 API createProject;增加 API addCode;