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

On Invalid Config Pilet Publish Removes Source #657

Closed FlorianRappl closed 9 months ago

FlorianRappl commented 9 months ago

Bug Report

For more information, see the CONTRIBUTING guide.

Prerequisites

Environment Details and Version

Ubuntu, Piral CLI 1.4.1

Description

When the main field of a pilet's package.json is pointing to the source file instead of the anticipated output then the Piral CLI first removes the corresponding source folder and then exists with an error that the source file is not longer found (true, it first removes it).

Steps to Reproduce

  1. Scaffold a new pilet
  2. Change main to be src/index.tsx instead of dist/index.js
  3. Run pilet publish --fresh ...

Expected behavior

The format expects the package.json's main to point to the target / produced file so maybe printing an error might be the correct response.

Actual behavior

The source folder is removed.

Possible Origin/Solution

Validate the package.json validity beforehand - make sure that the target != source (such that deleting the target would never delete the source).