public IEnumerable <ICheckerMessage> CheckSourceRepo(ISourceRepo repo) { // Installing packages globally is problematic only in the App Service envelope if (_env?.Type == Common.EnvironmentType.AzureAppService) { dynamic packageJson = NodePlatform.GetPackageJsonObject(repo, logger: null); if (packageJson != null) { return(CheckScriptsForGlobalInstallationAttempts( packageJson.scripts?.ToObject <IDictionary <string, string> >())); } } return(Enumerable.Empty <ICheckerMessage>()); }
public IEnumerable <ICheckerMessage> CheckSourceRepo(ISourceRepo repo) { dynamic packageJson = NodePlatform.GetPackageJsonObject(repo, null); if (packageJson == null) { return(null); } var result = new List <ICheckerMessage>(); CheckPackageJsonDependencyObject(packageJson.dependencies, "dependencies", result); CheckPackageJsonDependencyObject(packageJson.devDependencies, "devDependencies", result); return(result); }
public IEnumerable <ICheckerMessage> CheckSourceRepo(ISourceRepo repo) { dynamic packageJson = NodePlatform.GetPackageJsonObject(repo, null); if (packageJson == null) { _logger.LogDebug($"{NodeConstants.PackageJsonFileName.Hash()} is null; skipping checking for superseded packages"); return(Enumerable.Empty <ICheckerMessage>()); } var result = new List <ICheckerMessage>(); CheckPackageJsonDependencyObject(packageJson.dependencies, "dependencies", result); CheckPackageJsonDependencyObject(packageJson.devDependencies, "devDependencies", result); return(result); }
public LanguageDetectorResult Detect(RepositoryContext context) { bool isNodeApp = false; var sourceRepo = context.SourceRepo; if (sourceRepo.FileExists(NodeConstants.PackageJsonFileName) || sourceRepo.FileExists(NodeConstants.PackageLockJsonFileName) || sourceRepo.FileExists(NodeConstants.YarnLockFileName)) { isNodeApp = true; } else if (StaticSiteGeneratorHelper.IsStaticSite(sourceRepo, _environment)) { isNodeApp = true; } else { _logger.LogDebug( $"Could not find {NodeConstants.PackageJsonFileName}/{NodeConstants.PackageLockJsonFileName}" + $"/{NodeConstants.YarnLockFileName} in repo"); } if (!isNodeApp) { // Copying the logic currently running in Kudu: var mightBeNode = false; foreach (var typicalNodeFile in TypicalNodeDetectionFiles) { if (sourceRepo.FileExists(typicalNodeFile)) { mightBeNode = true; break; } } if (mightBeNode) { // Check if any of the known iis start pages exist // If so, then it is not a node.js web site otherwise it is foreach (var iisStartupFile in IisStartupFiles) { if (sourceRepo.FileExists(iisStartupFile)) { _logger.LogDebug( "App in repo is not a Node.js app as it has the file {iisStartupFile}", iisStartupFile.Hash()); return(null); } } isNodeApp = true; } else { // No point in logging the actual file list, as it's constant _logger.LogDebug("Could not find typical Node.js files in repo"); } } if (isNodeApp) { var packageJson = NodePlatform.GetPackageJsonObject(sourceRepo, _logger); var nodeVersion = DetectNodeVersion(packageJson); return(new LanguageDetectorResult { Language = NodeConstants.NodeJsName, LanguageVersion = nodeVersion, }); } else { _logger.LogDebug("App in repo is not a Node.js app"); } return(null); }
private string GetVersionFromPackageJson(RepositoryContext context) { var packageJson = NodePlatform.GetPackageJsonObject(context.SourceRepo, _logger); return(packageJson?.engines?.node?.Value as string); }