2.0.6 • Published 9 months ago

xhs-mp-cli v2.0.6

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

小程序命令行工具

小红书小程序官方提供的小程序命令行工具 / CI 工具,可以通过该工具箱进行登录、预览、上传等操作,支持命令行方式以及 NPM 直接调用方式。

安装

# 全局安装
npm install -g xhs-mp-cli

# 局部安装
npm install xhs-mp-cli

# 使用
xmc --help

使用

命令行通用参数

Usage: xmc --help

# --project 项目路径
# --verbose 显示详细日志

设置全局配置

主要用于配置全局代理等

命令行使用

Usage: xmc set-config [options]

Set xmc config

Options:
--proxy <proxy> Set global proxy(配置全局代理)
--default       Use default(恢复为默认配置)

代码调用

const xmc = require('xhs-mp-cli');
// 设置代理配置
await xmc.setConfig({
    proxy: 'http://127.0.0.1:8888' // 此地址仅为示例,具体地址需根据实际代理服务器确定。
});

// 清空配置/恢复默认配置
await xmc.setConfig({});

设置应用配置

主要用于设置小程序/小游戏的配置等,如配置免密登陆秘钥(代码上传秘钥)

命令行使用

Usage: xmc set-app-config [options]

Set xmc app config

Options:
--appid         小程序配置
--token         代码上传秘钥
--default       Use default(恢复为默认配置)

代码调用

const xmc = require('xhs-mp-cli');
// 设置代码上传秘钥
await xmc.setAppConfig({
    appId: 'xxxxxx',
    config: {
        token: 'xxxxx'
    }
});
// 清空配置/恢复默认配置
await xmc.setAppConfig({});

登陆

如果不使用代码上传秘钥进行免密登陆,可以采用扫码登录的方式。 登陆并保持会话。目前仅支持二维码扫码登陆

命令行使用

Usage: xmc login

Login to the developer platform

Options:
--type <type> Login Type (登陆方式),默认只支持 qrcode

代码调用

const xmc = require('xhs-mp-cli');
// 设置代理配置
await xmc.login({
    type: 'qrcode'
});

登出(清除本地 session)

退出登陆

命令行使用

Usage: xmc logout

Logout and clear the session.

代码调用

const xmc = require('xhs-mp-cli');
await xmc.logout();

预览

小程序/小游戏预览,可以真机扫码体验。

命令行使用

Usage: xmc preview [options]

Preivew the miniprogram/minigame

Options:
--path <path> The entry page path, 入口页面路径
--query <query> 页面参数,如a=x&b=xx
--launchMode <launchMode> 启动方式,default或halfPageNativeFunctionalized

# 示例
xmc preview --project xxx --path entry/api/api --query x=xxx&y=xxx --launchMode default
xmc preview --project xxx --path entry/api/api --query x=xxx&y=xxx --launchMode halfPageNativeFunctionalized

代码调用

const xmc = require('xhs-mp-cli');
interface IPreviewOptions {
   project: {
    projectPath: string
  }
  entry?: {
    path: string
    query?: string
    launchMode?: string
  }
}
interface IPreviewRes {
    qrcodeUrl: string
}

const res:IPreviewRes = await xmc.preview({
    project: {
        projectPath: 'xxx',
    },
    entry: {
        path: ""
        query: ""
        launchMode: ""
    }
} as IPreviewOptions);

上传

把项目上传到专业号平台/服务商平台进行发布。

命令行使用

Usage: xmc upload [Options]

Upload project to the developer platform

Options:
--version <version> Version(版本),如1.0.0
--desc <desc> 版本描述

代码调用

const xmc = require('xhs-mp-cli');

interface IUploadOptions {
   project: {
    projectPath: string
  }
  version: string
  desc: string
}
// 设置代理配置
await xmc.upload({
    project: {
        projectPath: 'xxx',
    },
    version: "1.0.1",
    desc: "test"
} as IUploadOptions);
2.0.5

9 months ago

2.0.4

9 months ago

2.0.6

9 months ago

2.0.4-beta.3

9 months ago

2.0.4-beta.4

9 months ago

2.0.4-beta.1

9 months ago

2.0.4-beta.2

9 months ago

2.0.4-beta.0

9 months ago

2.0.3

10 months ago

2.0.2

10 months ago

1.9.7-beta.0

11 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.9.11

11 months ago

1.9.10

11 months ago

1.9.9

11 months ago

1.9.8

11 months ago

1.9.7

11 months ago

1.9.6

11 months ago

1.11.0

10 months ago

1.9.6-beta.0

11 months ago

1.9.8-beta.0

11 months ago

1.2.0

1 year ago

1.8.0

12 months ago

1.6.0

1 year ago

1.4.0

1 year ago

1.5.1-beta.0

1 year ago

1.2.0-beta.1

1 year ago

1.2.0-beta.0

1 year ago

1.8.0-beta.0

12 months ago

1.3.10-beta.0

1 year ago

1.2.0-beta.2

1 year ago

1.4.0-beta.7

1 year ago

1.4.0-beta.6

1 year ago

1.9.5

11 months ago

1.4.0-beta.5

1 year ago

1.9.4

11 months ago

1.4.0-beta.4

1 year ago

1.9.3

11 months ago

1.3.9

1 year ago

1.9.2

12 months ago

1.3.8

1 year ago

1.4.0-beta.2

1 year ago

1.1.6-beta.0

1 year ago

1.4.0-beta.1

1 year ago

1.4.0-beta.0

1 year ago

1.4.1-beta.1

1 year ago

1.9.1

12 months ago

1.9.0

12 months ago

1.7.1

1 year ago

1.3.5

1 year ago

1.7.0

1 year ago

1.3.4

1 year ago

1.1.6

1 year ago

1.3.3

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.5.0-beta.0

1 year ago

1.5.0-beta.1

1 year ago

1.5.0-beta.8

1 year ago

1.5.0-beta.7

1 year ago

1.5.0-beta.3

1 year ago

2.0.0-beta.4

1 year ago

1.5.0-beta.6

1 year ago

2.0.0-beta.3

1 year ago

1.6.0-beta.8

1 year ago

1.6.0-beta.4

1 year ago

1.6.0-beta.5

1 year ago

1.6.0-beta.6

1 year ago

1.6.0-beta.7

1 year ago

1.6.0-beta.1

1 year ago

1.6.0-beta.2

1 year ago

1.6.0-beta.3

1 year ago

1.9.1-beta.0

12 months ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.0-beta.0

1 year ago

1.0.2

1 year ago

1.0.2-beta.0

1 year ago

1.0.1

1 year ago

1.0.1-beta.2

1 year ago

1.0.1-beta.1

1 year ago

1.0.1-beta.0

1 year ago

1.0.1-beta.3

1 year ago

1.0.0

1 year ago