获取模块的依赖

@param {string} file 模块文件地址
@param {string} moduleId 模块id
@return {Array}
485358
function getDependencis(file, moduleId) {
    var res = [];

    if (!fs.existsSync(file)) {
        return res;
    }

    var codeAST = amd.getAst(fs.readFileSync(file));
    var info = amd.analyseModule(codeAST);

    var dependencies = info.actualDependencies || [];

    return dependencies.slice(info.factoryAst.params.length).map(function (id) {
        return amd.resolveModuleId(id, moduleId);
    });
}
964721
function parseApiFile(file) {
  const jsDocRegex = /\/\*\*([\s\S]*?)\*\//gm;
  const fileContent = fs.readFileSync(file, { encoding: 'utf8' });
  const ext = path.extname(file);
  const yaml = [];
  const jsDocComments = [];

  if (ext === '.yaml' || ext === '.yml') {
    yaml.push(jsYaml.safeLoad(fileContent));
  } else {
    const regexResults = fileContent.match(jsDocRegex);
    if (regexResults) {
      for (let i = 0; i < regexResults.length; i += 1) {
        const jsDocComment = doctrine.parse(regexResults[i], { unwrap: true });
        jsDocComments.push(jsDocComment);
      }
    }
  }

  return {
    yaml,
    jsdoc: jsDocComments,
  };
}
1081984
function modInitFactoryInvoker( id ) {
        var module = modModules[ id ];
        var invoking;

        module.invokeFactory = invokeFactory;
        each( module.depPMs, function ( pluginModuleId ) {
            modAddDefinedListener( pluginModuleId, function () {
                each( module.depRs, function ( res ) {
                    if ( !res.absId && res.module === pluginModuleId ) {
                        res.absId = normalize( res.id, id );
                        nativeRequire( [ res.absId ], modAutoInvoke );
                    }
                } );
            } );
        } );

        /**
         * 初始化模块
         *
         * @inner
         */
        function invokeFactory() {
            if ( invoking || module.state !== MODULE_PREPARED ) {
                return;
            }

            invoking = 1;

            // 拼接factory invoke所需的arguments
            var factoryReady = 1;
            var factoryDeps = [];
            each(
                module.factoryDeps,
                function ( dep ) {
                    var depId = dep.absId;

                    if ( !BUILDIN_MODULE[ depId ] ) {
                        modTryInvokeFactory( depId );
                        if ( !modIs( depId, MODULE_DEFINED ) ) {
                            factoryReady = 0;
                            return false;
                        }
                    }

                    factoryDeps.push( depId );
                }
            );

            if ( factoryReady ) {
                try {
                    var args = modGetModulesExports(
                        factoryDeps,
                        {
                            require : module.require,
                            exports : module.exports,
                            module  : module
                        }
                    );

                    // 调用factory函数初始化module
                    var factory = module.factory;
                    var exports = typeof factory === 'function'
                        ? factory.apply( global, args )
                        : factory;

                    if ( exports != null ) {
                        module.exports = exports;
                    }

                    module.invokeFactory = null;
                }
                catch ( ex ) {
                    invoking = 0;
                    if ( /^\[MODULE_MISS\]"([^"]+)/.test( ex.message ) ) {
                        // 出错，则说明在factory的运行中，该require的模块是需要的
                        // 所以把它加入强依赖中
                        var hardCirclurDep = module.depMkv[ RegExp.$1 ];
                        hardCirclurDep && (hardCirclurDep.hard = 1);
                        return;
                    }

                    throw ex;
                }

                // 完成define
                // 不放在try里，避免后续的运行错误被这里吞掉
                modDefined( id );
            }
        }
    }
