Skip to content

ionic commands unnecessarily manipulate default files #2486

@janpio

Description

@janpio

There are multiple ionic commands that mess with the default "config" files cordova.xml and package.json and by that create unnecessary changes that have to be checked in with Git. Here are some examples for a project created with the blank template:

  1. ionic cordova platform add android removes empty lines + comments and changes the ordering of <icon> attributes in config.xml. In package.json it changes the indendation from 2 spaces to 4 spaces:
    https://github.com/janpio/ionic-default-files-messing/commit/3db056994ff89256d6b94e03c8e8074df4a53e22

  2. ionic cordova resources replaces the existing images with the exact same images - same file size, pixel identical. Looking at the binary of the images it seems only some dates in metadata (?) at the end of the file is different. Should this be in the files at all?
    https://github.com/janpio/ionic-default-files-messing/commit/f58c2de710ba271d7cd9234335ce11fa739d1c5f

  3. ionic cordova run android then completely rewrite config.xml again. It changed " to ' in the <?xml> tag, and removed standalone="yes" completely from it. Then it added spaces in front of the closing / in all the tags, moved the density attribute of <icon> for android to the front of the tag, and completely resorted the <plugin>s in the bottom.
    https://github.com/janpio/ionic-default-files-messing/commit/c440bec7e46dd28882bbdc5bc2e7288bffdd85bf

Of course you can now say "well, only cosmetic changes, no functionality change, doesn't matter" and you would be technically correct of course. But for beginners (and old timers getting confused easily...) this is a real and unnecessary burden.

(Could someone please execute the same commands on Mac OS or Linux to see if this is reproducible? I only tested this on Windows 10 for now)

Can the CLI be improved so this doesn't happen?
Can or should the default config.xml and package.json be adapted to their "intended" format?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions