timothymiller / t4-app

A powerful cross-platform UI toolkit for building actually native iOS, Android, macOS, Windows, Linux, and Progressive Web Apps with React (Native).
https://t4stack.com
MIT License
1.34k stars 71 forks source link

Prevent file removal errors during project creation #20

Closed rosswaycaster closed 1 year ago

rosswaycaster commented 1 year ago

Overview:

This pull request makes a modification to the file removal commands in the apps/cli/bin/index.js script to prevent errors when the files or directories do not exist.

Details:

In the setup function in apps/cli/bin/index.js, the rm command was updated to use the -f (force) option. This change applies to the removal of .github/workflows/cli.yml, .github/workflows/docs.yml, and .github/workflows/vscode.yml files. The -f option will prevent the rm command from throwing an error if the file does not exist, allowing the script to continue its execution.

Reason:

The original script used the rm -rf command for both file and directory removal. However, this can lead to errors when a file does not exist because rm -rf is primarily intended for directory operations.

This pull request modifies the script to use rm -f for file removal and rm -rf for directories. This ensures that the script runs smoothly even if certain files don't exist.

This specific change addresses an issue encountered when creating a new T4 project with yarn create t4-app --supabase, improving the overall user experience by preventing unnecessary errors and interruptions.

Test Plan:

To test the changes, follow these steps:

  1. Pull the changes from this PR.
  2. Navigate to the bin directory with the command cd apps/cli/bin.
  3. Run yarn install to install any necessary dependencies.
  4. Run the script directly using Node.js with the command node index.js --supabase.
  5. The script should execute successfully without any errors related to the removal of non-existent files.
rosswaycaster commented 1 year ago

@timothymiller mentioned on Discord that there was a typo in the docs. It should be yarn create t4-app --supabase-auth! I still think this PR could be useful for making the script more robust against missing files. Open to feedback!