Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
vedantmgoyal9 committed Aug 9, 2024
2 parents eb76c8f + 2151b95 commit c6f8f9d
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 38 deletions.
16 changes: 16 additions & 0 deletions doc/new.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,29 @@ By typing **ENTER** you will accept the string, and the wizard will move on.

![new command PackageIdentifier](./images/create-packageidentifier.png)

### Auto-filling manifest fields

If the installer URLs come from a GitHub release, the CLI can automatically fill in missing manifest metadata. A valid GitHub token must be provided using the `--token` argument to use this feature.
The new command flow may automatically fill in the following fields:

- `License` - The license from the GitHub repository.
- `ShortDescription` - The description from the GitHub repository.
- `ReleaseDate` - The publish date of the release on GitHub.
- `ReleaseNotesUrl` - The URL to the release notes on GitHub.
- `PackageUrl` - The URL to the package GitHub repository.
- `PublisherUrl` - The URL to the publisher's GitHub page.
- `PublisherSupportUrl` - The URL to GitHub issues for the package repository.
- `Tags` - The tags from the GitHub repository.
- `Documentations` - If the GitHub repository has a wiki, the URL to the wiki will be added to the manifest.

### Remaining required fields

Like the **PackageIdentifier** you will have the opportunity to accept or modify the remaining fields.

![new command default values](./images/create-defaults.png)

### Review Changes

Once you have successfully filled in the details, fields, **Winget-Create** will display the results for you to review.

![new command review](./images/create-review.png)
Expand Down
36 changes: 26 additions & 10 deletions doc/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The **update** command of the [Winget-Create](../README.md) tool is designed to

## Usage

`wingetcreate.exe update <id> [-u <urls>] [-v <version>] [-s] [-t <token>] [-o <output directory>] [-p <pull request title>] [-r] [<replace version>]`
`wingetcreate.exe update <id> [-u <urls>] [-v <version>] [-s] [-t <token>] [-o <output directory>] [-p <pull request title>] [-r] [<replace version>] [-d <display version>] [--release-date <release date> ] [--release-notes-url <release notes url>] [--format <format>] [--interactive] [--help]`

The **update** command can be called with the installer URL(s) that you wish to update the manifest with. **Please make sure that the number of installer URL(s) included matches the number of existing installer nodes in the manifest you are updating. Otherwise, the command will fail.** This is to ensure that we can deterministically update each installer node with the correct matching installer url provided.

Expand Down Expand Up @@ -34,6 +34,19 @@ e.g.,

`wingetcreate update <PackageIdentifier> --urls '<InstallerUrl1>|x64|user' '<InstallerUrl1>|x64|machine' '<InstallerUrl2>|x86|user' '<InstallerUrl2>|x86|machine'`

### Auto-filling manifest fields

If the installer URLs come from a GitHub release, the CLI can automatically fill in missing manifest metadata. A valid GitHub token must be provided using the `--token` argument to use this feature.
The update flow may automatically fill in the following fields:

- `ReleaseDate` - The publish date of the release on GitHub.
- `ReleaseNotesUrl` - The URL to the release notes on GitHub.
- `PackageUrl` - The URL to the package GitHub repository.
- `PublisherUrl` - The URL to the publisher's GitHub page.
- `PublisherSupportUrl` - The URL to GitHub issues for the package repository.
- `Tags` - The tags from the GitHub repository.
- `Documentations` - If the GitHub repository has a wiki, the URL to the wiki will be added to the manifest.

### Installer URL arguments

The following additional arguments can be provided with the installer URL(s):
Expand Down Expand Up @@ -94,16 +107,19 @@ The following arguments are available:

