zupublic-node
v0.1.3
Published
CLI for syncing static assets into a local folder from a remote API and filter.
Downloads
473
Readme
ZUPublic-node
ZUPublic-node is a publishable npm CLI for syncing local static assets from a remote API.
npm package name:
zupublic-node
CLI command:
zupublic-node
Chinese documentation:
中文快速说明
ZUPublic-node 用于根据远端接口和本地过滤器同步静态资源。
核心特点:
init初始化配置和过滤器模板pull拉取远端数据并同步静态文件- 按单文件
version判断是否需要更新 - 支持
-b和-t快速初始化
快速开始:
npm install -g zupublic-node
zupublic-node init -b https://example.com/api/config -t empty
zupublic-node diff
zupublic-node update scripts/app.js styles/theme.css
zupublic-node pullCommands
zupublic-node init
Creates:
update-public.config.jsonupdate-public.filter.ts
Supports:
-b,--baseurlto setbaseurldirectly-t,--templateto select a template by templateid
If baseurl is not passed, the CLI asks for it interactively.
The filter file is selected from templates maintained inside this package.
zupublic-node pull
- Reads
update-public.config.json - Fetches the remote API from
baseurl - Runs
update-public.filter.ts - Compares each remote file by
type + name + version - Only downloads files whose version changed or that are new
- Shows a progress bar while syncing files
- Updates local config
publics
zupublic-node diff
Compares the local recorded publics with the latest remote filtered result.
- Shows
ADDED,CHANGED, andREMOVEDentries - Does not download files
- Does not rewrite
update-public.config.json - Supports
--jsonfor structured output
Example:
zupublic-node diff
zupublic-node diff --jsonzupublic-node update
Downloads only the specified remote assets.
- Accepts one or more
type/nametargets - Re-downloads the specified files even if the version is unchanged
- Rewrites only the matching entries in
update-public.config.json - Fails if any requested target is missing from the latest remote result
Example:
zupublic-node update scripts/app.js
zupublic-node update scripts/app.js styles/theme.cssConfig
{
"baseurl": "https://example.com/api/config",
"auth": {
"headers": {
"Authorization": "Bearer ${UPDATE_PUBLIC_TOKEN}"
}
},
"publics": []
}auth.headers is optional. Header values support ${ENV_NAME} placeholders, so secrets can stay in environment variables instead of being committed to the config file.
Example:
# PowerShell
$env:UPDATE_PUBLIC_TOKEN="your-token"
zupublic-node pullFilter contract
The generated update-public.filter.ts must default export a function that returns:
{
publics: Array<{ name: string; link: string; type: string; version: string }>;
}Maintaining templates
Templates are maintained in this package under src/templates/.
To add a new selectable template:
- Add a file in
src/templates/ - Export it from
src/templates/index.ts - Publish a new npm version
After users update to the new package version, they can select that template during zupublic-node init.
Example:
zupublic-node init -b https://example.com/api/config -t empty