• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get version from manifest.xml CEP Extension

Guest
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

I have a small application developed with CEP. Is there a way to get the version from manifest.xml ? I make some checks if the version is smaller then version from my server if it is true I show some message for upgrade to a new version.
I avoid to read from file system because it's some problem with os between mac and windows and it appear some bugs, is there another solution for?

TOPICS
Actions and scripting , Windows

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

Don't you hardcode the version number in your app?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

It is hardcoded but not in js or jsx file it is hardcoded in manifest.xml file.
I think a good practice is to add/modify version in manifest.xml like:

 

<ExtensionManifest ExtensionBundleId="examplePanel" ExtensionBundleName="examplePanel" ExtensionBundleVersion="1.0.0" Version="7.0">
<ExtensionList>
<Extension Id="examplePanel.extension" Version="1.0"/>
</ExtensionList>

 

I wana get this ExtensioBundleVersion or Version from manifest.xml. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2019 Nov 06, 2019

Copy link to clipboard

Copied

It's not the right pattern but I made a function which the read manifest.xml and get the ExtensionBundleVersion attribute from file. 

function getPluginVersion() {
    const fs = require('fs');
    const path = csInterface.getSystemPath(SystemPath.EXTENSION);
    const data = fs.readFileSync(`${path}/CSXS/manifest.xml`);

    if (!data) {
        needNewVersion = true;

        return;
    }

    if (window.DOMParser) {
        const parser = new DOMParser();
        const xmlDoc = parser.parseFromString(data.toString(), 'text/xml');
        const children = xmlDoc.children;

        for (let i = 0; i <= children.length; i++) {
            if (children[i] && children[i].getAttribute('ExtensionBundleVersion')) {
                version = children[i].getAttribute('ExtensionBundleVersion');
            }
        }
    }
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2022 Feb 24, 2022

Copy link to clipboard

Copied

LATEST

 

I was not familiar with Node.js, so my mentor taught me this.

function getBundleVersion(){
    var csi = new CSInterface();
    var pth = csi.getExtensions([csi.getExtensionID()])[0].basePath + "/CSXS/manifest.xml";
    var data = window.cep.fs.readFile(pth, cep.encoding.utf8).data;
    var ver = data.match(/(?<=ExtensionBundleVersion\=")[\d\.]+(?=")/);
    if(ver){
        return ver[0];
    }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines