cli
cli copied to clipboard
Scaffolding: Add ability to skip missing placeholders or skip entire file
Is your feature request related to a problem? Please describe. Currently, a scaffolding command fails if a placeholder is missing by printing all the missing ones:
Missing placeholders:
// this line is used by starport scaffolding # types/genesis/testcase
// this line is used by starport scaffolding # types/genesis/validField
We're adding many new useful features in scaffolding like genesis tests but sometimes the user already has their own custom tests. In this case, we could have a command decreasing the verbosity of scaffolding like --no-test but the user may still want to benefit from test scaffolding but not for the genesis specifically
One solution currently is to move placeholder in comment block so it doesn't have any influence on the logic: https://github.com/tendermint/spn/blob/7fc10738363ffb37a80918b91ed18467946b75d7/x/profile/genesis_test.go#L12 But this is quite ugly
Describe the solution you'd like
Adding the ability to skip placeholders:
-
This could be through a specific flag like
--skip-missingor--force-modificationso that files are still modified but not the missing placehodlers -
Or through the prompt:
Missing placeholders:
// this line is used by starport scaffolding # types/genesis/testcase
Do you want to skip this modification? yes/no
yes
// this line is used by starport scaffolding # types/genesis/validField
Do you want to skip this modification? yes/no
no
scaffolding failed
Another solution could be to add the ability to skip an entire file modification when the user know the file is customized (in spn case we would do it for genesis_test.go)
Like adding a pragma comment on the top of the file to precise this file can't be modified by Starport
// NO STARPORT MODIFICATION
package types
import (
...
)
...
We may need to discuss this in a call, but here is one solution. We split scaffolding in parts (for example, for scaffold list it's scaffolding a type, crud and tests). If placeholders for a particular part are missing, we don't scaffold this part but continue to the next one. Command should fail if there are missing placeholders for crud (because that's the whole purpose of this command), but shouldn't fail if we have placeholders missing for tests.
We currently use a method Replace() from a package replacer
Maybe the solution could simply be using a method MayReplace() that doesn't fail if the placeholder doesn't exist
Issue is now out of scope due to plan to remove placeholders. Should file an issue to identify refactoring for removed placeholders.