in src/Detector/Node/NodeDetector.cs [37:139]
public PlatformDetectorResult Detect(DetectorContext context)
{
bool isNodeApp = false;
bool hasLernaJsonFile = false;
bool hasLageConfigJSFile = false;
bool hasYarnrcYmlFile = false;
bool IsYarnLockFileValidYamlFormat = false;
string appDirectory = string.Empty;
string lernaNpmClient = string.Empty;
var sourceRepo = context.SourceRepo;
if (sourceRepo.FileExists(NodeConstants.PackageJsonFileName) ||
sourceRepo.FileExists(NodeConstants.PackageLockJsonFileName) ||
sourceRepo.FileExists(NodeConstants.YarnLockFileName))
{
isNodeApp = true;
}
else
{
_logger.LogDebug(
$"Could not find {NodeConstants.PackageJsonFileName}/{NodeConstants.PackageLockJsonFileName}" +
$"/{NodeConstants.YarnLockFileName} in repo");
}
if (sourceRepo.FileExists(NodeConstants.YarnrcYmlName))
{
hasYarnrcYmlFile = true;
}
if (sourceRepo.FileExists(NodeConstants.YarnLockFileName)
&& IsYarnLockFileYamlFile(sourceRepo, NodeConstants.YarnLockFileName)) {
IsYarnLockFileValidYamlFormat = true;
}
if (sourceRepo.FileExists(NodeConstants.LernaJsonFileName))
{
hasLernaJsonFile = true;
lernaNpmClient = GetLernaJsonNpmClient(context);
}
if (sourceRepo.FileExists(NodeConstants.LageConfigJSFileName))
{
hasLageConfigJSFile = true;
}
if (!isNodeApp)
{
// Copying the logic currently running in Kudu:
var mightBeNode = false;
foreach (var typicalNodeFile in NodeConstants.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 NodeConstants.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)
{
_logger.LogDebug("App in repo is not a NodeJS app");
return null;
}
var version = GetVersion(context);
IEnumerable<FrameworkInfo> detectedFrameworkInfos = null;
if (!_options.DisableFrameworkDetection)
{
detectedFrameworkInfos = DetectFrameworkInfos(context);
}
return new NodePlatformDetectorResult
{
Platform = NodeConstants.PlatformName,
PlatformVersion = version,
AppDirectory = appDirectory,
Frameworks = detectedFrameworkInfos,
HasLernaJsonFile = hasLernaJsonFile,
HasLageConfigJSFile = hasLageConfigJSFile,
LernaNpmClient = lernaNpmClient,
HasYarnrcYmlFile = hasYarnrcYmlFile,
IsYarnLockFileValidYamlFormat = IsYarnLockFileValidYamlFormat,
};
}