| Argument | Description |
|--------------|-------------|
| **id** | Required. Package identifier used to lookup the existing manifest on the Windows Package Manager repo.
| **-u, --urls** | Installer Url(s) used to extract relevant metadata for generating a manifest
| **-v, --version** | Version to be used when updating the package version field.
| **-i, --interactive** | Boolean value for making the update command interactive. If true, the tool will prompt the user for input. Default is false.
| **-o, --out** | The output directory where the newly created manifests will be saved locally
| **-s, --submit** | Boolean value for submitting to the Windows Package Manager repo. If true, updated manifest will be submitted directly using the provided GitHub Token
| **-r, --replace** | Boolean value for replacing an existing manifest from the Windows Package Manager repo. Optionally provide a version or else the latest version will be replaced. Default is false.
| **-p, --prtitle** | The title of the pull request submitted to GitHub.
| **id** | Required. Package identifier used to lookup the existing manifest on the Windows Package Manager repo. |
| **-u, --urls** | Installer Url(s) used to extract relevant metadata for generating a manifest |
| **-v, --version** | Version to be used when updating the package version field. |
| **-d, --display-version** | Version to be used when updating the display version field. Version provided in the installer URL arguments will take precedence over this value. |
| **--release-notes-url** | URL to be used when updating the release notes url field. |
| **--release-date** | Date to be used when updating the release date field. Expected format is "YYYY-MM-DD". |
| **-o, --out** | The output directory where the newly created manifests will be saved locally |
| **-p, --prtitle** | The title of the pull request submitted to GitHub. |
| **-s, --submit** | Boolean value for submitting to the Windows Package Manager repo. If true, updated manifest will be submitted directly using the provided GitHub Token |
| **-r, --replace** | Boolean value for replacing an existing manifest from the Windows Package Manager repo. Optionally provide a version or else the latest version will be replaced. Default is false. |
| **-i, --interactive** | Boolean value for making the update command interactive. If true, the tool will prompt the user for input. Default is false. |
| **-f,--format** | Output format of the manifest. Default is "yaml". |
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. If no token is provided, tool will prompt for GitHub login credentials.
| **-t, --token** | GitHub personal access token used for direct submission to the Windows Package Manager repo. If no token is provided, tool will prompt for GitHub login credentials. |
| **-?, --help** | Gets additional help on this command. |

## Submit
Expand Down
7 changes: 5 additions & 2 deletions src/WingetCreateCLI/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,13 @@ public override async Task<bool> Execute()
ShiftRootFieldsToInstallerLevel(manifests.InstallerManifest);
try
{
Logger.InfoLocalized(nameof(Resources.PopulatingGitHubMetadata_Message));
if (this.GitHubClient != null)
{
await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
bool populated = await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
if (populated)
{
Logger.InfoLocalized(nameof(Resources.PopulatedGitHubMetadata_Message));
}
}
}
catch (Octokit.ApiException)
Expand Down
17 changes: 12 additions & 5 deletions src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,13 @@ public async Task<Manifests> UpdateManifestsAutonomously(Manifests manifests)
ResetVersionSpecificFields(manifests);
try
{
Logger.InfoLocalized(nameof(Resources.PopulatingGitHubMetadata_Message));

if (this.GitHubClient != null)
{
await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
bool populated = await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
if (populated)
{
Logger.InfoLocalized(nameof(Resources.PopulatedGitHubMetadata_Message));
}
}
}
catch (Octokit.ApiException)
Expand Down Expand Up @@ -654,9 +656,11 @@ private static void ResetVersionSpecificFields(Manifests manifests)
defaultLocaleManifest.ReleaseNotesUrl = null;

installerManifest.ReleaseDateTime = null;
installerManifest.ReleaseDate = null;
foreach (var installer in installerManifest.Installers)
{
installer.ReleaseDateTime = null;
installer.ReleaseDate = null;
}

