Skip to content

Bug: manifest:export -p treats file paths as directories #161

@codyfrisch

Description

@codyfrisch

Bug: manifest:export -p creates directory instead of file when given a file path

Current behavior

When specifying a file path with the -p flag:

mapps manifest:export -a 123 -p ./examples/manifest-test.json

The command creates a directory called manifest-test.json and extracts manifest.json inside it:

examples/
  manifest-test.json/     # directory, not a file
    manifest.json

This happens because manifestPath is always passed directly to decompressZipBufferToFiles which calls mkdirSync on the full path and then extracts into it.

This is also inconsistent with manifest:import, where the same -p flag expects a file path (e.g. -p ./manifest.json). A user who imports from a file path would naturally expect to export to a file path with the same flag.

The manifest is always a single file — manifest:import confirms this by accepting a single file path, not a directory. The zip used by the API for export is purely for compression, not for bundling multiple files. Treating the export path as a directory is inconsistent behavior. If multiple files were ever added in the future, manifest:import would also need to change to accept a directory, which introduces its own problems (what files to include, what to exclude).

Additionally

The command silently overwrites existing files with no warning, since extractAllTo is called with the overwrite flag set to true. There is no way to prevent accidental overwrites.

Expected behavior

  • -p ./examples/manifest-test.json should write the manifest to ./examples/manifest-test.json as a file
  • -p ./examples/ should write manifest.json into the ./examples/ directory (current directory behavior preserved)
  • If the target file already exists, the command should abort with an error unless --force is specified

Note on backwards compatibility

Fixing this changes behavior for anyone passing a .json path to -p and relying on it being treated as a directory name. Additionally, adding overwrite protection would break scripts that depend on silent overwrite. This fix may be best suited for a major version bump.

Use case

Exporting multiple app manifests into the same directory with descriptive filenames:

mapps manifest:export -a 123 -p ./examples/app-123-manifest.json
mapps manifest:export -a 456 -p ./examples/app-456-manifest.json

This is currently impossible without manually renaming files after each export.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions