Skip to content

Commit

Permalink
move application insights loader file name to build constants
Browse files Browse the repository at this point in the history
  • Loading branch information
arroyc authored May 1, 2019
1 parent aad2b92 commit 912a268
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
9 changes: 9 additions & 0 deletions build/build-constants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@
namespace: Microsoft.Oryx.Common
- type: go
directory: src/startupscriptgenerator/common/consts
- name: node-app-insights-loader
constants:
node-app-insights-loader-file-name: oryx-appinsightsloader.js
outputs:
- type: csharp
directory: src/BuildScriptGenerator/Node
namespace: Microsoft.Oryx.BuildScriptGenerator.Node
- type: go
directory: src/startupscriptgenerator/common/consts
- name: node-versions
constants:
yarn-version: 1.13.0
Expand Down
9 changes: 9 additions & 0 deletions src/BuildScriptGenerator/Node/NodeAppInsightsLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file was auto-generated from 'build-constants.yaml'. Changes may be overridden.

namespace Microsoft.Oryx.BuildScriptGenerator.Node
{
public static class NodeAppInsightsLoader
{
public const string NodeAppInsightsLoaderFileName = "oryx-appinsightsloader.js";
}
}
1 change: 0 additions & 1 deletion src/BuildScriptGenerator/Node/NodeConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ internal static class NodeConstants
internal const string NodeModulesTarGzFileName = "node_modules.tar.gz";
internal const string NodeModulesFileBuildProperty = "compressedNodeModulesFile";
internal const string NodeAppInsightsPackageName = "applicationinsights";
internal const string NodeAppInsightsLoaderFileName = "oryx-appinsightsloader.js";
internal const string InjectedAppInsights = "injectedAppInsights";
}
}
2 changes: 1 addition & 1 deletion src/BuildScriptGenerator/Node/NodePlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public BuildScriptSnippet GenerateBashBuildScriptSnippet(BuildScriptGeneratorCon
pruneDevDependencies: pruneDevDependencies,
appInsightsInjectCommand: appInsightsInjectCommand,
appInsightsPackageName: NodeConstants.NodeAppInsightsPackageName,
appInsightsLoaderFileName: NodeConstants.NodeAppInsightsLoaderFileName);
appInsightsLoaderFileName: NodeAppInsightsLoader.NodeAppInsightsLoaderFileName);

string script = TemplateHelpers.Render(
TemplateHelpers.TemplateResource.NodeBuildSnippet,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file was auto-generated from 'build-constants.yaml'. Changes may be overridden.

package consts

const NodeAppInsightsLoaderFileName string = "oryx-appinsightsloader.js"
7 changes: 5 additions & 2 deletions src/startupscriptgenerator/node/scriptgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"path/filepath"
"startupscriptgenerator/common"
"startupscriptgenerator/common/consts"
"strings"
)

Expand Down Expand Up @@ -168,10 +169,12 @@ func (gen *NodeStartupScriptGenerator) GenerateEntrypointScript() string {
startupCommand = common.ExtendPathForCommand(startupCommand, gen.SourcePath)
}

logger.LogInformation("Looking for App-Insights loader injected by Oryx and export that to NODE_OPTIONS if needed")
logger.LogInformation("Looking for App-Insights loader injected by Oryx and export to NODE_OPTIONS if needed")
scriptBuilder.WriteString("if [ -n $injectedAppInsights ]; then\n")
scriptBuilder.WriteString(" if [ -f ./oryx-appinsightsloader.js ]; then\n")
scriptBuilder.WriteString(" export NODE_OPTIONS='--require ./oryx-appinsightsloader.js '$NODE_OPTIONS\n")
var nodeOptions = "'--require ./" + consts.NodeAppInsightsLoaderFileName + " '$NODE_OPTIONS"
scriptBuilder.WriteString(" export NODE_OPTIONS=" + nodeOptions + "\n")
scriptBuilder.WriteString("")
scriptBuilder.WriteString(" fi\n")
scriptBuilder.WriteString("fi\n")
scriptBuilder.WriteString(startupCommand + "\n")
Expand Down

0 comments on commit 912a268

Please sign in to comment.