Skip to content
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

Fixes microsoft#21219 + some improvements #27

Merged
merged 14 commits into from
Sep 18, 2021

Conversation

vedantmgoyal9
Copy link

  • Have you signed the Contributor License Agreement?
  • Have you checked that there aren't other open pull requests for the same manifest update/change?
  • Have you validated your manifest locally with winget validate --manifest <path>?
  • Have you tested your manifest locally with winget install --manifest <path>?
  • Does your manifest conform to the 1.0 schema?

Note: <path> is the name of the directory containing the manifest you're submitting.


@OfficialEsco
Copy link
Collaborator

I'll start testing this now, my last 60+ PRs used version 1 of the SimpleUpdate

@OfficialEsco
Copy link
Collaborator

Well, something is broken

Select Mode

[1] New Manifest or Package Version

[2] Quick Update Package Version (Note: Must be used only when previous version's metadata is complete.)

[3] Update Package Metadata

[4] New Locale

[q] Any key to quit

Selection: 2

[Required] Enter the Package Identifier, in the following format <Publisher shortname.Application shortname>. For example: Microsoft.Excel
PackageIdentifier: Bethesda.Launcher

[Required] Enter the version. for example: 1.33.7
Version: 1.82.0
Found Existing Version: 1.75.0
   ~\GitHub\winget-pkgs  PR-Parms                                                                    10:41:46 
❯

@vedantmgoyal9
Copy link
Author

@OfficialEsco I have fixed the issue.

@Trenly If you do any changes to the script, please commit directly to my branch. It is very difficult for me to update the branch and resolve conflicts.

@Trenly
Copy link
Owner

Trenly commented Sep 17, 2021

@OfficialEsco I have fixed the issue.

@Trenly If you do any changes to the script, please commit directly to my branch. It is very difficult for me to update the branch and resolve conflicts.

Rebasing can be extremely difficult. It is a good skill to learn though, is how to read through and resolve merge conflicts during a rebase. I'll try to avoid any big changes while you have open PR's. I also don't want us to get into a situation where we have a branch of a branch of a branch of a branch for creating and merging in new features though, so I can't always guarantee there won't be conflicts

Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
Copy link
Owner

@Trenly Trenly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed these!

Tools/YamlCreate.ps1 Outdated Show resolved Hide resolved
@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 17, 2021

@Trenly I committed all suggestions but then read your message.
image
So, if you comment the line, you will find that if I try to create a non-existing (new) package, it proceeds to enter InstallerUrl and the rest of the data. But, if you uncomment that line, and the package does not exist before...
image
the script will throw error and exit.

The option is meant for only update the existing package version, so it is must that package should exist before selecting that option.

@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 17, 2021

#23 (comment) @Trenly you can only do. I have tried again but my brain got fully drained 🤯.

@Trenly
Copy link
Owner

Trenly commented Sep 17, 2021

@Trenly I committed all suggestions but then read your message.
So, if you comment the line, you will find that if I try to create a non-existing (new) package, it proceeds to enter InstallerUrl and the rest of the data. But, if you uncomment that line, and the package does not exist before...
the script will throw error and exit.

The option is meant for only update the existing package version, so it is must that package should exist before selecting that option.

Ohhh, I see. So it needs to be in both places. I misunderstood

@Trenly
Copy link
Owner

Trenly commented Sep 17, 2021

#23 (comment) @Trenly you can only do. I have tried again but my brain got fully drained 🤯.

What exactly isn't working about the multi-manifest Simple Update?

@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 17, 2021

Esco wants more fewer prompts. #23 (comment)

Edit: Original Issue: microsoft#21219

@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 17, 2021

@OfficialEsco @Trenly I have another feature that can be implemented pretty easily.

While creating manifests for packages like Mirantis.Lens, Fndroid.ClashForWindows, etc. we have to enter one URL two times to create different installers due to different scope/installer switches.

So, instead of downloading the same URL two times, it should check if that URL was entered before and if the condition is true, get the previous hash and continue to the next field.

@Trenly
Copy link
Owner

Trenly commented Sep 17, 2021

@OfficialEsco @Trenly I have another feature that can be implemented pretty easily.

While creating manifests for packages like Mirantis.Lens, Fndroid.ClashForWindows, etc. we have to enter one URL two times to create different installers due to different scope/installer switches.

So, instead of downloading the same URL two times, it should check if that URL was entered before and if the condition is true, get the previous hash and continue to the next field.

Sounds like a good idea; Lets make a separate issue / pr for it when we do implement it

@Trenly
Copy link
Owner

Trenly commented Sep 17, 2021

Esco wants more fewer prompts. #23 (comment)

Edit: Original Issue: microsoft#21219

@OfficialEsco @vedantmgoyal2009 I've created a PR over at Vedant's repo to make the prompts reduced the way Esco had in the original post

https://github.com/vedantmgoyal2009/winget-pkgs/pull/4

vedantmgoyal9 and others added 2 commits September 18, 2021 08:08
* Reduce input required for quick version update

* Fix Product Code

* Don't add null product code if no product code key exists
@Trenly Trenly requested a review from OfficialEsco September 18, 2021 02:51
@vedantmgoyal9
Copy link
Author

image
I think the warning should be displayed before entering PackageIdentifier because if a user sees a warning and then exits and starts over, he will have enter pkg id and version again. Also, is there any way to switch the mode without exiting the script?

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

image
I think the warning should be displayed before entering PackageIdentifier because if a user sees a warning and then exits and starts over, he will have enter pkg id and version again. Also, is there any way to switch the mode without exiting the script?

We can move the warning, that shouldn’t be too difficult;

I can look into switching the option when I move the warning

@vedantmgoyal9
Copy link
Author

Oh, I have done it already. Pushing a new commit in a few minutes.

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

Oh, I have done it already. Pushing a new commit in a few minutes.

Still pushing that commit, or want me to run one through quick?

@vedantmgoyal9
Copy link
Author

I was correcting a spelling mistake. It took me an hour to find it.

@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 18, 2021

And, in "another feature" I think we have to submit two PR, first of deleting the old version and then adding a new version.

No it does not because the URL is static

Read Previous Manifest
Create New Manifest
Delete old Manifest if InstallerURL is the same
Push Commit
Create PR

Or

Read Previous Manifest
Create New Manifest
Push Commit
Check if InstallerURL matches previous version
If match Delete old Manifest
Push Commit
Create PR

We have to do this part also?

Edit: I just now realised that does @wingetbot do the same thing while it is creating "Automatic Update" PRs?

* Move Update Prompt outside of Read-Info for clarity
* Update Messages
@vedantmgoyal9
Copy link
Author

Can we move code from functions like Test-Manifest, Submit-Manifest, Read-WinGet-MandatoryInfo, Read-PreviousWinGet-Manifest-Yaml, Show-OptionMenu at the last as you have done in commit 1f614b5

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

We have to do this part also?

Edit: I just now realised that does @wingetbot do the same thing while it is creating "Automatic Update" PRs?

We will have to add in the functionality to automatically delete old versions, yes, but we don't want to stack too many features into a single PR. The reason for this is that it makes any single change less likely to break the code. It's much easier to roll back a single feature to undo a mistake than it is to roll back all the features in a large PR and figure out which one caused the error. A rule of thumb I like to follow is to have one issue per PR unless they are extremely closely related.

I did create #32 so we can track working on the deletion of previous manifests; I don't believe it is necessary to complete to merge the quick updates in though, since Esco has it mentioned as an "additional feature" in the original request

@Trenly Trenly closed this Sep 18, 2021
@Trenly Trenly reopened this Sep 18, 2021
@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

Can we move code from functions like Test-Manifest, Submit-Manifest, Read-WinGet-MandatoryInfo, Read-PreviousWinGet-Manifest-Yaml, Show-OptionMenu at the last as you have done in commit 1f614b5

Yes, we can move code outside of functions if it makes sense to do so; However, if you do this you have to be very careful to respect program flow. More than once I've moved something outside of a function thinking it would be fine, only to find out later that the program flow wasn't quite the way I thought it was.

There are a few reasons that we would also want to use functions; 1) Repeated code; The test and submit functions are common to all of the options, so it makes the most sense to have them as a function; 2) Readability; Even if you can do something without a function, sometimes having a named function makes it easier for others to understand the intent of the code

