示例#1
0
    _.forEach(docs, function(doc) {
      if ( doc.docType === 'error' ) {

        // Parse out the error info from the id
        parts = doc.name.split(':');
        doc.namespace = parts[0];
        doc.name = parts[1];


        var namespaceDoc = errorNamespaces[doc.namespace];
        if ( !namespaceDoc ) {
          // First time we came across this namespace, so create a new one
          namespaceDoc = errorNamespaces[doc.namespace] = {
            area: doc.area,
            name: doc.namespace,
            errors: [],
            path: path.dirname(doc.path),
            outputPath: path.dirname(doc.outputPath) + '.html',
            docType: 'errorNamespace'
          };
        }

        // Add this error to the namespace
        namespaceDoc.errors.push(doc);
        doc.namespace = namespaceDoc;

        doc.formattedErrorMessage = minerrInfo.errors[doc.namespace.name][doc.name];

      }

    });
示例#2
0
// config has
//   files: [] - optional array of globs - defaults to all js, ts, html, json, css and md files (with certain files removed)
//   description: optional string - description of this plunker - defaults to the title in the index.html page.
//   tags: [] - optional array of strings
//   main: string - filename of what will become index.html in the plunker - defaults to index.html
function buildPlunkerFrom(configFileName, basePath, destPath) {
  // replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name;
  var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + 'plnkr.no-link.html';
  var altFileName;
  if (destPath && destPath.length > 0) {
    var partPath = path.dirname(path.relative(basePath, outputFileName));
    var altFileName = path.join(destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.');
  }
  try {
    var config = initConfigAndCollectFileNames(configFileName);
    var postData = createPostData(config);
    addPlunkerFiles(config, postData);
    var html = createPlunkerHtml(postData);
    fs.writeFileSync(outputFileName, html, 'utf-8');
    if (altFileName) {
      var altDirName = path.dirname(altFileName);
      if (!fs.existsSync(altDirName)) {
        mkdirp.sync(altDirName);
      }
      fs.writeFileSync(altFileName, html, 'utf-8');
    }
  } catch (e) {
    // if we fail delete the outputFile if it exists because it is an old one.
    if (existsSync(outputFileName)) {
      fs.unlinkSync(outputFileName);
    }
    if (altFileName && existsSync(altFileName)) {
      fs.unlinkSync(altFileName);
    }
    throw e;
  }
}
示例#3
0
  function getLinkInfoImpl(url, title, currentDoc) {
    var linkInfo = {url: url, type: 'url', valid: true, title: title || url};

    if (!url) {
      throw new Error('Invalid url');
    }

    var docs = getDocFromAlias(url, currentDoc);

    // Give each disambiguator a chance to reduce the number of ambiguous docs
    docs = getLinkInfoImpl.disambiguators.reduce(function(docs, disambiguator) {
      return disambiguator(url, title, currentDoc, docs);
    }, docs);

    if (!getLinkInfoImpl.useFirstAmbiguousLink && docs.length > 1) {
      linkInfo.valid = false;
      linkInfo.errorType = 'ambiguous';
      linkInfo.error = 'Ambiguous link: "' + url + '".\n' + docs.reduce(function(msg, doc) {
        return msg + '\n  "' + doc.id + '" (' + doc.docType + ') : (' + doc.path + ' / ' +
            doc.fileInfo.relativePath + ')';
      }, 'Matching docs: ');

    } else if (docs.length >= 1) {
      linkInfo.url = docs[0].path;
      linkInfo.title = title || encodeCodeBlock(docs[0].name, true);
      linkInfo.type = 'doc';

      if (getLinkInfoImpl.relativeLinks && currentDoc && currentDoc.path) {
        var currentFolder = path.dirname(currentDoc.path);
        var docFolder = path.dirname(linkInfo.url);
        var relativeFolder =
            path.relative(path.join('/', currentFolder), path.join('/', docFolder));
        linkInfo.url = path.join(relativeFolder, path.basename(linkInfo.url));
        log.debug(currentDoc.path, docs[0].path, linkInfo.url);
      }

    } else if (url.indexOf('#') > 0) {
      var pathAndHash = url.split('#');
      linkInfo = getLinkInfoImpl(pathAndHash[0], title, currentDoc);
      linkInfo.url = linkInfo.url + '#' + pathAndHash[1];
      return linkInfo;

    } else if (url.indexOf('/') === -1 && url.indexOf('#') !== 0) {
      linkInfo.valid = false;
      linkInfo.errorType = 'missing';
      linkInfo.error = 'Invalid link (does not match any doc): "' + url + '"';

    } else {
      linkInfo.title =
          title || ((url.indexOf('#') === 0) ? url.substring(1) : path.basename(url, '.html'));
    }

    return linkInfo;
  };
示例#4
0
function zipExample(configFileName, sourceDirName, outputDirName) {
  var json = jsonfile.readFileSync(configFileName);
  var fileGlobs = json.files;
  var zipRegionName = json.zipRegion;

  // assert that fileGlobs is an array
  assert.arrayOfString(fileGlobs, 'files property should be an array of strings');

  // backup two from the relative configFileName
  var relativeDirName = path.dirname(path.dirname(path.relative(sourceDirName, configFileName)));
  var configDirName = path.dirname(configFileName);
  // use the dir name of the folder containing the config file as the base file name of the zip file
  var baseFileName = path.basename(configDirName);
  // check if there is a prefix name before zipconfig.json
  if (configFileName.indexOf('.zipconfig.json') >= 0) {
    // if so use it as a suffix to the baseFileName
    var extraName = path.basename(configFileName, '.zipconfig.json');
    baseFileName = baseFileName + "." + extraName;
  }

  var outputFileName = path.join(outputDirName, relativeDirName, baseFileName + ".zip");
  // old code
  // var fileNames = globule.find(fileGlobs, { srcBase: configDirName, prefixBase: configDirName });
  fileGlobs = fileGlobs.map(function(fileGlob) {
    return path.join(configDirName, fileGlob);
  });
  var fileNames = globby.sync(fileGlobs, { ignore: ["**/node_modules/**"] });

  var zip = createZipArchive(outputFileName);
  fileNames.forEach(function(fileName) {
    var relativePath = path.relative(configDirName, fileName);
    var content = fs.readFileSync(fileName, 'utf8');
    var extn = path.extname(fileName).substr(1);
    // if we don't need to clean up the file then we can do the following.
    // zip.append(fs.createReadStream(fileName), { name: relativePath });
    var output;
    // if no zipRegion or zipRegion is not in content then just clean the content
    if (zipRegionName != null) {
      output = regionExtractor.getRegionDoc(content, extn, zipRegionName);
    }
    if (!output) {
      output = regionExtractor.removeDocTags(content, extn);
    }

    zip.append(output, { name: relativePath } )
  });

  zip.finalize();
}
示例#5
0
Container.prototype.create = function(id, parent) {
  if (parent && id[0] == '.') {
    // resolve relative component ID
    id = path.join(path.dirname(parent.id), id);
  }
  var psource = parent ? this._sources[parent._hs] : undefined;
  
  // built-ins
  switch (id) {
  case '!container':
    return new InjectedContainer(this, psource && psource.namespace);
  }
  
  
  id = this.resolve(id, parent);
  
  var spec = this._specs[id];
  if (!spec) {
    // No specification is registered with the given ID.  Attempt to register
    // the specification by loading its corresponding module.
    this._loadSpec(id);
  }
  
  spec = this._specs[id];
  if (!spec) {
    // After attemting auto-loading, the component ID is still unregistered,
    // which is a terminal condition.
    throw new Error('Unable to create object "' + id + '" required by: ' + (parent && parent.id || 'unknown'));
  }
  
  var obj = spec.create(this);
  this.emit('create', obj, spec);
  return obj;
}
示例#6
0
  each: function(doc) {
    if ( doc.fileType === 'js' ) {

      checkProperty(doc, 'section');
      checkProperty(doc, 'id');

      var parts = codeName.getAbsCodeNameParts(doc, doc.id);

      doc.path = codeName.getCodePath(doc, parts);

      // Strip off any hash fragment...
      // If the parts don't contain a "name" then it is a module, in which case use index.html
      doc.outputPath = partialFolder + '/' + doc.path.split('#').shift() + (parts.name ? '.html' : '/index.html');

    } else {
      var folderName = path.dirname(doc.file);
      var fileName = path.basename(doc.file, '.' + doc.fileType);
      if ( fileName === 'index' ) {
        // Don't include "index" on the end of the path
        doc.path = folderName;
        doc.outputPath = partialFolder + '/' + doc.path + '/index.html';
      } else {
        doc.path = folderName + '/' + fileName;
        doc.outputPath = partialFolder + '/' + folderName + '/' + fileName + '.html';
      }
    }
  }
示例#7
0
Container.prototype.create = function(id, parent) {
  if (parent && id[0] == '.') {
    // resolve relative component ID
    id = path.join(path.dirname(parent.id), id);
  }
  
  // built-ins
  switch (id) {
  case '!container':
    // TODO: Get the source prefix and pass it here.   Isolate introspected specs
    //       to the prefix.
    return new InjectedContainer(this);
  }
  
  
  id = this.resolve(id, parent && parent.id);
  
  var spec = this._specs[id];
  if (!spec) {
    // No specification is registered with the given ID.  Attempt to register
    // the specification by loading its corresponding module.
    this._loadSpec(id);
  }
  
  spec = this._specs[id];
  if (!spec) {
    // After attemting auto-loading, the component ID is still unregistered,
    // which is a terminal condition.
    throw new Error("Unable to create object '" + id + "'");
  }
  
  var obj = spec.create(this);
  this.emit('create', obj, spec);
  return obj;
}
示例#8
0
 exports.forEach(function (e) {
     var basePath = renderer_1.stripExtension(e.from);
     var relativePath = './' + canonical_path_1.relative(canonical_path_1.dirname(entryPointBasePath), basePath);
     var exportFrom = entryPointBasePath !== basePath ? " from '" + relativePath + "'" : '';
     var exportStr = "\nexport {" + e.identifier + "}" + exportFrom + ";";
     output.append(exportStr);
 });
示例#9
0
 return promise.then(() => {
   const examplePath = path.dirname(specPath);
   return runE2eTestsSystemJS(examplePath, outputFile).then(ok => {
     const arr = ok ? status.passed : status.failed;
     arr.push(examplePath);
   });
 });
示例#10
0
        exList.each((i, elt) => {
            const text = $(elt).text();
            log.debug(`Found example: ${enclosedByName} ${eltId}`, text);
            const matches = text.match(/{@example\s+([^\s]+)(\s+region=[\'\"]?(\w+)[\'\"]?)?\s*}/);
            if (!matches) {
                log.warn(enclosedByName, eltId, 'has an invalidly formed @example tag:', text);
                return true;
            }
            const exRelPath = matches[1];
            const region = matches[3];

            const dir = path.dirname(exRelPath)
            const extn = path.extname(exRelPath);
            const baseName = path.basename(exRelPath, extn);
            const fileNameNoExt = baseName + (region ? `-${region}` : '')
            const exFragPath = path.resolve(fragDir, dir, `${fileNameNoExt}${extn}.md`);
            if (!fs.existsSync(exFragPath)) {
                log.warn('Fragment not found:', exFragPath);
                return true;
            }
            $(elt).empty();
            const md = fs.readFileSync(exFragPath, 'utf8');
            const codeElt = _extractAndWrapInCodeTags(md);
            $(elt).html(codeElt);
            log.silly('Fragment code in html:', $(elt).html());
        });
示例#11
0
 getPath: function(doc) {
   var docPath = path.dirname(doc.fileInfo.relativePath);
   if (doc.fileInfo.baseName !== 'index') {
     docPath = path.join(docPath, doc.fileInfo.baseName);
   }
   return docPath;
 },
示例#12
0
 defaultFn: function(doc) {
   if ( doc.area === 'api' ) {
     // Calculate the module from the second segment of the file path
     // (the first being the area)
     return path.dirname(doc.file).split('/')[1];
   }
 }
示例#13
0
 function ensureDirectoryExistence(filePath) {
   var dirname = path.dirname(filePath);
   if (directoryExists(dirname)) {
     return true;
   }
   ensureDirectoryExistence(dirname);
   fs.mkdirSync(dirname);
 }
示例#14
0
 docs = docs.filter(doc => {
   if (doc.docType === 'package-content') {
     packageContentFiles[dirname(doc.fileInfo.filePath)] = doc;
     return false;
   } else {
     return true;
   }
 });
示例#15
0
 Transformer.prototype.writeFile = function (file) {
     shelljs_1.mkdir('-p', canonical_path_1.dirname(file.path));
     var backPath = file.path + '.bak';
     if (fs_1.existsSync(file.path) && !fs_1.existsSync(backPath)) {
         shelljs_1.mv(file.path, backPath);
     }
     fs_1.writeFileSync(file.path, file.contents, 'utf8');
 };
示例#16
0
  _initConfigAndCollectFileNames(configFileName) {
    var basePath = path.dirname(configFileName);
    var configSrc = fs.readFileSync(configFileName, 'utf-8');
    try {
      var config = (configSrc && configSrc.trim().length) ? JSON.parse(configSrc) : {};
    } catch (e) {
      throw new Error(`Plunker config - unable to parse json file: ${configFileName}\n${e}`);
    }

    var defaultIncludes = ['**/*.ts', '**/*.js', '**/*.css', '**/*.html', '**/*.md', '**/*.json', '**/*.png'];
    if (config.files) {
      if (config.files.length > 0) {
        if (config.files[0].substr(0, 1) == '!') {
          config.files = defaultIncludes.concat(config.files);
        }
      }
    } else {
      config.files = defaultIncludes;
    }
    var includeSpec = false;
    var gpaths = config.files.map(function(fileName) {
      fileName = fileName.trim();
      if (fileName.substr(0,1) == '!') {
        return "!" + path.join(basePath, fileName.substr(1));
      } else {
        includeSpec = includeSpec || /.*\.spec.(ts|js)$/.test(fileName);
        return path.join(basePath, fileName);
      }
    });

    // var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ];
    var defaultExcludes = [
      '!**/typings/**',
      '!**/typings.json',
      '!**/tsconfig.json',
      '!**/*plnkr.*',
      '!**/package.json',
      '!**/example-config.json',
      '!**/tslint.json',
      '!**/.editorconfig',
      '!**/systemjs.config.js',
      '!**/wallaby.js',
      '!**/karma-test-shim.js',
      '!**/karma.conf.js'
    ];

    // exclude all specs if no spec is mentioned in `files[]`
    if (!includeSpec) {
      defaultExcludes = defaultExcludes.concat(['!**/*.spec.*','!**/spec.js']);
    }

    Array.prototype.push.apply(gpaths, defaultExcludes);

    config.fileNames = globby.sync(gpaths, { ignore: ["**/node_modules/**"] });
    config.basePath = basePath;

    return config;
  }
示例#17
0
 return new Promise(function(resolve, reject) {
   var self = this;
   function create(comp) {
     if (!parent || comp._assembly.h == parent._assembly.h) {
       // The object is being created by another object within the same
       // assembly, or by the main script.
       return resolve(comp.create(self));
     } else {
       // The object is being created by an object from another assembly.
       // Most typically, a component interface is requested, allowing dynamic
       // object creation according to the runtime environment and
       // configuration.
       //
       // Assemblies declare the components they export for use by other
       // assemblies.  Any non-exported components are considered private, and
       // usable only within the assembly itself.  Restrictions are put in
       // place to prevent private components from being used outside of their
       // assembly.
       if (!comp._assembly.isExported(comp.id)) {
         return reject(new ComponentCreateError("Private component '" + comp.id + "' required by '" + parent.id + "'"));
       }
       return resolve(comp.create(self));
     }
   }
   
   
   if (ecomp) {
     // A component has been exposed via introspection, and an object is being
     // created from the component specification.  This is a fast path,
     // implemented as an optimization to avoid redundant resolution
     // operations.
     return create(ecomp);
   }
   
   if (parent && id[0] == '.') {
     // resolve relative component ID
     id = path.join(path.dirname(parent.id), id);
   }
   id = this.resolve(id, parent);
   
   var comp = this._components[id];
   if (comp) {
     return create(comp);
   } else {
     var self = this;
     this._loadComponent(id, function(err, comp) {
       if (err instanceof ComponentNotFoundError) {
         // Reject with a more informative error message that indicates the
         // requiring component.  This assists the developer in finding and
         // fixing the cause of error.
         reject(new ComponentNotFoundError("Unable to create component '" + id + "' required by '" + (parent && parent.id || 'unknown') + "'"));
       } else if (err) {
         return reject(err);
       }
       return create(comp);
     });
   }
 }.bind(this));
示例#18
0
/**
 * Handle all write operations.
 *
 * @private
 * @param {string}   relPath Relative path in the ouput directory
 * @param {string}   data    File content
 * @param {publish.writeCallback} cb node fs.write compatible callback
 * @return {undefined}
 */
function write(relPath, data, cb) {
  var target = path.join(context.destination, relPath);

  mkdirp(path.dirname(target), handleErrorCallback(function() {
    fs.writeFileSync(target, data);
    handleErrorCallback(cb)(null, target);
    logger.debug('file written: %s', target);
  }));
}
示例#19
0
 options.styles = _.map(options.styles, function(file) {
     var fileName = path.normalize(file);
   if (/^((https?:)?\/\/)/.test(file)) {
     return file;
   } else {
     fstreams.push(streamFile(file, path.join('css', path.dirname(fileName)), fakeDest));
     return path.join('css', fileName);
   }
 });
示例#20
0
 getId: function(doc) {
   var docPath = doc.name || doc.codeName;
   if ( !docPath ) {
     docPath = path.dirname(doc.fileInfo.relativePath);
     if ( doc.fileInfo.baseName !== 'index' ) {
       docPath = path.join(docPath, doc.fileInfo.baseName);
     }
   }
   return docPath;
 },
 InPlaceFileWriter.prototype.writeFileAndBackup = function (file) {
     shelljs_1.mkdir('-p', canonical_path_1.dirname(file.path));
     var backPath = file.path + '.__ivy_ngcc_bak';
     if (fs_1.existsSync(backPath)) {
         throw new Error("Tried to overwrite " + backPath + " with an ngcc back up file, which is disallowed.");
     }
     if (fs_1.existsSync(file.path)) {
         shelljs_1.mv(file.path, backPath);
     }
     fs_1.writeFileSync(file.path, file.contents, 'utf8');
 };
示例#22
0
    _.forEach(docs, function(doc) {
      if ( !doc.path ) {
        doc.path = path.join(path.dirname(doc.file));
        if ( doc.fileName !== 'index' ) {
          doc.path += '/' + doc.fileName;
        }
      }

      if ( !doc.outputPath ) {
        doc.outputPath = contentsFolder + '/' + doc.path + '.html';
      }
    });
示例#23
0
  _createZipArchive(zipFileName) {
    let dirName = path.dirname(zipFileName);
    fs.ensureDirSync(dirName);
    let output = fs.createWriteStream(zipFileName);
    let archive = archiver('zip');

    archive.on('error', function (err) {
      throw err;
    });

    archive.pipe(output);
    return archive;
  }
示例#24
0
function initConfigAndCollectFileNames(configFileName) {
  var basePath = path.dirname(configFileName);
  var configSrc = fs.readFileSync(configFileName, 'utf-8');
  try {
    var config = (configSrc && configSrc.trim().length) ? JSON.parse(configSrc) : {};
  } catch (e) {
    throw new Error("Plunker config - unable to parse json file: " + configFileName + '\n  ' + e);
  }

  var defaultIncludes = ['**/*.ts', '**/*.js', '**/*.css', '**/*.html', '**/*.md', '**/*.json', '**/*.png'];
  if (config.files) {
    if (config.files.length > 0) {
      if (config.files[0].substr(0, 1) == '!') {
        config.files = defaultIncludes.concat(config.files);
      }
    }
  } else {
    config.files = defaultIncludes;
  }
  var gpaths = config.files.map(function(fileName) {
    fileName = fileName.trim();
    if (fileName.substr(0,1) == '!') {
      return "!" + path.join(basePath, fileName.substr(1));
    } else {
      return path.join(basePath, fileName);
    }
  });

  // var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ];
  var defaultExcludes = [
    '!**/typings/**',
    '!**/typings.json',
    '!**/tsconfig.json',
    '!**/*plnkr.*',
    '!**/package.json',
    '!**/example-config.json',
    '!**/*.spec.*',
    '!**/tslint.json',
    '!**/.editorconfig',
    '!**/systemjs.config.js',
   ];
  Array.prototype.push.apply(gpaths, defaultExcludes);

  config.fileNames = globby.sync(gpaths, { ignore: ["**/node_modules/**"] });
  config.basePath = basePath;

  return config;
}
示例#25
0
var shredSingleDir = function(shredOptions, filePath) {
  shredOptions = resolveShredOptions(shredOptions);
  var fileDir = path.dirname(filePath);
  var relativePath = path.relative(shredOptions.examplesDir, fileDir);
  var examplesDir = path.join(shredOptions.examplesDir, relativePath);
  var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
  var options = {
    includeSubdirs: false,
    examplesDir: examplesDir,
    fragmentsDir: fragmentsDir
  }
  var cleanPath = path.join(fragmentsDir, '*.*')
  return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
    // console.log('Deleted files/folders:\n', paths.join('\n'));
    return shred(options);
  });
}
示例#26
0
var shredSingleJadeDir = function(shredOptions, filePath) {
  shredOptions = resolveShredOptions(shredOptions);
  var fileDir = path.dirname(filePath);
  var relativePath = path.relative(shredOptions.jadeDir, fileDir);
  var jadeDir = path.join(shredOptions.jadeDir, relativePath);

  var options = {
    includeSubdirs: false,
    jadeDir: jadeDir
  }
  // var cleanPath = path.join(jadeDir, '_.*.jade')
  //return delPromise([ cleanPath]).then(function(paths) {
  //  console.log('Deleted files/folders:\n', paths.join('\n'));
  //  return shred(options);
  //});
  return shred(options);
}
示例#27
0
    handler: function(doc, tagName, tagDescription) {
      // Parse out the uri and title
      var tagArgs = parseArgString(tagDescription);
      var unnamedArgs = tagArgs._;
      var uri = unnamedArgs[0];
      var title = tagArgs.title || (unnamedArgs.length > 1 ? unnamedArgs[1] : null);

      // Are there parameters and/or an anchor?
      var matches, paramAnchor = '';
      if (matches = uri.match(/([^\#\?]*)([\#\?].*)/)) {
        uri = matches[1];
        paramAnchor = matches[2];
      }

      // Is this a chapter-relative uri like 'guide/...'?
      if (!uri.match(/^(ts|js|dart)/)) {
        var lang = _self.lang;
        var vers = _self.vers;
        var prevUri = uri;
        uri = path.join(lang, vers, uri);
        log.info('Ajusted linkDocs chapter-relative uri (' + doc.fileInfo.baseName + '): ' + prevUri + ' -> ' + uri);
      }

      var isValid = false;
      var jadePath = path.join('./public/docs', uri + '.jade');
      var key = path.basename(jadePath, '.jade');
      if ( !fs.existsSync(jadePath)) {
        log.warn(createDocMessage('Invalid docs link (unable to locate jade file: "' + jadePath + '")', doc));
      } else {
        isValid = true;
        if (!title) {
          var jsonFilePath = path.join(path.dirname(jadePath), '_data.json');
          if ( fs.existsSync(jsonFilePath)) {
            var jsonObj = jsonFile.readFileSync(jsonFilePath);
            title = jsonObj[key] && jsonObj[key].title;
          }
        }
      }
      var url = path.join('/docs', uri + '.html' + paramAnchor);
      title = title || key || url;

      return isValid ?
        '<a href="' + url + '">' + title + '</a>' :
        '<span>' + title + '</span>';
    }
示例#28
0
    defaultFn: function(doc) {
      var partialFolder = 'partials';
      if ( doc.area === 'api' && doc.docType !== 'overview' ) {
        if ( doc.docType === 'module' ) {
          doc.id = _.template('module:${name}', doc);
          doc.outputPath = _.template('${area}/${name}/index.html', doc);
          doc.path = _.template('${area}/${name}', doc);

        } else if ( doc.name.indexOf('#' ) === -1 ) {
          doc.id = _.template('module:${module}.${docType}:${name}', doc);
          doc.outputPath = _.template('${area}/${module}/${docType}/${name}.html', doc);
          doc.path = _.template('${area}/${module}/${docType}/${name}', doc);

        } else {
          doc.id = doc.name;
          doc.isMember = true;
          doc.memberof = doc.id.split('#')[0];
          // This is a member of another doc so it doesn't need an output path
        }
      } else {
        doc.id = doc.fileName;

        if ( doc.docType === 'error' ) {
          // Parse out the error info from the id
          doc.id = doc.name;
          var parts = doc.id.split(':');
          doc.namespace = parts[0];
          doc.name = parts[1];
        }

        doc.path = path.join(path.dirname(doc.file));
        if ( doc.fileName !== 'index' ) {
          doc.path += '/' + doc.fileName;
        }
        doc.outputPath = doc.path + '.html';
      }

      if ( doc.outputPath ) {
        doc.outputPath = partialFolder + '/' + doc.outputPath;
      }
      
      return doc.id;
    }
示例#29
0
function createZipArchive(zipFileName) {
  var dirName = path.dirname(zipFileName);
  // insure that the folder exists.
  if (!fs.existsSync(dirName)) {
    mkdirp.sync(dirName);
  }
  var output = fs.createWriteStream(zipFileName);
  var archive = archiver('zip');

  output.on('close', function () {
    console.log('zip created: ' + zipFileName + ' (' + archive.pointer() + ' total bytes)');
  });

  archive.on('error', function (err) {
    throw err;
  });

  archive.pipe(output);
  return archive;
}
示例#30
0
module.exports = function loadConfig(configFilePath, defaultConfig) {

  // Default configuration
  defaultConfig = defaultConfig ||  require('./default-config');

  var configModule;
  if (configFilePath) {
    configFilePath = path.resolve(configFilePath);

    log.debug('Loading config %s', configFilePath);

    try {
      configModule = require(configFilePath);
    } catch(e) {
      if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(configFilePath) !== -1) {
        throw new Error('File "'+ configFilePath + '" does not exist!');
      } else {
        throw new Error('Invalid config file!\n  ' + e.stack);
      }
    }
    if (!_.isFunction(configModule)) {
      throw new Error('Config file must export a function!\n' + CONFIG_SYNTAX_HELP);
    }
  } else {
    log.debug('No config file specified.');
    // if no config file path is passed, we define a dummy config module.
    configModule = function() {};
  }

  var config = _.clone(defaultConfig, true);

  // Provide a default basePath
  config.basePath = path.dirname(configFilePath);

  try {
    return configModule(config);
  } catch(e) {
    throw new Error('Error in config file!\n' + e.message + '\n' + e.stack);
  }
};