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

tt-ide-cli

v0.1.27

Published

Command line interface for micro app development

Downloads

471

Readme

tma-cli Weekly downloads Yearly downloads

tma 是抖音小程序官方提供的命令行工具

NPM

安装

建议在全局安装 tma

npm install -g tt-ide-cli

使用

设置小程序 token

设置小程序的 token, 用于替代登录态

命令行使用

Usage: tma set-app-config <appid> --token <token>

Example: tma set-app-config ttxxxxxxx --token 123123123

代码调用

const tma = require('tt-ide-cli');
tma.setAppConfig({
  appId: 'ttxxxxxx',
  config: {
    token: '123123123',
  },
});

设置全局配置

主要用于配置工具的全局代理

命令行使用

Usage: tma set-config [options]

Set tt-ide-cli config

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

代码调用

const tma = require('tt-ide-cli');
await tma.setConfig({
    proxy: 'http://127.0.0.1:8899';
});

创建新项目

在当前目录下,以给定的项目名字创建一个空白的小程序项目

命令行使用

Usage: tma create [options] <project-name>

Create a new project with given name in current folder

Options:
  -f, --force  Overwrite target directory if it exists
  --template <template>    rich | empty (default: empty)
  --type <type>', 'js | ts (default: js)
  --targetDir <targetDir>  Target directory

代码调用

const tma = require('tt-ide-cli');
await tma.create({
  projectName: 'projectName',
  force: false, // 是否覆盖目标文件夹
  template: 'rich', // 'rich' | 'empty'
  // rich 为小程序能力展示 DEMO
  // empty 为小程序空项目
  targetDir: '/path/to/targetDir',
  type: 'js', // 'js' | 'ts'
  // js 为 js 小程序
  // ts 为 ts 小程序
});

打开已有项目

在小程序开发者工具中打开给定目录的项目,如果给定的目录不存在,则仅打开开发者工具

命令行使用

Usage: tma open <project-path> --mode lite

Open target project by path

Options:
  --mode  <mode>         IDE mode(eg. full, lite)

代码调用

const tma = require('tt-ide-cli');
await tma.open({
  project: {
    path: 'projectPath',
    mode: 'lite',
  },
});

登录

登录到开发者平台

命令行使用

Usage: tma login [options]

Login to the developer platform

Options:
  -m, --mobile         Login by mobile
  -e, --email          Login by email
  -p, --proxy <proxy>  Login with proxy
  -h, --help           Output usage information

通过 email 登录

命令行使用

Usage: tma login-e [email] [password]

Login to the developer platform by E-mail

Options:
  -p, --proxy <proxy>  Login with proxy
  -h, --help           Output usage information

代码调用

const tma = require('tt-ide-cli');
await tma.loginByEmail({
  email: 'email',
  password: 'password',
});

通过手机号登录

通过调用tma.sendVerificationCodeToPhone({ phoneNumber: 'phoneNumber' })可以发送验证码

代码调用

const tma = require('tt-ide-cli');
await tma.loginByPhone({
  phoneNumber: 'phoneNumber',
  code: 'code',
});

登出(清除本地 session)

命令行使用

Usage: tma logout

Logout and clear the session.

代码使用

const tma = require('tt-ide-cli');
await tma.logout();

本地项目体积

查看本地项目的文件体积

命令行使用

Usage: tma project-size [--json] entry

Output current project package size information.

Options:
  --json Output as JSON string

代码调用

const tma = require('tt-ide-cli');
const result = await tma.getProjectSize(projectPath);

预览小程序

将项目上传后,扫码二维码来预览小程序(如果要设置 miniapp-query, miniapp-scene 等启动参数需要同时设置 miniapp-path 参数,否则将不会生效)。

命令行使用

Usage: tma preview [options] [entry]

Preview project by remote

Options:
  --disable-cache                     Preview project without local cache
  -s, --small                         Use small QR Code, it may fail in some environments
  -c, --copy                          Copy remote url to clipboard
  -p, --proxy <proxy>                 Preview with proxy
  --miniapp-path <path>               Miniapp path
  --miniapp-query <query>             Miniapp query
  --miniapp-scene <scene>             Miniapp scene
  --miniapp-launch-from <launchFrom>  Miniapp launchFrom
  --miniapp-location <location>       Miniapp location
  --qrcode-output <qrcodeOutputPath>  Qrcode output path

代码调用

