@winner-fed/winner-deploy
Version:
Generate a publication deployed by the See platform
155 lines (152 loc) • 6.15 kB
TypeScript
declare 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;
}
interface deployOptions {
/**
* 系统类型, 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;
/**
* 发布物名称, 默认为 应用名称
* @default name
*/
appName?: 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模板变量, 可以动态配置
*/
variablesFunc?: () => Array<variables> | undefined;
/**
* 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
*/
copyFiles?: string[];
/**
* see发布物的包名,也就是 zip 包的命名
* @default `${system}-${name}-${version}`
*/
seePackageName?: string;
/**
* see发布物的存放路径,默认项目根目录下的 package
* @default `package`
*/
seePackagePath?: string;
/**
* see平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
* @default web
*/
seePackageType?: 'web' | 'docker';
/**
* docker 容器化镜像名,seePackageType 为 docker 时生效
*/
dockerImage?: string;
/**
* 脚本类型
* @default python
*/
scriptsType?: 'python' | 'bash';
/**
* 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
* @default null
*/
tplPath?: Record<string, string>;
}
/**
* 生成 see 平台部署包
* @param system {string} 系统类型, SEE 平台的分组是以系统类型字段纬度来的, 默认为 winner-front
* @param type {string} 应用类型, 外框架 - bizframe | 子系统 - subsystem, 默认为 主系统 - bizframe
* @param name {string} 发布物名称。当包含 scope 时,如字符 @、/ 。会做自动的转换。如@winner-fed/winner-deploy 转换为 winner-fed-winner-deploy
* @param appType {string} 发布物类型, 默认为 应用名称 - name
* @param appName {string} 发布物名称, 默认为 应用名称 - name
* @param group {string} 应用分组, 默认为 bizframe
* @param version {string} 发布包版本
* @param configName {string} 配置文件名称,不带有 .js, 默认为 config.local
* @param outputName {string} 输出的目录名称,默认为 dist
* @param templateFunc {function} 自定义变量配置文件, 默认为
* function () {
if (type === 'bizframe') {
return `./dist/config.local.js`;
}
}
* @param variablesFunc {function} deploy.xml模板变量, 可以动态配置, 默认为
* function () {
* const context = process.cwd()
if (type === 'bizframe') {
try {
const {variables} = require(path.resolve(
context,
'build',
'package',
`./variables.js`
));
return variables || [];
} catch (error) {
console.error(error);
return [];
}
}
}
* @param copyFiles {Array<string>} 不包含在 manifest.json 配置的文件,直接拷贝到 see 包里。文件路径是相对于项目根目录的路径+文件名,比如 dist/子包/version.js,那么 copyFiles: ['version.js']
* @param description {string} 发布包说明
* @param seePackageName {string} see发布物的包名,也就是 zip 包的命名,默认为 `${system}-${name}-${version}`
* @param seePackagePath {string} see发布物的存放路径,默认项目根目录下的 package,如果想在根目录下生成see发布物,值可设置为 '/'
* @param seePackageType see 平台发布物包的类型,'web'(默认的) | 'docker'(支持容器化部署的SEE发布物)
* @param dockerImage docker 容器化镜像名,seePackageType 为 docker 生效
* @param scriptsType 脚本类型 'python' | 'bash'
* @param tplPath 模板文件路径,支持传入多个模板文件路径,key 为模板文件名称,会放到see包的 template 目录下,value 为模板文件的绝对路径,可以使用 ejs 语法
* @param cb {function} 回调函数,用于处理在组装 see 包后,可以自定义执行的动作
*/
declare const generateSeePackageZip: ({ system, type, name, appType, appName, group, version, configName, outputName, templateFunc, variablesFunc, copyFiles, description, seePackageName, seePackagePath, seePackageType, dockerImage, scriptsType, tplPath }: deployOptions, cb: () => void) => void;
export { deployOptions, generateSeePackageZip, variables, variablesType };