Skip to content

Overwrite featureId during packaging #909

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mmajcica
Copy link

@mmajcica mmajcica commented Jun 2, 2024

In the contribution constraints, it is possible to reference the featureId's. FeatureId is composed of publisherId.extensionId.featureName. In case of extension tag being set, these fields do also need to be updated.

For further details check #172

This pull request introduces a new feature to update feature constraints in extension manifests and includes several related changes to the codebase. The most important updates involve adding the functionality to modify featureId properties in constraints, integrating this capability into the build and publish workflows, and updating the task configuration to support this feature.

New Feature: Update Feature Constraints in Extension Manifests

  • Added a new function, updateExtensionManifestsFeatureConstrains, to modify featureId properties in constraints within extension manifests. This function updates the featureId to include the correct extension ID and tag. (BuildTasks/Common/v5/Common.ts, BuildTasks/Common/v5/Common.tsR382-R410)

Workflow Integration

  • Updated the updateManifests function to include logic for updating feature constraints when the new updateFeatureConstraints input is enabled. (BuildTasks/Common/v5/Common.ts, [1] [2]
  • Renamed updateExtensionManifests to updateExtensionManifestsTaskIds for clarity, as it now specifically handles task IDs. (BuildTasks/Common/v5/Common.ts, BuildTasks/Common/v5/Common.tsL478-R520)

Publish Task Enhancements

  • Added a new boolean input, updateFeatureConstraints, to the publish task configuration (task.json). This input allows users to enable or disable the feature constraint update functionality. (BuildTasks/PublishExtension/v5/task.json, BuildTasks/PublishExtension/v5/task.jsonR179-R187)
  • Integrated the updateFeatureConstraints input into the PublishExtension task's workflow, ensuring the VSIX editor processes this new feature when enabled. (BuildTasks/PublishExtension/v5/PublishExtension.ts, [1] [2] [3]

VSIX Editor Updates

  • Added support for the updateFeatureConstraints option in the VSIXEditor class, including a new method editUpdateFeatureConstraints and logic to handle this option during VSIX file processing. (BuildTasks/PublishExtension/v5/vsixeditor.ts, [1] [2] [3]

These changes collectively enhance the flexibility and functionality of the extension publishing process by enabling automated updates to feature constraints in extension manifests.

@mmajcica mmajcica requested a review from jessehouwing as a code owner June 2, 2024 09:28
Mario Majcica added 3 commits June 2, 2024 11:31
const parts = constraint.properties.featureId.split(".");
parts[1] = extensionId;
const newFeatureId = parts.join(".");
constraint.properties.featureId = newFeatureId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are there any cases where people opt into someone else's feature Id? Say, the Microsoft new Boards Hub feature?

I haven't personally used these IDs, so there might be cases that we must keep in mind.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And I suspect the publisher may also be overwritten here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like ideally we'd loop over the feature contributions and then only overwrite the ones that match the same name at least.

https://github.com/gustavobergamim/azdevops-pipeline-approval/blob/master/vss-extension.json#L62-L99

await updateExtensionManifestsTaskIds(manifestPaths, tasksIds);
}

if (extensionTag && updateFeatureConstraints) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if extensionId || extentionTag || publisherId

@@ -7,6 +7,7 @@ import { AzureRMEndpoint } from "azure-pipelines-tasks-azure-arm-rest/azure-arm-
import fse from "fs-extra";
import uuidv5 from "uuidv5";
import tmp from "tmp";
import { forEach } from "core-js/core/array";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this?

const parts = constraint.properties.featureId.split(".");
parts[1] = extensionId;
const newFeatureId = parts.join(".");
constraint.properties.featureId = newFeatureId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like ideally we'd loop over the feature contributions and then only overwrite the ones that match the same name at least.

https://github.com/gustavobergamim/azdevops-pipeline-approval/blob/master/vss-extension.json#L62-L99

@mmajcica
Copy link
Author

mmajcica commented Jun 10, 2024 via email

@jessehouwing
Copy link
Collaborator

Sorry i was busy this weekend, haven't found time for it. But it is on my list to wrap things up and test it.

No problem! The release pipeline is still broken anyway ;). I was just exploring github how people were using features in the manifest to make sure this change won't break anyone.

@jessehouwing
Copy link
Collaborator

@mmajcica stil have plans to carry this forward, or shall we convert this to a draft PR for now?

@jessehouwing jessehouwing requested a review from Copilot January 28, 2025 13:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jessehouwing jessehouwing requested a review from Copilot April 22, 2025 12:55
Copy link
Contributor

@Copilot Copilot AI left a 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 introduces a new flag to update feature constraints during packaging and adjusts corresponding workflows and manifest updates.

  • Added "updateFeatureConstraints" flag and associated edit method in VSIXEditor.
  • Modified PublishExtension to pass through the new feature constraints update.
  • Updated Common utilities with a new manifest update function for feature constraints.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
BuildTasks/PublishExtension/v5/vsixeditor.ts Introduces new flag and method for updating feature constraints; conditional logic updated to include the new feature.
BuildTasks/PublishExtension/v5/PublishExtension.ts Reads and passes the new "updateFeatureConstraints" parameter to VSIXEditor.
BuildTasks/Common/v5/Common.ts Adds a new function to update feature IDs in extension manifests and renames an existing manifest update function.
Files not reviewed (1)
  • BuildTasks/PublishExtension/v5/task.json: Language not supported

if (this.versionNumber && this.updateTasksVersion || this.updateTasksId) {

if (this.versionNumber && this.updateTasksVersion || this.updateTasksId ||
this.editIdTag && this.editUpdateFeatureConstraints) {
Copy link
Preview

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

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

The conditional block references 'this.editIdTag && this.editUpdateFeatureConstraints' which appears to be a mistake since there is no 'editUpdateFeatureConstraints' property; it is likely intended to use 'this.updateFeatureConstraints'.

Suggested change
this.editIdTag && this.editUpdateFeatureConstraints) {
this.editIdTag && this.updateFeatureConstraints) {

Copilot uses AI. Check for mistakes.

@@ -378,6 +379,35 @@ function updateExtensionManifestTaskIds(manifest: any, originalTaskId: string, n
return manifest;
}

function updateExtensionManifestsFeatureConstrains(manifest: any): unknown {
Copy link
Preview

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

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

The function name 'updateExtensionManifestsFeatureConstrains' appears to be misspelled. Consider renaming it to 'updateExtensionManifestsFeatureConstraints' for clarity.

Suggested change
function updateExtensionManifestsFeatureConstrains(manifest: any): unknown {
function updateExtensionManifestsFeatureConstraints(manifest: any): unknown {

Copilot uses AI. Check for mistakes.

Comment on lines +468 to 469
await updateExtensionManifestsFeatureConstrains(manifestPaths);
}
Copy link
Preview

Copilot AI Apr 22, 2025

Choose a reason for hiding this comment

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

The function 'updateExtensionManifestsFeatureConstrains' is being passed 'manifestPaths' (an array) whereas it expects a manifest object. Consider iterating over 'manifestPaths' to load each manifest before processing.

Suggested change
await updateExtensionManifestsFeatureConstrains(manifestPaths);
}
for (const manifestPath of manifestPaths) {
const manifest = await getManifest(manifestPath);
await updateExtensionManifestsFeatureConstrains(manifest);
}

Copilot uses AI. Check for mistakes.

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.

2 participants