Add Node JS Generic (#374)

* Add Node JS Generic

This creates a generic template that can be used for Node JS applications.

There are no known limitations at this time. Feature requests are welcome.

* PATH step for scripts that need it.

* Greelan's review

* One day, glasses will be used.
This commit is contained in:
IceOfWraith 2023-05-20 11:27:34 -05:00 committed by GitHub
parent 78967f269e
commit aa2eda565a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 385 additions and 0 deletions

89
node.kvp Normal file
View File

@ -0,0 +1,89 @@
Meta.DisplayName=Node
Meta.Description=Node Service Instance
Meta.OS=Windows, Linux
Meta.AarchSupport=Native
Meta.Arch=All
Meta.Author=IceOfWraith
Meta.URL=https://nodejs.org
Meta.DisplayImageSource=url:https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Node.js_logo.svg/1200px-Node.js_logo.svg.png
Meta.EndpointURIFormat=
Meta.ConfigManifest=nodeconfig.json
Meta.MetaConfigManifest=
Meta.ConfigRoot=node.kvp
Meta.MinAMPVersion=2.4.4.0
Meta.SpecificDockerImage=
Meta.DockerRequired=False
Meta.ContainerPolicy=Supported
Meta.ContainerPolicyReason=
Meta.ExtraSetupStepsURI=
Meta.Prerequsites=[]
Meta.ConfigReleaseState=NotSpecified
Meta.NoCommercialUsage=False
App.DisplayName=Node
App.RootDir=./node-server/
App.BaseDirectory=./node-server/
App.ExecutableWin=node\node.exe
App.ExecutableLinux=./node/bin/node
App.WorkingDir=app
App.LinuxCommandLineArgs=
App.WindowsCommandLineArgs=
App.CommandLineArgs="{{$FullBaseDir}}app/{{ApplicationLocation}}/{{ApplicationName}}" {{CommandLineArgs}}
App.UseLinuxIOREDIR=False
App.AppSettings={}
App.EnvironmentVariables={}
App.CommandLineParameterFormat=-{0}={1}
App.CommandLineParameterDelimiter=
App.ExitMethod=OS_CLOSE
App.ExitTimeout=30
App.ExitString=stop
App.ExitFile=lock
App.HasWriteableConsole=True
App.HasReadableConsole=True
App.SupportsLiveSettingsChanges=False
App.LiveSettingChangeCommandFormat=set {0} "{1}"
App.ApplicationIPBinding=0.0.0.0
App.Ports=[{"Protocol":"Both","Name":"Main Port","Description":"Main port used for incoming traffic","Port":7777,"Ref":"ServerPort"}]
App.AdminPortRef=ServerPort
App.PrimaryApplicationPortRef=ServerPort
App.UniversalSleepApplicationUDPPortRef=0
App.UniversalSleepSteamQueryPortRef=0
App.MaxUsers=0
App.UseRandomAdminPassword=False
App.RemoteAdminPassword=Password123
App.AdminMethod=STDIO
App.AdminLoginTransform=None
App.RCONConnectDelaySeconds=5
App.RCONConnectRetrySeconds=5
App.RCONHeartbeatMinutes=0
App.RCONHeartbeatCommand=ping
App.TelnetLoginFormat={0}
App.UpdateSources=@IncludeJson[nodeupdates.json]
App.Compatibility=None
App.SteamUpdateAnonymousLogin=True
App.SteamForceLoginPrompt=False
App.RapidStartup=True
App.MonitorChildProcess=False
App.MonitorChildProcessWaitMs=1000
App.MonitorChildProcessName=
App.SupportsUniversalSleep=False
App.WakeupMode=Any
App.ApplicationReadyMode=Immediate
App.TemplateMatchRegex={{(\$?[\w]+)}}
Console.FilterMatchRegex=
Console.FilterMatchReplacement=
Console.ThrowawayMessageRegex=
Console.AppReadyRegex=^$
Console.UserJoinRegex=^$
Console.UserLeaveRegex=^$
Console.UserChatRegex=^$
Console.UpdateAvailableRegex=^$
Console.MetricsRegex=
Console.SuppressLogAtStart=False
Console.ActivateLogRegex=
Console.UserActions={}
Limits.SleepMode=False
Limits.SleepOnStart=False
Limits.SleepDelayMinutes=5
Limits.DozeDelay=2
Limits.AutoRetryCount=5
Limits.SleepStartThresholdSeconds=25

150
nodeconfig.json Normal file
View File

@ -0,0 +1,150 @@
[
{
"DisplayName":"Application Download Type",
"Category":"Node - Settings",
"Description":"Sets where to download the application from. Be sure to enter the \"Application Download Source\", \"GitHub Release Filename\", and \"GitHub Release Version\" where applicable. Update the application after setting this value.",
"Keywords":"download,type",
"FieldName":"DownloadType",
"InputType":"enum",
"IsFlagArgument":false,
"ParamFieldName":"DownloadType",
"IncludeInCommandLine":false,
"DefaultValue":"GitRepo",
"EnumValues":{
"DownloadURL":"Download URL",
"GithubRelease":"GitHub Release",
"GitRepo":"GitHub Repo",
"None":"None"
}
},
{
"DisplayName":"Application Download Source",
"Category":"Node - Settings",
"Description":"Sets the source for the \"Application Download Type\". Enter the values based on the type you chose in the previous input. GitHub Repo = URL that ends in .git. GitHub Release = User/Repo. Download URL = URL to a zip file to download. Update the application after setting this value.",
"Keywords":"download,source",
"FieldName":"DownloadSource",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"DownloadSource",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"https://github.com/IceOfWraith/IceBot.git",
"EnumValues":{}
},
{
"DisplayName":"GitHub Release Filename",
"Category":"Node - Settings",
"Description":"If you chose \"GitHub Release\" for the \"Application Download Type\", you need to enter the file from the release to download.",
"Keywords":"github,release,filename",
"FieldName":"DownloadFilename",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"DownloadFilename",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"discordbot.zip",
"EnumValues":{}
},
{
"DisplayName":"GitHub Release Version",
"Category":"Node - Settings",
"Description":"If you chose \"GitHub Release\" for the \"Application Download Type\", you may enter the release version to download. Leave this blank to download the latest.",
"Keywords":"github,release,version",
"FieldName":"DownloadVersion",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"DownloadVersion",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"1.0.0",
"EnumValues":{}
},
{
"DisplayName":"Node.js Version",
"Category":"Node - Settings",
"Description":"Sets the [Node.js release version](https://nodejs.org/download/release/) to install to run the application. NOTE: Specify a numbered version like v.18.16.0, rather than any \"latest\" version.",
"Keywords":"node,nodejs,version",
"FieldName":"NodeVersion",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"NodeVersion",
"IncludeInCommandLine":false,
"DefaultValue":"v18.16.0",
"Placeholder":"v18.16.0",
"EnumValues":{}
},
{
"DisplayName":"Application Name",
"Category":"Node - Settings",
"Description":"Specify name of the Node application to execute Do not specify \"node\" in front.",
"Keywords":"app,application,name",
"FieldName":"ApplicationName",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"ApplicationName",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"index.js",
"EnumValues":{}
},
{
"DisplayName":"Application Installation Location",
"Category":"Node - Settings",
"Description":"If the app downloads in a subfolder of \"app\" you must specify the folders here.",
"Keywords":"app,application,location",
"FieldName":"ApplicationLocation",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"ApplicationLocation",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"IceBot-main",
"EnumValues":{}
},
{
"DisplayName":"Command Line Arguments",
"Category":"Node - Settings",
"Description":"Specify any command line arguments to include.",
"Keywords":"command,line,arguments,args",
"FieldName":"CommandLineArgs",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"CommandLineArgs",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"value1=foo value2=bar",
"EnumValues":{}
},
{
"DisplayName":"npm Install Type",
"Category":"Node - Settings",
"Description":"Specify \"npm i\" to use a packages.json or specify \"npm ci\" to use a packages-lock.json. If \"Specific Packages\" is chosen you must enter the packages in the \"Specific npm Packages\" input.",
"Keywords":"npm,install,type",
"FieldName":"NpmInstallType",
"InputType":"enum",
"IsFlagArgument":false,
"ParamFieldName":"NpmInstallType",
"IncludeInCommandLine":false,
"DefaultValue":"npmi",
"EnumValues":{
"none":"None",
"npmci":"npm ci",
"npmi":"npm i",
"specify":"Specific Packages"
}
},
{
"DisplayName":"Specific npm Packages",
"Category":"Node - Settings",
"Description":"Specify any additional npm packages to install separated by a space. Select \"Specific Packages\" for the \"npm Install Type\".",
"Keywords":"additional,npm,packages",
"FieldName":"NpmPackages",
"InputType":"text",
"IsFlagArgument":false,
"ParamFieldName":"NpmPackages",
"IncludeInCommandLine":false,
"DefaultValue":"",
"Placeholder":"express fastify socket.io",
"EnumValues":{}
}
]

146
nodeupdates.json Normal file
View File

@ -0,0 +1,146 @@
[
{
"UpdateStageName":"App Directory Creation",
"UpdateSourcePlatform":"All",
"UpdateSource":"CreateDirectory",
"UpdateSourceArgs":"{{$FullBaseDir}}app"
},
{
"UpdateStageName":"Application Download",
"UpdateSourcePlatform":"All",
"UpdateSource":"GitRepo",
"UpdateSourceData":"{{DownloadSource}}",
"UpdateSourceTarget":"{{$FullBaseDir}}app",
"UpdateSourceConditionSetting":"DownloadType",
"UpdateSourceConditionValue":"GitRepo"
},
{
"UpdateStageName":"Application Download",
"UpdateSourcePlatform":"All",
"UpdateSource":"GithubRelease",
"UpdateSourceArgs":"{{DownloadSource}}",
"UpdateSourceData":"{{DownloadFilename}}",
"UpdateSourceVersion":"{{DownloadVersion}}",
"UpdateSourceTarget":"{{$FullBaseDir}}app",
"UnzipUpdateSource":true,
"OverwriteExistingFiles":true,
"DeleteAfterExtract":true,
"UpdateSourceConditionSetting":"DownloadType",
"UpdateSourceConditionValue":"GithubRelease"
},
{
"UpdateStageName":"Application Download",
"UpdateSourcePlatform":"All",
"UpdateSource":"FetchURL",
"UpdateSourceData":"{{DownloadSource}}",
"UpdateSourceTarget":"{{$FullBaseDir}}app",
"UnzipUpdateSource":true,
"OverwriteExistingFiles":true,
"DeleteAfterExtract":true,
"UpdateSourceConditionSetting":"DownloadType",
"UpdateSourceConditionValue":"DownloadURL"
},
{
"UpdateStageName":"Node.js Download",
"UpdateSourcePlatform":"Linux",
"UpdateSourceArch":"x86_64",
"UpdateSource":"FetchURL",
"UpdateSourceData":"https://nodejs.org/download/release/{{NodeVersion}}/node-{{NodeVersion}}-linux-x64.tar.gz",
"UpdateSourceTarget":"{{$FullBaseDir}}"
},
{
"UpdateStageName":"Node.js Extract",
"UpdateSourcePlatform":"Linux",
"UpdateSourceArch":"x86_64",
"UpdateSource":"Executable",
"UpdateSourceData":"/bin/bash",
"UpdateSourceArgs":"-c 'cd \"{{$FullBaseDir}}\" && rm -Rf \"{{$FullBaseDir}}node/\" && tar xfv node-{{NodeVersion}}-linux-x64.tar.gz > {{$FullBaseDir}}AMPSetupLog.txt 2>&1 && mv -v node-{{NodeVersion}}-linux-x64 node >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1 && rm node-{{NodeVersion}}-linux-x64.tar.gz'"
},
{
"UpdateStageName":"Node.js Download",
"UpdateSourcePlatform":"Linux",
"UpdateSourceArch":"aarch64",
"UpdateSource":"FetchURL",
"UpdateSourceData":"https://nodejs.org/download/release/{{NodeVersion}}/node-{{NodeVersion}}-linux-arm64.tar.gz",
"UpdateSourceTarget":"{{$FullBaseDir}}"
},
{
"UpdateStageName":"Node.js Extract",
"UpdateSourcePlatform":"Linux",
"UpdateSourceArch":"aarch64",
"UpdateSource":"Executable",
"UpdateSourceData":"/bin/bash",
"UpdateSourceArgs":"-c 'cd \"{{$FullBaseDir}}\" && rm -Rf \"{{$FullBaseDir}}node/\" && tar xfv node-{{NodeVersion}}-linux-arm64.tar.gz > {{$FullBaseDir}}AMPSetupLog.txt 2>&1 && mv -v node-{{NodeVersion}}-linux-arm64 node >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1 && rm node-{{NodeVersion}}-linux-arm64.tar.gz'"
},
{
"UpdateStageName":"Node.js Download",
"UpdateSourcePlatform":"Windows",
"UpdateSource":"FetchURL",
"UpdateSourceData":"https://nodejs.org/download/release/{{NodeVersion}}/node-{{NodeVersion}}-win-x64.zip",
"UpdateSourceTarget":"{{$FullBaseDir}}",
"UnzipUpdateSource":true,
"OverwriteExistingFiles":true,
"DeleteAfterExtract":true
},
{
"UpdateStageName":"Node.js Extract",
"UpdateSourcePlatform":"Windows",
"UpdateSource":"Executable",
"UpdateSourceData":"cmd.exe",
"UpdateSourceArgs":"/C cd \"{{$FullBaseDir}}\" & rmdir /S /Q \"{{$FullBaseDir}}node/\" & rename node-{{NodeVersion}}-win-x64 node > {{$FullBaseDir}}AMPSetupLog.txt 2>&1"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Linux",
"UpdateSource":"Executable",
"UpdateSourceData":"/bin/bash",
"UpdateSourceArgs":"-c 'export PATH=$PATH:{{$FullBaseDir}}node/bin && cd \"{{$FullBaseDir}}app/{{ApplicationLocation}}/\" && \"{{$FullBaseDir}}node/bin/node\" \"{{$FullBaseDir}}node/bin/npm\" i {{NpmPackages}} >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1'",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"specify"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Windows",
"UpdateSource":"Executable",
"UpdateSourceData":"cmd.exe",
"UpdateSourceArgs":"/C set PATH={{$FullBaseDir}}node;%PATH% && cd \"{{$FullBaseDir}}app\\{{ApplicationLocation}}\\\" && \"{{$FullBaseDir}}node\\node\" \"{{$FullBaseDir}}node\\node_modules\\npm\\bin\\npm-cli.js\" i {{NpmPackages}} >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"specify"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Linux",
"UpdateSource":"Executable",
"UpdateSourceData":"/bin/bash",
"UpdateSourceArgs":"-c 'export PATH=$PATH:{{$FullBaseDir}}node/bin && cd \"{{$FullBaseDir}}app/{{ApplicationLocation}}/\" && \"{{$FullBaseDir}}node/bin/node\" \"{{$FullBaseDir}}node/bin/npm\" i >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1'",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"npmi"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Windows",
"UpdateSource":"Executable",
"UpdateSourceData":"cmd.exe",
"UpdateSourceArgs":"/C set PATH={{$FullBaseDir}}node;%PATH% && cd \"{{$FullBaseDir}}app\\{{ApplicationLocation}}\\\" && \"{{$FullBaseDir}}node\\node\" \"{{$FullBaseDir}}node\\node_modules\\npm\\bin\\npm-cli.js\" i >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"npmi"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Linux",
"UpdateSource":"Executable",
"UpdateSourceData":"/bin/bash",
"UpdateSourceArgs":"-c 'export PATH=$PATH:{{$FullBaseDir}}node/bin && cd \"{{$FullBaseDir}}app/{{ApplicationLocation}}/\" && \"{{$FullBaseDir}}node/bin/node\" \"{{$FullBaseDir}}node/bin/npm\" ci >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1'",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"npmci"
},
{
"UpdateStageName":"npm Packages",
"UpdateSourcePlatform":"Windows",
"UpdateSource":"Executable",
"UpdateSourceData":"cmd.exe",
"UpdateSourceArgs":"/C set PATH={{$FullBaseDir}}node;%PATH% && cd \"{{$FullBaseDir}}app\\{{ApplicationLocation}}\\\" && \"{{$FullBaseDir}}node\\node\" \"{{$FullBaseDir}}node\\node_modules\\npm\\bin\\npm-cli.js\" ci >> {{$FullBaseDir}}AMPSetupLog.txt 2>&1",
"UpdateSourceConditionSetting":"NpmInstallType",
"UpdateSourceConditionValue":"npmci"
}
]