feat: rename dsh to dsh-sdk
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Commander adapter for the dsh subcommand surface.
|
||||
* Commander adapter for the dsh-sdk subcommand surface.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-scripts/args
|
||||
*/
|
||||
@@ -7,12 +7,12 @@
|
||||
import { parseArgs as parseNodeArgs } from 'node:util'
|
||||
import { Command } from 'commander'
|
||||
|
||||
/** Commands implemented by the dsh launcher. */
|
||||
type DshCommand = 'start' | 'dev' | 'build' | 'config'
|
||||
/** Commands implemented by the dsh-sdk launcher. */
|
||||
type DshSdkCommand = 'start' | 'dev' | 'build' | 'config'
|
||||
|
||||
/** Parsed dsh invocation. */
|
||||
export interface DshArgs {
|
||||
command?: DshCommand
|
||||
/** Parsed dsh-sdk invocation. */
|
||||
export interface DshSdkArgs {
|
||||
command?: DshSdkCommand
|
||||
target?: string
|
||||
forwarded: readonly string[]
|
||||
help: boolean
|
||||
@@ -29,16 +29,16 @@ export function parseSdkBootArgs(argv: readonly string[]): Record<string, string
|
||||
}
|
||||
|
||||
/** Parse one launcher invocation through real Commander subcommands. */
|
||||
export function parseDshArgs(argv: readonly string[]): DshArgs {
|
||||
export function parseDshSdkArgs(argv: readonly string[]): DshSdkArgs {
|
||||
if (argv.length === 0 || argv[0] === '--help' || argv[0] === '-h') {
|
||||
return { forwarded: [], help: true }
|
||||
}
|
||||
const separator = argv.indexOf('--')
|
||||
const launcherArgv = separator === -1 ? argv : argv.slice(0, separator)
|
||||
const passthrough = separator === -1 ? [] : argv.slice(separator + 1)
|
||||
let parsed: DshArgs | undefined
|
||||
let parsed: DshSdkArgs | undefined
|
||||
const program = new Command()
|
||||
.name('dsh')
|
||||
.name('dsh-sdk')
|
||||
.helpOption(false)
|
||||
.showHelpAfterError(false)
|
||||
.exitOverride()
|
||||
@@ -62,9 +62,9 @@ export function parseDshArgs(argv: readonly string[]): DshArgs {
|
||||
})
|
||||
program.parse([...launcherArgv], { from: 'user' })
|
||||
/* v8 ignore next -- every registered Commander action above assigns parsed or Commander throws */
|
||||
if (!parsed) throw new Error('dsh command did not resolve')
|
||||
if (!parsed) throw new Error('dsh-sdk command did not resolve')
|
||||
if (parsed.command === 'config' && passthrough.length > 0) {
|
||||
throw new Error('dsh config does not accept forwarded arguments')
|
||||
throw new Error('dsh-sdk config does not accept forwarded arguments')
|
||||
}
|
||||
return { ...parsed, forwarded: [...parsed.forwarded, ...passthrough] }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Self-executing dsh launcher.
|
||||
* Self-executing dsh-sdk launcher.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-scripts/bin
|
||||
*/
|
||||
|
||||
import { runDshCommand } from './command.ts'
|
||||
import { runDshSdkCommand } from './command.ts'
|
||||
|
||||
process.exitCode = await runDshCommand()
|
||||
process.exitCode = await runDshSdkCommand()
|
||||
|
||||
@@ -54,7 +54,7 @@ function resolveTsdownBin(cwd: string): string {
|
||||
try {
|
||||
manifestPath = require.resolve('tsdown/package.json')
|
||||
} catch (error) {
|
||||
throw new Error(`dsh build requires tsdown in this project: ${String(error)}`)
|
||||
throw new Error(`dsh-sdk build requires tsdown in this project: ${String(error)}`)
|
||||
}
|
||||
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { bin?: unknown }
|
||||
const bin = typeof manifest.bin === 'string'
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Internal dsh command composition used by the package bin.
|
||||
* Internal dsh-sdk command composition used by the package bin.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-scripts/command
|
||||
*/
|
||||
|
||||
import { parseDshArgs } from './args.ts'
|
||||
import { parseDshSdkArgs } from './args.ts'
|
||||
import { runProjectBuild } from './build.ts'
|
||||
import { runConfigCommand, type ConfigCommandContext } from './config.ts'
|
||||
import { runSDK } from './runtime.ts'
|
||||
import { DSH_TEMPLATES } from './templates/dsh-templates.ts'
|
||||
import { DSH_SDK_TEMPLATES } from './templates/dsh-sdk-templates.ts'
|
||||
|
||||
/** Injectable process and command boundaries used by the dsh bin. */
|
||||
export interface DshCommandContext extends ConfigCommandContext {
|
||||
/** Injectable process and command boundaries used by the dsh-sdk bin. */
|
||||
export interface DshSdkCommandContext extends ConfigCommandContext {
|
||||
cwd: string
|
||||
stdin: NodeJS.ReadStream
|
||||
stdout: NodeJS.WriteStream
|
||||
@@ -21,10 +21,10 @@ export interface DshCommandContext extends ConfigCommandContext {
|
||||
config?: typeof runConfigCommand
|
||||
}
|
||||
|
||||
/** Run one parsed dsh command and return its process exit code. */
|
||||
export async function runDshCommand(
|
||||
/** Run one parsed dsh-sdk command and return its process exit code. */
|
||||
export async function runDshSdkCommand(
|
||||
argv: readonly string[] = process.argv.slice(2),
|
||||
context: DshCommandContext = {
|
||||
context: DshSdkCommandContext = {
|
||||
cwd: process.cwd(),
|
||||
stdin: process.stdin,
|
||||
stdout: process.stdout,
|
||||
@@ -32,9 +32,9 @@ export async function runDshCommand(
|
||||
},
|
||||
): Promise<number> {
|
||||
try {
|
||||
const args = parseDshArgs(argv)
|
||||
const args = parseDshSdkArgs(argv)
|
||||
if (args.help || !args.command) {
|
||||
context.stdout.write(DSH_TEMPLATES.usage.render({}))
|
||||
context.stdout.write(DSH_SDK_TEMPLATES.usage.render({}))
|
||||
return 0
|
||||
}
|
||||
const run = context.run ?? runSDK
|
||||
@@ -52,7 +52,7 @@ export async function runDshCommand(
|
||||
}
|
||||
return 0
|
||||
} catch (error) {
|
||||
context.stderr.write(`dsh: ${error instanceof Error ? error.message : String(error)}\n`)
|
||||
context.stderr.write(`dsh-sdk: ${error instanceof Error ? error.message : String(error)}\n`)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* dsh config command composition.
|
||||
* dsh-sdk config command composition.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-scripts/config
|
||||
*/
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from '@deepseek-ai/dsh-helper'
|
||||
import { ConfigWorkflow, type ConfigWorkflowResult } from './config/config-workflow.ts'
|
||||
|
||||
/** Process stream slice required by dsh config. */
|
||||
/** Process stream slice required by dsh-sdk config. */
|
||||
export interface ConfigCommandContext {
|
||||
cwd: string
|
||||
stdin: NodeJS.ReadStream
|
||||
@@ -24,7 +24,7 @@ export interface ConfigCommandContext {
|
||||
/** Open and interactively edit one existing SDK project. */
|
||||
export async function runConfigCommand(context: ConfigCommandContext): Promise<ConfigWorkflowResult> {
|
||||
if (!context.port && (!context.stdin.isTTY || !context.stdout.isTTY)) {
|
||||
throw new Error('dsh config requires an interactive TTY')
|
||||
throw new Error('dsh-sdk config requires an interactive TTY')
|
||||
}
|
||||
const project = await SdkProject.open(context.cwd)
|
||||
const registry = createBuiltinRegistry(project.profile)
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
type PromptPort,
|
||||
type SdkProject,
|
||||
} from '@deepseek-ai/dsh-helper'
|
||||
import { DSH_TEMPLATES } from '../templates/dsh-templates.ts'
|
||||
import { DSH_SDK_TEMPLATES } from '../templates/dsh-sdk-templates.ts'
|
||||
|
||||
/** Config result, including an install failure that happened after commit. */
|
||||
export interface ConfigWorkflowResult {
|
||||
@@ -144,7 +144,7 @@ export class ConfigWorkflow {
|
||||
} catch (error) {
|
||||
const installError = error instanceof Error ? error : new Error(String(error))
|
||||
const manager = project.profile.packageManager
|
||||
this.output.write(DSH_TEMPLATES.configInstallFailure.render({
|
||||
this.output.write(DSH_SDK_TEMPLATES.configInstallFailure.render({
|
||||
error: installError.message,
|
||||
packageManager: manager.name,
|
||||
installArgs: manager.installCommand().join(' '),
|
||||
|
||||
@@ -68,7 +68,7 @@ async function registerDevRuntime(cwd: string = process.cwd()): Promise<void> {
|
||||
({ register: registerTsx } = await import('tsx/esm/api'))
|
||||
} catch (error) {
|
||||
/* v8 ignore next -- tsx is a declared project NPM dependency; missing-package behavior is defensive */
|
||||
throw new Error(`dsh dev requires the project's tsx NPM dependency: ${String(error)}`)
|
||||
throw new Error(`dsh-sdk dev requires the project's tsx NPM dependency: ${String(error)}`)
|
||||
}
|
||||
registerTsx()
|
||||
const mappings = await localPluginMappings(resolve(cwd))
|
||||
@@ -97,9 +97,9 @@ export async function startSDK(
|
||||
}
|
||||
const requested = source instanceof URL ? fileURLToPath(source) : source
|
||||
const absolute = resolveConfigPath(requested, undefined, cwd)
|
||||
loadEnv('dsh', dirname(absolute))
|
||||
installFailLoud('dsh')
|
||||
return boot('dsh', absolute)
|
||||
loadEnv('dsh-sdk', dirname(absolute))
|
||||
installFailLoud('dsh-sdk')
|
||||
return boot('dsh-sdk', absolute)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,12 +120,12 @@ export async function runSDK(
|
||||
try {
|
||||
await access(absolute)
|
||||
} catch (error) {
|
||||
const hint = options.dev ? '' : ' Run dsh build first if this is a TypeScript project.'
|
||||
const hint = options.dev ? '' : ' Run dsh-sdk build first if this is a TypeScript project.'
|
||||
throw new Error(`cannot start missing target ${target}.${hint} ${String(error)}`)
|
||||
}
|
||||
const module = await import(pathToFileURL(absolute).href) as { main?: (context: SdkBootContext) => unknown }
|
||||
if (typeof module.main !== 'function') {
|
||||
throw new Error(`dsh target ${target} must export function main()`)
|
||||
throw new Error(`dsh-sdk target ${target} must export function main()`)
|
||||
}
|
||||
const argv = [...options.argv ?? []]
|
||||
return module.main({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Usage: dsh <command> [options]
|
||||
Usage: dsh-sdk <command> [options]
|
||||
|
||||
Commands:
|
||||
start [target] [-- args...] Import a built module, or boot cordis.yml
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Package-owned terminal templates for the dsh launcher.
|
||||
* Package-owned terminal templates for the dsh-sdk launcher.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-scripts/templates/dsh-templates
|
||||
* @module @deepseek-ai/dsh-scripts/templates/dsh-sdk-templates
|
||||
*/
|
||||
|
||||
import { TextTemplate, type PackageManagerName } from '@deepseek-ai/dsh-helper'
|
||||
@@ -12,8 +12,8 @@ interface ConfigInstallFailureTemplateModel {
|
||||
installArgs: string
|
||||
}
|
||||
|
||||
/** Compiled dsh terminal templates. */
|
||||
export const DSH_TEMPLATES = {
|
||||
/** Compiled dsh-sdk terminal templates. */
|
||||
export const DSH_SDK_TEMPLATES = {
|
||||
usage: TextTemplate.fromFile<Record<string, never>>(new URL('./assets/usage.txt.tpl', import.meta.url)),
|
||||
configInstallFailure: TextTemplate.fromFile<ConfigInstallFailureTemplateModel>(
|
||||
new URL('./assets/config-install-failure.txt.tpl', import.meta.url),
|
||||
Reference in New Issue
Block a user