1.2.14 • Published 10 months ago

software-template v1.2.14

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

Software-Template

简介

是 software-cli 功能扩展包,主要负责项目文件生成,内置项目模板如下(持续更新迭代升级):

  1. WEB: React
  2. Mobile: 微信小程序
  3. PC: Electron
  4. Server: NodeJS
  5. Plugins: ChromeExtension/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 说明

  1. createProject(projStack:String, root:String,projName:String) 创建项目

    projStack:项目技术栈,只能传入以下值其中之一,'js', 'ts', 'react', 'vue', 'wxext', 'electron', 'koa', 'chromeext', 'vscodeext'
    root:即将创建项目目录的父目录,传入绝对路径
    projName:项目名称
  2. addCode(filePath: String, mark: String|Number, text: String) 给指定路径的文件插入代码

    filePath:文件路径
    mark:文件中已存在的自定义标记或行号
    text:代码文本

应用包

所有应用包的 UI 框架需要自行添加,不做集成。

app-js

JS/TS 应用项目模板,默认.js 文件格式,文件后缀为.ts 时, dev-server 自动编译 TS,无需任何配置。

app-react

React 应用项目基础模板,React18 + redux5,默认.js + .jsx 文件格式,当文件格式为.ts + .tsx 时, dev-server 自动编译 TS,无需任何配置。

app-electron

Electron 应用项目模板,默认集成 react 框架。

app-wxext(暂未发布)

微信小程序应用项目模板,采用小程序容器技术实现。

版本说明

  1. 1.1.0 删除原有的 MPA 应用模式,推荐使用模块联邦创建子应用;新增 electron 项目支持;
  2. 1.2.0 修改 API createProject;增加 API addCode;
  3. 1.2.11 修改模板对 TypeScript 的支持;
1.2.9

10 months ago

1.2.10

10 months ago

1.2.11

10 months ago

1.2.14

10 months ago

1.2.8

12 months ago

1.1.8

12 months ago

1.1.6

1 year ago

1.1.5

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.31

1 year ago

1.0.28

1 year ago

1.0.0

1 year ago