1015040
function addFile( file ) {
            var $li = $( '<li id="' + file.id + '">' +
                    '<p class="title">' + file.name + '</p>' +
                    '<p class="imgWrap"></p>'+
                    '<p class="progress"><span></span></p>' +
                    '</li>' ),

                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span></div>').appendTo( $li ),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find( 'p.imgWrap' ),
                $info = $('<p class="error"></p>'),

                showError = function( code ) {
                    switch( code ) {
                        case 'exceed_size':
                            text = '文件大小超出';
                            break;

                        default:
                            text = '上传失败，请重试';
                            break;
                    }

                    $info.text( text ).appendTo( $li );
                };

            if ( file.getStatus() === 'invalid' ) {
                showError( file.statusText );
            } else {
                // @todo lazyload
                $wrap.text( '预览中' );
                uploader.makeThumb( file, function( error, src ) {
                    if ( error ) {
                        $wrap.text( '不能预览' );
                        return;
                    }

                    var img = $('<img src="'+src+'">');
                    $wrap.empty().append( img );
                }, thumbnailWidth, thumbnailHeight );

                percentages[ file.id ] = [ file.size, 0 ];
                file.ratation = 0;
            }

            file.on('statuschange', function( cur, prev ) {
                if ( prev === 'progress' ) {
                    $prgress.hide().width(0);
                } else if ( prev === 'queued' ) {
                    $li.off( 'mouseenter mouseleave' );
                    $btns.remove();
                }

                // 成功
                if ( cur === 'error' || cur === 'invalid' ) {
                    showError( file.statusText );
                    percentages[ file.id ][ 1 ] = 1;
                } else if ( cur === 'queued' ) {
                    percentages[ file.id ][ 1 ] = 0;
                } else if ( cur === 'progress' ) {
                    $info.remove();
                    $prgress.css('display', 'block');
                }

                $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur );
            });

            $li.on( 'mouseenter', function() {
                $btns.stop().animate({height: 30});
            });

            $li.on( 'mouseleave', function() {
                $btns.stop().animate({height: 0});
            });

            $btns.on( 'click', 'span', function() {
                var index = $(this).index(),
                    deg;

                switch ( index ) {
                    case 0:
                        uploader.removeFile( file );
                        return;

                    case 1:
                        file.ratation += 90;
                        break;

                    case 2:
                        file.ratation -= 90;
                        break;
                }

                // -webkit-transform: rotate(90deg);
                index && (deg = 'rotate(' + file.ratation + 'deg)', $wrap.css({
                    '-webkit-transform': deg,
                    '-mos-transform': deg,
                    '-o-transform': deg,
                    'transform': deg
                }));
            });

            $li.appendTo( $queue );
        }
53818
public function getInfo($module_id)
    {
        static $information = array();

        if (isset($information[$module_id])) {
            return $information[$module_id];
        }

        $file = $this->getModuleInfoFile($module_id);

        $decoded = null;

        if (is_file($file)) {
            $decoded = json_decode(file_get_contents($file), true);
        }

        if (is_array($decoded)) {
            $decoded['id'] = $decoded['module_id'] = $module_id;
            $information[$module_id] = $decoded;
        } else {
            $information[$module_id] = array();
        }

        return $information[$module_id];
    }
710145
function(file) {
			var id = typeof(file) === 'string' ? file : file.id;

			for (var i = files.length - 1; i >= 0; i--) {
				if (files[i].id === id) {
					return this.splice(i, 1)[0];
				}
			}
		}
1358666
function parseModuleId(filepath, transportBase) {
		transportBase = transportBase.replace(/\\/g, "/");
		filepath = filepath.replace(/\\/g, "/");

		var index = filepath.indexOf(transportBase);
		if(transportBase && index > -1) {
			id = filepath.substr(index + transportBase.length).replace(/^\/|\.\w+$/g, "");
		}
		else {
			id = path.basename(filepath).replace(/^\/|\.\w+$/g, "");
		}
		return id;
	}
