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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ldsg/cli

v0.3.18

Published

CLI tool for generating and starting ldsg applications

Readme

@ldsg/cli

命令行工具,用于生成和部署 ldsg 应用。

安装

npm install -g @ldsg/cli

或者在 monorepo 中本地使用:

cd libs/cli
npm link

使用

Generate 命令

根据 LDSG_APP_DATA_URI 环境变量获取应用数据,在指定目录生成 ldsg 应用。如果未指定目录,则在当前目录生成:

ldsg generate /path/to/target

或者使用缩写:

ldsg g /path/to/target

在当前目录生成:

ldsg g

参数

  • <targetDir> - 目标目录路径(可选,默认为当前目录)

选项

  • --confirm - 跳过确认提示,直接生成
  • --build - 生成后构建应用
  • --verbose - 启用详细输出

示例

基本生成
export LDSG_APP_DATA_URI="http://example.com/app-data"
ldsg generate ./my-app
生成并构建
ldsg generate ./my-app --build
启用详细输出
ldsg generate ./my-app --verbose

Deploy 命令

将 ldsg 应用部署到目标目录:

ldsg deploy /path/to/target

命令行参数

ldsg deploy <targetDir> [options]

参数

  • <targetDir> - 目标目录路径(必需)

选项

  • --confirm - 跳过确认提示,直接部署
  • --dry-run - 预览模式,显示将要执行的操作但不实际更改文件
  • --verbose - 启用详细输出

示例

基本部署

ldsg deploy ./dist/my-app

部署到已存在的目录(需要确认)

ldsg deploy ./existing-dir
# 输出:Target directory ./existing-dir already exists.
#       Use --confirm flag to proceed without prompting.

强制覆盖已存在的目录

ldsg deploy ./existing-dir --confirm

预览将要执行的操作

ldsg deploy ./preview-dir --dry-run
# 输出:Dry run mode - no changes will be made
#       Would deploy to: /absolute/path/to/preview-dir

启用详细输出

ldsg deploy ./verbose-dir --verbose
# 输出:Starting deployment...
#       Target directory: /absolute/path/to/verbose-dir
#       Starting build process...
#       Build completed successfully
#       Copying files from /path/to/dist to /absolute/path/to/verbose-dir...
#       Files copied successfully
#       Deployment completed successfully!

工作流程

部署命令执行以下步骤:

  1. 验证目标目录(如果存在且未提供 --confirm,则提示确认)
  2. 执行构建过程(rush build
  3. 复制构建产物到目标目录
  4. 生成部署元数据文件(deployment.json

部署元数据

成功部署后,目标目录将包含 deployment.json 文件:

{
  "timestamp": "2024-03-09T12:00:00.000Z",
  "version": "0.1.0",
  "targetDir": "/absolute/path/to/target"
}

错误处理

CLI 会提供清晰的错误消息:

  • 缺少目标目录:提示必须提供目标目录参数
  • 缺少 LDSG_APP_DATA_URI:提示必须设置环境变量
  • 构建失败:显示构建错误详情并退出
  • 文件操作错误:显示权限或其他文件系统错误
  • 目标目录已存在:提示使用 --confirm 或 --dry-run

退出码

  • 0 - 部署成功
  • 1 - 部署失败(构建错误、文件错误、验证失败等)

开发

构建项目

cd libs/cli
npm run build

运行测试

cd libs/cli
npm test

清理构建产物

cd libs/cli
npm run clean

贡献

欢迎贡献!请确保:

  1. 代码遵循项目风格指南
  2. 添加适当的测试
  3. 更新文档