foreach (LocaleManifest localeManifest in localeManifests)
Expand Down Expand Up @@ -934,10 +938,13 @@ private async Task<Manifests> UpdateManifestsInteractively(Manifests manifests)
ResetVersionSpecificFields(manifests);
try
{
Logger.InfoLocalized(nameof(Resources.PopulatingGitHubMetadata_Message));
if (this.GitHubClient != null)
{
await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
bool populated = await this.GitHubClient.PopulateGitHubMetadata(manifests, this.Format.ToString());
if (populated)
{
Logger.InfoLocalized(nameof(Resources.PopulatedGitHubMetadata_Message));
}
}
}
catch (Octokit.ApiException)
Expand Down
8 changes: 4 additions & 4 deletions src/WingetCreateCLI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@
<value>Base manifest contains DisplayVersion that has not been updated. Use --display-version CLI arg or provide the version in the installer URL.</value>
</data>
<data name="DisplayVersion_HelpText" xml:space="preserve">
<value>Version to be used when updating the display version field. Version provided in the installer URL arguments will take precendence over this value.</value>
<value>Version to be used when updating the display version field. Version provided in the installer URL arguments will take precedence over this value.</value>
</data>
<data name="UsingDisplayVersion_Message" xml:space="preserve">
<value>Using display version '{0}' for {1}</value>
Expand All @@ -1377,8 +1377,8 @@
<data name="CouldNotPopulateGitHubMetadata_Warning" xml:space="preserve">
<value>Could not populate manifest metadata through GitHub's API.</value>
</data>
<data name="PopulatingGitHubMetadata_Message" xml:space="preserve">
<value>GitHub URL detected. The CLI will automatically fill some manifests fields.</value>
<data name="PopulatedGitHubMetadata_Message" xml:space="preserve">
<value>GitHub URL detected. The CLI has automatically filled some manifest fields.</value>
</data>
<data name="ReleaseDate_HelpText" xml:space="preserve">
<value>Date to be used when updating the release date field. Expected format is "YYYY-MM-DD".</value>
Expand Down
14 changes: 9 additions & 5 deletions src/WingetCreateCore/Common/GitHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,16 @@ public async Task<string> FindPackageId(string packageId)
/// </summary>
/// <param name="manifests">Wrapper object for manifest object models to be populated with GitHub metadata.</param>
/// <param name="serializerFormat">The output format of the manifest serializer.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task PopulateGitHubMetadata(Manifests manifests, string serializerFormat)
/// <returns>A <see cref="Task"/> representing the asynchronous operation. The task result is a boolean indicating whether metadata was successfully populated.</returns>
public async Task<bool> PopulateGitHubMetadata(Manifests manifests, string serializerFormat)
{
// Only populate metadata if we have a valid GitHub token.
if (this.github.Credentials.AuthenticationType != AuthenticationType.Anonymous)
{
await GitHubManifestMetadata.PopulateManifestMetadata(manifests, serializerFormat, this.github);
return await GitHubManifestMetadata.PopulateManifestMetadata(manifests, serializerFormat, this.github);
}

return false;
}

/// <summary>
Expand Down Expand Up @@ -499,15 +501,15 @@ private async Task DeletePullRequestBranch(int pullRequestId)

private static class GitHubManifestMetadata
{
public static async Task PopulateManifestMetadata(Manifests manifests, string serializerFormat, GitHubClient client)
public static async Task<bool> PopulateManifestMetadata(Manifests manifests, string serializerFormat, GitHubClient client)
{
// Get owner and repo from the installer manifest
GitHubUrlMetadata? metadata = GetMetadataFromGitHubUrl(manifests.InstallerManifest);

if (metadata == null)
{
// Could not populate GitHub metadata.
return;
return false;
}

string owner = metadata.Value.Owner;
Expand Down Expand Up @@ -574,6 +576,8 @@ public static async Task PopulateManifestMetadata(Manifests manifests, string se
},
};
}

return true;
}

private static void SetReleaseDate(Manifests manifests, string serializerFormat, Release githubRelease)
Expand Down
Loading

0 comments on commit c6f8f9d

Please sign in to comment.