chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动

演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-18 13:59:25 +08:00
1 parent 60158935f4
commit 6519682885
15831 files changed
+3063428

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# scripts/lib/common.sh — shared shell helpers for cli/ scripts.
[[ -n "${DIFYCTL_LIB_COMMON_SH:-}" ]] && return 0
readonly DIFYCTL_LIB_COMMON_SH=1
log::info() { printf '\033[36m[info]\033[0m %s\n' "$*" >&2; }
log::warn() { printf '\033[33m[warn]\033[0m %s\n' "$*" >&2; }
log::err() { printf '\033[31m[err ]\033[0m %s\n' "$*" >&2; }
die() { log::err "$*"; exit 1; }
# Resolve the cli/ directory (parent of scripts/).
cli::root() {
local dir
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
printf '%s' "$dir"
}
require() {
command -v "$1" >/dev/null 2>&1 || die "missing dependency: $1${2:+ — $2}"
}
@@ -0,0 +1,77 @@
import type { ExecSyncOptions } from 'node:child_process'
import { execSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
export const BUILD_CHANNELS = ['dev', 'alpha', 'rc', 'edge', 'stable'] as const
export type BuildChannel = (typeof BUILD_CHANNELS)[number]
export type BuildInfo = {
version: string
commit: string
buildDate: string
channel: BuildChannel
}
export type Env = Record<string, string | undefined>
export type GitProbe = (cmd: string) => string | null
const GIT_PROBE_OPTS: ExecSyncOptions = {
stdio: ['ignore', 'pipe', 'ignore'],
}
export const defaultGitProbe: GitProbe = (cmd) => {
try {
return execSync(cmd, GIT_PROBE_OPTS).toString().trim() || null
} catch {
return null
}
}
type PackageManifest = {
difyctl?: {
channel?: string
}
}
export type PackageReader = () => PackageManifest
// Default reader resolves cli/package.json relative to this file so the same
// helper works whether invoked from vite.config.ts, bin/dev.js, or release.sh.
const defaultPackageReader: PackageReader = () => {
try {
const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json')
return JSON.parse(readFileSync(pkgPath, 'utf8')) as PackageManifest
} catch {
return {}
}
}
export type ResolveOptions = {
env?: Env
git?: GitProbe
now?: () => Date
pkg?: PackageReader
}
export function resolveBuildInfo(opts: ResolveOptions = {}): BuildInfo {
const env = opts.env ?? process.env
const git = opts.git ?? defaultGitProbe
const now = opts.now ?? (() => new Date())
const pkg = (opts.pkg ?? defaultPackageReader)()
const channel = env.DIFYCTL_CHANNEL ?? pkg.difyctl?.channel ?? 'dev'
if (!(BUILD_CHANNELS as readonly string[]).includes(channel)) {
throw new Error(`invalid DIFYCTL_CHANNEL: ${channel} (expected ${BUILD_CHANNELS.join(' | ')})`)
}
const version = env.DIFYCTL_VERSION ?? git('git describe --tags --dirty --always') ?? '0.0.0-dev'
const commit = env.DIFYCTL_COMMIT ?? git('git rev-parse HEAD') ?? 'none'
const buildDate = env.DIFYCTL_BUILD_DATE ?? now().toISOString()
return { version, commit, buildDate, channel: channel as BuildChannel }
}