smapiot / piral

🚀 Framework for next generation web apps using micro frontends. ⭐️ Star to support our work!
https://piral.io
MIT License
1.68k stars 125 forks source link

Pilet pack/tgz format includes entries for directories starting in version 0.15.x #629

Closed peter-at-work closed 1 year ago

peter-at-work commented 1 year ago

Bug Report

For more information, see the CONTRIBUTING guide.

Prerequisites

Environment Details and Version

Previous piral-cli version used: 0.14.32 New piral-cli version used: 1.2.0

Description

Starting with piral-cli 0.15.0, the npm packing process to generate the pilet package/tgz is replaced with a simpler tar packing process using the tar utility. https://github.com/smapiot/piral/commit/a850ff7a24ccb631d3bc3d34d04b439f85d44e8a

With the new packing process, the directories/folders are included as 0-length items in the pack list and are included when enumerating the files in the pack. The entries for the directories/folders have additional information attached, such as the Unix file mode drwxr-xr-x.

The previous npm packing process did not include the directories/folders as entries in the pack list. npm apparently does not have any use of the additional information (Unix file mode) that is preserved by the tar utility.

Steps to Reproduce

  1. Using a pilet scaffolded with piral-cli version 0.14.32, pack the pilet: npx pilet pack
  2. Using a pilet scaffolded with piral-cli version 1.2.0 (0.15.0 or later), pack the pilet: npx pilet pack

7-zip flat view of the package built with piral-cli version 0.14.32: image

7-zip flat view of the package built with piral-cli version 1.2.0: image

Expected behavior

With the new pack process introduced in 0.15.0, it should still ignore directories/folders during packing, since the associated directories/folders attributes are not useful nor needed.

Possible Origin/Solution

Perhaps the filter option to the tar c() method can be utilized to filter out directories/folders https://github.com/isaacs/node-tar Something like filter = (path, stat) => stat.isDirectory() ? false : true