-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working installer and static application
- Loading branch information
1 parent
4413475
commit ebfde8c
Showing
12 changed files
with
172 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
:: This batch script makes the Caché application deployment much faster by building and importing the project. | ||
:: Replace the variables below to match your Caché installation and build & import application to Caché using only one command. | ||
|
||
:: Caché 2016.2+ IS REQUIRED TO PROCEED | ||
@echo off | ||
|
||
:: CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH ON WINDOWS (folder that contains bin, CSP, mgr and other folders) | ||
:: Configurable variables: change them to fit your system :: | ||
set CACHE_DIR=C:\Program Files\InterSystems\Ensemble | ||
:: NAMESPACE TO IMPORT PACKAGE TO | ||
set NAMESPACE=SAMPLES | ||
:: Other variables | ||
set BUILD_DIR=build\cls | ||
:: set BUILD_STATIC_DIR=build\static | ||
:: set CSP_DIR=C:\Program Files\InterSystems\Ensemble\CSP\samples\EntityBrowser | ||
:: User credentials. Remove if necessary. | ||
set USERNAME=_SYSTEM | ||
set PASSWORD=SYS | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
@echo off | ||
:: Pre-configured variables | ||
set BUILD_DIR=build\cls | ||
set XML_EXPORT_DIR=build | ||
set PACKAGE_NAME=EntityBrowser | ||
|
||
:: Build and import application to Caché | ||
echo Importing project... | ||
call npm run gulp | ||
:: call xcopy /sy "%~dp0\%BUILD_STATIC_DIR%" "%CSP_DIR%" | ||
( | ||
echo %USERNAME% | ||
echo %PASSWORD% | ||
echo zn "%NAMESPACE%" set st = $system.Status.GetErrorText($system.OBJ.ImportDir("%~dp0%BUILD_DIR%",,"ck",,1^^^)^^^) w "IMPORT STATUS: "_$case(st="",1:"OK",:st^^^), ! halt | ||
echo zn "%NAMESPACE%" set st = $system.Status.GetErrorText($system.OBJ.ImportDir("%~dp0%BUILD_DIR%",,"ck",,1^^^)^^^) w "IMPORT STATUS: "_$case(st="",1:"OK",:st^^^), ! | ||
echo s st = $system.Status.GetErrorText($system.OBJ.ExportPackage("%PACKAGE_NAME%", "%~dp0%XML_EXPORT_DIR%\%PACKAGE_NAME%-v"_##class(%PACKAGE_NAME%.Installer^^^).#VERSION_".xml"^^^)^^^) w $c(13,10^^^)_"EXPORT STATUS: "_$case(st="",1:"OK",:st^^^), ! halt | ||
) | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE% | ||
|
||
:: Other utilities that may be useful: | ||
:: | ||
:: Copy files to CSP folder | ||
::$ set BUILD_STATIC_DIR=build\static | ||
::$ set CSP_DIR=C:\Program Files\InterSystems\Ensemble\CSP\samples\EntityBrowser | ||
::$ call xcopy /sy "%~dp0\%BUILD_STATIC_DIR%" "%CSP_DIR%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
#!/usr/bin/env bash | ||
# This batch script makes the Caché application deployment much faster by building and importing the project. | ||
# Replace the variables below to match your Caché installation and build & import application to Caché using only one command. | ||
|
||
# Caché 2016.2+ IS REQUIRED TO PROCEED | ||
set +v | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH (folder that contains bin, CSP, mgr and other folders) | ||
# Configurable variables: change them to fit your system # | ||
CACHE_DIR=/InterSystems/Cache | ||
# NAMESPACE TO IMPORT PACKAGE TO | ||
NAMESPACE=SAMPLES | ||
# Other variables | ||
BUILD_DIR=build/cls | ||
BUILD_STATIC_DIR=build/static | ||
CSP_DIR=/InterSystems/Cache/csp/samples/EntityBrowser | ||
# Credentials | ||
USERNAME=_SYSTEM | ||
PASSWORD=SYS | ||
########################################################## | ||
|
||
set +v | ||
# Pre-configured variables | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
BUILD_DIR=build/cls | ||
XML_EXPORT_DIR=build | ||
PACKAGE_NAME=EntityBrowser | ||
|
||
# Build and import application to Caché | ||
echo "Importing project..." | ||
npm run gulp | ||
cp -R "$DIR/$BUILD_STATIC_DIR"* "$CSP_DIR" | ||
cat <<EOT | "$CACHE_DIR/bin/cache" -s "$CACHE_DIR/mgr" -U $NAMESPACE | ||
$USERNAME | ||
$PASSWORD | ||
zn "$NAMESPACE" set st = \$system.Status.GetErrorText(\$system.OBJ.ImportDir("$DIR/$BUILD_DIR",,"ck /checkuptodate=all",,1)) | ||
write "IMPORT STATUS: "_\$case(st="",1:"OK",:st), ! halt | ||
cat <<EOT | "$CACHE_DIR/bin/cache" -s "$CACHE_DIR/mgr" -U ${NAMESPACE} | ||
${USERNAME} | ||
${PASSWORD} | ||
zn "${NAMESPACE}" set st = \$system.Status.GetErrorText(\$system.OBJ.ImportDir("${DIR}/${BUILD_DIR}",,"ck /checkuptodate=all",,1)) | ||
write "IMPORT STATUS: "_\$case(st="",1:"OK",:st), \! | ||
s st = \$system.Status.GetErrorText(\$system.OBJ.ExportPackage("${PACKAGE_NAME}", "${DIR}/${XML_EXPORT_DIR}/${PACKAGE_NAME}%-v"_##class(${PACKAGE_NAME}.Installer).#VERSION_".xml")) w \$c(13,10)_"EXPORT STATUS: "_\$case(st="",1:"OK",:st), \! halt | ||
EOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Class EntityBrowser.Installer Extends %Projection.AbstractProjection [ DependsOn = Router ] | ||
{ | ||
|
||
Projection Reference As Installer; | ||
|
||
Parameter AppName = "EntityBrowser"; | ||
|
||
Parameter DispatchClass = "EntityBrowser.Router"; | ||
|
||
Parameter VERSION = "<!-- @echo package.version -->"; | ||
|
||
/// This method is invoked when this class is compiling. | ||
ClassMethod CreateProjection(cls As %String, ByRef params) As %Status | ||
{ | ||
write !, "Registering web application /" _ ..#AppName | ||
return ##class(WebAppManager).Register("/" _ ..#AppName, { | ||
"Description": ("A web application for Cache Entity Browser Project. You can change any " | ||
_ "properties of this application except of Dispatch Class property. To delete the " | ||
_ "application simply delete " _ ..#AppName _ " package, the web application will be " | ||
_ "deleted automatically."), | ||
"IsNameSpaceDefault": ($$$NO), | ||
"DispatchClass": (..#DispatchClass) | ||
}) | ||
} | ||
|
||
/// This method is invoked when a class is 'uncompiled'. | ||
ClassMethod RemoveProjection(cls As %String, ByRef params, recompile As %Boolean) As %Status | ||
{ | ||
return:recompile $$$OK | ||
write !, "Removing web application /" _ ..#AppName | ||
return ##class(WebAppManager).Delete("/" _ ..#AppName, { | ||
"DispatchClass": (..#DispatchClass) | ||
}) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// Application entry point. | ||
Class EntityBrowser.Router Extends (ServeXData, StaticData) | ||
{ | ||
|
||
XData UrlMap | ||
{ | ||
<Routes> | ||
<Map Prefix="/api" Forward="EntityBrowser.API"/> | ||
<Route Url="/(.*)" Method="GET" Call="Serve"/> | ||
</Routes> | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/cls/EntityBrowser/REST/StaticData.cls → src/cls/EntityBrowser/StaticData.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/// This class simplifies work with web applications. | ||
/// For Caché 2016.2+ | ||
/// @author ZitRo | ||
Class EntityBrowser.WebAppManager | ||
{ | ||
|
||
/// Registers new or updates existing web application with new config (as JSON dynamic object). | ||
/// List the properties you can assign to JSON object with the next command: | ||
/// %SYS > do ##class(Security.Applications).Get("/csp/user", .props) zw props | ||
/// | ||
/// Usage example: ##class(EntityBrowser.WebAppManager).Register("/name", { "NameSpace": "USER" }) | ||
ClassMethod Register(name As %String, config As %DynamicObject = {{}}) As %Status | ||
{ | ||
set ns = $Namespace | ||
new $Namespace | ||
try { | ||
set $Namespace = "%SYS" | ||
} catch (e) { | ||
return e.AsSystemError() | ||
} | ||
set st = $$$OK | ||
set spec("AutheEnabled") = $$$AutheCache // defaults | ||
set spec("NameSpace") = ns | ||
set iter = config.%GetIterator() | ||
while iter.%GetNext(.key, .value) { | ||
set spec(key) = value | ||
} | ||
if ('##class(Security.Applications).Exists(name)) { | ||
return ##class(Security.Applications).Create(name, .spec) | ||
} | ||
return ##class(Security.Applications).Modify(name, .spec) | ||
} | ||
|
||
/// Deletes the specified application only if it matches matchingConfig. | ||
/// If matchingConfig object is empty, deletes the application. You can specify only those matches | ||
/// you need to check. | ||
ClassMethod Delete(name As %String, matchingConfig As %DynamicObject = {{}}) | ||
{ | ||
new $Namespace | ||
try { | ||
set $Namespace = "%SYS" | ||
} catch (e) { | ||
return e.AsSystemError() | ||
} | ||
set st = $$$OK | ||
return:'##class(Security.Applications).Exists(name) | ||
do ##class(Security.Applications).Get(name, .spec) | ||
set iter = matchingConfig.%GetIterator() | ||
while iter.%GetNext(.key, .value) { | ||
return:($get(spec(key)) '= value) st | ||
} | ||
return ##class(Security.Applications).Delete(name) | ||
} | ||
|
||
} |