Zalo Mini App CLI

4.0.3 · active · verified Sun Apr 19

The `zmp-cli` is a command-line interface utility designed to streamline the development, testing, and deployment of Zalo Mini Apps. It provides essential commands for developer login, project creation, building, previewing, and deployment, offering an alternative to the Zalo Mini App Extension. Currently at version 4.0.3, the package was last published a month ago as of March 2026, indicating active maintenance. It focuses on integrating into various IDEs and CI/CD pipelines for automation. Key differentiators include its ability to convert existing web applications into Zalo Mini Apps and its support for both QR code and access token-based authentication. Its primary mode of interaction is through shell commands, though it also exposes a programmatic interface for advanced automation in JavaScript/TypeScript environments.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates global CLI installation and common shell commands for login and project initialization, alongside a conceptual programmatic invocation example using the exposed `login` function.

import { login, init } from 'zmp-cli';
import { exec } from 'child_process';

// --- CLI Usage ---
console.log('--- CLI Usage ---');
exec('npm install -g zmp-cli', (err, stdout, stderr) => {
  if (err) {
    console.error(`CLI install error: ${stderr}`);
    return;
  }
  console.log('Zalo Mini App CLI installed globally.');

  exec('zmp --help', (err, stdout, stderr) => {
    if (err) {
      console.error(`zmp --help error: ${stderr}`);
      return;
    }
    console.log('zmp --help output:\n', stdout.substring(0, 200) + '...');

    console.log('\nRun `zmp login` to authenticate or `zmp init` to create a project.');
    console.log('For example: `zmp login` will prompt for QR code or access token.');
    console.log('Or: `zmp init` will guide through project creation.');

    // --- Programmatic Usage (Conceptual) ---
    console.log('\n--- Programmatic Usage (Conceptual) ---');
    async function automateZmp() {
      try {
        console.log('Attempting programmatic login (this will likely open a browser/terminal prompt).');
        // In a real scenario, you might pass an access token directly if the API supports it.
        // For now, this acts as an example of calling the exported function.
        await login();
        console.log('Login initiated programmatically. Please complete in browser/terminal.');

        console.log('Initiating a new Zalo Mini App project programmatically (e.g., in a temp directory).');
        // For actual programmatic init, you'd provide options like project name, template, etc.
        // await init({ name: 'my-automated-app', template: 'blank', appId: process.env.ZMP_APP_ID ?? '' });
        console.log('`init()` function would be called here with specific options.');
      } catch (error) {
        console.error('Programmatic ZMP operation failed:', error);
      }
    }
    // automateZmp(); // Uncomment to run the programmatic example
  });
});

view raw JSON →