microsoft / tfs-cli

Cross-platform CLI for Microsoft Team Foundation Server and Visual Studio Team Services
MIT License
372 stars 132 forks source link

Allow flexible manifest specification, including production vs. development differences #342

Closed bworline closed 3 years ago

bworline commented 4 years ago

This PR adds support for webpack-like configuration of the manifest file by giving the option to provide a manifest js file instead of a manifest json file.

From the updated documentation: "Use the --manifest-js option to supply a Node.JS CommonJS module and export a function. The function will be invoked with an environment property bag as a parameter, and must return the manifest JSON object. Environment variables for the property bag are specified with the --env command line parameter. These are space separated key-value pairs, e.g. --env mode=production rootpath="c:\program files" size=large."

This can address scenarios described by the following issues. Fixes #161, Fixes #258.

An example manifest JS file might look like the following. It's inspired by David Hathaway's article on Streamlining Azure DevOps extension development but allows combining the development and release configs.

module.exports = (env) => {
    let [idPostfix, namePostfix] = (env.mode == "development") ? ["-dev", " [DEV]"] : ["", ""];
    let manifest = {
        manifestVersion: 1,
        id: `myextensionidentifier${idPostfix}`,
        name: `My Great Extension${namePostfix}`,
        ...
        contributions: [
            {
                id: "mywidgetidentifier",
                properties: {
                    name: `Super Widget${namePostfix}`,
                    ...
                },
                ...
            }
        ]
    }
    if (env.mode == 'development') {
        manifest.baseUri = "https://localhost:3000";
    }
    return manifest;
}
bworline commented 4 years ago
bworline commented 4 years ago

@stephenmichaelf are you able to look at this PR? If not, can you point me to someone who can?

jtpetty commented 4 years ago

@stephenmichaelf - Can you review this PR?

bworline commented 3 years ago

@dwilsonactual can you merge this PR? I don't have write access.

jessehouwing commented 3 years ago

I don't see how this closes #92. It doesn't seem to process the task.json in each build task extension...

bworline commented 3 years ago

I don't see how this closes #92. It doesn't seem to process the task.json in each build task extension...

Ah, you are correct. I'd confused manifest.json with task.json. I've removed the link to #92.

jessehouwing commented 3 years ago

Would love that functionality though :). There are ways the manifests interact.