Tl;dr - Yes, in some cases, we just should be careful about it

@vedantmgoyal9 vedantmgoyal9 marked this pull request as ready for review September 18, 2021 05:23
@vedantmgoyal9
Copy link
Author

vedantmgoyal9 commented Sep 18, 2021

@Trenly Quick Update does not take Installer Switches from previous manifest.
image
Edit: It takes Installer Switches but why winget displays a warning 🤔?

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

@Trenly Quick Update does not take Installer Switches from previous manifest.
Edit: It takes Installer Switches but why winget displays a warning 🤔?

It is because winget sees they are empty strings; Even if the values are defined, if the strings are empty then they are handled as if they are not specified

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

@OfficialEsco Some pretty big restructures in this one; If you have any issues with it, please let us know. I'd like to merge this in before I start working on #30

Copy link
Collaborator

@OfficialEsco OfficialEsco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually feels like this is ready to go tbh

@Trenly
Copy link
Owner

Trenly commented Sep 18, 2021

It actually feels like this is ready to go tbh
Sweet! I'll merge it in soon then

@Trenly Trenly merged commit f3f1b90 into Trenly:YamlParsing Sep 18, 2021
@Trenly Trenly deleted the patch-9 branch September 18, 2021 16:41
Trenly added a commit that referenced this pull request Sep 27, 2021
…aller Architectures, and Comments (#27)

* Update YamlCreate.ps1

* auto-detect installer architecture

* Fix #27 (comment)

* Fix auto-detection

* Apply suggestions from code review

Co-authored-by: Kaleb Luedtke <[email protected]>

* Move Test + Submit to main

* Update Tools/YamlCreate.ps1

* fix quick-update check

* Reduce input required for quick version update (#4)

* Reduce input required for quick version update

* Fix Product Code

* Don't add null product code if no product code key exists

* improve quick update

* Move prompt outside of Read-Info for clarity

* Move Update Prompt outside of Read-Info for clarity

* Update Messages

* if there are any errors due to this commit, i will revert changes

* Add Comments for code clarity

Co-authored-by: Kaleb Luedtke <[email protected]>
Trenly added a commit that referenced this pull request Oct 13, 2021
…aller Architectures, and Comments (#27)

* Update YamlCreate.ps1

* auto-detect installer architecture

* Fix #27 (comment)

* Fix auto-detection

* Apply suggestions from code review

Co-authored-by: Kaleb Luedtke <[email protected]>

* Move Test + Submit to main

* Update Tools/YamlCreate.ps1

* fix quick-update check

* Reduce input required for quick version update (#4)

* Reduce input required for quick version update

* Fix Product Code

* Don't add null product code if no product code key exists

* improve quick update

* Move prompt outside of Read-Info for clarity

* Move Update Prompt outside of Read-Info for clarity

* Update Messages

* if there are any errors due to this commit, i will revert changes

* Add Comments for code clarity

Co-authored-by: Kaleb Luedtke <[email protected]>
denelon added a commit to microsoft/winget-pkgs that referenced this pull request Nov 3, 2021
* Install powershell-yaml

* Enforce ordering of keys

* Create function for adding list parameters

* Write Version Manifest using Yaml Parser

* Add To-Do Section

* Rebase on master and cleanup commit history

* Revert inadvertent changes from testing

* Implement logic for installers using YAML parser

* Fix statement in incorrect position

* Remove RAW writing

* Begin reading MultiManifests using Yaml parser

* Cleanup unneeded variables

* Bump Version

* Read parameters from singletons

* Add Product Code

* Abstract ReadInstallerManifest to sub-function

* Fix: Handle uninitialized variables

* Merge New/Update, add EditMetadata

* Fix: Change EditMetadata to work on singleton manifests

* Fix: Update Git commit messages for accuracy

* Remove Empty Manifest Folders

* Fix: Correct text

* Fix: Remove code for testing

* Feature: If old manifests exist, update in place to preserve extra keys

* Fix: Null Error when creating new

* Fix: Cast only when installer code

* Fix: Respect installer locale

* Fix: Use UTF8 Encoding

* Sort Yaml Keys

* Git error handling

* Fixed Moniker prompt for NewLocale

* minItems, maxItems, pattern, variable fix

* Implemented minItems from Schema
* Implemented maxItems from Schema
* Implemented pattern from Schema
* Implemented available Architecture's from Schema
* Implemented available InstallerType's from Schema
* Added $script: to some variables which needs to stay throughout the script

Only tested with one manifest as of now

Cleanup If/Else logic & Rebase on master

* Update method of getting Product Code from installer

* SignatureSha256 and PackageFamilyName (#5)

* More CommitTypes

* Fill in PR Parameters #21940 (#4)

* Detect PackageFamilyName for MSIX/APPX (#8)

* Update YamlCreate.ps1

* Update YamlCreate.ps1

* Exclude .validation (#9)

* Exclude .validation

* Added exclude to ExistingVersions

Co-authored-by: Levvie - she/her <[email protected]>

* Add new line for PackageFamilyName (#10)

* Standardize Keypress Menus (#11)

* Standardize Keypress Menus

* Fix: Use variable instead of pipeline

* Fix Help Texts & Spacing

* Cleanup Git Messages

* Filter by Yaml

* Remove debugging line

Co-authored-by: Esco <[email protected]>

Co-authored-by: Kaleb Luedtke <[email protected]>
Co-authored-by: Esco <[email protected]>

* Replaced PrBodyContentReply `n with array (#12)

* Menu reduction (#13)

* Simplify Code + Make Issues Entry Safer

* Check issue validity

* Fix unintended Revert

Co-authored-by: Esco <[email protected]>

* Fix unintended Revert

Co-authored-by: Esco <[email protected]>

* Fix unintended Revert

Co-authored-by: Esco <[email protected]>

Co-authored-by: Esco <[email protected]>

* More patterns (#15)

Added pattern for

* PackageIdentifier
* PackageVersion
* PackageFamilyName
* PackageLocale

* Readability (#16)

* Add Comparison Functions for Readability

* Simplify Validation Function

* Fix: Missing text

* Remove spaces from split function

* Fix: Resolve renamed variable

* Validate Installer Modes

* Validate File Extensions with Pattern and Length

* Add Custom Error Class (#18)

* Create function for adding list parameters

* Remove RAW writing

* Remove Empty Manifest Folders

* minItems, maxItems, pattern, variable fix

* Implemented minItems from Schema
* Implemented maxItems from Schema
* Implemented pattern from Schema
* Implemented available Architecture's from Schema
* Implemented available InstallerType's from Schema
* Added $script: to some variables which needs to stay throughout the script

* Add Custom Error Class

* Cleanup Class Constructor

* Additional error messages + cleanup

* Continue adding error messages

* Switched Local formatter to OTBS + Static Strings (Where applicable)

* Fix Spacing

* Remove unused variables from rebase

Co-authored-by: Esco <[email protected]>

* Fix: Check for package before do-until

* Finish Locale Errors

* Fix Spacing Issues

* Make Enums Case Sensitive

* Fix Unique Items + Incorrect Variables

Co-authored-by: Esco <[email protected]>

* Subfolder fix (#21)

* Fix: Subfolder Exists Erroring

* Return

* Write Unused Keys as Comments (#22)

* Write Unused Keys as Comments

* Exclude certain keys from appearing as comments

* Comment only Locale + Version

* Quick Update, Function Reduction, Detect Installer Types, Detect Installer Architectures, and Comments (#27)

* Update YamlCreate.ps1

* auto-detect installer architecture

* Fix Trenly#27 (comment)

* Fix auto-detection

* Apply suggestions from code review

Co-authored-by: Kaleb Luedtke <[email protected]>

* Move Test + Submit to main

* Update Tools/YamlCreate.ps1

* fix quick-update check

* Reduce input required for quick version update (#4)

* Reduce input required for quick version update

* Fix Product Code

* Don't add null product code if no product code key exists

* improve quick update

* Move prompt outside of Read-Info for clarity

* Move Update Prompt outside of Read-Info for clarity

* Update Messages

* if there are any errors due to this commit, i will revert changes

* Add Comments for code clarity

Co-authored-by: Kaleb Luedtke <[email protected]>

* Fix error from when functions were moved

* Handle Manifest Level Parameters (#34)

* Begin Handling Manifest Level Parameters

* Fix InstallModes

* Add delete manifest functionality (#39)

* Add functionality to manually delete manifests

* Add settings file and script documentation (#38)

* Do not default installer locale

* Add a script settings file with documentation

* Add setting to suppress quick update warning

* Remove accidental file inclusion

* Fix: Update SignatureSha256 in quick update mode (#41)

* Change Settings to allow for negative suppression (#46)

* Change Settings to allow for negative suppression

* Fix sample settings file

* Invalid SandboxTest variable

Co-authored-by: Vedant Mohan Goyal <[email protected]>

Co-authored-by: Kaleb Luedtke <[email protected]>
Co-authored-by: Esco <[email protected]>
Co-authored-by: Vedant Mohan Goyal <[email protected]>

* Cleaner references to linked issues (#49)

* Command Line Arguments (#50)

* Add switch for settings

* Allow PackageIdentifier and PackageVersion to be passed as optional parameters

* Add -help switch and documentation

* Settings File Location

* Fix spacing issue [Trenly#49] Trenly#51

Co-authored-by: Kaleb Luedtke <[email protected]>
Co-authored-by: Vedant Mohan Goyal <[email protected]>

* Fix Parameter Reading and Condensing(#54)

* Fix: Allow InstallerSwitch keys to be split between installer level and manifest level on a per-key basis

* Fix: Save parameters to variables before removing them from manifest level

* Fix: Sandboxtest not working

* Fix: Prompt for PFN if file does not exist (#55)

* Auto Mode (#58)

* Auto Mode

* Fix for same version

* Keep ProductCodes for .exe files

* Keep ProductCodes for .exe files in Option-2

* Simplify function names, add debug info (#62)

* Fix: Allow autoupdate to update old package versions (#66)

* Make Simple Update automatically detect Sha256, SignatureSha256, and ProductCode without prompts (#61)

* Make Simple Update automatically detect Sha256, SignatureSha256, and ProductCode without prompts

* Add Parameter Mode (#64)

* Add Parameter Mode

* Update YamlCreate.ps1

* Update YamlCreate.md

Co-authored-by: Vedant Mohan Goyal <[email protected]>

* Use Unique Branch Names (#67)

* Use Unique Branch Names

* Process Branch Names Safely

* Fix: Allow values other than en-US for default locale (#70)

* Made it so git config was only modified for the local repo. (#72)

* Only modify git config for local repo.

* Fixed 2214.

* Support for settings on Linux and macOS (#73)

* Support for settings on Linux and macOS

* Easton's suggestion

* Update YamlCreate.md

* Update Tools/YamlCreate.ps1

Co-authored-by: Kaleb Luedtke <[email protected]>

* Update YamlCreate.ps1

Co-authored-by: Kaleb Luedtke <[email protected]>

* Check for open PR's before submitting (#69)

* Check for open PR's before submitting

* Rebase on c82b39f

* Use API instead of CLI

* Exit when user-choice to terminate

Co-authored-by: Vedant Mohan Goyal <[email protected]>

Co-authored-by: Vedant Mohan Goyal <[email protected]>

* Throw when script error (#74)

* Fix: Add locale when converting from singleton (#75)

* Fix: Branch names when deleting (#79)

* Fix: Don't check for PRs on deletion (#80)

* Update PR Content when removing a manifest (#82)

* Update PR Content when removing a manifest

* More realistic character count limits

* Add is:pr to exclude issues from results (#88)

* Ensure file names are valid before saving (#85)

* Ensure file names are valid before saving

* Fix: Catch when content disposition doesn't exist

* Fix UserAgent not following redirects

* Additional Web Request Parameters

* Fix: Min descriptor length + Agent

* Fix: Escape Regex in variables (#91)

* Fix: Only add moniker to defaultLocale (#92)

* Chore: Add references to YamlCreate documentation (#93)

* Typo (#94)

* Chore: Add note to enable settings

Co-authored-by: denelon <[email protected]>

* Chore: Remove To-do message

* Update YamlCreate.ps1

* Move integer validation (#99)

* Rename String.Validate -> Test-String (#101)

* Suppress Write-Host warnings from ScriptAnalyzer

* Fix missing constructor parameter

* Rename Write-Locale-Manifests -> Write-LocaleManifest

* Rename Write-Version-Manifest -> Write-VersionManifest

* Rename Write-Installer-Manifest -> Write-InstallerManifest

* Rename Read-WinGet-LocaleManifest -> Read-LocaleMetadata

* Rename Read-WinGet-InstallerManifest -> Read-InstallerMetadata

* Rename Read-Installer-Values-Minimal -> Read-QuickInstallerEntry

* Rename Read-Installer-Values -> Read-InstallerEntry

* Rename Enter-PR-Parameters -> Read-PRBody

* Rename Write-Colors -> Write-MulticolorLine

* Use Named Parameters for AddYamlParameter

* Use Named Parameters for AddYamlListParameter

* Use Named Parameters for PromptInstallerManifestValue

* Support ShouldProcess for removing manifests

* Move Downloading of installer to a separate function

* More function name updates

* Fix: Download Method (#107)

* Check for version when setting proxy (#109)

* Use defaultLocale due to microsoft/winget-cli#1646 resolving microsoft/winget-cli#1595

Co-authored-by: Esco <[email protected]>
Co-authored-by: Vedant Mohan Goyal <[email protected]>
Co-authored-by: Levvie - she/her <[email protected]>
Co-authored-by: Kaleb Luedtke <[email protected]>
Co-authored-by: Easton Pillay <[email protected]>
Co-authored-by: denelon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants