@adinsure-ops/ops-cli
v5.3.0
Published
Operations CLI for working with AdInsure
Readme
Operations CLI
Operations CLI for supporting AdInsure development processes.
https://www.npmjs.com/package/@adinsure-ops/ops-cli
Install
npm install -g @adinsure-ops/ops-cli
CLI development
For development you will need Node.js (recommended 20 LTS, minimal 18.0.0) and Yarn installed.
We recommend Visual Studio Code IDE.
To quick start development:
- Clone this repository (
git clone https://git.adacta-fintech.com/ops/ops-cli.git) - Open in VS Code
- Run
yarn install - For easier debugging, run
yarn link
You can run and debug commands directly from terminal by running ops [command] (if you yarn link-ed the package) or execute .\bin\run [command] (if you didn't). For debugging, you can follow oclif's documentation on how to turn on debug mode for a single command here.
Upgrade guilde
Upgrade to version 5.1.0
18 or higher is required.
Upgrade to version 5.0.0
Node 16, 18 or 20 is required.
Upgrade to version 4.0.0
We changed the way service principal login works. It is no longer needed to call login command for service principal login (for example in CI). Commands ops login --servicePrincipal -c ${AZURE_CLIENT_ID} -s ${AZURE_CLIENT_SECRET} should be removed, but AZURE_CLIENT_ID and AZURE_CLIENT_SECRET environment variables should exists, because OPS Cli uses it in background.
Commands
ops help [COMMAND]ops doctorops download:client <flags>ops download:identity-server <flags>ops download:platform <flags>ops download:scheduler <flags>ops download:server <flags>ops download:signalr <flags>ops download:studio <flags>ops download:keycloak-scim <flags>ops download:jmeter <flags>ops gitlab:get-tag-pipelineops gitlab:next-nightly-tagops log <issue> -t <type> -c [component]ops log:gen [options]ops log:validate [options]ops loginops login:ruops npm:check-publishops npm:publishops npm:dependency-updateops nuget:dependency-updateops prepare-contentops sql <type> <module> [flags]ops translateops version <type> [flags]ops config:set <type> <value>ops config:unset <type>ops config:get <type>ops config:list
ops help [COMMAND]
display help for ops
USAGE
$ ops help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI.See code: @oclif/plugin-help
ops doctor
check if everyting is installed
USAGE
$ ops doctor
OPTIONS
-p, --fix try to install missing packages.
EXAMPLE
$ ops doctorops download:client <flags>
download AdInsure Client zip from Azure storage
USAGE
$ ops download:client <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLE
$ ops download:client -v 3.2.0 -o ~/Downloads
$ ops download:client -v 3.2.0 -s gitlabruops download:identity-server <flags>
download AdInsure Identity Server zip from Azure storage
USAGE
$ ops download:identity-server <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLE
$ ops download:identity-server -v 3.0.3 -o ~/Downloads
$ ops download:identity-server -v 3.0.3 -s gitlabruops download:platform <flags>
download AdInsure Platform bundle containing zip of Client, Server IdentityServer and SignalR from azure storage
USAGE
$ ops download <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
ALIASES
$ ops download
EXAMPLE
$ ops download -v 6.0.0 -o ~/Downloads
$ ops download -v 6.0.0 -s gitlabruops download:scheduler <flags>
download AdInsure Scheduler zip from azure storage
USAGE
$ ops download:scheduler <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLE
$ ops download:scheduler -v 3.2.0 -o ~/Downloads
$ ops download:scheduler -v 3.2.0 -s gitlabruops download:server <flags>
download AdInsure Server zip from Azure storage
USAGE
$ ops download:server <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLE
$ ops download:server -v 3.2.0 -o ~/Downloads
$ ops download:server -v 3.2.0 -s gitlabruops download:signalr <flags>
download AdInsure SignalR zip from Azure storage
USAGE
$ ops download:signalr <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
-s, --source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLE
$ ops download:signalr -v 18.0.0 -o ~/Downloads
$ ops download:signalr -v 18.0.0 -s gitlabruops download:studio <flags>
download AdInsure Studio vsix from azure storage
USAGE
$ ops download:studio <flags>
OPTIONS
-k, --keep only with install. If passed, it will not remove the vsix file.
-i, --install install plugin to vscode. save to temp folder and remove vsix after.
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-s, --skip only with install. If passed, and desired version is installed it will skip it.
-v, --version=version (required) version we want to download.
-f, --force Create output directory if it does not exist. By default this is false and it depends on the output switch.
--source=source [default: azure] artifact source. (can be configured via 'config:set endpoint')
EXAMPLES
$ ops download:studio -v 15.0.0 -o ~/Downloads
$ ops download:studio -v 15.0.0 -i
$ ops download:studio -v 15.0.0 -i -s
$ ops download:studio -v 15.0.0 --source=gitlabruops download:keycloak-scim <flags>
Download the Keycloak scim zip for AdInsure server
USAGE
$ ops download:keycloak-scim <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
-v, --version=version (required) version we want to download.
EXAMPLES
$ ops download:keycloak-scim -v 3.2.0 -o ~/Downloads
$ ops download:keycloak-scim -v 3.0.0 ops download:jmeter <flags>
Download the Jmeter examples zip
USAGE
$ ops download:jmeter <flags>
OPTIONS
-o, --output=output [default: ./] output directory. (can be configured via 'config:set download_folder')
EXAMPLES
$ ops download:jmeter -o ~/Downloadsops gitlab:get-tag-pipeline
get pipeline status for tag
USAGE
$ ops gitlab:get-tag-pipeline <tag>
ARGUMENTS
TAG Tag
OPTIONS
--delay=delay [default: 5] Delay of check in seconds (defaults to 5 seconds).
--host=host (required) [default: https://git.adacta-fintech.com] Server hostname.
--pat=pat (required) Token from user that has permissions to list and create tags.
--project=project (required) [default: 413] Project ID.
--timeout=timeout [default: 120] Timeout for wait command in seconds (defaults to 120 seconds).
--wait Wait for pipeline to finish.ops gitlab:next-nightly-tag
creates new gitlab tag
USAGE
$ ops gitlab:next-nightly-tag <version>
ARGUMENTS
VERSION Tag version
OPTIONS
--dryRun Only printout version and don't create it.
--host=host (required) [default: https://git.adacta-fintech.com] Server hostname.
--pat=pat (required) Token from user that has permissions to list and create tags.
--project=project (required) [default: 413] Project ID.
--reference=reference (required) Reference to create tag on (branch, commit, tag).ops jira:issue <issue>
get Jira issue
USAGE
$ ops jira:issue <issue>
ARGUMENTS
ISSUE Jira issue number
OPTIONS
--hostname=hostname [default: https://jira.adacta-fintech.com] jira hostname.
--password=password (required) jira password.
--username=username (required) jira username.
EXAMPLE
$ ops jira:issue LJADIRD-1337ops jira:issue <issue> -a [label] -r [label]
list or edit labels on Jira issue
USAGE
$ ops jira:labels <issue> -a [label] -r [label]
ARGUMENTS
ISSUE Jira issue number
OPTIONS
-a, --add=add add label.
-r, --remove=remove remove label.
--hostname=hostname [default: https://jira.adacta-fintech.com] jira hostname.
--password=password (required) jira password.
--username=username (required) jira username.
EXAMPLE
$ ops jira:labels LJADIRD-1337ops log <issue> -t <type> -c [component]
creates a new changelog entry
USAGE
$ ops log <issue> -t <type> -c [component]
ARGUMENTS
ISSUE Jira issue number.
TYPE (feature|fixed|improve|breaking) Change type.
COMPONENT (Configuration|DevOps|Implementation|Platform) Component for which new changelog should be generated.
OPTIONS
-c, --component=component Component for which new changelog should be generated.
-t, --type=feature|fixed|improve|breaking (required) type of changelog.
-d, --description=description Description of a changelog.
-f, --force Create logs directory if it does not exist.
ALIASES
$ ops log
$ ops log:add
EXAMPLES
$ ops log LJADIRD-1234 -t feature
$ ops log LJADIRD-5678 -t fixed
$ ops log LJADIRD-8765 -t breaking -c Platform
$ ops log LJADIRD-5678 -t fixed -d "Fixed my bug"
$ ops log LJADIRD-4321 -t improve -c Configurationops log:gen [options]
generates final changelog from unreleased notes on the root, final changelog for implementation component is placed under basic/Changelog.md
USAGE
$ ops log:gen [options]
OPTIONS
-c, --components=components components separated by comma (,) to process for final changelog.
-f, --file=file [default: CHANGELOG.md] file to update with new changelogs.
-p, --preview generates a preview markdown of current unreleased changelogs.
-v, --version=version version for which you're generating changelogs.
--force update target file without prompting for confirmation.
--ignore-no-changelogs generate final changelog even if no unreleased changelogs exist.
ALIASES
$ ops log:gen
EXAMPLE
$ ops log:gen
$ ops log:gen -p
$ ops log:gen -c Platform
$ ops log:gen -c Platform,Configuration
$ ops log:gen -c Implementation -f CHANGELOG.Implementation.mdops log:validate [options]
validates formatting of all unreleased changelogs:
- 2.4.2 - added an exit statement that will force exit on changelog validation errors, preparing it for CI
USAGE
$ ops log:validate [options]
ALIASES
$ ops log:validate
EXAMPLE
$ ops log:validateops login
log in to use ops services
USAGE
$ ops login
OPTIONS
--deviceFlow authenticate using device flow
--force Force a change of login token
--npm register also for npm
--skipCI=<value> Skip login if environment variables is set
EXAMPLES
$ ops login
$ ops login --npm
$ ops login --skipCi CI
$ ops login --deviceFlowops login:ru --token <token>
Log in to use OPS services with a GitLabRu token.
USAGE
$ ops login:ru --token <token> [--force]
OPTIONS
--token=token (required) The GitLabRu token to store.
--force Force update of the stored token.
ALIASES
$ ops login:ru
EXAMPLES
$ ops login:ru --token abc123
$ ops login:ru --token xyz789 --forceops npm:check-publish
check if npm packages were published
USAGE
$ ops npm:check-publish [options]
OPTIONS
-p, --package=package package name filter you want to check.
-v, --version=version (required) version we want to check if published.
-x, --exclude=exclude exclude packages from filter.
--pat=pat PAT token or AZURE_DEVOPS_EXT_PAT environment variable.
EXAMPLES
$ ops npm:check-publish -v 6.0.1
$ ops npm:check-publish -p @adinsure/* -v 6.0.0
$ ops npm:check-publish -p @adinsure/* -x @adisure/demo -v 6.0.0ops npm:publish
publish npm packages
USAGE
$ ops npm:publish [options]
OPTIONS
-p, --package=package package name filter you want to check.
-v, --version=version (required) version we want to check if published.
-x, --exclude=exclude exclude packages from filter.
--pat=pat PAT token or AZURE_DEVOPS_EXT_PAT environment variable.
EXAMPLES
$ ops npm:publish -v 15.0.0
$ ops npm:publish -v 15.0.0
$ ops npm:publish -p @adinsure-tooling/* -v 15.0.0
$ ops npm:publish -p @adinsure-tooling/* -x @adisure-tooling/studio-services -v 6.0.0ops npm:dependency-update
update npm dependencies per package filter
USAGE
$ ops npm:dependency-update <type> [flags]
ARGUMENTS
VERSION Type of release
OPTIONS
--exclude=exclude exclude directories where to search for package.json.
--filter=filter (required) regular expression for which NPM packages to update.
EXAMPLE
$ ops npm:dependency-update 3.4.3 --filter @adinsure/*ops nuget:dependency-update
update nuget dependencies per package filter
USAGE
$ ops nuget:dependency-update <type> [flags]
ARGUMENTS
VERSION Type of release
OPTIONS
--exclude=exclude exclude directories where to search for csproj files.
--filter=filter (required) regular expression for which NuGet packages to update.
EXAMPLE
$ ops nuget:dependency-update 3.4.3 --filter Adacta.AdInsure --exclude Schedulerops version <type>
creates everything necessary for the new release
USAGE
$ ops version <type> [flags]
ARGUMENTS
TYPE (patch|minor|major|prerelease|preminor|premajor|new) Type of release
OPTIONS
-i, --independent increment npm packages independent of VERSION file.
-v, --version=version force version.
--no-deps skip dependency update.
--no-script skip creation of script.
--only-npm-packages=only-npm-packages [default: .*] regular expression for which NPM packages to include.
--script-prefix=script-prefix [default: 7.10] prefix for db script version creation.
--exclude-dir exclude directories where to search for package.json.
EXAMPLES
$ ops version minor
$ ops version new-version -v 3.4.0
$ ops version new-version -v 3.2.1 --script-prefix 7.10
$ ops version patch --no-deps
$ ops version patch --no-script
$ ops version new -v 3.2.1 --only-npm-packages "@adinsure/"prerelease is generated from YearMonth incremental number (example: 201909.1) or RC (example: rc.0). prereleases generated in same month will have only last number incremented and first prerelease generated in next month will bump first number and start with 0 (example: 201910.0)
patch increments third number and prerelease number is ommited. (example: 3.4.0-201909.2 -> 3.4.0 and 3.3.11 -> 3.3.12)
preminor increments for prerelease in second number (example: 3.2.3 -> 3.3.0-201910.0)
minor increments second number (example: 3.4.3 -> 3.5.0)
premajor increments to prerelease in first number (example: 3.4.3 -> 4.0.0-201911.0)
major increments first number (example: 3.4.5 -> 4.0.0)
new-version allows setting own version regardles of VERSION file. Incrementing NPM version separately is not supported in this case. NPM packages are also bumped to specified version.
Prerelease Note: Prerelease should only be user in master branch. \ Patch Note: Patch is used on release/x.x branches for creating patch releases When creating new release/x.x branch 2 steps are needed:
- creating patch version on release/x.x branch
- creating preminor or premajor version on master branch \ Dependencies for packages are updated on all package.json files. If prerelease version in specified full version is specified (example: 4.0.0-201911.0), or if non prerelease version ends with x (example: 3.5.x) \ NPM packages node: For npm package to update properly wsrun-version preset needs to be in scripts portion of package.json. (example:
"wsrun-version": "yarn wsrun -p @adinsure-tools/* -p @adinsure/* -c")
ops prepare-content -d <destination> -s [source]
creates a directory/file structure from /source to /destination</source> as defined in the .opsprepare file. Actual
destination path for each file will be specified destination path with appended relative path from working directory where command is executed to specified source directory or current directory (if source is not specified). Be careful about using
.. notation in target and source paths as it may lead to unpredictable results due to relative path resolving.
Introduced in version 3.1.0.
USAGE
$ ops prepare-content -d <destination> -s [source]
OPTIONS
-d, --destination=destination path to target directory.
-s, --source=source optional path to source directory containing .opsprepare file, (default: current directory).
EXAMPLES
$ ops prepare-content -d ./target_directory/
copies everything defined in .opsprepare
from current directory
to ./target_directory
$ ops prepare-content -d ./target_directory/ -s ./source_directory
copies everything defined in ./source_directory/.opsprepare
from ./source_directory/
to ./target_directory/source_directory
$ ops prepare-content -d C:\git\target_directory
copies everything defined in .opsprepare
from current directory
to C:\git\target_directory
$ ops prepare-content -d C:\git\target_directory -s C:\git\subfolder\subfolder
when executed in c:\git it copies everything defined in C:\git\subfolder\subfolder\.opsprepare
from C:\git\subfolder\subfolder
to C:\git\target_directory\subfolder\subfolder.opsprepare dotfile
The prepare-content command uses .opsprepare dotfile as instruction set for content preparation.
The syntax resembles that of .gitignore but differs in how it functions and doesn't support advanced
pattern matching.
Following operations/transformations are currently supported:
- Copy: copies the file/directory from source path to destination path with same name
- Transform: transform source file to destination file with same name
- Removal: remove file/directory (based on source path) from destination path
Before diving into the actual syntax and supported tokens let's look at an example
of how using ops prepare-content creates a target directory structure with files
based on the specified .opsprepare file residing in source directory.
This is the example source directory structure:
src_data
├── .opsprepare
├── README.tpl
├── bin
│ ├── ops.sh
│ └── run
│ └── ops
├── dist
│ └── server
│ └── main.cs
├── src
│ ├── commands
│ │ ├── prepare.ts
│ │ └── version.ts
│ ├── config.ts
│ └── main.ts
└── transform
└── render-tpl.jsContents of .opsprepare file in the src_data directory:
# Comment
src
dist/server
!src/commands
!src/config.ts
src/config.ts {cp:/src/configuration.ts}
# Another comment
!bin/run
README.md {js:/transform/render-tpl.js}
README.tpl {cp:/README.tpl.src}Running ops -s src_data -d dst_data with src_data/.opsprepare containing above content
results in:
dst_data
└── src_data
├── README.md
├── README.tpl.src
├── dist
│ └── server
│ └── main.cs
└── src
├── main.ts
└── src
└── configuration.tsWhat actually happened:
- First note that all data was copied into
dst_data/src_databecause.opspreparefiles relative location toopsexecution directiory issrc_data. srcdirectory was copied recursively to destinationdist/serverdirectory was copied recursively including its full path path relative tosrc_datasrc/config.tsfile was transformed (copied) tosrc/configuration.tsin the destinationREADME.mdfile was created at the destination as a result of JavaScript based transformationREADME.tplfile was transformed (copied) toREADME.tpl.srcin the destinationsrc/commandsdirectory was removed from destinationsrc/config.tsfile was removed from destinationbin/rundirectory was removed from destination
Note that copying and explicit transformations are performed before any removal operations.
Comments
Any line prefixed by # is considered a comment and will not result in any file/directory operation.
Copy operations
Any file/directory not prefixed by ! or # having explicit transformation defined in {...} after
its name will be copied to the destination with it's full path relative to ops execution directory
to the target directory.
Transformation operations
Transformation operations are always specified using curly braces following the source file name. Base syntax looks like this:
{<transformation type>:<transformation parameters>}Two types of transformation operations are supported:
- cp: copy transformation which supports renaming of the source file at the destination
- js: JavasSript based transformation which results in the file containing string returned by the transformation function contained in transformation module.
cp - copy transformation syntax
{cp:<destination path>}
Examples:
{cp:/dst/newfilename}
{cp:dst/newfilenames}Copy transformation is supported for both files and directories. Source file or directory will be
copied to the destination path with its new name. The destination will always be relative to the
destination path of entire prepare-content operation therefore paths in the transformation block
can start with or without the / character but using makes the syntax more readable.
js - JavaScript transformation syntax
{js:<transformation_module_path>}
Example:
{js:/transformations/templateRenderer.js}JavaScript transformation is supported only for files, not directories.
Transformation module path should be relative to .opsprepare file but can start with / character
for better readability. It can export multiple functions though only one can be used in single
transformation specification.
Transformation function that is defined in the transformation module will be called with a single parameter - absolute path of the source file.
Transformation function MUST return a string. This string will become the content of the file on destination.
Destination file will be created with the same name as source file and content returned by the
transformation function. The existence of actual source file will not be validated by the
prepare-content operation (warning is shown if it doesn't exist), such validation is responsibility
of the transformation function if required.
Example transformation module transform.js with exported function called render:
export default function render(path) {
/*
Some transformation happens in here and it's result which is
a string is assigned to result variable which is returned.
*/
return result;
}An important thing to note is that you can only export one default function in a module, so defining multiple functions in one file that call each other is possible, however defining multiple default exports is not and therefore there can only be one function that will be called in a module file.
Removal operations
Any file/directory prefixed by ! will be removed from the destination based on it's full path
relative from ops execution directory to source file/directory path.
ops sql <type> <module> [flags]
creates a new database script
USAGE
$ ops sql <type> <module> [flags]
ARGUMENTS
TYPE (Schema|Data|Migration|Extend) Type of database scripts
MODULE (acc|claims|core|pas|reins|shared) Module of data database scripts
OPTIONS
-d, --description=description description of script to be used in filename for offline.
-l, --layer=layer name of the configuration layer for which you are generating database script.
-m, --major generate script for major version.
-o, --offline generate database script with timestamp.
-v, --version=version version for which you're generating database script.
Extend type options for extending DBs:
--table-schema table schema name
--table-name table name
--column-name new column's name
--column-type new column's type
EXAMPLES
$ ops sql schema
$ ops sql data shared --layer basic
$ ops sql data shared --major
$ ops sql data shared --offline --description "this is script description"
$ ops sql Extend -v 22.0.0 -l basic --table-schema "Table_Shema" --table-name "Table_Name" --column-name "New_Column_Name" --column-type "NEWTYPE"Note: version if not provided is taken from file
SQL_SCRIPTS_VERSION,PLATFORM_VERSIONorVERSIONin order.
ops translate
downloads translate from AdDictionary service
USAGE
$ ops translate <language> [flags]
ARGUMENTS
LANGUAGE language id you want to download. Values must be semi-colon (;) separated.
OPTIONS
-f, --format=json|xml (required) translations format [xml - server translations, json - client translations].
-m, --module=module module name you want to download. Values must be semi-colon (;) separated.
-o, --output=output [default: .] absolute or relative destination path to a folder where translations are extracted.
--filename=filename specify filename of output (XML only).
--respectServerFilename respect filename that is returned from AdDictionary server (XML only).
EXAMPLES
$ ops translate "en-US=en-US;ru-Ru=ru-RU" -f json -m "Client business accounting;Client business base;"
$ ops translate "en-US=en-US;ru-Ru=ru-RU" -f xml -o translationDestinationops config:set <type> <value>
Set a configuration value for OPS.
USAGE
$ ops config:set <type> <value>
OPTIONS
type (required) Type of OPS configuration. Available options: [endpoint, download_folder].
value (required) Possible configuration values. Available options for endpoint: [azure, gitlabru]. Expects a valid path for download_folder.
ALIASES
$ ops config:set
EXAMPLES
$ ops config:set endpoint gitlabru
$ ops config:set endpoint azure
$ ops config:set download_folder ./Downloadsops config:unset <type>
Remove a configuration value so that the system default is used.
USAGE
$ ops config:unset <type>
OPTIONS
type (required) Type of OPS configuration. Available options: [endpoint, download_folder].
ALIASES
$ ops config:unset
EXAMPLES
$ ops config:unset endpoint
$ ops config:unset download_folderops config:get <type>
Retrieve a configuration value for OPS.
USAGE
$ ops config:get <type>
OPTIONS
type (required) Type of OPS configuration to retrieve. Available options: [endpoint, download_folder].
ALIASES
$ ops config:get
EXAMPLES
$ ops config:get endpoint
$ ops config:get download_folderops config:list
List all OPS configuration values stored in the config file.
USAGE
$ ops config:list