const tma = require('tt-ide-cli');
// previewResult 返回值
interface ProjectQRCode {
  expireTime: number; // 二维码过期时间
  shortUrl: string; // 二维码短链
  originSchema: string; // 二维码 schema
  qrcodeSVG?: string; // 二维码 SVG
  qrcodeFilePath?: string; // 二维码存储路径
  useCache: boolean; // 是否命中并使用缓存
}
const previewResult: ProjectQRCode = await tma.preview({
  project: {
    path: 'projectPath', // 项目地址
  },
  page: {
    path: '', // 小程序打开页面
    query: '', // 小程序打开 query
    scene: '', // 小程序打开场景值
    launchFrom: '', // 小程序打开场景(未知可填空字符串)
    location: '', // 小程序打开位置(未知可填空字符串)
  },
  qrcode: {
    format: 'imageSVG', // imageSVG | imageFile | null | terminal
    // imageSVG 用于产出二维码 SVG
    // imageFile 用于将二维码存储到某个路径
    // terminal 用于将二维码在控制台输出
    // null 则不产出二维码
    output: '', // 只在 imageFile 生效,填写图片输出绝对路径
    options: {
      small: false, // 使用小二维码,主要用于 terminal
    },
  },
  cache: true, // 是否使用缓存
  copyToClipboard: true, // 是否将产出的二维码链接复制到剪切板
});

上传项目

把项目上传到开发者平台进行发布

命令行使用

  • app-changelog 为必填参数,其余为可选参数,其中 app-version 的默认值为前序版本号末位加一。
Usage: tma upload [options] [entry]

Upload project to the developer platform

Options:
  -v, --app-version <appVersion>          App version (eg: [major].[minor].[patch])
  -c, --app-changelog <appChangelog>      Changelog for this version
  -p, --proxy <proxy>                     Update request proxy
  -cp, --copy                             Copy remote url to clipboard
  --qrcode-output <qrcodeOutputPath>      Qrcode output path
  --channel <channel>                     Test Channel

代码调用

const tma = require('tt-ide-cli');
// uploadResult 返回值
interface ProjectQRCode {
  expireTime: number; // 二维码过期时间
  shortUrl: string; // 二维码短链
  originSchema: string; // 二维码 schema
  qrcodeSVG?: string; // 二维码 SVG
  qrcodeFilePath?: string; // 二维码存储路径
  useCache: boolean; // 是否命中并使用缓存
}
const uploadResult: ProjectQRCode = await tma.upload({
  project: {
    path: 'projectPath', // 项目地址
  },
  qrcode: {
    format: 'imageSVG', // imageSVG | imageFile | null | terminal
    // imageSVG 用于产出二维码 SVG
    // imageFile 用于将二维码存储到某个路径
    // terminal 用于将二维码在控制台输出
    // null 则不产出二维码
    output: '', // 只在 imageFile 生效,填写图片输出绝对路径
    options: {
      small: false, // 使用小二维码,主要用于 terminal
    },
  },
  copyToClipboard: true, // 是否将产出的二维码链接复制到剪切板
  changeLog: 'changelog', // 本次更新日志
  version: '1.0.0', // 本次更新版本,可选参数,默认值为前序版本号末位加一
  needUploadSourcemap: true, // 是否上传后生成 sourcemap,推荐使用 true,否则开发者后台解析错误时将不能展示原始代码
  channel: '1', // 可选项,测试通道,不传该参数时为默认通道
});

小程序 host

查询小程序支持的 host 。

命令行使用

Usage: tma hosts [appid]

Get Audit Host List
tma hosts tt07e3715e98c9xxxx

代码调用

const tma = require('tt-ide-cli');
await tma.getAuditHostsList({ appid: '' });

小程序提审

小程序提审

  • 小程序首次提审,需要通过 defaultSsUrl 属性给定一个截图路径;

    推荐首次提审时,到开发者平台上传合规截图;

  • 后续提审会复用前一次提审的截图;
  • 现在支持的 host 参数已有
    • douyin
    • toutiao
    • douyin_lite
    • tt_lite
    • 更多 host 可以通过 tma hosts [appid] 的命令查询

命令行使用

Usage: tma audit [options] [appid]

Audit project in the developer platform

Options:
  --host <hosts>            Host Apps(eg: douyin,toutiao,tt_lite)
  --auto-publish <boolean>  Auto Publish After Audit
  --channel <channel>       Test channel
# 使用示范
tma audit --host douyin,toutiao,tt_lite tt07e3715e98c9xxxx

代码调用

const tma = require('tt-ide-cli');
// 提审
await tma.audit({
  appid: '',
  host: [], // douyin,toutiao,tt_lite
  autoPublish: true, // 是否审核通过后自动发布
  defaultSsUrl: '/tmp/picture/default.png',
});

获取小程序信息

命令行使用

Usage: tma get-meta [options] [appid]

Get appid meta

代码调用

const tma = require('tt-ide-cli');
// metaResult 返回值
interface MiniappMetaInfo {
  version: String; // 线上小程序版本号
}
const metaResult: MiniappMetaInfo = await tma.getMeta({
  appid: 'appid',
});

构建 NPM

对应开发者工具 构建 NPM 功能

命令行使用

Usage: tma build-npm [options]

Build npm

Options:
  --project-path  Project path

代码调用

const tma = require('tt-ide-cli');
await tma.buildNpm({
  project: {
    path: 'projectPath',
  },
});