0.1.3 • Published 7 months ago

@winner-fed/deploy-cli v0.1.3

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

deploy-cli

支持组装 see 包和 ftp 上传。

安装

yarn add @winner-fed/deploy-cli --dev

构建 see 包

deploy-cli see

ftp 上传

deploy-cli ftp

配置文件

当以命令行方式运行 deploy-cli 时, 会读取执行目录下的 deploy.config.jspackage.json 中的属性作为配置文件。由于 deploy-cli 本身也附带 TypeScript 类型,也直接支持 TS 配置文件。 deploy-cli 支持以下的文件类型:

  • deploy.config.ts
  • deploy.config.js
  • deploy.config.cjs
  • deploy.config.mjs
  • deploy.config.json
  • package.jsondeploy 属性

在上述的文件中,都可以使用 defaultmodule.exports 进行导出。

deploy.config.js 配置项

export interface UserConfig {
  source: string;
  /**
   * see config
   */
  seeConfig: SeeConfig;
  /**
   *  ftp config
   */
  ftpConfig: FtpConfig;
  /**
   * Use a custom config filename
   */
  config?: string;
}

export interface SeeConfig {
  /**
   * 系统类型, SEE 平台的分组是以系统类型字段纬度来的
   * @default winner-front
   */
  system: string;
  /**
   * 应用类型, 外框架 - bizframe | 子系统 - subsystem
   * @default bizframe
   */
  type: 'bizframe' | 'subsystem';
  /**
   * 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
   * @default package.json -> name
   */
  name: string;
  /**
   * 发布包版本
   * @default package.json -> version
   */
  version: string;
  /**
   * 发布包的描述说明
   * @default package.json -> description
   */
  description: string;
  /**
   * 发布物类型, 默认为 应用名称
   * @default name
   */
  appType?: string;
  /**
   * 应用分组, 默认为 bizframe
   * @default 'bizframe'
   */
  group?: string;
  /**
   * 配置文件名称,不带有 .js。当强制为空时,可以理解成,是构建静态资源的 see 包,不包含 index.html,config.local.js 文件等,此时 scriptsType 只能使用 bash
   * @default config.local
   */
  configName?: string;
  /**
   * 输出的目录名称
   * @default dist
   */
  outputName?: string;
  /**
   * 自定义变量配置文件
   */
  templateFunc?: () => string | undefined;
  /**
   * deploy.xml模板变量, 可以动态配置
   */
  variables?: Array<variables> | undefined;
  /**
   * 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
   */
  copyFiles?: string[];
  /**
   * see发布物的包名,也就是 zip 包的命名
   * @default `${system}-${name}-${version}`
   */
  seePackageName?: string;
  /**
   * see平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
   * @default web
   */
  seePackageType?: 'web' | 'docker';
  /**
   * 是否 docker 包
   */
  isDocker?: boolean;
  /**
   * docker 容器化镜像名,seePackageType 为 docker 时生效
   */
  dockerImage?: string;
  /**
   * 脚本类型
   * @default python
   */
  scriptsType?: 'python' | 'bash';
  /**
   * 构建版本
   */
  buildVersion: string;
  /**
   * 是否为生产包
   */
  isProduction: boolean;
}

export interface FtpConfig {
  /**
   * 目标服务器登录用户
   */
  user: string;
  /**
   * 目标服务器登录密码
   */
  password: string;
  /**
   * 目标服务器主机地址,ftp 常用端口为21,sftp 为 22
   */
  host: string;
  /**
   * 目标服务器端口
   */
  port: number;
  /**
   * 本地路径
   */
  localPath: string;
  /**
   * 目标服务器上传路径
   */
  remotePath: string;
  /**
   * 包含的文件
   */
  include: Array<string>;
  /**
   * 不包含的文件
   **/
  exclude: Array<string>;
  /**
   * 上传之前,删除目标服务器路径的所有文件
   * @default false
   */
  deleteRemote: boolean;
  /**
   * @default true
   */
  forcePasv: boolean;
  /**
   * 使用 sftp 或 ftp
   * @default false
   */
  sftp: boolean;
}

type variablesType =
  | 'input'
  | 'select'
  | 'editor'
  | 'switch'
  | 'smallfile'
  | 'table'
  | 'mselect'
  | 'switchForm'
  | 'complexSelect'
  | 'division';

interface variables {
  type: variablesType;
  label: string;
  name: string;
  options: string;
  required: boolean;
  fold: boolean;
  children: Array<variables>;
  tooltip: string;
  default: string;
}

自定义配置文件路径

可以通过 --config 指定具体路径的配置文件

deploy-cli see/ftp --config build/config.js