npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xhs-mp-cli

v2.0.11

Published

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

Downloads

984

Readme

小程序命令行工具

小红书小程序官方提供的小程序命令行工具 / 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);