Back to Nocobase

nb source download

docs/docs/en/api/cli/source/download.md

2.1.213.5 KB
Original Source

nb source download

Fetch NocoBase from npm, Docker, or Git. --version is shared by all three source types: npm uses a package version, Docker uses an image tag, and Git uses a git ref.

Usage

bash
nb source download [flags]

Parameters

ParameterTypeDescription
--yes, -ybooleanUse defaults and skip interactive prompts
--verbosebooleanShow verbose command output
--localestringCLI prompt language: en-US or zh-CN
--source, -sstringSource type: docker, npm, or git
--version, -vstringnpm package version, Docker image tag, or Git ref
--replace, -rbooleanReplace the target directory if it already exists
--dev-dependencies, -D / --no-dev-dependenciesbooleanWhether npm/Git installs devDependencies
--output-dir, -ostringDownload target directory, or directory for the Docker tarball
--git-urlstringGit repository URL
--docker-registrystringDocker image repository name without tag
--docker-platformstringDocker image platform: auto, linux/amd64, or linux/arm64
--docker-save / --no-docker-savebooleanWhether to save the pulled Docker image as a tarball
--npm-registrystringRegistry used for npm/Git downloads and dependency installation
--build / --no-buildbooleanWhether to build after npm/Git dependency installation
--build-dtsbooleanWhether to generate TypeScript declaration files during npm/Git build
--hook-scriptstringHook module to run after npm scaffold or Git clone and before dependency installation; only applies to npm/Git source

Examples

bash
nb source download
nb source download -y --source npm --version alpha
nb source download -y --source npm --version alpha --no-build
nb source download --source npm --version alpha --output-dir=./app
nb source download --source docker --version alpha --docker-registry=nocobase/nocobase --docker-platform=linux/arm64
nb source download -y --source docker --version alpha --docker-save -o ./docker-images
nb source download --source git --version alpha [email protected]:nocobase/nocobase.git
nb source download --source git --version fix/cli-v2
nb source download -y --source npm --version alpha --build-dts
nb source download -y --source npm --version alpha --npm-registry=https://registry.npmmirror.com
nb source download -y --source git --version beta --hook-script ./hooks.mjs

Pre-install hook

--hook-script only affects the current nb source download run. If you want the hook to be saved with the env and reused by nb app upgrade or local source restore, pass it through nb init --hook-script instead.

The hook file must default-export an object with beforeDependencyInstall(context):

js
export default {
  beforeDependencyInstall: async ({ sourcePath, version, envConfig }) => {
    // Runs after git clone / npm scaffold and before yarn install.
  },
};

When you run nb source download --hook-script directly, beforeDependencyInstall receives context.phase as source-download and context.command as source:download. This command does not run beforeAppInstall or afterAppStart; those hooks belong to app install, start, restart, and upgrade flows.

Version Aliases

With Git source, common dist-tags are resolved to branches: latest -> main, beta -> next, alpha -> develop.