731005
function resolveModuleId(id, file, conf, modulename) {
    var paths = conf.paths || {};
    var pkgs = conf.packages || [];
    var baseUrl = conf.baseUrl || '.';
    var root = fis.project.getProjectPath();
    var connector = fis.config.get('namespaceConnector', ':');
    var dirname = file.dirname;
    var pluginPath, info, m, pkg, path, dirs, item, main;
    var dir, lastdir, i, len, ns, subpath, idx, sibling, resolved;

    // 支持 amd plugin
    idx = id.indexOf('!');
    if (~idx) {
        pluginPath = id.substring(idx + 1);
        id = id.substring(0, idx);
    }

    if (pluginPath) {
        info = fis.uri(pluginPath, file.dirname);
        if (info.file && info.file.isFile()) {

            if (info.file.useHash && fis.compile.settings.hash) {
                compileFile(info.file);
            }

            var query = (info.file.query && info.query) ? '&' + info.query.substring(1) : info.query;
            var url = info.file.getUrl(fis.compile.settings.hash, fis.compile.settings.domain);
            var hash = info.hash || info.file.hash;
            pluginPath = info.quote + url + query + hash + info.quote;
        }

        info = null;
    }

    // convert baseUrl
    if (baseUrl[0] !== '/') {
        baseUrl = pth.join(root, baseUrl);
    }
    baseUrl = pth.resolve(baseUrl);

    if (id === '.' || id.substring(id.length-1) === '/') {
        // 真麻烦，还得去查找当前目录是不是 match 一个 packagers。
        // 如果是，得找到 main 的设置。
        pkg = findPkgByPath(pkgs, id, file, baseUrl, root);
        main = pkg && pkg.main || 'main';

        id = id === '.' ? './' + main : id + main;
    }

    idx = id.indexOf(connector);
    if (~idx && (ns = id.substring(0, idx))) {
        subpath = id.substring(idx + 1);

        if (ns == fis.config.get('namespace')) {
            info = fis.uri(subpath, root);
            info.file || (info = fis.uri(subpath + '.js', root));
        } else {
            //  不处理其他模块的
            return {
                isFisId: true,
                path: id + (/\.js$/.test(id)?'':'.js'),
                pluginPath: pluginPath
            }
        }
    } else if (id[0] === '.') {

        // 先相对与当前定义的模块定位。
        // 很可能多个 module 在一个文件里面定义的。
        if (modulename) {
            resolved = pth.join(pth.dirname(modulename), id);

            if (resolved && !conf.noOnymousModule && map.get(resolved)) {
                info = fis.uri(map.get(resolved), root);
            }
        }

        // 没找到，再来看当前文件夹下有没有这个文件。
        if (!info || !info.file) {
            // 相对路径
            info = fis.uri(id, dirname);
            info.file || (info = fis.uri(id + '.js', dirname));
        }

        // combine 模式
        // 看看当前文件里面已经有没有定义了的 module
        if (!info.file && !conf.noOnymousModule && (sibling = getKeyByValue(map.get(), file.subpath))) {
            id = pth.join(sibling.replace(/(\/|\\)[^\/\\]+$/, ''), id);

            if (id && map.get(id)) {
                info = fis.uri(map.get(id), root);
            }
        }

    } else if (id[0] === '/') {

        // 绝对路径, 那也是相对与 baseUrl 的绝对路径。
        id = id.substring(1);
        info = fis.uri(id, baseUrl);
        info.file || (info = fis.uri(id + '.js', baseUrl));

        // baseUrl 里面没有，还是再看看项目根目录里面有没有。
        if (!info.file) {
            info = fis.uri(id, root);
            info.file || (info = fis.uri(id + '.js', root));
        }

    } else if ((m = /^([^\/]+)(?:\/(.*))?$/.exec(id))) {
        path = m[0];
        pkg = m[1];
        subpath = m[2] || '';

        // 先查找 map 中是否已经注册
        // fixme 跨模块会不会有问题？
        if (!conf.noOnymousModule && map.get(path)) {
            info = fis.uri(map.get(path), root);
        } else if (paths[pkg]) {
            // 再查找 conf.paths
            dirs = paths[pkg];

            Array.isArray(dirs) || (dirs = [dirs]);

            for (i = 0, len = dirs.length; i < len; i++) {
                dir = dirs[i];

                // 如果是其他模块下的路径
                if (~dir.indexOf(connector)) {
                    return {
                        isFisId: true,
                        path: dir + subpath + (!subpath || /\.js$/.test(subpath)?'':'.js')
                    }
                }

                info = fis.uri(dir, baseUrl);
                info.file || (info = fis.uri(dir + '.js', baseUrl));

                if (!info.file) {
                    info = fis.uri(dir, root);
                    info.file || (info = fis.uri(dir + '.js', root));
                }

                if (info.file || !subpath) {
                    break;
                }

                // 没找到，再来当文件夹处理

                var dirorign = dir;

                if (dirorign[0] !== '/') {
                    dir = pth.join(baseUrl, dirorign);
                }

                info = fis.uri(subpath, dir);
                info.file || (info = fis.uri(subpath + '.js', dir));


                if (!info.file && dirorign[0] !== '/') {
                    dir = pth.join(baseUrl, dirorign);
                    info = fis.uri(subpath, dir);
                    info.file || (info = fis.uri(subpath + '.js', dir));
                }

                // 如果找到了需要断开。
                if (info.file) {
                    break;
                }
            }

        // 再查找 conf.packages
        } else if ((item = findPkg(pkg, pkgs))) {
            if (~item.location.indexOf(connector)) {

                subpath = subpath ? subpath : item.main || 'main';

                return {
                    isFisId: true,
                    path: item.location + '/' + subpath + (/\.js$/.exec(subpath) ? '' : '.js'),
                    pluginPath: pluginPath
                }
            }

            dir = baseUrl;
            dir = pth.join(dir, item.location || item.name);
            subpath = subpath || item.main || 'main';
            info = fis.uri(subpath, dir);
            info.file || (info = fis.uri(subpath + '.js', dir));

            if (!info.file) {
                dir = pth.join(root, item.location || item.name);
                info = fis.uri(subpath, dir);
                info.file || (info = fis.uri(subpath + '.js', dir));
            }
        } else {

            if (conf.shim) {
                var shim = conf.shim;

                for (var key in shim) {
                    if (!shim.hasOwnProperty(key)) {
                        continue;
                    }

                    var val = shim[key];
                    if (val.id === pkg ) {
                        info = fis.uri(key, root);
                        if (info.file) {
                            return {
                                file: info.file,
                                pluginPath: pluginPath
                            }
                        }
                    }
                }
            }

            var top = baseUrl;
            // 递归查找。
            for (dir = dirname; true;) {
                info = fis.uri(path, dir);
                info.file || (info = fis.uri(path + '.js', dir));

                if (info.file) {
                    break;
                }

                lastdir = dir;
                dir = pth.dirname(dir);

                if (dir === top || dir === lastdir) {
                    break;
                }
            }

            if (!info.file) {
                info = fis.uri(path, baseUrl);
                info.file || (info = fis.uri(path + '.js', baseUrl));
            }

            if (!info.file) {
                info = fis.uri(path, root);
                info.file || (info = fis.uri(path + '.js', root));
            }
        }
    }

    return {
        file: info && info.file,
        pluginPath: pluginPath
    }
}
1293099
function getModules(directory, logger, local) {
    logger(`Getting modules @ ${directory.path}`);
    if (directory.barrel) {
        // If theres a barrel then use that as it *should* contain descendant modules.
        logger(`Found existing barrel @ ${directory.barrel.path}`);
        return [directory.barrel];
    }
    const files = [].concat(directory.files);
    if (!local) {
        directory.directories.forEach((childDirectory) => {
            // Recurse.
            files.push(...getModules(childDirectory, logger, local));
        });
    }
    // Only return files that look like TypeScript modules.
    return files.filter((file) => file.name.match(utilities_1.isTypeScriptFile));
}
1317885
public static String getModuleVersion(final String moduleId) {
        final int splitter = moduleId.lastIndexOf(':');
        if(splitter == -1){
            return moduleId;
        }
        return moduleId.substring(splitter+1);
    }
