npm.io
2.3.0 • Published 2d agoCLI

@loint2101/s3-cli

Licence
MIT
Version
2.3.0
Deps
6
Size
81 kB
Vulns
0
Weekly
0

@loint2101/s3-cli

CLI tool giúp build và publish các project .NET (ASP.NET, WebForms, MVC) bằng MSBuild — thay thế các file .bat thủ công.

Tính năng

  • Multi-profile — quản lý nhiều project (WebPOS, WebAdmin, API...) qua file JSON
  • Build hàng loạts3 build webpos webadmin hoặc s3 build all
  • Interactive inits3 init quét .csproj + .pubxml, wizard tạo profile nhanh
  • Precompile — hỗ trợ PrecompileBeforePublish / EnableUpdateable
  • Auto-zip — tự động nén output thành file .zip có gắn ngày
  • Dọn dẹp thông minh — xóa file/folder không cần thiết trước khi zip (config, images, resources...)
  • Chạy song song — build tối đa 3 profile cùng lúc

Cài đặt

npm install -g @loint2101/s3-cli

Yêu cầu: Node.js >= 16 và MSBuild (Visual Studio hoặc Build Tools).

Sử dụng

Khởi tạo profile
# Interactive wizard — quét .csproj, hỏi từng bước
s3 init

# Auto-scan — tự động gen profile, không hỏi
s3 init --scan

# Lưu vào global (~/.s3build/profiles/)
s3 init --global

Wizard tự động:

  • Quét .csproj trong thư mục hiện tại (bỏ qua class library)
  • Đọc .pubxml trong Properties\PublishProfiles\ để pre-fill thông tin
  • Pre-check sẵn folder/file thường xoá (Images, web.config, App_GlobalResources...)
Cấu trúc profile
{
  "name": "WebPOS",
  "project": "C:\\path\\to\\WebPOS.csproj",
  "publishDir": "C:\\localpublish\\WebPOS",
  "zipDir": "C:\\localpublish",
  "zipPattern": "WebPOS_{date}.zip",
  "msbuild": {
    "configuration": "Release",
    "deployOnBuild": true,
    "webPublishMethod": "FileSystem",
    "precompileBeforePublish": true,
    "enableUpdateable": true
  },
  "clean": {
    "folders": ["Images", "PaymentSetting"],
    "files": ["web.config", "ConnectionStrings.config"]
  }
}
Build
# Build một profile
s3 build webpos

# Build nhiều profile cùng lúc (song song tối đa 3)
s3 build webpos webadmin

# Build tất cả profiles
s3 build all

# Build với ngày tùy chỉnh
s3 build webpos --date 01-07-2026
Xem danh sách profiles
s3 list
Quản lý config
# Xem profile
s3 config get webpos

# Set field (tự động parse kiểu: true/false, number, string)
s3 config set webpos msbuild.configuration Debug
s3 config set webpos msbuild.skipPostBuild true

# Thêm/xoá item trong mảng
s3 config add webpos clean.folders Temp
s3 config remove webpos clean.files web.config

# Xoá profile
s3 config delete webpos

Profile lookup

CLI tìm profile theo thứ tự ưu tiên:

  1. ./s3build-profiles/<name>.json (thư mục hiện tại)
  2. ~/.s3build/profiles/<name>.json (global)
  3. Bundled profiles (cài kèm package)

Luồng hoạt động

s3 build <profiles...>
  │
  ├── [parallel max 3]
  │   ├── 1. Load profile config
  │   ├── 2. Xóa thư mục publish cũ
  │   ├── 3. Chạy MSBuild → publish ra folder (optionally precompile)
  │   ├── 4. Xóa folders/files theo clean config
  │   └── 5. Nén thành ZIP (archiver)
  │
  └── Done → hiển thị danh sách file ZIP

License

MIT

Keywords