DevExtreme CLI: --empty flag incorrectly parsed as string instead of boolean
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.emptyevaluates tofalse(non-empty strings are truthy) - Sample pages are NOT created ❌
When templateOptions.empty = false (boolean):
-
!templateOptions.emptyevaluates totrue - 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