({
name,
appName,
forcedAddOns = [],
forcedDeployment,
defaultFramework,
frameworkDefinitionInitializers,
showDeploymentOptions = true,
legacyAutoCreate = false,
defaultRouterOnly = false,
}: {
name: string
appName: string
forcedAddOns?: Array<string>
forcedDeployment?: string
defaultFramework?: string
frameworkDefinitionInitializers?: Array<() => FrameworkDefinition>
showDeploymentOptions?: boolean
legacyAutoCreate?: boolean
defaultRouterOnly?: boolean
})
| 236 | } |
| 237 | |
| 238 | export function cli({ |
| 239 | name, |
| 240 | appName, |
| 241 | forcedAddOns = [], |
| 242 | forcedDeployment, |
| 243 | defaultFramework, |
| 244 | frameworkDefinitionInitializers, |
| 245 | showDeploymentOptions = true, |
| 246 | legacyAutoCreate = false, |
| 247 | defaultRouterOnly = false, |
| 248 | }: { |
| 249 | name: string |
| 250 | appName: string |
| 251 | forcedAddOns?: Array<string> |
| 252 | forcedDeployment?: string |
| 253 | defaultFramework?: string |
| 254 | frameworkDefinitionInitializers?: Array<() => FrameworkDefinition> |
| 255 | showDeploymentOptions?: boolean |
| 256 | legacyAutoCreate?: boolean |
| 257 | defaultRouterOnly?: boolean |
| 258 | }) { |
| 259 | let currentTelemetry: TelemetryClient | undefined |
| 260 | const environment = createUIEnvironment(appName, false, () => currentTelemetry) |
| 261 | |
| 262 | const program = new Command() |
| 263 | |
| 264 | async function confirmTargetDirectorySafety( |
| 265 | targetDir: string, |
| 266 | forced?: boolean, |
| 267 | ) { |
| 268 | if (forced) { |
| 269 | return |
| 270 | } |
| 271 | |
| 272 | if (!fs.existsSync(targetDir)) { |
| 273 | return |
| 274 | } |
| 275 | |
| 276 | if (!fs.statSync(targetDir).isDirectory()) { |
| 277 | throw new Error(`Target path exists and is not a directory: ${targetDir}`) |
| 278 | } |
| 279 | |
| 280 | if (fs.readdirSync(targetDir).length === 0) { |
| 281 | return |
| 282 | } |
| 283 | |
| 284 | const shouldContinue = await confirm({ |
| 285 | message: `Target directory "${targetDir}" already exists and is not empty. Continue anyway?`, |
| 286 | initialValue: false, |
| 287 | }) |
| 288 | |
| 289 | if (isCancel(shouldContinue) || !shouldContinue) { |
| 290 | cancel('Operation cancelled.') |
| 291 | process.exit(0) |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | async function confirmCreateOptions(finalOptions: Options) { |
no test coverage detected