-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
base: main
Are you sure you want to change the base?
Changes from all commits
b152236
d42ab87
447bb68
973aaff
12703ba
60b2eb1
f58855c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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"; | ||||||||||||||
|
||||||||||||||
function writeBuildTempFile(taskName: string, data: any): string { | ||||||||||||||
const tempDir = tl.getVariable("Agent.TempDirectory"); | ||||||||||||||
|
@@ -378,6 +379,35 @@ function updateExtensionManifestTaskIds(manifest: any, originalTaskId: string, n | |||||||||||||
return manifest; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
function updateExtensionManifestsFeatureConstrains(manifest: any): unknown { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
if (!manifest.contributions) { | ||||||||||||||
tl.debug(`No contributions found`); | ||||||||||||||
return manifest; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
const extensionTag = tl.getInput("extensionTag", false) || ""; | ||||||||||||||
const extensionId = `${(tl.getInput("extensionId", false) || manifest.id)}${extensionTag}`; | ||||||||||||||
|
||||||||||||||
manifest.contributions | ||||||||||||||
.filter((c: any) => c.constraints && c.constraints.length > 0) | ||||||||||||||
.forEach((c: any) => { | ||||||||||||||
c.constraints.forEach((constraint: any) => { | ||||||||||||||
if (constraint.properties?.featureId) { | ||||||||||||||
tl.debug(`Extension manifest featureId before: ${constraint.properties.featureId}`); | ||||||||||||||
|
||||||||||||||
const parts = constraint.properties.featureId.split("."); | ||||||||||||||
parts[1] = extensionId; | ||||||||||||||
const newFeatureId = parts.join("."); | ||||||||||||||
constraint.properties.featureId = newFeatureId; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I suspect the publisher may also be overwritten here. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||
|
||||||||||||||
tl.debug(`Extension manifest featureId after: ${newFeatureId}`); | ||||||||||||||
} | ||||||||||||||
}); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
return manifest; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
function updateTaskVersion(manifest: any, extensionVersionString: string, extensionVersionType: string): unknown { | ||||||||||||||
const versionParts = extensionVersionString.split("."); | ||||||||||||||
if (versionParts.length > 3) { | ||||||||||||||
|
@@ -414,6 +444,8 @@ function updateTaskVersion(manifest: any, extensionVersionString: string, extens | |||||||||||||
export async function updateManifests(manifestPaths: string[]): Promise<void> { | ||||||||||||||
const updateTasksVersion = tl.getBoolInput("updateTasksVersion", false); | ||||||||||||||
const updateTasksId = tl.getBoolInput("updateTasksId", false); | ||||||||||||||
const extensionTag = tl.getInput("extensionTag", false); | ||||||||||||||
const updateFeatureConstraints = tl.getBoolInput("updateFeatureConstraints", false); | ||||||||||||||
|
||||||||||||||
if (updateTasksVersion || updateTasksId) { | ||||||||||||||
if (!(manifestPaths && manifestPaths.length)) { | ||||||||||||||
|
@@ -423,7 +455,17 @@ export async function updateManifests(manifestPaths: string[]): Promise<void> { | |||||||||||||
tl.debug(`Found manifests: ${manifestPaths.join(", ")}`); | ||||||||||||||
|
||||||||||||||
const tasksIds = await updateTaskManifests(manifestPaths, updateTasksId, updateTasksVersion); | ||||||||||||||
await updateExtensionManifests(manifestPaths, tasksIds); | ||||||||||||||
await updateExtensionManifestsTaskIds(manifestPaths, tasksIds); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
if (extensionTag && updateFeatureConstraints) { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||||||||||||||
if (!(manifestPaths && manifestPaths.length)) { | ||||||||||||||
manifestPaths = getExtensionManifestPaths(); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
tl.debug(`Found manifests: ${manifestPaths.join(", ")}`); | ||||||||||||||
|
||||||||||||||
await updateExtensionManifestsFeatureConstrains(manifestPaths); | ||||||||||||||
} | ||||||||||||||
Comment on lines
+468
to
469
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
|
@@ -475,7 +517,7 @@ async function updateTaskManifests(manifestPaths: string[], updateTasksId: boole | |||||||||||||
return tasksIds; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async function updateExtensionManifests(manifestPaths: string[], updatedTaskIds: [string, string][]): Promise<void> { | ||||||||||||||
async function updateExtensionManifestsTaskIds(manifestPaths: string[], updatedTaskIds: [string, string][]): Promise<void> { | ||||||||||||||
await Promise.all(manifestPaths.map(async (path) => { | ||||||||||||||
tl.debug(`Patching: ${path}.`); | ||||||||||||||
let originalManifest = await getManifest(path); | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -109,6 +109,7 @@ export default class VSIXEditor { | |||||
private extensionPricing: string = null; | ||||||
private updateTasksVersion = true; | ||||||
private updateTasksId = true; | ||||||
private updateFeatureConstraints = false; | ||||||
|
||||||
constructor( | ||||||
public inputFile: string, | ||||||
|
@@ -203,7 +204,9 @@ export default class VSIXEditor { | |||||
tl.debug("Extracting files to " + dirPath); | ||||||
|
||||||
await this.extractArchive(this.inputFile, dirPath); | ||||||
if (this.versionNumber && this.updateTasksVersion || this.updateTasksId) { | ||||||
|
||||||
if (this.versionNumber && this.updateTasksVersion || this.updateTasksId || | ||||||
this.editIdTag && this.editUpdateFeatureConstraints) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
tl.debug("Look for build tasks manifest"); | ||||||
const extensionManifest = path.join(dirPath, "extension.vsomanifest"); | ||||||
await common.checkUpdateTasksManifests(extensionManifest); | ||||||
|
@@ -344,6 +347,11 @@ export default class VSIXEditor { | |||||
this.updateTasksId = updateTasksId; | ||||||
} | ||||||
|
||||||
public editUpdateFeatureConstraints(updateFeatureConstraints: boolean) { | ||||||
this.validateEditMode(); | ||||||
this.updateFeatureConstraints = updateFeatureConstraints; | ||||||
} | ||||||
|
||||||
private validateEditMode() : void { | ||||||
if (!this.edit) { throw new Error("Editing is not started"); } | ||||||
} | ||||||
|
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.
Do we need this?