-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
refactor(persist): Allow explicit declaration of persistent item types #6367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends the “persist” manifest entry to allow an explicit object form with separate file
and directory
lists, while preserving legacy array/schema support.
- Adds a new
persist
definition inschema.json
that accepts either the legacy string/array formats or an object withfile
and/ordirectory
keys. - Refactors
persist_data
andunlink_persist_data
inlib/install.ps1
to 8000 build and process separate lists for files vs. directories based on the new schema.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
schema.json | Replaces legacy refs with a new persist definition allowing explicit file /directory object |
lib/install.ps1 | Updates persist_data and unlink_persist_data to distinguish and handle file vs. directory entries |
Comments suppressed due to low confidence (2)
lib/install.ps1:450
- [nitpick] The variable name
$persistence
is easily confused with the input$persist
. Consider renaming to something like$parsedPersist
or$persistItems
for clarity.
$persistence = [PSCustomObject]@{
lib/install.ps1:447
- We should add unit or integration tests covering the new object-style
persist
(file
vsdirectory
) to ensure both legacy and new formats behave as expected.
function persist_data($manifest, $original_dir, $persist_dir) {
@@ -404,6 +404,37 @@ | |||
} | |||
] | |||
}, | |||
"persist": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new object form for persist
should be documented in the manifest reference (README or docs) so users know the file
/directory
keys are now supported.
"persist": { | |
"persist": { | |
"description": "Specifies files or directories to persist across updates. Can be a string, an array of strings, or an object with 'file' and/or 'directory' keys. The 'file' key is used to specify files to persist, and the 'directory' key is used to specify directories to persist. At least one of 'file' or 'directory' must be provided.", |
Copilot uses AI. Check for mistakes.
@@ -1,3 +1,9 @@ | |||
## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/master...develop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since v0.5.3 has not been released yet, I think the log entry should be added under v0.5.3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be change when #6257 include this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like 0.5.3's publish process is currently frozen >︿<
The persist refactor is here: #3248 Please wait while v0.5.3 is merged. |
If you plan to continue implementing #3248, then I suggest you move 'type' to top-level like this PR to avoid redundantly type definitions, and have a strictly restrict for type-specific 'methods'. #6369 (comment) |
I will proceed with a force merge of v0.5.3 if there are no further comments, and we can focus on adding more features afterward. |
I agree. #6369 (comment) is the more elegant solution, imo. |
Description
Motivation and Context
Closes #6179
before:
will create empty dir for non-existent items
after:
will create empty file/dir for non-existent items by its property
How Has This Been Tested?
persistence.json
legacy persistence:
wakemeonlan: Same behavior as before, it still a wrong persistence, because it's wrong when written.
rufus: Same behavior as before
Checklist:
develop
branch.