mirror of
https://github.com/langgenius/dify.git
synced 2026-04-23 04:06:13 +08:00
add build
This commit is contained in:
@ -1,17 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const entryFile = path.join(packageRoot, 'src', 'cli.ts')
|
||||
const tsxImport = await import.meta.resolve('tsx')
|
||||
const entryFile = path.join(packageRoot, 'dist', 'cli.mjs')
|
||||
|
||||
if (!fs.existsSync(entryFile))
|
||||
throw new Error(`Built CLI entry not found at ${entryFile}. Run "pnpm --filter @dify/cli build" first.`)
|
||||
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
['--import', tsxImport, entryFile, ...process.argv.slice(2)],
|
||||
[entryFile, ...process.argv.slice(2)],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
|
||||
@ -6,11 +6,15 @@
|
||||
"bin": {
|
||||
"dify-cli": "./bin/dify-cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vp pack"
|
||||
},
|
||||
"dependencies": {
|
||||
"tsx": "catalog:",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "catalog:"
|
||||
"@types/node": "catalog:",
|
||||
"vite": "catalog:",
|
||||
"vite-plus": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
17
packages/cli/vite.config.ts
Normal file
17
packages/cli/vite.config.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { defineConfig } from 'vite-plus'
|
||||
|
||||
export default defineConfig({
|
||||
pack: {
|
||||
clean: true,
|
||||
deps: {
|
||||
neverBundle: ['typescript'],
|
||||
},
|
||||
entry: ['src/cli.ts'],
|
||||
format: ['esm'],
|
||||
outDir: 'dist',
|
||||
platform: 'node',
|
||||
sourcemap: true,
|
||||
target: 'node22',
|
||||
treeshake: true,
|
||||
},
|
||||
})
|
||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -601,9 +601,6 @@ importers:
|
||||
|
||||
packages/cli:
|
||||
dependencies:
|
||||
tsx:
|
||||
specifier: 'catalog:'
|
||||
version: 4.21.0
|
||||
typescript:
|
||||
specifier: 'catalog:'
|
||||
version: 6.0.2
|
||||
@ -611,6 +608,12 @@ importers:
|
||||
'@types/node':
|
||||
specifier: 'catalog:'
|
||||
version: 25.6.0
|
||||
vite:
|
||||
specifier: npm:@voidzero-dev/vite-plus-core@0.1.16
|
||||
version: '@voidzero-dev/vite-plus-core@0.1.16(@types/node@25.6.0)(jiti@2.6.1)(sass@1.98.0)(terser@5.46.1)(tsx@4.21.0)(typescript@6.0.2)(yaml@2.8.3)'
|
||||
vite-plus:
|
||||
specifier: 'catalog:'
|
||||
version: 0.1.16(@types/node@25.6.0)(@voidzero-dev/vite-plus-core@0.1.16(@types/node@25.6.0)(jiti@2.6.1)(sass@1.98.0)(terser@5.46.1)(tsx@4.21.0)(typescript@6.0.2)(yaml@2.8.3))(happy-dom@20.9.0)(jiti@2.6.1)(sass@1.98.0)(terser@5.46.1)(tsx@4.21.0)(typescript@6.0.2)(yaml@2.8.3)
|
||||
|
||||
packages/iconify-collections:
|
||||
devDependencies:
|
||||
|
||||
Reference in New Issue
Block a user