devextreme-cli icon indicating copy to clipboard operation
devextreme-cli copied to clipboard

DevExtreme CLI: --empty flag incorrectly parsed as string instead of boolean

Open AlisherAmonulloev opened this issue 3 months ago • 0 comments

Issue

When creating a new React app with explicit CLI parameters, the --empty false flag fails to create sample pages, even though it should include them.

Expected behavior:

npx devextreme-cli new react-app MyApp --empty false
# Should create src/pages/ with sample pages (home, tasks, profile)

Actual behavior:

npx devextreme-cli new react-app MyApp --empty false
# Does NOT create src/pages/ directory - pages are missing

Workaround that works:

npx devextreme-cli new react-app MyApp
# Interactive prompts work correctly and create pages

Root Cause

The minimist argument parser was treating --empty false as a string "false" instead of a boolean false. This caused the conditional check in application.react.js to fail:

if(!templateOptions.empty) {
    addSamplePages(appPath, templateOptions);
}

When templateOptions.empty = "false" (string):

  • !templateOptions.empty evaluates to false (non-empty strings are truthy)
  • Sample pages are NOT created ❌

When templateOptions.empty = false (boolean):

  • !templateOptions.empty evaluates to true
  • Sample pages ARE created ✅

Solution

Configure minimist to parse the --empty flag as a boolean type by adding it to the boolean array in the parser options:

const args = require('minimist')(process.argv.slice(2), {
    alias: { v: 'version' },
    boolean: ['empty']  // ← Added this line
});

This ensures --empty false, --empty true, and --empty are all parsed as proper boolean values, making the flag behavior consistent regardless of how it's specified.

Ticket ID: T1311643

AlisherAmonulloev avatar Oct 28 '25 13:10 AlisherAmonulloev