762367
function(moduleIds) {
		for (var i = moduleIds.length; i--;) {
			var moduleId = moduleIds[i],
				module = getModule(moduleId);

			if (module == null) {
				module = _modules[moduleId] = {};
				_fetchFunc(moduleId);
			}
		}
	}
706507
function(moduleId) {
		var scriptEl = document.createElement('script');
		scriptEl.type = 'text/javascript';
		scriptEl.src = resolveModuleUri(moduleId);

		var useStandard = !!scriptEl.addEventListener,
			timeoutHandle;

		var errorFunc = function() {
			postLoadFunc(false);
		};

		var loadFunc = function() {
			if (useStandard || (scriptEl.readyState == 'complete' || scriptEl.readyState == 'loaded')) {
				postLoadFunc(getModule(moduleId).defined);
			}
		};

		var postLoadFunc = function(loaded) {
			clearTimeout(timeoutHandle);

			if (useStandard) {
				scriptEl.removeEventListener('load', loadFunc, false);
				scriptEl.removeEventListener('error', errorFunc, false);
			}
			else {
				scriptEl.detachEvent('onreadystatechange', loadFunc);
			}

			if (!loaded) {
				var module = getModule(moduleId);
				if (!module.defined) {
					module.defined = module.error = true;
					fireCallbacks();
				}
			}
		};

		if (useStandard) {
			scriptEl.addEventListener('load', loadFunc, false);
			scriptEl.addEventListener('error', errorFunc, false);
		}
		else {
			scriptEl.attachEvent('onreadystatechange', loadFunc);
		}

		timeoutHandle = setTimeout(errorFunc, _timeoutLength);

		head.appendChild(scriptEl);
	}
