rockcarver / frodo-cli

A CLI to manage ForgeRock platform deployments supporting Identity Cloud tenants, ForgeOps deployments, and classic deployments.
MIT License
17 stars 14 forks source link

Script import watch should not automatically import all files upon invocation #372

Closed nquirk22 closed 2 weeks ago

nquirk22 commented 4 months ago

Frodo CLI version

Installed versions: cli: v1.0.1 lib: v1.1.0 node: v18.5.0

Describe the issue

According to this discussion, the intended workflow for developers working on auth scripts locally in their IDE is to first export scripts using frodo's script export --all-separate -extract command, then enable frodo script import -watch so that local changes are pushed up as they are made. Neither the export nor import functionality allows for any filtering or specification of overwrite behavior, and frodo's current version does not yet allow for importation of single files, though I see that has been implemented as part of upcoming verison 2.x.x.

This means that both steps in the local development workflow are extremely error-prone and cumbersome.

Specifically, frodo immediately imports all local scripts whenever frodo script import --all-separate --watch is invoked. This could cause unwanted remote updates to our org's dozens of auth scripts if a developer happens to have a stale version of a script lingering in the folder where import --watch is run.

This could be mitigated somewhat by always exporting fresh versions of every remote script to the local machine, but frodo's script export functionality automatically overwrites any existing local files, and supplying the necessary --extract command means no specific file can be exported.

So, to avoid any unwanted local and remote overwrites, a developer working locally would first need to export the current remote version of all scripts to their local machine, which in our case, is dozens of scripts. This must happen in a clean folder or any local pending changes will be overwritten. Then, to avoid immediately importing all the scripts which they just exported, they must move the desired .js and .json files to another clean folder and only then invoke script import --watch, or risk overwriting any remote changes that were made by others in the time between export and import.

While the upcoming ability to import single scripts manually is a welcome addition and will certainly help, it would be nice to have more granular control over which files are exported when we use the --extract flag (as we must) or, barring a filter, control over overwrite behavior. Alternatively, simply not importing all files when starting script import --watch would cut down significantly on risk, since that has the greatest chance of clobbering dozens of remote files with stale versions. Ideally, --watch only imports files that change after it is invoked.

vscheuber commented 3 months ago

@phalestrivir @hfranklin I wonder if you guys could take a look at this one?

hfranklin commented 2 months ago

Preston should have time to look at this after next week

vscheuber commented 2 weeks ago

Fixed in main (2.x) branch.