• Patson Settachatgul 7
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I'm running on windows 10, sfdx version 6.1.19, and getting an error when I try to pull source froma scratch org.  I feel like I've tracked it down to some code in node_modules\sfdx-cli\node_modules\salesforce-alm\dist\lib\typeDefUtil.js  which seems to assume a POSIX path seperator.  The parameter auraBundleFileProperties is an array of objects representing file properties.  The fullName property doesn't seem consistent in what path separator is being used.  Sometimes it's '/', Sometimes it's '\' -- I was able to solve the issue by changing the line

            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);

to

            const parentBundle = auraBundleFileProperties.find(fileProperty => path.normalize(fileProperty.fullName).split(path.sep)[0] === bundleName);

That seemed to work, but I've obviously hacked the original code delivered by SF... Has anyone else run into this issue?

The function was originally written as...
static getDefaultAggregateMetadataPath(devName, typeDef, defaultSrcDir, metadataRegistry, auraBundleFileProperties) {
        let metadataPath;
        const defaultTypeDir = !util.isNullOrUndefined(typeDef.defaultDirectory) ?
            path.join(defaultSrcDir, typeDef.defaultDirectory) : defaultSrcDir;
        if (typeDef.metadataName === metadataRegistry.typeDefs.AuraDefinitionBundle.metadataName) {
            const bundleName = devName.split(path.sep)[0];
            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);
            const fileName = `${path.basename(parentBundle.fileName)}${metadataRegistry.metadataFileExt}`;
            metadataPath = path.join(defaultTypeDir, bundleName, fileName);
        }
       .... more code.....
}
I'm trying to automate installation of some packages which have custom profiles.  When you're installing manually, there's a step to map the custom profile to an existing profile in the target org.  But, I don't see a way to do that when you're using ANT, or the Metadata API.... Is there a way to do this?
I'm running on windows 10, sfdx version 6.1.19, and getting an error when I try to pull source froma scratch org.  I feel like I've tracked it down to some code in node_modules\sfdx-cli\node_modules\salesforce-alm\dist\lib\typeDefUtil.js  which seems to assume a POSIX path seperator.  The parameter auraBundleFileProperties is an array of objects representing file properties.  The fullName property doesn't seem consistent in what path separator is being used.  Sometimes it's '/', Sometimes it's '\' -- I was able to solve the issue by changing the line

            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);

to

            const parentBundle = auraBundleFileProperties.find(fileProperty => path.normalize(fileProperty.fullName).split(path.sep)[0] === bundleName);

That seemed to work, but I've obviously hacked the original code delivered by SF... Has anyone else run into this issue?

The function was originally written as...
static getDefaultAggregateMetadataPath(devName, typeDef, defaultSrcDir, metadataRegistry, auraBundleFileProperties) {
        let metadataPath;
        const defaultTypeDir = !util.isNullOrUndefined(typeDef.defaultDirectory) ?
            path.join(defaultSrcDir, typeDef.defaultDirectory) : defaultSrcDir;
        if (typeDef.metadataName === metadataRegistry.typeDefs.AuraDefinitionBundle.metadataName) {
            const bundleName = devName.split(path.sep)[0];
            const parentBundle = auraBundleFileProperties.find(fileProperty => fileProperty.fullName.split(path.sep)[0] === bundleName);
            const fileName = `${path.basename(parentBundle.fileName)}${metadataRegistry.metadataFileExt}`;
            metadataPath = path.join(defaultTypeDir, bundleName, fileName);
        }
       .... more code.....
}
For some reason, when I create code within a scratch org, I will often get this error. I've tried troubleshooting it, and it appears to be something related to either a component bundle or a class, but it's impossible to determine which ones. The only work around that I have been able to accomplish is to copy/paste the code to notepad and delete the bundle and class from the scratch org.