Skip to content

Commit

Permalink
Add types for cds.cli (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
chgeo committed Sep 18, 2024
1 parent c7a7f05 commit 09bdac6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

### Added
- `cds.app` typed as express.js application
- `cds.cli` CLI arguments

## Version 0.6.5 - 2024-08-13
### Fixed
Expand Down
13 changes: 13 additions & 0 deletions apis/facade.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,18 @@ export const version: string
export const home: string
export const root: string

type CliCommands = 'add' | 'build' | 'compile' | 'deploy' | 'import' | 'init' | 'serve' | (string & {})
/**
* The parsed effective `cds` CLI command and arguments.
* May be undefined if not started from the `cds` CLI.
* @see https://cap.cloud.sap/docs/node.js/cds-facade#cds-cli
*/
export const cli: {
/** Basic command like `serve` */ command?: CliCommands,
/** Positional arguments */ argv?: string[],
/** Named arguments */ options?: Record<string, any>,
} | undefined


import { env } from './env'
export const requires: env.Requires
7 changes: 7 additions & 0 deletions test/typescript/apis/project/cds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ cds.version === '1.2.3'
cds.home === 'path/to/cds'
cds.root === 'path/to/project'
cds.requires === cds.env.requires

cds.cli!.argv = ['']
cds.cli!.options = { foo: true }
cds.cli!.command = 'deploy'
cds.cli!.command = 'unknown-command'
//@ts-expect-error
cds.cli!.command = true

0 comments on commit 09bdac6

Please sign in to comment.