lib/clientlib.js
function writeClientLibXml(item, options) {
    var content = '<?xml version="1.0" encoding="UTF-8"?>' +
        '<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' +
        ' jcr:primaryType="cq:ClientLibraryFolder"';

    if (item.hasOwnProperty('categories')) {
        var fieldValue = item.categories.join(',');
        content += ' categories="[' + fieldValue + ']"';
    } else {
        content += ' categories="[' + item.name + ']" ';
    }

    clientLibDirectoryFields.forEach(function (fieldKey) {
      if (item.hasOwnProperty(fieldKey)) {
          if (typeof item[fieldKey] === 'boolean') {
            // Boolean value
            content += ' ' + fieldKey + '="{Boolean}' + item[fieldKey] + '"';
          } else if (Array.isArray(item[fieldKey])) {
            // Array of strings
            var fieldValue = item[fieldKey].join(',');
            content += ' ' + fieldKey + '="[' + fieldValue + ']"';
          } else if (typeof item[fieldKey] === 'string') {
            // String value
            content += ' ' + fieldKey + '="' + item[fieldKey] + '"';
          }
      }
    });

    content += "/>";
    var outputPath = item.outputPath || path.join(item.path, item.name);
    var contentXml = path.join(outputPath + "/.content.xml");

    options.verbose && console.log("write clientlib json file: " + contentXml);

    fse.writeFileSync(contentXml, content);
}
function writeClientLibXml(item, options) {
    var content = '<?xml version="1.0" encoding="UTF-8"?>' +
        '<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' +
        ' jcr:primaryType="cq:ClientLibraryFolder"';

    if (item.hasOwnProperty('categories')) {
        var fieldValue = item.categories.join(',');
        content += ' categories="[' + fieldValue + ']"';
    } else {
        content += ' categories="[' + item.name + ']" ';
    }

    clientLibDirectoryFields.forEach(function (fieldKey) {
      if (item.hasOwnProperty(fieldKey)) {
          if (typeof item[fieldKey] === 'boolean') {
            // Boolean value
            content += ' ' + fieldKey + '="{Boolean}' + item[fieldKey] + '"';
          } else if (Array.isArray(item[fieldKey])) {
            // Array of strings
            var fieldValue = item[fieldKey].join(',');
            content += ' ' + fieldKey + '="[' + fieldValue + ']"';
          } else if (typeof item[fieldKey] === 'string') {
            // String value
            content += ' ' + fieldKey + '="' + item[fieldKey] + '"';
          }
      }
    });

    content += "/>";
    var outputPath = item.outputPath || path.join(item.path, item.name);
    var contentXml = path.join(outputPath + "/.content.xml");

    options.verbose && console.log("write clientlib json file: " + contentXml);

    fse.writeFileSync(contentXml, content);
}
function writeClientLibXml ( item , options ) { var content = '<?xml version="1.0" encoding="UTF-8"?>' + '<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"' + ' jcr:primaryType="cq:ClientLibraryFolder"' ; if ( item . hasOwnProperty ( 'categories' ) ) { var fieldValue = item . categories . join ( ',' ) ; content += ' categories="[' + fieldValue + ']"' ; } else { content += ' categories="[' + item . name + ']" ' ; } clientLibDirectoryFields . forEach ( function ( fieldKey ) { if ( item . hasOwnProperty ( fieldKey ) ) { if ( typeof item [ fieldKey ] === 'boolean' ) { // Boolean value content += ' ' + fieldKey + '="{Boolean}' + item [ fieldKey ] + '"' ; } else if ( Array . isArray ( item [ fieldKey ] ) ) { // Array of strings var fieldValue = item [ fieldKey ] . join ( ',' ) ; content += ' ' + fieldKey + '="[' + fieldValue + ']"' ; } else if ( typeof item [ fieldKey ] === 'string' ) { // String value content += ' ' + fieldKey + '="' + item [ fieldKey ] + '"' ; } } } ) ; content += "/>" ; var outputPath = item . outputPath || path . join ( item . path , item . name ) ; var contentXml = path . join ( outputPath + "/.content.xml" ) ; options . verbose && console . log ( "write clientlib json file: " + contentXml ) ; fse . writeFileSync ( contentXml , content ) ; }
Write a configuration XML file for a clientlib
with the given properties in `item`
@param {ClientLibItem} item - clientlib configuration properties
@param {Object} options - further options
Write a configuration XML file for a clientlib with the given properties in item