1022620
private ModuleInfo loadModuleInfo(ModuleIdentifier modID, File modJsonFile) {
    return new ModuleInfo(modID, new ModuleFields(loadModuleConfig(modID, modJsonFile)));
  }
1184747
function (file) {

        var that = this;
        var error = false;
        var walk;

        if (file) {


            var fileList = typeof file === 'string' ? [file] : file;

            fileList = fileList.map(function (file) {
                return path.resolve(that.base, file);
            });

            walk = function (list) {

                list.forEach(function (file) {

                    if (error) {
                        return;
                    }

                    error = !that._compile(file);

                });
            };


            walk(fileList);

            if (!error && this.options.combo) {
                this._combo();
            }

        } else {


            walk = function (dir) {

                if (dir === that.output) {
                    return;
                }

                var dirList = fs.readdirSync(dir);

                dirList.forEach(function (item) {

                    if (error) {
                        return;
                    }

                    if (fs.statSync(path.join(dir, item)).isDirectory()) {
                        walk(path.join(dir, item));
                    } else if (that.filterBasename(item) && that.filterExtname(item)) {
                        error = !that._compile(path.join(dir, item));
                    }

                });
            };


            walk(this.base);

            if (!error && this.options.combo) {
                this._combo();
            }
        }

    }
572350
public OvhModuleList moduleList_id_GET(Long id) throws IOException {
		String qPath = "/hosting/web/moduleList/{id}";
		StringBuilder sb = path(qPath, id);
		String resp = execN(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhModuleList.class);
	}
706391
public Object getFileMetadata(String file, String key) {
    Map<String, Object> fileKeys = fileLevel.get(file);
    if (fileKeys == null) {
      return null;
    }

    return fileKeys.get(key);
  }
565894
public Map<String, Object> processFile(File file) {
        ParserEngine engine = Engines.get(FileUtil.fileExt(file));
        if (engine==null) {
            LOGGER.error("Unable to find suitable markup engine for {}",file);
            return null;
        }

        return engine.parse(config, file);
    }